@eddyskywalker/dsh-chatgpt-subscription 0.66.2 → 0.67.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/CHANGELOG.md +33 -0
- package/lib/client.js +57 -0
- package/lib/client.js.map +1 -1
- package/lib/codemode.js +28 -7
- package/lib/{entry-plan-mode-CLRKkgYG.js → entry-plan-mode-gqE4UeU5.js} +5 -2
- package/lib/{entry-progress-updates-DZ0ZRus4.js → entry-progress-updates-DpzbX1GP.js} +5 -1
- package/lib/index.js +263 -194
- package/lib/plan-mode-pipeline.js +1 -1
- package/lib/plan-mode.js +1 -1
- package/lib/progress-updates.js +1 -1
- package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
- package/lib/types/client/progress-updates/locales.d.ts +8 -2
- package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts +3 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/entry-codemode.d.ts.map +1 -1
- package/lib/types/entry-plan-mode-pipeline.d.ts.map +1 -1
- package/lib/types/entry-plan-mode.d.ts.map +1 -1
- package/lib/types/host/agent-preset.d.ts.map +1 -1
- package/lib/types/host/codemode/rules.d.ts +13 -5
- package/lib/types/host/codemode/rules.d.ts.map +1 -1
- package/lib/types/host/command-code/adapter.d.ts.map +1 -1
- package/lib/types/host/dispatch-execution-guard.d.ts.map +1 -1
- package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
- package/lib/types/host/kimi-code/tool-argument-guard.d.ts +7 -0
- package/lib/types/host/kimi-code/tool-argument-guard.d.ts.map +1 -1
- package/lib/types/host/kimi-code/tool-argument-recovery.d.ts.map +1 -1
- package/lib/types/host/progress-updates/prompt.d.ts.map +1 -1
- package/lib/types/host/progress-updates/tool.d.ts.map +1 -1
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/presets/dispatch/README.md +9 -9
- package/presets/dispatch/agent.cordis.yml +26 -18
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as resolveProgressUpdatesSettings, n as attachProgressSettings } from "./entry-progress-updates-
|
|
1
|
+
import { a as resolveProgressUpdatesSettings, n as attachProgressSettings } from "./entry-progress-updates-DpzbX1GP.js";
|
|
2
2
|
import { attachPlanModePipelineSettings, resolvePlanModePipelineEnabled } from "./plan-mode-pipeline.js";
|
|
3
3
|
import { n as PLUGIN_MESSAGE_SOURCE_KIND, r as normalizeGenerateOptions, t as LlmError$1 } from "./llm-compat-u9mor0uu.js";
|
|
4
4
|
import { DEFAULT_SKIP_PROVIDERS, PRUNER_SERVICE_NAME, resolveSkipProviders, shouldSkipPruningForSession } from "./tool-result-pruner.js";
|
|
5
|
-
import { b as installDispatchExecutionGuard, h as installPlanModeExitReminder, l as PLAN_PROJECTION_KEY, p as createPlanNotice, v as registeredPlanControllerActive, x as resolveDispatchExecutionGuardEnabled } from "./entry-plan-mode-
|
|
5
|
+
import { b as installDispatchExecutionGuard, h as installPlanModeExitReminder, l as PLAN_PROJECTION_KEY, p as createPlanNotice, v as registeredPlanControllerActive, x as resolveDispatchExecutionGuardEnabled } from "./entry-plan-mode-gqE4UeU5.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import * as LlmModule from "@deepseek-ai/dsh-llm";
|
|
8
8
|
import { EMPTY_RESPONSE_CODE, HarnessError, LlmAdapter, LlmError, ProviderRequestId, ReasoningEffortId, ToolCallId, attributionHeaders, createUserMessage, errorChain, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
@@ -809,7 +809,7 @@ const ROUTE_PREFIX$5 = "/api/dsh-chatgpt-subscription";
|
|
|
809
809
|
* `test/responses-client.test.ts` asserts the two agree, so a release that
|
|
810
810
|
* forgets this constant fails the suite instead of shipping quietly.
|
|
811
811
|
*/
|
|
812
|
-
const PLUGIN_VERSION = "0.
|
|
812
|
+
const PLUGIN_VERSION = "0.67.0";
|
|
813
813
|
const CODEX_CHATGPT_PROVIDER_ID = "codex-chatgpt";
|
|
814
814
|
const CODEX_API_BASE = "https://chatgpt.com/backend-api/codex";
|
|
815
815
|
const CODEX_RESPONSES_URL = `${CODEX_API_BASE}/responses`;
|
|
@@ -4488,7 +4488,7 @@ var OAuthService = class {
|
|
|
4488
4488
|
throw new OAuthServiceError("oauth-token-exchange-failed", `The ChatGPT device code could not be issued (${response.status}${detail === null ? "" : `, ${detail}`}).`, response.status);
|
|
4489
4489
|
}
|
|
4490
4490
|
const payload = await response.json().catch(() => null);
|
|
4491
|
-
const record = isRecord$
|
|
4491
|
+
const record = isRecord$71(payload) ? payload : {};
|
|
4492
4492
|
const authId = nonEmptyString$11(record.device_auth_id);
|
|
4493
4493
|
const userCode = nonEmptyString$11(record.user_code) ?? nonEmptyString$11(record.usercode);
|
|
4494
4494
|
if (authId === void 0 || userCode === void 0) throw new OAuthServiceError("oauth-token-exchange-failed", "ChatGPT returned no device code.");
|
|
@@ -4555,7 +4555,7 @@ var OAuthService = class {
|
|
|
4555
4555
|
const detail = deviceErrorIdentifier(payload);
|
|
4556
4556
|
throw new OAuthServiceError("oauth-token-exchange-failed", `The ChatGPT device confirmation was refused (${response.status}${detail === void 0 ? "" : `, ${detail}`}).`, response.status);
|
|
4557
4557
|
}
|
|
4558
|
-
const record = isRecord$
|
|
4558
|
+
const record = isRecord$71(payload) ? payload : {};
|
|
4559
4559
|
const authorizationCode = nonEmptyString$11(record.authorization_code);
|
|
4560
4560
|
const codeVerifier = nonEmptyString$11(record.code_verifier);
|
|
4561
4561
|
if (authorizationCode === void 0 || codeVerifier === void 0) throw new OAuthServiceError("oauth-token-exchange-failed", "ChatGPT confirmed the device code but returned no authorization code.");
|
|
@@ -4888,11 +4888,11 @@ const DEVICE_PENDING_STATUSES = /* @__PURE__ */ new Set([
|
|
|
4888
4888
|
function isPendingDeviceAnswer(response, payload) {
|
|
4889
4889
|
if (response.status === 403 || response.status === 404) return true;
|
|
4890
4890
|
if (!response.ok && response.status !== 400) return false;
|
|
4891
|
-
if (!isRecord$
|
|
4891
|
+
if (!isRecord$71(payload)) return false;
|
|
4892
4892
|
const status = payload.status;
|
|
4893
4893
|
if (typeof status === "string" && DEVICE_PENDING_STATUSES.has(status.toLowerCase())) return true;
|
|
4894
4894
|
const error = payload.error;
|
|
4895
|
-
if (isRecord$
|
|
4895
|
+
if (isRecord$71(error)) {
|
|
4896
4896
|
const code = error.code;
|
|
4897
4897
|
if (typeof code === "string" && DEVICE_PENDING_STATUSES.has(code.toLowerCase())) return true;
|
|
4898
4898
|
}
|
|
@@ -4906,18 +4906,18 @@ function isPendingDeviceAnswer(response, payload) {
|
|
|
4906
4906
|
* wrong.
|
|
4907
4907
|
*/
|
|
4908
4908
|
function deviceErrorIdentifier(payload) {
|
|
4909
|
-
if (!isRecord$
|
|
4909
|
+
if (!isRecord$71(payload)) return void 0;
|
|
4910
4910
|
const candidates = [payload.code];
|
|
4911
4911
|
const error = payload.error;
|
|
4912
4912
|
if (typeof error === "string") candidates.push(error);
|
|
4913
|
-
else if (isRecord$
|
|
4913
|
+
else if (isRecord$71(error)) candidates.push(error.code, error.type);
|
|
4914
4914
|
candidates.push(payload.status);
|
|
4915
4915
|
for (const candidate of candidates) if (typeof candidate === "string" && /^[a-z0-9_.-]{1,64}$/i.test(candidate)) return candidate;
|
|
4916
4916
|
}
|
|
4917
4917
|
function nonEmptyString$11(value) {
|
|
4918
4918
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
4919
4919
|
}
|
|
4920
|
-
function isRecord$
|
|
4920
|
+
function isRecord$71(value) {
|
|
4921
4921
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4922
4922
|
}
|
|
4923
4923
|
async function oauthErrorIdentifier(response) {
|
|
@@ -5098,7 +5098,7 @@ const CODEX_CLI_CREDENTIAL_SOURCE = "codex";
|
|
|
5098
5098
|
* here, and the import has to be repeated afterwards.
|
|
5099
5099
|
*/
|
|
5100
5100
|
const ADOPTED_CODEX_CREDENTIAL_EXPIRED_HINT = "The sign-in imported from the Codex CLI has expired. Sign in again in the Codex CLI, then import it again from this settings card.";
|
|
5101
|
-
function isRecord$
|
|
5101
|
+
function isRecord$70(value) {
|
|
5102
5102
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5103
5103
|
}
|
|
5104
5104
|
/** A trimmed, non-empty string, or nothing. */
|
|
@@ -5200,7 +5200,7 @@ function decodeJwtClaims$1(token) {
|
|
|
5200
5200
|
if (parts.length !== 3) return void 0;
|
|
5201
5201
|
try {
|
|
5202
5202
|
const value = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
5203
|
-
return isRecord$
|
|
5203
|
+
return isRecord$70(value) ? value : void 0;
|
|
5204
5204
|
} catch {
|
|
5205
5205
|
return;
|
|
5206
5206
|
}
|
|
@@ -5245,10 +5245,10 @@ function expiryFromAccessToken(accessToken) {
|
|
|
5245
5245
|
* the file carries cannot reach the result.
|
|
5246
5246
|
*/
|
|
5247
5247
|
function parseAdoptedCodexCredential(value, sourcePath) {
|
|
5248
|
-
if (!isRecord$
|
|
5248
|
+
if (!isRecord$70(value)) return void 0;
|
|
5249
5249
|
if (value.auth_mode !== "chatgpt") return void 0;
|
|
5250
5250
|
const tokens = value[CODEX_CLI_TOKENS_KEY];
|
|
5251
|
-
if (!isRecord$
|
|
5251
|
+
if (!isRecord$70(tokens)) return void 0;
|
|
5252
5252
|
const accessToken = nonEmptyString$10(tokens.access_token);
|
|
5253
5253
|
if (accessToken === void 0) return void 0;
|
|
5254
5254
|
const refreshToken = nonEmptyString$10(tokens.refresh_token);
|
|
@@ -5267,7 +5267,7 @@ function parseAdoptedCodexCredential(value, sourcePath) {
|
|
|
5267
5267
|
const email = claims === void 0 ? void 0 : nonEmptyString$10(claims.email);
|
|
5268
5268
|
if (email !== void 0) credentials.email = email;
|
|
5269
5269
|
const authClaims = claims === void 0 ? void 0 : claims[CODEX_AUTH_CLAIMS_KEY];
|
|
5270
|
-
const planType = isRecord$
|
|
5270
|
+
const planType = isRecord$70(authClaims) ? nonEmptyString$10(authClaims.chatgpt_plan_type) : void 0;
|
|
5271
5271
|
if (planType !== void 0) credentials.planType = planType;
|
|
5272
5272
|
}
|
|
5273
5273
|
const accountId = nonEmptyString$10(tokens.account_id);
|
|
@@ -8160,7 +8160,7 @@ const schemaFields = /* @__PURE__ */ new Set([
|
|
|
8160
8160
|
"required",
|
|
8161
8161
|
"propertyOrdering"
|
|
8162
8162
|
]);
|
|
8163
|
-
function isRecord$
|
|
8163
|
+
function isRecord$69(value) {
|
|
8164
8164
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8165
8165
|
}
|
|
8166
8166
|
function mergeSchemas(left, right) {
|
|
@@ -8168,7 +8168,7 @@ function mergeSchemas(left, right) {
|
|
|
8168
8168
|
...left,
|
|
8169
8169
|
...right
|
|
8170
8170
|
};
|
|
8171
|
-
if (isRecord$
|
|
8171
|
+
if (isRecord$69(left.properties) && isRecord$69(right.properties)) merged.properties = {
|
|
8172
8172
|
...left.properties,
|
|
8173
8173
|
...right.properties
|
|
8174
8174
|
};
|
|
@@ -8204,9 +8204,9 @@ const mergedTypeKeys = /* @__PURE__ */ new Set([
|
|
|
8204
8204
|
* model with strictly less than the schema it started from.
|
|
8205
8205
|
*/
|
|
8206
8206
|
function describeBranch(branch) {
|
|
8207
|
-
const type = typeof branch.type === "string" ? branch.type : isRecord$
|
|
8207
|
+
const type = typeof branch.type === "string" ? branch.type : isRecord$69(branch.properties) ? "object" : isRecord$69(branch.items) ? "array" : "value";
|
|
8208
8208
|
const details = [];
|
|
8209
|
-
if (isRecord$
|
|
8209
|
+
if (isRecord$69(branch.properties)) {
|
|
8210
8210
|
const names = Object.keys(branch.properties);
|
|
8211
8211
|
if (names.length > 0) details.push(`{${names.join(",")}}`);
|
|
8212
8212
|
}
|
|
@@ -8220,7 +8220,7 @@ function describeBranch(branch) {
|
|
|
8220
8220
|
}
|
|
8221
8221
|
/** How well one branch can stand in for a whole union; a named object shape wins. */
|
|
8222
8222
|
function branchRank(branch) {
|
|
8223
|
-
if (isRecord$
|
|
8223
|
+
if (isRecord$69(branch.properties)) return 3;
|
|
8224
8224
|
if (branch.type === "object") return 2;
|
|
8225
8225
|
if (branch.type === "array") return 1;
|
|
8226
8226
|
return 0;
|
|
@@ -8249,7 +8249,7 @@ function unionShape(branches) {
|
|
|
8249
8249
|
shape: branches[0],
|
|
8250
8250
|
folded: false
|
|
8251
8251
|
};
|
|
8252
|
-
if (new Set(branches.map((branch) => branch.type)).size === 1 && branches.every((branch) => !isRecord$
|
|
8252
|
+
if (new Set(branches.map((branch) => branch.type)).size === 1 && branches.every((branch) => !isRecord$69(branch.properties) && !isRecord$69(branch.items))) {
|
|
8253
8253
|
const shape = { type: branches[0].type };
|
|
8254
8254
|
if (branches.every((branch) => Array.isArray(branch.enum))) {
|
|
8255
8255
|
const values = [...new Set(branches.flatMap((branch) => branch.enum))];
|
|
@@ -8286,7 +8286,7 @@ function foldOwnFields(node) {
|
|
|
8286
8286
|
const out = {};
|
|
8287
8287
|
for (const [key, value] of Object.entries(node)) {
|
|
8288
8288
|
if (key === "anyOf" || key === "oneOf" || key === "allOf") continue;
|
|
8289
|
-
if (key === "properties" && isRecord$
|
|
8289
|
+
if (key === "properties" && isRecord$69(value)) {
|
|
8290
8290
|
out.properties = Object.fromEntries(Object.entries(value).map(([name, child]) => [name, foldSchemaUnions(child)]));
|
|
8291
8291
|
continue;
|
|
8292
8292
|
}
|
|
@@ -8315,15 +8315,15 @@ function foldOwnFields(node) {
|
|
|
8315
8315
|
* argument the model sends anyway fails there, naming the actual problem.
|
|
8316
8316
|
*/
|
|
8317
8317
|
function foldSchemaUnions(node) {
|
|
8318
|
-
if (!isRecord$
|
|
8318
|
+
if (!isRecord$69(node)) return node;
|
|
8319
8319
|
let own = foldOwnFields(node);
|
|
8320
8320
|
if (Array.isArray(node.allOf)) for (const branch of node.allOf) {
|
|
8321
8321
|
const folded = foldSchemaUnions(branch);
|
|
8322
|
-
if (isRecord$
|
|
8322
|
+
if (isRecord$69(folded)) own = mergeSchemas(own, folded);
|
|
8323
8323
|
}
|
|
8324
8324
|
const alternatives = Array.isArray(node.anyOf) ? node.anyOf : Array.isArray(node.oneOf) ? node.oneOf : [];
|
|
8325
8325
|
if (alternatives.length === 0) return own;
|
|
8326
|
-
const branches = alternatives.map((branch) => foldSchemaUnions(branch)).filter(isRecord$
|
|
8326
|
+
const branches = alternatives.map((branch) => foldSchemaUnions(branch)).filter(isRecord$69);
|
|
8327
8327
|
if (branches.length === 0) return own;
|
|
8328
8328
|
const shapes = branches.filter((branch) => branch.type !== "null");
|
|
8329
8329
|
const acceptsNull = branches.some((branch) => branch.type === "null");
|
|
@@ -8339,7 +8339,7 @@ function foldSchemaUnions(node) {
|
|
|
8339
8339
|
return merged;
|
|
8340
8340
|
}
|
|
8341
8341
|
function toAntigravityToolSchema(schema, options = {}) {
|
|
8342
|
-
if (!isRecord$
|
|
8342
|
+
if (!isRecord$69(schema)) return schema;
|
|
8343
8343
|
const root = schema;
|
|
8344
8344
|
function resolveReference(reference) {
|
|
8345
8345
|
let target = root;
|
|
@@ -8347,13 +8347,13 @@ function toAntigravityToolSchema(schema, options = {}) {
|
|
|
8347
8347
|
const path = reference === "#" ? [] : reference.slice(2).split("/");
|
|
8348
8348
|
for (const segment of path) {
|
|
8349
8349
|
const key = segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
8350
|
-
target = isRecord$
|
|
8350
|
+
target = isRecord$69(target) && Object.hasOwn(target, key) ? target[key] : void 0;
|
|
8351
8351
|
}
|
|
8352
|
-
if (!isRecord$
|
|
8352
|
+
if (!isRecord$69(target)) throw new LlmError(`Antigravity tool schema reference was not found: ${reference}`, "PROVIDER_ERROR");
|
|
8353
8353
|
return target;
|
|
8354
8354
|
}
|
|
8355
8355
|
function convert(node, references) {
|
|
8356
|
-
if (!isRecord$
|
|
8356
|
+
if (!isRecord$69(node)) return {};
|
|
8357
8357
|
let inherited = {};
|
|
8358
8358
|
if (typeof node.$ref === "string") {
|
|
8359
8359
|
if (references.has(node.$ref)) throw new LlmError(`Antigravity tool schema contains a recursive reference: ${node.$ref}`, "PROVIDER_ERROR");
|
|
@@ -8362,8 +8362,8 @@ function toAntigravityToolSchema(schema, options = {}) {
|
|
|
8362
8362
|
if (Array.isArray(node.allOf)) for (const branch of node.allOf) inherited = mergeSchemas(inherited, convert(branch, references));
|
|
8363
8363
|
const out = {};
|
|
8364
8364
|
for (const [key, value] of Object.entries(node)) if (schemaFields.has(key)) out[key] = value;
|
|
8365
|
-
if (isRecord$
|
|
8366
|
-
if (isRecord$
|
|
8365
|
+
if (isRecord$69(node.properties)) out.properties = Object.fromEntries(Object.entries(node.properties).map(([name, child]) => [name, convert(child, references)]));
|
|
8366
|
+
if (isRecord$69(node.items)) out.items = convert(node.items, references);
|
|
8367
8367
|
const alternatives = Array.isArray(node.anyOf) ? node.anyOf : node.oneOf;
|
|
8368
8368
|
if (Array.isArray(alternatives)) out.anyOf = alternatives.map((child) => convert(child, references));
|
|
8369
8369
|
if (Array.isArray(node.type)) {
|
|
@@ -8399,7 +8399,7 @@ let toolCallCounter = 0;
|
|
|
8399
8399
|
function sanitizeText$9(text) {
|
|
8400
8400
|
return text.replace(/\0/g, "");
|
|
8401
8401
|
}
|
|
8402
|
-
function isRecord$
|
|
8402
|
+
function isRecord$68(value) {
|
|
8403
8403
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8404
8404
|
}
|
|
8405
8405
|
function asString$30(value) {
|
|
@@ -8419,25 +8419,25 @@ function toolCallIdNeeded(modelId, runtimeModel) {
|
|
|
8419
8419
|
return modelId.startsWith("claude-") || modelId.startsWith("gpt-oss-") || runtimeModel.startsWith("claude-") || runtimeModel.startsWith("gpt-oss-");
|
|
8420
8420
|
}
|
|
8421
8421
|
function parseArguments$1(raw) {
|
|
8422
|
-
if (isRecord$
|
|
8422
|
+
if (isRecord$68(raw)) return raw;
|
|
8423
8423
|
if (raw === void 0 || raw === null || raw === "") return {};
|
|
8424
8424
|
const parsed = typeof raw === "string" ? safeJsonParse$9(raw) : raw;
|
|
8425
|
-
return isRecord$
|
|
8425
|
+
return isRecord$68(parsed) ? parsed : {};
|
|
8426
8426
|
}
|
|
8427
8427
|
const NO_RESOLVED_IMAGES$5 = /* @__PURE__ */ new Map();
|
|
8428
8428
|
function attachmentOf$5(block) {
|
|
8429
8429
|
const attachment = block.attachment;
|
|
8430
|
-
if (!isRecord$
|
|
8430
|
+
if (!isRecord$68(attachment)) return void 0;
|
|
8431
8431
|
return typeof attachment.attachmentId === "string" ? attachment : void 0;
|
|
8432
8432
|
}
|
|
8433
8433
|
function attachmentLabel$6(block) {
|
|
8434
|
-
const attachment = isRecord$
|
|
8434
|
+
const attachment = isRecord$68(block.attachment) ? block.attachment : void 0;
|
|
8435
8435
|
return asString$30(attachment?.name) || asString$30(attachment?.attachmentId);
|
|
8436
8436
|
}
|
|
8437
8437
|
function collectImageRefs$3(content, refs) {
|
|
8438
8438
|
if (!Array.isArray(content)) return;
|
|
8439
8439
|
for (const block of content) {
|
|
8440
|
-
if (!isRecord$
|
|
8440
|
+
if (!isRecord$68(block)) continue;
|
|
8441
8441
|
if (block.type === "image") {
|
|
8442
8442
|
const attachment = attachmentOf$5(block);
|
|
8443
8443
|
if (attachment) refs.set(attachment.attachmentId, attachment);
|
|
@@ -8570,7 +8570,7 @@ function unavailableImageText$6(block) {
|
|
|
8570
8570
|
}
|
|
8571
8571
|
function imageBlockToPart(block, images) {
|
|
8572
8572
|
let data = asString$30(block.data) || asString$30(block.base64);
|
|
8573
|
-
const source = isRecord$
|
|
8573
|
+
const source = isRecord$68(block.source) ? block.source : void 0;
|
|
8574
8574
|
if (!data && source) data = asString$30(source.data) || asString$30(source.base64);
|
|
8575
8575
|
let mimeType = asString$30(block.mimeType) || asString$30(block.mediaType) || (source ? asString$30(source.mimeType) || asString$30(source.mediaType) : void 0) || "image/png";
|
|
8576
8576
|
if (data?.startsWith("data:")) {
|
|
@@ -8595,8 +8595,8 @@ function contentToUserParts(content, images) {
|
|
|
8595
8595
|
if (typeof content === "string") return [{ text: sanitizeText$9(content) }];
|
|
8596
8596
|
if (!Array.isArray(content)) return [];
|
|
8597
8597
|
const parts = [];
|
|
8598
|
-
for (const block of content) if (isRecord$
|
|
8599
|
-
else if (isRecord$
|
|
8598
|
+
for (const block of content) if (isRecord$68(block) && block.type === "text" && typeof block.text === "string") parts.push({ text: sanitizeText$9(block.text) });
|
|
8599
|
+
else if (isRecord$68(block) && block.type === "image") {
|
|
8600
8600
|
const img = imageBlockToPart(block, images);
|
|
8601
8601
|
parts.push(img ?? { text: unavailableImageText$6(block) });
|
|
8602
8602
|
}
|
|
@@ -8611,7 +8611,7 @@ function toolResultImageParts(blocks, images) {
|
|
|
8611
8611
|
if (!Array.isArray(blocks)) return [];
|
|
8612
8612
|
const parts = [];
|
|
8613
8613
|
for (const block of blocks) {
|
|
8614
|
-
if (!isRecord$
|
|
8614
|
+
if (!isRecord$68(block)) continue;
|
|
8615
8615
|
if (block.type === "image") {
|
|
8616
8616
|
parts.push(imageBlockToPart(block, images) ?? { text: unavailableImageText$6(block) });
|
|
8617
8617
|
continue;
|
|
@@ -8623,7 +8623,7 @@ function toolResultImageParts(blocks, images) {
|
|
|
8623
8623
|
function toolResultText$9(blocks) {
|
|
8624
8624
|
if (!Array.isArray(blocks)) return "";
|
|
8625
8625
|
return blocks.map((block) => {
|
|
8626
|
-
if (!isRecord$
|
|
8626
|
+
if (!isRecord$68(block)) return "";
|
|
8627
8627
|
if (block.type === "text" && typeof block.text === "string") return sanitizeText$9(block.text);
|
|
8628
8628
|
if (block.type === "tool-result") return toolResultText$9(block.content);
|
|
8629
8629
|
if (block.type === "image") {
|
|
@@ -8637,9 +8637,9 @@ function replayBlockFor$1(message, index) {
|
|
|
8637
8637
|
const source = message.source;
|
|
8638
8638
|
if (!source || source.kind !== "model" || source.provider !== "antigravity") return void 0;
|
|
8639
8639
|
const state = source.replayState;
|
|
8640
|
-
if (!isRecord$
|
|
8640
|
+
if (!isRecord$68(state)) return void 0;
|
|
8641
8641
|
if (Array.isArray(state.blocks)) return state.blocks[index];
|
|
8642
|
-
const resp = isRecord$
|
|
8642
|
+
const resp = isRecord$68(state.response) ? state.response : void 0;
|
|
8643
8643
|
if (resp) {
|
|
8644
8644
|
if (Array.isArray(resp.outputItems)) return resp.outputItems[index];
|
|
8645
8645
|
if (Array.isArray(resp.blocks)) return resp.blocks[index];
|
|
@@ -8741,10 +8741,10 @@ function assistantParts(message, model, runtimeModel, toolCalls) {
|
|
|
8741
8741
|
if (!Array.isArray(message.content)) return parts;
|
|
8742
8742
|
for (let index = 0; index < message.content.length; index++) {
|
|
8743
8743
|
const block = message.content[index];
|
|
8744
|
-
if (!isRecord$
|
|
8744
|
+
if (!isRecord$68(block)) continue;
|
|
8745
8745
|
if (block.type === "reasoning" && runtimeModel.startsWith("claude-") && (message.source?.kind !== "model" || message.source.provider !== "antigravity" || !("model" in message.source) || message.source.model !== model.id)) continue;
|
|
8746
8746
|
const replay = replayBlockFor$1(message, index);
|
|
8747
|
-
const originalParts = Array.isArray(replay?.parts) ? replay.parts.filter(isRecord$
|
|
8747
|
+
const originalParts = Array.isArray(replay?.parts) ? replay.parts.filter(isRecord$68) : [];
|
|
8748
8748
|
if ((block.type === "text" || block.type === "reasoning") && originalParts.length > 0 && originalParts.every((part) => !part.functionCall) && originalParts.map((part) => asString$30(part.text) || "").join("") === sanitizeText$9(String(block.text || ""))) {
|
|
8749
8749
|
parts.push(...originalParts.map(replayPart));
|
|
8750
8750
|
continue;
|
|
@@ -8765,8 +8765,8 @@ function assistantParts(message, model, runtimeModel, toolCalls) {
|
|
|
8765
8765
|
} else if (block.type === "tool-call") {
|
|
8766
8766
|
const toolId = String(block.id || "");
|
|
8767
8767
|
const toolName = String(block.name || "");
|
|
8768
|
-
const originalCall = originalParts.find((part) => isRecord$
|
|
8769
|
-
const wireId = asString$30((isRecord$
|
|
8768
|
+
const originalCall = originalParts.find((part) => isRecord$68(part.functionCall));
|
|
8769
|
+
const wireId = asString$30((isRecord$68(originalCall?.functionCall) ? originalCall.functionCall : void 0)?.id) || (toolCallIdNeeded(model.id, runtimeModel) ? sanitizeToolCallId(toolId, toolName) : originalCall ? void 0 : toolId || void 0);
|
|
8770
8770
|
toolCalls.set(toolId, {
|
|
8771
8771
|
name: toolName,
|
|
8772
8772
|
id: wireId
|
|
@@ -8818,7 +8818,7 @@ function convertMessages(options, model, runtimeModel, images = NO_RESOLVED_IMAG
|
|
|
8818
8818
|
continue;
|
|
8819
8819
|
}
|
|
8820
8820
|
const content = Array.isArray(message.content) ? message.content : [];
|
|
8821
|
-
const userParts = contentToUserParts(content.filter((b) => !isRecord$
|
|
8821
|
+
const userParts = contentToUserParts(content.filter((b) => !isRecord$68(b) || b.type !== "tool-result"), images);
|
|
8822
8822
|
if (role === "system") {
|
|
8823
8823
|
if (userParts.length) contents.push({
|
|
8824
8824
|
role: GEMINI_ROLE.user,
|
|
@@ -8830,7 +8830,7 @@ function convertMessages(options, model, runtimeModel, images = NO_RESOLVED_IMAG
|
|
|
8830
8830
|
role: GEMINI_ROLE.user,
|
|
8831
8831
|
parts: userParts
|
|
8832
8832
|
});
|
|
8833
|
-
for (const b of content) if (isRecord$
|
|
8833
|
+
for (const b of content) if (isRecord$68(b) && b.type === "tool-result") pushToolResult(contents, b, toolCalls, model, runtimeModel, images);
|
|
8834
8834
|
}
|
|
8835
8835
|
return contents;
|
|
8836
8836
|
}
|
|
@@ -8973,7 +8973,7 @@ const USAGE_FIELDS = [
|
|
|
8973
8973
|
"totalTokenCount"
|
|
8974
8974
|
];
|
|
8975
8975
|
function collectUsage(value, state) {
|
|
8976
|
-
if (!isRecord$
|
|
8976
|
+
if (!isRecord$68(value)) return;
|
|
8977
8977
|
for (const key of USAGE_FIELDS) {
|
|
8978
8978
|
const count = value[key];
|
|
8979
8979
|
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) continue;
|
|
@@ -9003,17 +9003,17 @@ function processStreamLine$4(line, state) {
|
|
|
9003
9003
|
}
|
|
9004
9004
|
if (!json) return [];
|
|
9005
9005
|
const chunk = safeJsonParse$9(json);
|
|
9006
|
-
if (!isRecord$
|
|
9007
|
-
const responseData = isRecord$
|
|
9008
|
-
const error = isRecord$
|
|
9006
|
+
if (!isRecord$68(chunk)) return [];
|
|
9007
|
+
const responseData = isRecord$68(chunk.response) ? chunk.response : chunk;
|
|
9008
|
+
const error = isRecord$68(chunk.error) ? chunk.error : isRecord$68(responseData.error) ? responseData.error : void 0;
|
|
9009
9009
|
if (error !== void 0) throw new LlmError$1(`Antigravity stream error: ${asString$30(error.message) ?? "unknown error"}`, isContextOverflow(error) ? CONTEXT_OVERFLOW_CODE : "PROVIDER_ERROR");
|
|
9010
9010
|
const candidates = Array.isArray(responseData.candidates) ? responseData.candidates : [];
|
|
9011
|
-
const candidate = isRecord$
|
|
9012
|
-
const content = isRecord$
|
|
9011
|
+
const candidate = isRecord$68(candidates[0]) ? candidates[0] : void 0;
|
|
9012
|
+
const content = isRecord$68(candidate?.content) ? candidate.content : void 0;
|
|
9013
9013
|
const parts = Array.isArray(content?.parts) ? content.parts : [];
|
|
9014
9014
|
const out = [];
|
|
9015
9015
|
for (const part of parts) {
|
|
9016
|
-
if (!isRecord$
|
|
9016
|
+
if (!isRecord$68(part)) continue;
|
|
9017
9017
|
if (typeof part.text === "string" && part.text !== "") {
|
|
9018
9018
|
const isThinking = Boolean(part.thought);
|
|
9019
9019
|
const blockType = isThinking ? "reasoning" : "text";
|
|
@@ -9045,7 +9045,7 @@ function processStreamLine$4(line, state) {
|
|
|
9045
9045
|
index: state.currentBlock.index,
|
|
9046
9046
|
text: delta
|
|
9047
9047
|
});
|
|
9048
|
-
} else if (!isRecord$
|
|
9048
|
+
} else if (!isRecord$68(part.functionCall) && thoughtSignature(part)) {
|
|
9049
9049
|
if (state.replayBlocks.length === 0) {
|
|
9050
9050
|
const type = part.thought ? "reasoning" : "text";
|
|
9051
9051
|
state.blocks.push({
|
|
@@ -9069,12 +9069,12 @@ function processStreamLine$4(line, state) {
|
|
|
9069
9069
|
}
|
|
9070
9070
|
state.replayBlocks[state.replayBlocks.length - 1].parts.push(replayPart(part));
|
|
9071
9071
|
}
|
|
9072
|
-
if (isRecord$
|
|
9072
|
+
if (isRecord$68(part.functionCall)) {
|
|
9073
9073
|
out.push(...closeCurrentBlock(state));
|
|
9074
9074
|
const fc = part.functionCall;
|
|
9075
9075
|
const toolName = asString$30(fc.name) || "";
|
|
9076
9076
|
const toolId = asString$30(fc.id) || sanitizeToolCallId("", toolName);
|
|
9077
|
-
const argsText = JSON.stringify(isRecord$
|
|
9077
|
+
const argsText = JSON.stringify(isRecord$68(fc.args) ? fc.args : {});
|
|
9078
9078
|
const index = state.blocks.length;
|
|
9079
9079
|
const block = {
|
|
9080
9080
|
type: "tool-call",
|
|
@@ -9113,7 +9113,7 @@ function processStreamLine$4(line, state) {
|
|
|
9113
9113
|
if (responseData !== chunk) collectUsage(responseData.usageMetadata, state);
|
|
9114
9114
|
const finishMessage = asString$30(candidate?.finishMessage);
|
|
9115
9115
|
if (finishMessage) state.finishMessage = finishMessage;
|
|
9116
|
-
const blockReason = asString$30((isRecord$
|
|
9116
|
+
const blockReason = asString$30((isRecord$68(responseData.promptFeedback) ? responseData.promptFeedback : void 0)?.blockReason);
|
|
9117
9117
|
const finishReason = asString$30(candidate?.finishReason) || asString$30(responseData.finishReason) || (blockReason ? `PROMPT_BLOCKED:${blockReason}` : void 0);
|
|
9118
9118
|
if (finishReason) {
|
|
9119
9119
|
state.finishReason = finishReason;
|
|
@@ -9186,7 +9186,7 @@ function closeStream$7(state) {
|
|
|
9186
9186
|
*
|
|
9187
9187
|
* @module dsh-chatgpt-subscription/request-images
|
|
9188
9188
|
*/
|
|
9189
|
-
function isRecord$
|
|
9189
|
+
function isRecord$67(value) {
|
|
9190
9190
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9191
9191
|
}
|
|
9192
9192
|
function asString$29(value) {
|
|
@@ -9245,17 +9245,17 @@ const SUPPORTED_IMAGE_MEDIA_TYPES$4 = /* @__PURE__ */ new Set([
|
|
|
9245
9245
|
]);
|
|
9246
9246
|
function attachmentOf$4(block) {
|
|
9247
9247
|
const attachment = block.attachment;
|
|
9248
|
-
if (!isRecord$
|
|
9248
|
+
if (!isRecord$67(attachment)) return void 0;
|
|
9249
9249
|
return typeof attachment.attachmentId === "string" ? attachment : void 0;
|
|
9250
9250
|
}
|
|
9251
9251
|
function attachmentLabel$5(block) {
|
|
9252
|
-
const attachment = isRecord$
|
|
9252
|
+
const attachment = isRecord$67(block.attachment) ? block.attachment : void 0;
|
|
9253
9253
|
return asString$29(attachment?.name) || asString$29(attachment?.attachmentId);
|
|
9254
9254
|
}
|
|
9255
9255
|
function collectImageRefs$2(content, refs) {
|
|
9256
9256
|
if (!Array.isArray(content)) return;
|
|
9257
9257
|
for (const block of content) {
|
|
9258
|
-
if (!isRecord$
|
|
9258
|
+
if (!isRecord$67(block)) continue;
|
|
9259
9259
|
if (block.type === "image") {
|
|
9260
9260
|
const attachment = attachmentOf$4(block);
|
|
9261
9261
|
if (attachment) refs.set(attachment.attachmentId, attachment);
|
|
@@ -9285,7 +9285,7 @@ function base64Length$2(bytes) {
|
|
|
9285
9285
|
*/
|
|
9286
9286
|
function inlinePayloadOf$1(block) {
|
|
9287
9287
|
let data = asString$29(block.data) || asString$29(block.base64);
|
|
9288
|
-
const source = isRecord$
|
|
9288
|
+
const source = isRecord$67(block.source) ? block.source : void 0;
|
|
9289
9289
|
if (!data && source) data = asString$29(source.data) || asString$29(source.base64);
|
|
9290
9290
|
if (data?.startsWith("data:")) {
|
|
9291
9291
|
const matched = data.match(/^data:([^;,]+);base64,(.*)$/s);
|
|
@@ -9315,7 +9315,7 @@ function requestImagePayloadLength(block, images) {
|
|
|
9315
9315
|
function collectRequestImagePayloads(content, images, lengths) {
|
|
9316
9316
|
if (!Array.isArray(content)) return;
|
|
9317
9317
|
for (const block of content) {
|
|
9318
|
-
if (!isRecord$
|
|
9318
|
+
if (!isRecord$67(block)) continue;
|
|
9319
9319
|
if (block.type === "image") {
|
|
9320
9320
|
const bytes = requestImagePayloadLength(block, images);
|
|
9321
9321
|
if (bytes !== void 0) lengths.push(bytes);
|
|
@@ -9369,7 +9369,7 @@ function replaceOldestRequestImages(options, count, images) {
|
|
|
9369
9369
|
let replaced = false;
|
|
9370
9370
|
return {
|
|
9371
9371
|
content: content.map((block) => {
|
|
9372
|
-
if (remaining.count === 0 || !isRecord$
|
|
9372
|
+
if (remaining.count === 0 || !isRecord$67(block)) return block;
|
|
9373
9373
|
if (block.type === "image") {
|
|
9374
9374
|
if (requestImagePayloadLength(block, images) === void 0) return block;
|
|
9375
9375
|
remaining.count -= 1;
|
|
@@ -9511,7 +9511,7 @@ function collectImageOccurrences(options, images) {
|
|
|
9511
9511
|
const walk = (content) => {
|
|
9512
9512
|
if (!Array.isArray(content)) return;
|
|
9513
9513
|
for (const block of content) {
|
|
9514
|
-
if (!isRecord$
|
|
9514
|
+
if (!isRecord$67(block)) continue;
|
|
9515
9515
|
if (block.type === "image") {
|
|
9516
9516
|
const bytes = requestImagePayloadLength(block, images);
|
|
9517
9517
|
const key = requestImageKey(block, images);
|
|
@@ -9581,7 +9581,7 @@ function replaceDroppedRequestImages(options, droppedKeys, images) {
|
|
|
9581
9581
|
let replaced = false;
|
|
9582
9582
|
return {
|
|
9583
9583
|
content: content.map((block) => {
|
|
9584
|
-
if (!isRecord$
|
|
9584
|
+
if (!isRecord$67(block)) return block;
|
|
9585
9585
|
if (block.type === "image") {
|
|
9586
9586
|
const key = requestImageKey(block, images);
|
|
9587
9587
|
if (key === void 0 || !droppedKeys.has(key)) return block;
|
|
@@ -9770,7 +9770,7 @@ function unavailableImageText$5(block) {
|
|
|
9770
9770
|
}
|
|
9771
9771
|
function imageBlockToInline$3(block, images) {
|
|
9772
9772
|
let data = asString$29(block.data) || asString$29(block.base64);
|
|
9773
|
-
const source = isRecord$
|
|
9773
|
+
const source = isRecord$67(block.source) ? block.source : void 0;
|
|
9774
9774
|
if (!data && source) data = asString$29(source.data) || asString$29(source.base64);
|
|
9775
9775
|
let mediaType = asString$29(block.mimeType) || asString$29(block.mediaType) || (source ? asString$29(source.mimeType) || asString$29(source.mediaType) : void 0) || "image/png";
|
|
9776
9776
|
if (data?.startsWith("data:")) {
|
|
@@ -9916,12 +9916,12 @@ const BOOLEAN_KEYS = [
|
|
|
9916
9916
|
"waitWarmup",
|
|
9917
9917
|
"hint"
|
|
9918
9918
|
];
|
|
9919
|
-
function isRecord$
|
|
9919
|
+
function isRecord$66(value) {
|
|
9920
9920
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9921
9921
|
}
|
|
9922
9922
|
/** Validate one provider override without silently dropping unknown keys. */
|
|
9923
9923
|
function parsePromptCacheOverride(provider, value) {
|
|
9924
|
-
if (!isRecord$
|
|
9924
|
+
if (!isRecord$66(value)) throw new Error(`prompt cache policy for "${provider}" must be an object`);
|
|
9925
9925
|
const out = {};
|
|
9926
9926
|
for (const [key, entry] of Object.entries(value)) {
|
|
9927
9927
|
if (!OVERRIDE_KEYS.has(key)) throw new Error(`prompt cache policy for "${provider}" has unknown field "${key}"`);
|
|
@@ -9942,7 +9942,7 @@ function parsePromptCacheOverride(provider, value) {
|
|
|
9942
9942
|
/** Validate a whole config-owned map. Undefined means no overrides. */
|
|
9943
9943
|
function parsePromptCacheOverrides(value) {
|
|
9944
9944
|
if (value === void 0) return {};
|
|
9945
|
-
if (!isRecord$
|
|
9945
|
+
if (!isRecord$66(value)) throw new Error("promptCacheOverrides must be an object keyed by provider id");
|
|
9946
9946
|
const out = {};
|
|
9947
9947
|
for (const [provider, override] of Object.entries(value)) {
|
|
9948
9948
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(provider)) throw new Error(`invalid prompt cache provider id "${provider}"`);
|
|
@@ -10124,14 +10124,14 @@ async function fetchWithPrefixCoordination(fetchFn, coordinator, groupKey, warmT
|
|
|
10124
10124
|
}
|
|
10125
10125
|
//#endregion
|
|
10126
10126
|
//#region src/host/common/prefix-stability.ts
|
|
10127
|
-
function isRecord$
|
|
10127
|
+
function isRecord$65(value) {
|
|
10128
10128
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10129
10129
|
}
|
|
10130
10130
|
function firstTextOf$1(content) {
|
|
10131
10131
|
if (typeof content === "string") return content.trim() === "" ? void 0 : content;
|
|
10132
10132
|
if (!Array.isArray(content)) return void 0;
|
|
10133
10133
|
for (const block of content) {
|
|
10134
|
-
if (!isRecord$
|
|
10134
|
+
if (!isRecord$65(block)) continue;
|
|
10135
10135
|
if (block.type === "text" && typeof block.text === "string" && block.text !== "") return block.text;
|
|
10136
10136
|
if (block.type === "tool-result") {
|
|
10137
10137
|
const nested = firstTextOf$1(block.content);
|
|
@@ -10145,7 +10145,7 @@ function isToolResultMessage$9(message) {
|
|
|
10145
10145
|
/** Stability tier for an initial bootstrap reminder; null means dynamic/history-bound. */
|
|
10146
10146
|
function classifyBootstrapUserMessage$1(message) {
|
|
10147
10147
|
if (message.role !== "user" || isToolResultMessage$9(message)) return null;
|
|
10148
|
-
const source = isRecord$
|
|
10148
|
+
const source = isRecord$65(message.source) ? message.source : void 0;
|
|
10149
10149
|
const kind = source !== void 0 && typeof source.kind === "string" ? source.kind : void 0;
|
|
10150
10150
|
const text = firstTextOf$1(message.content)?.trimStart() ?? "";
|
|
10151
10151
|
if (kind === "progress-updates-language" || text.startsWith("Progress update output language override:")) return 1;
|
|
@@ -10156,7 +10156,7 @@ function classifyBootstrapUserMessage$1(message) {
|
|
|
10156
10156
|
}
|
|
10157
10157
|
function isCompactCheckpointMessage(message) {
|
|
10158
10158
|
if (message === void 0 || message.role !== "user" || isToolResultMessage$9(message)) return false;
|
|
10159
|
-
const source = isRecord$
|
|
10159
|
+
const source = isRecord$65(message.source) ? message.source : void 0;
|
|
10160
10160
|
if (source !== void 0 && source.kind === "compact-checkpoint") return true;
|
|
10161
10161
|
return firstTextOf$1(message.content)?.trimStart().startsWith("This is an automatically generated checkpoint condensing") === true;
|
|
10162
10162
|
}
|
|
@@ -10164,7 +10164,7 @@ function isCompactCheckpointMessage(message) {
|
|
|
10164
10164
|
function normalizeAgentInstructionsMessage(message) {
|
|
10165
10165
|
if (!Array.isArray(message.content) || message.content.length !== 1) return message;
|
|
10166
10166
|
const first = message.content[0];
|
|
10167
|
-
if (!isRecord$
|
|
10167
|
+
if (!isRecord$65(first) || first.type !== "text" || typeof first.text !== "string") return message;
|
|
10168
10168
|
const raw = first.text;
|
|
10169
10169
|
const firstIdx = raw.indexOf("\n\nInstructions from: ");
|
|
10170
10170
|
if (firstIdx < 0) return message;
|
|
@@ -10277,7 +10277,7 @@ function allTextOf(content) {
|
|
|
10277
10277
|
if (typeof content === "string") return content;
|
|
10278
10278
|
if (!Array.isArray(content)) return "";
|
|
10279
10279
|
return content.map((block) => {
|
|
10280
|
-
if (!isRecord$
|
|
10280
|
+
if (!isRecord$65(block)) return "";
|
|
10281
10281
|
if (block.type === "text" && typeof block.text === "string") return block.text;
|
|
10282
10282
|
if (block.type === "tool-result") return allTextOf(block.content);
|
|
10283
10283
|
return "";
|
|
@@ -11060,7 +11060,7 @@ function withoutValidatedToolConfig(body) {
|
|
|
11060
11060
|
* a tool call only runs after its stream finishes, so retrying can neither
|
|
11061
11061
|
* repeat committed output nor re-run a tool.
|
|
11062
11062
|
*/
|
|
11063
|
-
function streamFailure$
|
|
11063
|
+
function streamFailure$3(error, signal) {
|
|
11064
11064
|
if (error instanceof LlmError) return error;
|
|
11065
11065
|
if (signal.aborted) return new LlmError("Antigravity stream aborted", "ABORTED", { cause: error });
|
|
11066
11066
|
const chain = errorChain(error).trim();
|
|
@@ -11340,7 +11340,7 @@ var AntigravityAdapter = class extends LlmAdapter {
|
|
|
11340
11340
|
try {
|
|
11341
11341
|
while (true) {
|
|
11342
11342
|
const { done, value } = await reader.read().catch((error) => {
|
|
11343
|
-
throw streamFailure$
|
|
11343
|
+
throw streamFailure$3(error, signal);
|
|
11344
11344
|
});
|
|
11345
11345
|
if (done) break;
|
|
11346
11346
|
if (value !== void 0 && value.byteLength > 0) activity?.pulse();
|
|
@@ -12758,11 +12758,11 @@ function createControlledModelFetch(baseFetch, options) {
|
|
|
12758
12758
|
* text and may opt into a hard handoff threshold; coordination tools are exempt
|
|
12759
12759
|
* because they are expected to recur while real work continues.
|
|
12760
12760
|
*/
|
|
12761
|
-
function isRecord$
|
|
12761
|
+
function isRecord$64(value) {
|
|
12762
12762
|
return typeof value === "object" && value !== null;
|
|
12763
12763
|
}
|
|
12764
12764
|
function isPlainRecord$2(value) {
|
|
12765
|
-
if (!isRecord$
|
|
12765
|
+
if (!isRecord$64(value) || Array.isArray(value)) return false;
|
|
12766
12766
|
const prototype = Object.getPrototypeOf(value);
|
|
12767
12767
|
return prototype === Object.prototype || prototype === null;
|
|
12768
12768
|
}
|
|
@@ -14852,7 +14852,7 @@ var ResponsesClient = class {
|
|
|
14852
14852
|
try {
|
|
14853
14853
|
yield* wrapStreamWithWatchdog((watchdogSignal, activity) => parseResponsesStream(response, watchdogSignal, void 0, activity), options.signal, this.codexStreamIdleTimeoutMs, "LLM_STREAM_IDLE_TIMEOUT", "Codex");
|
|
14854
14854
|
} catch (error) {
|
|
14855
|
-
throw streamFailure$
|
|
14855
|
+
throw streamFailure$2(error, options.signal);
|
|
14856
14856
|
} finally {
|
|
14857
14857
|
this.turnStates.delete(turnKey);
|
|
14858
14858
|
release?.();
|
|
@@ -15061,7 +15061,7 @@ function isPreConnectionFailure$2(error) {
|
|
|
15061
15061
|
* attempt on retry, and a tool call is only executed after its stream finishes,
|
|
15062
15062
|
* so retrying can neither repeat committed output nor re-run a tool.
|
|
15063
15063
|
*/
|
|
15064
|
-
function streamFailure$
|
|
15064
|
+
function streamFailure$2(error, signal) {
|
|
15065
15065
|
if (error instanceof LlmError) return error;
|
|
15066
15066
|
if (signal?.aborted) return new LlmError("Codex request aborted", "ABORTED", { cause: error });
|
|
15067
15067
|
const chain = errorChain(error).trim();
|
|
@@ -17150,7 +17150,7 @@ async function compactionCandidates(ctx) {
|
|
|
17150
17150
|
};
|
|
17151
17151
|
}))).filter((provider) => provider.models.length > 0) };
|
|
17152
17152
|
}
|
|
17153
|
-
function isRecord$
|
|
17153
|
+
function isRecord$63(value) {
|
|
17154
17154
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17155
17155
|
}
|
|
17156
17156
|
function readPreferencesUpdate(value, current) {
|
|
@@ -17208,7 +17208,7 @@ function readPreferencesUpdate(value, current) {
|
|
|
17208
17208
|
patch.subagentAllowParentForkByMainModel = value.subagentAllowParentForkByMainModel;
|
|
17209
17209
|
}
|
|
17210
17210
|
if ("contextWindowOverrides" in value) {
|
|
17211
|
-
if (!isRecord$
|
|
17211
|
+
if (!isRecord$63(value.contextWindowOverrides)) throw new PreferenceError("contextWindowOverrides must be an object.");
|
|
17212
17212
|
const overrides = {};
|
|
17213
17213
|
for (const [model, contextWindow] of Object.entries(value.contextWindowOverrides)) {
|
|
17214
17214
|
if (!isCodexModelId(model)) throw new PreferenceError("Unknown Codex model for a context window override.");
|
|
@@ -22106,11 +22106,11 @@ function commandCodeHeaders(apiKey, extra = {}) {
|
|
|
22106
22106
|
function timeoutSignal$5(signal, ms) {
|
|
22107
22107
|
return signal ? AbortSignal.any([signal, AbortSignal.timeout(ms)]) : AbortSignal.timeout(ms);
|
|
22108
22108
|
}
|
|
22109
|
-
function isRecord$
|
|
22109
|
+
function isRecord$62(value) {
|
|
22110
22110
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22111
22111
|
}
|
|
22112
22112
|
function asRecord$16(value) {
|
|
22113
|
-
return isRecord$
|
|
22113
|
+
return isRecord$62(value) ? value : void 0;
|
|
22114
22114
|
}
|
|
22115
22115
|
function asString$28(value) {
|
|
22116
22116
|
if (typeof value === "string" && value.trim() !== "") return value;
|
|
@@ -22154,7 +22154,7 @@ function deepValue(value, keys, depth = 0) {
|
|
|
22154
22154
|
}
|
|
22155
22155
|
return;
|
|
22156
22156
|
}
|
|
22157
|
-
if (!isRecord$
|
|
22157
|
+
if (!isRecord$62(value)) return void 0;
|
|
22158
22158
|
for (const key of keys) if (value[key] !== void 0 && value[key] !== null) return value[key];
|
|
22159
22159
|
for (const nested of Object.values(value)) {
|
|
22160
22160
|
const hit = deepValue(nested, keys, depth + 1);
|
|
@@ -22168,7 +22168,7 @@ function collectRecords(value, keys, depth = 0, out = []) {
|
|
|
22168
22168
|
for (const entry of value) collectRecords(entry, keys, depth + 1, out);
|
|
22169
22169
|
return out;
|
|
22170
22170
|
}
|
|
22171
|
-
if (!isRecord$
|
|
22171
|
+
if (!isRecord$62(value)) return out;
|
|
22172
22172
|
if (keys.some((key) => value[key] !== void 0)) out.push(value);
|
|
22173
22173
|
for (const nested of Object.values(value)) collectRecords(nested, keys, depth + 1, out);
|
|
22174
22174
|
return out;
|
|
@@ -23064,7 +23064,7 @@ function cleanOrphanedToolCalls(messages, refold) {
|
|
|
23064
23064
|
*
|
|
23065
23065
|
* https://commandcode.ai/blog/command-code-provider-api
|
|
23066
23066
|
*/
|
|
23067
|
-
function isRecord$
|
|
23067
|
+
function isRecord$61(value) {
|
|
23068
23068
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23069
23069
|
}
|
|
23070
23070
|
function asString$26(value) {
|
|
@@ -23104,17 +23104,17 @@ const SUPPORTED_IMAGE_MEDIA_TYPES$3 = /* @__PURE__ */ new Set([
|
|
|
23104
23104
|
]);
|
|
23105
23105
|
function attachmentOf$3(block) {
|
|
23106
23106
|
const attachment = block.attachment;
|
|
23107
|
-
if (!isRecord$
|
|
23107
|
+
if (!isRecord$61(attachment)) return void 0;
|
|
23108
23108
|
return typeof attachment.attachmentId === "string" ? attachment : void 0;
|
|
23109
23109
|
}
|
|
23110
23110
|
function attachmentLabel$4(block) {
|
|
23111
|
-
const attachment = isRecord$
|
|
23111
|
+
const attachment = isRecord$61(block.attachment) ? block.attachment : void 0;
|
|
23112
23112
|
return asString$26(attachment?.name) || asString$26(attachment?.attachmentId);
|
|
23113
23113
|
}
|
|
23114
23114
|
function collectImageRefs$1(content, refs) {
|
|
23115
23115
|
if (!Array.isArray(content)) return;
|
|
23116
23116
|
for (const block of content) {
|
|
23117
|
-
if (!isRecord$
|
|
23117
|
+
if (!isRecord$61(block)) continue;
|
|
23118
23118
|
if (block.type === "image") {
|
|
23119
23119
|
const attachment = attachmentOf$3(block);
|
|
23120
23120
|
if (attachment) refs.set(attachment.attachmentId, attachment);
|
|
@@ -23135,7 +23135,7 @@ function requestImageBytes$1(block) {
|
|
|
23135
23135
|
function collectRequestImageBytes$1(content, lengths) {
|
|
23136
23136
|
if (!Array.isArray(content)) return;
|
|
23137
23137
|
for (const block of content) {
|
|
23138
|
-
if (!isRecord$
|
|
23138
|
+
if (!isRecord$61(block)) continue;
|
|
23139
23139
|
if (block.type === "tool-result") {
|
|
23140
23140
|
collectRequestImageBytes$1(block.content, lengths);
|
|
23141
23141
|
continue;
|
|
@@ -23171,7 +23171,7 @@ function offloadOldestRequestImages$1(options) {
|
|
|
23171
23171
|
let replaced = false;
|
|
23172
23172
|
return {
|
|
23173
23173
|
content: content.map((block) => {
|
|
23174
|
-
if (remaining.count === 0 || !isRecord$
|
|
23174
|
+
if (remaining.count === 0 || !isRecord$61(block)) return block;
|
|
23175
23175
|
if (block.type === "image") {
|
|
23176
23176
|
if (requestImageBytes$1(block) === void 0) return block;
|
|
23177
23177
|
remaining.count -= 1;
|
|
@@ -23243,7 +23243,7 @@ function unavailableImageText$4(block) {
|
|
|
23243
23243
|
}
|
|
23244
23244
|
function imageBlockToInline$2(block, images) {
|
|
23245
23245
|
let data = asString$26(block.data) || asString$26(block.base64);
|
|
23246
|
-
const source = isRecord$
|
|
23246
|
+
const source = isRecord$61(block.source) ? block.source : void 0;
|
|
23247
23247
|
if (!data && source) data = asString$26(source.data) || asString$26(source.base64);
|
|
23248
23248
|
let mediaType = asString$26(block.mimeType) || asString$26(block.mediaType) || (source ? asString$26(source.mimeType) || asString$26(source.mediaType) : void 0) || "image/png";
|
|
23249
23249
|
if (data?.startsWith("data:")) {
|
|
@@ -23269,7 +23269,7 @@ function textOf$9(content) {
|
|
|
23269
23269
|
if (!Array.isArray(content)) return "";
|
|
23270
23270
|
const parts = [];
|
|
23271
23271
|
for (const block of content) {
|
|
23272
|
-
if (!isRecord$
|
|
23272
|
+
if (!isRecord$61(block)) continue;
|
|
23273
23273
|
if (block.type === "text" && typeof block.text === "string") parts.push(sanitizeText$8(block.text));
|
|
23274
23274
|
else if (block.type === "tool-result") parts.push(textOf$9(block.content));
|
|
23275
23275
|
}
|
|
@@ -23278,7 +23278,7 @@ function textOf$9(content) {
|
|
|
23278
23278
|
function toolResultText$8(blocks) {
|
|
23279
23279
|
if (!Array.isArray(blocks)) return "";
|
|
23280
23280
|
return blocks.map((block) => {
|
|
23281
|
-
if (!isRecord$
|
|
23281
|
+
if (!isRecord$61(block)) return "";
|
|
23282
23282
|
if (block.type === "text" && typeof block.text === "string") return sanitizeText$8(block.text);
|
|
23283
23283
|
if (block.type === "tool-result") return toolResultText$8(block.content);
|
|
23284
23284
|
if (block.type === "image") return `[image: ${attachmentLabel$4(block) ?? "attached image"}]`;
|
|
@@ -23296,7 +23296,7 @@ function toolResultBlocks$2(blocks, images) {
|
|
|
23296
23296
|
const out = [];
|
|
23297
23297
|
let hasImage = false;
|
|
23298
23298
|
for (const block of blocks) {
|
|
23299
|
-
if (!isRecord$
|
|
23299
|
+
if (!isRecord$61(block)) continue;
|
|
23300
23300
|
if (block.type === "text" && typeof block.text === "string") {
|
|
23301
23301
|
out.push({
|
|
23302
23302
|
type: "text",
|
|
@@ -23345,7 +23345,7 @@ function toolResultImageBlocks$5(blocks, images) {
|
|
|
23345
23345
|
if (!Array.isArray(blocks)) return [];
|
|
23346
23346
|
const out = [];
|
|
23347
23347
|
for (const block of blocks) {
|
|
23348
|
-
if (!isRecord$
|
|
23348
|
+
if (!isRecord$61(block)) continue;
|
|
23349
23349
|
if (block.type === "image") {
|
|
23350
23350
|
const inline = imageBlockToInline$2(block, images);
|
|
23351
23351
|
if (inline && SUPPORTED_IMAGE_MEDIA_TYPES$3.has(inline.mediaType)) out.push({
|
|
@@ -23389,7 +23389,7 @@ function nonSystemMessages$7(options) {
|
|
|
23389
23389
|
}
|
|
23390
23390
|
/** Drop the JSON-Schema keywords provider gateways reject or ignore. */
|
|
23391
23391
|
function stripMetaSchema$2(schema) {
|
|
23392
|
-
if (!isRecord$
|
|
23392
|
+
if (!isRecord$61(schema)) return {
|
|
23393
23393
|
type: "object",
|
|
23394
23394
|
properties: {}
|
|
23395
23395
|
};
|
|
@@ -23406,7 +23406,7 @@ function openAIUserContent$4(message, images) {
|
|
|
23406
23406
|
const parts = [];
|
|
23407
23407
|
let hasImage = false;
|
|
23408
23408
|
for (const block of message.content) {
|
|
23409
|
-
if (!isRecord$
|
|
23409
|
+
if (!isRecord$61(block)) continue;
|
|
23410
23410
|
if (block.type === "text" && typeof block.text === "string") {
|
|
23411
23411
|
const text = sanitizeText$8(block.text);
|
|
23412
23412
|
if (text !== "") parts.push({
|
|
@@ -23434,7 +23434,7 @@ function openAIAssistantContent$4(message) {
|
|
|
23434
23434
|
const textParts = [];
|
|
23435
23435
|
const toolCalls = [];
|
|
23436
23436
|
for (const block of message.content) {
|
|
23437
|
-
if (!isRecord$
|
|
23437
|
+
if (!isRecord$61(block)) continue;
|
|
23438
23438
|
if (block.type === "text" && typeof block.text === "string") textParts.push(sanitizeText$8(block.text));
|
|
23439
23439
|
else if (block.type === "tool-call" && typeof block.name === "string") toolCalls.push({
|
|
23440
23440
|
id: typeof block.id === "string" && block.id !== "" ? block.id : `call_${toolCalls.length}`,
|
|
@@ -23484,7 +23484,7 @@ function buildOpenAIRequest$1(options, images = NO_RESOLVED_IMAGES$3) {
|
|
|
23484
23484
|
while (index < conversation.length && isToolResultMessage$8(conversation[index])) {
|
|
23485
23485
|
const current = conversation[index];
|
|
23486
23486
|
const block = current.content[0];
|
|
23487
|
-
const callId = isRecord$
|
|
23487
|
+
const callId = isRecord$61(block) && typeof block.toolCallId === "string" ? block.toolCallId : "";
|
|
23488
23488
|
messages.push({
|
|
23489
23489
|
role: "tool",
|
|
23490
23490
|
tool_call_id: callId,
|
|
@@ -23545,7 +23545,7 @@ function anthropicUserContent$3(message, images) {
|
|
|
23545
23545
|
if (!Array.isArray(message.content)) return [];
|
|
23546
23546
|
const blocks = [];
|
|
23547
23547
|
for (const block of message.content) {
|
|
23548
|
-
if (!isRecord$
|
|
23548
|
+
if (!isRecord$61(block)) continue;
|
|
23549
23549
|
if (block.type === "text" && typeof block.text === "string") {
|
|
23550
23550
|
const text = sanitizeText$8(block.text);
|
|
23551
23551
|
if (text !== "") blocks.push({
|
|
@@ -23582,7 +23582,7 @@ function anthropicUserContent$3(message, images) {
|
|
|
23582
23582
|
function anthropicAssistantContent$3(message) {
|
|
23583
23583
|
const blocks = [];
|
|
23584
23584
|
for (const block of message.content) {
|
|
23585
|
-
if (!isRecord$
|
|
23585
|
+
if (!isRecord$61(block)) continue;
|
|
23586
23586
|
if (block.type === "text" && typeof block.text === "string") {
|
|
23587
23587
|
const text = sanitizeText$8(block.text);
|
|
23588
23588
|
if (text !== "") blocks.push({
|
|
@@ -23595,7 +23595,7 @@ function anthropicAssistantContent$3(message) {
|
|
|
23595
23595
|
type: "tool_use",
|
|
23596
23596
|
id: typeof block.id === "string" && block.id !== "" ? block.id : `toolu_${blocks.length}`,
|
|
23597
23597
|
name: block.name,
|
|
23598
|
-
input: isRecord$
|
|
23598
|
+
input: isRecord$61(parsed) ? parsed : {}
|
|
23599
23599
|
});
|
|
23600
23600
|
}
|
|
23601
23601
|
}
|
|
@@ -23734,7 +23734,7 @@ function responsesUserContent(message, images) {
|
|
|
23734
23734
|
if (!Array.isArray(message.content)) return [];
|
|
23735
23735
|
const parts = [];
|
|
23736
23736
|
for (const block of message.content) {
|
|
23737
|
-
if (!isRecord$
|
|
23737
|
+
if (!isRecord$61(block)) continue;
|
|
23738
23738
|
if (block.type === "text" && typeof block.text === "string") {
|
|
23739
23739
|
const text = sanitizeText$8(block.text);
|
|
23740
23740
|
if (text !== "") parts.push({
|
|
@@ -23759,7 +23759,7 @@ function responsesToolResultImageBlocks(blocks, images) {
|
|
|
23759
23759
|
if (!Array.isArray(blocks)) return [];
|
|
23760
23760
|
const out = [];
|
|
23761
23761
|
for (const block of blocks) {
|
|
23762
|
-
if (!isRecord$
|
|
23762
|
+
if (!isRecord$61(block)) continue;
|
|
23763
23763
|
if (block.type === "image") {
|
|
23764
23764
|
const inline = imageBlockToInline$2(block, images);
|
|
23765
23765
|
if (inline && SUPPORTED_IMAGE_MEDIA_TYPES$3.has(inline.mediaType)) out.push({
|
|
@@ -23786,8 +23786,8 @@ function buildResponsesRequest(options, images = NO_RESOLVED_IMAGES$3) {
|
|
|
23786
23786
|
const imageBlocks = [];
|
|
23787
23787
|
while (index < conversation.length && isToolResultMessage$8(conversation[index])) {
|
|
23788
23788
|
const current = conversation[index];
|
|
23789
|
-
const toolResult = Array.isArray(current.content) ? current.content.find((b) => isRecord$
|
|
23790
|
-
const callId = (isRecord$
|
|
23789
|
+
const toolResult = Array.isArray(current.content) ? current.content.find((b) => isRecord$61(b) && b.type === "tool-result") : void 0;
|
|
23790
|
+
const callId = (isRecord$61(toolResult) && typeof toolResult.toolCallId === "string" ? toolResult.toolCallId : "") || (typeof current.source?.callId === "string" ? current.source.callId : "");
|
|
23791
23791
|
input.push({
|
|
23792
23792
|
type: "function_call_output",
|
|
23793
23793
|
call_id: callId,
|
|
@@ -23810,7 +23810,7 @@ function buildResponsesRequest(options, images = NO_RESOLVED_IMAGES$3) {
|
|
|
23810
23810
|
content
|
|
23811
23811
|
});
|
|
23812
23812
|
for (const call of toolCalls) {
|
|
23813
|
-
const fn = isRecord$
|
|
23813
|
+
const fn = isRecord$61(call.function) ? call.function : void 0;
|
|
23814
23814
|
input.push({
|
|
23815
23815
|
type: "function_call",
|
|
23816
23816
|
call_id: call.id,
|
|
@@ -23933,9 +23933,9 @@ function processOpenAIStreamLine$1(line, state) {
|
|
|
23933
23933
|
}
|
|
23934
23934
|
if (payload === "") return [];
|
|
23935
23935
|
const chunk = safeJsonParse$8(payload);
|
|
23936
|
-
if (!isRecord$
|
|
23936
|
+
if (!isRecord$61(chunk)) return [];
|
|
23937
23937
|
const out = [];
|
|
23938
|
-
if (isRecord$
|
|
23938
|
+
if (isRecord$61(chunk.error)) {
|
|
23939
23939
|
const message = asString$26(chunk.error.message) ?? "unknown error";
|
|
23940
23940
|
state.streamError = {
|
|
23941
23941
|
vocabulary: "openai",
|
|
@@ -23944,20 +23944,20 @@ function processOpenAIStreamLine$1(line, state) {
|
|
|
23944
23944
|
};
|
|
23945
23945
|
throw new LlmError$1(`Command Code stream error: ${message}`, isContextOverflow(chunk.error) ? CONTEXT_OVERFLOW_CODE : "PROVIDER_ERROR");
|
|
23946
23946
|
}
|
|
23947
|
-
const usage = isRecord$
|
|
23947
|
+
const usage = isRecord$61(chunk.usage) ? chunk.usage : void 0;
|
|
23948
23948
|
if (usage) {
|
|
23949
23949
|
state.sawUsage = true;
|
|
23950
23950
|
const prompt = numberOr$9(usage.prompt_tokens, 0);
|
|
23951
|
-
const details = isRecord$
|
|
23951
|
+
const details = isRecord$61(usage.prompt_tokens_details) ? usage.prompt_tokens_details : void 0;
|
|
23952
23952
|
const cached = details ? numberOr$9(details.cached_tokens, 0) : 0;
|
|
23953
23953
|
state.inputTokens = Math.max(0, prompt - cached);
|
|
23954
23954
|
state.cacheReadTokens = cached;
|
|
23955
23955
|
state.outputTokens = numberOr$9(usage.completion_tokens, state.outputTokens);
|
|
23956
|
-
if (isRecord$
|
|
23956
|
+
if (isRecord$61(usage.completion_tokens_details)) state.reasoningTokens = numberOr$9(usage.completion_tokens_details.reasoning_tokens, state.reasoningTokens);
|
|
23957
23957
|
}
|
|
23958
23958
|
const choices = Array.isArray(chunk.choices) ? chunk.choices : [];
|
|
23959
|
-
const choice = isRecord$
|
|
23960
|
-
const delta = isRecord$
|
|
23959
|
+
const choice = isRecord$61(choices[0]) ? choices[0] : void 0;
|
|
23960
|
+
const delta = isRecord$61(choice?.delta) ? choice.delta : void 0;
|
|
23961
23961
|
if (delta) {
|
|
23962
23962
|
const reasoning = asString$26(delta.reasoning_content) ?? asString$26(delta.reasoning);
|
|
23963
23963
|
if (reasoning !== void 0 && reasoning !== "") {
|
|
@@ -23985,7 +23985,7 @@ function processOpenAIStreamLine$1(line, state) {
|
|
|
23985
23985
|
}
|
|
23986
23986
|
const toolDeltas = Array.isArray(delta.tool_calls) ? delta.tool_calls : [];
|
|
23987
23987
|
for (const entry of toolDeltas) {
|
|
23988
|
-
if (!isRecord$
|
|
23988
|
+
if (!isRecord$61(entry)) continue;
|
|
23989
23989
|
out.push(...applyOpenAIToolDelta$1(entry, state));
|
|
23990
23990
|
}
|
|
23991
23991
|
}
|
|
@@ -23999,7 +23999,7 @@ function processOpenAIStreamLine$1(line, state) {
|
|
|
23999
23999
|
}
|
|
24000
24000
|
function applyOpenAIToolDelta$1(entry, state) {
|
|
24001
24001
|
const wireIndex = typeof entry.index === "number" ? entry.index : 0;
|
|
24002
|
-
const fn = isRecord$
|
|
24002
|
+
const fn = isRecord$61(entry.function) ? entry.function : {};
|
|
24003
24003
|
const out = [];
|
|
24004
24004
|
let call = state.toolCalls.get(wireIndex);
|
|
24005
24005
|
const incomingId = asString$26(entry.id);
|
|
@@ -24074,12 +24074,12 @@ function processAnthropicStreamLine$1(line, state) {
|
|
|
24074
24074
|
const payload = trimmed.slice(5).trim();
|
|
24075
24075
|
if (payload === "" || payload === "[DONE]") return [];
|
|
24076
24076
|
const event = safeJsonParse$8(payload);
|
|
24077
|
-
if (!isRecord$
|
|
24077
|
+
if (!isRecord$61(event)) return [];
|
|
24078
24078
|
const type = asString$26(event.type);
|
|
24079
24079
|
const out = [];
|
|
24080
24080
|
if (type === "message_start") {
|
|
24081
|
-
const message = isRecord$
|
|
24082
|
-
const usage = message && isRecord$
|
|
24081
|
+
const message = isRecord$61(event.message) ? event.message : void 0;
|
|
24082
|
+
const usage = message && isRecord$61(message.usage) ? message.usage : void 0;
|
|
24083
24083
|
if (usage) {
|
|
24084
24084
|
state.sawUsage = true;
|
|
24085
24085
|
state.inputTokens = numberOr$9(usage.input_tokens, 0);
|
|
@@ -24093,7 +24093,7 @@ function processAnthropicStreamLine$1(line, state) {
|
|
|
24093
24093
|
}
|
|
24094
24094
|
if (type === "content_block_start") {
|
|
24095
24095
|
const contentIndex = numberOr$9(event.index, 0);
|
|
24096
|
-
const block = isRecord$
|
|
24096
|
+
const block = isRecord$61(event.content_block) ? event.content_block : {};
|
|
24097
24097
|
const blockType = asString$26(block.type);
|
|
24098
24098
|
out.push(...closeCurrent$6(state));
|
|
24099
24099
|
if (blockType === "tool_use") {
|
|
@@ -24143,7 +24143,7 @@ function processAnthropicStreamLine$1(line, state) {
|
|
|
24143
24143
|
}
|
|
24144
24144
|
if (type === "content_block_delta") {
|
|
24145
24145
|
const contentIndex = numberOr$9(event.index, 0);
|
|
24146
|
-
const delta = isRecord$
|
|
24146
|
+
const delta = isRecord$61(event.delta) ? event.delta : {};
|
|
24147
24147
|
const deltaType = asString$26(delta.type);
|
|
24148
24148
|
if (deltaType === "input_json_delta") {
|
|
24149
24149
|
const pending = state.toolCalls.get(contentIndex);
|
|
@@ -24216,10 +24216,10 @@ function processAnthropicStreamLine$1(line, state) {
|
|
|
24216
24216
|
return out;
|
|
24217
24217
|
}
|
|
24218
24218
|
if (type === "message_delta") {
|
|
24219
|
-
const delta = isRecord$
|
|
24219
|
+
const delta = isRecord$61(event.delta) ? event.delta : void 0;
|
|
24220
24220
|
const stop = delta ? asString$26(delta.stop_reason) : void 0;
|
|
24221
24221
|
if (stop !== void 0 && stop !== "") state.finishReason = stop;
|
|
24222
|
-
const usage = isRecord$
|
|
24222
|
+
const usage = isRecord$61(event.usage) ? event.usage : void 0;
|
|
24223
24223
|
if (usage) {
|
|
24224
24224
|
state.sawUsage = true;
|
|
24225
24225
|
state.outputTokens = numberOr$9(usage.output_tokens, state.outputTokens);
|
|
@@ -24231,7 +24231,7 @@ function processAnthropicStreamLine$1(line, state) {
|
|
|
24231
24231
|
return closeStream$6(state);
|
|
24232
24232
|
}
|
|
24233
24233
|
if (type === "error") {
|
|
24234
|
-
const error = isRecord$
|
|
24234
|
+
const error = isRecord$61(event.error) ? event.error : {};
|
|
24235
24235
|
const message = asString$26(error.message) ?? "unknown error";
|
|
24236
24236
|
state.streamError = {
|
|
24237
24237
|
vocabulary: "anthropic",
|
|
@@ -24277,7 +24277,7 @@ function processResponsesStreamLine(line, state) {
|
|
|
24277
24277
|
} catch {
|
|
24278
24278
|
return [];
|
|
24279
24279
|
}
|
|
24280
|
-
if (!isRecord$
|
|
24280
|
+
if (!isRecord$61(parsed)) return [];
|
|
24281
24281
|
const type = typeof parsed.type === "string" ? parsed.type : "";
|
|
24282
24282
|
if (type === "response.output_text.delta") {
|
|
24283
24283
|
const delta = typeof parsed.delta === "string" ? parsed.delta : "";
|
|
@@ -24304,7 +24304,7 @@ function processResponsesStreamLine(line, state) {
|
|
|
24304
24304
|
}];
|
|
24305
24305
|
}
|
|
24306
24306
|
if (type === "response.output_item.added") {
|
|
24307
|
-
const item = isRecord$
|
|
24307
|
+
const item = isRecord$61(parsed.item) ? parsed.item : null;
|
|
24308
24308
|
if (item === null || item.type !== "function_call") return [];
|
|
24309
24309
|
return startResponsesToolCall(state, parsed, item);
|
|
24310
24310
|
}
|
|
@@ -24328,11 +24328,11 @@ function processResponsesStreamLine(line, state) {
|
|
|
24328
24328
|
return [];
|
|
24329
24329
|
}
|
|
24330
24330
|
if (type === "response.completed" || type === "response.incomplete") {
|
|
24331
|
-
const response = isRecord$
|
|
24331
|
+
const response = isRecord$61(parsed.response) ? parsed.response : null;
|
|
24332
24332
|
if (response !== null) {
|
|
24333
24333
|
if (response.status === "failed") {
|
|
24334
24334
|
state.done = true;
|
|
24335
|
-
const errorObj = isRecord$
|
|
24335
|
+
const errorObj = isRecord$61(response.error) ? response.error : null;
|
|
24336
24336
|
const detail = errorObj && typeof errorObj.message === "string" ? errorObj.message : typeof response.error === "string" ? response.error : "";
|
|
24337
24337
|
state.streamError = {
|
|
24338
24338
|
vocabulary: "responses",
|
|
@@ -24345,7 +24345,7 @@ function processResponsesStreamLine(line, state) {
|
|
|
24345
24345
|
}
|
|
24346
24346
|
state.done = true;
|
|
24347
24347
|
if (type === "response.incomplete") {
|
|
24348
|
-
const details = response && isRecord$
|
|
24348
|
+
const details = response && isRecord$61(response.incomplete_details) ? response.incomplete_details : null;
|
|
24349
24349
|
const reason = details && typeof details.reason === "string" ? details.reason : "";
|
|
24350
24350
|
state.finishReason = reason === "max_output_tokens" || reason === "length" || reason === "max_tokens" ? "length" : reason || "length";
|
|
24351
24351
|
} else state.finishReason = "stop";
|
|
@@ -24353,8 +24353,8 @@ function processResponsesStreamLine(line, state) {
|
|
|
24353
24353
|
}
|
|
24354
24354
|
if (type === "response.failed" || type === "error") {
|
|
24355
24355
|
state.done = true;
|
|
24356
|
-
const errorObj = isRecord$
|
|
24357
|
-
const detail = (typeof parsed.message === "string" ? parsed.message : "") || (errorObj && typeof errorObj.message === "string" ? errorObj.message : "") || (isRecord$
|
|
24356
|
+
const errorObj = isRecord$61(parsed.error) ? parsed.error : isRecord$61(parsed.response) && isRecord$61(parsed.response.error) ? parsed.response.error : null;
|
|
24357
|
+
const detail = (typeof parsed.message === "string" ? parsed.message : "") || (errorObj && typeof errorObj.message === "string" ? errorObj.message : "") || (isRecord$61(parsed.response) && typeof parsed.response.error === "string" ? parsed.response.error : typeof parsed.error === "string" ? parsed.error : "");
|
|
24358
24358
|
state.streamError = {
|
|
24359
24359
|
vocabulary: "responses",
|
|
24360
24360
|
error: errorObj,
|
|
@@ -24442,15 +24442,15 @@ function responsesToolCall(state, key) {
|
|
|
24442
24442
|
for (const call of state.toolCalls.values()) if (call.id === toToolCallId(key)) return call;
|
|
24443
24443
|
}
|
|
24444
24444
|
function readResponsesUsage(response, state) {
|
|
24445
|
-
const usage = isRecord$
|
|
24445
|
+
const usage = isRecord$61(response.usage) ? response.usage : null;
|
|
24446
24446
|
if (usage === null) return;
|
|
24447
|
-
const cached = isRecord$
|
|
24448
|
-
const written = isRecord$
|
|
24447
|
+
const cached = isRecord$61(usage.input_tokens_details) ? numberOrZero(usage.input_tokens_details.cached_tokens) : 0;
|
|
24448
|
+
const written = isRecord$61(usage.input_tokens_details) ? numberOrZero(usage.input_tokens_details.cache_write_tokens) : 0;
|
|
24449
24449
|
state.inputTokens = Math.max(0, numberOrZero(usage.input_tokens) - cached - written);
|
|
24450
24450
|
state.cacheReadTokens = cached;
|
|
24451
24451
|
state.cacheWriteTokens = written;
|
|
24452
24452
|
state.outputTokens = numberOrZero(usage.output_tokens);
|
|
24453
|
-
const outputDetails = isRecord$
|
|
24453
|
+
const outputDetails = isRecord$61(usage.output_tokens_details) ? usage.output_tokens_details : null;
|
|
24454
24454
|
if (outputDetails !== null) state.reasoningTokens = numberOrZero(outputDetails.reasoning_tokens);
|
|
24455
24455
|
state.sawUsage = true;
|
|
24456
24456
|
}
|
|
@@ -24538,7 +24538,7 @@ const ANTHROPIC_IN_BAND_STATUS = {
|
|
|
24538
24538
|
* Anything not recognized keeps the mapper's verdict.
|
|
24539
24539
|
*/
|
|
24540
24540
|
function inBandResponsesCode(error, message) {
|
|
24541
|
-
const fields = isRecord$
|
|
24541
|
+
const fields = isRecord$60(error) ? error : {};
|
|
24542
24542
|
const rawCode = (asString$25(fields.code) ?? asString$25(fields.type) ?? "").toLowerCase();
|
|
24543
24543
|
const text = message.toLowerCase();
|
|
24544
24544
|
if (text.includes("rate limit") || rawCode === "rate_limit" || rawCode === "rate_limit_exceeded") return "RATE_LIMIT";
|
|
@@ -24597,13 +24597,13 @@ function reclassifyInBandResponsesError(thrown, rawError, message, classify) {
|
|
|
24597
24597
|
}
|
|
24598
24598
|
/** The wire `error` object of an in-band event, read defensively. */
|
|
24599
24599
|
function readErrorType(error) {
|
|
24600
|
-
if (!isRecord$
|
|
24600
|
+
if (!isRecord$60(error)) return null;
|
|
24601
24601
|
return typeof error.type === "string" ? error.type : null;
|
|
24602
24602
|
}
|
|
24603
24603
|
function asString$25(value) {
|
|
24604
24604
|
return typeof value === "string" ? value : void 0;
|
|
24605
24605
|
}
|
|
24606
|
-
function isRecord$
|
|
24606
|
+
function isRecord$60(value) {
|
|
24607
24607
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24608
24608
|
}
|
|
24609
24609
|
//#endregion
|
|
@@ -25209,7 +25209,7 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
25209
25209
|
}
|
|
25210
25210
|
throw reclassified;
|
|
25211
25211
|
}
|
|
25212
|
-
throw error;
|
|
25212
|
+
throw streamFailure$1(error, signal);
|
|
25213
25213
|
}
|
|
25214
25214
|
} finally {
|
|
25215
25215
|
reader.cancel().catch(() => void 0);
|
|
@@ -25217,6 +25217,18 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
25217
25217
|
}
|
|
25218
25218
|
};
|
|
25219
25219
|
/**
|
|
25220
|
+
* A body severed mid-stream arrives as undici's bare `TypeError: terminated`,
|
|
25221
|
+
* which the harness otherwise normalizes to non-retryable UNKNOWN. Preserve
|
|
25222
|
+
* existing LlmError verdicts and caller cancellation; classify every other
|
|
25223
|
+
* body-read failure as TRANSPORT and retain its cause chain in the message.
|
|
25224
|
+
*/
|
|
25225
|
+
function streamFailure$1(error, signal) {
|
|
25226
|
+
if (error instanceof LlmError) return error;
|
|
25227
|
+
if (signal.aborted) return new LlmError("Command Code stream aborted", "ABORTED", { cause: error });
|
|
25228
|
+
const chain = errorChain(error).trim();
|
|
25229
|
+
return new LlmError(`Command Code stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
25230
|
+
}
|
|
25231
|
+
/**
|
|
25220
25232
|
* The error one recorded in-band failure becomes, or the mapper's own verdict.
|
|
25221
25233
|
*
|
|
25222
25234
|
* Two rules, because this line speaks three in-band vocabularies and they do
|
|
@@ -27868,14 +27880,14 @@ const IN_BAND_SERVER = [
|
|
|
27868
27880
|
function isAbort$2(error, signal) {
|
|
27869
27881
|
return signal?.aborted === true || error instanceof Error && error.name === "AbortError";
|
|
27870
27882
|
}
|
|
27871
|
-
function isRecord$
|
|
27883
|
+
function isRecord$59(value) {
|
|
27872
27884
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27873
27885
|
}
|
|
27874
27886
|
function asString$24(value) {
|
|
27875
27887
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
27876
27888
|
}
|
|
27877
27889
|
function attachmentLabel$3(block) {
|
|
27878
|
-
const attachment = isRecord$
|
|
27890
|
+
const attachment = isRecord$59(block.attachment) ? block.attachment : void 0;
|
|
27879
27891
|
return asString$24(attachment?.name) || asString$24(attachment?.attachmentId);
|
|
27880
27892
|
}
|
|
27881
27893
|
function unavailableImageText$3(block) {
|
|
@@ -27911,7 +27923,7 @@ async function processMessageContent(content, model, attachments, signal) {
|
|
|
27911
27923
|
textParts.push(part);
|
|
27912
27924
|
continue;
|
|
27913
27925
|
}
|
|
27914
|
-
if (!isRecord$
|
|
27926
|
+
if (!isRecord$59(part)) continue;
|
|
27915
27927
|
if (part.type === "text") {
|
|
27916
27928
|
if (typeof part.text === "string" && part.text !== "") textParts.push(part.text);
|
|
27917
27929
|
continue;
|
|
@@ -27940,7 +27952,7 @@ async function processMessageContent(content, model, attachments, signal) {
|
|
|
27940
27952
|
continue;
|
|
27941
27953
|
}
|
|
27942
27954
|
const inline = part.source;
|
|
27943
|
-
if (isRecord$
|
|
27955
|
+
if (isRecord$59(inline)) {
|
|
27944
27956
|
const data = inline.data;
|
|
27945
27957
|
if (typeof data === "string" && data !== "") {
|
|
27946
27958
|
images.push(encodeImage(data, asMediaType(inline.mediaType)));
|
|
@@ -27981,7 +27993,7 @@ async function toOllamaRequest(options, attachments, signal, declared) {
|
|
|
27981
27993
|
const toolResultBlocks = message.content.filter((b) => b.type === "tool-result");
|
|
27982
27994
|
if (toolResultBlocks.length > 0) {
|
|
27983
27995
|
for (const block of toolResultBlocks) {
|
|
27984
|
-
const toolCallId = String(block.toolCallId ?? (isRecord$
|
|
27996
|
+
const toolCallId = String(block.toolCallId ?? (isRecord$59(message.source) ? message.source.callId : "") ?? "");
|
|
27985
27997
|
const processed = await processMessageContent(block.content, options.model, attachments, signal);
|
|
27986
27998
|
messages.push({
|
|
27987
27999
|
role: "tool",
|
|
@@ -32958,11 +32970,11 @@ const MODELS_PATH$2 = "/models";
|
|
|
32958
32970
|
const USAGES_PATH = "/usages";
|
|
32959
32971
|
/** The service reports money in fixed-point units of 1e-6 cents. */
|
|
32960
32972
|
const FIXED_POINT_CENTS = 1e6;
|
|
32961
|
-
function isRecord$
|
|
32973
|
+
function isRecord$58(value) {
|
|
32962
32974
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32963
32975
|
}
|
|
32964
32976
|
function asRecord$14(value) {
|
|
32965
|
-
return isRecord$
|
|
32977
|
+
return isRecord$58(value) ? value : void 0;
|
|
32966
32978
|
}
|
|
32967
32979
|
function asString$23(value) {
|
|
32968
32980
|
if (typeof value === "string" && value.trim() !== "") return value;
|
|
@@ -34077,12 +34089,12 @@ async function testConnection$1(store, options = {}) {
|
|
|
34077
34089
|
*
|
|
34078
34090
|
* @module dsh-chatgpt-subscription/tool-schema
|
|
34079
34091
|
*/
|
|
34080
|
-
function isRecord$
|
|
34092
|
+
function isRecord$57(value) {
|
|
34081
34093
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34082
34094
|
}
|
|
34083
34095
|
function cloneJsonValue(value) {
|
|
34084
34096
|
if (Array.isArray(value)) return value.map(cloneJsonValue);
|
|
34085
|
-
if (isRecord$
|
|
34097
|
+
if (isRecord$57(value)) {
|
|
34086
34098
|
const res = {};
|
|
34087
34099
|
for (const [k, v] of Object.entries(value)) res[k] = cloneJsonValue(v);
|
|
34088
34100
|
return res;
|
|
@@ -34097,7 +34109,7 @@ function resolveLocalJsonPointer(root, ref) {
|
|
|
34097
34109
|
let current = root;
|
|
34098
34110
|
for (const rawPart of ref.slice(2).split("/")) {
|
|
34099
34111
|
const part = rawPart.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
34100
|
-
if (isRecord$
|
|
34112
|
+
if (isRecord$57(current)) {
|
|
34101
34113
|
if (!Object.prototype.hasOwnProperty.call(current, part)) return { found: false };
|
|
34102
34114
|
current = current[part];
|
|
34103
34115
|
} else if (Array.isArray(current)) {
|
|
@@ -34113,7 +34125,7 @@ function resolveLocalJsonPointer(root, ref) {
|
|
|
34113
34125
|
}
|
|
34114
34126
|
function derefNode(node, root, visited) {
|
|
34115
34127
|
if (Array.isArray(node)) return node.map((item) => derefNode(item, root, visited));
|
|
34116
|
-
if (isRecord$
|
|
34128
|
+
if (isRecord$57(node)) {
|
|
34117
34129
|
if (typeof node["$ref"] === "string" && (node["$ref"] === "#" || node["$ref"].startsWith("#/"))) {
|
|
34118
34130
|
const ref = node["$ref"];
|
|
34119
34131
|
if (visited.has(ref)) return node;
|
|
@@ -34122,7 +34134,7 @@ function derefNode(node, root, visited) {
|
|
|
34122
34134
|
visited.add(ref);
|
|
34123
34135
|
const inlined = derefNode(resolved.value, root, visited);
|
|
34124
34136
|
visited.delete(ref);
|
|
34125
|
-
if (isRecord$
|
|
34137
|
+
if (isRecord$57(inlined)) {
|
|
34126
34138
|
const merged = { ...inlined };
|
|
34127
34139
|
for (const [k, v] of Object.entries(node)) {
|
|
34128
34140
|
if (k === "$ref") continue;
|
|
@@ -34142,7 +34154,7 @@ function derefNode(node, root, visited) {
|
|
|
34142
34154
|
}
|
|
34143
34155
|
function hasUnresolvedDefinitionRef(node, bucketKey) {
|
|
34144
34156
|
if (Array.isArray(node)) return node.some((child) => hasUnresolvedDefinitionRef(child, bucketKey));
|
|
34145
|
-
if (isRecord$
|
|
34157
|
+
if (isRecord$57(node)) {
|
|
34146
34158
|
const ref = node["$ref"];
|
|
34147
34159
|
if (typeof ref === "string" && ref.startsWith(`#/${bucketKey}/`)) return true;
|
|
34148
34160
|
for (const [k, v] of Object.entries(node)) {
|
|
@@ -34173,19 +34185,19 @@ function inferTypeFromValues(values) {
|
|
|
34173
34185
|
if (types.size === 1) return types.values().next().value;
|
|
34174
34186
|
}
|
|
34175
34187
|
function normalizeSchemaProperties(node) {
|
|
34176
|
-
if (!isRecord$
|
|
34177
|
-
if (isRecord$
|
|
34178
|
-
for (const propSchema of Object.values(node.properties)) if (isRecord$
|
|
34188
|
+
if (!isRecord$57(node)) return;
|
|
34189
|
+
if (isRecord$57(node.properties)) {
|
|
34190
|
+
for (const propSchema of Object.values(node.properties)) if (isRecord$57(propSchema)) {
|
|
34179
34191
|
if (!propSchema.type && !propSchema.$ref) {
|
|
34180
34192
|
if (Array.isArray(propSchema.enum) && propSchema.enum.length > 0) propSchema.type = inferTypeFromValues(propSchema.enum) ?? "string";
|
|
34181
34193
|
else if (propSchema.const !== void 0) propSchema.type = inferValueType(propSchema.const) ?? "string";
|
|
34182
|
-
else if (isRecord$
|
|
34194
|
+
else if (isRecord$57(propSchema.properties)) propSchema.type = "object";
|
|
34183
34195
|
else if (propSchema.items) propSchema.type = "array";
|
|
34184
34196
|
}
|
|
34185
34197
|
normalizeSchemaProperties(propSchema);
|
|
34186
34198
|
}
|
|
34187
34199
|
}
|
|
34188
|
-
if (isRecord$
|
|
34200
|
+
if (isRecord$57(node.items)) normalizeSchemaProperties(node.items);
|
|
34189
34201
|
else if (Array.isArray(node.items)) for (const item of node.items) normalizeSchemaProperties(item);
|
|
34190
34202
|
}
|
|
34191
34203
|
/**
|
|
@@ -34193,7 +34205,7 @@ function normalizeSchemaProperties(node) {
|
|
|
34193
34205
|
* inlining definitions ($defs/definitions/$ref), and ensuring property types for enums/consts.
|
|
34194
34206
|
*/
|
|
34195
34207
|
function normalizeKimiToolSchema(schema) {
|
|
34196
|
-
if (!isRecord$
|
|
34208
|
+
if (!isRecord$57(schema)) return {
|
|
34197
34209
|
type: "object",
|
|
34198
34210
|
properties: {}
|
|
34199
34211
|
};
|
|
@@ -34211,7 +34223,7 @@ function stripMetaSchema$1(schema) {
|
|
|
34211
34223
|
}
|
|
34212
34224
|
//#endregion
|
|
34213
34225
|
//#region src/host/common/prompt-estimate.ts
|
|
34214
|
-
function isRecord$
|
|
34226
|
+
function isRecord$56(value) {
|
|
34215
34227
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34216
34228
|
}
|
|
34217
34229
|
/** Tool-call arguments as the JSON string a wire carries, whatever shape they arrived in. */
|
|
@@ -34244,7 +34256,7 @@ function estimatedInputTokens(options) {
|
|
|
34244
34256
|
const contentCharacters = (content) => {
|
|
34245
34257
|
if (!Array.isArray(content)) return typeof content === "string" ? content.length : 0;
|
|
34246
34258
|
return content.reduce((total, block) => {
|
|
34247
|
-
if (!isRecord$
|
|
34259
|
+
if (!isRecord$56(block)) return total;
|
|
34248
34260
|
if ((block.type === "text" || block.type === "reasoning") && typeof block.text === "string") return total + block.text.length;
|
|
34249
34261
|
if (block.type === "tool-result") return total + contentCharacters(block.content);
|
|
34250
34262
|
if (block.type === "tool-call") {
|
|
@@ -34387,7 +34399,7 @@ function videoOmissionText$1(reason, label) {
|
|
|
34387
34399
|
}
|
|
34388
34400
|
//#endregion
|
|
34389
34401
|
//#region src/host/common/video-request.ts
|
|
34390
|
-
function isRecord$
|
|
34402
|
+
function isRecord$55(value) {
|
|
34391
34403
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34392
34404
|
}
|
|
34393
34405
|
function asString$22(value) {
|
|
@@ -34395,14 +34407,14 @@ function asString$22(value) {
|
|
|
34395
34407
|
}
|
|
34396
34408
|
function videoAttachmentOf(block) {
|
|
34397
34409
|
const attachment = block.attachment;
|
|
34398
|
-
if (!isRecord$
|
|
34410
|
+
if (!isRecord$55(attachment)) return void 0;
|
|
34399
34411
|
if (typeof attachment.attachmentId !== "string") return void 0;
|
|
34400
34412
|
return attachment;
|
|
34401
34413
|
}
|
|
34402
34414
|
function collectVideoRefs(content, refs) {
|
|
34403
34415
|
if (!Array.isArray(content)) return;
|
|
34404
34416
|
for (const block of content) {
|
|
34405
|
-
if (!isRecord$
|
|
34417
|
+
if (!isRecord$55(block) || block.type !== "video") continue;
|
|
34406
34418
|
const attachment = videoAttachmentOf(block);
|
|
34407
34419
|
if (attachment) refs.set(attachment.attachmentId, attachment);
|
|
34408
34420
|
}
|
|
@@ -34417,7 +34429,7 @@ function requestVideoBytes(block) {
|
|
|
34417
34429
|
function collectRequestVideoBytes(content, lengths) {
|
|
34418
34430
|
if (!Array.isArray(content)) return;
|
|
34419
34431
|
for (const block of content) {
|
|
34420
|
-
if (!isRecord$
|
|
34432
|
+
if (!isRecord$55(block) || block.type !== "video") continue;
|
|
34421
34433
|
const bytes = requestVideoBytes(block);
|
|
34422
34434
|
if (bytes !== void 0) lengths.push(bytes);
|
|
34423
34435
|
}
|
|
@@ -34461,7 +34473,7 @@ function isAbortLike(error, signal) {
|
|
|
34461
34473
|
}
|
|
34462
34474
|
/** True when the request carries any video occurrence at all. */
|
|
34463
34475
|
function requestHasVideo(options) {
|
|
34464
|
-
return options.messages.some((message) => Array.isArray(message.content) && message.content.some((block) => isRecord$
|
|
34476
|
+
return options.messages.some((message) => Array.isArray(message.content) && message.content.some((block) => isRecord$55(block) && block.type === "video"));
|
|
34465
34477
|
}
|
|
34466
34478
|
function omittedVideoText(omit, block) {
|
|
34467
34479
|
return omit("unreadable", videoBlockLabel(block));
|
|
@@ -34496,7 +34508,7 @@ function offloadOldestRequestVideos(options, maxBytes) {
|
|
|
34496
34508
|
if (remaining.count === 0 || !Array.isArray(message.content)) return message;
|
|
34497
34509
|
let replaced = false;
|
|
34498
34510
|
const content = message.content.map((block) => {
|
|
34499
|
-
if (remaining.count === 0 || !isRecord$
|
|
34511
|
+
if (remaining.count === 0 || !isRecord$55(block) || block.type !== "video") return block;
|
|
34500
34512
|
if (requestVideoBytes(block) === void 0) return block;
|
|
34501
34513
|
remaining.count -= 1;
|
|
34502
34514
|
replaced = true;
|
|
@@ -34569,6 +34581,47 @@ function toolArgumentLimit(toolName) {
|
|
|
34569
34581
|
if (toolName === "write" || toolName === "edit" || toolName === "code_run" || toolName === "run_code") return LARGE_PROGRAM_ARGUMENT_LIMIT;
|
|
34570
34582
|
return DEFAULT_ARGUMENT_LIMIT;
|
|
34571
34583
|
}
|
|
34584
|
+
function isRecord$54(value) {
|
|
34585
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34586
|
+
}
|
|
34587
|
+
/**
|
|
34588
|
+
* Repair only a complete ask_user_question call whose optional field names carry
|
|
34589
|
+
* surrounding whitespace. One unambiguous source key and the expected value type
|
|
34590
|
+
* are required; collisions, underscore variants, and all other tools stay intact
|
|
34591
|
+
* so the execution guard can still reject payloads whose meaning is unclear.
|
|
34592
|
+
*/
|
|
34593
|
+
function repairAskUserQuestionArgumentWhitespace(toolName, argumentText) {
|
|
34594
|
+
if (toolName !== "ask_user_question") return argumentText;
|
|
34595
|
+
let parsed;
|
|
34596
|
+
try {
|
|
34597
|
+
parsed = JSON.parse(argumentText);
|
|
34598
|
+
} catch {
|
|
34599
|
+
return argumentText;
|
|
34600
|
+
}
|
|
34601
|
+
if (!isRecord$54(parsed) || !Array.isArray(parsed.questions)) return argumentText;
|
|
34602
|
+
let changed = false;
|
|
34603
|
+
const questions = parsed.questions.map((candidate) => {
|
|
34604
|
+
if (!isRecord$54(candidate)) return candidate;
|
|
34605
|
+
let repaired;
|
|
34606
|
+
for (const canonical of ["header", "options"]) {
|
|
34607
|
+
if (Object.prototype.hasOwnProperty.call(candidate, canonical)) continue;
|
|
34608
|
+
const sources = Object.keys(candidate).filter((key) => key !== canonical && key.trim() === canonical);
|
|
34609
|
+
if (sources.length !== 1) continue;
|
|
34610
|
+
const source = sources[0];
|
|
34611
|
+
const value = candidate[source];
|
|
34612
|
+
if (canonical === "header" ? typeof value !== "string" : !Array.isArray(value)) continue;
|
|
34613
|
+
repaired ??= { ...candidate };
|
|
34614
|
+
delete repaired[source];
|
|
34615
|
+
repaired[canonical] = value;
|
|
34616
|
+
changed = true;
|
|
34617
|
+
}
|
|
34618
|
+
return repaired ?? candidate;
|
|
34619
|
+
});
|
|
34620
|
+
return changed ? JSON.stringify({
|
|
34621
|
+
...parsed,
|
|
34622
|
+
questions
|
|
34623
|
+
}) : argumentText;
|
|
34624
|
+
}
|
|
34572
34625
|
/** Split `header_comment`, `header_unused`, and `header___` into one family. */
|
|
34573
34626
|
function keyFamily(key) {
|
|
34574
34627
|
const suffix = /_(?:comment|unused)$|_+$/.exec(key);
|
|
@@ -36415,6 +36468,10 @@ function appendGuardedArguments(state, call, delta) {
|
|
|
36415
36468
|
call.guard ??= new KimiToolArgumentGuard(call.name);
|
|
36416
36469
|
throwToolGuardViolation(state, call, call.guard.observe(delta));
|
|
36417
36470
|
}
|
|
36471
|
+
function completedToolArguments(call) {
|
|
36472
|
+
const argumentText = call.arguments === "" ? "{}" : call.arguments;
|
|
36473
|
+
return repairAskUserQuestionArgumentWhitespace(call.name, argumentText);
|
|
36474
|
+
}
|
|
36418
36475
|
function closeToolCalls$5(state) {
|
|
36419
36476
|
const out = [];
|
|
36420
36477
|
for (const [wireIndex, call] of [...state.toolCalls.entries()].sort((a, b) => a[0] - b[0])) {
|
|
@@ -36423,7 +36480,7 @@ function closeToolCalls$5(state) {
|
|
|
36423
36480
|
type: "tool-call",
|
|
36424
36481
|
id: toToolCallId(state.toolCallIds.normalize(call.id)),
|
|
36425
36482
|
name: call.name,
|
|
36426
|
-
arguments: call
|
|
36483
|
+
arguments: completedToolArguments(call)
|
|
36427
36484
|
};
|
|
36428
36485
|
state.blocks[call.blockIndex] = block;
|
|
36429
36486
|
out.push({
|
|
@@ -36562,7 +36619,7 @@ function applyOpenAIToolDelta(entry, state) {
|
|
|
36562
36619
|
type: "tool-call",
|
|
36563
36620
|
id: toToolCallId(state.toolCallIds.normalize(call.id)),
|
|
36564
36621
|
name: call.name,
|
|
36565
|
-
arguments: call
|
|
36622
|
+
arguments: completedToolArguments(call)
|
|
36566
36623
|
};
|
|
36567
36624
|
state.blocks[call.blockIndex] = closedBlock;
|
|
36568
36625
|
out.push({
|
|
@@ -36760,7 +36817,7 @@ function processAnthropicStreamLine(line, state) {
|
|
|
36760
36817
|
type: "tool-call",
|
|
36761
36818
|
id: toToolCallId(state.toolCallIds.normalize(pending.id)),
|
|
36762
36819
|
name: pending.name,
|
|
36763
|
-
arguments: pending
|
|
36820
|
+
arguments: completedToolArguments(pending)
|
|
36764
36821
|
};
|
|
36765
36822
|
state.blocks[pending.blockIndex] = block;
|
|
36766
36823
|
out.push({
|
|
@@ -50329,7 +50386,7 @@ function createKimiToolArgumentRecoveryMessage(code) {
|
|
|
50329
50386
|
return createUserMessage$1({
|
|
50330
50387
|
content: [{
|
|
50331
50388
|
type: "text",
|
|
50332
|
-
text: repeated ? "The previous tool call was stopped because its JSON arguments contained a runaway repeated-key family. Do not resume, reuse, or repair that payload. If you still need a tool, make one fresh call with minimal valid JSON and only the exact property names in its schema. For ask_user_question, use only questions, id, question, header, options, label, description, and multi_select as applicable
|
|
50389
|
+
text: repeated ? "The previous tool call was stopped because its JSON arguments contained a runaway repeated-key family. Do not resume, reuse, or repair that payload. If you still need a tool, make one fresh call with minimal valid JSON and only the exact property names in its schema. For ask_user_question, use only questions, id, question, header, options, label, description, and multi_select as applicable. Property names are case-sensitive and must not carry surrounding whitespace, documentation annotations, or appended underscores. A minimal choices call is {\"questions\":[{\"id\":\"choice\",\"question\":\"Which choice?\",\"options\":[{\"label\":\"A\"}]}]}. If no tool call is necessary, continue with the evidence already available or explain the blocker in text." : "The previous tool call was stopped because its arguments exceeded the route byte budget. Do not resend the same payload. If the existing evidence is sufficient, finish in text. Otherwise make one fresh call with the smallest sufficient arguments; for a large file or program, use a legal smaller/chunked approach instead of repeating the oversized content."
|
|
50333
50390
|
}],
|
|
50334
50391
|
source: {
|
|
50335
50392
|
kind: PLUGIN_MESSAGE_SOURCE_KIND,
|
|
@@ -95513,6 +95570,7 @@ const DISPATCH_PRESET = {
|
|
|
95513
95570
|
|
|
95514
95571
|
[Coordinator Identity] You are the Lead & Dispatch Agent: converge requirements, plan architecture, select R1 topology (Lead-Core / Hybrid / Fan-out), orchestrate subagents where ROI is positive, and own final acceptance.
|
|
95515
95572
|
[Execution Pipeline] R0 Triage -> (L2) R-G Interview -> R9 Plan -> R1 Topology -> (if delegating: R2 Routing -> R5 Brief -> R-W Wait) -> R6 Acceptance.
|
|
95573
|
+
[Dispatch Native Tool Whitelist] Top-level: only code_run, cache_warmup_result, dispatch_ledger, progress_update, and structured_output. Every task tool—including win_bash—is program-only: use await tools.<name>(...) inside code_run, never top-level. "One call" = ONE code_run with exactly one sub-call; approval = ONE code_run containing only tools.exit_plan_mode(...).
|
|
95516
95574
|
|
|
95517
95575
|
[Agent Teams Board] A current harness adds exactly one Agent Teams surface beside this mode: the shared task board (team_task_create and its list/get/update siblings). It is bookkeeping, not a second dispatcher. The board tools stay declared whether or not the board is on - frozen declaration, not availability - so confirm with team_task_list before relying on it. When it is on, the dispatch ledger stays the dispatch authority and R5 briefs stay the task contract; publish cross-agent dependencies (blocked_by) and write scopes on one team task per brief, claimed and completed by the child that owns it; never start work because a task is ready, and never reassign a task to skip R6.
|
|
95518
95576
|
|
|
@@ -95527,7 +95585,7 @@ When in doubt, clarify before escalating; if complexity grows mid-task, stop, re
|
|
|
95527
95585
|
## R-G · Clarification Interview (L2 Only, Always Before Planning)
|
|
95528
95586
|
- G1 Design Tree: Model requirements as a dependency tree of decisions; never list flat questions.
|
|
95529
95587
|
- G2 Frontier & Rounds: Ask the entire current frontier (decisions whose prerequisites are settled) in one round, wait for answers, recompute the frontier, and repeat. Never ask one question per round, never ask dependent questions together.
|
|
95530
|
-
- G3 Execution via Tool: Submit each round in
|
|
95588
|
+
- G3 Execution via Tool: Submit each round in ONE code_run program that returns exactly one tools.ask_user_question(...) sub-call with stable ids, concise headers, and your recommended option first marked "(Recommended)", formatted as "Q1 — Title / Question body / Recommended answer". The same rule covers every decision stop outside the interview; see R-W. Copy argument property names verbatim from the schema: Q1/G4 are rule ids, never argument-key suffixes.
|
|
95531
95589
|
- G4 Facts Are Yours, Decisions Are the User's: Never ask the user for repository facts verifiable by reading code or searching files; inspect read-only yourself or dispatch a read-only subagent per R2 (subagent model routes are provided directly by list_subagent_models) without blocking unrelated frontier questions. The same holds for any technical, naming, layout, or styling choice that an established reference in the repository or in AGENTS.md already settles: treat it as a repository fact (target_basis: existing-standard), follow the existing standard, and do not ask the user. Reserve ask_user_question strictly for unsettled product or design decisions with no established precedent.
|
|
95532
95590
|
- G5 Convergence: End the interview only when the frontier is empty and the user explicitly confirms shared understanding.
|
|
95533
95591
|
- G6 Prohibited: Answering your own questions, making product/design decisions for the user, skipping the interview, or treating a casual remark as full sign-off.
|
|
@@ -95556,19 +95614,19 @@ A subagent has full authority to plan, execute, and self-verify within its assig
|
|
|
95556
95614
|
Every task brief covers six elements: Goal / Boundary (which files or modules may be touched) / Constraints / Limits (see below) / Acceptance Criteria / Required Evidence to Report.
|
|
95557
95615
|
- [Compact Delta Brief] Standing default limits and the report schema already live in [Role Identification], so use a Compact Delta Brief by default: state Goal, original file/line Source Pointers (do not paraphrase code into long prose), Module-Interface Boundary, Constraints, Acceptance Criteria, and Required Evidence, and omit repeating standing limits unless overriding them.
|
|
95558
95616
|
- [Limits] When overriding any standing limit, write one line per limit spelling out four things: **what it bounds, in what unit, the cap, and whether it accumulates**. Write explicit caps ("at most 3 attempts", "edits at most 5 files", "test runs: unlimited"), never ranges ("2–5 files"); where an override dimension is left unstated, silence is read as a limit of zero, and a quota that resets per cycle is lost, not banked.
|
|
95559
|
-
- Do not ask the child to restate your rules back as a correctness check; if a limit is genuinely unclear, instruct the child to spend one minimal tool call to verify it. Dispatch independent tasks concurrently
|
|
95617
|
+
- Do not ask the child to restate your rules back as a correctness check; if a limit is genuinely unclear, instruct the child to spend one minimal tool call to verify it. Dispatch independent tasks concurrently through code_run Promise.all only after the interview has converged.
|
|
95560
95618
|
|
|
95561
95619
|
## R6 · Review & Acceptance
|
|
95562
95620
|
Two layers: subagent self-check -> your independent review (reading diffs, running tests, checking each criterion). The completion notification is a post-hoc signal: it tells you a child stopped, not that the work passed.
|
|
95563
95621
|
- Re-dispatch budget per brief: 1 first attempt + at most 2 re-dispatches = at most 3 runs total. Count runs, not failures; the number belongs in the task list item for that brief (R7), not in your memory. Only after the third run fails, transition to R8 Fallback.
|
|
95564
95622
|
- [Non-Penalized hand_back] A subagent that stops cleanly before mutating any out-of-boundary file and reports status: hand_back with a valid hand_back_reason is a scope routing event, not an execution failure, and does not increment the brief’s 3-run failure counter. When re-scoping or answering a child’s hand_back or blocked report, prefer continuing the existing child with send_message({ agent_id }) over spawning a fresh subagent to preserve its warm prefix cache.
|
|
95565
|
-
- [Noticed but not handled] Every defect found in review: the defect goes back out on a re-dispatch with evidence or go to the user via ask_user_question (R-W); on Lead-Core/Hybrid core, fix and re-verify before delivery. Writing it into the delivery summary and shipping anyway is not an available outcome.
|
|
95623
|
+
- [Noticed but not handled] Every defect found in review: the defect goes back out on a re-dispatch with evidence or go to the user via tools.ask_user_question inside code_run (R-W); on Lead-Core/Hybrid core, fix and re-verify before delivery. Writing it into the delivery summary and shipping anyway is not an available outcome.
|
|
95566
95624
|
- [UI Visual Evidence Gate] For any task or subtask that changes visible UI or GUI layout, styling, or components, acceptance requires both Before and After visual evidence—screenshots or live DOM/rendered captures—taken under the same scenario, viewport, and theme. After-only evidence fails R6 review.
|
|
95567
95625
|
|
|
95568
95626
|
## R-W · Turn Boundary (Waiting / Goals / Questions)
|
|
95569
95627
|
- [Waiting for Subagents] End your turn and let the subagent completion notification wake you. Treat it as "there is now something to review", never as "this passed". Never run sleep, polling loops, watch, or placeholder long commands to wait; only call job_output({ wait: true }) when genuinely blocked on an immediate collection. State who was dispatched, what you are waiting for, and what you will do next before ending the turn.
|
|
95570
95628
|
- [Goals] Do not proactively create goals: never call create_goal or /goal unless the user asks; track tasks in todo_write.
|
|
95571
|
-
- [Questions] Whenever a decision is missing, hand the question out with
|
|
95629
|
+
- [Questions] Whenever a decision is missing, hand the question out with ONE code_run program containing exactly one tools.ask_user_question(...) sub-call. Only two exceptions: plan-mode approval still goes through tools.exit_plan_mode inside code_run, and a finished task asks nothing.
|
|
95572
95630
|
|
|
95573
95631
|
## R7 · Documentation
|
|
95574
95632
|
Maintain the task list (in todo_write, not create_goal; see R-W), decision log, and interview conclusions; Each task item carries its own run count.
|
|
@@ -95579,8 +95637,8 @@ Maintain the task list (in todo_write, not create_goal; see R-W), decision log,
|
|
|
95579
95637
|
Fallback is a task-scoped, non-session-wide exception for delegated briefs: it covers only the single task that triggered it. Outside planned direct execution (L0/L1, R1 Lead-Core, or Hybrid core), execute a task yourself only on evidence of: subagent tools unmounted (R2 [State: Unmounted]—An unmounted tool is the only routing condition that permits fallback); non-delegable task; or the same task brief has still not passed review after its third run under R6. Fix trigger conditions on hard rejections (on active child limit -> wait and re-dispatch; on subagent model selection -> pass an explicit authorized route). When the next task begins, always return to R0 to triage anew.
|
|
95580
95638
|
|
|
95581
95639
|
## R9 · Plan Pipeline (Converged Interview -> Plan Mode -> Plan -> Approval)
|
|
95582
|
-
- Trigger: only for L2 once R-G has converged. Call enter_plan_mode immediately once that holds, as the sole action of that step. Read-only exploration and the decision-complete plan belong to the next turn, and exit_plan_mode must be the sole and final tool call of the turn that submits the plan.
|
|
95583
|
-
- Rejection & Abandon: on "Keep planning", revise and resubmit via exit_plan_mode; call leave_plan_mode only when the user explicitly says no plan is wanted. When enter_plan_mode is absent, the degraded path is one ask_user_question asking the user to enter /plan.
|
|
95640
|
+
- Trigger: only for L2 once R-G has converged. Call tools.enter_plan_mode inside ONE code_run immediately once that holds, as the sole top-level action of that step. Read-only exploration and the decision-complete plan belong to the next turn, and ONE code_run containing only tools.exit_plan_mode must be the sole and final top-level tool call of the turn that submits the plan.
|
|
95641
|
+
- Rejection & Abandon: on "Keep planning", revise and resubmit via tools.exit_plan_mode inside code_run; call tools.leave_plan_mode inside code_run only when the user explicitly says no plan is wanted. When enter_plan_mode is absent, the degraded path is ONE code_run program containing exactly one tools.ask_user_question(...) sub-call asking the user to enter /plan.
|
|
95584
95642
|
- Subagent: where the host exposes the live root set (agents.roots()), a call made by a live child is rejected with DELEGATED_CALLER, while an older generation cannot determine roots at all and the bridge lets the call through. Never rely on that rejection: it carries the open decision, including any request to enter Plan Mode, back to its dispatcher.
|
|
95585
95643
|
|
|
95586
95644
|
## Anti-Patterns (Any Occurrence Is a Violation)
|
|
@@ -95588,7 +95646,7 @@ Fallback is a task-scoped, non-session-wide exception for delegated briefs: it c
|
|
|
95588
95646
|
2. Switching to teammate vocabulary to keep orchestrating, or Treating the team task board as a substitute for R1 topology, R2 routing, R5 briefs, R6 acceptance, or R-W waiting (R1, R6).
|
|
95589
95647
|
3. Omitting provider/model under [State: Listed], Second-guessing list_subagent_models output by hunting through local config or source files just to check which subagent models are allowed, or Reporting a route as "authorized", or claiming per-task routing is in force, when the session recorded no allowlist (R2).
|
|
95590
95648
|
4. Writing a task brief with a range where a cap belongs ("2–5 files", "a few attempts"), or Asking a subagent to restate its rules as a correctness check (R0, R5).
|
|
95591
|
-
5. Running sleep, polling loops, or placeholder long commands to wait, Proactively creating a goal at the start of a task, or Ending with a paragraph of prose to wait for user sign-off instead of
|
|
95649
|
+
5. Running sleep, polling loops, or placeholder long commands to wait, Proactively creating a goal at the start of a task, or Ending with a paragraph of prose to wait for user sign-off instead of asking through tools.ask_user_question inside code_run (R-W).
|
|
95592
95650
|
6. Directly editing a subagent's module, declaring completion without verification, or Shipping a defect you already named in the review, on the grounds that it is recorded in the summary (R6).
|
|
95593
95651
|
7. Carrying a one-off fallback forward as the default for the rest of the session, or Using a tool hard-rejection as a fallback excuse instead of fixing its trigger condition (R8).
|
|
95594
95652
|
8. 23. Asking the user about an implementation detail an existing-standard in the repository already settles; 24. Penalizing a clean status: hand_back scope escalation as a failed run, or spawning a cold replacement subagent when send_message can continue the warm child session; 25. Accepting a visible UI change without Before & After comparison evidence (R-G, R6).
|
|
@@ -95647,13 +95705,13 @@ Fallback is a task-scoped, non-session-wide exception for delegated briefs: it c
|
|
|
95647
95705
|
config: [{
|
|
95648
95706
|
id: "plan-mode",
|
|
95649
95707
|
name: "@eddyskywalker/dsh-chatgpt-subscription/plan-mode",
|
|
95650
|
-
config: { section: `[Plan Mode] Plan Mode is active. Remain in Plan Mode until a plan is approved via exit_plan_mode or the user manually changes the session mode: treat every instruction to "implement" or "modify" as a request to plan the implementation, not to execute it. Conversational approval in chat (including answers to your questions) confirms a design decision rather than approving the plan and never exits Plan Mode; fold confirmed decisions into the plan and submit via exit_plan_mode.
|
|
95708
|
+
config: { section: `[Plan Mode] Plan Mode is active. Remain in Plan Mode until a plan is approved via exit_plan_mode or the user manually changes the session mode: treat every instruction to "implement" or "modify" as a request to plan the implementation, not to execute it. Conversational approval in chat (including answers to your questions) confirms a design decision rather than approving the plan and never exits Plan Mode; fold confirmed decisions into the plan and submit via tools.exit_plan_mode inside code_run.
|
|
95651
95709
|
|
|
95652
|
-
[Read-Only Exploration & Clarification Interview] Inspect the repository first using non-mutating reads, searches, and static checks, preferring existing functions, utilities, and patterns; never edit or write files, mutate config, run formatters/codegen that rewrite tracked files, commit, or otherwise enact the plan. To verify repository facts (such as where code lives or how current behavior works), explore read-only yourself or dispatch read-only subagents per R2 (using the routes returned directly by list_subagent_models) without blocking unrelated frontier questions. Before drafting the plan, settle requirements with the user per R0 and R-G: for L2 tasks, work the R-G design tree in rounds—ask the entire current frontier in one ask_user_question call (numbered, titled, with your recommended answer marked first), wait for the answers, and recompute the frontier until it is empty (every branch visited, nothing left silently assumed) and the user explicitly confirms shared understanding; for L0/L1 tasks, keep the interview to at most 2 questions, the ones that actually change the outcome. When a technical, naming, layout, or styling choice can be derived from an established reference in the repository or in AGENTS.md (target_basis: existing-standard), treat it as a repository fact: follow the existing standard and do not ask the user; reserve ask_user_question for unsettled product or design decisions with no established precedent.
|
|
95710
|
+
[Read-Only Exploration & Clarification Interview] Inspect the repository first using non-mutating reads, searches, and static checks, preferring existing functions, utilities, and patterns; never edit or write files, mutate config, run formatters/codegen that rewrite tracked files, commit, or otherwise enact the plan. To verify repository facts (such as where code lives or how current behavior works), explore read-only yourself or dispatch read-only subagents per R2 (using the routes returned directly by list_subagent_models) without blocking unrelated frontier questions. Before drafting the plan, settle requirements with the user per R0 and R-G: for L2 tasks, work the R-G design tree in rounds—ask the entire current frontier in ONE code_run program containing exactly one tools.ask_user_question(...) sub-call (numbered, titled, with your recommended answer marked first), wait for the answers, and recompute the frontier until it is empty (every branch visited, nothing left silently assumed) and the user explicitly confirms shared understanding; for L0/L1 tasks, keep the interview to at most 2 questions, the ones that actually change the outcome. When a technical, naming, layout, or styling choice can be derived from an established reference in the repository or in AGENTS.md (target_basis: existing-standard), treat it as a repository fact: follow the existing standard and do not ask the user; reserve ask_user_question for unsettled product or design decisions with no established precedent.
|
|
95653
95711
|
|
|
95654
95712
|
[Plan Completeness] Make the plan decision-complete: state the goal, success criteria, and R1 execution topology (Lead-Core, Hybrid, or Fan-out with subtask boundaries); group implementation changes by subsystem; specify public API, schema, and data-flow changes; and cover edge cases, failure modes, test strategy, acceptance criteria, and explicit assumptions. Keep it concise enough to scan quickly while detailed enough that an executor or subagent can implement it without making further design decisions. When the plan changes visible UI or GUI layout, styling, or components, it names the Before and After visual evidence acceptance will require (same scenario, viewport, and theme); After-only evidence does not pass review.
|
|
95655
95713
|
|
|
95656
|
-
[Plan Approval] When ready, call exit_plan_mode with the complete plan Markdown starting with a # Title heading
|
|
95714
|
+
[Plan Approval] When ready, make ONE code_run program whose only sub-call is tools.exit_plan_mode with the complete plan Markdown starting with a # Title heading; that code_run is the sole and final top-level tool call of that turn: implementation or dispatch happens only in subsequent turns after approval. Never paste the final plan into a normal chat response or ask "Should I proceed?" in prose or via tools.ask_user_question inside code_run. If the user rejects the plan, fold in their feedback and resubmit via tools.exit_plan_mode inside code_run; if the approval channel is unavailable or aborted, stay in Plan Mode and ask the user to switch modes manually—never start implementing on your own.` }
|
|
95657
95715
|
}, {
|
|
95658
95716
|
id: "plan-mode-pipeline",
|
|
95659
95717
|
name: "@eddyskywalker/dsh-chatgpt-subscription/plan-mode-pipeline"
|
|
@@ -95783,7 +95841,16 @@ Fallback is a task-scoped, non-session-wide exception for delegated briefs: it c
|
|
|
95783
95841
|
},
|
|
95784
95842
|
{
|
|
95785
95843
|
id: "code-mode",
|
|
95786
|
-
name: CODEMODE_PACKAGE
|
|
95844
|
+
name: CODEMODE_PACKAGE,
|
|
95845
|
+
config: {
|
|
95846
|
+
nativeToolsOnly: true,
|
|
95847
|
+
nativeTools: [
|
|
95848
|
+
"cache_warmup_result",
|
|
95849
|
+
"dispatch_ledger",
|
|
95850
|
+
"progress_update",
|
|
95851
|
+
"structured_output"
|
|
95852
|
+
]
|
|
95853
|
+
}
|
|
95787
95854
|
},
|
|
95788
95855
|
{
|
|
95789
95856
|
id: "present",
|
|
@@ -106532,6 +106599,7 @@ const Config = z$1.object({
|
|
|
106532
106599
|
planModePipeline: z$1.boolean().default(true).volatile().description("启用计划模式管线:允许调度模式在澄清访谈收敛后用 enter_plan_mode 进入计划模式,放弃规划时用 leave_plan_mode 退出。"),
|
|
106533
106600
|
dispatchExecutionGuard: z$1.boolean().default(true).volatile().description("启用调度执行守卫:在执行期拦截子代理越权调用主控专用工具,并拦截等待子代理期间的纯 sleep 空等命令;不修改工具声明面,零损耗保护 Kimi 缓存。"),
|
|
106534
106601
|
toolRunawayGuard: z$1.boolean().default(true).volatile().description("启用工具失控治理:重复调用同一工具与参数时分级提醒;Kimi 保留第 12 次强停,其他线路只提醒。"),
|
|
106602
|
+
mediaTools: z$1.boolean().default(true).volatile().description("注册图片/视频工具:Codex/Antigravity 生图、Kimi 视频挂载、MiniMax 视频生成与理解;默认开启。修改后重载插件或重启 DSH,Kimi 既有会话在工具表变化后会重建一次前缀缓存。"),
|
|
106535
106603
|
teamPolicyCacheGuard: z$1.boolean().default(true).volatile().description("把内置 Agent Teams 的 team:policy 段从 system prompt 摘掉,改为开关切换时以尾部用户消息投递一次,避免中途开团队协作时刷掉整段前缀缓存;默认开启。"),
|
|
106536
106604
|
cacheWarmup: z$1.boolean().default(true).volatile().description(CACHE_WARMUP_SETTING_DESCRIPTION),
|
|
106537
106605
|
cacheWarmupProviders: z$1.array(z$1.string()).default(CONTROLLED_PROVIDERS).volatile().description("允许产生新结果预览的线路;默认覆盖全部受控线路,空数组表示关闭所有新投影。"),
|
|
@@ -107305,13 +107373,14 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
107305
107373
|
]);
|
|
107306
107374
|
const disposeUpdateRoutes = registerUpdateRoutes(ctx, { fetchFn: proxyFetch });
|
|
107307
107375
|
const disposeAdapter = ctx.llm.registerAdapter([PROVIDER_ID$13], adapter);
|
|
107308
|
-
const
|
|
107309
|
-
const
|
|
107376
|
+
const mediaToolsEnabled = pluginConfig.mediaTools?.get() !== false;
|
|
107377
|
+
const disposeImageTool = mediaToolsEnabled ? ctx.tools.register(createCodexImageTool(oauth, ctx.attachments, { fetchFn: proxyFetch })) : () => void 0;
|
|
107378
|
+
const disposeAntigravityImageTool = mediaToolsEnabled ? ctx.tools.register(createAntigravityImageTool(antigravityAccountPool, antigravityStore, ctx.attachments, {
|
|
107310
107379
|
fetchFn: antigravityProxyFetch,
|
|
107311
107380
|
isEnabled: () => antigravityPreferences.status().enabled !== false
|
|
107312
|
-
}));
|
|
107313
|
-
const disposeVideoTool = ctx.tools.register(createKimiVideoTool(ctx, { fetchFn: proxyFetch }));
|
|
107314
|
-
const minimaxMediaToolsEnabled = minimaxCodePreferences.status().enabled;
|
|
107381
|
+
})) : () => void 0;
|
|
107382
|
+
const disposeVideoTool = mediaToolsEnabled ? ctx.tools.register(createKimiVideoTool(ctx, { fetchFn: proxyFetch })) : () => void 0;
|
|
107383
|
+
const minimaxMediaToolsEnabled = mediaToolsEnabled && minimaxCodePreferences.status().enabled;
|
|
107315
107384
|
const disposeMinimaxUnderstandVideoTool = minimaxMediaToolsEnabled ? ctx.tools.register(createMinimaxUnderstandVideoTool(ctx, {
|
|
107316
107385
|
fetchFn: proxyFetch,
|
|
107317
107386
|
pool: minimaxCodeAccountPool
|