Repository navigation
Conversation
The bundled provider catalog ships account:zai-start-plan / account:bigmodel-start-plan (e.g. the ZCODE WEEKEND BUILD token promos), and Desktop's host registers them whenever the account is entitled, but the standalone account paths only enumerate Individual Coding Plan providers, so the CLI fails with 'Provider Registry 中不存在 Model'. Five minimal edits, AST-anchored on the existing bundler labels: - readStandaloneCodingPlanCatalog: enumerate Start Plan providers too - resolveStandaloneCodingPlanProvider: keep login's one-provider-per-family contract by excluding Start Plan ids - standaloneAccountIdentityCredentialKey: map Start Plan providers to the family's Coding Plan identity (the identity is account-scoped) - createStandaloneProviderRuntimeHeadersPort: accept the Start Plan access mode, and authenticate Start Plan requests with the zcode-scoped JWT credential, since zcode.z.ai/api/v1/zcode-plan rejects the Coding Plan api-key and the exchanged api.z.ai project JWT with 401 No protocol changes: requests are still built and signed by the genuine runtime. Registered as an optional patch with a behavioral test (test/runtime/start-plan.test.ts) covering the fixture patch, identity mapping and idempotency.
|
Thanks @Erencv — the investigation in #248 and this PR was very helpful, especially identifying the standalone catalog gates and the ZCode JWT required by Start Plan. I've opened #251 as a maintainer follow-up to integrate this with our existing shared OAuth flow. It keeps one account login for both plans, handles Desktop-only sessions without aliasing Coding Plan identities, and selects the Start Plan JWT before any Coding Plan project-token resolution. It also covers account switching, rejected/missing sessions, and JWTs without an optional I've now verified locally that Start Plan works with my account, and the automated regression suite also passes (158 tests). Your work is credited in the new PR and commit message, and I'd appreciate your review there. Once #251 is merged, we can close this PR as superseded. Thanks again for getting this started! |
Reuse the existing ZCode account session for standalone Start Plan providers without aliasing Coding Plan identities, exchanging project tokens, or falling back to paid credentials. Guard account changes, cancellation and rejected sessions, and support JWTs without optional expiry claims. Follow up on #248 and #249; thanks to Erencv for investigating the standalone gates and identifying the ZCode JWT credential.
Draft — opened alongside #248 for early feedback; I'll finalize (or withdraw, or retarget upstream) per maintainer guidance.
What this does
Makes
account:zai-start-plan/account:bigmodel-start-planproviders usable in standalone mode (CLI + TUI) when the account is entitled to them — e.g. Z.ai's ZCODE WEEKEND BUILD promos, which today are Desktop-only. Full analysis, evidence and reproduction in #248.How it works
The runtime already ships everything needed: the bundled catalog contains the start-plan providers, the OpenAI-compatible request path branches on
accountAccess.mode === "start-plan"(retry/captcha recovery), and the signed-header transport is provider-agnostic. Only the standalone account plumbing refuses to see the mode. Following the existingruntime-*-patches.tsconventions (acorn-anchored on bundler labels, exact-shape matching,incompatible()on drift),runtime-start-plan-patches.tsmakes five minimal edits:readStandaloneCodingPlanCatalogstart-planproviders besideindividual-coding-plan, so they reach the registry and get an entitlement computedresolveStandaloneCodingPlanProviderstandaloneAccountIdentityCredentialKeycreateStandaloneProviderRuntimeHeadersPortstart-planaccess mode inrefreshBeforeModelRequestcreateStandaloneProviderRuntimeHeadersPortzcodejwttokencredential —zcode.z.ai/api/v1/zcode-plan/*rejects both the Coding Plan api-key (manual path) and the exchanged api.z.ai project JWT (OAuth path) with 401No protocol changes: requests are still built, anti-bot-signed and sent by the genuine runtime. Billing is domain-isolated (
zcode-planendpoints can only draw start-plan buckets), so this cannot silently spend the paid plan.Registration
sync-runtime.ts: newstart-plan-standaloneentry,requirement: "optional",verify: hasRuntimeStartPlan— if a future upstream runtime ships native support (or renames the anchors), the patch skips/fails loudly instead of corrupting the bundle.Testing
test/runtime/start-plan.test.ts:has*flips, idempotentstandaloneAccountIdentityCredentialKeymapsaccount:zai-start-plan/account:bigmodel-start-planto the family Coding Plan identity key and leaves other providers untouchedvendor/zcode.cjsships the support aftersyncbun test test/runtime/start-plan.test.ts→ 3 passZCODE_NODE=node bun bin/zcode.ts --model account:zai-start-plan/GLM-5.3-Flash --prompt 'Reply with exactly: ok'→ok, exit 0/modellistsaccount:zai-start-plan/GLM-5.3-Flash,GLM-5.2,GLM-5-Turbo; switching and real turns work; Desktop's Start Plan balance decreases accordinglyNotes for review
fetchhook + curl matrix againstzcode-plan/anthropic/v1/messages— see Standalone CLI cannot use z.ai Start Plan providers (e.g. ZCODE WEEKEND BUILD) — analysis + proposed patch #248); if you'd prefer a different credential strategy (e.g. deriving a plan-scoped token from the OAuth access token), I'm glad to rework.bun lockfileuntouched; no new dependencies (reusesacornalready used byruntime-shared-oauth-patches.ts).entitledfrom stored credentials (identity + OAuth token), exactly as it already does for the coding plan.