Add console global flags (--console-region, --console-site, --console-switch-agent)
to the options of all 12 commands that depend on callConsoleGateway, so they appear
in --help output. Document this as convention #4 in AGENTS.md for future commands.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Eliminate per-command --region/--site/--switch-agent duplication across 11 console gateway commands.
These values now flow through config (CLI flags → config file → defaults) and are consumed by
callConsoleGateway automatically. Also wire consoleSite into resolveConsoleOrigin so --console-site
selects the correct login URL (domestic vs international).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adapts to bailian-cli-login af06baf which added workspace_id to the
notifyToken payload. The field is parsed from query/body and written
to config.json as workspace_id.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Field was replaced by region+site gateway resolution but ConfigFile
definition, parseConfigFile logic, and test case were left behind.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Export validateAndPersistApiKey from login-console.ts and reuse in
login.ts. Remove duplicated canRetry, RETRY_DELAY_BASE_MS, and
validateKeyAndPersist from login.ts. Unify validation model to
qwen3.7-max. Reorder base_url write before apiKey validation in
the --api-key path to avoid double read-modify-write.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When used with --api-key, validates the key against the specified
base URL and persists it to config.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move apiKey validation into login-console.ts so it uses the baseUrl
from the same callback (not stale config). All fields are now persisted
in one place: config fields first, then apiKey validated + written.
Remove onApiKey callback indirection from runConsoleLogin signature.
Clean up debug logging.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These fields were only extracted from query params but the console
sends them in the JSON POST body. Add parseExtrasFromRawBody() to
handle JSON and form-urlencoded bodies.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract hasConfig variable to deduplicate the multi-field condition check,
remove the changed flag pattern in favor of direct write-through.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Console gateway URL and action are now resolved from a region + site
mapping table instead of a single hardcoded config value. Supports
cn-beijing and ap-southeast-1 with domestic/international site variants.
- Add ConsoleSite type, REGION_GATEWAYS mapping, and resolveGateway()
- Add switchAgent to cornerstoneParam for delegated access
- Add console_site, console_region, console_switch_agent to config
- Remove consoleGatewayUrl from Config (replaced by region+site resolution)
- login-console callback now persists baseUrl, site, region, switchAgent
- bl console call gains --site and --switch-agent flags
- All callers delegate region default to callConsoleGateway (no more hardcoded cn-beijing)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>