@mars-sea/dsh-commandcode-provider 0.11.8 → 0.11.10

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
@@ -7,7 +7,7 @@ import { Context } from "@deepseek-ai/cordis";
7
7
  import { AttachmentStore, ImageAttachmentRef } from "@deepseek-ai/dsh-attachment";
8
8
  import { CommandDefinition } from "@deepseek-ai/dsh-commands";
9
9
  //#region src/adapter.d.ts
10
- declare const COMMAND_CODE_CLI_VERSION = "1.62.0";
10
+ declare const COMMAND_CODE_CLI_VERSION = "1.64.0";
11
11
  declare const DEFAULT_API_BASE = "https://api.commandcode.ai";
12
12
  declare const DEFAULT_GENERATE_MAX_TOKENS = 64000;
13
13
  declare const DEFAULT_MAX_OUTPUT_TOKENS = 65536;
@@ -93,6 +93,16 @@ interface CommandCodeConnectionOptions {
93
93
  * the plugin's user settings schema.
94
94
  */
95
95
  protocol?: 'auto' | CommandCodeProtocol;
96
+ /**
97
+ * Whether requests enforce zero data retention by sending the
98
+ * `x-cmd-zdr: 1` header (the same opt-in the official CLI exposes as
99
+ * `CMD_ZDR=1`). Default false. Every chat request carries the header when
100
+ * enabled. The provider refuses a model without a ZDR-capable upstream with
101
+ * 422 `cmd_zdr_no_providers`; never retry that request without the header.
102
+ * The decision endpoint (`/provider/v1/systemone`) is deliberately never
103
+ * reached through this connection option — see `./systemone.ts`.
104
+ */
105
+ zdr?: boolean;
96
106
  }
97
107
  /**
98
108
  * Resolve the durable attachment service, or undefined when the host does not
@@ -340,6 +350,11 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
340
350
  * failure accounting: the billing probe fails open silently, the usage
341
351
  * report books failures per endpoint. Non-2xx and non-record bodies come
342
352
  * back without a record; only a transport throw propagates to the caller.
353
+ *
354
+ * `timeoutMs` is the caller's budget for this one request. The default is the
355
+ * CATALOG probe's short cap, which fits the picker's fail-open reads; the
356
+ * usage report deliberately passes the connection's own request budget so an
357
+ * account query is not held to a stricter (and invisible) limit than chat.
343
358
  */
344
359
  private fetchEndpointJson;
345
360
  /**
@@ -411,6 +426,20 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
411
426
  * view. Requires a usable API key (throws `MISSING_CREDENTIAL` otherwise).
412
427
  * Pass `apiKey` to report on a specific account of a multi-account pool;
413
428
  * the default resolves the currently active account.
429
+ *
430
+ * Two failure modes are NOT "the network is down", and the report must say
431
+ * so rather than let {@link classifyTotalFailure} blame the connection:
432
+ *
433
+ * - A key that no HTTP header can carry (a stray newline from a paste, a
434
+ * full-width character) makes `fetch` throw a `TypeError` **before any
435
+ * I/O**, for every endpoint at once. The chat path refuses such a key
436
+ * through `assertUsableApiKey`; this path must too, and it answers
437
+ * `blocked: 'invalid-key'` instead of four phantom transport failures.
438
+ * - The four endpoints get the SAME per-request budget as a chat call
439
+ * (`connection.requestTimeoutMs`, default 60 s), not the catalog's 10 s
440
+ * probe budget: on a slow link a 10 s cap made every account query time
441
+ * out while chat kept working, which is exactly a "check your network"
442
+ * banner that never clears.
414
443
  */
415
444
  getUsage(apiKey?: string): Promise<CommandCodeUsageReport>;
416
445
  /**
@@ -758,6 +787,46 @@ declare const KNOWN_EFFORTS: Readonly<Record<string, readonly string[]>>;
758
787
  * dsh-commandcode-upstream skill).
759
788
  */
760
789
  declare const KNOWN_IMAGE_MODELS: ReadonlySet<string>;
790
+ /**
791
+ * Models WITHOUT a zero-data-retention upstream, per the official CLI's own
792
+ * registry (`command-code@1.64.0` `dist/cli.mjs`: `modelSupportsZdr(id)` is
793
+ * exactly `!nonZdrSet.has(canonicalize(id))`, and `knownModelSupportsZdr`
794
+ * carries the same membership in the sibling route table — the union is this
795
+ * set). The official docs (commandcode.ai/docs/resources/zdr) put it in prose
796
+ * — "99% of our models have ZDR-capable upstreams … only a small handful of
797
+ * models are affected" — so the CLI's exclusion list is the only per-model
798
+ * evidence there is; a ZDR request naming one of these fails with HTTP 422
799
+ * `cmd_zdr_no_providers` instead of routing through a provider that retains.
800
+ *
801
+ * Why a NEGATIVE set, and why "not listed" answers TRUE: 99% of the catalog is
802
+ * covered, so the maintained difference is the exception list. This helper is
803
+ * informational; the adapter sends the ZDR header for EVERY request when the
804
+ * switch is on. The provider remains the routing authority and refuses an
805
+ * unsupported model rather than silently dropping the privacy guarantee.
806
+ *
807
+ * `minimax/minimax-m3-free` is the one entry the public catalog
808
+ * (`/provider/v1/models`) does not serve (it is CLI/pricing-visible and hidden
809
+ * from the picker); it stays listed because the CLI carries it and a Go-plan
810
+ * request can still name it.
811
+ *
812
+ * Keep in sync via the dsh-commandcode-upstream skill: the CLI's registry data
813
+ * (its `zdr:{only:[…]}` provider routes and the per-provider `zdr`/`noTraining`
814
+ * flags) is upstream-internal routing, not a per-model contract, so this table
815
+ * is the snapshot of the exclusion set and nothing more. The 1.62.0 → 1.64.0
816
+ * diff of that union is EMPTY: both anchors were extracted from both bundles
817
+ * during the 2026-09-23 check and each carries the same 20 members — which is
818
+ * how rare a change here is expected to be. `meituan/LongCat-2.0` is the one
819
+ * member the two anchors disagree about (it is in `modelSupportsZdr`'s set in
820
+ * both releases and in neither `knownModelSupportsZdr` set), so the union is
821
+ * what this table follows; reading only the sibling route table would drop it.
822
+ */
823
+ declare const KNOWN_NON_ZDR_MODELS: ReadonlySet<string>;
824
+ /**
825
+ * Whether the CLI snapshot lists a ZDR-capable upstream for `modelId`. This is
826
+ * informational, never a reason to omit the header when ZDR is enabled: the
827
+ * provider may add coverage or lack capacity after this snapshot was taken.
828
+ */
829
+ declare function supportsZeroDataRetention(modelId: string): boolean;
761
830
  /**
762
831
  * Models the official CLI's model table (command-code@1.53.0) marks
763
832
  * `reasoning:!0` but defines no selectable `reasoning_effort` levels — they
@@ -1372,7 +1441,10 @@ declare function validateCommandApiKey(fetchImpl: typeof fetch, apiBase: string,
1372
1441
  /**
1373
1442
  * One browser-login attempt machine. Single-flight by design: `begin()` while
1374
1443
  * waiting returns the live attempt's status instead of starting a second one;
1375
- * a terminal state makes the next `begin()` start fresh.
1444
+ * a start that is still binding its port is REJOINED through
1445
+ * {@link CommandCodeLoginFlow.begin}'s in-flight promise, because the status
1446
+ * face cannot say `waiting` until that bind settles; a terminal state makes the
1447
+ * next `begin()` start fresh.
1376
1448
  */
1377
1449
  declare class CommandCodeLoginFlow {
1378
1450
  private readonly deps;
@@ -1390,6 +1462,17 @@ declare class CommandCodeLoginFlow {
1390
1462
  * the user cancelled and flipping the page back to success.
1391
1463
  */
1392
1464
  private attemptSeq;
1465
+ /**
1466
+ * The start currently binding a port, if any. Every `begin()` that arrives
1467
+ * before it settles joins it: two independent starts would each bind their
1468
+ * own loopback server, and only the LAST one is reachable by
1469
+ * {@link CommandCodeLoginFlow.teardown} — the orphan keeps listening and
1470
+ * answering `/callback` for the process's lifetime, and ten of them exhaust
1471
+ * the port window so browser login dies until the Host restarts.
1472
+ */
1473
+ private starting;
1474
+ /** A `cancel()` that arrived while a start was still binding (see {@link CommandCodeLoginFlow.cancel}). */
1475
+ private cancelPending;
1393
1476
  private disposed;
1394
1477
  constructor(deps: CommandCodeLoginFlowDeps);
1395
1478
  /** Subscribe to state transitions. @returns the disposer. */
@@ -1402,7 +1485,18 @@ declare class CommandCodeLoginFlow {
1402
1485
  * Rejects only when the flow cannot start at all (no free port, disposed).
1403
1486
  */
1404
1487
  begin(): Promise<CommandCodeLoginStatus>;
1405
- /** Cancel a waiting attempt; terminal states are untouched. */
1488
+ /**
1489
+ * The binding half of {@link CommandCodeLoginFlow.begin}: one attempt, one
1490
+ * server, one published `waiting` status. Callers reach it only through
1491
+ * `begin()`'s single-flight fence.
1492
+ */
1493
+ private startAttempt;
1494
+ /**
1495
+ * Cancel a waiting attempt; terminal states are untouched. A start that is
1496
+ * still binding a port is flagged instead of ignored — it cannot be torn
1497
+ * down from here (its server does not exist yet), so `startAttempt` observes
1498
+ * the flag once the bind settles and retires it.
1499
+ */
1406
1500
  cancel(): void;
1407
1501
  /** Stop everything; a waiting attempt ends cancelled. Idempotent. */
1408
1502
  dispose(): void;
@@ -1478,10 +1572,20 @@ declare function selectCommandCodeSearchProvider(web: WebRuntime, enable: boolea
1478
1572
  * configured, leave auto-select" and must round-trip untouched: writing the
1479
1573
  * factory default instead would still override a sibling plugin's own
1480
1574
  * constructor-time pin.
1575
+ *
1576
+ * `preexisting` is the one fact `displaced` cannot carry: an `undefined`
1577
+ * `displaced` means EITHER "the field was unset when we took over" (give
1578
+ * `undefined` back on disable) OR "the field already read `commandcode`"
1579
+ * (touch nothing on disable — see {@link applyCommandCodeSearchSelection}).
1580
+ * Collapsing the two is what turned a user's own `searchProvider: commandcode`
1581
+ * pin into an auto-select — and then into `WEB_PROVIDER_AMBIGUOUS` on every
1582
+ * search — the moment this plugin was disabled or unloaded.
1481
1583
  */
1482
1584
  interface CommandCodeSearchSelection {
1483
1585
  owner: boolean;
1484
1586
  displaced: string | undefined;
1587
+ /** Whether the field already read `commandcode` when this plugin first took it over. */
1588
+ preexisting: boolean;
1485
1589
  }
1486
1590
  /** Fresh selection state: the plugin starts out not owning the selection. */
1487
1591
  declare function commandCodeSearchSelection(): CommandCodeSearchSelection;
@@ -1500,8 +1604,14 @@ declare function commandCodeSearchSelection(): CommandCodeSearchSelection;
1500
1604
  * auto-select — already says what the user wants.
1501
1605
  * - When the field already reads `commandcode` at first touch (e.g. a
1502
1606
  * surviving runtime the plugin did not set, or a manual
1503
- * `searchProvider: commandcode` pin), `displaced` stays undefined so the
1504
- * later disable is a no-op rather than a guess at the factory default.
1607
+ * `searchProvider: commandcode` pin), `displaced` stays undefined and
1608
+ * `preexisting` is set, so the later disable is a no-op rather than a guess
1609
+ * at the factory default. A "no-op" means the field is left ALONE: writing
1610
+ * that `undefined` back would destroy the user's own pin, and dsh-web reads
1611
+ * a cleared `searchProviderId` as auto-select — where a second usable
1612
+ * provider (the shipped `deepseek-official` is usable whenever a DeepSeek
1613
+ * key resolves) makes EVERY later search throw
1614
+ * `WEB_PROVIDER_AMBIGUOUS`.
1505
1615
  *
1506
1616
  * Never throws: like the low-level rewrite, a hardened runtime shape degrades
1507
1617
  * to registered-but-unselected.
@@ -1812,6 +1922,44 @@ interface Config {
1812
1922
  * the toggle is on. Read by the browser client; the adapter ignores it.
1813
1923
  */
1814
1924
  showSidebarQuota?: boolean;
1925
+ /**
1926
+ * Whether the Command Code decision model (`typesafe/jev`) may auto-approve
1927
+ * shell commands that dsh was about to ask about. Defaults to FALSE: the
1928
+ * guard turns a model's opinion into a one-shot approval grant, so it is
1929
+ * opt-in, and the command text (plus the agent's own description of it) is
1930
+ * sent to Command Code to judge. Only commands a policy already wanted a
1931
+ * human to look at are ever judged, and only a confident "safe" verdict
1932
+ * (`commandGuardThreshold`) skips the prompt — every other outcome, including
1933
+ * any failure of the decision call itself, delegates to the normal approval
1934
+ * flow. See `./command-guard.ts`.
1935
+ */
1936
+ commandGuard?: boolean;
1937
+ /**
1938
+ * Minimum probability of "safe" that lets the guard skip the approval prompt;
1939
+ * defaults to 0.9. Lowering it approves more, on less evidence.
1940
+ */
1941
+ commandGuardThreshold?: number;
1942
+ /**
1943
+ * Milliseconds the guard waits for a decision before falling back to the
1944
+ * human prompt; defaults to 1500. This is a latency budget for an interactive
1945
+ * approval, not a request timeout — a decision that arrives late is useless,
1946
+ * because the user is staring at a prompt.
1947
+ */
1948
+ commandGuardTimeoutMs?: number;
1949
+ /**
1950
+ * Whether requests enforce zero data retention: the provider then routes
1951
+ * them only through upstreams that keep no prompts/completions and never
1952
+ * train on them (its own opt-in, `CMD_ZDR=1` in the CLI / `x-cmd-zdr: 1` on
1953
+ * the Provider API). Defaults to FALSE: `zdr` changes WHERE a request is
1954
+ * served. Every chat request carries the header when enabled; a model with
1955
+ * no ZDR-capable upstream fails with 422 `cmd_zdr_no_providers` instead of
1956
+ * being routed through an upstream that retains data. ZDR capacity is
1957
+ * priced pass-through and usually costs more, and the price readout keeps
1958
+ * quoting the ordinary catalog rates (the real per-request price shows in
1959
+ * Command Code's Studio). The decision endpoint behind the command guard is
1960
+ * never ZDR-enforced — see `./systemone.ts`.
1961
+ */
1962
+ zdr?: boolean;
1815
1963
  /**
1816
1964
  * Language override for the `/commandcode` Host-side command's user-facing
1817
1965
  * copy. Host commands cannot read the client's `ctx.locale`, so this is
@@ -1825,7 +1973,35 @@ interface Config {
1825
1973
  */
1826
1974
  lang?: string;
1827
1975
  }
1976
+ /**
1977
+ * The 0.1.7-generation schema: every field volatile except the
1978
+ * composition-only `apiKey` secret.
1979
+ *
1980
+ * dsh 0.1.7's settings forms are projected from the schema's `meta.volatile`
1981
+ * nodes, so an unmarked field would be invisible to AND unwritable from the
1982
+ * settings page and refused by form-edit path validation — and on that
1983
+ * generation the loader hands `apply()` a live reference per marked field,
1984
+ * committing later writes without remounting this fiber (the
1985
+ * `loader/volatile-update` listener at the bottom of `apply` covers the facts
1986
+ * that are not re-derived per read). The mark is inert on engines whose
1987
+ * schemastery predates `.volatile()`.
1988
+ */
1828
1989
  declare const Config: z<Config>;
1990
+ /**
1991
+ * The ≤0.1.6-generation registration schema: the same fields, NO volatile
1992
+ * marks.
1993
+ *
1994
+ * The legacy `installSection(owner, ns, schema, entry, hooks)` re-validates the
1995
+ * `entry` it is handed (`register()` → `resolve()` → `schema(mergeLayers(base,
1996
+ * section))`) and its `describe()` structuredClones that same `entry`. Since
1997
+ * schemastery ≥3.18.3 creates references at parse time on EVERY generation —
1998
+ * `dsh-settings` through 0.1.6 declares `schemastery: ^3.18.2`, so old engines
1999
+ * freshly installed today resolve 3.18.3 — a marked schema plus the raw
2000
+ * reference-carrying `config` is a boot-time `ValidationError` there. This
2001
+ * schema is therefore unmarked, and `apply` pairs it with
2002
+ * `unwrapVolatileConfig(config)`.
2003
+ */
2004
+ declare const LegacySettingsSchema: z<Config>;
1829
2005
  /** One resolution's complete request facts: connection plus credential reference. */
1830
2006
  interface ResolvedCommandCodeOptions extends CommandCodeConnectionOptions {
1831
2007
  apiKeyEnv: CredentialRef;
@@ -1839,5 +2015,5 @@ interface ResolvedCommandCodeOptions extends CommandCodeConnectionOptions {
1839
2015
  declare function resolveAdapterOptions(config: Config): ResolvedCommandCodeOptions;
1840
2016
  declare function apply(ctx: Context, config: Config): void;
1841
2017
  //#endregion
1842
- export { ACTIVE_ACCOUNT_AUTO, type ApiKeyValidation, BILLING_ACCESS_TTL_MS, COMMANDCODE_SEARCH_PROVIDER_ID, COMMAND_CODE_CLI_VERSION, type CommandCodeAccountConfig, CommandCodeAccountPool, type CommandCodeAccountSlot, type CommandCodeAccountState, type CommandCodeAccountUsage, type CommandCodeAccountsReport, CommandCodeAdapter, type CommandCodeAdapterDeps, type CommandCodeBillingAccess, type CommandCodeCommandDeps, type CommandCodeConnectionOptions, type CommandCodeLoginCredentials, type CommandCodeLoginFailureReason, CommandCodeLoginFlow, type CommandCodeLoginFlowDeps, type CommandCodeLoginStatus, type CommandCodeModelAccountRule, CommandCodeSearchProvider, type CommandCodeSearchProviderDeps, type CommandCodeSearchSelection, type CommandCodeTuiSettingsDeps, type CommandCodeUsageDeps, type CommandCodeUsageReport, CommandCodeUsageService, Config, DEFAULT_API_BASE, DEFAULT_GENERATE_MAX_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MODELS_CACHE_PATH, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_WEB_SEARCH_PROVIDER_ID, KNOWN_DEALS, KNOWN_EFFORTS, KNOWN_IMAGE_MODELS, KNOWN_PEAK_PRICING, KNOWN_PLANS, KNOWN_SUBSCRIPTION_PLANS, KNOWN_THINKING_MODELS, LANG_AUTO, LOGIN_ALLOWED_ORIGINS, LOGIN_BEGIN_ENDPOINT, LOGIN_BODY_LIMIT_BYTES, LOGIN_CANCEL_ENDPOINT, LOGIN_MAX_PORT_ATTEMPTS, LOGIN_START_PORT, LOGIN_STATUS_ENDPOINT, LOGIN_TIMEOUT_MS, type LoginFlowFacade, PLAN_LABELS, PLAN_ORDER, PROVIDER, type ResolveAttachments, ResolvedCommandCodeOptions, type TuiSettingsField, type TuiSettingsFieldOption, type TuiSettingsFieldWrite, type TuiSettingsGroup, type TuiSettingsSection, type TuiSettingsSectionsService, USAGE_REPORT_ENDPOINT, accountUsable, apply, applyCommandCodeSearchSelection, applyCommandCodeTuiSettings, applyCommands, applyUsageRemote, buildCommandAuthUrl, buildCommandCodeTuiSection, capabilityDescription, commandCodeSearchSelection, commandDefinition, compareByPlan, dealLabel, formatContext, inject, loginStatusSchema, matchModelRule, modelVisibleInPlan, name, parseLoginStatus, peakPricingLabel, peakPricingState, planLabel, projectSlugFromPath, resolveAdapterOptions, resolveAuthFileApiKey, selectAccountForModel, selectActiveAccount, selectCommandCodeSearchProvider, studioBaseForApiBase, subscriptionPlanInfo, usageReportSchema, validateCommandApiKey };
2018
+ export { ACTIVE_ACCOUNT_AUTO, type ApiKeyValidation, BILLING_ACCESS_TTL_MS, COMMANDCODE_SEARCH_PROVIDER_ID, COMMAND_CODE_CLI_VERSION, type CommandCodeAccountConfig, CommandCodeAccountPool, type CommandCodeAccountSlot, type CommandCodeAccountState, type CommandCodeAccountUsage, type CommandCodeAccountsReport, CommandCodeAdapter, type CommandCodeAdapterDeps, type CommandCodeBillingAccess, type CommandCodeCommandDeps, type CommandCodeConnectionOptions, type CommandCodeLoginCredentials, type CommandCodeLoginFailureReason, CommandCodeLoginFlow, type CommandCodeLoginFlowDeps, type CommandCodeLoginStatus, type CommandCodeModelAccountRule, CommandCodeSearchProvider, type CommandCodeSearchProviderDeps, type CommandCodeSearchSelection, type CommandCodeTuiSettingsDeps, type CommandCodeUsageDeps, type CommandCodeUsageReport, CommandCodeUsageService, Config, DEFAULT_API_BASE, DEFAULT_GENERATE_MAX_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MODELS_CACHE_PATH, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_WEB_SEARCH_PROVIDER_ID, KNOWN_DEALS, KNOWN_EFFORTS, KNOWN_IMAGE_MODELS, KNOWN_NON_ZDR_MODELS, KNOWN_PEAK_PRICING, KNOWN_PLANS, KNOWN_SUBSCRIPTION_PLANS, KNOWN_THINKING_MODELS, LANG_AUTO, LOGIN_ALLOWED_ORIGINS, LOGIN_BEGIN_ENDPOINT, LOGIN_BODY_LIMIT_BYTES, LOGIN_CANCEL_ENDPOINT, LOGIN_MAX_PORT_ATTEMPTS, LOGIN_START_PORT, LOGIN_STATUS_ENDPOINT, LOGIN_TIMEOUT_MS, LegacySettingsSchema, type LoginFlowFacade, PLAN_LABELS, PLAN_ORDER, PROVIDER, type ResolveAttachments, ResolvedCommandCodeOptions, type TuiSettingsField, type TuiSettingsFieldOption, type TuiSettingsFieldWrite, type TuiSettingsGroup, type TuiSettingsSection, type TuiSettingsSectionsService, USAGE_REPORT_ENDPOINT, accountUsable, apply, applyCommandCodeSearchSelection, applyCommandCodeTuiSettings, applyCommands, applyUsageRemote, buildCommandAuthUrl, buildCommandCodeTuiSection, capabilityDescription, commandCodeSearchSelection, commandDefinition, compareByPlan, dealLabel, formatContext, inject, loginStatusSchema, matchModelRule, modelVisibleInPlan, name, parseLoginStatus, peakPricingLabel, peakPricingState, planLabel, projectSlugFromPath, resolveAdapterOptions, resolveAuthFileApiKey, selectAccountForModel, selectActiveAccount, selectCommandCodeSearchProvider, studioBaseForApiBase, subscriptionPlanInfo, supportsZeroDataRetention, usageReportSchema, validateCommandApiKey };
1843
2019
  //# sourceMappingURL=index.d.ts.map