@eddyskywalker/dsh-chatgpt-subscription 0.73.0 → 0.74.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 +21 -0
- package/lib/client.js.map +1 -1
- package/lib/codemode.js +125 -60
- package/lib/{entry-plan-mode-5DBZA4Il.js → entry-plan-mode-EShP3ndV.js} +34 -8
- package/lib/index.js +591 -477
- package/lib/{llm-compat-u9mor0uu.js → llm-compat--WsaC9K6.js} +25 -1
- package/lib/plan-mode.js +2 -2
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/entry-codemode.d.ts.map +1 -1
- package/lib/types/entry-plan-mode.d.ts +14 -0
- package/lib/types/entry-plan-mode.d.ts.map +1 -1
- package/lib/types/host/antigravity-acp/errors.d.ts +1 -1
- package/lib/types/host/antigravity-acp/errors.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/contracts.d.ts +11 -1
- package/lib/types/host/cache-warmup/contracts.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/result-tool.d.ts +4 -0
- package/lib/types/host/cache-warmup/result-tool.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/store.d.ts.map +1 -1
- package/lib/types/host/claude/adapter.d.ts +2 -1
- package/lib/types/host/claude/adapter.d.ts.map +1 -1
- package/lib/types/host/cline-pass/adapter.d.ts.map +1 -1
- package/lib/types/host/cline-pass/mapper.d.ts +1 -1
- package/lib/types/host/cline-pass/mapper.d.ts.map +1 -1
- package/lib/types/host/codemode/rules.d.ts.map +1 -1
- package/lib/types/host/codemode/transport.d.ts +23 -1
- package/lib/types/host/codemode/transport.d.ts.map +1 -1
- package/lib/types/host/command-code/adapter.d.ts.map +1 -1
- package/lib/types/host/common/llm-compat.d.ts +15 -2
- package/lib/types/host/common/llm-compat.d.ts.map +1 -1
- package/lib/types/host/common/stream-error.d.ts +1 -1
- package/lib/types/host/common/stream-error.d.ts.map +1 -1
- package/lib/types/host/common/tool-runaway.d.ts +91 -3
- package/lib/types/host/common/tool-runaway.d.ts.map +1 -1
- package/lib/types/host/compaction-policy-guard.d.ts.map +1 -1
- package/lib/types/host/glm-coding-plan/adapter.d.ts.map +1 -1
- package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
- package/lib/types/host/kimi-code/repeat-breaker.d.ts +3 -1
- package/lib/types/host/kimi-code/repeat-breaker.d.ts.map +1 -1
- package/lib/types/host/minimax-code/adapter.d.ts.map +1 -1
- package/lib/types/host/minimax-code/runtime-enhancements.d.ts +10 -97
- package/lib/types/host/minimax-code/runtime-enhancements.d.ts.map +1 -1
- package/lib/types/host/ollama/adapter.d.ts.map +1 -1
- package/lib/types/host/opendesign/adapter.d.ts.map +1 -1
- package/lib/types/host/opendesign/mapper.d.ts +1 -1
- package/lib/types/host/opendesign/mapper.d.ts.map +1 -1
- package/lib/types/host/qoder/adapter.d.ts.map +1 -1
- package/lib/types/host/responses-client.d.ts.map +1 -1
- package/lib/types/host/step-code/adapter.d.ts.map +1 -1
- package/lib/types/host/workbuddy/account-pool.d.ts +1 -1
- package/lib/types/host/workbuddy/account-pool.d.ts.map +1 -1
- package/lib/types/host/workbuddy/adapter.d.ts +2 -1
- package/lib/types/host/workbuddy/adapter.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +42 -42
- package/presets/dispatch/README.md +2 -2
- package/presets/dispatch/agent.cordis.yml +2 -2
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as resolveProgressUpdatesSettings, n as attachProgressSettings } from "./entry-progress-updates-DMLVID9V.js";
|
|
2
2
|
import { attachPlanModePipelineSettings, resolvePlanModePipelineEnabled } from "./plan-mode-pipeline.js";
|
|
3
|
-
import { n as PLUGIN_MESSAGE_SOURCE_KIND, r as normalizeGenerateOptions, t as LlmError$1 } from "./llm-compat
|
|
3
|
+
import { n as PLUGIN_MESSAGE_SOURCE_KIND, r as normalizeGenerateOptions, t as LlmError$1 } from "./llm-compat--WsaC9K6.js";
|
|
4
4
|
import { DEFAULT_SKIP_PROVIDERS, PRUNER_SERVICE_NAME, resolveSkipProviders, shouldSkipPruningForSession } from "./tool-result-pruner.js";
|
|
5
|
-
import {
|
|
5
|
+
import { S as resolveDispatchExecutionGuardEnabled, g as installPlanModeExitReminder, l as PLAN_PROJECTION_KEY, m as createPlanNotice, x as installDispatchExecutionGuard, y as registeredPlanControllerActive } from "./entry-plan-mode-EShP3ndV.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";
|
|
@@ -817,7 +817,7 @@ const ROUTE_PREFIX$5 = "/api/dsh-chatgpt-subscription";
|
|
|
817
817
|
* `test/responses-client.test.ts` asserts the two agree, so a release that
|
|
818
818
|
* forgets this constant fails the suite instead of shipping quietly.
|
|
819
819
|
*/
|
|
820
|
-
const PLUGIN_VERSION = "0.
|
|
820
|
+
const PLUGIN_VERSION = "0.74.0";
|
|
821
821
|
const CODEX_CHATGPT_PROVIDER_ID = "codex-chatgpt";
|
|
822
822
|
const CODEX_API_BASE = "https://chatgpt.com/backend-api/codex";
|
|
823
823
|
const CODEX_RESPONSES_URL = `${CODEX_API_BASE}/responses`;
|
|
@@ -4486,8 +4486,8 @@ var OAuthService = class {
|
|
|
4486
4486
|
}
|
|
4487
4487
|
const payload = await response.json().catch(() => null);
|
|
4488
4488
|
const record = isRecord$69(payload) ? payload : {};
|
|
4489
|
-
const authId = nonEmptyString$
|
|
4490
|
-
const userCode = nonEmptyString$
|
|
4489
|
+
const authId = nonEmptyString$12(record.device_auth_id);
|
|
4490
|
+
const userCode = nonEmptyString$12(record.user_code) ?? nonEmptyString$12(record.usercode);
|
|
4491
4491
|
if (authId === void 0 || userCode === void 0) throw new OAuthServiceError("oauth-token-exchange-failed", "ChatGPT returned no device code.");
|
|
4492
4492
|
return {
|
|
4493
4493
|
authId,
|
|
@@ -4553,8 +4553,8 @@ var OAuthService = class {
|
|
|
4553
4553
|
throw new OAuthServiceError("oauth-token-exchange-failed", `The ChatGPT device confirmation was refused (${response.status}${detail === void 0 ? "" : `, ${detail}`}).`, response.status);
|
|
4554
4554
|
}
|
|
4555
4555
|
const record = isRecord$69(payload) ? payload : {};
|
|
4556
|
-
const authorizationCode = nonEmptyString$
|
|
4557
|
-
const codeVerifier = nonEmptyString$
|
|
4556
|
+
const authorizationCode = nonEmptyString$12(record.authorization_code);
|
|
4557
|
+
const codeVerifier = nonEmptyString$12(record.code_verifier);
|
|
4558
4558
|
if (authorizationCode === void 0 || codeVerifier === void 0) throw new OAuthServiceError("oauth-token-exchange-failed", "ChatGPT confirmed the device code but returned no authorization code.");
|
|
4559
4559
|
return {
|
|
4560
4560
|
authorizationCode,
|
|
@@ -4911,7 +4911,7 @@ function deviceErrorIdentifier(payload) {
|
|
|
4911
4911
|
candidates.push(payload.status);
|
|
4912
4912
|
for (const candidate of candidates) if (typeof candidate === "string" && /^[a-z0-9_.-]{1,64}$/i.test(candidate)) return candidate;
|
|
4913
4913
|
}
|
|
4914
|
-
function nonEmptyString$
|
|
4914
|
+
function nonEmptyString$12(value) {
|
|
4915
4915
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
4916
4916
|
}
|
|
4917
4917
|
function isRecord$69(value) {
|
|
@@ -5099,7 +5099,7 @@ function isRecord$68(value) {
|
|
|
5099
5099
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5100
5100
|
}
|
|
5101
5101
|
/** A trimmed, non-empty string, or nothing. */
|
|
5102
|
-
function nonEmptyString$
|
|
5102
|
+
function nonEmptyString$11(value) {
|
|
5103
5103
|
if (typeof value !== "string") return void 0;
|
|
5104
5104
|
const trimmed = value.trim();
|
|
5105
5105
|
return trimmed === "" ? void 0 : trimmed;
|
|
@@ -5246,9 +5246,9 @@ function parseAdoptedCodexCredential(value, sourcePath) {
|
|
|
5246
5246
|
if (value.auth_mode !== "chatgpt") return void 0;
|
|
5247
5247
|
const tokens = value[CODEX_CLI_TOKENS_KEY];
|
|
5248
5248
|
if (!isRecord$68(tokens)) return void 0;
|
|
5249
|
-
const accessToken = nonEmptyString$
|
|
5249
|
+
const accessToken = nonEmptyString$11(tokens.access_token);
|
|
5250
5250
|
if (accessToken === void 0) return void 0;
|
|
5251
|
-
const refreshToken = nonEmptyString$
|
|
5251
|
+
const refreshToken = nonEmptyString$11(tokens.refresh_token);
|
|
5252
5252
|
if (refreshToken === void 0) return void 0;
|
|
5253
5253
|
const expiresAt = expiryFromAccessToken(accessToken);
|
|
5254
5254
|
if (expiresAt === void 0) return void 0;
|
|
@@ -5257,17 +5257,17 @@ function parseAdoptedCodexCredential(value, sourcePath) {
|
|
|
5257
5257
|
refreshToken,
|
|
5258
5258
|
expiresAt
|
|
5259
5259
|
};
|
|
5260
|
-
const idToken = nonEmptyString$
|
|
5260
|
+
const idToken = nonEmptyString$11(tokens.id_token);
|
|
5261
5261
|
if (idToken !== void 0) {
|
|
5262
5262
|
credentials.idToken = idToken;
|
|
5263
5263
|
const claims = decodeJwtClaims$1(idToken);
|
|
5264
|
-
const email = claims === void 0 ? void 0 : nonEmptyString$
|
|
5264
|
+
const email = claims === void 0 ? void 0 : nonEmptyString$11(claims.email);
|
|
5265
5265
|
if (email !== void 0) credentials.email = email;
|
|
5266
5266
|
const authClaims = claims === void 0 ? void 0 : claims[CODEX_AUTH_CLAIMS_KEY];
|
|
5267
|
-
const planType = isRecord$68(authClaims) ? nonEmptyString$
|
|
5267
|
+
const planType = isRecord$68(authClaims) ? nonEmptyString$11(authClaims.chatgpt_plan_type) : void 0;
|
|
5268
5268
|
if (planType !== void 0) credentials.planType = planType;
|
|
5269
5269
|
}
|
|
5270
|
-
const accountId = nonEmptyString$
|
|
5270
|
+
const accountId = nonEmptyString$11(tokens.account_id);
|
|
5271
5271
|
if (accountId !== void 0) credentials.accountId = accountId;
|
|
5272
5272
|
return {
|
|
5273
5273
|
adopted: true,
|
|
@@ -7575,20 +7575,214 @@ function resolveToolRunawayGuardEnabled(config) {
|
|
|
7575
7575
|
}
|
|
7576
7576
|
return field !== false;
|
|
7577
7577
|
}
|
|
7578
|
+
/** 轮询类工具名(后台任务的结果读取)。 */
|
|
7579
|
+
const POLLING_TOOL_NAMES = Object.freeze(["job_output", "task_output"]);
|
|
7580
|
+
const TURN_ONLY_SUFFIX = " This is a temporary runtime reminder for the current Turn only, not a user preference or a durable rule; do not save this reminder or generalize it into Memory, Skills, or other persistent instruction files for future Turns or sessions.";
|
|
7581
|
+
/** 渲染「同一个动作立刻重复」提醒。 */
|
|
7582
|
+
function renderExactActionRepeatReminder(occurrences) {
|
|
7583
|
+
return `[runaway guard] The immediately repeated tool action has now occurred ${occurrences} times with the same arguments. Do not repeat it unchanged. Inspect the results already available, then either change strategy with a concrete expected state change, or report the blocker. Repetition alone does not establish that the task is complete or impossible.${TURN_ONLY_SUFFIX}`;
|
|
7584
|
+
}
|
|
7585
|
+
/** 渲染「同一族错误连续发生」提醒。 */
|
|
7586
|
+
function renderSameErrorFamilyReminder(occurrences) {
|
|
7587
|
+
return `[runaway guard] The same tool error family has now occurred ${occurrences} times in a row. Do not retry the same route unchanged. Diagnose the cause, change one controlled variable or switch route. Do not infer that the entire task has failed from this signal.${TURN_ONLY_SUFFIX}`;
|
|
7588
|
+
}
|
|
7589
|
+
/** 渲染「反复轮询同一个后台任务」提醒。 */
|
|
7590
|
+
function renderPollingRepeatReminder(occurrences) {
|
|
7591
|
+
return [
|
|
7592
|
+
"<system-reminder>",
|
|
7593
|
+
`${occurrences === 3 ? "Three" : String(occurrences)} task_output reads for the same task have returned an unchanged status and output cursor. Avoid repeated polling; you will be notified automatically and this conversation will resume when the background task completes.`,
|
|
7594
|
+
"This reminder applies only to the current Turn. Do not save or generalize it into Memory, Skills, or other persistent instructions.",
|
|
7595
|
+
"</system-reminder>"
|
|
7596
|
+
].join("\n");
|
|
7597
|
+
}
|
|
7598
|
+
/** 规范化错误文本,去掉会漂移的数字/id/时间戳,取它的「族」。 */
|
|
7599
|
+
function normalizeToolErrorFamily(text) {
|
|
7600
|
+
if (text === void 0 || text === "") return "unknown";
|
|
7601
|
+
return (text.split(/\r?\n/, 1)[0] ?? "").replace(/\d+/g, "#").slice(0, 200);
|
|
7602
|
+
}
|
|
7603
|
+
function nonEmptyString$10(value) {
|
|
7604
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
7605
|
+
}
|
|
7606
|
+
/** 判断一次工具执行结果是否失败。 */
|
|
7607
|
+
function isToolErrorResult(result) {
|
|
7608
|
+
return isRecord$67(result) && result["isError"] === true;
|
|
7609
|
+
}
|
|
7610
|
+
/** 读一次工具执行结果里的结构化错误码。 */
|
|
7611
|
+
function toolErrorCodeOf(result) {
|
|
7612
|
+
if (!isRecord$67(result)) return void 0;
|
|
7613
|
+
const error = result["error"];
|
|
7614
|
+
if (!isRecord$67(error)) return void 0;
|
|
7615
|
+
const info = error["info"];
|
|
7616
|
+
if (isRecord$67(info)) {
|
|
7617
|
+
const infoCode = nonEmptyString$10(info["code"]);
|
|
7618
|
+
if (infoCode !== void 0) return infoCode;
|
|
7619
|
+
}
|
|
7620
|
+
return nonEmptyString$10(error["code"]);
|
|
7621
|
+
}
|
|
7622
|
+
/** 读一次工具执行结果里的全部文本块。 */
|
|
7623
|
+
function toolResultTextOf(result) {
|
|
7624
|
+
if (!isRecord$67(result)) return "";
|
|
7625
|
+
const content = result["content"];
|
|
7626
|
+
if (!Array.isArray(content)) return "";
|
|
7627
|
+
const parts = [];
|
|
7628
|
+
for (const block of content) if (isRecord$67(block) && block["type"] === "text") parts.push(nonEmptyString$10(block["text"]) ?? "");
|
|
7629
|
+
return parts.join("\n");
|
|
7630
|
+
}
|
|
7631
|
+
/** 读一次工具执行结果里的失败文本(无 `error.message` 且为错误结果时回退读取文本内容)。 */
|
|
7632
|
+
function toolErrorTextOf(result) {
|
|
7633
|
+
if (isRecord$67(result)) {
|
|
7634
|
+
const error = result["error"];
|
|
7635
|
+
if (isRecord$67(error)) {
|
|
7636
|
+
const msg = nonEmptyString$10(error["message"]);
|
|
7637
|
+
if (msg !== void 0) return msg;
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
if (!isToolErrorResult(result)) return void 0;
|
|
7641
|
+
const text = toolResultTextOf(result);
|
|
7642
|
+
return text === "" ? void 0 : text;
|
|
7643
|
+
}
|
|
7644
|
+
/** 从一次工具执行与结果中构造失控检测观察量。 */
|
|
7645
|
+
function observationFromToolExecution(toolName, args, result) {
|
|
7646
|
+
return {
|
|
7647
|
+
toolName,
|
|
7648
|
+
arguments: args,
|
|
7649
|
+
isError: isToolErrorResult(result),
|
|
7650
|
+
errorCode: toolErrorCodeOf(result),
|
|
7651
|
+
errorText: toolErrorTextOf(result),
|
|
7652
|
+
resultText: toolResultTextOf(result)
|
|
7653
|
+
};
|
|
7654
|
+
}
|
|
7655
|
+
function isPollingObservation(toolName, args) {
|
|
7656
|
+
if (!POLLING_TOOL_NAMES.includes(toolName)) return false;
|
|
7657
|
+
return (isPlainRecord$2(args) ? args : void 0)?.["wait"] !== true;
|
|
7658
|
+
}
|
|
7659
|
+
/**
|
|
7660
|
+
* 造一台单会话工具级失控守卫。
|
|
7661
|
+
*
|
|
7662
|
+
* 三种可提醒信号(顺序即提醒优先级):
|
|
7663
|
+
* 1. `same_error_family` —— 同一个工具连续报同一族错误;
|
|
7664
|
+
* 2. `exact_action_repeat` —— 同一次动作(同名 + 同参数)立刻重复;
|
|
7665
|
+
* 3. `polling_repeat` —— 连续轮询同一个后台任务而输出没变。
|
|
7666
|
+
*/
|
|
7667
|
+
function createToolRunawayGuard(options = {}) {
|
|
7668
|
+
const threshold = options.remindAfterOccurrences ?? 3;
|
|
7669
|
+
const exactActionRepeats = createExactRepeatTracker();
|
|
7670
|
+
const errorStreaks = /* @__PURE__ */ new Map();
|
|
7671
|
+
const pollingStreaks = /* @__PURE__ */ new Map();
|
|
7672
|
+
const recentActions = [];
|
|
7673
|
+
let activeAbabKey;
|
|
7674
|
+
let reminderAttempted = false;
|
|
7675
|
+
const signals = [];
|
|
7676
|
+
const record = (kind, occurrences, toolName) => {
|
|
7677
|
+
signals.push({
|
|
7678
|
+
kind,
|
|
7679
|
+
occurrences,
|
|
7680
|
+
toolName
|
|
7681
|
+
});
|
|
7682
|
+
};
|
|
7683
|
+
return {
|
|
7684
|
+
observe(observation) {
|
|
7685
|
+
const toolName = observation.toolName;
|
|
7686
|
+
const actionKey = canonicalToolCallKey(toolName, observation.arguments);
|
|
7687
|
+
const countsAsAction = !POLLING_TOOL_NAMES.includes(toolName);
|
|
7688
|
+
if (countsAsAction) {
|
|
7689
|
+
const action = exactActionRepeats.observe(toolName, observation.arguments);
|
|
7690
|
+
record("exact_action_repeat", action.count, toolName);
|
|
7691
|
+
}
|
|
7692
|
+
if (countsAsAction) {
|
|
7693
|
+
recentActions.push(actionKey);
|
|
7694
|
+
if (recentActions.length > 4) recentActions.shift();
|
|
7695
|
+
if (recentActions.length === 4) {
|
|
7696
|
+
const [a, b, c, d] = recentActions;
|
|
7697
|
+
if (a !== void 0 && b !== void 0 && a !== b && a === c && b === d) {
|
|
7698
|
+
const episode = `${a}\u0000${b}`;
|
|
7699
|
+
if (activeAbabKey !== episode) {
|
|
7700
|
+
activeAbabKey = episode;
|
|
7701
|
+
record("abab_action_cycle", 2, toolName);
|
|
7702
|
+
}
|
|
7703
|
+
} else activeAbabKey = void 0;
|
|
7704
|
+
}
|
|
7705
|
+
}
|
|
7706
|
+
if (observation.isError === true) {
|
|
7707
|
+
const key = `${toolName}\u0000${observation.errorCode ?? normalizeToolErrorFamily(observation.errorText)}`;
|
|
7708
|
+
const previous = errorStreaks.get(key);
|
|
7709
|
+
const count = previous === void 0 ? 1 : previous.count + 1;
|
|
7710
|
+
errorStreaks.set(key, {
|
|
7711
|
+
toolName,
|
|
7712
|
+
count
|
|
7713
|
+
});
|
|
7714
|
+
record("same_error_family", count, toolName);
|
|
7715
|
+
} else for (const [key, entry] of [...errorStreaks]) if (entry.toolName === toolName) errorStreaks.delete(key);
|
|
7716
|
+
if (isPollingObservation(toolName, observation.arguments)) {
|
|
7717
|
+
const key = `${canonicalToolCallKey(toolName, observation.arguments)}\u0000${observation.resultText ?? ""}`;
|
|
7718
|
+
const previous = pollingStreaks.get(toolName);
|
|
7719
|
+
const count = previous !== void 0 && previous.key === key ? previous.count + 1 : 1;
|
|
7720
|
+
pollingStreaks.set(toolName, {
|
|
7721
|
+
key,
|
|
7722
|
+
count
|
|
7723
|
+
});
|
|
7724
|
+
record("polling_repeat", count, toolName);
|
|
7725
|
+
} else pollingStreaks.delete(toolName);
|
|
7726
|
+
if (reminderAttempted) return void 0;
|
|
7727
|
+
const errorCandidate = [...errorStreaks.values()].find((entry) => entry.count >= threshold);
|
|
7728
|
+
if (errorCandidate !== void 0) {
|
|
7729
|
+
reminderAttempted = true;
|
|
7730
|
+
return {
|
|
7731
|
+
kind: "same_error_family",
|
|
7732
|
+
occurrences: errorCandidate.count,
|
|
7733
|
+
text: renderSameErrorFamilyReminder(errorCandidate.count)
|
|
7734
|
+
};
|
|
7735
|
+
}
|
|
7736
|
+
const actionStreak = exactActionRepeats.current();
|
|
7737
|
+
if (countsAsAction && actionStreak !== void 0 && actionStreak.count >= threshold) {
|
|
7738
|
+
reminderAttempted = true;
|
|
7739
|
+
return {
|
|
7740
|
+
kind: "exact_action_repeat",
|
|
7741
|
+
occurrences: actionStreak.count,
|
|
7742
|
+
text: renderExactActionRepeatReminder(actionStreak.count)
|
|
7743
|
+
};
|
|
7744
|
+
}
|
|
7745
|
+
const pollingCandidate = [...pollingStreaks.values()].find((entry) => entry.count >= threshold);
|
|
7746
|
+
if (pollingCandidate !== void 0) {
|
|
7747
|
+
reminderAttempted = true;
|
|
7748
|
+
return {
|
|
7749
|
+
kind: "polling_repeat",
|
|
7750
|
+
occurrences: pollingCandidate.count,
|
|
7751
|
+
text: renderPollingRepeatReminder(pollingCandidate.count)
|
|
7752
|
+
};
|
|
7753
|
+
}
|
|
7754
|
+
},
|
|
7755
|
+
reset() {
|
|
7756
|
+
exactActionRepeats.reset();
|
|
7757
|
+
errorStreaks.clear();
|
|
7758
|
+
pollingStreaks.clear();
|
|
7759
|
+
recentActions.length = 0;
|
|
7760
|
+
activeAbabKey = void 0;
|
|
7761
|
+
reminderAttempted = false;
|
|
7762
|
+
},
|
|
7763
|
+
get signals() {
|
|
7764
|
+
return signals;
|
|
7765
|
+
}
|
|
7766
|
+
};
|
|
7767
|
+
}
|
|
7578
7768
|
/**
|
|
7579
|
-
* Exact-repeat
|
|
7580
|
-
*
|
|
7769
|
+
* Exact-repeat + deterministic zero-progress (same error family / unchanged polling)
|
|
7770
|
+
* state machine shared by provider profiles. A missing forceStopAt gives reminders only;
|
|
7771
|
+
* no provider inherits Kimi's hard stop accidentally.
|
|
7581
7772
|
*/
|
|
7582
7773
|
function createExactRepeatBreaker(options) {
|
|
7583
7774
|
const sessions = /* @__PURE__ */ new Map();
|
|
7584
7775
|
const maxSessions = options.maxSessions ?? 256;
|
|
7585
7776
|
const exempt = new Set(options.exemptTools ?? TOOL_RUNAWAY_EXEMPT_TOOLS);
|
|
7777
|
+
const errorAndPollingThreshold = options.errorAndPollingThreshold ?? 3;
|
|
7586
7778
|
const stateOf = (sessionId) => {
|
|
7587
7779
|
let state = sessions.get(sessionId);
|
|
7588
7780
|
if (state === void 0) state = {
|
|
7589
7781
|
tracker: createExactRepeatTracker(),
|
|
7590
7782
|
count: 0,
|
|
7591
|
-
handoffActive: false
|
|
7783
|
+
handoffActive: false,
|
|
7784
|
+
errorStreaks: /* @__PURE__ */ new Map(),
|
|
7785
|
+
pollingStreaks: /* @__PURE__ */ new Map()
|
|
7592
7786
|
};
|
|
7593
7787
|
sessions.delete(sessionId);
|
|
7594
7788
|
sessions.set(sessionId, state);
|
|
@@ -7598,11 +7792,26 @@ function createExactRepeatBreaker(options) {
|
|
|
7598
7792
|
}
|
|
7599
7793
|
return state;
|
|
7600
7794
|
};
|
|
7795
|
+
const updateErrorStreaks = (state, toolName, observation) => {
|
|
7796
|
+
if (observation.isError === true) {
|
|
7797
|
+
const key = `${toolName}\u0000${observation.errorCode ?? normalizeToolErrorFamily(observation.errorText)}`;
|
|
7798
|
+
const previous = state.errorStreaks.get(key);
|
|
7799
|
+
const count = previous === void 0 ? 1 : previous.count + 1;
|
|
7800
|
+
state.errorStreaks.set(key, {
|
|
7801
|
+
toolName,
|
|
7802
|
+
count
|
|
7803
|
+
});
|
|
7804
|
+
return count;
|
|
7805
|
+
}
|
|
7806
|
+
for (const [key, entry] of [...state.errorStreaks]) if (entry.toolName === toolName) state.errorStreaks.delete(key);
|
|
7807
|
+
return 0;
|
|
7808
|
+
};
|
|
7601
7809
|
return {
|
|
7602
7810
|
checkBeforeExecute(sessionId, toolName, args) {
|
|
7603
7811
|
if (options.forceStopAt === void 0) return void 0;
|
|
7604
7812
|
const state = stateOf(sessionId);
|
|
7605
7813
|
if (state.handoffActive) return options.handoffVeto ?? options.handoffReminder;
|
|
7814
|
+
if (POLLING_TOOL_NAMES.includes(toolName)) return void 0;
|
|
7606
7815
|
const key = canonicalToolCallKey(toolName, args);
|
|
7607
7816
|
if (state.tracker.current()?.key === key && state.count + 1 >= options.forceStopAt) {
|
|
7608
7817
|
state.count += 1;
|
|
@@ -7610,16 +7819,37 @@ function createExactRepeatBreaker(options) {
|
|
|
7610
7819
|
return options.handoffVeto ?? options.handoffReminder;
|
|
7611
7820
|
}
|
|
7612
7821
|
},
|
|
7613
|
-
recordAfterExecute(sessionId, toolName, args) {
|
|
7822
|
+
recordAfterExecute(sessionId, toolName, args, observation) {
|
|
7614
7823
|
if (exempt.has(toolName)) return void 0;
|
|
7615
7824
|
const state = stateOf(sessionId);
|
|
7616
7825
|
if (state.handoffActive) return options.handoffReminder ?? options.reminder(state.count);
|
|
7826
|
+
if (POLLING_TOOL_NAMES.includes(toolName) && observation !== void 0) {
|
|
7827
|
+
const errorCount = updateErrorStreaks(state, toolName, observation);
|
|
7828
|
+
const isPolling = isPollingObservation(toolName, args);
|
|
7829
|
+
let pollCount = 0;
|
|
7830
|
+
if (isPolling) {
|
|
7831
|
+
const key = `${canonicalToolCallKey(toolName, args)}\u0000${observation.resultText ?? ""}`;
|
|
7832
|
+
const previous = state.pollingStreaks.get(toolName);
|
|
7833
|
+
pollCount = previous !== void 0 && previous.key === key ? previous.count + 1 : 1;
|
|
7834
|
+
state.pollingStreaks.set(toolName, {
|
|
7835
|
+
key,
|
|
7836
|
+
count: pollCount
|
|
7837
|
+
});
|
|
7838
|
+
} else state.pollingStreaks.delete(toolName);
|
|
7839
|
+
if (observation.isError === true && errorCount >= errorAndPollingThreshold) return renderSameErrorFamilyReminder(errorCount);
|
|
7840
|
+
if (isPolling && pollCount >= errorAndPollingThreshold) return renderPollingRepeatReminder(pollCount);
|
|
7841
|
+
return;
|
|
7842
|
+
}
|
|
7843
|
+
if (!POLLING_TOOL_NAMES.includes(toolName)) state.pollingStreaks.clear();
|
|
7617
7844
|
state.count = state.tracker.observe(toolName, args).count;
|
|
7618
7845
|
if (options.forceStopAt !== void 0 && state.count >= options.forceStopAt) {
|
|
7619
7846
|
state.handoffActive = true;
|
|
7620
7847
|
return options.handoffReminder ?? options.reminder(state.count);
|
|
7621
7848
|
}
|
|
7622
|
-
|
|
7849
|
+
const errorCount = observation !== void 0 ? updateErrorStreaks(state, toolName, observation) : 0;
|
|
7850
|
+
const exactReminder = options.reminder(state.count);
|
|
7851
|
+
if (exactReminder !== void 0) return exactReminder;
|
|
7852
|
+
if (errorCount >= errorAndPollingThreshold) return renderSameErrorFamilyReminder(errorCount);
|
|
7623
7853
|
},
|
|
7624
7854
|
resetSession(sessionId) {
|
|
7625
7855
|
sessions.delete(sessionId);
|
|
@@ -10195,7 +10425,7 @@ var ResponsesClient = class {
|
|
|
10195
10425
|
release = opened.release;
|
|
10196
10426
|
break;
|
|
10197
10427
|
} catch (error) {
|
|
10198
|
-
if (error instanceof LlmError && (error.code === "NOT_FOUND" || error.status === 404)) {
|
|
10428
|
+
if (error instanceof LlmError$1 && (error.code === "NOT_FOUND" || error.status === 404)) {
|
|
10199
10429
|
const fallback = resolveCodexFallbackModel(currentModel);
|
|
10200
10430
|
if (fallback && fallback.id !== currentModel) {
|
|
10201
10431
|
currentModel = fallback.id;
|
|
@@ -10321,7 +10551,7 @@ var ResponsesClient = class {
|
|
|
10321
10551
|
await pool.markAuthFailed(account.id, error instanceof Error ? error.message : "ChatGPT sign-in expired.").catch(() => void 0);
|
|
10322
10552
|
free();
|
|
10323
10553
|
if (await pool.hasAnotherAvailableAccount(tried)) continue;
|
|
10324
|
-
throw new LlmError("ChatGPT sign-in has expired. Sign in again.", "AUTH", {
|
|
10554
|
+
throw new LlmError$1("ChatGPT sign-in has expired. Sign in again.", "AUTH", {
|
|
10325
10555
|
status: 401,
|
|
10326
10556
|
cause: error
|
|
10327
10557
|
});
|
|
@@ -10333,7 +10563,7 @@ var ResponsesClient = class {
|
|
|
10333
10563
|
await pool.markCooldown(account.id, after ?? DEFAULT_POOL_COOLDOWN_MS, "Codex 429").catch(() => void 0);
|
|
10334
10564
|
free();
|
|
10335
10565
|
if (await pool.hasAnotherAvailableAccount(tried)) continue;
|
|
10336
|
-
throw new LlmError("Codex rate limit reached.", "RATE_LIMIT", {
|
|
10566
|
+
throw new LlmError$1("Codex rate limit reached.", "RATE_LIMIT", {
|
|
10337
10567
|
status: 429,
|
|
10338
10568
|
...after === void 0 ? {} : { providerRetryAfterMs: after }
|
|
10339
10569
|
});
|
|
@@ -10382,7 +10612,7 @@ var ResponsesClient = class {
|
|
|
10382
10612
|
continue;
|
|
10383
10613
|
}
|
|
10384
10614
|
const chain = errorChain(cause).trim();
|
|
10385
|
-
throw new LlmError(`Codex request failed: ${chain === "" ? "the connection failed before any response arrived" : chain.slice(0, 500)}${isPreConnectionFailure$2(cause) ? " The request never reached ChatGPT. Check the network, proxy/VPN/TUN, or the plugin proxy settings." : ""}`, "NETWORK", { cause });
|
|
10615
|
+
throw new LlmError$1(`Codex request failed: ${chain === "" ? "the connection failed before any response arrived" : chain.slice(0, 500)}${isPreConnectionFailure$2(cause) ? " The request never reached ChatGPT. Check the network, proxy/VPN/TUN, or the plugin proxy settings." : ""}`, "NETWORK", { cause });
|
|
10386
10616
|
}
|
|
10387
10617
|
}
|
|
10388
10618
|
};
|
|
@@ -10428,10 +10658,10 @@ function isPreConnectionFailure$2(error) {
|
|
|
10428
10658
|
* so retrying can neither repeat committed output nor re-run a tool.
|
|
10429
10659
|
*/
|
|
10430
10660
|
function streamFailure$2(error, signal) {
|
|
10431
|
-
if (error instanceof LlmError) return error;
|
|
10432
|
-
if (signal?.aborted) return new LlmError("Codex request aborted", "ABORTED", { cause: error });
|
|
10661
|
+
if (error instanceof LlmError$1) return error;
|
|
10662
|
+
if (signal?.aborted) return new LlmError$1("Codex request aborted", "ABORTED", { cause: error });
|
|
10433
10663
|
const chain = errorChain(error).trim();
|
|
10434
|
-
return new LlmError(`Codex stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
10664
|
+
return new LlmError$1(`Codex stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
10435
10665
|
}
|
|
10436
10666
|
/**
|
|
10437
10667
|
* Prompt cache key for one conversation.
|
|
@@ -10455,7 +10685,7 @@ function perRequestNonce() {
|
|
|
10455
10685
|
return requestCounter;
|
|
10456
10686
|
}
|
|
10457
10687
|
async function* parseResponsesStream(response, signal, _legacyHiddenSandboxControls = /* @__PURE__ */ new Set(), activity) {
|
|
10458
|
-
if (response.body === null) throw new LlmError("Codex returned no response stream.", "PROVIDER_ERROR");
|
|
10688
|
+
if (response.body === null) throw new LlmError$1("Codex returned no response stream.", "PROVIDER_ERROR");
|
|
10459
10689
|
const reader = response.body.getReader();
|
|
10460
10690
|
const abortReader = () => {
|
|
10461
10691
|
reader.cancel(signal?.reason).catch(() => void 0);
|
|
@@ -10651,7 +10881,7 @@ async function* parseResponsesStream(response, signal, _legacyHiddenSandboxContr
|
|
|
10651
10881
|
const message = string(error?.message) ?? "Codex generation failed.";
|
|
10652
10882
|
const rawCode = string(error?.code)?.toLowerCase();
|
|
10653
10883
|
const isOverload = message.toLowerCase().includes("overload") || message.toLowerCase().includes("server error") || rawCode === "server_error" || rawCode === "service_unavailable" || rawCode === "internal_error";
|
|
10654
|
-
throw new LlmError(message, message.toLowerCase().includes("rate limit") || rawCode === "rate_limit" ? "RATE_LIMIT" : isOverload ? "SERVER_ERROR" : isContextOverflow(error) ? CONTEXT_OVERFLOW_CODE : string(error?.code)?.toUpperCase() ?? "PROVIDER_ERROR");
|
|
10884
|
+
throw new LlmError$1(message, message.toLowerCase().includes("rate limit") || rawCode === "rate_limit" ? "RATE_LIMIT" : isOverload ? "SERVER_ERROR" : isContextOverflow(error) ? CONTEXT_OVERFLOW_CODE : string(error?.code)?.toUpperCase() ?? "PROVIDER_ERROR");
|
|
10655
10885
|
}
|
|
10656
10886
|
};
|
|
10657
10887
|
try {
|
|
@@ -10671,7 +10901,7 @@ async function* parseResponsesStream(response, signal, _legacyHiddenSandboxContr
|
|
|
10671
10901
|
try {
|
|
10672
10902
|
event = JSON.parse(data);
|
|
10673
10903
|
} catch {
|
|
10674
|
-
throw new LlmError("Codex returned malformed streaming JSON.", "PROTOCOL_ERROR");
|
|
10904
|
+
throw new LlmError$1("Codex returned malformed streaming JSON.", "PROTOCOL_ERROR");
|
|
10675
10905
|
}
|
|
10676
10906
|
const valueRecord = record$3(event);
|
|
10677
10907
|
if (valueRecord !== null) yield* consume(valueRecord);
|
|
@@ -10682,7 +10912,7 @@ async function* parseResponsesStream(response, signal, _legacyHiddenSandboxContr
|
|
|
10682
10912
|
reader.releaseLock();
|
|
10683
10913
|
}
|
|
10684
10914
|
if (signal?.aborted) throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
10685
|
-
if (terminal === null) throw new LlmError("Codex stream ended before a terminal event.", "PROTOCOL_ERROR");
|
|
10915
|
+
if (terminal === null) throw new LlmError$1("Codex stream ended before a terminal event.", "PROTOCOL_ERROR");
|
|
10686
10916
|
const finalReason = terminal;
|
|
10687
10917
|
if (reasoningIndex !== null) {
|
|
10688
10918
|
if (pendingReasoningDelta !== "") {
|
|
@@ -10718,7 +10948,7 @@ async function* parseResponsesStream(response, signal, _legacyHiddenSandboxContr
|
|
|
10718
10948
|
const replayedToolCallIds = new Set(replayOutput.flatMap((item) => item.type === "function_call" && typeof item.call_id === "string" ? [item.call_id] : []));
|
|
10719
10949
|
for (const tool of tools.values()) {
|
|
10720
10950
|
if (!tool.started) continue;
|
|
10721
|
-
if (!isSafeJsonArguments(tool.arguments) || tool.name === "") throw new LlmError(`Codex returned invalid JSON arguments for tool ${tool.name || "(unnamed)"}.`, "INVALID_TOOL_ARGUMENTS");
|
|
10951
|
+
if (!isSafeJsonArguments(tool.arguments) || tool.name === "") throw new LlmError$1(`Codex returned invalid JSON arguments for tool ${tool.name || "(unnamed)"}.`, "INVALID_TOOL_ARGUMENTS");
|
|
10722
10952
|
validToolCount++;
|
|
10723
10953
|
if (!replayedToolCallIds.has(tool.id)) {
|
|
10724
10954
|
replayOutput.push({
|
|
@@ -10775,7 +11005,7 @@ function incompleteFinishReason(response) {
|
|
|
10775
11005
|
if (reason === "steered") return { kind: "stop" };
|
|
10776
11006
|
const detail = JSON.stringify(reason);
|
|
10777
11007
|
const message = string(record$3(response?.error)?.message);
|
|
10778
|
-
throw new LlmError(`Codex returned an incomplete response (${detail})${message ? `: ${message}` : "."}`, reason === "content_filter" ? "CONTENT_FILTER" : "PROVIDER_INCOMPLETE");
|
|
11008
|
+
throw new LlmError$1(`Codex returned an incomplete response (${detail})${message ? `: ${message}` : "."}`, reason === "content_filter" ? "CONTENT_FILTER" : "PROVIDER_INCOMPLETE");
|
|
10779
11009
|
}
|
|
10780
11010
|
function visibleReasoningDelta(delta, currentVisibleChars, alreadyTruncated) {
|
|
10781
11011
|
if (delta === "" || alreadyTruncated) return {
|
|
@@ -10837,12 +11067,12 @@ async function responseError(response) {
|
|
|
10837
11067
|
...requestId ? { requestId: ProviderRequestId(requestId) } : {},
|
|
10838
11068
|
...response.status === 429 ? { providerRetryAfterMs: retryAfterMs$1(response.headers) } : {}
|
|
10839
11069
|
};
|
|
10840
|
-
if (isHttpContextOverflow(response.status, detail)) return new LlmError(`Codex context window exceeded: ${detail}`, CONTEXT_OVERFLOW_CODE, options);
|
|
10841
|
-
if (response.status === 401) return new LlmError("ChatGPT sign-in has expired. Sign in again.", "AUTH", options);
|
|
10842
|
-
if (response.status === 404) return new LlmError(`Codex model or resource not found (${response.status})${detail ? `: ${detail}` : "."}`, "NOT_FOUND", options);
|
|
10843
|
-
if (response.status === 429) return new LlmError("Codex rate limit reached.", "RATE_LIMIT", options);
|
|
10844
|
-
if (response.status >= 500) return new LlmError(`Codex service error (${response.status}).`, "SERVER_ERROR", options);
|
|
10845
|
-
return new LlmError(`Codex request failed (${response.status})${detail ? `: ${detail}` : "."}`, "PROVIDER_ERROR", options);
|
|
11070
|
+
if (isHttpContextOverflow(response.status, detail)) return new LlmError$1(`Codex context window exceeded: ${detail}`, CONTEXT_OVERFLOW_CODE, options);
|
|
11071
|
+
if (response.status === 401) return new LlmError$1("ChatGPT sign-in has expired. Sign in again.", "AUTH", options);
|
|
11072
|
+
if (response.status === 404) return new LlmError$1(`Codex model or resource not found (${response.status})${detail ? `: ${detail}` : "."}`, "NOT_FOUND", options);
|
|
11073
|
+
if (response.status === 429) return new LlmError$1("Codex rate limit reached.", "RATE_LIMIT", options);
|
|
11074
|
+
if (response.status >= 500) return new LlmError$1(`Codex service error (${response.status}).`, "SERVER_ERROR", options);
|
|
11075
|
+
return new LlmError$1(`Codex request failed (${response.status})${detail ? `: ${detail}` : "."}`, "PROVIDER_ERROR", options);
|
|
10846
11076
|
}
|
|
10847
11077
|
/**
|
|
10848
11078
|
* Concatenated assistant text a non-delta `message` output item carries, which
|
|
@@ -19624,7 +19854,7 @@ function reclassifyInBandError(thrown, rawError, classify, statusFor = inBandAnt
|
|
|
19624
19854
|
if (status === null) return thrown;
|
|
19625
19855
|
const failure = classify(status, JSON.stringify({ error: rawError }));
|
|
19626
19856
|
if (!failure.retryable) return thrown;
|
|
19627
|
-
return new LlmError(thrown.message, failure.code, { cause: thrown });
|
|
19857
|
+
return new LlmError$1(thrown.message, failure.code, { cause: thrown });
|
|
19628
19858
|
}
|
|
19629
19859
|
/**
|
|
19630
19860
|
* {@link reclassifyInBandError} for a line whose classifier reads a status, fed
|
|
@@ -19647,7 +19877,7 @@ function reclassifyInBandResponsesError(thrown, rawError, message, classify) {
|
|
|
19647
19877
|
message
|
|
19648
19878
|
}));
|
|
19649
19879
|
if (!failure.retryable) return thrown;
|
|
19650
|
-
return new LlmError(thrown.message, failure.code, { cause: thrown });
|
|
19880
|
+
return new LlmError$1(thrown.message, failure.code, { cause: thrown });
|
|
19651
19881
|
}
|
|
19652
19882
|
/** The wire `error` object of an in-band event, read defensively. */
|
|
19653
19883
|
function readErrorType(error) {
|
|
@@ -20067,7 +20297,7 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
20067
20297
|
}));
|
|
20068
20298
|
}
|
|
20069
20299
|
async resolveModel(provider, modelId, signal) {
|
|
20070
|
-
if (signal?.aborted) throw new LlmError("Command Code model resolution aborted", "ABORTED");
|
|
20300
|
+
if (signal?.aborted) throw new LlmError$1("Command Code model resolution aborted", "ABORTED");
|
|
20071
20301
|
const settings = await this.settings();
|
|
20072
20302
|
const entry = (await this.catalog()).find((model) => model.id === modelId);
|
|
20073
20303
|
const efforts = reasoningEffortsFor$1(modelId);
|
|
@@ -20136,7 +20366,7 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
20136
20366
|
let apiEnv;
|
|
20137
20367
|
if (pool === null) {
|
|
20138
20368
|
const credentials = await this.store.read();
|
|
20139
|
-
if (credentials === null) throw new LlmError(`Not signed in to ${PROVIDER_NAME$11}. Sign in from Settings > Command Code, or paste an API key there.`, "MISSING_CREDENTIAL");
|
|
20369
|
+
if (credentials === null) throw new LlmError$1(`Not signed in to ${PROVIDER_NAME$11}. Sign in from Settings > Command Code, or paste an API key there.`, "MISSING_CREDENTIAL");
|
|
20140
20370
|
apiKey = credentials.apiKey;
|
|
20141
20371
|
apiEnv = credentials.apiEnv ?? resolveApiEnv();
|
|
20142
20372
|
} else {
|
|
@@ -20166,13 +20396,13 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
20166
20396
|
});
|
|
20167
20397
|
activity?.pulse();
|
|
20168
20398
|
} catch (error) {
|
|
20169
|
-
if (signal.aborted) throw new LlmError("Command Code request aborted", "ABORTED", { cause: error });
|
|
20170
|
-
throw new LlmError(`Command Code request failed: ${error instanceof Error ? error.message : String(error)}`, "TRANSPORT", { cause: error });
|
|
20399
|
+
if (signal.aborted) throw new LlmError$1("Command Code request aborted", "ABORTED", { cause: error });
|
|
20400
|
+
throw new LlmError$1(`Command Code request failed: ${error instanceof Error ? error.message : String(error)}`, "TRANSPORT", { cause: error });
|
|
20171
20401
|
}
|
|
20172
20402
|
if (response.ok) break;
|
|
20173
20403
|
detail = (await response.text().catch(() => "")).slice(0, 600);
|
|
20174
20404
|
if (response.status === 422) {
|
|
20175
|
-
if (detail.includes("cmd_zdr_no_providers")) throw new LlmError(`${PROVIDER_NAME$11} rejected request under Zero Data Retention: no ZDR-capable upstream is available for this model (${detail || "cmd_zdr_no_providers"}).`, "PROVIDER_ERROR", { status: 422 });
|
|
20405
|
+
if (detail.includes("cmd_zdr_no_providers")) throw new LlmError$1(`${PROVIDER_NAME$11} rejected request under Zero Data Retention: no ZDR-capable upstream is available for this model (${detail || "cmd_zdr_no_providers"}).`, "PROVIDER_ERROR", { status: 422 });
|
|
20176
20406
|
break;
|
|
20177
20407
|
}
|
|
20178
20408
|
if (pool === null || accountId === void 0) break;
|
|
@@ -20194,22 +20424,22 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
20194
20424
|
const status = response?.status ?? 500;
|
|
20195
20425
|
const { code } = classifyCommandCodeFailure(status, detail);
|
|
20196
20426
|
if (status === 422) {
|
|
20197
|
-
if (detail.includes("cmd_zdr_no_providers")) throw new LlmError(`${PROVIDER_NAME$11} rejected request under Zero Data Retention: no ZDR-capable upstream is available for this model (${detail || "cmd_zdr_no_providers"}).`, code, { status: 422 });
|
|
20198
|
-
throw new LlmError(`${PROVIDER_NAME$11} validation error (422): ${detail || "Unprocessable Entity"}`, code, { status: 422 });
|
|
20427
|
+
if (detail.includes("cmd_zdr_no_providers")) throw new LlmError$1(`${PROVIDER_NAME$11} rejected request under Zero Data Retention: no ZDR-capable upstream is available for this model (${detail || "cmd_zdr_no_providers"}).`, code, { status: 422 });
|
|
20428
|
+
throw new LlmError$1(`${PROVIDER_NAME$11} validation error (422): ${detail || "Unprocessable Entity"}`, code, { status: 422 });
|
|
20199
20429
|
}
|
|
20200
|
-
if (isCommandCodeModelAccessDenied(status, detail)) throw new LlmError(`${PROVIDER_NAME$11} access denied for model ${options.model}: this model is not included in the plan or requires higher entitlement (${status}).${detail ? ` ${detail}` : ""}`, code, { status });
|
|
20201
|
-
if (isCommandCodeCredentialInvalid(status, detail) || status === 401) throw new LlmError(`${PROVIDER_NAME$11} rejected the stored API key (${status}). Sign in again from Settings > Command Code.${detail ? ` ${detail}` : ""}`, code, { status });
|
|
20430
|
+
if (isCommandCodeModelAccessDenied(status, detail)) throw new LlmError$1(`${PROVIDER_NAME$11} access denied for model ${options.model}: this model is not included in the plan or requires higher entitlement (${status}).${detail ? ` ${detail}` : ""}`, code, { status });
|
|
20431
|
+
if (isCommandCodeCredentialInvalid(status, detail) || status === 401) throw new LlmError$1(`${PROVIDER_NAME$11} rejected the stored API key (${status}). Sign in again from Settings > Command Code.${detail ? ` ${detail}` : ""}`, code, { status });
|
|
20202
20432
|
if (status === 429) {
|
|
20203
20433
|
const after = response === void 0 ? void 0 : retryAfterMs$1(response.headers);
|
|
20204
|
-
throw new LlmError(`${PROVIDER_NAME$11} rate limit or plan quota reached (429). Check the quota card in Settings > Command Code.${detail ? ` ${detail}` : ""}`, code, {
|
|
20434
|
+
throw new LlmError$1(`${PROVIDER_NAME$11} rate limit or plan quota reached (429). Check the quota card in Settings > Command Code.${detail ? ` ${detail}` : ""}`, code, {
|
|
20205
20435
|
status: 429,
|
|
20206
20436
|
...after === void 0 ? {} : { providerRetryAfterMs: after }
|
|
20207
20437
|
});
|
|
20208
20438
|
}
|
|
20209
|
-
if (status >= 500) throw new LlmError(`${PROVIDER_NAME$11} upstream server error (${status}): ${detail || "No response"}`, code, { status });
|
|
20210
|
-
throw new LlmError(`${PROVIDER_NAME$11} API error (${status}): ${detail || "No response"}`, code, { status });
|
|
20439
|
+
if (status >= 500) throw new LlmError$1(`${PROVIDER_NAME$11} upstream server error (${status}): ${detail || "No response"}`, code, { status });
|
|
20440
|
+
throw new LlmError$1(`${PROVIDER_NAME$11} API error (${status}): ${detail || "No response"}`, code, { status });
|
|
20211
20441
|
}
|
|
20212
|
-
if (response.body === null) throw new LlmError("Command Code returned an empty response body", "PROVIDER_ERROR");
|
|
20442
|
+
if (response.body === null) throw new LlmError$1("Command Code returned an empty response body", "PROVIDER_ERROR");
|
|
20213
20443
|
const reader = response.body.getReader();
|
|
20214
20444
|
const decoder = new TextDecoder();
|
|
20215
20445
|
const state = createStreamState$7(wire);
|
|
@@ -20255,7 +20485,7 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
20255
20485
|
}
|
|
20256
20486
|
} catch (error) {
|
|
20257
20487
|
const inBand = state.streamError;
|
|
20258
|
-
if (error instanceof LlmError && !outputStarted && inBand !== void 0 && error.code === "PROVIDER_ERROR") {
|
|
20488
|
+
if (error instanceof LlmError$1 && !outputStarted && inBand !== void 0 && error.code === "PROVIDER_ERROR") {
|
|
20259
20489
|
const reclassified = reclassifyInBandStreamError(error, inBand);
|
|
20260
20490
|
if (reclassified.code === "RATE_LIMIT" && pool !== null && accountId !== void 0) {
|
|
20261
20491
|
const after = retryAfterMs$1(response.headers);
|
|
@@ -20277,10 +20507,10 @@ var CommandCodeAdapter = class extends LlmAdapter {
|
|
|
20277
20507
|
* body-read failure as TRANSPORT and retain its cause chain in the message.
|
|
20278
20508
|
*/
|
|
20279
20509
|
function streamFailure$1(error, signal) {
|
|
20280
|
-
if (error instanceof LlmError) return error;
|
|
20281
|
-
if (signal.aborted) return new LlmError("Command Code stream aborted", "ABORTED", { cause: error });
|
|
20510
|
+
if (error instanceof LlmError$1) return error;
|
|
20511
|
+
if (signal.aborted) return new LlmError$1("Command Code stream aborted", "ABORTED", { cause: error });
|
|
20282
20512
|
const chain = errorChain(error).trim();
|
|
20283
|
-
return new LlmError(`Command Code stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
20513
|
+
return new LlmError$1(`Command Code stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
20284
20514
|
}
|
|
20285
20515
|
/**
|
|
20286
20516
|
* The error one recorded in-band failure becomes, or the mapper's own verdict.
|
|
@@ -22787,7 +23017,7 @@ var OllamaAdapter = class extends LlmAdapter {
|
|
|
22787
23017
|
}));
|
|
22788
23018
|
}
|
|
22789
23019
|
async resolveModel(provider, modelId, signal) {
|
|
22790
|
-
if (signal?.aborted) throw new LlmError("Ollama model resolution aborted", "ABORTED");
|
|
23020
|
+
if (signal?.aborted) throw new LlmError$1("Ollama model resolution aborted", "ABORTED");
|
|
22791
23021
|
const settings = await this.settings();
|
|
22792
23022
|
const entry = (await this.catalog()).find((model) => model.id === modelId);
|
|
22793
23023
|
const declared = signal?.aborted ? void 0 : await this.thinkingCapability(modelId);
|
|
@@ -22855,7 +23085,7 @@ var OllamaAdapter = class extends LlmAdapter {
|
|
|
22855
23085
|
let credentials;
|
|
22856
23086
|
if (pool === null) {
|
|
22857
23087
|
const stored = await this.store.read();
|
|
22858
|
-
if (stored === null) throw new LlmError(`No ${PROVIDER_NAME$10} API key configured. Add one from Settings > ${PROVIDER_NAME$10} (create a key at https://ollama.com/settings/keys).`, "MISSING_CREDENTIAL");
|
|
23088
|
+
if (stored === null) throw new LlmError$1(`No ${PROVIDER_NAME$10} API key configured. Add one from Settings > ${PROVIDER_NAME$10} (create a key at https://ollama.com/settings/keys).`, "MISSING_CREDENTIAL");
|
|
22859
23089
|
credentials = stored;
|
|
22860
23090
|
} else {
|
|
22861
23091
|
const effective = await pool.getEffectiveCredential(tried, fetchFn);
|
|
@@ -22916,9 +23146,9 @@ var OllamaAdapter = class extends LlmAdapter {
|
|
|
22916
23146
|
break;
|
|
22917
23147
|
}
|
|
22918
23148
|
const status = lastStatus;
|
|
22919
|
-
if (status === 401 || status === 403) throw new LlmError(`${PROVIDER_NAME$10} rejected the API key (${status}). Replace it from Settings > ${PROVIDER_NAME$10}.${lastDetail ? ` ${lastDetail}` : ""}`, "INVALID_CREDENTIAL", { status });
|
|
22920
|
-
if (status === 429) throw new LlmError(`${PROVIDER_NAME$10} rate limit or plan quota reached (429). Add another key, or wait for the cooldown shown in Settings > ${PROVIDER_NAME$10}.${lastDetail ? ` ${lastDetail}` : ""}`, "RATE_LIMIT", { status: 429 });
|
|
22921
|
-
throw new LlmError(`${PROVIDER_NAME$10} request failed${status === void 0 ? "" : ` (${status})`}.${lastDetail}`, lastInBandCode ?? (status !== void 0 && status >= 500 ? "SERVER" : "INVALID_REQUEST"), status === void 0 ? {} : { status });
|
|
23149
|
+
if (status === 401 || status === 403) throw new LlmError$1(`${PROVIDER_NAME$10} rejected the API key (${status}). Replace it from Settings > ${PROVIDER_NAME$10}.${lastDetail ? ` ${lastDetail}` : ""}`, "INVALID_CREDENTIAL", { status });
|
|
23150
|
+
if (status === 429) throw new LlmError$1(`${PROVIDER_NAME$10} rate limit or plan quota reached (429). Add another key, or wait for the cooldown shown in Settings > ${PROVIDER_NAME$10}.${lastDetail ? ` ${lastDetail}` : ""}`, "RATE_LIMIT", { status: 429 });
|
|
23151
|
+
throw new LlmError$1(`${PROVIDER_NAME$10} request failed${status === void 0 ? "" : ` (${status})`}.${lastDetail}`, lastInBandCode ?? (status !== void 0 && status >= 500 ? "SERVER" : "INVALID_REQUEST"), status === void 0 ? {} : { status });
|
|
22922
23152
|
}
|
|
22923
23153
|
};
|
|
22924
23154
|
/**
|
|
@@ -25051,7 +25281,7 @@ const ACP_ERROR_CODES = {
|
|
|
25051
25281
|
*/
|
|
25052
25282
|
function acpError(code, detail) {
|
|
25053
25283
|
const base = ACP_ERROR_CODES[code];
|
|
25054
|
-
return new LlmError(detail === void 0 ? base : `${base} ${detail}`, code);
|
|
25284
|
+
return new LlmError$1(detail === void 0 ? base : `${base} ${detail}`, code);
|
|
25055
25285
|
}
|
|
25056
25286
|
//#endregion
|
|
25057
25287
|
//#region src/host/antigravity-acp/history.ts
|
|
@@ -27955,7 +28185,25 @@ function countLines(text, escapedMode = usesEscapedNewlines(text)) {
|
|
|
27955
28185
|
return text.endsWith("\n") || escapedMode && text.endsWith("n") && isEscapedNewlineAt(text, text.length - 1) ? lines : lines + 1;
|
|
27956
28186
|
}
|
|
27957
28187
|
/**
|
|
27958
|
-
*
|
|
28188
|
+
* 向上查找某 UTF-8 字节偏移所在逻辑行的行首字节偏移。
|
|
28189
|
+
*
|
|
28190
|
+
* 与 {@link countLines} / {@link pageText} 保持一致:支持真实换行 `\n` 以及
|
|
28191
|
+
* 单行 JSON 里的转义换行 `\n`(前面紧邻奇数个 `\`)。
|
|
28192
|
+
*/
|
|
28193
|
+
function findLineStartByte(buffer, fromByte, escapedMode) {
|
|
28194
|
+
for (let cursor = fromByte - 1; cursor >= 0; cursor -= 1) {
|
|
28195
|
+
const byte = buffer[cursor];
|
|
28196
|
+
if (byte === 10) return cursor + 1;
|
|
28197
|
+
if (escapedMode && byte === 110) {
|
|
28198
|
+
let backslashes = 0;
|
|
28199
|
+
for (let probe = cursor - 1; probe >= 0 && buffer[probe] === 92; probe -= 1) backslashes += 1;
|
|
28200
|
+
if ((backslashes & 1) === 1) return cursor + 1;
|
|
28201
|
+
}
|
|
28202
|
+
}
|
|
28203
|
+
return 0;
|
|
28204
|
+
}
|
|
28205
|
+
/**
|
|
28206
|
+
* 按 UTF-8 字节安全分页(可选按字面量 `query` 定位首个匹配行)。
|
|
27959
28207
|
*
|
|
27960
28208
|
* `offset` 是字节偏移,必须落在字符边界上(上一页的 `nextOffset` 天然满足);
|
|
27961
28209
|
* 每页最多 `limit` 行且不超过 `maxBytes` 字节,任何一页都不会把一个字符切成两半。
|
|
@@ -27963,13 +28211,52 @@ function countLines(text, escapedMode = usesEscapedNewlines(text)) {
|
|
|
27963
28211
|
* 「两次翻页拼起来等于原文」是构造出来的性质,不是巧合。
|
|
27964
28212
|
*/
|
|
27965
28213
|
function pageText(args) {
|
|
27966
|
-
const { sessionId, refId, text, buffer, offset, limit, maxBytes } = args;
|
|
28214
|
+
const { sessionId, refId, text, buffer, offset, limit, maxBytes, query } = args;
|
|
27967
28215
|
const totalBytes = buffer.length;
|
|
27968
28216
|
if (!Number.isInteger(offset) || offset < 0) throw new CacheWarmupStoreError("offset must be a non-negative integer byte offset", "OFFSET_OUT_OF_RANGE");
|
|
27969
28217
|
if (offset > totalBytes) throw new CacheWarmupStoreError(`offset ${offset} is past the ${totalBytes}-byte result`, "OFFSET_OUT_OF_RANGE");
|
|
27970
28218
|
if (offset < totalBytes && (buffer[offset] & 192) === 128) throw new CacheWarmupStoreError("offset is not on a UTF-8 character boundary", "OFFSET_INVALID");
|
|
27971
28219
|
const escapedMode = usesEscapedNewlines(text);
|
|
27972
|
-
|
|
28220
|
+
let sliceOffset = offset;
|
|
28221
|
+
let matchMeta;
|
|
28222
|
+
if (query !== void 0) {
|
|
28223
|
+
const queryBytes = Buffer.from(query, "utf8");
|
|
28224
|
+
const hitByteOffset = offset === totalBytes ? -1 : buffer.indexOf(queryBytes, offset);
|
|
28225
|
+
if (hitByteOffset < 0) return {
|
|
28226
|
+
sessionId,
|
|
28227
|
+
refId,
|
|
28228
|
+
mode: "text",
|
|
28229
|
+
content: "",
|
|
28230
|
+
offset,
|
|
28231
|
+
nextOffset: null,
|
|
28232
|
+
complete: true,
|
|
28233
|
+
matched: false,
|
|
28234
|
+
omitted: {
|
|
28235
|
+
reason: "none",
|
|
28236
|
+
chars: 0,
|
|
28237
|
+
lines: 0,
|
|
28238
|
+
rows: 0,
|
|
28239
|
+
bytes: 0
|
|
28240
|
+
},
|
|
28241
|
+
totalChars: text.length,
|
|
28242
|
+
totalBytes,
|
|
28243
|
+
limit,
|
|
28244
|
+
maxBytes
|
|
28245
|
+
};
|
|
28246
|
+
const lineStartByte = findLineStartByte(buffer, hitByteOffset, escapedMode);
|
|
28247
|
+
const maxLeadBytes = maxBytes >= 8 ? Math.min(2048, Math.floor(maxBytes / 4)) : 0;
|
|
28248
|
+
sliceOffset = lineStartByte;
|
|
28249
|
+
if (hitByteOffset - lineStartByte > maxLeadBytes) {
|
|
28250
|
+
let pos = hitByteOffset - maxLeadBytes;
|
|
28251
|
+
while (pos < hitByteOffset && (buffer[pos] & 192) === 128) pos += 1;
|
|
28252
|
+
sliceOffset = pos;
|
|
28253
|
+
}
|
|
28254
|
+
matchMeta = {
|
|
28255
|
+
matched: true,
|
|
28256
|
+
matchOffset: hitByteOffset
|
|
28257
|
+
};
|
|
28258
|
+
}
|
|
28259
|
+
const rest = sliceOffset === 0 ? text : new TextDecoder("utf-8").decode(buffer.subarray(sliceOffset));
|
|
27973
28260
|
let content = "";
|
|
27974
28261
|
let contentBytes = 0;
|
|
27975
28262
|
let lines = 0;
|
|
@@ -27994,7 +28281,8 @@ function pageText(args) {
|
|
|
27994
28281
|
if (char === "\n") lines += 1;
|
|
27995
28282
|
else if (escapedMode && char === "n" && isEscapedNewlineAt(content, content.length - 1)) lines += 1;
|
|
27996
28283
|
}
|
|
27997
|
-
const
|
|
28284
|
+
const consumedBytes = Buffer.byteLength(content, "utf8");
|
|
28285
|
+
const nextOffset = sliceOffset + consumedBytes;
|
|
27998
28286
|
const complete = nextOffset >= totalBytes;
|
|
27999
28287
|
const remaining = rest.slice(content.length);
|
|
28000
28288
|
return {
|
|
@@ -28002,9 +28290,10 @@ function pageText(args) {
|
|
|
28002
28290
|
refId,
|
|
28003
28291
|
mode: "text",
|
|
28004
28292
|
content,
|
|
28005
|
-
offset,
|
|
28293
|
+
offset: sliceOffset,
|
|
28006
28294
|
nextOffset: complete ? null : nextOffset,
|
|
28007
28295
|
complete,
|
|
28296
|
+
...matchMeta ?? {},
|
|
28008
28297
|
omitted: {
|
|
28009
28298
|
reason: complete ? "none" : stoppedByBytes ? "bytes" : stoppedByLines ? "lines" : "bytes",
|
|
28010
28299
|
chars: remaining.length,
|
|
@@ -28226,22 +28515,26 @@ var FileResultReferenceStore = class {
|
|
|
28226
28515
|
if (stats === void 0 || !stats.isFile()) throw new CacheWarmupStoreError("stored result is missing; it was released or evicted", "RESULT_NOT_FOUND");
|
|
28227
28516
|
const ttlMs = this.options.ttlMs;
|
|
28228
28517
|
if (ttlMs !== void 0 && ttlMs > 0 && this.now() - stats.mtimeMs > ttlMs) throw new CacheWarmupStoreError("stored result expired", "RESULT_EXPIRED");
|
|
28518
|
+
if (input.query !== void 0 && (typeof input.query !== "string" || input.query.length === 0)) throw new CacheWarmupStoreError("query must be a non-empty string", "QUERY_INVALID");
|
|
28229
28519
|
const buffer = await fs.readFile(file);
|
|
28230
28520
|
const text = new TextDecoder("utf-8").decode(buffer);
|
|
28231
28521
|
const limit = clampLimit(input.limit);
|
|
28232
28522
|
const maxBytes = clampMaxBytes(input.maxBytes);
|
|
28233
28523
|
const offset = input.offset ?? 0;
|
|
28234
|
-
if (input.fields !== void 0 || input.equals !== void 0)
|
|
28235
|
-
|
|
28236
|
-
|
|
28237
|
-
|
|
28238
|
-
|
|
28239
|
-
|
|
28240
|
-
|
|
28241
|
-
|
|
28242
|
-
|
|
28243
|
-
|
|
28244
|
-
|
|
28524
|
+
if (input.fields !== void 0 || input.equals !== void 0) {
|
|
28525
|
+
if (input.query !== void 0) throw new CacheWarmupStoreError("query applies to text mode only; omit fields and equals when using query", "QUERY_INVALID");
|
|
28526
|
+
return pageStructured({
|
|
28527
|
+
sessionId,
|
|
28528
|
+
refId: input.refId,
|
|
28529
|
+
text,
|
|
28530
|
+
buffer,
|
|
28531
|
+
offset,
|
|
28532
|
+
limit,
|
|
28533
|
+
maxBytes,
|
|
28534
|
+
fields: input.fields,
|
|
28535
|
+
equals: input.equals
|
|
28536
|
+
});
|
|
28537
|
+
}
|
|
28245
28538
|
return pageText({
|
|
28246
28539
|
sessionId,
|
|
28247
28540
|
refId: input.refId,
|
|
@@ -28249,7 +28542,8 @@ var FileResultReferenceStore = class {
|
|
|
28249
28542
|
buffer,
|
|
28250
28543
|
offset,
|
|
28251
28544
|
limit,
|
|
28252
|
-
maxBytes
|
|
28545
|
+
maxBytes,
|
|
28546
|
+
query: input.query
|
|
28253
28547
|
});
|
|
28254
28548
|
}
|
|
28255
28549
|
/**
|
|
@@ -30280,7 +30574,7 @@ function planProjection(text, toolName, navigation, retrievalOnly, spilled = fal
|
|
|
30280
30574
|
}
|
|
30281
30575
|
/** 预览尾部:把「怎么读全文」写死在预览里,模型不用猜。 */
|
|
30282
30576
|
function footerFor(refId) {
|
|
30283
|
-
return `[full result: ${refId} · page with offset/limit(default 64 lines)/maxBytes(default 16384 bytes)]`;
|
|
30577
|
+
return `[full result: ${refId} · page with query/offset/limit(default 64 lines)/maxBytes(default 16384 bytes)]`;
|
|
30284
30578
|
}
|
|
30285
30579
|
/**
|
|
30286
30580
|
* 核心决策:预算 → 计划 → 装配 → 入库。
|
|
@@ -38407,7 +38701,7 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
38407
38701
|
(item.kind === "image" ? imageReferences : videoReferences).set(item.attachmentId, reference);
|
|
38408
38702
|
cited.push(item);
|
|
38409
38703
|
} catch (error) {
|
|
38410
|
-
if (input.signal.aborted || isAbortError(error)) throw new LlmError("Kimi Code media upload aborted", "ABORTED", { cause: error });
|
|
38704
|
+
if (input.signal.aborted || isAbortError(error)) throw new LlmError$1("Kimi Code media upload aborted", "ABORTED", { cause: error });
|
|
38411
38705
|
}
|
|
38412
38706
|
}));
|
|
38413
38707
|
return {
|
|
@@ -38563,7 +38857,7 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
38563
38857
|
}));
|
|
38564
38858
|
}
|
|
38565
38859
|
async resolveModel(provider, modelId, signal) {
|
|
38566
|
-
if (signal?.aborted) throw new LlmError("Kimi Code model resolution aborted", "ABORTED");
|
|
38860
|
+
if (signal?.aborted) throw new LlmError$1("Kimi Code model resolution aborted", "ABORTED");
|
|
38567
38861
|
const settings = await this.settings();
|
|
38568
38862
|
const catalog = await this.catalog();
|
|
38569
38863
|
const entry = catalog.find((model) => model.id === modelId);
|
|
@@ -38848,13 +39142,13 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
38848
39142
|
activity?.pulse();
|
|
38849
39143
|
return response;
|
|
38850
39144
|
} catch (error) {
|
|
38851
|
-
if (signal.aborted) throw new LlmError("Kimi Code request aborted", "ABORTED", { cause: error });
|
|
38852
|
-
throw new LlmError(`Kimi Code request failed: ${error instanceof Error ? error.message : String(error)}`, "TRANSPORT", { cause: error });
|
|
39145
|
+
if (signal.aborted) throw new LlmError$1("Kimi Code request aborted", "ABORTED", { cause: error });
|
|
39146
|
+
throw new LlmError$1(`Kimi Code request failed: ${error instanceof Error ? error.message : String(error)}`, "TRANSPORT", { cause: error });
|
|
38853
39147
|
}
|
|
38854
39148
|
};
|
|
38855
39149
|
if (sideChannel && sessionKey !== "") {
|
|
38856
39150
|
await prefixRequests.waitForMainSession(sessionKey, signal);
|
|
38857
|
-
if (signal.aborted) throw new LlmError("Kimi Code request aborted", "ABORTED");
|
|
39151
|
+
if (signal.aborted) throw new LlmError$1("Kimi Code request aborted", "ABORTED");
|
|
38858
39152
|
}
|
|
38859
39153
|
const coldGroupKey = sideChannel ? void 0 : coldStartGroupKey(region, requestOptions, accountScope);
|
|
38860
39154
|
const coldGate = coldGroupKey === void 0 ? void 0 : await acquireColdStartWarmup(coldGroupKey, signal);
|
|
@@ -38927,7 +39221,7 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
38927
39221
|
if (await pool.hasAnotherAvailableAccount(tried)) continue;
|
|
38928
39222
|
}
|
|
38929
39223
|
}
|
|
38930
|
-
throw new LlmError(failure.message, failure.code, {
|
|
39224
|
+
throw new LlmError$1(failure.message, failure.code, {
|
|
38931
39225
|
status: response.status,
|
|
38932
39226
|
...after === void 0 ? {} : { providerRetryAfterMs: after }
|
|
38933
39227
|
});
|
|
@@ -38945,7 +39239,7 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
38945
39239
|
droppedImages: stickyOffload.droppedCount + bodyFitDroppedKeys.length
|
|
38946
39240
|
}, requestOptions);
|
|
38947
39241
|
}
|
|
38948
|
-
if (response.body === null) throw new LlmError("Kimi Code returned an empty response body", "PROVIDER_ERROR");
|
|
39242
|
+
if (response.body === null) throw new LlmError$1("Kimi Code returned an empty response body", "PROVIDER_ERROR");
|
|
38949
39243
|
const reader = response.body.getReader();
|
|
38950
39244
|
const decoder = new TextDecoder();
|
|
38951
39245
|
const state = createStreamState$5(wire, requestOptions.sessionId, sideChannel);
|
|
@@ -38994,20 +39288,20 @@ var KimiCodeAdapter = class extends LlmAdapter {
|
|
|
38994
39288
|
}
|
|
38995
39289
|
} catch (error) {
|
|
38996
39290
|
const inBand = state.streamError;
|
|
38997
|
-
if (error instanceof LlmError && !outputStarted && error.code === "PROVIDER_ERROR" && inBand !== void 0) throw await this.inBandStreamFailure(error, inBand, servedByAccountId, retrySignal, requestDiagnostic.attempts.at(-1));
|
|
39291
|
+
if (error instanceof LlmError$1 && !outputStarted && error.code === "PROVIDER_ERROR" && inBand !== void 0) throw await this.inBandStreamFailure(error, inBand, servedByAccountId, retrySignal, requestDiagnostic.attempts.at(-1));
|
|
38998
39292
|
throw streamFailure(error, signal);
|
|
38999
39293
|
}
|
|
39000
39294
|
} finally {
|
|
39001
39295
|
reader.cancel().catch(() => void 0);
|
|
39002
39296
|
}
|
|
39003
39297
|
} catch (error) {
|
|
39004
|
-
if (error instanceof LlmError && isKimiToolArgumentGuardCode(error.code)) rememberSameAccountRetry(retrySignal, diagnosticState?.accountId);
|
|
39298
|
+
if (error instanceof LlmError$1 && isKimiToolArgumentGuardCode(error.code)) rememberSameAccountRetry(retrySignal, diagnosticState?.accountId);
|
|
39005
39299
|
requestError = error;
|
|
39006
39300
|
throw error;
|
|
39007
39301
|
} finally {
|
|
39008
39302
|
const endedAt = Date.now();
|
|
39009
39303
|
const finalAccountId = diagnosticState?.accountId ?? requestDiagnostic.accountId ?? requestDiagnostic.attempts.at(-1)?.accountId;
|
|
39010
|
-
const errorCode = requestError instanceof LlmError ? requestError.code : requestError === void 0 ? void 0 : "UNKNOWN";
|
|
39304
|
+
const errorCode = requestError instanceof LlmError$1 ? requestError.code : requestError === void 0 ? void 0 : "UNKNOWN";
|
|
39011
39305
|
const lastAttempt = requestDiagnostic.attempts.at(-1);
|
|
39012
39306
|
if (lastAttempt !== void 0 && errorCode !== void 0) {
|
|
39013
39307
|
lastAttempt.code = errorCode;
|
|
@@ -39088,22 +39382,22 @@ function isRefreshTimeout(error) {
|
|
|
39088
39382
|
}
|
|
39089
39383
|
/** Preserve OAuth failure semantics before the first model request. */
|
|
39090
39384
|
function credentialFailure(error, signal) {
|
|
39091
|
-
if (signal.aborted) return new LlmError("Kimi Code credential preparation aborted", "ABORTED", { cause: error });
|
|
39092
|
-
if (error instanceof LlmError) return error;
|
|
39093
|
-
if (error instanceof KimiCodeUnauthorizedError) return new LlmError(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
39094
|
-
if (error instanceof KimiCodeOAuthError) return new LlmError(error.message, "INVALID_REQUEST", {
|
|
39385
|
+
if (signal.aborted) return new LlmError$1("Kimi Code credential preparation aborted", "ABORTED", { cause: error });
|
|
39386
|
+
if (error instanceof LlmError$1) return error;
|
|
39387
|
+
if (error instanceof KimiCodeUnauthorizedError) return new LlmError$1(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
39388
|
+
if (error instanceof KimiCodeOAuthError) return new LlmError$1(error.message, "INVALID_REQUEST", {
|
|
39095
39389
|
cause: error,
|
|
39096
39390
|
status: error.status
|
|
39097
39391
|
});
|
|
39098
39392
|
if (error instanceof KimiCodeRetryableError) {
|
|
39099
39393
|
const detail = errorChain(error).trim().slice(0, 500);
|
|
39100
39394
|
const code = error.status === 429 ? "RATE_LIMIT" : error.status !== void 0 ? "SERVER" : isRefreshTimeout(error) ? "TIMEOUT" : "TRANSPORT";
|
|
39101
|
-
return new LlmError(`Kimi Code credential refresh failed: ${detail}`, code, {
|
|
39395
|
+
return new LlmError$1(`Kimi Code credential refresh failed: ${detail}`, code, {
|
|
39102
39396
|
cause: error,
|
|
39103
39397
|
...error.status === void 0 ? {} : { status: error.status }
|
|
39104
39398
|
});
|
|
39105
39399
|
}
|
|
39106
|
-
return new LlmError(`Kimi Code credential could not be prepared: ${error instanceof Error ? error.message : String(error)}`, "MISSING_CREDENTIAL", { cause: error });
|
|
39400
|
+
return new LlmError$1(`Kimi Code credential could not be prepared: ${error instanceof Error ? error.message : String(error)}`, "MISSING_CREDENTIAL", { cause: error });
|
|
39107
39401
|
}
|
|
39108
39402
|
/**
|
|
39109
39403
|
* The failure a stream that died mid-body is reported as.
|
|
@@ -39131,10 +39425,10 @@ function credentialFailure(error, signal) {
|
|
|
39131
39425
|
* retried one.
|
|
39132
39426
|
*/
|
|
39133
39427
|
function streamFailure(error, signal) {
|
|
39134
|
-
if (error instanceof LlmError) return error;
|
|
39135
|
-
if (signal.aborted) return new LlmError("Kimi Code stream aborted", "ABORTED", { cause: error });
|
|
39428
|
+
if (error instanceof LlmError$1) return error;
|
|
39429
|
+
if (signal.aborted) return new LlmError$1("Kimi Code stream aborted", "ABORTED", { cause: error });
|
|
39136
39430
|
const chain = errorChain(error).trim();
|
|
39137
|
-
return new LlmError(`Kimi Code stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
39431
|
+
return new LlmError$1(`Kimi Code stream failed: ${chain === "" ? "the response stream ended unexpectedly" : chain.slice(0, 500)}`, "TRANSPORT", { cause: error });
|
|
39138
39432
|
}
|
|
39139
39433
|
function processLine(line, state, wire) {
|
|
39140
39434
|
return wire === "anthropic" ? processAnthropicStreamLine(line, state) : processOpenAIStreamLine(line, state);
|
|
@@ -41301,204 +41595,13 @@ function renderDirectCallReminder(toolNames) {
|
|
|
41301
41595
|
].join("\n");
|
|
41302
41596
|
}
|
|
41303
41597
|
/**
|
|
41304
|
-
*
|
|
41305
|
-
* @returns 后缀正文。
|
|
41306
|
-
*/
|
|
41307
|
-
const TURN_ONLY_SUFFIX = " This is a temporary runtime reminder for the current Turn only, not a user preference or a durable rule; do not save this reminder or generalize it into Memory, Skills, or other persistent instruction files for future Turns or sessions.";
|
|
41308
|
-
/**
|
|
41309
|
-
* 渲染「同一个动作立刻重复」提醒。
|
|
41310
|
-
*
|
|
41311
|
-
* 与官方 `packages/agent-modules/runaway-guard/src/reminder.ts` 逐字一致。
|
|
41312
|
-
* @param occurrences - 连击次数。
|
|
41313
|
-
* @returns 提醒正文。
|
|
41314
|
-
*/
|
|
41315
|
-
function renderExactActionRepeatReminder(occurrences) {
|
|
41316
|
-
return `[runaway guard] The immediately repeated tool action has now occurred ${occurrences} times with the same arguments. Do not repeat it unchanged. Inspect the results already available, then either change strategy with a concrete expected state change, or report the blocker. Repetition alone does not establish that the task is complete or impossible.${TURN_ONLY_SUFFIX}`;
|
|
41317
|
-
}
|
|
41318
|
-
/**
|
|
41319
|
-
* 渲染「同一族错误连续发生」提醒。
|
|
41320
|
-
*
|
|
41321
|
-
* 与官方 `packages/agent-modules/runaway-guard/src/reminder.ts` 逐字一致。
|
|
41322
|
-
* @param occurrences - 连击次数。
|
|
41323
|
-
* @returns 提醒正文。
|
|
41324
|
-
*/
|
|
41325
|
-
function renderSameErrorFamilyReminder(occurrences) {
|
|
41326
|
-
return `[runaway guard] The same tool error family has now occurred ${occurrences} times in a row. Do not retry the same route unchanged. Diagnose the cause, change one controlled variable or switch route. Do not infer that the entire task has failed from this signal.${TURN_ONLY_SUFFIX}`;
|
|
41327
|
-
}
|
|
41328
|
-
/**
|
|
41329
|
-
* 渲染「反复轮询同一个后台任务」提醒。
|
|
41330
|
-
*
|
|
41331
|
-
* 与官方 `packages/agent-modules/runaway-guard/src/reminder.ts` 逐字一致:
|
|
41332
|
-
* 三次读同一个任务时写的是 `Three`,其它次数写数字。
|
|
41333
|
-
* @param occurrences - 连击次数。
|
|
41334
|
-
* @returns 提醒正文。
|
|
41335
|
-
*/
|
|
41336
|
-
function renderPollingRepeatReminder(occurrences) {
|
|
41337
|
-
return [
|
|
41338
|
-
"<system-reminder>",
|
|
41339
|
-
`${occurrences === 3 ? "Three" : String(occurrences)} task_output reads for the same task have returned an unchanged status and output cursor. Avoid repeated polling; you will be notified automatically and this conversation will resume when the background task completes.`,
|
|
41340
|
-
"This reminder applies only to the current Turn. Do not save or generalize it into Memory, Skills, or other persistent instructions.",
|
|
41341
|
-
"</system-reminder>"
|
|
41342
|
-
].join("\n");
|
|
41343
|
-
}
|
|
41344
|
-
/**
|
|
41345
|
-
* 轮询类工具名(后台任务的结果读取)。
|
|
41346
|
-
*
|
|
41347
|
-
* 这两个工具读的是后台任务的状态;反复读同一个任务而输出没变,就是官方说的
|
|
41348
|
-
* 「polling repeat」。
|
|
41349
|
-
*/
|
|
41350
|
-
const POLLING_TOOL_NAMES = Object.freeze(["job_output", "task_output"]);
|
|
41351
|
-
/**
|
|
41352
|
-
* 规范化一段错误文本,取它的「族」。
|
|
41353
|
-
*
|
|
41354
|
-
* 族的作用是**把同一类错误认成同一类**:路径里的数字、id、时间戳都不该让
|
|
41355
|
-
* 两次一模一样的失败看起来是两回事。
|
|
41356
|
-
* @param text - 错误文本。
|
|
41357
|
-
* @returns 族标识。
|
|
41358
|
-
*/
|
|
41359
|
-
function errorFamilyOf(text) {
|
|
41360
|
-
if (text === void 0 || text === "") return "unknown";
|
|
41361
|
-
return (text.split(/\r?\n/, 1)[0] ?? "").replace(/\d+/g, "#").slice(0, 200);
|
|
41362
|
-
}
|
|
41363
|
-
/**
|
|
41364
|
-
* 造一台工具级失控守卫。
|
|
41365
|
-
*
|
|
41366
|
-
* 三种可提醒信号(顺序即官方提醒优先级):
|
|
41367
|
-
*
|
|
41368
|
-
* 1. `same_error_family` —— 同一个工具连续报同一族错误;
|
|
41369
|
-
* 2. `exact_action_repeat` —— 同一次动作(同名 + 同参数)立刻重复;
|
|
41370
|
-
* 3. `polling_repeat` —— 连续轮询同一个后台任务而输出没变。
|
|
41371
|
-
*
|
|
41372
|
-
* `abab_action_cycle`(A B A B 的循环)**只记录不提醒**:官方把它排在提醒
|
|
41373
|
-
* 候选之外——模型在两个动作之间来回跳时,提醒它「别重复」是没有意义的。
|
|
41374
|
-
*
|
|
41375
|
-
* 每轮**至多一条**提醒:官方在发出第一条后就把本轮的提醒机会用掉了。
|
|
41598
|
+
* 造一台 MiniMax Code 会话的工具级失控守卫(实现已下沉至共享内核 `tool-runaway.ts`)。
|
|
41376
41599
|
*
|
|
41377
41600
|
* @param options - 守卫选项。
|
|
41378
41601
|
* @returns 守卫。
|
|
41379
41602
|
*/
|
|
41380
41603
|
function createMinimaxRunawayGuard(options = {}) {
|
|
41381
|
-
|
|
41382
|
-
/** 同一次动作的连击,由所有线路共享的规范键与跟踪器计算。 */
|
|
41383
|
-
const exactActionRepeats = createExactRepeatTracker();
|
|
41384
|
-
/** 同一族错误的连击(键是工具名 + 错误族)。 */
|
|
41385
|
-
const errorStreaks = /* @__PURE__ */ new Map();
|
|
41386
|
-
/** 轮询连击(键是工具名)。 */
|
|
41387
|
-
const pollingStreaks = /* @__PURE__ */ new Map();
|
|
41388
|
-
/** 最近几次动作,用来认 A B A B 的循环。 */
|
|
41389
|
-
const recentActions = [];
|
|
41390
|
-
/** 当前正在计数的 A B 循环对。 */
|
|
41391
|
-
let activeAbabKey;
|
|
41392
|
-
/** 本轮是否已经提醒过。 */
|
|
41393
|
-
let reminderAttempted = false;
|
|
41394
|
-
/** 观察到的信号。 */
|
|
41395
|
-
const signals = [];
|
|
41396
|
-
/**
|
|
41397
|
-
* 记一条信号。
|
|
41398
|
-
* @param kind - 信号种类。
|
|
41399
|
-
* @param occurrences - 连击次数。
|
|
41400
|
-
* @param toolName - 工具名。
|
|
41401
|
-
*/
|
|
41402
|
-
const record = (kind, occurrences, toolName) => {
|
|
41403
|
-
signals.push({
|
|
41404
|
-
kind,
|
|
41405
|
-
occurrences,
|
|
41406
|
-
toolName
|
|
41407
|
-
});
|
|
41408
|
-
};
|
|
41409
|
-
/**
|
|
41410
|
-
* 判断这次执行是不是一次「原地不动」的轮询。
|
|
41411
|
-
* @param observation - 观察事实。
|
|
41412
|
-
* @returns 是轮询时为 true。
|
|
41413
|
-
*/
|
|
41414
|
-
const isPolling = (observation) => {
|
|
41415
|
-
if (!POLLING_TOOL_NAMES.includes(observation.toolName)) return false;
|
|
41416
|
-
return (isPlainRecord(observation.arguments) ? observation.arguments : void 0)?.["wait"] !== true;
|
|
41417
|
-
};
|
|
41418
|
-
return {
|
|
41419
|
-
observe(observation) {
|
|
41420
|
-
const toolName = observation.toolName;
|
|
41421
|
-
const actionKey = canonicalToolCallKey(toolName, observation.arguments);
|
|
41422
|
-
const countsAsAction = !POLLING_TOOL_NAMES.includes(toolName);
|
|
41423
|
-
if (countsAsAction) {
|
|
41424
|
-
const action = exactActionRepeats.observe(toolName, observation.arguments);
|
|
41425
|
-
record("exact_action_repeat", action.count, toolName);
|
|
41426
|
-
}
|
|
41427
|
-
if (countsAsAction) {
|
|
41428
|
-
recentActions.push(actionKey);
|
|
41429
|
-
if (recentActions.length > 4) recentActions.shift();
|
|
41430
|
-
if (recentActions.length === 4) {
|
|
41431
|
-
const [a, b, c, d] = recentActions;
|
|
41432
|
-
if (a !== void 0 && b !== void 0 && a !== b && a === c && b === d) {
|
|
41433
|
-
const episode = `${a}\u0000${b}`;
|
|
41434
|
-
if (activeAbabKey !== episode) {
|
|
41435
|
-
activeAbabKey = episode;
|
|
41436
|
-
record("abab_action_cycle", 2, toolName);
|
|
41437
|
-
}
|
|
41438
|
-
} else activeAbabKey = void 0;
|
|
41439
|
-
}
|
|
41440
|
-
}
|
|
41441
|
-
if (observation.isError === true) {
|
|
41442
|
-
const key = `${toolName}\u0000${observation.errorCode ?? errorFamilyOf(observation.errorText)}`;
|
|
41443
|
-
const previous = errorStreaks.get(key);
|
|
41444
|
-
const count = previous === void 0 ? 1 : previous.count + 1;
|
|
41445
|
-
errorStreaks.set(key, {
|
|
41446
|
-
toolName,
|
|
41447
|
-
count
|
|
41448
|
-
});
|
|
41449
|
-
record("same_error_family", count, toolName);
|
|
41450
|
-
} else for (const [key, entry] of [...errorStreaks]) if (entry.toolName === toolName) errorStreaks.delete(key);
|
|
41451
|
-
if (isPolling(observation)) {
|
|
41452
|
-
const key = `${canonicalToolCallKey(toolName, observation.arguments)}\u0000${observation.resultText ?? ""}`;
|
|
41453
|
-
const previous = pollingStreaks.get(toolName);
|
|
41454
|
-
const count = previous !== void 0 && previous.key === key ? previous.count + 1 : 1;
|
|
41455
|
-
pollingStreaks.set(toolName, {
|
|
41456
|
-
key,
|
|
41457
|
-
count
|
|
41458
|
-
});
|
|
41459
|
-
record("polling_repeat", count, toolName);
|
|
41460
|
-
} else pollingStreaks.delete(toolName);
|
|
41461
|
-
if (reminderAttempted) return void 0;
|
|
41462
|
-
const errorCandidate = [...errorStreaks.values()].find((entry) => entry.count >= threshold);
|
|
41463
|
-
if (errorCandidate !== void 0) {
|
|
41464
|
-
reminderAttempted = true;
|
|
41465
|
-
return {
|
|
41466
|
-
kind: "same_error_family",
|
|
41467
|
-
occurrences: errorCandidate.count,
|
|
41468
|
-
text: renderSameErrorFamilyReminder(errorCandidate.count)
|
|
41469
|
-
};
|
|
41470
|
-
}
|
|
41471
|
-
const actionStreak = exactActionRepeats.current();
|
|
41472
|
-
if (countsAsAction && actionStreak !== void 0 && actionStreak.count >= threshold) {
|
|
41473
|
-
reminderAttempted = true;
|
|
41474
|
-
return {
|
|
41475
|
-
kind: "exact_action_repeat",
|
|
41476
|
-
occurrences: actionStreak.count,
|
|
41477
|
-
text: renderExactActionRepeatReminder(actionStreak.count)
|
|
41478
|
-
};
|
|
41479
|
-
}
|
|
41480
|
-
const pollingCandidate = [...pollingStreaks.values()].find((entry) => entry.count >= threshold);
|
|
41481
|
-
if (pollingCandidate !== void 0) {
|
|
41482
|
-
reminderAttempted = true;
|
|
41483
|
-
return {
|
|
41484
|
-
kind: "polling_repeat",
|
|
41485
|
-
occurrences: pollingCandidate.count,
|
|
41486
|
-
text: renderPollingRepeatReminder(pollingCandidate.count)
|
|
41487
|
-
};
|
|
41488
|
-
}
|
|
41489
|
-
},
|
|
41490
|
-
reset() {
|
|
41491
|
-
exactActionRepeats.reset();
|
|
41492
|
-
errorStreaks.clear();
|
|
41493
|
-
pollingStreaks.clear();
|
|
41494
|
-
recentActions.length = 0;
|
|
41495
|
-
activeAbabKey = void 0;
|
|
41496
|
-
reminderAttempted = false;
|
|
41497
|
-
},
|
|
41498
|
-
get signals() {
|
|
41499
|
-
return signals;
|
|
41500
|
-
}
|
|
41501
|
-
};
|
|
41604
|
+
return createToolRunawayGuard(options);
|
|
41502
41605
|
}
|
|
41503
41606
|
/**
|
|
41504
41607
|
* 读宿主上下文上的工具注册面。
|
|
@@ -41683,51 +41786,6 @@ function createRunawayReminder(reminder) {
|
|
|
41683
41786
|
});
|
|
41684
41787
|
}
|
|
41685
41788
|
/**
|
|
41686
|
-
* 读一次执行的结果是不是失败。
|
|
41687
|
-
* @param result - 工具执行结果。
|
|
41688
|
-
* @returns 失败时为 true。
|
|
41689
|
-
*/
|
|
41690
|
-
function isErrorResult(result) {
|
|
41691
|
-
return isRecord$50(result) && result["isError"] === true;
|
|
41692
|
-
}
|
|
41693
|
-
/**
|
|
41694
|
-
* 读一次执行的结构化错误码。
|
|
41695
|
-
* @param result - 工具执行结果。
|
|
41696
|
-
* @returns 错误码;没有时为 undefined。
|
|
41697
|
-
*/
|
|
41698
|
-
function errorCodeOf$1(result) {
|
|
41699
|
-
if (!isRecord$50(result)) return void 0;
|
|
41700
|
-
const error = result["error"];
|
|
41701
|
-
if (!isRecord$50(error)) return void 0;
|
|
41702
|
-
const info = error["info"];
|
|
41703
|
-
if (!isRecord$50(info)) return void 0;
|
|
41704
|
-
return stringOf$4(info["code"]);
|
|
41705
|
-
}
|
|
41706
|
-
/**
|
|
41707
|
-
* 读一次执行的失败文本。
|
|
41708
|
-
* @param result - 工具执行结果。
|
|
41709
|
-
* @returns 失败文本;没有时为 undefined。
|
|
41710
|
-
*/
|
|
41711
|
-
function errorTextOf(result) {
|
|
41712
|
-
if (!isRecord$50(result)) return void 0;
|
|
41713
|
-
const error = result["error"];
|
|
41714
|
-
if (!isRecord$50(error)) return void 0;
|
|
41715
|
-
return stringOf$4(error["message"]);
|
|
41716
|
-
}
|
|
41717
|
-
/**
|
|
41718
|
-
* 读一次执行的结果文本(轮询判定用)。
|
|
41719
|
-
* @param result - 工具执行结果。
|
|
41720
|
-
* @returns 结果文本;没有时是空串。
|
|
41721
|
-
*/
|
|
41722
|
-
function resultTextOf(result) {
|
|
41723
|
-
if (!isRecord$50(result)) return "";
|
|
41724
|
-
const content = result["content"];
|
|
41725
|
-
if (!Array.isArray(content)) return "";
|
|
41726
|
-
const parts = [];
|
|
41727
|
-
for (const block of content) if (isRecord$50(block) && block["type"] === "text") parts.push(stringOf$4(block["text"]) ?? "");
|
|
41728
|
-
return parts.join("\n");
|
|
41729
|
-
}
|
|
41730
|
-
/**
|
|
41731
41789
|
* 找一次工具调用的参数 schema。
|
|
41732
41790
|
* @param tools - 工具注册面。
|
|
41733
41791
|
* @param name - 工具名。
|
|
@@ -41833,15 +41891,16 @@ function installMinimaxRuntimeEnhancements(ctx, options = {}) {
|
|
|
41833
41891
|
const contexts = [];
|
|
41834
41892
|
const directName = directCallToolNameOf(exec);
|
|
41835
41893
|
if (directName !== void 0 && isPtcSessionOf(agent, tools)) contexts.push(createDirectCallReminder(directName));
|
|
41836
|
-
|
|
41837
|
-
|
|
41838
|
-
|
|
41839
|
-
|
|
41840
|
-
|
|
41841
|
-
|
|
41842
|
-
|
|
41843
|
-
|
|
41844
|
-
|
|
41894
|
+
if ((() => {
|
|
41895
|
+
try {
|
|
41896
|
+
return options.runawayEnabled?.() !== false;
|
|
41897
|
+
} catch {
|
|
41898
|
+
return true;
|
|
41899
|
+
}
|
|
41900
|
+
})()) {
|
|
41901
|
+
const reminder = guardOf(agent).observe(observationFromToolExecution(exec.name, exec.arguments, result));
|
|
41902
|
+
if (reminder !== void 0) contexts.push(createRunawayReminder(reminder));
|
|
41903
|
+
}
|
|
41845
41904
|
if (contexts.length === 0) return decision;
|
|
41846
41905
|
return withAdditionalContexts$1(decision, contexts);
|
|
41847
41906
|
} catch {
|
|
@@ -45977,7 +46036,7 @@ function sameModelId(requested, answered) {
|
|
|
45977
46036
|
* substitution means this id no longer routes, so the selection has to change.
|
|
45978
46037
|
*/
|
|
45979
46038
|
function modelSubstitutedFailure(requested, answered) {
|
|
45980
|
-
return new LlmError("MiniMax Code(编程订阅) answered with a different model than the one requested: the request asked for \"" + requested + "\", and the service answered as \"" + answered + "\". This endpoint does not reject a model id it cannot route — it silently runs another one — so the id \"" + requested + "\" is not being served and the request was billed at the answering model's rate instead. Nothing was retried, because the same request would be answered the same way. Pick a different model for this line, or check whether \"" + requested + "\" is still offered, then send the request again.", MODEL_SUBSTITUTED_CODE, { status: 200 });
|
|
46039
|
+
return new LlmError$1("MiniMax Code(编程订阅) answered with a different model than the one requested: the request asked for \"" + requested + "\", and the service answered as \"" + answered + "\". This endpoint does not reject a model id it cannot route — it silently runs another one — so the id \"" + requested + "\" is not being served and the request was billed at the answering model's rate instead. Nothing was retried, because the same request would be answered the same way. Pick a different model for this line, or check whether \"" + requested + "\" is still offered, then send the request again.", MODEL_SUBSTITUTED_CODE, { status: 200 });
|
|
45981
46040
|
}
|
|
45982
46041
|
var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
45983
46042
|
store;
|
|
@@ -46108,7 +46167,7 @@ var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
|
46108
46167
|
* deliberately not exposed as a fixed defaultMaxTokens reservation here.
|
|
46109
46168
|
*/
|
|
46110
46169
|
async resolveModel(provider, modelId, signal) {
|
|
46111
|
-
if (signal?.aborted === true) throw new LlmError("MiniMax Code model resolution aborted", "ABORTED");
|
|
46170
|
+
if (signal?.aborted === true) throw new LlmError$1("MiniMax Code model resolution aborted", "ABORTED");
|
|
46112
46171
|
const settings = await this.settings();
|
|
46113
46172
|
const entry = minimaxCodeModelDef(modelId);
|
|
46114
46173
|
const efforts = orderReasoningEfforts(effortsForModel(modelId), [
|
|
@@ -46202,8 +46261,8 @@ var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
|
46202
46261
|
credentials = selection.credentials;
|
|
46203
46262
|
accountId = selection.accountId;
|
|
46204
46263
|
} catch (error) {
|
|
46205
|
-
if (error instanceof MinimaxCodeUnauthorizedError) throw new LlmError(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
46206
|
-
throw new LlmError("MiniMax Code(编程订阅) credential could not be prepared: " + (error instanceof Error ? error.message : String(error)), "MISSING_CREDENTIAL", { cause: error });
|
|
46264
|
+
if (error instanceof MinimaxCodeUnauthorizedError) throw new LlmError$1(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
46265
|
+
throw new LlmError$1("MiniMax Code(编程订阅) credential could not be prepared: " + (error instanceof Error ? error.message : String(error)), "MISSING_CREDENTIAL", { cause: error });
|
|
46207
46266
|
}
|
|
46208
46267
|
if (accountId !== void 0) tried.add(accountId);
|
|
46209
46268
|
authOwner = computeMinimaxAuthOwner(credentials, accountId);
|
|
@@ -46252,8 +46311,8 @@ var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
|
46252
46311
|
});
|
|
46253
46312
|
activity?.pulse();
|
|
46254
46313
|
} catch (error) {
|
|
46255
|
-
if (signal.aborted) throw new LlmError("MiniMax Code request aborted", "ABORTED", { cause: error });
|
|
46256
|
-
throw new LlmError("MiniMax Code(编程订阅) request failed: " + (error instanceof Error ? error.message : String(error)), "TRANSPORT", { cause: error });
|
|
46314
|
+
if (signal.aborted) throw new LlmError$1("MiniMax Code request aborted", "ABORTED", { cause: error });
|
|
46315
|
+
throw new LlmError$1("MiniMax Code(编程订阅) request failed: " + (error instanceof Error ? error.message : String(error)), "TRANSPORT", { cause: error });
|
|
46257
46316
|
}
|
|
46258
46317
|
refusedBody = void 0;
|
|
46259
46318
|
if (response.ok) break;
|
|
@@ -46266,8 +46325,8 @@ var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
|
46266
46325
|
authOwner = computeMinimaxAuthOwner(credentials, accountId);
|
|
46267
46326
|
body = buildBodyForOwner(authOwner);
|
|
46268
46327
|
} catch (error) {
|
|
46269
|
-
if (error instanceof MinimaxCodeUnauthorizedError) throw new LlmError(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
46270
|
-
throw new LlmError("MiniMax Code(编程订阅) credential could not be renewed after the service refused " + redactToken(refused) + ": " + (error instanceof Error ? error.message : String(error)), "INVALID_CREDENTIAL", { cause: error });
|
|
46328
|
+
if (error instanceof MinimaxCodeUnauthorizedError) throw new LlmError$1(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
46329
|
+
throw new LlmError$1("MiniMax Code(编程订阅) credential could not be renewed after the service refused " + redactToken(refused) + ": " + (error instanceof Error ? error.message : String(error)), "INVALID_CREDENTIAL", { cause: error });
|
|
46271
46330
|
}
|
|
46272
46331
|
}
|
|
46273
46332
|
if (response.ok) break;
|
|
@@ -46282,12 +46341,12 @@ var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
|
46282
46341
|
}
|
|
46283
46342
|
}
|
|
46284
46343
|
const hint = failure.code === "INVALID_CREDENTIAL" ? " (credential " + redactToken(credentials.accessToken) + ")" : "";
|
|
46285
|
-
throw new LlmError(failure.message + hint, failure.code, {
|
|
46344
|
+
throw new LlmError$1(failure.message + hint, failure.code, {
|
|
46286
46345
|
status: response.status,
|
|
46287
46346
|
...after === void 0 ? {} : { providerRetryAfterMs: after }
|
|
46288
46347
|
});
|
|
46289
46348
|
}
|
|
46290
|
-
if (response.body === null) throw new LlmError("MiniMax Code(编程订阅) returned an empty response body", "PROVIDER_ERROR");
|
|
46349
|
+
if (response.body === null) throw new LlmError$1("MiniMax Code(编程订阅) returned an empty response body", "PROVIDER_ERROR");
|
|
46291
46350
|
const reader = response.body.getReader();
|
|
46292
46351
|
const decoder = new TextDecoder();
|
|
46293
46352
|
const state = createStreamState({
|
|
@@ -46378,7 +46437,7 @@ var MinimaxCodeAdapter = class extends LlmAdapter {
|
|
|
46378
46437
|
yield chunk;
|
|
46379
46438
|
}
|
|
46380
46439
|
} catch (error) {
|
|
46381
|
-
if (error instanceof LlmError && !outputStarted && error.code === "PROVIDER_ERROR" && state.streamError !== void 0) {
|
|
46440
|
+
if (error instanceof LlmError$1 && !outputStarted && error.code === "PROVIDER_ERROR" && state.streamError !== void 0) {
|
|
46382
46441
|
const reclassified = reclassifyInBandError(error, state.streamError, classifyMinimaxFailure);
|
|
46383
46442
|
if (pool !== void 0 && accountId !== void 0) {
|
|
46384
46443
|
const inBandBody = JSON.stringify({ error: state.streamError });
|
|
@@ -49605,7 +49664,14 @@ function installKimiRepeatBreaker(ctx, options = {}) {
|
|
|
49605
49664
|
if (target === void 0) return decision;
|
|
49606
49665
|
const toolName = stringOf$3(exec.name);
|
|
49607
49666
|
if (toolName === void 0) return decision;
|
|
49608
|
-
const
|
|
49667
|
+
const args = exec.arguments;
|
|
49668
|
+
const obs = observationFromToolExecution(toolName, args, result);
|
|
49669
|
+
const reminder = target.breaker.recordAfterExecute(target.key, toolName, args, {
|
|
49670
|
+
isError: obs.isError,
|
|
49671
|
+
errorCode: obs.errorCode,
|
|
49672
|
+
errorText: obs.errorText,
|
|
49673
|
+
resultText: obs.resultText
|
|
49674
|
+
});
|
|
49609
49675
|
if (reminder === void 0) return decision;
|
|
49610
49676
|
return withAdditionalContexts(decision, [createRepeatBreakerReminder(reminder)]);
|
|
49611
49677
|
} catch {
|
|
@@ -57129,7 +57195,7 @@ function assertClaudeCliVersionMeetsFloor(modelId, catalog = FALLBACK_MODELS) {
|
|
|
57129
57195
|
if (floor === void 0) return;
|
|
57130
57196
|
const effective = claudeCliVersion();
|
|
57131
57197
|
if (meetsDottedVersionFloor(effective, floor)) return;
|
|
57132
|
-
throw new LlmError("Claude(订阅) will not serve " + modelId + " to a client reporting version " + effective + ": upstream requires " + floor + " or newer for this model, and a lower claim is refused with claude_code_version_too_old. This was caught locally, before the request was sent. Raise the reported version with the DSH_CLAUDE_CLI_VERSION environment variable, or with a setClaudeCliVersion pin, then retry. The stored sign-in is still valid — this is not a credential problem and signing in again will not change it.", "PROVIDER_ERROR");
|
|
57198
|
+
throw new LlmError$1("Claude(订阅) will not serve " + modelId + " to a client reporting version " + effective + ": upstream requires " + floor + " or newer for this model, and a lower claim is refused with claude_code_version_too_old. This was caught locally, before the request was sent. Raise the reported version with the DSH_CLAUDE_CLI_VERSION environment variable, or with a setClaudeCliVersion pin, then retry. The stored sign-in is still valid — this is not a credential problem and signing in again will not change it.", "PROVIDER_ERROR");
|
|
57133
57199
|
}
|
|
57134
57200
|
const claudePrefixRequests = new PrefixRequestCoordinator();
|
|
57135
57201
|
const claudeStickyImages = new StickyImageBudgetStore("claude");
|
|
@@ -57277,7 +57343,7 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57277
57343
|
}));
|
|
57278
57344
|
}
|
|
57279
57345
|
async resolveModel(provider, modelId, signal) {
|
|
57280
|
-
if (signal?.aborted) throw new LlmError("Claude model resolution aborted", "ABORTED");
|
|
57346
|
+
if (signal?.aborted) throw new LlmError$1("Claude model resolution aborted", "ABORTED");
|
|
57281
57347
|
const settings = await this.settings();
|
|
57282
57348
|
const record = await this.primaryAccount(settings);
|
|
57283
57349
|
const catalog = record === null ? FALLBACK_MODELS : await this.catalog(record.credentials);
|
|
@@ -57326,7 +57392,7 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57326
57392
|
async resolveCredential(pool, tried, fetchFn, signal) {
|
|
57327
57393
|
if (pool === null) {
|
|
57328
57394
|
const record = await this.primaryAccount(await this.settings());
|
|
57329
|
-
if (record === null) throw new LlmError(MISSING_CREDENTIAL_MESSAGE, "MISSING_CREDENTIAL");
|
|
57395
|
+
if (record === null) throw new LlmError$1(MISSING_CREDENTIAL_MESSAGE, "MISSING_CREDENTIAL");
|
|
57330
57396
|
try {
|
|
57331
57397
|
return {
|
|
57332
57398
|
credentials: await ensureAccessToken(new ClaudeAccountTokenStore(this.store, record.internalId), {
|
|
@@ -57336,8 +57402,8 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57336
57402
|
accountId: void 0
|
|
57337
57403
|
};
|
|
57338
57404
|
} catch (error) {
|
|
57339
|
-
if (error instanceof ClaudeUnauthorizedError) throw new LlmError(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
57340
|
-
throw new LlmError("Claude credential could not be prepared: " + (error instanceof Error ? error.message : String(error)), "MISSING_CREDENTIAL", { cause: error });
|
|
57405
|
+
if (error instanceof ClaudeUnauthorizedError) throw new LlmError$1(error.message, "INVALID_CREDENTIAL", { cause: error });
|
|
57406
|
+
throw new LlmError$1("Claude credential could not be prepared: " + (error instanceof Error ? error.message : String(error)), "MISSING_CREDENTIAL", { cause: error });
|
|
57341
57407
|
}
|
|
57342
57408
|
}
|
|
57343
57409
|
try {
|
|
@@ -57348,8 +57414,8 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57348
57414
|
accountId: effective.account.id
|
|
57349
57415
|
};
|
|
57350
57416
|
} catch (error) {
|
|
57351
|
-
if (error instanceof LlmError) throw error;
|
|
57352
|
-
throw new LlmError(error instanceof Error ? error.message : MISSING_CREDENTIAL_MESSAGE, "MISSING_CREDENTIAL", { cause: error });
|
|
57417
|
+
if (error instanceof LlmError$1) throw error;
|
|
57418
|
+
throw new LlmError$1(error instanceof Error ? error.message : MISSING_CREDENTIAL_MESSAGE, "MISSING_CREDENTIAL", { cause: error });
|
|
57353
57419
|
}
|
|
57354
57420
|
}
|
|
57355
57421
|
/**
|
|
@@ -57402,7 +57468,7 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57402
57468
|
signal
|
|
57403
57469
|
});
|
|
57404
57470
|
} catch (error) {
|
|
57405
|
-
if (signal.aborted) throw new LlmError("Claude request aborted", "ABORTED", { cause: error });
|
|
57471
|
+
if (signal.aborted) throw new LlmError$1("Claude request aborted", "ABORTED", { cause: error });
|
|
57406
57472
|
throw toLlmError(networkFailure(error));
|
|
57407
57473
|
}
|
|
57408
57474
|
}
|
|
@@ -57461,8 +57527,8 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57461
57527
|
}
|
|
57462
57528
|
throw toLlmError(failure);
|
|
57463
57529
|
}
|
|
57464
|
-
if (response === void 0) throw new LlmError("Claude produced no response", "PROVIDER_ERROR");
|
|
57465
|
-
if (response.body === null) throw new LlmError("Claude returned an empty response body", "PROVIDER_ERROR");
|
|
57530
|
+
if (response === void 0) throw new LlmError$1("Claude produced no response", "PROVIDER_ERROR");
|
|
57531
|
+
if (response.body === null) throw new LlmError$1("Claude returned an empty response body", "PROVIDER_ERROR");
|
|
57466
57532
|
const reader = response.body.getReader();
|
|
57467
57533
|
const decoder = new TextDecoder();
|
|
57468
57534
|
const state = createStreamState$4(toolNames);
|
|
@@ -57497,14 +57563,14 @@ var ClaudeAdapter = class ClaudeAdapter extends LlmAdapter {
|
|
|
57497
57563
|
yield chunk;
|
|
57498
57564
|
}
|
|
57499
57565
|
} catch (error) {
|
|
57500
|
-
if (error instanceof LlmError) {
|
|
57566
|
+
if (error instanceof LlmError$1) {
|
|
57501
57567
|
if (outputStarted || error.code !== "PROVIDER_ERROR" || state.streamError === void 0) throw error;
|
|
57502
57568
|
const verdict = inBandStreamVerdict(error, state.streamError, response.headers);
|
|
57503
57569
|
if (verdict.failure !== null && shouldRotateAccount(verdict.failure, outputStarted) && usedAccountId !== void 0) await pool?.markCooldown(usedAccountId, cooldownMsFor(verdict.failure), "Claude(订阅) in-stream 429").catch(() => void 0);
|
|
57504
57570
|
throw verdict.error;
|
|
57505
57571
|
}
|
|
57506
|
-
if (signal.aborted) throw new LlmError("Claude request aborted", "ABORTED", { cause: error });
|
|
57507
|
-
throw new LlmError("Claude stream failed: " + (error instanceof Error ? error.message : String(error)), outputStarted ? "PROVIDER_ERROR" : "TRANSPORT", { cause: error });
|
|
57572
|
+
if (signal.aborted) throw new LlmError$1("Claude request aborted", "ABORTED", { cause: error });
|
|
57573
|
+
throw new LlmError$1("Claude stream failed: " + (error instanceof Error ? error.message : String(error)), outputStarted ? "PROVIDER_ERROR" : "TRANSPORT", { cause: error });
|
|
57508
57574
|
}
|
|
57509
57575
|
} finally {
|
|
57510
57576
|
reader.cancel().catch(() => void 0);
|
|
@@ -57630,7 +57696,7 @@ function inBandStreamVerdict(thrown, streamError, headers) {
|
|
|
57630
57696
|
};
|
|
57631
57697
|
const retryAfter = failure.retryAfterMs !== null && failure.retryAfterMs > 0 ? failure.retryAfterMs : void 0;
|
|
57632
57698
|
return {
|
|
57633
|
-
error: new LlmError(thrown.message, codeForFailure(failure), retryAfter === void 0 ? {} : { providerRetryAfterMs: retryAfter }),
|
|
57699
|
+
error: new LlmError$1(thrown.message, codeForFailure(failure), retryAfter === void 0 ? {} : { providerRetryAfterMs: retryAfter }),
|
|
57634
57700
|
failure
|
|
57635
57701
|
};
|
|
57636
57702
|
}
|
|
@@ -57650,16 +57716,16 @@ function toLlmError(failure) {
|
|
|
57650
57716
|
...retryAfter === void 0 ? {} : { providerRetryAfterMs: retryAfter }
|
|
57651
57717
|
};
|
|
57652
57718
|
const detail = failure.message === "" ? "" : " " + failure.message;
|
|
57653
|
-
if (failure.clientVersionTooOld) return new LlmError("Claude(订阅) refused this request because the client version it was told is below the server's floor (claude_code_version_too_old). Raise it with the DSH_CLAUDE_CLI_VERSION environment variable (or a setClaudeCliVersion pin), then retry — the stored sign-in is still valid." + detail, "PROVIDER_ERROR", options);
|
|
57654
|
-
if (failure.kind === "request" && isHttpContextOverflow(failure.status, failure.message)) return new LlmError("Claude(订阅) context window exceeded." + detail, CONTEXT_OVERFLOW_CODE, options);
|
|
57719
|
+
if (failure.clientVersionTooOld) return new LlmError$1("Claude(订阅) refused this request because the client version it was told is below the server's floor (claude_code_version_too_old). Raise it with the DSH_CLAUDE_CLI_VERSION environment variable (or a setClaudeCliVersion pin), then retry — the stored sign-in is still valid." + detail, "PROVIDER_ERROR", options);
|
|
57720
|
+
if (failure.kind === "request" && isHttpContextOverflow(failure.status, failure.message)) return new LlmError$1("Claude(订阅) context window exceeded." + detail, CONTEXT_OVERFLOW_CODE, options);
|
|
57655
57721
|
switch (failure.kind) {
|
|
57656
|
-
case "credential": return new LlmError("Claude(订阅) rejected the stored credential. Sign in again from Settings > Claude." + detail, "INVALID_CREDENTIAL", options);
|
|
57722
|
+
case "credential": return new LlmError$1("Claude(订阅) rejected the stored credential. Sign in again from Settings > Claude." + detail, "INVALID_CREDENTIAL", options);
|
|
57657
57723
|
case "rate_limit_account":
|
|
57658
|
-
case "rate_limit_global": return new LlmError("Claude(订阅) rate limit reached" + (failure.accountScoped ? " for this account" : "") + (failure.resetsAt === null ? "" : ", resets at " + failure.resetsAt) + ". Check the quota card in Settings > Claude." + detail, "RATE_LIMIT", options);
|
|
57659
|
-
case "overloaded": return new LlmError("Claude(订阅) is temporarily overloaded." + detail, "SERVER", options);
|
|
57660
|
-
case "server": return new LlmError("Claude(订阅) upstream server error (" + failure.status + ")." + detail, "SERVER", options);
|
|
57661
|
-
case "request": return new LlmError("Claude(订阅) rejected the request." + detail, "PROVIDER_ERROR", options);
|
|
57662
|
-
default: return new LlmError("Claude(订阅) request failed before a response arrived." + detail, "TRANSPORT", options);
|
|
57724
|
+
case "rate_limit_global": return new LlmError$1("Claude(订阅) rate limit reached" + (failure.accountScoped ? " for this account" : "") + (failure.resetsAt === null ? "" : ", resets at " + failure.resetsAt) + ". Check the quota card in Settings > Claude." + detail, "RATE_LIMIT", options);
|
|
57725
|
+
case "overloaded": return new LlmError$1("Claude(订阅) is temporarily overloaded." + detail, "SERVER", options);
|
|
57726
|
+
case "server": return new LlmError$1("Claude(订阅) upstream server error (" + failure.status + ")." + detail, "SERVER", options);
|
|
57727
|
+
case "request": return new LlmError$1("Claude(订阅) rejected the request." + detail, "PROVIDER_ERROR", options);
|
|
57728
|
+
default: return new LlmError$1("Claude(订阅) request failed before a response arrived." + detail, "TRANSPORT", options);
|
|
57663
57729
|
}
|
|
57664
57730
|
}
|
|
57665
57731
|
//#endregion
|
|
@@ -64445,7 +64511,7 @@ function glmCooldownDecision(input) {
|
|
|
64445
64511
|
function requireWire(modelId, entry) {
|
|
64446
64512
|
const wire = entry.wire;
|
|
64447
64513
|
if (wire === "anthropic" || wire === "openai") return wire;
|
|
64448
|
-
throw new LlmError("GLM(ZCode 账号) 的模型目录里没有 " + modelId + " 的协议声明,无法选择调用面。请在设置页刷新模型目录;若这是上游新增的模型,本插件还没记录它走哪个面。", "NOT_FOUND");
|
|
64514
|
+
throw new LlmError$1("GLM(ZCode 账号) 的模型目录里没有 " + modelId + " 的协议声明,无法选择调用面。请在设置页刷新模型目录;若这是上游新增的模型,本插件还没记录它走哪个面。", "NOT_FOUND");
|
|
64449
64515
|
}
|
|
64450
64516
|
/**
|
|
64451
64517
|
* 构造一次请求。**不联网、不读设置**,所以可以被单独测。
|
|
@@ -64569,7 +64635,7 @@ var GlmCodingPlanAdapter = class extends LlmAdapter {
|
|
|
64569
64635
|
};
|
|
64570
64636
|
}
|
|
64571
64637
|
const stored = await this.store.read();
|
|
64572
|
-
if (stored === null) throw new LlmError("还没有登录 GLM(ZCode 账号) 账号。请在设置页点击登录,或先在 ZCode 客户端登录后使用 adopt。", "MISSING_CREDENTIAL");
|
|
64638
|
+
if (stored === null) throw new LlmError$1("还没有登录 GLM(ZCode 账号) 账号。请在设置页点击登录,或先在 ZCode 客户端登录后使用 adopt。", "MISSING_CREDENTIAL");
|
|
64573
64639
|
return {
|
|
64574
64640
|
accountId: null,
|
|
64575
64641
|
credentials: stored
|
|
@@ -64591,7 +64657,7 @@ var GlmCodingPlanAdapter = class extends LlmAdapter {
|
|
|
64591
64657
|
}));
|
|
64592
64658
|
}
|
|
64593
64659
|
async resolveModel(provider, model, signal) {
|
|
64594
|
-
if (signal?.aborted) throw new LlmError(t("glm.modelResolveAborted", { provider: PROVIDER_NAME$1 }), "ABORTED");
|
|
64660
|
+
if (signal?.aborted) throw new LlmError$1(t("glm.modelResolveAborted", { provider: PROVIDER_NAME$1 }), "ABORTED");
|
|
64595
64661
|
const settings = await this.settings();
|
|
64596
64662
|
const region = await this.catalogRegion(settings) ?? "intl";
|
|
64597
64663
|
const entry = resolveGlmModel(model, this.catalog(region));
|
|
@@ -64660,8 +64726,8 @@ var GlmCodingPlanAdapter = class extends LlmAdapter {
|
|
|
64660
64726
|
});
|
|
64661
64727
|
activity?.pulse();
|
|
64662
64728
|
} catch (error) {
|
|
64663
|
-
if (signal.aborted) throw new LlmError(t("glm.requestAborted", { provider: PROVIDER_NAME$1 }), "ABORTED", { cause: error });
|
|
64664
|
-
throw new LlmError(t("glm.requestFailed", {
|
|
64729
|
+
if (signal.aborted) throw new LlmError$1(t("glm.requestAborted", { provider: PROVIDER_NAME$1 }), "ABORTED", { cause: error });
|
|
64730
|
+
throw new LlmError$1(t("glm.requestFailed", {
|
|
64665
64731
|
provider: PROVIDER_NAME$1,
|
|
64666
64732
|
detail: error instanceof Error ? error.message : String(error)
|
|
64667
64733
|
}), "TRANSPORT", { cause: error });
|
|
@@ -64701,8 +64767,8 @@ var GlmCodingPlanAdapter = class extends LlmAdapter {
|
|
|
64701
64767
|
throw failure;
|
|
64702
64768
|
}
|
|
64703
64769
|
const settled = plan;
|
|
64704
|
-
if (response === void 0) throw new LlmError(t("glm.noResponse", { provider: PROVIDER_NAME$1 }), "PROVIDER_ERROR");
|
|
64705
|
-
if (response.body === null) throw new LlmError(t("glm.emptyBody", { provider: PROVIDER_NAME$1 }), "PROVIDER_ERROR");
|
|
64770
|
+
if (response === void 0) throw new LlmError$1(t("glm.noResponse", { provider: PROVIDER_NAME$1 }), "PROVIDER_ERROR");
|
|
64771
|
+
if (response.body === null) throw new LlmError$1(t("glm.emptyBody", { provider: PROVIDER_NAME$1 }), "PROVIDER_ERROR");
|
|
64706
64772
|
const reader = response.body.getReader();
|
|
64707
64773
|
const decoder = new TextDecoder();
|
|
64708
64774
|
let buffer = "";
|
|
@@ -64725,7 +64791,7 @@ var GlmCodingPlanAdapter = class extends LlmAdapter {
|
|
|
64725
64791
|
buffer += decoder.decode();
|
|
64726
64792
|
if (buffer.trim() !== "") for (const line of buffer.split("\n")) for (const chunk of processGlmAnthropicStreamLine(line, state)) yield chunk;
|
|
64727
64793
|
if (state.finished) return;
|
|
64728
|
-
if (!glmStreamHasContent(state)) throw new LlmError(t("glm.anthropicEmpty", { provider: PROVIDER_NAME$1 }), "PROVIDER_ERROR");
|
|
64794
|
+
if (!glmStreamHasContent(state)) throw new LlmError$1(t("glm.anthropicEmpty", { provider: PROVIDER_NAME$1 }), "PROVIDER_ERROR");
|
|
64729
64795
|
assertGlmStreamComplete(state);
|
|
64730
64796
|
for (const chunk of closeGlmAnthropicStream(state)) yield chunk;
|
|
64731
64797
|
} finally {
|
|
@@ -69245,7 +69311,7 @@ var StepCodeAdapter = class extends LlmAdapter {
|
|
|
69245
69311
|
};
|
|
69246
69312
|
}
|
|
69247
69313
|
const stored = await this.store.read();
|
|
69248
|
-
if (stored === null) throw new LlmError("还没有登录 Step Code(Step Plan 订阅) 账号。请在设置页点击登录、在 stepcode 客户端登录后使用导入,或粘贴一个 Platform API Key。", "MISSING_CREDENTIAL");
|
|
69314
|
+
if (stored === null) throw new LlmError$1("还没有登录 Step Code(Step Plan 订阅) 账号。请在设置页点击登录、在 stepcode 客户端登录后使用导入,或粘贴一个 Platform API Key。", "MISSING_CREDENTIAL");
|
|
69249
69315
|
return {
|
|
69250
69316
|
accountId: null,
|
|
69251
69317
|
credentials: {
|
|
@@ -69297,7 +69363,7 @@ var StepCodeAdapter = class extends LlmAdapter {
|
|
|
69297
69363
|
}));
|
|
69298
69364
|
}
|
|
69299
69365
|
async resolveModel(provider, model, signal) {
|
|
69300
|
-
if (signal?.aborted) throw new LlmError(t("sc.modelResolveAborted", { provider: PROVIDER_NAME$6 }), "ABORTED");
|
|
69366
|
+
if (signal?.aborted) throw new LlmError$1(t("sc.modelResolveAborted", { provider: PROVIDER_NAME$6 }), "ABORTED");
|
|
69301
69367
|
const settings = await this.settings();
|
|
69302
69368
|
const picked = await this.credentialFor().catch(() => null);
|
|
69303
69369
|
const catalog = this.catalog(picked?.credentials.profile);
|
|
@@ -69367,8 +69433,8 @@ var StepCodeAdapter = class extends LlmAdapter {
|
|
|
69367
69433
|
});
|
|
69368
69434
|
activity?.pulse();
|
|
69369
69435
|
} catch (error) {
|
|
69370
|
-
if (signal.aborted) throw new LlmError(t("sc.requestAborted", { provider: PROVIDER_NAME$6 }), "ABORTED", { cause: error });
|
|
69371
|
-
throw new LlmError(t("sc.requestFailed", {
|
|
69436
|
+
if (signal.aborted) throw new LlmError$1(t("sc.requestAborted", { provider: PROVIDER_NAME$6 }), "ABORTED", { cause: error });
|
|
69437
|
+
throw new LlmError$1(t("sc.requestFailed", {
|
|
69372
69438
|
provider: PROVIDER_NAME$6,
|
|
69373
69439
|
detail: error instanceof Error ? error.message : String(error)
|
|
69374
69440
|
}), "TRANSPORT", { cause: error });
|
|
@@ -69394,8 +69460,8 @@ var StepCodeAdapter = class extends LlmAdapter {
|
|
|
69394
69460
|
}
|
|
69395
69461
|
throw failure;
|
|
69396
69462
|
}
|
|
69397
|
-
if (response === void 0) throw new LlmError(t("sc.noResponse", { provider: PROVIDER_NAME$6 }), "PROVIDER_ERROR");
|
|
69398
|
-
if (response.body === null) throw new LlmError(t("sc.emptyBody", { provider: PROVIDER_NAME$6 }), "PROVIDER_ERROR");
|
|
69463
|
+
if (response === void 0) throw new LlmError$1(t("sc.noResponse", { provider: PROVIDER_NAME$6 }), "PROVIDER_ERROR");
|
|
69464
|
+
if (response.body === null) throw new LlmError$1(t("sc.emptyBody", { provider: PROVIDER_NAME$6 }), "PROVIDER_ERROR");
|
|
69399
69465
|
const reader = response.body.getReader();
|
|
69400
69466
|
const decoder = new TextDecoder();
|
|
69401
69467
|
const state = createStreamState$2();
|
|
@@ -72872,7 +72938,7 @@ function serializeMessages(messages, images) {
|
|
|
72872
72938
|
* raised locally with the id that has no question.
|
|
72873
72939
|
*/
|
|
72874
72940
|
const answer = (callId, content) => {
|
|
72875
|
-
if (!awaiting.includes(callId)) throw new LlmError(`tool result for call "${callId}" has no tool_call awaiting it: the conversation cannot be expressed as a valid OpenAI message sequence`, "INVALID_REQUEST");
|
|
72941
|
+
if (!awaiting.includes(callId)) throw new LlmError$1(`tool result for call "${callId}" has no tool_call awaiting it: the conversation cannot be expressed as a valid OpenAI message sequence`, "INVALID_REQUEST");
|
|
72876
72942
|
wire.push({
|
|
72877
72943
|
role: "tool",
|
|
72878
72944
|
tool_call_id: callId,
|
|
@@ -73095,7 +73161,7 @@ async function* parseServerSentEvents$1(body) {
|
|
|
73095
73161
|
yield JSON.parse(payload);
|
|
73096
73162
|
} catch {}
|
|
73097
73163
|
}
|
|
73098
|
-
throw new LlmError("stream ended without [DONE]", "STREAM_CLOSED");
|
|
73164
|
+
throw new LlmError$1("stream ended without [DONE]", "STREAM_CLOSED");
|
|
73099
73165
|
}
|
|
73100
73166
|
/** Assemble the terminal content block for one open block. */
|
|
73101
73167
|
function closeBlock$1(block) {
|
|
@@ -73229,7 +73295,7 @@ async function* translate(payloads) {
|
|
|
73229
73295
|
return;
|
|
73230
73296
|
}
|
|
73231
73297
|
const chunk = unwrapEnvelope(payload);
|
|
73232
|
-
if (chunk.error !== void 0 && chunk.choices === void 0) throw new LlmError(errorText$1(chunk.error), streamErrorCode$1(errorText$1(chunk.error)));
|
|
73298
|
+
if (chunk.error !== void 0 && chunk.choices === void 0) throw new LlmError$1(errorText$1(chunk.error), streamErrorCode$1(errorText$1(chunk.error)));
|
|
73233
73299
|
const choices = Array.isArray(chunk.choices) ? chunk.choices : [];
|
|
73234
73300
|
for (const choice of choices) {
|
|
73235
73301
|
if (!isRecord$26(choice)) continue;
|
|
@@ -73304,7 +73370,7 @@ async function* translate(payloads) {
|
|
|
73304
73370
|
for (const chunk of closing()) yield chunk;
|
|
73305
73371
|
return;
|
|
73306
73372
|
}
|
|
73307
|
-
throw new LlmError("stream ended without [DONE]", "STREAM_CLOSED");
|
|
73373
|
+
throw new LlmError$1("stream ended without [DONE]", "STREAM_CLOSED");
|
|
73308
73374
|
}
|
|
73309
73375
|
//#endregion
|
|
73310
73376
|
//#region src/host/cline-pass/adapter.ts
|
|
@@ -73447,7 +73513,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73447
73513
|
}));
|
|
73448
73514
|
}
|
|
73449
73515
|
async resolveModel(provider, modelId, signal) {
|
|
73450
|
-
if (signal?.aborted) throw new LlmError("Cline Pass model resolution aborted", "ABORTED");
|
|
73516
|
+
if (signal?.aborted) throw new LlmError$1("Cline Pass model resolution aborted", "ABORTED");
|
|
73451
73517
|
const info = await this.modelInfo(modelId);
|
|
73452
73518
|
return {
|
|
73453
73519
|
provider,
|
|
@@ -73474,10 +73540,10 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73474
73540
|
yield* wrapStreamWithWatchdog((watchdogSignal, activity) => this.requestStream(options, settings, watchdogSignal, activity), options.signal, settings.streamIdleTimeoutMs, STREAM_IDLE_TIMEOUT_CODE$6, PROVIDER_NAME$5);
|
|
73475
73541
|
}
|
|
73476
73542
|
async *requestStream(rawOptions, settings, signal, activity) {
|
|
73477
|
-
if (settings.enabled === false) throw new LlmError(`${PROVIDER_NAME$5} is disabled in Settings > Subscription. Enable the line there, then retry.`, "INVALID_REQUEST");
|
|
73543
|
+
if (settings.enabled === false) throw new LlmError$1(`${PROVIDER_NAME$5} is disabled in Settings > Subscription. Enable the line there, then retry.`, "INVALID_REQUEST");
|
|
73478
73544
|
const normalized = normalizeGenerateOptions(rawOptions);
|
|
73479
73545
|
const images = await resolveRequestImages$1(normalized, this.options.attachments, signal).catch((error) => {
|
|
73480
|
-
if (signal.aborted) throw new LlmError("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73546
|
+
if (signal.aborted) throw new LlmError$1("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73481
73547
|
return NO_RESOLVED_IMAGES$3;
|
|
73482
73548
|
});
|
|
73483
73549
|
const options = offloadOldestRequestImages$1(normalized, void 0, images);
|
|
@@ -73514,7 +73580,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73514
73580
|
try {
|
|
73515
73581
|
release = await this.gate.acquire(account.id, upstream);
|
|
73516
73582
|
} catch (error) {
|
|
73517
|
-
if (signal.aborted) throw new LlmError("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73583
|
+
if (signal.aborted) throw new LlmError$1("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73518
73584
|
throw error;
|
|
73519
73585
|
}
|
|
73520
73586
|
const attemptLabel = "(auto)";
|
|
@@ -73530,13 +73596,13 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73530
73596
|
break;
|
|
73531
73597
|
} catch (error) {
|
|
73532
73598
|
headerDeadline.clear();
|
|
73533
|
-
if (signal.aborted) throw new LlmError("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73599
|
+
if (signal.aborted) throw new LlmError$1("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73534
73600
|
transportError = error;
|
|
73535
73601
|
if (transportTry < TRANSPORT_RETRIES$1 && isPreConnectionFailure$1(error)) {
|
|
73536
73602
|
try {
|
|
73537
73603
|
await setTimeout$1(TRANSPORT_RETRY_BASE_MS$1 * (transportTry + 1), void 0, { signal: upstream });
|
|
73538
73604
|
} catch (waitError) {
|
|
73539
|
-
if (signal.aborted) throw new LlmError("Cline Pass request aborted by caller", "ABORTED", { cause: waitError });
|
|
73605
|
+
if (signal.aborted) throw new LlmError$1("Cline Pass request aborted by caller", "ABORTED", { cause: waitError });
|
|
73540
73606
|
throw waitError;
|
|
73541
73607
|
}
|
|
73542
73608
|
continue;
|
|
@@ -73548,7 +73614,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73548
73614
|
const note = errorChain$2(transportError);
|
|
73549
73615
|
const hint = isPreConnectionFailure$1(transportError) ? ` The request never reached the gateway: ${account.baseURL} failed during TLS/connect. Check the network, proxy or TUN, or set a custom proxy in the plugin.` : "";
|
|
73550
73616
|
trace.push(attemptLabel);
|
|
73551
|
-
lastError = new LlmError(note + hint, "TRANSPORT", { cause: transportError });
|
|
73617
|
+
lastError = new LlmError$1(note + hint, "TRANSPORT", { cause: transportError });
|
|
73552
73618
|
continue;
|
|
73553
73619
|
}
|
|
73554
73620
|
if (!response.ok) {
|
|
@@ -73559,7 +73625,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73559
73625
|
} catch {}
|
|
73560
73626
|
trace.push(attemptLabel);
|
|
73561
73627
|
const code = streamErrorCode$1(detail, response.status);
|
|
73562
|
-
lastError = new LlmError(`${detail || `HTTP ${response.status}`} [model=${options.model}]`, code, { status: response.status });
|
|
73628
|
+
lastError = new LlmError$1(`${detail || `HTTP ${response.status}`} [model=${options.model}]`, code, { status: response.status });
|
|
73563
73629
|
if (code === "AUTH" || code === "QUOTA") {
|
|
73564
73630
|
refused.add(account.id);
|
|
73565
73631
|
await this.standDown(account.id, code, detail);
|
|
@@ -73578,7 +73644,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73578
73644
|
continue;
|
|
73579
73645
|
}
|
|
73580
73646
|
if (response.body === null) {
|
|
73581
|
-
lastError = new LlmError("gateway returned no response body", "EMPTY_RESPONSE", { status: response.status });
|
|
73647
|
+
lastError = new LlmError$1("gateway returned no response body", "EMPTY_RESPONSE", { status: response.status });
|
|
73582
73648
|
continue;
|
|
73583
73649
|
}
|
|
73584
73650
|
const observed = {
|
|
@@ -73628,9 +73694,9 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73628
73694
|
yield chunk;
|
|
73629
73695
|
}
|
|
73630
73696
|
} catch (error) {
|
|
73631
|
-
if (signal.aborted) throw new LlmError("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73632
|
-
const note = error instanceof LlmError ? error.message : errorChain$2(error);
|
|
73633
|
-
const code = error instanceof LlmError ? error.code : "TRANSPORT";
|
|
73697
|
+
if (signal.aborted) throw new LlmError$1("Cline Pass request aborted by caller", "ABORTED", { cause: error });
|
|
73698
|
+
const note = error instanceof LlmError$1 ? error.message : errorChain$2(error);
|
|
73699
|
+
const code = error instanceof LlmError$1 ? error.code : "TRANSPORT";
|
|
73634
73700
|
trace.push(attemptLabel);
|
|
73635
73701
|
if (yielded) {
|
|
73636
73702
|
this.store.record({
|
|
@@ -73646,7 +73712,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73646
73712
|
code,
|
|
73647
73713
|
account: account.name
|
|
73648
73714
|
});
|
|
73649
|
-
throw error instanceof LlmError ? error : new LlmError(note, "TRANSPORT", { cause: error });
|
|
73715
|
+
throw error instanceof LlmError$1 ? error : new LlmError$1(note, "TRANSPORT", { cause: error });
|
|
73650
73716
|
}
|
|
73651
73717
|
if (code === "AUTH" || code === "QUOTA") {
|
|
73652
73718
|
refused.add(account.id);
|
|
@@ -73666,7 +73732,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73666
73732
|
account: account.name
|
|
73667
73733
|
});
|
|
73668
73734
|
}
|
|
73669
|
-
lastError = error instanceof LlmError ? error : new LlmError(note, "TRANSPORT", { cause: error });
|
|
73735
|
+
lastError = error instanceof LlmError$1 ? error : new LlmError$1(note, "TRANSPORT", { cause: error });
|
|
73670
73736
|
continue;
|
|
73671
73737
|
} finally {
|
|
73672
73738
|
consumer.abort("Cline Pass stream consumer stopped");
|
|
@@ -73678,7 +73744,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73678
73744
|
try {
|
|
73679
73745
|
await setTimeout$1(EMPTY_REPLY_DELAY_MS, void 0, { signal });
|
|
73680
73746
|
} catch (waitError) {
|
|
73681
|
-
if (signal.aborted) throw new LlmError("Cline Pass request aborted by caller", "ABORTED", { cause: waitError });
|
|
73747
|
+
if (signal.aborted) throw new LlmError$1("Cline Pass request aborted by caller", "ABORTED", { cause: waitError });
|
|
73682
73748
|
throw waitError;
|
|
73683
73749
|
}
|
|
73684
73750
|
attemptIndex -= 1;
|
|
@@ -73740,7 +73806,7 @@ var ClinePassAdapter = class extends LlmAdapter {
|
|
|
73740
73806
|
error: message.slice(0, 200),
|
|
73741
73807
|
account: ""
|
|
73742
73808
|
});
|
|
73743
|
-
throw lastError ?? new LlmError(`${message} [model=${options.model}]`, "UPSTREAM");
|
|
73809
|
+
throw lastError ?? new LlmError$1(`${message} [model=${options.model}]`, "UPSTREAM");
|
|
73744
73810
|
}
|
|
73745
73811
|
}
|
|
73746
73812
|
/** Park an account that refused a request, for the reason it refused. */
|
|
@@ -79407,7 +79473,7 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
79407
79473
|
};
|
|
79408
79474
|
}
|
|
79409
79475
|
const stored = await this.store.read();
|
|
79410
|
-
if (stored === null) throw new LlmError("还没有登录 Qoder(订阅) 账号。请在设置页点击登录(全球区)、粘贴 PAT,或在本机 qodercli 登录后使用导入。", "MISSING_CREDENTIAL");
|
|
79476
|
+
if (stored === null) throw new LlmError$1("还没有登录 Qoder(订阅) 账号。请在设置页点击登录(全球区)、粘贴 PAT,或在本机 qodercli 登录后使用导入。", "MISSING_CREDENTIAL");
|
|
79411
79477
|
return {
|
|
79412
79478
|
accountId: null,
|
|
79413
79479
|
credentials: upstreamCredentialOf$1(stored)
|
|
@@ -79431,7 +79497,7 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
79431
79497
|
}));
|
|
79432
79498
|
}
|
|
79433
79499
|
async resolveModel(provider, model, signal) {
|
|
79434
|
-
if (signal?.aborted) throw new LlmError(t("qo.modelResolveAborted", { provider: PROVIDER_NAME$4 }), "ABORTED");
|
|
79500
|
+
if (signal?.aborted) throw new LlmError$1(t("qo.modelResolveAborted", { provider: PROVIDER_NAME$4 }), "ABORTED");
|
|
79435
79501
|
const settings = await this.settings();
|
|
79436
79502
|
const region = (await this.credentialFor().catch(() => null))?.credentials.region ?? "global";
|
|
79437
79503
|
const catalog = this.catalog(region);
|
|
@@ -79578,8 +79644,8 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
79578
79644
|
});
|
|
79579
79645
|
activity?.pulse();
|
|
79580
79646
|
} catch (error) {
|
|
79581
|
-
if (signal.aborted) throw new LlmError(t("qo.requestAborted", { provider: PROVIDER_NAME$4 }), "ABORTED", { cause: error });
|
|
79582
|
-
throw new LlmError(t("qo.requestFailed", {
|
|
79647
|
+
if (signal.aborted) throw new LlmError$1(t("qo.requestAborted", { provider: PROVIDER_NAME$4 }), "ABORTED", { cause: error });
|
|
79648
|
+
throw new LlmError$1(t("qo.requestFailed", {
|
|
79583
79649
|
provider: PROVIDER_NAME$4,
|
|
79584
79650
|
detail: error instanceof Error ? error.message : String(error)
|
|
79585
79651
|
}), "TRANSPORT", { cause: error });
|
|
@@ -79590,7 +79656,7 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
79590
79656
|
if (await handlePreContentFailure(failure, response.headers)) continue;
|
|
79591
79657
|
throw failure;
|
|
79592
79658
|
}
|
|
79593
|
-
if (response.body === null) throw new LlmError(t("qo.emptyBody", { provider: PROVIDER_NAME$4 }), "PROVIDER_ERROR");
|
|
79659
|
+
if (response.body === null) throw new LlmError$1(t("qo.emptyBody", { provider: PROVIDER_NAME$4 }), "PROVIDER_ERROR");
|
|
79594
79660
|
const reader = response.body.getReader();
|
|
79595
79661
|
const decoder = new TextDecoder();
|
|
79596
79662
|
const state = createQoderStreamState();
|
|
@@ -79626,7 +79692,7 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
79626
79692
|
}
|
|
79627
79693
|
return;
|
|
79628
79694
|
} catch (error) {
|
|
79629
|
-
if (!yielded && error instanceof LlmError) {
|
|
79695
|
+
if (!yielded && error instanceof LlmError$1) {
|
|
79630
79696
|
if (await handlePreContentFailure(error, response.headers)) continue;
|
|
79631
79697
|
}
|
|
79632
79698
|
throw error;
|
|
@@ -83562,7 +83628,7 @@ function serializeMessages$1(messages, images) {
|
|
|
83562
83628
|
};
|
|
83563
83629
|
/** A tool answer: it closes its own id, and the group when it was the last. */
|
|
83564
83630
|
const answer = (callId, content) => {
|
|
83565
|
-
if (!awaiting.includes(callId)) throw new LlmError(`OpenDesign request is invalid: the tool result for call id "${callId}" has no pending tool call to answer, so the message list would carry a tool message that no assistant tool_calls message introduced. Nothing was sent.`, "INVALID_REQUEST");
|
|
83631
|
+
if (!awaiting.includes(callId)) throw new LlmError$1(`OpenDesign request is invalid: the tool result for call id "${callId}" has no pending tool call to answer, so the message list would carry a tool message that no assistant tool_calls message introduced. Nothing was sent.`, "INVALID_REQUEST");
|
|
83566
83632
|
wire.push({
|
|
83567
83633
|
role: "tool",
|
|
83568
83634
|
tool_call_id: callId,
|
|
@@ -83914,7 +83980,7 @@ async function* parseServerSentEvents(body) {
|
|
|
83914
83980
|
yield JSON.parse(payload);
|
|
83915
83981
|
} catch {}
|
|
83916
83982
|
}
|
|
83917
|
-
throw new LlmError("stream ended without [DONE]", "STREAM_CLOSED");
|
|
83983
|
+
throw new LlmError$1("stream ended without [DONE]", "STREAM_CLOSED");
|
|
83918
83984
|
}
|
|
83919
83985
|
/**
|
|
83920
83986
|
* Whether one failure is the SSE parser's own "the body ended without [DONE]".
|
|
@@ -84050,7 +84116,7 @@ async function* translate$1(payloads) {
|
|
|
84050
84116
|
for (const chunk of terminal(reason)) yield chunk;
|
|
84051
84117
|
return;
|
|
84052
84118
|
}
|
|
84053
|
-
if (isErrorPayload(payload)) throw new LlmError(errorText(payload.error), streamErrorCode(errorText(payload.error)));
|
|
84119
|
+
if (isErrorPayload(payload)) throw new LlmError$1(errorText(payload.error), streamErrorCode(errorText(payload.error)));
|
|
84054
84120
|
const chunk = isRecord$17(payload) ? payload : {};
|
|
84055
84121
|
const choices = Array.isArray(chunk.choices) ? chunk.choices : [];
|
|
84056
84122
|
for (const choice of choices) {
|
|
@@ -84126,7 +84192,7 @@ async function* translate$1(payloads) {
|
|
|
84126
84192
|
for (const chunk of terminal(pendingFinish)) yield chunk;
|
|
84127
84193
|
return;
|
|
84128
84194
|
}
|
|
84129
|
-
throw new LlmError("stream ended without [DONE]", "STREAM_CLOSED");
|
|
84195
|
+
throw new LlmError$1("stream ended without [DONE]", "STREAM_CLOSED");
|
|
84130
84196
|
}
|
|
84131
84197
|
//#endregion
|
|
84132
84198
|
//#region src/host/opendesign/adapter.ts
|
|
@@ -84254,7 +84320,7 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84254
84320
|
}));
|
|
84255
84321
|
}
|
|
84256
84322
|
async resolveModel(provider, modelId, signal) {
|
|
84257
|
-
if (signal?.aborted) throw new LlmError("OpenDesign model resolution aborted", "ABORTED");
|
|
84323
|
+
if (signal?.aborted) throw new LlmError$1("OpenDesign model resolution aborted", "ABORTED");
|
|
84258
84324
|
const info = await this.modelInfo(modelId);
|
|
84259
84325
|
return {
|
|
84260
84326
|
provider,
|
|
@@ -84285,13 +84351,13 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84285
84351
|
}
|
|
84286
84352
|
/** The message the pool's empty state should raise, in this line's words. */
|
|
84287
84353
|
noAccountError(cause) {
|
|
84288
|
-
return new LlmError(`${PROVIDER_NAME$2} has no usable account: ${cause instanceof Error ? cause.message : String(cause)} Add an API key from the OpenDesign Cloud console in Settings > Subscription.`, "AUTH", { cause });
|
|
84354
|
+
return new LlmError$1(`${PROVIDER_NAME$2} has no usable account: ${cause instanceof Error ? cause.message : String(cause)} Add an API key from the OpenDesign Cloud console in Settings > Subscription.`, "AUTH", { cause });
|
|
84289
84355
|
}
|
|
84290
84356
|
async *requestStream(rawOptions, settings, signal, activity) {
|
|
84291
|
-
if (settings.enabled === false) throw new LlmError(`${PROVIDER_NAME$2} is disabled in Settings > Subscription. Enable the line there, then retry.`, "INVALID_REQUEST");
|
|
84357
|
+
if (settings.enabled === false) throw new LlmError$1(`${PROVIDER_NAME$2} is disabled in Settings > Subscription. Enable the line there, then retry.`, "INVALID_REQUEST");
|
|
84292
84358
|
const normalized = normalizeGenerateOptions(rawOptions);
|
|
84293
84359
|
const images = await resolveRequestImages$1(normalized, this.options.attachments, signal).catch((error) => {
|
|
84294
|
-
if (signal.aborted) throw new LlmError("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84360
|
+
if (signal.aborted) throw new LlmError$1("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84295
84361
|
return NO_RESOLVED_IMAGES$3;
|
|
84296
84362
|
});
|
|
84297
84363
|
const options = offloadOldestRequestImages$1(normalized, MAX_REQUEST_IMAGE_BYTES$1, images);
|
|
@@ -84316,7 +84382,7 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84316
84382
|
this.gate.setLimit(account.id, settings.maxConcurrentRequests);
|
|
84317
84383
|
release = await this.gate.acquire(account.id, upstream);
|
|
84318
84384
|
} catch (error) {
|
|
84319
|
-
if (signal.aborted) throw new LlmError("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84385
|
+
if (signal.aborted) throw new LlmError$1("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84320
84386
|
throw error;
|
|
84321
84387
|
}
|
|
84322
84388
|
try {
|
|
@@ -84337,13 +84403,13 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84337
84403
|
break;
|
|
84338
84404
|
} catch (error) {
|
|
84339
84405
|
headerDeadline.clear();
|
|
84340
|
-
if (signal.aborted) throw new LlmError("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84406
|
+
if (signal.aborted) throw new LlmError$1("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84341
84407
|
transportError = error;
|
|
84342
84408
|
if (transportTry < TRANSPORT_RETRIES && isPreConnectionFailure(error)) {
|
|
84343
84409
|
try {
|
|
84344
84410
|
await setTimeout$1(TRANSPORT_RETRY_BASE_MS * (transportTry + 1), void 0, { signal: upstream });
|
|
84345
84411
|
} catch (waitError) {
|
|
84346
|
-
if (signal.aborted) throw new LlmError("OpenDesign request aborted by caller", "ABORTED", { cause: waitError });
|
|
84412
|
+
if (signal.aborted) throw new LlmError$1("OpenDesign request aborted by caller", "ABORTED", { cause: waitError });
|
|
84347
84413
|
throw waitError;
|
|
84348
84414
|
}
|
|
84349
84415
|
continue;
|
|
@@ -84352,7 +84418,7 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84352
84418
|
}
|
|
84353
84419
|
}
|
|
84354
84420
|
if (response === void 0) {
|
|
84355
|
-
lastError = new LlmError(`${errorChain$1(transportError)} The request never reached the gateway: ${baseURL} failed during TLS/connect. Check the network or proxy.`, "TRANSPORT", { cause: transportError });
|
|
84421
|
+
lastError = new LlmError$1(`${errorChain$1(transportError)} The request never reached the gateway: ${baseURL} failed during TLS/connect. Check the network or proxy.`, "TRANSPORT", { cause: transportError });
|
|
84356
84422
|
break;
|
|
84357
84423
|
}
|
|
84358
84424
|
if (!response.ok) {
|
|
@@ -84367,7 +84433,7 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84367
84433
|
continue;
|
|
84368
84434
|
}
|
|
84369
84435
|
const code = streamErrorCode(detail, response.status);
|
|
84370
|
-
lastError = new LlmError(`${detail || `HTTP ${response.status}`} [model=${options.model}]`, code, { status: response.status });
|
|
84436
|
+
lastError = new LlmError$1(`${detail || `HTTP ${response.status}`} [model=${options.model}]`, code, { status: response.status });
|
|
84371
84437
|
if (code === "AUTH" || code === "QUOTA") {
|
|
84372
84438
|
refused.add(account.id);
|
|
84373
84439
|
await this.standDown(account.id, code, detail);
|
|
@@ -84380,7 +84446,7 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84380
84446
|
break;
|
|
84381
84447
|
}
|
|
84382
84448
|
if (response.body === null) {
|
|
84383
|
-
lastError = new LlmError("gateway returned no response body", "EMPTY_RESPONSE", { status: response.status });
|
|
84449
|
+
lastError = new LlmError$1("gateway returned no response body", "EMPTY_RESPONSE", { status: response.status });
|
|
84384
84450
|
break;
|
|
84385
84451
|
}
|
|
84386
84452
|
const iterator = translate$1(parseServerSentEvents(tapChunks(response.body, () => activity?.pulse())))[Symbol.asyncIterator]();
|
|
@@ -84393,17 +84459,17 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84393
84459
|
yield next.value;
|
|
84394
84460
|
}
|
|
84395
84461
|
} catch (error) {
|
|
84396
|
-
if (signal.aborted) throw new LlmError("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84397
|
-
const note = error instanceof LlmError ? error.message : errorChain$1(error);
|
|
84398
|
-
const code = error instanceof LlmError ? error.code : "TRANSPORT";
|
|
84399
|
-
if (yielded) throw error instanceof LlmError ? error : new LlmError(note, "TRANSPORT", { cause: error });
|
|
84462
|
+
if (signal.aborted) throw new LlmError$1("OpenDesign request aborted by caller", "ABORTED", { cause: error });
|
|
84463
|
+
const note = error instanceof LlmError$1 ? error.message : errorChain$1(error);
|
|
84464
|
+
const code = error instanceof LlmError$1 ? error.code : "TRANSPORT";
|
|
84465
|
+
if (yielded) throw error instanceof LlmError$1 ? error : new LlmError$1(note, "TRANSPORT", { cause: error });
|
|
84400
84466
|
if (code === "AUTH" || code === "QUOTA") {
|
|
84401
84467
|
refused.add(account.id);
|
|
84402
84468
|
await this.standDown(account.id, code, note);
|
|
84403
|
-
lastError = error instanceof LlmError ? error : new LlmError(note, "TRANSPORT", { cause: error });
|
|
84469
|
+
lastError = error instanceof LlmError$1 ? error : new LlmError$1(note, "TRANSPORT", { cause: error });
|
|
84404
84470
|
continue;
|
|
84405
84471
|
}
|
|
84406
|
-
lastError = error instanceof LlmError ? error : new LlmError(note, "TRANSPORT", { cause: error });
|
|
84472
|
+
lastError = error instanceof LlmError$1 ? error : new LlmError$1(note, "TRANSPORT", { cause: error });
|
|
84407
84473
|
break;
|
|
84408
84474
|
} finally {
|
|
84409
84475
|
consumer.abort("OpenDesign stream consumer stopped");
|
|
@@ -84415,7 +84481,7 @@ var OpenDesignAdapter = class extends LlmAdapter {
|
|
|
84415
84481
|
release();
|
|
84416
84482
|
}
|
|
84417
84483
|
}
|
|
84418
|
-
throw lastError ?? new LlmError(`no account could serve the request [model=${options.model}]`, "UPSTREAM");
|
|
84484
|
+
throw lastError ?? new LlmError$1(`no account could serve the request [model=${options.model}]`, "UPSTREAM");
|
|
84419
84485
|
}
|
|
84420
84486
|
/** Park an account that refused a request, for the reason it refused. */
|
|
84421
84487
|
async standDown(accountId, code, detail) {
|
|
@@ -89373,6 +89439,31 @@ function installCompactionPolicyGuard(ctx, options = {}) {
|
|
|
89373
89439
|
if (isRecord$11(optionsField)) observe(readString(optionsField["provider"]), readString(optionsField["model"]));
|
|
89374
89440
|
const config = source["config"];
|
|
89375
89441
|
if (isRecord$11(config)) observe(readString(config["provider"]), readString(config["model"]));
|
|
89442
|
+
const modelField = source["model"];
|
|
89443
|
+
if (isRecord$11(modelField) && typeof modelField["current"] === "function") {
|
|
89444
|
+
let current;
|
|
89445
|
+
try {
|
|
89446
|
+
current = modelField["current"].call(modelField);
|
|
89447
|
+
} catch {
|
|
89448
|
+
current = void 0;
|
|
89449
|
+
}
|
|
89450
|
+
if (isRecord$11(current)) observe(readString(current["provider"]), readString(current["model"]));
|
|
89451
|
+
}
|
|
89452
|
+
const messages = source["messages"];
|
|
89453
|
+
if (Array.isArray(messages)) for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
89454
|
+
const msg = messages[i];
|
|
89455
|
+
if (!isRecord$11(msg)) continue;
|
|
89456
|
+
const role = msg["role"];
|
|
89457
|
+
if (role !== void 0 && role !== "assistant") continue;
|
|
89458
|
+
const msgSource = msg["source"];
|
|
89459
|
+
if (!isRecord$11(msgSource)) continue;
|
|
89460
|
+
const provider = readString(msgSource["provider"]);
|
|
89461
|
+
const model = readString(msgSource["model"]);
|
|
89462
|
+
if (provider !== void 0 && model !== void 0) {
|
|
89463
|
+
observe(provider, model);
|
|
89464
|
+
break;
|
|
89465
|
+
}
|
|
89466
|
+
}
|
|
89376
89467
|
};
|
|
89377
89468
|
/**
|
|
89378
89469
|
* 读一个字符串字段。
|
|
@@ -93256,7 +93347,7 @@ Determine tier by semantic impact and uncertainty (write a brief "Tier + Rationa
|
|
|
93256
93347
|
- L1 Moderate: unambiguous module-local or mechanical multi-file work; edits at most 5 files (5 is a cap, not a range and not a target), no external contract break or unsettled product/UI decision, at most 2 open points. -> Ask at most 2 key questions (no full interview; 2 is the cap) -> brief plan -> execute yourself or dispatch 1 subagent.
|
|
93257
93348
|
- L2 Complex / Multi-step: cross-module/contract changes, multi-part work, unsettled decisions, or major irreversible risk. -> L2-Clear (settled, reversible): brief decision-complete plan -> R1 -> R6, without full interview/Plan Mode. L2-Governed (unsettled product/UI/external contract or major irreversible risk): R-G Interview -> R9 Plan & Approval -> R1 -> R6.
|
|
93258
93349
|
- [Stop by Impact, Not by Effort] Within Boundary, a subagent fixes all affected call sites, types, and tests, but pauses with status: hand_back immediately if a change would break an external contract, alter cross-module responsibilities, or require an unsettled product/UI decision—even for a single line.
|
|
93259
|
-
- [Execution Economy] Use one cheap probe, the smallest complete change, batched independent
|
|
93350
|
+
- [Execution Economy] Use one cheap probe, the smallest complete change, batched reads of known, independent paths (probe before reading unknown paths), and incremental edits; with no code/config change since a check passed, do not re-run that same equivalent check (still run distinct unexecuted checks such as typecheck/build). Stop after at most 2 consecutive model steps without progress to change approach or escalate; re-triage if complexity grows mid-task.
|
|
93260
93351
|
|
|
93261
93352
|
## R-G · Clarification Interview (L2-Governed Only, Before R9)
|
|
93262
93353
|
- G1 Design Tree & G2 Frontier: Model requirements as a decision dependency tree; ask the entire current frontier (decisions whose prerequisites are settled) in one round, wait for answers, and recompute. Never ask one question per round or dependent questions together.
|
|
@@ -93287,7 +93378,7 @@ Every task brief covers six elements: Goal / Boundary / Constraints / Limits (se
|
|
|
93287
93378
|
- [Limits] Each override states **what it bounds, in what unit, the cap, and whether it accumulates**. Use explicit caps ("at most 3 runs", "edits at most 5 files"), never ranges ("2–5 files"); silence is read as a limit of zero, and a quota that resets per cycle is lost, not banked. Do not ask the child to restate your rules back as a correctness check. Dispatch independent tasks concurrently through code_run Promise.all once decisions are settled.
|
|
93288
93379
|
|
|
93289
93380
|
## R6 · Lead Acceptance
|
|
93290
|
-
One acceptance layer owned by Lead: subagents supply implementation/evidence; Lead reads the final diff, checks every criterion, and runs risk-relevant verification. The completion notification is a post-hoc signal: a child stopped, not that the work passed.
|
|
93381
|
+
One acceptance layer owned by Lead: subagents supply implementation/evidence; Lead reads the final diff, checks every criterion, and runs risk-relevant verification without re-running an already-passed equivalent check when no code/config changed. The completion notification is a post-hoc signal: a child stopped, not that the work passed.
|
|
93291
93382
|
- 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). Only after the third run ends without acceptance, transition to R8 Fallback.
|
|
93292
93383
|
- [Non-Penalized hand_back] Clean status: hand_back with a valid hand_back_reason and no out-of-boundary mutation does not increment a failure count or trigger R8 by itself (each run still counts toward the 3-run cap). Re-scope or answer via send_message({ agent }) on the existing child to preserve its warm prefix cache.
|
|
93293
93384
|
- [Noticed but not handled] Every defect found in review: the defect goes back out on a re-dispatch with evidence or goes to the user via R-W (or fix and re-verify on Lead-Core/Hybrid core). Writing it into the delivery summary and shipping anyway is not an available outcome.
|
|
@@ -95140,6 +95231,8 @@ function pageValue(raw, refId, sessionId) {
|
|
|
95140
95231
|
const nextOffset = complete ? void 0 : numberOf$2(page.nextOffset);
|
|
95141
95232
|
const omitted = omittedCharsOf(page.omitted);
|
|
95142
95233
|
const totalChars = numberOf$2(page.totalChars);
|
|
95234
|
+
const matched = booleanOf$1(page.matched);
|
|
95235
|
+
const matchOffset = numberOf$2(page.matchOffset);
|
|
95143
95236
|
return {
|
|
95144
95237
|
ok: true,
|
|
95145
95238
|
action: "page",
|
|
@@ -95150,6 +95243,8 @@ function pageValue(raw, refId, sessionId) {
|
|
|
95150
95243
|
...nextOffset === void 0 ? {} : { nextOffset },
|
|
95151
95244
|
...omitted === void 0 ? {} : { omitted },
|
|
95152
95245
|
...totalChars === void 0 ? {} : { totalChars },
|
|
95246
|
+
...matched === void 0 ? {} : { matched },
|
|
95247
|
+
...matchOffset === void 0 ? {} : { matchOffset },
|
|
95153
95248
|
...text === void 0 ? {} : {
|
|
95154
95249
|
text,
|
|
95155
95250
|
chars: text.length
|
|
@@ -95172,7 +95267,7 @@ function createCacheWarmupResultTool(deps) {
|
|
|
95172
95267
|
name: CACHE_WARMUP_RESULT_TOOL,
|
|
95173
95268
|
description: [
|
|
95174
95269
|
"Read back a result that was replaced by a preview, using the `ref://<session>/<sha256>` handle written in that preview.",
|
|
95175
|
-
"Use `action: \"page\"` to read a slice: pass `offset
|
|
95270
|
+
"Use `action: \"page\"` to read a slice: pass `offset` (or `query` to locate a literal substring in text results), and optionally `limit`, `maxBytes`, `fields` and `equals`.",
|
|
95176
95271
|
"Keep slices small (a page defaults to 64 lines / 16 KB and is capped at 25 KB): every character a page returns is processed again on the next turn, so read only the slice you need.",
|
|
95177
95272
|
"Every page reports `complete`, `nextOffset`, `omitted` and `totalChars`, so you can see whether more remains instead of assuming a slice is the whole thing.",
|
|
95178
95273
|
"Use `action: \"release\"` when the stored copy is no longer needed."
|
|
@@ -95193,9 +95288,13 @@ function createCacheWarmupResultTool(deps) {
|
|
|
95193
95288
|
type: "integer",
|
|
95194
95289
|
description: "Where to start: a UTF-8 byte offset for text results, a row index for structured ones."
|
|
95195
95290
|
},
|
|
95291
|
+
query: {
|
|
95292
|
+
type: "string",
|
|
95293
|
+
description: "Case-sensitive literal substring to locate in a text result starting from `offset` (default 0); returns a page starting at the matched line, or `matched: false` when absent."
|
|
95294
|
+
},
|
|
95196
95295
|
limit: {
|
|
95197
95296
|
type: "integer",
|
|
95198
|
-
description: "Maximum number of
|
|
95297
|
+
description: "Maximum number of lines (text) or rows (structured) in this page."
|
|
95199
95298
|
},
|
|
95200
95299
|
maxBytes: {
|
|
95201
95300
|
type: "integer",
|
|
@@ -95258,6 +95357,14 @@ function createCacheWarmupResultTool(deps) {
|
|
|
95258
95357
|
type: "number",
|
|
95259
95358
|
description: "Characters in the whole stored result."
|
|
95260
95359
|
},
|
|
95360
|
+
matched: {
|
|
95361
|
+
type: "boolean",
|
|
95362
|
+
description: "Whether `query` matched in a text result."
|
|
95363
|
+
},
|
|
95364
|
+
matchOffset: {
|
|
95365
|
+
type: "number",
|
|
95366
|
+
description: "UTF-8 byte offset of the first `query` match."
|
|
95367
|
+
},
|
|
95261
95368
|
released: {
|
|
95262
95369
|
type: "boolean",
|
|
95263
95370
|
description: "Whether a stored copy was actually released."
|
|
@@ -95296,13 +95403,18 @@ function createCacheWarmupResultTool(deps) {
|
|
|
95296
95403
|
text: value.released === true ? "Released " + value.refId + ". The preview in your history is unchanged; it can no longer be read back." : "Nothing stored for " + value.refId + "; nothing to release."
|
|
95297
95404
|
}];
|
|
95298
95405
|
const at = value.offset ?? 0;
|
|
95299
|
-
const span = typeof value.chars === "number" ? value.chars + " chars" : "no content";
|
|
95300
95406
|
const total = typeof value.totalChars === "number" ? " of " + value.totalChars : "";
|
|
95407
|
+
if (value.matched === false) return [{
|
|
95408
|
+
type: "text",
|
|
95409
|
+
text: value.refId + " from offset " + at + " — no match found" + total + ", complete\n\n(no match)"
|
|
95410
|
+
}];
|
|
95411
|
+
const span = typeof value.chars === "number" ? value.chars + " chars" : "no content";
|
|
95412
|
+
const matchNote = value.matched === true && typeof value.matchOffset === "number" ? " (matched at offset " + value.matchOffset + ")" : "";
|
|
95301
95413
|
const tail = value.complete === true ? "complete" : "more remains" + (typeof value.nextOffset === "number" ? ", continue at offset " + value.nextOffset : "") + (typeof value.omitted === "number" ? ", " + value.omitted + " chars omitted" : "");
|
|
95302
95414
|
const body = typeof value.text === "string" && value.text !== "" ? value.text : "(empty page)";
|
|
95303
95415
|
return [{
|
|
95304
95416
|
type: "text",
|
|
95305
|
-
text: value.refId + " from offset " + at + " — " + span + total + ", " + tail + "\n\n" + body
|
|
95417
|
+
text: value.refId + " from offset " + at + matchNote + " — " + span + total + ", " + tail + "\n\n" + body
|
|
95306
95418
|
}];
|
|
95307
95419
|
}
|
|
95308
95420
|
},
|
|
@@ -95345,11 +95457,13 @@ function createCacheWarmupResultTool(deps) {
|
|
|
95345
95457
|
["limit", args.limit],
|
|
95346
95458
|
["maxBytes", args.maxBytes]
|
|
95347
95459
|
]) if (value !== void 0 && !isCount(value)) return failure(action, refId, sessionId, "BAD_ARGUMENT", name + " must be a non-negative integer");
|
|
95460
|
+
if (args.query !== void 0 && (typeof args.query !== "string" || args.query === "")) return failure(action, refId, sessionId, "BAD_ARGUMENT", "query must be a non-empty string");
|
|
95348
95461
|
const request = {
|
|
95349
95462
|
sessionId,
|
|
95350
95463
|
refId
|
|
95351
95464
|
};
|
|
95352
95465
|
if (args.offset !== void 0) request.offset = args.offset;
|
|
95466
|
+
if (args.query !== void 0) request.query = args.query;
|
|
95353
95467
|
if (args.limit !== void 0) request.limit = args.limit;
|
|
95354
95468
|
if (args.maxBytes !== void 0) request.maxBytes = args.maxBytes;
|
|
95355
95469
|
if (args.fields !== void 0) request.fields = args.fields;
|
|
@@ -95485,7 +95599,7 @@ const CACHE_WARMUP_GUIDANCE = [
|
|
|
95485
95599
|
"On large `run_code`/`code_run` results this line may replace the output with a preview: a short description plus one or more `ref://<session>/<sha256>` handles.",
|
|
95486
95600
|
"",
|
|
95487
95601
|
"- A preview is **not** the full result. It states `complete`, `omitted` and `nextOffset` explicitly; treat an incomplete preview as incomplete data, not as the whole output.",
|
|
95488
|
-
"- To read the original, call `cache_warmup_result` with `action: \"page\"` and that `refId
|
|
95602
|
+
"- To read the original, call `cache_warmup_result` with `action: \"page\"` and that `refId` (pass `query` to jump directly to a literal keyword/error in text logs, or follow `offset` / `nextOffset` until `complete` is true).",
|
|
95489
95603
|
"- Page in small slices (`limit` around 64-120 lines, `maxBytes` at most 8-16 KB) and read only the slice you actually need. Reading a whole stored result back in one call re-sends what the preview just saved.",
|
|
95490
95604
|
"- `action: \"release\"` drops the stored copy. The preview already in the conversation stays identical; it simply can no longer be read back.",
|
|
95491
95605
|
"- Source code, type and contract definitions, mixed evidence and anything that could not be parsed reliably are never replaced: they arrive in full.",
|
|
@@ -101036,11 +101150,11 @@ async function refreshCredentials(credentials, options = {}) {
|
|
|
101036
101150
|
const text = await response.text().catch(() => "");
|
|
101037
101151
|
if (!response.ok) {
|
|
101038
101152
|
const detail = text.slice(0, 200);
|
|
101039
|
-
throw new LlmError(`${PROVIDER_NAME$3} token refresh failed (${response.status})${detail ? `: ${detail}` : ""}`, response.status === 401 || response.status === 403 ? "INVALID_CREDENTIAL" : "TRANSPORT", { status: response.status });
|
|
101153
|
+
throw new LlmError$1(`${PROVIDER_NAME$3} token refresh failed (${response.status})${detail ? `: ${detail}` : ""}`, response.status === 401 || response.status === 403 ? "INVALID_CREDENTIAL" : "TRANSPORT", { status: response.status });
|
|
101040
101154
|
}
|
|
101041
101155
|
const payload = asRecord(JSON.parse(text));
|
|
101042
101156
|
const data = asRecord(payload?.data);
|
|
101043
|
-
if (payload === void 0 || payload.code !== 0 || data === void 0) throw new LlmError(`${PROVIDER_NAME$3} token refresh was rejected: ${asString(payload?.msg) ?? "no detail"}`, "INVALID_CREDENTIAL");
|
|
101157
|
+
if (payload === void 0 || payload.code !== 0 || data === void 0) throw new LlmError$1(`${PROVIDER_NAME$3} token refresh was rejected: ${asString(payload?.msg) ?? "no detail"}`, "INVALID_CREDENTIAL");
|
|
101044
101158
|
const accessToken = asString(data.accessToken);
|
|
101045
101159
|
if (accessToken === void 0) throw new Error(`${PROVIDER_NAME$3} token refresh returned no access token`);
|
|
101046
101160
|
const expiresIn = asNumber(data.expiresIn);
|
|
@@ -101673,7 +101787,7 @@ var WorkBuddyAdapter = class extends LlmAdapter {
|
|
|
101673
101787
|
}));
|
|
101674
101788
|
}
|
|
101675
101789
|
async resolveModel(provider, modelId, signal) {
|
|
101676
|
-
if (signal?.aborted) throw new LlmError("WorkBuddy model resolution aborted", "ABORTED");
|
|
101790
|
+
if (signal?.aborted) throw new LlmError$1("WorkBuddy model resolution aborted", "ABORTED");
|
|
101677
101791
|
const settings = await this.settings();
|
|
101678
101792
|
const credentials = await this.credentials(settings);
|
|
101679
101793
|
const catalog = credentials === null ? FALLBACK_MODELS$1 : await this.catalog(credentials);
|
|
@@ -101804,7 +101918,7 @@ var WorkBuddyAdapter = class extends LlmAdapter {
|
|
|
101804
101918
|
if (pool === null) {
|
|
101805
101919
|
const currentSettings = await this.settings();
|
|
101806
101920
|
const stored = await this.credentials(currentSettings);
|
|
101807
|
-
if (stored === null) throw new LlmError(`Not signed in to ${PROVIDER_NAME$3}. Sign in with the CodeBuddy desktop client; this route reads its credential from the local auth directory.`, "MISSING_CREDENTIAL");
|
|
101921
|
+
if (stored === null) throw new LlmError$1(`Not signed in to ${PROVIDER_NAME$3}. Sign in with the CodeBuddy desktop client; this route reads its credential from the local auth directory.`, "MISSING_CREDENTIAL");
|
|
101808
101922
|
credentials = await this.store.ensureFresh(stored, (current) => refreshCredentials(current, { fetchFn }));
|
|
101809
101923
|
} else {
|
|
101810
101924
|
let effective;
|
|
@@ -101812,8 +101926,8 @@ var WorkBuddyAdapter = class extends LlmAdapter {
|
|
|
101812
101926
|
effective = await pool.getEffectiveCredential(tried, fetchFn, options.model);
|
|
101813
101927
|
} catch (error) {
|
|
101814
101928
|
if (isPoolPausedError(error)) throw error;
|
|
101815
|
-
if (error instanceof LlmError) throw error;
|
|
101816
|
-
throw new LlmError(error instanceof Error ? error.message : `Not signed in to ${PROVIDER_NAME$3}.`, "MISSING_CREDENTIAL", { cause: error });
|
|
101929
|
+
if (error instanceof LlmError$1) throw error;
|
|
101930
|
+
throw new LlmError$1(error instanceof Error ? error.message : `Not signed in to ${PROVIDER_NAME$3}.`, "MISSING_CREDENTIAL", { cause: error });
|
|
101817
101931
|
}
|
|
101818
101932
|
accountId = effective.account.id;
|
|
101819
101933
|
servedAccountId = accountId;
|
|
@@ -101855,8 +101969,8 @@ var WorkBuddyAdapter = class extends LlmAdapter {
|
|
|
101855
101969
|
});
|
|
101856
101970
|
activity?.pulse();
|
|
101857
101971
|
} catch (error) {
|
|
101858
|
-
if (signal.aborted) throw new LlmError("WorkBuddy request aborted", "ABORTED", { cause: error });
|
|
101859
|
-
throw new LlmError(`WorkBuddy request failed: ${error instanceof Error ? error.message : String(error)}`, "TRANSPORT", { cause: error });
|
|
101972
|
+
if (signal.aborted) throw new LlmError$1("WorkBuddy request aborted", "ABORTED", { cause: error });
|
|
101973
|
+
throw new LlmError$1(`WorkBuddy request failed: ${error instanceof Error ? error.message : String(error)}`, "TRANSPORT", { cause: error });
|
|
101860
101974
|
}
|
|
101861
101975
|
if (response.ok) break;
|
|
101862
101976
|
refusedStatus = response.status;
|
|
@@ -101885,7 +101999,7 @@ var WorkBuddyAdapter = class extends LlmAdapter {
|
|
|
101885
101999
|
credentials = pool !== null && accountId !== void 0 ? await pool.renewCredential(accountId, fetchFn, credentials) : await this.store.renew(credentials, (current) => refreshCredentials(current, { fetchFn }));
|
|
101886
102000
|
} catch (error) {
|
|
101887
102001
|
if (isPoolPausedError(error)) throw error;
|
|
101888
|
-
const verdict = error instanceof LlmError ? error : new LlmError(`${PROVIDER_NAME$3} credential could not be renewed after the service refused it: ${error instanceof Error ? error.message : String(error)}`, "INVALID_CREDENTIAL", { cause: error });
|
|
102002
|
+
const verdict = error instanceof LlmError$1 ? error : new LlmError$1(`${PROVIDER_NAME$3} credential could not be renewed after the service refused it: ${error instanceof Error ? error.message : String(error)}`, "INVALID_CREDENTIAL", { cause: error });
|
|
101889
102003
|
if (pool !== null && await pool.hasAnotherAvailableAccount(tried)) continue rotation;
|
|
101890
102004
|
throw verdict;
|
|
101891
102005
|
}
|
|
@@ -101921,8 +102035,8 @@ var WorkBuddyAdapter = class extends LlmAdapter {
|
|
|
101921
102035
|
}
|
|
101922
102036
|
throw failure;
|
|
101923
102037
|
}
|
|
101924
|
-
if (response === void 0) throw new LlmError("WorkBuddy produced no response", "PROVIDER_ERROR");
|
|
101925
|
-
if (response.body === null) throw new LlmError("WorkBuddy returned an empty response body", "PROVIDER_ERROR");
|
|
102038
|
+
if (response === void 0) throw new LlmError$1("WorkBuddy produced no response", "PROVIDER_ERROR");
|
|
102039
|
+
if (response.body === null) throw new LlmError$1("WorkBuddy returned an empty response body", "PROVIDER_ERROR");
|
|
101926
102040
|
const recorded = { tokens: 0 };
|
|
101927
102041
|
try {
|
|
101928
102042
|
if (servedProtocol === "anthropic-messages") {
|
|
@@ -102019,7 +102133,7 @@ const SIGNATURE_REFUSED_CODE = 11159;
|
|
|
102019
102133
|
* from the service, and no retry can help.
|
|
102020
102134
|
*/
|
|
102021
102135
|
function accountRestrictedFailure(detail, status) {
|
|
102022
|
-
return new LlmError(`${PROVIDER_NAME$3} barred this account (11140): the subscription refused to serve it at all, which is not a model park and not a usage window. Every model of this account is affected; use another account or have this one released by the service.${detail ? ` ${detail}` : ""}`, "ACCOUNT_RESTRICTED", { status });
|
|
102136
|
+
return new LlmError$1(`${PROVIDER_NAME$3} barred this account (11140): the subscription refused to serve it at all, which is not a model park and not a usage window. Every model of this account is affected; use another account or have this one released by the service.${detail ? ` ${detail}` : ""}`, "ACCOUNT_RESTRICTED", { status });
|
|
102023
102137
|
}
|
|
102024
102138
|
/**
|
|
102025
102139
|
* Map one failed HTTP response onto a DSH failure.
|
|
@@ -102032,27 +102146,27 @@ function accountRestrictedFailure(detail, status) {
|
|
|
102032
102146
|
function classifyFailure$1(status, detail, headers) {
|
|
102033
102147
|
const code = readErrorCode(detail);
|
|
102034
102148
|
if (status === 401) {
|
|
102035
|
-
if (!namesRejectedCredential(detail)) return new LlmError(`${PROVIDER_NAME$3} refused this request once (401), and neither the renewed credential nor the replay changed that answer. The sign-in was NOT marked invalid: this endpoint also refuses a valid bearer, so a dead credential needs the token endpoint's own word before it is recorded.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102036
|
-
return new LlmError(`${PROVIDER_NAME$3} rejected the stored credential (401). Sign in again with the CodeBuddy desktop client.${detail ? ` ${detail}` : ""}`, "INVALID_CREDENTIAL", { status });
|
|
102149
|
+
if (!namesRejectedCredential(detail)) return new LlmError$1(`${PROVIDER_NAME$3} refused this request once (401), and neither the renewed credential nor the replay changed that answer. The sign-in was NOT marked invalid: this endpoint also refuses a valid bearer, so a dead credential needs the token endpoint's own word before it is recorded.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102150
|
+
return new LlmError$1(`${PROVIDER_NAME$3} rejected the stored credential (401). Sign in again with the CodeBuddy desktop client.${detail ? ` ${detail}` : ""}`, "INVALID_CREDENTIAL", { status });
|
|
102037
102151
|
}
|
|
102038
102152
|
if (status === 403) {
|
|
102039
|
-
if (refusalIsNotCredential(detail)) return new LlmError(`${PROVIDER_NAME$3} refused this request (403) before it reached the model: the refusal did not name a rejected credential, so it most likely came from a proxy, a gateway rule or another component on this lane rather than from the subscription. The stored credential was left untouched.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102040
|
-
return new LlmError(`${PROVIDER_NAME$3} rejected the stored credential (${status}). Sign in again with the CodeBuddy desktop client.${detail ? ` ${detail}` : ""}`, "INVALID_CREDENTIAL", { status });
|
|
102153
|
+
if (refusalIsNotCredential(detail)) return new LlmError$1(`${PROVIDER_NAME$3} refused this request (403) before it reached the model: the refusal did not name a rejected credential, so it most likely came from a proxy, a gateway rule or another component on this lane rather than from the subscription. The stored credential was left untouched.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102154
|
+
return new LlmError$1(`${PROVIDER_NAME$3} rejected the stored credential (${status}). Sign in again with the CodeBuddy desktop client.${detail ? ` ${detail}` : ""}`, "INVALID_CREDENTIAL", { status });
|
|
102041
102155
|
}
|
|
102042
102156
|
if (status === 429 || code === 6004 || code === 14003) {
|
|
102043
102157
|
const after = (headers ? retryAfterMs$1(headers) : void 0) ?? readRateLimitReset(detail);
|
|
102044
|
-
return new LlmError(`${PROVIDER_NAME$3} rate limit or plan quota reached. Check the quota card in Settings > WorkBuddy.${detail ? ` ${detail}` : ""}`, "RATE_LIMIT", {
|
|
102158
|
+
return new LlmError$1(`${PROVIDER_NAME$3} rate limit or plan quota reached. Check the quota card in Settings > WorkBuddy.${detail ? ` ${detail}` : ""}`, "RATE_LIMIT", {
|
|
102045
102159
|
status: status === 429 ? 429 : void 0,
|
|
102046
102160
|
...after === void 0 ? {} : { providerRetryAfterMs: after }
|
|
102047
102161
|
});
|
|
102048
102162
|
}
|
|
102049
|
-
if (code === 11102) return new LlmError(`${PROVIDER_NAME$3} does not serve this model for the signed-in account: it is either unavailable in the account's region or not included in its plan. Pick a different model in Settings > WorkBuddy.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102050
|
-
if (code === 11135 || code === 11133) return new LlmError(`${PROVIDER_NAME$3} rejected the request parameters (${code}). An image may be unsupported by this model or unreadable.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102163
|
+
if (code === 11102) return new LlmError$1(`${PROVIDER_NAME$3} does not serve this model for the signed-in account: it is either unavailable in the account's region or not included in its plan. Pick a different model in Settings > WorkBuddy.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102164
|
+
if (code === 11135 || code === 11133) return new LlmError$1(`${PROVIDER_NAME$3} rejected the request parameters (${code}). An image may be unsupported by this model or unreadable.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102051
102165
|
if (code === ERROR_CODE.ACCOUNT_RESTRICTED) return accountRestrictedFailure(detail, status);
|
|
102052
|
-
if (code === SIGNATURE_REFUSED_CODE) return new LlmError(`${PROVIDER_NAME$3} refused a thinking block's signature (11159). A replayed reasoning block whose signature this route did not produce cannot be verified, so it has to be dropped rather than replayed.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102053
|
-
if (code === 11128) return new LlmError(/conversation id|unapproved channel/i.test(detail) ? `${PROVIDER_NAME$3} blocked the request at its channel check (11128): the gateway did not accept it as an official client request. This is a plugin-side gap, not an account problem.${detail ? ` ${detail}` : ""}` : `${PROVIDER_NAME$3} rejected the message history: the conversation must open with a system prompt.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102054
|
-
if (status >= 500 || code === 11134) return new LlmError(`${PROVIDER_NAME$3} upstream server error (${status}): ${detail || "No response"}`, "SERVER", { status });
|
|
102055
|
-
return new LlmError(`${PROVIDER_NAME$3} API error (${status}): ${detail || "No response"}`, isHttpContextOverflow(status, detail) ? CONTEXT_OVERFLOW_CODE : "PROVIDER_ERROR", { status });
|
|
102166
|
+
if (code === SIGNATURE_REFUSED_CODE) return new LlmError$1(`${PROVIDER_NAME$3} refused a thinking block's signature (11159). A replayed reasoning block whose signature this route did not produce cannot be verified, so it has to be dropped rather than replayed.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102167
|
+
if (code === 11128) return new LlmError$1(/conversation id|unapproved channel/i.test(detail) ? `${PROVIDER_NAME$3} blocked the request at its channel check (11128): the gateway did not accept it as an official client request. This is a plugin-side gap, not an account problem.${detail ? ` ${detail}` : ""}` : `${PROVIDER_NAME$3} rejected the message history: the conversation must open with a system prompt.${detail ? ` ${detail}` : ""}`, "PROVIDER_ERROR", { status });
|
|
102168
|
+
if (status >= 500 || code === 11134) return new LlmError$1(`${PROVIDER_NAME$3} upstream server error (${status}): ${detail || "No response"}`, "SERVER", { status });
|
|
102169
|
+
return new LlmError$1(`${PROVIDER_NAME$3} API error (${status}): ${detail || "No response"}`, isHttpContextOverflow(status, detail) ? CONTEXT_OVERFLOW_CODE : "PROVIDER_ERROR", { status });
|
|
102056
102170
|
}
|
|
102057
102171
|
/**
|
|
102058
102172
|
* Whether a 403 body carries POSITIVE evidence that the refusal was not a
|
|
@@ -102182,7 +102296,7 @@ const WORKBUDDY_POOL_PAUSED_CODE = "WORKBUDDY_POOL_PAUSED";
|
|
|
102182
102296
|
* accounts" (wait for the pause, then sign the restricted ones in again) from
|
|
102183
102297
|
* "this request was rate limited". It is never reported as an upstream 429.
|
|
102184
102298
|
*/
|
|
102185
|
-
var WorkBuddyPoolPausedError = class extends LlmError {
|
|
102299
|
+
var WorkBuddyPoolPausedError = class extends LlmError$1 {
|
|
102186
102300
|
/** Unix milliseconds the pause lifts on its own; absent when nothing named one. */
|
|
102187
102301
|
pausedUntil;
|
|
102188
102302
|
constructor(message, pausedUntil) {
|
|
@@ -102491,7 +102605,7 @@ var WorkBuddyAccountPool = class extends AccountPoolCore {
|
|
|
102491
102605
|
if (refreshed.source === "desktop") await store.writeBack(refreshed);
|
|
102492
102606
|
return refreshed;
|
|
102493
102607
|
},
|
|
102494
|
-
refreshFailureStatus: (error) => error instanceof LlmError && error.code === "INVALID_CREDENTIAL" ? "expired" : void 0,
|
|
102608
|
+
refreshFailureStatus: (error) => error instanceof LlmError$1 && error.code === "INVALID_CREDENTIAL" ? "expired" : void 0,
|
|
102495
102609
|
extendSummary: (account, base, now) => ({
|
|
102496
102610
|
...base,
|
|
102497
102611
|
region: account.region ?? account.credentials.region,
|
|
@@ -104268,7 +104382,7 @@ const Config = z$1.object({
|
|
|
104268
104382
|
]).default("auto").volatile().description("进展更新的输出语言:auto 跟随对话语言,zh 中文,en 英文。"),
|
|
104269
104383
|
planModePipeline: z$1.boolean().default(true).volatile().description("启用计划模式管线:允许调度模式在澄清访谈收敛后用 enter_plan_mode 进入计划模式,放弃规划时用 leave_plan_mode 退出。"),
|
|
104270
104384
|
dispatchExecutionGuard: z$1.boolean().default(true).volatile().description("启用调度执行守卫:在执行期拦截子代理越权调用主控专用工具,并拦截等待子代理期间的纯 sleep 空等命令;不修改工具声明面,零损耗保护 Kimi 缓存。"),
|
|
104271
|
-
toolRunawayGuard: z$1.boolean().default(true).volatile().description("
|
|
104385
|
+
toolRunawayGuard: z$1.boolean().default(true).volatile().description("启用工具失控治理:对零增量病态信号(同名同参重复、同一工具连续同族报错、后台任务无变化轮询)分级提醒;Kimi 保留第 12 次同参强停,其他线路只提醒。"),
|
|
104272
104386
|
mediaTools: z$1.boolean().default(true).volatile().description("注册图片/视频工具:Codex 生图、Kimi 视频挂载、MiniMax 视频生成与理解;默认开启。修改后重载插件或重启 DSH,Kimi 既有会话在工具表变化后会重建一次前缀缓存。"),
|
|
104273
104387
|
teamPolicyCacheGuard: z$1.boolean().default(true).volatile().description("把内置 Agent Teams 的 team:policy 段从 system prompt 摘掉,改为开关切换时以尾部用户消息投递一次,避免中途开团队协作时刷掉整段前缀缓存;默认开启。"),
|
|
104274
104388
|
cacheWarmup: z$1.boolean().default(true).volatile().description(CACHE_WARMUP_SETTING_DESCRIPTION),
|
|
@@ -104355,7 +104469,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
104355
104469
|
const guard = installCompactionPolicyGuard(ctx);
|
|
104356
104470
|
return () => guard.dispose();
|
|
104357
104471
|
}, "dsh-chatgpt-subscription: compaction policy guard");
|
|
104358
|
-
ctx.effect(() => installMinimaxRuntimeEnhancements(ctx), "dsh-chatgpt-subscription: MiniMax runtime enhancements");
|
|
104472
|
+
ctx.effect(() => installMinimaxRuntimeEnhancements(ctx, { runawayEnabled: () => resolveToolRunawayGuardEnabled(pluginConfig) }), "dsh-chatgpt-subscription: MiniMax runtime enhancements");
|
|
104359
104473
|
ctx.effect(() => installKimiRepeatBreaker(ctx, {
|
|
104360
104474
|
providers: CONTROLLED_PROVIDERS.filter((provider) => provider !== "minimax-code"),
|
|
104361
104475
|
globalEnabled: () => resolveToolRunawayGuardEnabled(pluginConfig)
|