@mars-sea/dsh-commandcode-provider 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -29,7 +29,7 @@ interface RequestTimingSummary {
29
29
  type RequestTimingSink = (summary: RequestTimingSummary) => void | Promise<void>;
30
30
  //#endregion
31
31
  //#region src/adapter.d.ts
32
- declare const COMMAND_CODE_CLI_VERSION = "1.72.1";
32
+ declare const COMMAND_CODE_CLI_VERSION = "1.73.0";
33
33
  declare const DEFAULT_API_BASE = "https://api.commandcode.ai";
34
34
  /**
35
35
  * The output budget this bundle asks for, and the ceiling it will never exceed.
@@ -47,9 +47,16 @@ declare const DEFAULT_API_BASE = "https://api.commandcode.ai";
47
47
  * (a 64 000 request answered headers in 1.28 s against 1.57 s for 131 072) but
48
48
  * it did cap what a model could ever say in one turn.
49
49
  *
50
- * This is only an UPPER bound. `requestContextBudget` lowers it per request
51
- * from the prompt actually being sent, so raising the ceiling cannot push a
52
- * large session over its window.
50
+ * No client-side clamp is applied on top of this: an earlier version pre-shrank
51
+ * `max_tokens` from an estimate of the prompt already sent (`requestContextBudget()`,
52
+ * issue #67), but that estimate over-corrected on ordinary long conversations —
53
+ * exactly the "output gets cut short as the conversation grows" symptom issue #74
54
+ * reported — while a live A/B probe (2026-09-30, `stealth/space-bunny-alpha`,
55
+ * ~19.6% over its 1,000,000-token window with no client-side shrink) showed the
56
+ * endpoint answers a genuine overflow with an unambiguous `400 … exceeds the
57
+ * model's context window`, which `isContextOverflowDetail()` below already
58
+ * classifies as `CONTEXT_WINDOW_EXCEEDED` independently of this constant. See
59
+ * [决策记录](../docs/决策记录.md).
53
60
  */
54
61
  declare const DEFAULT_GENERATE_MAX_TOKENS = 131072;
55
62
  /**
@@ -441,6 +448,8 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
441
448
  imageRequestPricing(_provider: string, model: string): LlmImageRequestPricing | undefined;
442
449
  /** 地址或缓存文件变化时丢弃旧目录,防止旧网关的路由声明影响新请求。 */
443
450
  private currentCatalogState;
451
+ /** 直接生成也使用本地可信目录,不额外联网;并发冷请求共用一次文件读取。 */
452
+ private catalogForGenerate;
444
453
  /** 共享一次刷新;调用者取消只结束自己的等待,不取消其他调用者的请求。 */
445
454
  private loadCatalog;
446
455
  listModels(provider: string, opts?: {
@@ -450,9 +459,8 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
450
459
  * The per-model allowance bracket this account POOL falls into, or undefined
451
460
  * when there is nothing honest to show.
452
461
  *
453
- * The pricing page publishes a per-model monthly allowance for GOAT and Pro
454
- * only — its own words are "the boost is a per-model allowance, so it lives on
455
- * the plans that have them" — so a pool whose highest plan is Go, Provider,
462
+ * The pricing page publishes per-model monthly allowances for Go, GOAT and
463
+ * Pro. A pool whose highest plan is Provider,
456
464
  * Max or Ultra gets undefined rather than a neighbouring tier's figure. Taking
457
465
  * the HIGHEST tier matches the question the picker already answers for a pool
458
466
  * (see `modelVisibleForAnyAccount`): what the user can reach, not what the one
@@ -460,7 +468,7 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
460
468
  * too — an unreachable billing endpoint yields undefined, which hides the
461
469
  * allowance instead of inventing one.
462
470
  */
463
- allowanceTier(): Promise<'goat' | 'pro' | undefined>;
471
+ allowanceTier(): Promise<'go' | 'goat' | 'pro' | undefined>;
464
472
  resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
465
473
  /** The headers every authenticated account endpoint shares. */
466
474
  private accountHeaders;
@@ -803,6 +811,26 @@ declare class CommandCodeAccountPool {
803
811
  key: string;
804
812
  slot: CommandCodeAccountSlot;
805
813
  } | undefined>;
814
+ /**
815
+ * Which account is serving right now, for display (the settings page's
816
+ * account card, the sidebar usage stats) — without consuming a request's
817
+ * `tried` budget and without throwing when nothing can serve.
818
+ *
819
+ * Reads and self-heals exactly like {@link resolveKey} would: an `unknown`
820
+ * mark on the pinned account is re-probed (throttled the same way, sharing
821
+ * the same per-key timestamp), and a pool where nothing currently resolves
822
+ * gets one batch probe pass too. Without this, the badge read a possibly
823
+ * stale mark forever — nothing but an actual generate request ever cleared
824
+ * an `unknown` mark, so a page left open with no chat activity kept
825
+ * showing "switched to the fallback account" long after a real request
826
+ * would have quietly recovered (issue #51's follow-up report: the account
827
+ * card and the sidebar stats both stuck on the wrong account).
828
+ *
829
+ * No `model` parameter: the badge describes the pool as a whole, not one
830
+ * request, so model-routing rules are deliberately not consulted here —
831
+ * matching what the direct `selectActiveAccount` call this replaces did.
832
+ */
833
+ activeAccount(): Promise<ResolvedAccount | undefined>;
806
834
  /**
807
835
  * Record a rejection against one key. A `throttled` rejection (the plain 429
808
836
  * that named no window) marks the key with the `throttle` cause, leaving
@@ -868,6 +896,26 @@ declare class CommandCodeAccountPool {
868
896
  * read as "never usable again" to {@link accountUsable}, so `unknown` it is.
869
897
  */
870
898
  private stampWindowMark;
899
+ /**
900
+ * The explicit-account fallback re-check: when `chosen` (what rotation
901
+ * would currently serve) is not the account the user actually asked for,
902
+ * re-probe that explicit account's mark before accepting the fallback —
903
+ * so a rate-limit mark never demotes the user's own selection for good
904
+ * (issue #51). Returns the revived account, or `undefined` when there is
905
+ * nothing to revive (explicit account already serving, not due for a
906
+ * probe, or the probe found it still exceeded). Shared by {@link resolveKey}
907
+ * (the request path) and {@link activeAccount} (the display path), so both
908
+ * agree on what "currently usable" means instead of drifting apart.
909
+ */
910
+ private reviveExplicit;
911
+ /**
912
+ * Probe every marked account's real usage window when nothing currently
913
+ * resolves. Disabled (401) keys are not probed — an invalid key stays
914
+ * invalid. A throwing probe counts as "unknown" (like a failed one): it
915
+ * must not turn the all-exhausted path into a raw rejection instead of
916
+ * RATE_LIMIT. Shared by {@link resolveKey} and {@link activeAccount}.
917
+ */
918
+ private probeAllMarked;
871
919
  /** Hand out the chosen account's key. */
872
920
  private pick;
873
921
  }
@@ -896,7 +944,7 @@ declare const KNOWN_EFFORTS: Readonly<Record<string, readonly string[]>>;
896
944
  declare const KNOWN_IMAGE_MODELS: ReadonlySet<string>;
897
945
  /**
898
946
  * Models WITHOUT a zero-data-retention upstream, per the official CLI's own
899
- * registry (`command-code@1.72.1` `dist/cli.mjs`): `modelSupportsZdr(id)` is
947
+ * registry (`command-code@1.73.0` `dist/cli.mjs`): `modelSupportsZdr(id)` is
900
948
  * exactly `!nonZdrSet.has(canonicalize(id))`, and `knownModelSupportsZdr`
901
949
  * carries the same membership in the sibling route table — the UNION of both
902
950
  * is this set. Reading only the sibling route table would drop `meituan/
@@ -957,7 +1005,7 @@ declare const KNOWN_THINKING_MODELS: ReadonlySet<string>;
957
1005
  * `/docs/plans/max` and `/docs/resources/pricing-limits`). Each plan's model
958
1006
  * list is a superset of the one below it: Go ⊂ GOAT ⊂ Pro ⊂ Provider/Max.
959
1007
  * Models absent from every plan list (Claude Opus/Fable, Fugu Ultra) are
960
- * Provider-tier. Re-verified at command-code@1.72.1 (2026-09-30): 86 catalog
1008
+ * Provider-tier. Re-verified at command-code@1.73.0 (2026-10-01): 86 catalog
961
1009
  * ids at 53/62/76/84 cumulative, a strict superset chain — every release since
962
1010
  * 1.49.0 has been additive with no tier move, and per-entry tags below name the
963
1011
  * release that added each row.
@@ -986,7 +1034,7 @@ declare function compareByPlan(a: {
986
1034
  /**
987
1035
  * Subscription plan table, synced from the official CLI bundle's plan maps
988
1036
  * (located by the `"individual-go"` key in `dist/cli.mjs`, re-verified unchanged
989
- * through command-code@1.72.1): subscription `planId` prefix → display name and
1037
+ * through command-code@1.73.0): subscription `planId` prefix → display name and
990
1038
  * the plan's monthly credit total. This is the account's own subscription
991
1039
  * (from `/alpha/billing/subscriptions`) — distinct from {@link KNOWN_PLANS},
992
1040
  * which maps catalog models to their minimum tier.
@@ -1182,11 +1230,11 @@ interface CommandCodeCatalogModel {
1182
1230
  * Per-model MONTHLY allowance in USD: how much of the plan's monthly credit
1183
1231
  * pool this one model may draw, already resolved by the Host against the
1184
1232
  * account pool's highest plan (the pricing page publishes an allowance for
1185
- * GOAT and Pro only). Undefined when that plan has no published allowance
1233
+ * Go, GOAT and Pro). Undefined when that plan has no published allowance
1186
1234
  * (Go, Provider, Max, Ultra) or when billing could not be read — the browser
1187
1235
  * shows nothing rather than guessing a neighbouring tier's figure.
1188
1236
  *
1189
- * Deliberately a plain number and not the `{ goat, pro }` pair: the bracket is
1237
+ * Deliberately a plain number and not the `{ go, goat, pro }` map: the bracket is
1190
1238
  * a Host decision that already depends on facts the browser does not hold, and
1191
1239
  * shipping both figures would invite a second, divergent rule here. Note this
1192
1240
  * is dollars per MONTH, unlike every rate in `CommandCodePriceTable`.
@@ -1440,7 +1488,7 @@ declare class CommandCodeUsageService<C extends CommandCodeConnectionOptions = C
1440
1488
  declare function applyUsageRemote<C extends CommandCodeConnectionOptions>(ctx: Context, deps: CommandCodeUsageDeps<C>): void;
1441
1489
  //#endregion
1442
1490
  //#region src/login.d.ts
1443
- /** Give up on the browser after this long without a callback (mirrors the CLI). */
1491
+ /** 登录总期限包含浏览器回调、密钥验证与存储,不能在收到回调后撤掉保护。 */
1444
1492
  declare const LOGIN_TIMEOUT_MS = 120000;
1445
1493
  /** First local port the flow tries (mirrors the CLI). */
1446
1494
  declare const LOGIN_START_PORT = 5959;
@@ -1503,7 +1551,7 @@ declare function studioBaseForApiBase(apiBase: string): string;
1503
1551
  * tests). Mirrors the CLI's verdicts: 401 → invalid_key, other non-OK →
1504
1552
  * server_error, transport failure → network_error.
1505
1553
  */
1506
- declare function validateCommandApiKey(fetchImpl: typeof fetch, apiBase: string, apiKey: string): Promise<ApiKeyValidation>;
1554
+ declare function validateCommandApiKey(fetchImpl: typeof fetch, apiBase: string, apiKey: string, signal?: AbortSignal): Promise<ApiKeyValidation>;
1507
1555
  /**
1508
1556
  * One browser-login attempt machine. Single-flight by design: `begin()` while
1509
1557
  * waiting returns the live attempt's status instead of starting a second one;
@@ -1518,6 +1566,7 @@ declare class CommandCodeLoginFlow {
1518
1566
  private statusValue;
1519
1567
  private server;
1520
1568
  private timer;
1569
+ private attemptAbort;
1521
1570
  /** Settle hooks of the live attempt's callback promise. */
1522
1571
  private settle;
1523
1572
  /**
@@ -1597,7 +1646,9 @@ declare class CommandCodeLoginFlow {
1597
1646
  /** Map a tagged settle rejection onto the status face. */
1598
1647
  private failFrom;
1599
1648
  private clearTimer;
1600
- /** Close the server and watchdog without touching the published status. */
1649
+ /** 消费一次回调后关闭监听;保留总期限以约束后续验证。 */
1650
+ private closeCallback;
1651
+ /** 结束整个尝试,同时中止验证请求,迟到结果由所有权检查拦截。 */
1601
1652
  private teardown;
1602
1653
  }
1603
1654
  //#endregion