@mars-sea/dsh-commandcode-provider 0.15.4 → 0.16.0

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
@@ -61,7 +61,7 @@ type CommandCodeProtocol = 'cli' | 'openai' | 'messages';
61
61
  declare const DEFAULT_MAX_OUTPUT_TOKENS = 131072;
62
62
  //#endregion
63
63
  //#region src/adapter.d.ts
64
- declare const COMMAND_CODE_CLI_VERSION = "1.88.0";
64
+ declare const COMMAND_CODE_CLI_VERSION = "1.88.1";
65
65
  declare const DEFAULT_API_BASE = "https://api.commandcode.ai";
66
66
  /**
67
67
  * The output budget this bundle asks for, and the ceiling it will never exceed.
@@ -382,6 +382,25 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
382
382
  private readonly surfaceOffload;
383
383
  private readonly billingAccess;
384
384
  private readonly billingAccessInflight;
385
+ /**
386
+ * Successful account-endpoint responses, keyed by gateway + key + exact URL.
387
+ *
388
+ * The settings card and the picker's advisory plan filter ask the SAME three
389
+ * endpoints about the SAME account (`/alpha/whoami`, then credits and
390
+ * subscriptions in parallel). Here that is four round trips per surface for
391
+ * two answers — and the card refreshes on a timer, so the picker keeps paying
392
+ * for rows it already has. Sharing the raw responses removes the duplicate
393
+ * without either surface having to know about the other: whoever asks second
394
+ * within {@link ACCOUNT_FACTS_TTL_MS} reads the same record instead of the
395
+ * wire.
396
+ *
397
+ * Only SUCCESSFUL records are kept. A failure must be retried rather than
398
+ * replayed, or an endpoint that recovered a second ago would keep reporting
399
+ * yesterday's outage — and the usage report's per-endpoint `failures` and
400
+ * {@link classifyTotalFailure} verdict would describe a request this process
401
+ * never made.
402
+ */
403
+ private readonly accountJson;
385
404
  private readonly protocolCache;
386
405
  /** Namespace account-derived facts by gateway without exposing the key. */
387
406
  private accountCacheKey;
@@ -488,8 +507,24 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
488
507
  */
489
508
  allowanceTier(): Promise<'go' | 'goat' | 'pro' | undefined>;
490
509
  resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
510
+ /**
511
+ * Resolve and validate the key one account-endpoint call will use.
512
+ *
513
+ * Every account endpoint runs the chat path's own `assertUsableApiKey` check,
514
+ * or a key carrying a character no HTTP header can hold throws inside `fetch`
515
+ * BEFORE any I/O — once per endpoint — and the report reads as "the network is
516
+ * down". The credential reference is read structurally: it belongs to the
517
+ * host's resolved options, not to this adapter's connection type, and it only
518
+ * names the key in the rejection message.
519
+ *
520
+ * Separate from {@link accountHeadersFor} so a caller that also needs to key a
521
+ * cache by the same identity does not have to resolve the key twice.
522
+ */
523
+ private usableAccountKey;
491
524
  /** The headers every authenticated account endpoint shares. */
492
525
  private accountHeaders;
526
+ /** Headers for an already-validated key; see {@link usableAccountKey}. */
527
+ private accountHeadersFor;
493
528
  /**
494
529
  * Fetch one JSON GET and return its HTTP status with a parsed record. The
495
530
  * catalog, billing probe, and usage report each apply their own failure
@@ -524,6 +559,23 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
524
559
  * everything" (fail-open).
525
560
  */
526
561
  private loadBillingAccessForKey;
562
+ /**
563
+ * One account-endpoint GET, served from {@link accountJson} when `share` and
564
+ * the same URL answered successfully within {@link ACCOUNT_FACTS_TTL_MS}.
565
+ *
566
+ * `timeoutMs` is the CALLER's budget; a cache hit spends none of it. Failures
567
+ * are never cached, so this can only ever save a request that would have
568
+ * re-read an answer this process already had.
569
+ *
570
+ * `share: false` marks a VOLATILE endpoint — one whose answer is the number
571
+ * the user is actually looking at, and which must therefore never be replayed
572
+ * from an earlier request. The usage card's summary is exactly that: its
573
+ * headline counts and cost are the reason the card exists, and stamping a
574
+ * cached copy with the current time would misreport when they were read.
575
+ * Identity and billing facts are the opposite: a plan tier or an org id that
576
+ * is 30 s old is still the truth, and those are what the picker duplicates.
577
+ */
578
+ private accountJsonGet;
527
579
  /**
528
580
  * The billing facts behind the picker's plan filter, mirroring the CLI's
529
581
  * `createBilling` flow: whoami yields the org id, then the subscriptions
@@ -879,6 +931,21 @@ declare class CommandCodeAccountPool {
879
931
  * keeps its window unknown on purpose, so a probe can still find out.
880
932
  */
881
933
  markRejected(apiKey: string, rejection: AccountRejection, resetAtMs?: number): void;
934
+ /**
935
+ * 用量报告读到的窗口结论(设置页账号卡片、`/commandcode` 拉取的
936
+ * `/alpha/billing/credits`):某个窗口已超限,就按探测的同一口径给这个密钥
937
+ * 打标记——有可信重置时刻记为到期自动恢复的 `cooldown`,否则为 `unknown`。
938
+ *
939
+ * 为什么需要(issue #105):轮转原本只认真实请求的拒绝,进程重启或冷却过早
940
+ * 到期后,卡片明明显示「每周 100%」,自动模式和「当前使用」徽标仍选列表第一个
941
+ * 账号,下一个请求白撞一次拒绝才换号。报告本来就要拉这个接口,把结论记进池里
942
+ * 不增加任何请求。
943
+ *
944
+ * 只加不减:窗口未超限时不清除已有标记。限流(throttle)或消费上限这类拒绝
945
+ * 在窗口数据里看不到(issue #54),据此清标记会让每次刷新卡片都换来一次注定
946
+ * 被拒的请求;清除仍只走有节流的探测路径。401 禁用的密钥不改。
947
+ */
948
+ noteWindowReport(apiKey: string, verdict: AccountWindowProbe | undefined): void;
882
949
  /**
883
950
  * Record a model-scoped `unavailable` rejection (no credits, or a model
884
951
  * outside this account's plan) as a SHORT-LIVED PREFERENCE demotion.
@@ -1165,10 +1232,9 @@ declare const KNOWN_THINKING_MODELS: ReadonlySet<string>;
1165
1232
  * `/docs/plans/max` and `/docs/resources/pricing-limits`). Each plan's model
1166
1233
  * list is a superset of the one below it: Go ⊂ GOAT ⊂ Pro ⊂ Provider/Max.
1167
1234
  * Models absent from every plan list (Claude Opus/Fable, Fugu Ultra) are
1168
- * Provider-tier. Re-verified at command-code@1.88.0 (2026-10-24) against the
1169
- * live `?view=client` catalog: 105 ids, still a strict superset chain. Mistral
1170
- * Large 4
1171
- * (1.75.0) was the only addition at the 1.77.0 check; the 1.78.0/1.79.0 pair
1235
+ * Provider-tier. Re-verified at command-code@1.88.1 (2026-10-28) against the
1236
+ * live `?view=client` catalog: 106 ids, still a strict superset chain. Mistral
1237
+ * Large 4 (1.75.0) was the only addition at the 1.77.0 check; the 1.78.0/1.79.0 pair
1172
1238
  * added Claude Haiku 5.5 at Pro and the free Glyph Cluster preview at Go.
1173
1239
  * 1.79.2 lowers Haiku 5.5's minimum plan to GOAT; 1.80.0 adds Muse Wonder at
1174
1240
  * Max; 1.82.0 adds Gemini 4 Argon at Pro and nothing else moves. The 1.82.4
@@ -1177,7 +1243,8 @@ declare const KNOWN_THINKING_MODELS: ReadonlySet<string>;
1177
1243
  * which left the live catalog. Every other
1178
1244
  * tier is unchanged. The 1.86.1 sync (2026-10-21) adds only the Ornith 1.5 122B
1179
1245
  * launch pair at Go; the 1.87.1 check (2026-10-22) adds no model and moves no
1180
- * tier, and the 2026-10-24 check adds only Kimi K3.1 Pro at Go.
1246
+ * tier, the 2026-10-24 check adds only Kimi K3.1 Pro at Go, and the 2026-10-27
1247
+ * check adds only GPT-6.1 Terra at Pro.
1181
1248
  * The only removals since 1.49.0 are the two retired stealth previews (Pixel
1182
1249
  * Canary at 1.73.1, Space Bunny Alpha at 1.74.3), Ling 3.0 Flash Sante
1183
1250
  * (2026-10-16) and the retired Cat Jam preview (2026-10-20). Per-entry tags