Mosaic CLI Docs 中文

Playbook

Azure End-to-End Operations Playbook

Run this once to build a production-grade baseline: Azure profile, model routing, channels, gateway, safety policy, observability, and regression gates.

Important: Azure base URL should be https://<resource>.openai.azure.com/openai/v1. Do not append another /v1.

Step 0: Environment prerequisites

mosaic --version
mosaic --project-state directory --ensure --check-writable

export AZURE_OPENAI_BASE_URL="https://<resource>.openai.azure.com/openai/v1"
export AZURE_OPENAI_API_KEY="<your_key>"
# optional: run one command for the whole playbook
cd cli
./scripts/azure_ops_playbook.sh --profile az-openai --run-regression
# machine-readable summary output
./scripts/azure_ops_playbook.sh \
  --profile az-openai \
  --json-summary \
  --summary-out reports/azure-playbook-summary.json

Step 1: Create Azure profile

mosaic --project-state --profile az-openai setup \
  --base-url "$AZURE_OPENAI_BASE_URL" \
  --api-key-env AZURE_OPENAI_API_KEY \
  --model gpt-4o-mini

mosaic --project-state --profile az-openai configure --show

Step 2: Verify model visibility and routing

mosaic --project-state --profile az-openai models list
mosaic --project-state --profile az-openai models status
mosaic --project-state --profile az-openai models aliases set fast gpt-4o-mini
mosaic --project-state --profile az-openai models fallbacks add gpt-4.1-mini
mosaic --project-state --profile az-openai models aliases list
mosaic --project-state --profile az-openai models fallbacks list

Step 3: Core ask/chat/session chain

mosaic --project-state --profile az-openai ask "hello from azure profile"
mosaic --project-state --profile az-openai chat
mosaic --project-state --profile az-openai session list

Step 4: Add channels

# terminal channel (always recommended)
mosaic --project-state channels add --name local-terminal --kind terminal

# optional Slack webhook channel
mosaic --project-state channels add \
  --name team-slack \
  --kind slack_webhook \
  --endpoint https://hooks.slack.com/services/XXX/YYY/ZZZ

# optional Telegram bot channel
export MOSAIC_TELEGRAM_BOT_TOKEN=<bot_token>
mosaic --project-state channels add \
  --name team-telegram \
  --kind telegram_bot \
  --chat-id <chat_id> \
  --token-env MOSAIC_TELEGRAM_BOT_TOKEN

mosaic --project-state channels list
mosaic --project-state channels status

Step 5: Test channel delivery

mosaic --project-state channels test <channel_id>
mosaic --project-state channels send <channel_id> --text "azure playbook send ok"
mosaic --project-state channels logs --channel <channel_id> --tail 20

Step 6: Operate gateway lifecycle

mosaic --project-state gateway install --host 127.0.0.1 --port 8787
mosaic --project-state gateway start
mosaic --project-state gateway probe
mosaic --project-state gateway call status --params '{"detail":true}'
mosaic --project-state gateway health --verbose

Step 7: Apply safety baseline

mosaic --project-state approvals set confirm
mosaic --project-state approvals allowlist add "git status"
mosaic --project-state sandbox set standard
mosaic --project-state safety check --command "git status"
mosaic --project-state safety check --command "curl https://example.com"

Step 8: Observability baseline

mosaic --project-state status
mosaic --project-state health
mosaic --project-state doctor
mosaic --project-state logs --tail 120
mosaic --project-state dashboard
mosaic --project-state safety report --audit-tail 50 --compare-window 24h

Step 9: Regression gate before release

cd cli
./scripts/run_regression_suite.sh

# optional live smoke with your Azure profile
LIVE=1 \
BASE_URL="$AZURE_OPENAI_BASE_URL" \
API_KEY_ENV=AZURE_OPENAI_API_KEY \
MODEL=gpt-4o-mini \
./scripts/tutorial_regression.sh --profile az-openai

Acceptance checklist

  • Azure profile passes setup/models list/ask.
  • At least one channel passes test + send.
  • Gateway probe + call are healthy.
  • Policy baseline active: approvals=confirm, sandbox=standard.
  • Regression scripts complete without critical failures.