@mars-sea/dsh-commandcode-provider 0.11.11 → 0.11.12
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/CHANGELOG.md +8 -0
- package/README.md +19 -16
- package/README.zh-CN.md +13 -16
- package/lib/client.js +62 -123
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +39 -75
- package/lib/index.js +198 -324
- package/lib/index.js.map +1 -1
- package/package.json +40 -48
package/lib/index.js
CHANGED
|
@@ -2,8 +2,7 @@ import { homedir, tmpdir } from "node:os";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
4
|
import { MAX_TIMER_DELAY_MS } from "@deepseek-ai/dsh-timeout";
|
|
5
|
-
import
|
|
6
|
-
import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmAdapter, LlmError, ReasoningEffortId, ToolCallId, assertUsableApiKey, attributionHeaders, errorChain, isContextWindowExceededError, offloadedImageText, resolveRetryPolicy, textOnlyImageText } from "@deepseek-ai/dsh-llm";
|
|
5
|
+
import { CONTEXT_WINDOW_EXCEEDED_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, ReasoningEffortId, ToolCallId, assertUsableApiKey, attributionHeaders, errorChain, isContextWindowExceededError, offloadedImageText, projectOffloadedImages, requiredImageOffload, resolveRetryPolicy, textOnlyImageText } from "@deepseek-ai/dsh-llm";
|
|
7
6
|
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
8
7
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
9
8
|
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
@@ -309,6 +308,11 @@ const KNOWN_EFFORTS = {
|
|
|
309
308
|
"low",
|
|
310
309
|
"medium",
|
|
311
310
|
"high"
|
|
311
|
+
],
|
|
312
|
+
"stealth/space-bunny-alpha": [
|
|
313
|
+
"low",
|
|
314
|
+
"medium",
|
|
315
|
+
"high"
|
|
312
316
|
]
|
|
313
317
|
};
|
|
314
318
|
/**
|
|
@@ -374,6 +378,7 @@ const KNOWN_IMAGE_MODELS = /* @__PURE__ */ new Set([
|
|
|
374
378
|
"moonshotai/Kimi-K2.7-Code-Highspeed",
|
|
375
379
|
"moonshotai/Kimi-K3",
|
|
376
380
|
"sakana/fugu-ultra",
|
|
381
|
+
"stealth/space-bunny-alpha",
|
|
377
382
|
"stepfun/Step-3.7-Flash",
|
|
378
383
|
"stepfun/Step-5-Preview",
|
|
379
384
|
"thinkingmachines/inkling",
|
|
@@ -390,7 +395,7 @@ const KNOWN_IMAGE_MODELS = /* @__PURE__ */ new Set([
|
|
|
390
395
|
]);
|
|
391
396
|
/**
|
|
392
397
|
* Models WITHOUT a zero-data-retention upstream, per the official CLI's own
|
|
393
|
-
* registry (`command-code@1.
|
|
398
|
+
* registry (`command-code@1.65.0` `dist/cli.mjs`: `modelSupportsZdr(id)` is
|
|
394
399
|
* exactly `!nonZdrSet.has(canonicalize(id))`, and `knownModelSupportsZdr`
|
|
395
400
|
* carries the same membership in the sibling route table — the union is this
|
|
396
401
|
* set). The official docs (commandcode.ai/docs/resources/zdr) put it in prose
|
|
@@ -416,9 +421,12 @@ const KNOWN_IMAGE_MODELS = /* @__PURE__ */ new Set([
|
|
|
416
421
|
* is the snapshot of the exclusion set and nothing more. The 1.62.0 → 1.64.0
|
|
417
422
|
* diff of that union is EMPTY: both anchors were extracted from both bundles
|
|
418
423
|
* during the 2026-09-23 check and each carries the same 20 members — which is
|
|
419
|
-
* how rare a change here is expected to be.
|
|
420
|
-
*
|
|
421
|
-
*
|
|
424
|
+
* how rare a change here is expected to be. The 1.64.0 → 1.65.0 diff (2026-09-24)
|
|
425
|
+
* is the counterexample that proves the check still runs: exactly one member
|
|
426
|
+
* joins (`stealth/space-bunny-alpha`), and it is in both anchors. `meituan/
|
|
427
|
+
* LongCat-2.0` is the one member the two anchors disagree about (it is in
|
|
428
|
+
* `modelSupportsZdr`'s set in both releases and in neither `knownModelSupportsZdr`
|
|
429
|
+
* set), so the union is
|
|
422
430
|
* what this table follows; reading only the sibling route table would drop it.
|
|
423
431
|
*/
|
|
424
432
|
const KNOWN_NON_ZDR_MODELS = /* @__PURE__ */ new Set([
|
|
@@ -433,6 +441,7 @@ const KNOWN_NON_ZDR_MODELS = /* @__PURE__ */ new Set([
|
|
|
433
441
|
"minimax/minimax-m3-free",
|
|
434
442
|
"poolside/laguna-s-2.1-free",
|
|
435
443
|
"sakana/fugu-ultra",
|
|
444
|
+
"stealth/space-bunny-alpha",
|
|
436
445
|
"stepfun/Step-3.7-Flash",
|
|
437
446
|
"stepfun/Step-5-Preview",
|
|
438
447
|
"xai/grok-4.5",
|
|
@@ -565,7 +574,11 @@ function requiresMessagesEndpoint(modelId) {
|
|
|
565
574
|
* and 1.60.0 added `stepfun/Step-5-Preview` (Go); command-code@1.62.0 added the
|
|
566
575
|
* MiMo V2.6 family — `xiaomi/mimo-v2.6-flash` + `xiaomi/mimo-v2.6-pro` (Go) and
|
|
567
576
|
* `xiaomi/mimo-v2.6-pro-ultraspeed` (GOAT) — so the 1.58.0 -> 1.62.0 window's
|
|
568
|
-
* only tier changes are additions and the superset chain still holds.
|
|
577
|
+
* only tier changes are additions and the superset chain still holds. The
|
|
578
|
+
* 1.62.0 -> 1.65.0 window continues the pattern: 1.64.0 added
|
|
579
|
+
* `claude-opus-5-5` (Provider/Max), `gpt-6-sol` (Pro) and `gpt-6-luna` (Go),
|
|
580
|
+
* and 1.65.0 added `stealth/space-bunny-alpha` (Go, every tier) — additions
|
|
581
|
+
* only, no tier moves.
|
|
569
582
|
*
|
|
570
583
|
* The Provider API exposes no plan metadata, so this snapshot is the source of
|
|
571
584
|
* truth for the picker's plan annotation — it answers "which plan do I need to
|
|
@@ -610,6 +623,7 @@ const KNOWN_PLANS = {
|
|
|
610
623
|
"stepfun/Step-3.5-Flash": "go",
|
|
611
624
|
"stepfun/Step-3.7-Flash": "go",
|
|
612
625
|
"stepfun/Step-5-Preview": "go",
|
|
626
|
+
"stealth/space-bunny-alpha": "go",
|
|
613
627
|
"tencent/hy3-paid": "go",
|
|
614
628
|
"tencent/hy4-preview": "go",
|
|
615
629
|
"thinkingmachines/inkling": "go",
|
|
@@ -817,6 +831,10 @@ const KNOWN_DEALS = {
|
|
|
817
831
|
"inclusionai/ling-3.0-flash-sante:free": {
|
|
818
832
|
label: "FREE",
|
|
819
833
|
free: true
|
|
834
|
+
},
|
|
835
|
+
"stealth/space-bunny-alpha": {
|
|
836
|
+
label: "FREE",
|
|
837
|
+
free: true
|
|
820
838
|
}
|
|
821
839
|
};
|
|
822
840
|
/**
|
|
@@ -2600,9 +2618,11 @@ const REQUEST_IMAGE_MAX_ENCODED_BYTES = 1048576;
|
|
|
2600
2618
|
* never returns a zero dimension (a 1-px degenerate side is what the round of
|
|
2601
2619
|
* an extreme aspect ratio can produce, and a 0 would make the encoder refuse).
|
|
2602
2620
|
*
|
|
2603
|
-
*
|
|
2604
|
-
*
|
|
2605
|
-
*
|
|
2621
|
+
* `dsh-attachment` exports an equivalent `longEdgeDimensions`, but it does not
|
|
2622
|
+
* guard its inputs: a reference whose declared size is 0 or NaN — a malformed
|
|
2623
|
+
* or fabricated attachment record — would project to a zero-sized target and
|
|
2624
|
+
* make the encoder refuse the whole request. The guard is the reason this stays
|
|
2625
|
+
* local; `tests/image-tokens.test.ts` pins the degenerate cases.
|
|
2606
2626
|
*/
|
|
2607
2627
|
function longEdgeDimensions(width, height, longEdge) {
|
|
2608
2628
|
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return {
|
|
@@ -2623,16 +2643,11 @@ function longEdgeDimensions(width, height, longEdge) {
|
|
|
2623
2643
|
}
|
|
2624
2644
|
/**
|
|
2625
2645
|
* The request target for one normalized attachment: its aspect ratio under the
|
|
2626
|
-
* long-edge budget, plus the byte budget
|
|
2627
|
-
*
|
|
2628
|
-
* The area is computed from the PROJECTED dimensions rather than the source's,
|
|
2629
|
-
* so ≤0.1.5's own pixel projection lands on the same geometry instead of
|
|
2630
|
-
* re-deriving a slightly different one from the original.
|
|
2646
|
+
* long-edge budget, plus the encoded-byte budget.
|
|
2631
2647
|
*/
|
|
2632
2648
|
function requestImageTarget(ref) {
|
|
2633
2649
|
const projected = longEdgeDimensions(ref.width, ref.height, REQUEST_IMAGE_MAX_LONG_EDGE);
|
|
2634
2650
|
return {
|
|
2635
|
-
maxPixels: projected.width * projected.height,
|
|
2636
2651
|
width: projected.width,
|
|
2637
2652
|
height: projected.height,
|
|
2638
2653
|
maxBytes: REQUEST_IMAGE_MAX_ENCODED_BYTES
|
|
@@ -3002,7 +3017,7 @@ function openStreamTrace(scope, options = {}) {
|
|
|
3002
3017
|
* per-request options thunk and an API-key resolver from the plugin entry
|
|
3003
3018
|
* (src/index.ts), so a settings change reaches the very next request.
|
|
3004
3019
|
*/
|
|
3005
|
-
const COMMAND_CODE_CLI_VERSION = "1.
|
|
3020
|
+
const COMMAND_CODE_CLI_VERSION = "1.65.0";
|
|
3006
3021
|
const DEFAULT_API_BASE = "https://api.commandcode.ai";
|
|
3007
3022
|
const DEFAULT_GENERATE_MAX_TOKENS = 64e3;
|
|
3008
3023
|
const DEFAULT_MAX_OUTPUT_TOKENS = 65536;
|
|
@@ -3383,32 +3398,24 @@ async function writeModelsCache(cachePath, models) {
|
|
|
3383
3398
|
}
|
|
3384
3399
|
}
|
|
3385
3400
|
/**
|
|
3386
|
-
*
|
|
3387
|
-
* content blocks. Older engines wrap those fields in the first tool-result
|
|
3388
|
-
* block of a role:'user' message. Read structurally so the bundle still builds
|
|
3389
|
-
* and loads against older peers. Pairing and emission MUST use this same view:
|
|
3390
|
-
* otherwise a dropped result either drops its call too (making the model
|
|
3391
|
-
* forget completed work), or leaves an unanswered call on the wire.
|
|
3401
|
+
* The tool result one message answers, or undefined when it answers none.
|
|
3392
3402
|
*
|
|
3393
|
-
*
|
|
3394
|
-
*
|
|
3395
|
-
*
|
|
3403
|
+
* The harness models a tool result as its own `role: 'tool'` message carrying
|
|
3404
|
+
* `toolCallId`/`isError` beside raw content blocks (a closed role map:
|
|
3405
|
+
* `MessageRoleMap.tool` is the only role a tool result can arrive on). Pairing
|
|
3406
|
+
* and emission MUST agree on this same view: otherwise a dropped result either
|
|
3407
|
+
* drops its call too (making the model forget completed work), or leaves an
|
|
3408
|
+
* unanswered call on the wire.
|
|
3396
3409
|
*/
|
|
3397
3410
|
function toolResultOf(message) {
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
}
|
|
3407
|
-
if (message.role !== "user") return void 0;
|
|
3408
|
-
const kind = message.source?.kind;
|
|
3409
|
-
if (kind !== void 0 && kind !== "tool") return void 0;
|
|
3410
|
-
const block = message.content[0];
|
|
3411
|
-
return block?.type === "tool-result" ? block : void 0;
|
|
3411
|
+
if (message.role !== "tool") return void 0;
|
|
3412
|
+
const { toolCallId, content } = message;
|
|
3413
|
+
if (typeof toolCallId !== "string" || toolCallId === "") return void 0;
|
|
3414
|
+
return {
|
|
3415
|
+
toolCallId,
|
|
3416
|
+
isError: message.isError ?? false,
|
|
3417
|
+
content
|
|
3418
|
+
};
|
|
3412
3419
|
}
|
|
3413
3420
|
/**
|
|
3414
3421
|
* Collect the tool calls that have a paired tool result, plus each call's
|
|
@@ -3481,23 +3488,16 @@ function toolResultMedia(block) {
|
|
|
3481
3488
|
const chunks = [];
|
|
3482
3489
|
const images = [];
|
|
3483
3490
|
const seen = /* @__PURE__ */ new Set();
|
|
3484
|
-
const
|
|
3485
|
-
|
|
3486
|
-
if (nested.
|
|
3487
|
-
|
|
3488
|
-
continue;
|
|
3489
|
-
}
|
|
3490
|
-
if (nested.type === "image") {
|
|
3491
|
-
if (!seen.has(nested.attachment.attachmentId)) {
|
|
3492
|
-
seen.add(nested.attachment.attachmentId);
|
|
3493
|
-
images.push(nested.attachment);
|
|
3494
|
-
}
|
|
3495
|
-
continue;
|
|
3496
|
-
}
|
|
3497
|
-
if (nested.type === "tool-result") walk(nested.content);
|
|
3491
|
+
for (const nested of block.content) {
|
|
3492
|
+
if (nested.type === "text" || nested.type === "reasoning") {
|
|
3493
|
+
if (nested.text) chunks.push(nested.text);
|
|
3494
|
+
continue;
|
|
3498
3495
|
}
|
|
3499
|
-
|
|
3500
|
-
|
|
3496
|
+
if (nested.type === "image" && !seen.has(nested.attachment.attachmentId)) {
|
|
3497
|
+
seen.add(nested.attachment.attachmentId);
|
|
3498
|
+
images.push(nested.attachment);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
3501
|
return {
|
|
3502
3502
|
text: chunks.join("\n"),
|
|
3503
3503
|
images
|
|
@@ -3542,8 +3542,7 @@ function toolResultImageNote(media, toolCallId) {
|
|
|
3542
3542
|
return `${lead} ${media.images.length > 1 ? `${media.images.length} images, ` : ""}${dimensions}`;
|
|
3543
3543
|
}
|
|
3544
3544
|
function hasImageContent(message) {
|
|
3545
|
-
|
|
3546
|
-
return check(message.content);
|
|
3545
|
+
return message.content.some((block) => block.type === "image");
|
|
3547
3546
|
}
|
|
3548
3547
|
/** The budget ladder: the primary rung first, the 413 eviction rung second. */
|
|
3549
3548
|
const REQUEST_IMAGE_BUDGETS = [{
|
|
@@ -3557,68 +3556,13 @@ const REQUEST_IMAGE_BUDGETS = [{
|
|
|
3557
3556
|
byteQuantum: 8388608,
|
|
3558
3557
|
countQuantum: 12
|
|
3559
3558
|
}];
|
|
3559
|
+
/** The engine's own helpers: what a process that injects nothing speaks. */
|
|
3560
|
+
const ENGINE_IMAGE_POLICY = {
|
|
3561
|
+
projectOffloadedImages,
|
|
3562
|
+
requiredImageOffload
|
|
3563
|
+
};
|
|
3560
3564
|
/**
|
|
3561
|
-
*
|
|
3562
|
-
* oldest images past it become placeholder text in place, the newest keep their
|
|
3563
|
-
* bytes, and a history already inside the budget is returned as the SAME array
|
|
3564
|
-
* — the caller uses that identity to tell "nothing evicted" from "evicted".
|
|
3565
|
-
*
|
|
3566
|
-
* Nested tool-result images ride the same core walk, which is exactly right
|
|
3567
|
-
* for this adapter: an evicted `read_image` result surfaces its placeholder as
|
|
3568
|
-
* the tool message's own text, so no carrier user message is emitted for it.
|
|
3569
|
-
*/
|
|
3570
|
-
function projectRequestImages(messages, budget, policy) {
|
|
3571
|
-
const offload = policy.offloadRequestImagesWithPolicy;
|
|
3572
|
-
if (typeof offload !== "function") return messages;
|
|
3573
|
-
return offload(messages, {
|
|
3574
|
-
representation: "base64",
|
|
3575
|
-
maxBytes: budget.maxBytes,
|
|
3576
|
-
maxImages: budget.maxImages,
|
|
3577
|
-
byteQuantum: budget.byteQuantum,
|
|
3578
|
-
countQuantum: budget.countQuantum,
|
|
3579
|
-
placeholder: (ref) => offloadedImageText(ref)
|
|
3580
|
-
});
|
|
3581
|
-
}
|
|
3582
|
-
/**
|
|
3583
|
-
* The request options one budget produced: the caller's own object when the
|
|
3584
|
-
* history was already inside the budget, else a copy carrying the projection.
|
|
3585
|
-
* The next rung of the ladder is applied to the CURRENT projection, never to
|
|
3586
|
-
* the raw history — otherwise a retry could reintroduce images the first rung
|
|
3587
|
-
* had already evicted.
|
|
3588
|
-
*/
|
|
3589
|
-
function withImageBudget(options, budget, policy) {
|
|
3590
|
-
const projected = projectRequestImages(options.messages, budget, policy);
|
|
3591
|
-
return projected === options.messages ? options : {
|
|
3592
|
-
...options,
|
|
3593
|
-
messages: [...projected]
|
|
3594
|
-
};
|
|
3595
|
-
}
|
|
3596
|
-
/**
|
|
3597
|
-
* Stable provider-neutral code for "a request still carries more images than
|
|
3598
|
-
* this route will send; offload N of them and retry". Declared locally rather
|
|
3599
|
-
* than imported: the constant does not exist on the 0.1.2–0.1.5 peers this
|
|
3600
|
-
* plugin still supports, and importing it statically is the link-time failure
|
|
3601
|
-
* described above the budget constants.
|
|
3602
|
-
*/
|
|
3603
|
-
const IMAGE_OFFLOAD_REQUIRED_CODE = "IMAGE_OFFLOAD_REQUIRED";
|
|
3604
|
-
/** The installed engine's image policy; see {@link CoreImagePolicy}. */
|
|
3605
|
-
const CORE_IMAGE_POLICY = dshLlm;
|
|
3606
|
-
/**
|
|
3607
|
-
* The durable-offload contract this engine speaks, or undefined on ≤0.1.5.
|
|
3608
|
-
*
|
|
3609
|
-
* Both members are required together: a half-populated engine would either
|
|
3610
|
-
* lose the surface's marks (re-sending evicted images as pixels) or lose the
|
|
3611
|
-
* count (silently sending an over-budget body), and neither is worth a partial
|
|
3612
|
-
* opt-in. Absent, the adapter keeps its own transient projection instead.
|
|
3613
|
-
*/
|
|
3614
|
-
function surfaceImagePolicy(api = CORE_IMAGE_POLICY) {
|
|
3615
|
-
return typeof api.projectOffloadedImages === "function" && typeof api.requiredImageOffload === "function" ? {
|
|
3616
|
-
projectOffloadedImages: api.projectOffloadedImages,
|
|
3617
|
-
requiredImageOffload: api.requiredImageOffload
|
|
3618
|
-
} : void 0;
|
|
3619
|
-
}
|
|
3620
|
-
/**
|
|
3621
|
-
* The failure a route raises instead of evicting on its own (≥0.1.6). The
|
|
3565
|
+
* The failure a route raises instead of evicting on its own. The
|
|
3622
3566
|
* count is the ONE thing the harness needs: `dsh-compaction-image-offload`
|
|
3623
3567
|
* records it as an `image/offload` event, marks that many oldest retained
|
|
3624
3568
|
* occurrences, and retries the step.
|
|
@@ -3647,10 +3591,14 @@ function coreBudget(budget) {
|
|
|
3647
3591
|
*/
|
|
3648
3592
|
const imageVersionBytes = (block) => block.attachment.bytes;
|
|
3649
3593
|
/**
|
|
3650
|
-
*
|
|
3651
|
-
* and an over-budget history FAILS with the count to offload
|
|
3652
|
-
* evicted here. Throws rather than returning, so no caller can
|
|
3653
|
-
* send a body this route already knows is too large.
|
|
3594
|
+
* Request options under one budget rung: the surface's durable marks become
|
|
3595
|
+
* placeholder text, and an over-budget history FAILS with the count to offload
|
|
3596
|
+
* instead of being evicted here. Throws rather than returning, so no caller can
|
|
3597
|
+
* accidentally send a body this route already knows is too large.
|
|
3598
|
+
*
|
|
3599
|
+
* The next rung is applied to the CURRENT projection, never to the raw history —
|
|
3600
|
+
* otherwise the 413 retry could reintroduce images the first rung had already
|
|
3601
|
+
* evicted.
|
|
3654
3602
|
*/
|
|
3655
3603
|
function withSurfaceOffload(options, policy, budget) {
|
|
3656
3604
|
const marked = policy.projectOffloadedImages(options.messages, (ref) => offloadedImageText(ref));
|
|
@@ -3663,21 +3611,17 @@ function withSurfaceOffload(options, policy, budget) {
|
|
|
3663
3611
|
};
|
|
3664
3612
|
}
|
|
3665
3613
|
/**
|
|
3666
|
-
* One image's bytes for the wire: the attachment service's REQUEST VERSION
|
|
3667
|
-
* it can produce one, else the normalized original.
|
|
3614
|
+
* One image's bytes for the wire: the attachment service's REQUEST VERSION.
|
|
3668
3615
|
*
|
|
3669
3616
|
* `readImage()` answers the stored original, which is what admission accepted —
|
|
3670
3617
|
* not what a provider request should carry. `readImageRequest()` re-encodes to
|
|
3671
3618
|
* the route target in `./image-request.ts` and caches the result under it, so
|
|
3672
3619
|
* the same attachment costs one encode per target instead of one per occurrence,
|
|
3673
3620
|
* and the base64 the wire expands is bounded (both the pixel budget and, more to
|
|
3674
|
-
* the point here, the encoded bytes).
|
|
3675
|
-
* not implement the abstract method; every engine this plugin declares support
|
|
3676
|
-
* for does.
|
|
3621
|
+
* the point here, the encoded bytes).
|
|
3677
3622
|
*/
|
|
3678
3623
|
async function readRequestImage(attachments, ref) {
|
|
3679
|
-
|
|
3680
|
-
return (await attachments.readImage(ref)).data;
|
|
3624
|
+
return (await attachments.readImageRequest(ref, requestImageTarget(ref))).data;
|
|
3681
3625
|
}
|
|
3682
3626
|
/**
|
|
3683
3627
|
* Price one request occurrence.
|
|
@@ -3686,13 +3630,12 @@ async function readRequestImage(attachments, ref) {
|
|
|
3686
3630
|
* model-visible TEXT so the caller's estimator can charge that instead: a model
|
|
3687
3631
|
* that accepts text only (the harness projects those images to placeholder text
|
|
3688
3632
|
* before the request), and an occurrence the session surface has already
|
|
3689
|
-
* offloaded (
|
|
3690
|
-
*
|
|
3691
|
-
*
|
|
3633
|
+
* offloaded (the same placeholder text rides in every later request). A retained
|
|
3634
|
+
* occurrence on this route contributes no text at all — the pixels are inlined —
|
|
3635
|
+
* so its price is the family's visual-token count and nothing else.
|
|
3692
3636
|
*/
|
|
3693
|
-
function priceRequestImage(
|
|
3694
|
-
const
|
|
3695
|
-
const ref = block.attachment ?? occurrence;
|
|
3637
|
+
function priceRequestImage(block, model, imageCapable) {
|
|
3638
|
+
const ref = block.attachment;
|
|
3696
3639
|
if (!imageCapable) return {
|
|
3697
3640
|
visualTokens: 0,
|
|
3698
3641
|
text: textOnlyImageText(ref)
|
|
@@ -4225,13 +4168,9 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
4225
4168
|
catalog = [];
|
|
4226
4169
|
fetchImpl;
|
|
4227
4170
|
resolveAttachments;
|
|
4228
|
-
/** The engine's request-image policy, resolved once (tests may inject one). */
|
|
4229
|
-
imagePolicy;
|
|
4230
4171
|
/**
|
|
4231
|
-
* The
|
|
4232
|
-
*
|
|
4233
|
-
* speaks cannot change while it runs, and resolving here keeps every request
|
|
4234
|
-
* on the same branch (see {@link surfaceImagePolicy}).
|
|
4172
|
+
* The durable-offload contract, resolved once (tests may inject a stub). The
|
|
4173
|
+
* contract cannot change while the process runs.
|
|
4235
4174
|
*/
|
|
4236
4175
|
surfaceOffload;
|
|
4237
4176
|
billingAccess = /* @__PURE__ */ new Map();
|
|
@@ -4242,8 +4181,7 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
4242
4181
|
this.deps = deps;
|
|
4243
4182
|
this.fetchImpl = deps.fetchImpl ?? fetch;
|
|
4244
4183
|
this.resolveAttachments = deps.resolveAttachments;
|
|
4245
|
-
this.
|
|
4246
|
-
this.surfaceOffload = surfaceImagePolicy(this.imagePolicy);
|
|
4184
|
+
this.surfaceOffload = deps.imageOffload ?? ENGINE_IMAGE_POLICY;
|
|
4247
4185
|
}
|
|
4248
4186
|
/**
|
|
4249
4187
|
* Display metadata for the picker's provider group header. The base class
|
|
@@ -4727,8 +4665,7 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
4727
4665
|
const reasoningEffort = effort && effort !== "off" && supported?.includes(effort) ? effort : void 0;
|
|
4728
4666
|
const systemText = [options.system ?? "", ...options.messages.filter((m) => m.role === "system").map((m) => m.content.map(blockText).filter(Boolean).join("\n"))].filter(Boolean).join("\n\n");
|
|
4729
4667
|
let protocol = this.resolveProtocol(apiKey, options.model);
|
|
4730
|
-
let requestOptions =
|
|
4731
|
-
let imageBudgetIndex = 0;
|
|
4668
|
+
let requestOptions = withSurfaceOffload(options, this.surfaceOffload, REQUEST_IMAGE_BUDGETS[0]);
|
|
4732
4669
|
const buildBody = async (target) => target === "cli" ? buildCliBody(requestOptions, connection, {
|
|
4733
4670
|
maxTokens,
|
|
4734
4671
|
reasoningEffort,
|
|
@@ -4761,19 +4698,9 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
4761
4698
|
body = await buildBody("cli");
|
|
4762
4699
|
continue;
|
|
4763
4700
|
}
|
|
4764
|
-
if (attempt.status === 413 &&
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
if (missing > 0) throw imageOffloadRequired(missing);
|
|
4768
|
-
} else {
|
|
4769
|
-
const tightened = withImageBudget(requestOptions, REQUEST_IMAGE_BUDGETS[imageBudgetIndex + 1], this.imagePolicy);
|
|
4770
|
-
if (tightened !== requestOptions) {
|
|
4771
|
-
imageBudgetIndex += 1;
|
|
4772
|
-
requestOptions = tightened;
|
|
4773
|
-
body = await buildBody(protocol);
|
|
4774
|
-
continue;
|
|
4775
|
-
}
|
|
4776
|
-
}
|
|
4701
|
+
if (attempt.status === 413 && REQUEST_IMAGE_BUDGETS.length > 1) {
|
|
4702
|
+
const missing = this.surfaceOffload.requiredImageOffload(requestOptions.messages, coreBudget(REQUEST_IMAGE_BUDGETS[1]), imageVersionBytes);
|
|
4703
|
+
if (missing > 0) throw imageOffloadRequired(missing);
|
|
4777
4704
|
}
|
|
4778
4705
|
const rotate = this.deps.rotateApiKey;
|
|
4779
4706
|
const rejection = classifyAccountRejection(attempt.status, attempt.errText);
|
|
@@ -5700,7 +5627,6 @@ function makeStrictCodec(typeSymbol, schema) {
|
|
|
5700
5627
|
return {
|
|
5701
5628
|
mode: "strict",
|
|
5702
5629
|
typeSymbol,
|
|
5703
|
-
schema,
|
|
5704
5630
|
create: () => schema
|
|
5705
5631
|
};
|
|
5706
5632
|
}
|
|
@@ -5712,7 +5638,6 @@ function makeStrictCodec(typeSymbol, schema) {
|
|
|
5712
5638
|
* only its own facts.
|
|
5713
5639
|
*/
|
|
5714
5640
|
function makeRemoteDescriptor(endpoint, method, typeSymbol, schema) {
|
|
5715
|
-
const result = makeStrictCodec(typeSymbol, schema);
|
|
5716
5641
|
return {
|
|
5717
5642
|
id: `${REMOTE_PACKAGE}#${endpoint}`,
|
|
5718
5643
|
service: REMOTE_SERVICE,
|
|
@@ -5720,7 +5645,7 @@ function makeRemoteDescriptor(endpoint, method, typeSymbol, schema) {
|
|
|
5720
5645
|
method,
|
|
5721
5646
|
invocation: { kind: "direct" },
|
|
5722
5647
|
parameters: [],
|
|
5723
|
-
result
|
|
5648
|
+
result: makeStrictCodec(typeSymbol, schema)
|
|
5724
5649
|
};
|
|
5725
5650
|
}
|
|
5726
5651
|
//#endregion
|
|
@@ -6643,30 +6568,6 @@ const COMMANDCODE_SEARCH_PROVIDER_ID = "commandcode";
|
|
|
6643
6568
|
* modsearch even with Command Code search turned off (issue #26).
|
|
6644
6569
|
*/
|
|
6645
6570
|
const DEFAULT_WEB_SEARCH_PROVIDER_ID = "deepseek-official";
|
|
6646
|
-
/**
|
|
6647
|
-
* Point the web seam's search selection at this plugin's provider (`commandcode`).
|
|
6648
|
-
* Sets the runtime field; the next search call honours it because `search()`
|
|
6649
|
-
* re-reads `searchProviderId` each time. Returns the prior id (or undefined).
|
|
6650
|
-
* Never throws: a hardened/frozen runtime shape must not break the
|
|
6651
|
-
* settings-save path that calls this — the provider simply stays
|
|
6652
|
-
* registered-but-unselected (the boot-time `searchProvider: commandcode`
|
|
6653
|
-
* cordis patch is the durable alternative).
|
|
6654
|
-
*
|
|
6655
|
-
* @deprecated Prefer {@link applyCommandCodeSearchSelection}: this overload
|
|
6656
|
-
* always overwrites the displaced backend with the factory default on
|
|
6657
|
-
* disable, so turning Command Code search off silences whichever provider
|
|
6658
|
-
* was selected before (e.g. modsearch) instead of restoring it (issue #26).
|
|
6659
|
-
*/
|
|
6660
|
-
function selectCommandCodeSearchProvider(web, enable) {
|
|
6661
|
-
try {
|
|
6662
|
-
const field = web;
|
|
6663
|
-
const prior = field.searchProviderId;
|
|
6664
|
-
field.searchProviderId = enable ? COMMANDCODE_SEARCH_PROVIDER_ID : DEFAULT_WEB_SEARCH_PROVIDER_ID;
|
|
6665
|
-
return prior;
|
|
6666
|
-
} catch {
|
|
6667
|
-
return;
|
|
6668
|
-
}
|
|
6669
|
-
}
|
|
6670
6571
|
/** Fresh selection state: the plugin starts out not owning the selection. */
|
|
6671
6572
|
function commandCodeSearchSelection() {
|
|
6672
6573
|
return {
|
|
@@ -7378,8 +7279,8 @@ function transportBudgetMessage(failureMessage, maxRetries) {
|
|
|
7378
7279
|
* as an internal advisor instead: the command guard in `./command-guard.ts`
|
|
7379
7280
|
* asks it whether a shell command is safe to auto-approve.
|
|
7380
7281
|
*
|
|
7381
|
-
* The three question types are the whole vocabulary (command-code@1.
|
|
7382
|
-
* `systemOneRequestSchema
|
|
7282
|
+
* The three question types are the whole vocabulary (command-code@1.65.0
|
|
7283
|
+
* `systemOneRequestSchema`, unchanged since 1.64.0):
|
|
7383
7284
|
*
|
|
7384
7285
|
* - `noul` — "is this true?", optional `criteria: { true, false }` describing
|
|
7385
7286
|
* each verdict. Answers with `noul`, the probability of *yes*.
|
|
@@ -7714,7 +7615,7 @@ const COMMAND_GUARD_DENY_LIST = [
|
|
|
7714
7615
|
},
|
|
7715
7616
|
{
|
|
7716
7617
|
id: "device-redirect",
|
|
7717
|
-
pattern:
|
|
7618
|
+
pattern: />{1,2}\s*\/dev\/(?:sd|disk|nvme|hd)/
|
|
7718
7619
|
},
|
|
7719
7620
|
{
|
|
7720
7621
|
id: "fork-bomb",
|
|
@@ -8099,25 +8000,58 @@ function applyCommandGuard(ctx, deps) {
|
|
|
8099
8000
|
//#endregion
|
|
8100
8001
|
//#region src/config-volatile.ts
|
|
8101
8002
|
/**
|
|
8102
|
-
*
|
|
8103
|
-
*
|
|
8104
|
-
*
|
|
8105
|
-
*
|
|
8003
|
+
* Volatile-config helpers for dsh 0.1.7's schema-derived profile Config.
|
|
8004
|
+
*
|
|
8005
|
+
* 0.1.7 rewrote settings around profile Config: `settings.describe()` projects
|
|
8006
|
+
* each active entry's schema through `volatileForm()`, so a form contains ONLY
|
|
8007
|
+
* fields whose schema nodes carry `meta.volatile`, and a form edit is refused
|
|
8008
|
+
* unless its path lies beneath a marked node. On that generation the loader
|
|
8009
|
+
* resolves each marked top-level field into a readonly `Volatile<T>` reference
|
|
8010
|
+
* (`{ get() }`, frozen, written in place by the owning runtime) instead of a
|
|
8011
|
+
* plain value, commits later changes WITHOUT remounting the fiber, and
|
|
8012
|
+
* dispatches `loader/volatile-update` to the owning fiber.
|
|
8013
|
+
*
|
|
8014
|
+
* Two helpers keep the rest of the plugin reading a PLAIN `Config`:
|
|
8015
|
+
*
|
|
8016
|
+
* - `markVolatile(schema)` applies `.volatile()`, so 0.1.7's forms see every
|
|
8017
|
+
* field we mark. The declared type is preserved through the mark on purpose:
|
|
8018
|
+
* it changes what the schema PARSES to (a live reference), not the
|
|
8019
|
+
* plugin-facing `Config` shape every consumer reads.
|
|
8020
|
+
* - `unwrapVolatileConfig(config)` reads every top-level field through its
|
|
8021
|
+
* reference when one is present — returning a FRESH object per call, since
|
|
8022
|
+
* a reference's identity is stable while its value changes — and returns the
|
|
8023
|
+
* config untouched when none is.
|
|
8024
|
+
*
|
|
8025
|
+
* Only TOP-LEVEL fields are marked (form writes name top-level paths such as
|
|
8026
|
+
* `accounts` or `modelVisibility.<id>`, whose first segment is the marked
|
|
8027
|
+
* node), so one unwrap level is complete. The literal `apiKey` secret stays
|
|
8028
|
+
* unmarked on purpose: no settings surface writes it — the settings page and
|
|
8029
|
+
* the dsh-TUI section both write keys through the credentials seam — so it
|
|
8030
|
+
* keeps composition-only semantics, and a config-file edit to it reloading the
|
|
8031
|
+
* fiber is the correct behavior for a secret literal.
|
|
8032
|
+
*
|
|
8033
|
+
* @module dsh-commandcode-provider/config-volatile
|
|
8034
|
+
*/
|
|
8035
|
+
/**
|
|
8036
|
+
* Mark one schema field volatile.
|
|
8037
|
+
*
|
|
8038
|
+
* `.volatile()` is unconditional: the mark is a schemastery 3.18.3 feature and
|
|
8039
|
+
* the only engine this bundle supports (`dsh 0.1.7-rc.1`) pins `~3.18.4`, so
|
|
8040
|
+
* the method is always present. It is reached through a structural member
|
|
8041
|
+
* rather than schemastery's own typing so the function can keep the caller's
|
|
8042
|
+
* declared field type, which is what lets `Config` stay the plain shape every
|
|
8043
|
+
* consumer reads while the schema parses to live references.
|
|
8044
|
+
*
|
|
8045
|
+
* @param schema - The field schema.
|
|
8046
|
+
* @returns The schema carrying `meta.volatile`.
|
|
8106
8047
|
*/
|
|
8107
8048
|
function markVolatile(schema) {
|
|
8108
|
-
|
|
8109
|
-
if (typeof candidate.volatile !== "function") return schema;
|
|
8110
|
-
return candidate.volatile();
|
|
8049
|
+
return schema.volatile();
|
|
8111
8050
|
}
|
|
8112
8051
|
/**
|
|
8113
8052
|
* Mark every field of a Config field dict volatile, except the named
|
|
8114
8053
|
* composition-only secrets (`apiKey` here, which no settings surface writes).
|
|
8115
8054
|
*
|
|
8116
|
-
* The result is a NEW dict of schema instances: callers that also need an
|
|
8117
|
-
* UNMARKED schema for the legacy settings generation must build the fields
|
|
8118
|
-
* twice (`configFields()`), never share one dict — `.volatile()` clones per
|
|
8119
|
-
* call, and a shared instance would carry the mark into the legacy schema.
|
|
8120
|
-
*
|
|
8121
8055
|
* @param fields - Freshly built field schemas.
|
|
8122
8056
|
* @param skip - Field names that must stay unmarked.
|
|
8123
8057
|
* @returns The field dict with every non-skipped field marked.
|
|
@@ -8138,24 +8072,21 @@ function isVolatileRef(value) {
|
|
|
8138
8072
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.isFrozen(value) && typeof value.get === "function";
|
|
8139
8073
|
}
|
|
8140
8074
|
/**
|
|
8141
|
-
* Read one config object as PLAIN values
|
|
8075
|
+
* Read one config object as PLAIN values.
|
|
8142
8076
|
*
|
|
8143
|
-
*
|
|
8077
|
+
* Every top-level field found to be a volatile reference is read through
|
|
8144
8078
|
* `.get()` — freshly on every call, so a live update lands on the very next
|
|
8145
|
-
* read.
|
|
8146
|
-
*
|
|
8147
|
-
*
|
|
8079
|
+
* read. The loader resolves EVERY marked node into a reference, unset fields
|
|
8080
|
+
* included, so a loader-parsed config always yields a fresh object here; the
|
|
8081
|
+
* pass-through for a field that is not a reference is what keeps the unmarked
|
|
8082
|
+
* `apiKey` literal readable.
|
|
8148
8083
|
*/
|
|
8149
8084
|
function unwrapVolatileConfig(config) {
|
|
8150
8085
|
const source = config;
|
|
8151
8086
|
if (typeof source !== "object" || source === null) return config;
|
|
8152
|
-
let found = false;
|
|
8153
8087
|
const plain = {};
|
|
8154
|
-
for (const [field, value] of Object.entries(source))
|
|
8155
|
-
|
|
8156
|
-
found = true;
|
|
8157
|
-
} else plain[field] = value;
|
|
8158
|
-
return found ? plain : config;
|
|
8088
|
+
for (const [field, value] of Object.entries(source)) plain[field] = isVolatileRef(value) ? value.get() : value;
|
|
8089
|
+
return plain;
|
|
8159
8090
|
}
|
|
8160
8091
|
//#endregion
|
|
8161
8092
|
//#region src/index.ts
|
|
@@ -8167,10 +8098,9 @@ function unwrapVolatileConfig(config) {
|
|
|
8167
8098
|
* the configurable-provider directory, so the web Models page shows a
|
|
8168
8099
|
* "Command Code" card with an API-key field and the model picker lists the
|
|
8169
8100
|
* live Command Code model catalog. Connection facts resolve per request over
|
|
8170
|
-
* the plugin's live
|
|
8171
|
-
*
|
|
8172
|
-
*
|
|
8173
|
-
* reaches the next request without a restart.
|
|
8101
|
+
* the plugin's live profile Config (volatile fields, unwrapped per read) and
|
|
8102
|
+
* the credential seam, so a changed key, endpoint, or cache path reaches the
|
|
8103
|
+
* next request without a restart.
|
|
8174
8104
|
*
|
|
8175
8105
|
* ```yaml
|
|
8176
8106
|
* - id: llm-commandcode
|
|
@@ -8196,87 +8126,55 @@ const PROVIDER = "commandcode";
|
|
|
8196
8126
|
/** Default models cache path (mirrors the pi plugin's on-disk cache). */
|
|
8197
8127
|
const DEFAULT_MODELS_CACHE_PATH = join(homedir(), ".commandcode", "models-cache.json");
|
|
8198
8128
|
/**
|
|
8199
|
-
* The Config schema
|
|
8200
|
-
*
|
|
8201
|
-
* A FACTORY, not a shared dict, and that is load-bearing: the exported
|
|
8202
|
-
* {@link Config} marks every field volatile while {@link LegacySettingsSchema}
|
|
8203
|
-
* must carry no mark at all, and schemastery's schema instances are
|
|
8204
|
-
* single-purpose objects — sharing one dict would leak the marks into the
|
|
8205
|
-
* legacy registration (see `config-volatile.ts` for why that is a boot-time
|
|
8206
|
-
* `ValidationError` on ≤0.1.6 engines whose schemastery resolved to ≥3.18.3).
|
|
8207
|
-
*
|
|
8208
|
-
* @returns One fresh schema instance per Config field.
|
|
8209
|
-
*/
|
|
8210
|
-
function configFields() {
|
|
8211
|
-
return {
|
|
8212
|
-
apiKeyEnv: z.string().role("credential-ref").default(DEFAULT_API_KEY_ENV),
|
|
8213
|
-
apiKey: z.string().role("secret"),
|
|
8214
|
-
apiBase: z.string(),
|
|
8215
|
-
workingDir: z.string(),
|
|
8216
|
-
modelsCachePath: z.string(),
|
|
8217
|
-
requestTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS),
|
|
8218
|
-
streamIdleTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS),
|
|
8219
|
-
transportMaxRetries: z.number().min(0).max(50),
|
|
8220
|
-
filterModelsByPlan: z.boolean(),
|
|
8221
|
-
visibleModels: z.array(z.string()),
|
|
8222
|
-
/**
|
|
8223
|
-
* Per-model visibility overrides for the terminal settings page's checkbox
|
|
8224
|
-
* list, keyed by catalog id. dsh-TUI addresses a staged edit by its field
|
|
8225
|
-
* PATH, so two checkboxes sharing one path would overwrite each other's
|
|
8226
|
-
* draft and the section's last model would decide every write; a map gives
|
|
8227
|
-
* each checkbox a path of its own. An id listed here wins over
|
|
8228
|
-
* {@link Config.visibleModels}; ids absent here keep following it.
|
|
8229
|
-
*/
|
|
8230
|
-
modelVisibility: z.dict(z.boolean()),
|
|
8231
|
-
webSearch: z.boolean().default(true),
|
|
8232
|
-
showSidebarQuota: z.boolean().default(false),
|
|
8233
|
-
accounts: z.array(z.object({
|
|
8234
|
-
label: z.string(),
|
|
8235
|
-
apiKeyEnv: z.string().role("credential-ref"),
|
|
8236
|
-
/** Literal key for one extra slot; see the top-level `apiKey` secret note. */
|
|
8237
|
-
apiKey: z.string().role("secret")
|
|
8238
|
-
})),
|
|
8239
|
-
activeAccount: z.string(),
|
|
8240
|
-
modelAccountRules: z.array(z.object({
|
|
8241
|
-
models: z.array(z.string()),
|
|
8242
|
-
account: z.string()
|
|
8243
|
-
})),
|
|
8244
|
-
commandGuard: z.boolean().default(false),
|
|
8245
|
-
commandGuardThreshold: z.number().min(COMMAND_GUARD_MIN_THRESHOLD).max(1),
|
|
8246
|
-
commandGuardTimeoutMs: z.number().min(200).max(COMMAND_GUARD_MAX_TIMEOUT_MS),
|
|
8247
|
-
zdr: z.boolean().default(false),
|
|
8248
|
-
lang: z.string().pattern(/^(zh|en)$/).default("zh")
|
|
8249
|
-
};
|
|
8250
|
-
}
|
|
8251
|
-
/**
|
|
8252
|
-
* The 0.1.7-generation schema: every field volatile except the
|
|
8253
|
-
* composition-only `apiKey` secret.
|
|
8129
|
+
* The Config schema: every field volatile except the composition-only `apiKey`
|
|
8130
|
+
* secret.
|
|
8254
8131
|
*
|
|
8255
8132
|
* dsh 0.1.7's settings forms are projected from the schema's `meta.volatile`
|
|
8256
8133
|
* nodes, so an unmarked field would be invisible to AND unwritable from the
|
|
8257
|
-
* settings page and refused by form-edit path validation — and
|
|
8258
|
-
*
|
|
8259
|
-
*
|
|
8260
|
-
*
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
*
|
|
8275
|
-
*
|
|
8276
|
-
*
|
|
8277
|
-
*
|
|
8278
|
-
|
|
8279
|
-
|
|
8134
|
+
* settings page and refused by form-edit path validation — and the loader
|
|
8135
|
+
* hands `apply()` a live reference per marked field, committing later writes
|
|
8136
|
+
* without remounting this fiber (the `loader/volatile-update` listener at the
|
|
8137
|
+
* bottom of `apply` covers the facts that are not re-derived per read).
|
|
8138
|
+
*/
|
|
8139
|
+
const Config = z.object(markVolatileFields({
|
|
8140
|
+
apiKeyEnv: z.string().role("credential-ref").default(DEFAULT_API_KEY_ENV),
|
|
8141
|
+
apiKey: z.string().role("secret"),
|
|
8142
|
+
apiBase: z.string(),
|
|
8143
|
+
workingDir: z.string(),
|
|
8144
|
+
modelsCachePath: z.string(),
|
|
8145
|
+
requestTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS),
|
|
8146
|
+
streamIdleTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS),
|
|
8147
|
+
transportMaxRetries: z.number().min(0).max(50),
|
|
8148
|
+
filterModelsByPlan: z.boolean(),
|
|
8149
|
+
visibleModels: z.array(z.string()),
|
|
8150
|
+
/**
|
|
8151
|
+
* Per-model visibility overrides for the terminal settings page's checkbox
|
|
8152
|
+
* list, keyed by catalog id. dsh-TUI addresses a staged edit by its field
|
|
8153
|
+
* PATH, so two checkboxes sharing one path would overwrite each other's
|
|
8154
|
+
* draft and the section's last model would decide every write; a map gives
|
|
8155
|
+
* each checkbox a path of its own. An id listed here wins over
|
|
8156
|
+
* {@link Config.visibleModels}; ids absent here keep following it.
|
|
8157
|
+
*/
|
|
8158
|
+
modelVisibility: z.dict(z.boolean()),
|
|
8159
|
+
webSearch: z.boolean().default(true),
|
|
8160
|
+
showSidebarQuota: z.boolean().default(false),
|
|
8161
|
+
accounts: z.array(z.object({
|
|
8162
|
+
label: z.string(),
|
|
8163
|
+
apiKeyEnv: z.string().role("credential-ref"),
|
|
8164
|
+
/** Literal key for one extra slot; see the top-level `apiKey` secret note. */
|
|
8165
|
+
apiKey: z.string().role("secret")
|
|
8166
|
+
})),
|
|
8167
|
+
activeAccount: z.string(),
|
|
8168
|
+
modelAccountRules: z.array(z.object({
|
|
8169
|
+
models: z.array(z.string()),
|
|
8170
|
+
account: z.string()
|
|
8171
|
+
})),
|
|
8172
|
+
commandGuard: z.boolean().default(false),
|
|
8173
|
+
commandGuardThreshold: z.number().min(COMMAND_GUARD_MIN_THRESHOLD).max(1),
|
|
8174
|
+
commandGuardTimeoutMs: z.number().min(200).max(COMMAND_GUARD_MAX_TIMEOUT_MS),
|
|
8175
|
+
zdr: z.boolean().default(false),
|
|
8176
|
+
lang: z.string().pattern(/^(zh|en)$/).default("zh")
|
|
8177
|
+
}, ["apiKey"]));
|
|
8280
8178
|
/**
|
|
8281
8179
|
* The one explicit resolve step from raw config to validated connection
|
|
8282
8180
|
* facts. Programmatic construction may bypass Schemastery normalization, so
|
|
@@ -8311,19 +8209,8 @@ function readModelVisibility(raw) {
|
|
|
8311
8209
|
}
|
|
8312
8210
|
function apply(ctx, config) {
|
|
8313
8211
|
installCostProjection(ctx);
|
|
8314
|
-
|
|
8315
|
-
const
|
|
8316
|
-
let lastRaw;
|
|
8317
|
-
let lastGood;
|
|
8318
|
-
const options = () => {
|
|
8319
|
-
const raw = current();
|
|
8320
|
-
if (raw === lastRaw && lastGood !== void 0) return lastGood;
|
|
8321
|
-
const next = resolveAdapterOptions(raw);
|
|
8322
|
-
lastRaw = raw;
|
|
8323
|
-
lastGood = next;
|
|
8324
|
-
return next;
|
|
8325
|
-
};
|
|
8326
|
-
options();
|
|
8212
|
+
const current = () => unwrapVolatileConfig(config);
|
|
8213
|
+
const options = () => resolveAdapterOptions(current());
|
|
8327
8214
|
const slots = () => {
|
|
8328
8215
|
const raw = current();
|
|
8329
8216
|
const list = [{
|
|
@@ -8548,23 +8435,10 @@ function apply(ctx, config) {
|
|
|
8548
8435
|
}, "dsh-commandcode-provider: tui settings handle");
|
|
8549
8436
|
});
|
|
8550
8437
|
ctx.inject(["settings"], (settingsCtx) => {
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
service.installSection(ctx, NS, LegacySettingsSchema, unwrapVolatileConfig(config), {
|
|
8554
|
-
setSource: (next) => {
|
|
8555
|
-
source = next;
|
|
8556
|
-
},
|
|
8557
|
-
onChange: () => {
|
|
8558
|
-
applySearchSelection(current().webSearch ?? true);
|
|
8559
|
-
refreshTuiSettings?.();
|
|
8560
|
-
}
|
|
8561
|
-
});
|
|
8562
|
-
return;
|
|
8563
|
-
}
|
|
8564
|
-
if (typeof service.configure === "function") settingsCtx.effect(() => {
|
|
8565
|
-
const dispose = service.configure?.({ auto: false }, ctx.fiber);
|
|
8438
|
+
settingsCtx.effect(() => {
|
|
8439
|
+
const dispose = settingsCtx.settings.configure({ auto: false }, ctx.fiber);
|
|
8566
8440
|
return () => {
|
|
8567
|
-
dispose
|
|
8441
|
+
dispose();
|
|
8568
8442
|
};
|
|
8569
8443
|
}, "dsh-commandcode-provider: settings auto-form policy");
|
|
8570
8444
|
});
|
|
@@ -8580,6 +8454,6 @@ function apply(ctx, config) {
|
|
|
8580
8454
|
}, "dsh-commandcode-provider: volatile config updates");
|
|
8581
8455
|
}
|
|
8582
8456
|
//#endregion
|
|
8583
|
-
export { ACTIVE_ACCOUNT_AUTO, BILLING_ACCESS_TTL_MS, COMMANDCODE_SEARCH_PROVIDER_ID, COMMAND_CODE_CLI_VERSION, CommandCodeAccountPool, CommandCodeAdapter, CommandCodeLoginFlow, CommandCodeSearchProvider, 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,
|
|
8457
|
+
export { ACTIVE_ACCOUNT_AUTO, BILLING_ACCESS_TTL_MS, COMMANDCODE_SEARCH_PROVIDER_ID, COMMAND_CODE_CLI_VERSION, CommandCodeAccountPool, CommandCodeAdapter, CommandCodeLoginFlow, CommandCodeSearchProvider, 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, PLAN_LABELS, PLAN_ORDER, PROVIDER, 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, studioBaseForApiBase, subscriptionPlanInfo, supportsZeroDataRetention, usageReportSchema, validateCommandApiKey };
|
|
8584
8458
|
|
|
8585
8459
|
//# sourceMappingURL=index.js.map
|