@eddyskywalker/dsh-chatgpt-subscription 1.3.0 → 1.4.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.
Files changed (47) hide show
  1. package/lib/advisor-contracts-BG7iEfUc.js +8 -0
  2. package/lib/client.js +24 -19
  3. package/lib/client.js.map +1 -1
  4. package/lib/codemode.js +2 -1
  5. package/lib/index.js +288 -92
  6. package/lib/{preset-sync-RBsYhDY3.js → preset-sync-DspdQkYN.js} +1 -8
  7. package/lib/{progress-updates-jiHnSAmz.js → progress-updates-ART24-8J.js} +81 -4
  8. package/lib/progress-updates.js +1 -1
  9. package/lib/{tool-result-pruner-Cd3sTkjl.js → tool-result-pruner-CuKHwU2R.js} +15 -6
  10. package/lib/tool-result-pruner.js +1 -1
  11. package/lib/types/client/features/progress-updates/contracts.d.ts +2 -0
  12. package/lib/types/client/features/progress-updates/contracts.d.ts.map +1 -1
  13. package/lib/types/client/features/progress-updates/dashboard.d.ts.map +1 -1
  14. package/lib/types/client/features/progress-updates/locales.d.ts +8 -2
  15. package/lib/types/client/features/progress-updates/locales.d.ts.map +1 -1
  16. package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
  17. package/lib/types/client/providers/claude/locales.d.ts +3 -3
  18. package/lib/types/client/providers/claude-api/locales.d.ts +2 -2
  19. package/lib/types/client/providers/kimi-code/locales.d.ts +3 -3
  20. package/lib/types/compat.d.ts +1 -1
  21. package/lib/types/host/providers/chatgpt-api/model-catalog.d.ts.map +1 -1
  22. package/lib/types/host/providers/claude-api/model-catalog.d.ts.map +1 -1
  23. package/lib/types/host/providers/longcat/model-catalog.d.ts.map +1 -1
  24. package/lib/types/host/providers/qianwen-token-plan/adapter.d.ts.map +1 -1
  25. package/lib/types/host/providers/qoder/mapper.d.ts.map +1 -1
  26. package/lib/types/host/providers/qoder/model-catalog.d.ts.map +1 -1
  27. package/lib/types/host/runtime/advisor/index.d.ts +4 -1
  28. package/lib/types/host/runtime/advisor/index.d.ts.map +1 -1
  29. package/lib/types/host/runtime/advisor/prompt.d.ts +14 -0
  30. package/lib/types/host/runtime/advisor/prompt.d.ts.map +1 -1
  31. package/lib/types/host/runtime/advisor/request.d.ts +3 -0
  32. package/lib/types/host/runtime/advisor/request.d.ts.map +1 -1
  33. package/lib/types/host/runtime/compact-after-turn/index.d.ts +22 -2
  34. package/lib/types/host/runtime/compact-after-turn/index.d.ts.map +1 -1
  35. package/lib/types/host/runtime/compaction-gate.d.ts +21 -0
  36. package/lib/types/host/runtime/compaction-gate.d.ts.map +1 -1
  37. package/lib/types/host/runtime/deepseek-v41-flash/index.d.ts +2 -1
  38. package/lib/types/host/runtime/deepseek-v41-flash/index.d.ts.map +1 -1
  39. package/lib/types/host/runtime/deepseek-v41-flash/match.d.ts +7 -5
  40. package/lib/types/host/runtime/deepseek-v41-flash/match.d.ts.map +1 -1
  41. package/lib/types/host/runtime/deepseek-v41-flash/reasoning-seed.d.ts.map +1 -1
  42. package/lib/types/host/runtime/progress-updates/projection.d.ts +6 -1
  43. package/lib/types/host/runtime/progress-updates/projection.d.ts.map +1 -1
  44. package/lib/types/host/runtime/progress-updates/store.d.ts +2 -0
  45. package/lib/types/host/runtime/progress-updates/store.d.ts.map +1 -1
  46. package/lib/types/index.d.ts.map +1 -1
  47. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { a as resolveProgressUpdatesSettings, n as attachProgressSettings } from "./progress-updates-jiHnSAmz.js";
1
+ import { a as resolveProgressUpdatesSettings, n as attachProgressSettings, o as PROGRESS_UPDATE_LANGUAGES } from "./progress-updates-ART24-8J.js";
2
+ import { n as ADVISOR_TOOL_TIMEOUT_MS, r as CONSULT_ADVISOR_TOOL_NAME, t as ADVISOR_STATE_PATH } from "./advisor-contracts-BG7iEfUc.js";
2
3
  import { h as resolvePlanModePipelineEnabled, l as attachPlanModePipelineSettings } from "./plan-mode-pipeline-DQ8TM6mP.js";
3
- import { a as ADVISOR_TOOL_TIMEOUT_MS, c as PLUGIN_MESSAGE_SOURCE_KIND, d as formatToolUpdateNotice, f as leadingSystemEndIndex, h as normalizeGenerateOptions, i as ADVISOR_STATE_PATH, l as extractSystemText, m as midConversationUpdateToUserMessage, n as installBundledPresets, o as CONSULT_ADVISOR_TOOL_NAME, p as midConversationSystemToUserMessage, r as resolvesFromHere, s as LlmError$1, u as formatMidConversationSystemReminder } from "./preset-sync-RBsYhDY3.js";
4
- import { A as isDeepSeekV41Flash, B as estimateCodexPayloadTokens, C as isOpenModelSessionPrefixCacheProtected, D as matchOpenModelScope, E as matchOpenModelProfile, F as checkpointFromMetadata, G as shouldCompactCodexPayload, H as latestCodexCompaction, I as checkpointFromOutputItems, K as withCodexCompactionTrigger, L as codexCompactionReplayMetadata, M as isDeepSeekV41FlashSession, N as readScopeRoute, O as matchOpenModelSession, P as readSessionRoute, R as codexRemoteCompactionEnabled, S as isOpenModelPrefixCacheProtected, T as isStepOpenModel, U as noteCodexRemoteCompactionFailure, V as isCompactionItem, W as projectFreshCodexCompaction, _ as isKimiOpenModel, b as isMinimaxOpenModel, d as OPEN_MODEL_PROFILES, f as bareOpenModelId, g as isKimiK31OpenModel, h as isGlm5OpenModel, j as isDeepSeekV41FlashScope, k as DEEPSEEK_OFFICIAL_PROVIDERS, l as resolveSkipProviders, m as isGlm54OpenModel, n as DEFAULT_SKIP_PROVIDERS, p as isDeepSeekV4NonV41Model, r as PRUNER_SERVICE_NAME, u as shouldSkipPruningForSession, v as isLongSparseOpenModel, w as isQwenOpenModel, x as isOpenModelCacheWarmupProtected, y as isMimoOpenModel, z as codexRemoteCompactionThreshold } from "./tool-result-pruner-Cd3sTkjl.js";
4
+ import { a as PLUGIN_MESSAGE_SOURCE_KIND, c as formatToolUpdateNotice, d as midConversationUpdateToUserMessage, f as normalizeGenerateOptions, i as LlmError$1, l as leadingSystemEndIndex, n as installBundledPresets, o as extractSystemText, r as resolvesFromHere, s as formatMidConversationSystemReminder, u as midConversationSystemToUserMessage } from "./preset-sync-DspdQkYN.js";
5
+ import { A as isDeepSeekV41Flash, B as estimateCodexPayloadTokens, C as isOpenModelSessionPrefixCacheProtected, D as matchOpenModelScope, E as matchOpenModelProfile, F as checkpointFromMetadata, G as shouldCompactCodexPayload, H as latestCodexCompaction, I as checkpointFromOutputItems, K as withCodexCompactionTrigger, L as codexCompactionReplayMetadata, M as isDeepSeekV41FlashSession, N as readScopeRoute, O as matchOpenModelSession, P as readSessionRoute, R as codexRemoteCompactionEnabled, S as isOpenModelPrefixCacheProtected, T as isStepOpenModel, U as noteCodexRemoteCompactionFailure, V as isCompactionItem, W as projectFreshCodexCompaction, _ as isKimiOpenModel, b as isMinimaxOpenModel, d as OPEN_MODEL_PROFILES, f as bareOpenModelId, g as isKimiK31OpenModel, h as isGlm5OpenModel, j as isDeepSeekV41FlashScope, k as DEEPSEEK_OFFICIAL_PROVIDERS, l as resolveSkipProviders, m as isGlm54OpenModel, n as DEFAULT_SKIP_PROVIDERS, p as isDeepSeekV4NonV41Model, r as PRUNER_SERVICE_NAME, u as shouldSkipPruningForSession, v as isLongSparseOpenModel, w as isQwenOpenModel, x as isOpenModelCacheWarmupProtected, y as isMimoOpenModel, z as codexRemoteCompactionThreshold } from "./tool-result-pruner-CuKHwU2R.js";
5
6
  import { C as isDelegatedCaller, S as installDispatchExecutionGuard, T as resolveDispatchExecutionGuardEnabled, _ as installPlanModeExitReminder, b as registeredPlanControllerActive, h as createPlanNotice, l as PLAN_PROJECTION_KEY, n as EXIT_PLAN_MODE, w as isDelegatedSession } from "./plan-mode-cY8pp0PZ.js";
6
7
  import { createRequire } from "node:module";
7
8
  import * as LlmModule from "@deepseek-ai/dsh-llm";
@@ -891,7 +892,7 @@ const ROUTE_PREFIX$6 = "/api/dsh-chatgpt-subscription";
891
892
  * `test/responses-client.test.ts` asserts the two agree, so a release that
892
893
  * forgets this constant fails the suite instead of shipping quietly.
893
894
  */
894
- const PLUGIN_VERSION = "1.3.0";
895
+ const PLUGIN_VERSION = "1.4.0";
895
896
  const CODEX_CHATGPT_PROVIDER_ID = "codex-chatgpt";
896
897
  const CODEX_API_BASE = "https://chatgpt.com/backend-api/codex";
897
898
  const CODEX_RESPONSES_URL = `${CODEX_API_BASE}/responses`;
@@ -8943,15 +8944,15 @@ function belowThreshold(threshold, contextTokens) {
8943
8944
  return threshold > 0 && contextTokens !== void 0 && contextTokens < threshold;
8944
8945
  }
8945
8946
  /**
8946
- * 主会话「全部任务完成后压缩」的判定。
8947
- * @param facts - 观测到的事实。
8948
- * @returns 跳过原因,或 undefined(压缩)。
8947
+ * 一次性「本轮结束后压缩」的线路策略。
8948
+ * @param facts - 线路开关、任务与阈值事实;undefined 表示没有线路策略。
8949
+ * @returns normal 表示按一次性开关原本的规则压缩;hold 表示继续等待任务;
8950
+ * compact 表示现在压缩并关闭;skip 表示关闭开关但不压缩。
8949
8951
  */
8950
- function taskCompleteSkipReason(facts) {
8951
- if (!facts.enabled) return "off";
8952
- if (facts.pendingWork) return "keepalive-pending";
8953
- if (facts.writtenTtlMs !== void 0 && facts.keepaliveTtlMs !== void 0 && facts.writtenTtlMs !== facts.keepaliveTtlMs) return "other-tier";
8954
- if (belowThreshold(facts.threshold, facts.contextTokens)) return "below-threshold";
8952
+ function armedTaskDecision(facts) {
8953
+ if (facts === void 0 || !facts.enabled) return "normal";
8954
+ if (facts.pendingWork) return "hold";
8955
+ return facts.eligible ? "compact" : "skip";
8955
8956
  }
8956
8957
  //#endregion
8957
8958
  //#region src/host/common/provider-route.ts
@@ -14169,32 +14170,18 @@ var CompactAfterTurnController = class {
14169
14170
  }
14170
14171
  if (state === void 0) return;
14171
14172
  if (state.phase === "armed") {
14173
+ if (state.autoChecking) return;
14172
14174
  if (state.lastTurnEnd === null) return;
14173
14175
  if (state.lastTurnEnd === "aborted") {
14174
14176
  state.lastTurnEnd = null;
14175
14177
  return;
14176
14178
  }
14177
- const compactNow = this.deps.compactor(agent);
14178
- if (compactNow === void 0) {
14179
- state.phase = "off";
14180
- state.lastTurnEnd = null;
14181
- state.last = {
14182
- kind: "failed",
14183
- detail: "This session has no compaction engine.",
14184
- at: this.now()
14185
- };
14179
+ if (this.deps.taskPolicy === void 0) {
14180
+ state.pendingTaskComplete = false;
14181
+ this.startArmedCompaction(id, state, agent);
14186
14182
  return;
14187
14183
  }
14188
- state.phase = "compacting";
14189
- state.lastTurnEnd = null;
14190
- state.autoTurnEnd = null;
14191
- state.pendingTaskComplete = false;
14192
- state.contended = false;
14193
- const abort = new AbortController();
14194
- state.abort = abort;
14195
- this.defer(() => {
14196
- this.run(id, state, agent, compactNow, abort, false);
14197
- });
14184
+ this.scheduleArmedCheck(id, state, agent);
14198
14185
  return;
14199
14186
  }
14200
14187
  if (state.phase !== "off" || this.deps.autoCompact === void 0) return;
@@ -14223,19 +14210,37 @@ var CompactAfterTurnController = class {
14223
14210
  }
14224
14211
  /**
14225
14212
  * External trigger: every delegated child and background job of this session
14226
- * has settled, so the wait-time keepalive no longer applies. The session
14227
- * compacts once at its next idle, or straight away when it already is.
14213
+ * has settled, so the wait-time keepalive no longer applies. Automatic child
14214
+ * compaction runs at the next idle; a manually armed main session is
14215
+ * re-evaluated only after a turn has already ended.
14228
14216
  * @param sessionId - the session whose delegation batch just drained.
14229
14217
  */
14230
14218
  requestTaskComplete(sessionId) {
14231
- if (this.disposed || sessionId === "" || this.deps.autoCompact === void 0) return;
14219
+ if (this.disposed || sessionId === "" || this.deps.autoCompact === void 0 && this.deps.taskPolicy === void 0) return;
14232
14220
  const agent = this.agents.get(sessionId);
14233
14221
  if (agent === void 0) return;
14234
14222
  const state = this.ensure(sessionId);
14223
+ if (state.phase === "armed") {
14224
+ state.pendingTaskComplete = true;
14225
+ if (state.autoChecking || this.statusById.get(sessionId) !== "idle" || state.lastTurnEnd === null) return;
14226
+ if (state.lastTurnEnd === "aborted") {
14227
+ state.lastTurnEnd = null;
14228
+ state.pendingTaskComplete = false;
14229
+ return;
14230
+ }
14231
+ if (this.deps.taskPolicy === void 0) {
14232
+ state.pendingTaskComplete = false;
14233
+ this.startArmedCompaction(sessionId, state, agent);
14234
+ return;
14235
+ }
14236
+ this.scheduleArmedCheck(sessionId, state, agent);
14237
+ return;
14238
+ }
14235
14239
  if (state.phase !== "off" || state.autoChecking || this.statusById.get(sessionId) !== "idle") {
14236
14240
  state.pendingTaskComplete = true;
14237
14241
  return;
14238
14242
  }
14243
+ if (this.deps.autoCompact === void 0) return;
14239
14244
  state.autoChecking = true;
14240
14245
  const expectedEpoch = state.epoch;
14241
14246
  this.defer(() => {
@@ -14266,6 +14271,72 @@ var CompactAfterTurnController = class {
14266
14271
  this.agents.clear();
14267
14272
  this.statusById.clear();
14268
14273
  }
14274
+ /** Take the manual one-shot path immediately; shared by normal and held triggers. */
14275
+ startArmedCompaction(id, state, agent) {
14276
+ const compactNow = this.deps.compactor(agent);
14277
+ if (compactNow === void 0) {
14278
+ state.phase = "off";
14279
+ state.lastTurnEnd = null;
14280
+ state.last = {
14281
+ kind: "failed",
14282
+ detail: "This session has no compaction engine.",
14283
+ at: this.now()
14284
+ };
14285
+ return;
14286
+ }
14287
+ state.phase = "compacting";
14288
+ state.lastTurnEnd = null;
14289
+ state.autoTurnEnd = null;
14290
+ state.pendingTaskComplete = false;
14291
+ state.contended = false;
14292
+ const abort = new AbortController();
14293
+ state.abort = abort;
14294
+ this.defer(() => {
14295
+ this.run(id, state, agent, compactNow, abort, false);
14296
+ });
14297
+ }
14298
+ /** Defer the armed policy read out of the status listener. */
14299
+ scheduleArmedCheck(id, state, agent) {
14300
+ if (this.disposed || state.autoChecking) return;
14301
+ state.pendingTaskComplete = false;
14302
+ state.autoChecking = true;
14303
+ const expectedEpoch = state.epoch;
14304
+ this.defer(() => {
14305
+ this.runArmedPolicy(id, state, agent, expectedEpoch);
14306
+ });
14307
+ }
14308
+ /**
14309
+ * Ask the line policy whether the armed switch should wait, compact, or skip.
14310
+ * A request that arrives while this read is in flight sets pendingTaskComplete
14311
+ * and is picked up again in the finally block instead of being lost.
14312
+ */
14313
+ async runArmedPolicy(id, state, agent, expectedEpoch) {
14314
+ try {
14315
+ if (this.disposed || this.sessions.get(id) !== state || state.phase !== "armed" || state.epoch !== expectedEpoch || this.agents.get(id) !== agent) return;
14316
+ let facts;
14317
+ try {
14318
+ facts = await this.deps.taskPolicy?.(agent);
14319
+ } catch {
14320
+ facts = void 0;
14321
+ }
14322
+ if (this.disposed || this.sessions.get(id) !== state || state.phase !== "armed" || state.epoch !== expectedEpoch || this.agents.get(id) !== agent) return;
14323
+ const decision = armedTaskDecision(facts);
14324
+ if (decision === "hold") return;
14325
+ if (decision === "skip") {
14326
+ state.phase = "off";
14327
+ state.lastTurnEnd = null;
14328
+ state.autoTurnEnd = null;
14329
+ state.pendingTaskComplete = false;
14330
+ return;
14331
+ }
14332
+ this.startArmedCompaction(id, state, agent);
14333
+ } finally {
14334
+ state.autoChecking = false;
14335
+ const again = state.phase === "armed" && state.pendingTaskComplete && state.lastTurnEnd !== null && state.lastTurnEnd !== "aborted" && this.statusById.get(id) === "idle" && !this.disposed && this.sessions.get(id) === state;
14336
+ this.pruneIdleState(id, state);
14337
+ if (again) this.scheduleArmedCheck(id, state, agent);
14338
+ }
14339
+ }
14269
14340
  async runAuto(id, state, agent, expectedEpoch) {
14270
14341
  try {
14271
14342
  if (this.disposed || this.sessions.get(id) !== state || state.phase !== "off" || state.epoch !== expectedEpoch || this.agents.get(id) !== agent) return;
@@ -14401,6 +14472,7 @@ function installCompactAfterTurn(host, options = {}) {
14401
14472
  const controller = new CompactAfterTurnController({
14402
14473
  compactor: (agent) => compactorOf(host, options, agent),
14403
14474
  autoCompact: options.autoCompact,
14475
+ taskPolicy: options.taskPolicy,
14404
14476
  logger: host.logger
14405
14477
  });
14406
14478
  try {
@@ -14497,6 +14569,26 @@ Rules:
14497
14569
  - Cite only evidence visible in the transcript. Do not claim to have read files, run commands, or verified anything that is not visible. Omitted-history markers are not evidence that the agent skipped work.
14498
14570
  - Do not demand commits, branches, extra documentation, or other process the user did not request.
14499
14571
  - If the agent is on track, say so after the review in one sentence. Keep the advice under 300 words unless the situation genuinely needs more.`;
14572
+ /**
14573
+ * 顾问反馈与进展更新共用同一个语言档位。
14574
+ *
14575
+ * 提示词本身是英文,但顾问的回复会直接成为一条进展正文,所以这里明确把输出
14576
+ * 语言钉在进展设置上;`auto` 跟随最近一条真人用户消息,而不是英文系统提示。
14577
+ */
14578
+ const ADVISOR_LANGUAGE_DIRECTIVES = {
14579
+ auto: "Write your advice in the language the human user is writing in, following the most recent user message; do not switch to English just because these instructions are in English.",
14580
+ zh: "Write your advice in Simplified Chinese, even when the conversation or these instructions are in another language.",
14581
+ en: "Write your advice in English, even when the conversation or these instructions are in another language.",
14582
+ ru: "Write your advice in Russian, even when the conversation or these instructions are in another language."
14583
+ };
14584
+ /**
14585
+ * 取一个语言档位对应的顾问输出指令。
14586
+ * @param language - 进展更新的语言档位。
14587
+ * @returns 追加给顾问系统提示的一句指令。
14588
+ */
14589
+ function advisorLanguageDirective(language) {
14590
+ return ADVISOR_LANGUAGE_DIRECTIVES[language] ?? ADVISOR_LANGUAGE_DIRECTIVES.auto;
14591
+ }
14500
14592
  const ADVISOR_TOOL_DESCRIPTION = `Consult the configured read-only advisor model for a stronger second opinion on your own reading of this conversation. The conversation is forwarded automatically, including tool calls and results; the question argument only sets the review focus.
14501
14593
 
14502
14594
  Call advisor BEFORE substantive work: before writing, editing, committing to an interpretation, or building on an assumption. If orientation is needed first, find and read the relevant files, then call advisor; orientation itself is not substantive work. Also call advisor when you believe a multi-step task is complete; make the deliverable durable first by writing the file or saving the result. Call it when errors recur or the approach stops converging, and before changing approach. On short reactive tasks where the next action is dictated by tool output you just read, you may skip it.
@@ -14968,6 +15060,7 @@ async function requestAdvisor(options) {
14968
15060
  const gaps = [options.transcript.omittedMessages > 0 ? `${options.transcript.omittedMessages} middle messages were omitted to fit the advisor context window.` : "", options.transcript.orphanedToolCalls > 0 ? `${options.transcript.orphanedToolCalls} tool results fell outside that window; their calls carry an explicit placeholder.` : ""].filter(Boolean);
14969
15061
  const system = [
14970
15062
  ADVISOR_SYSTEM_PROMPT,
15063
+ advisorLanguageDirective(options.language ?? "auto"),
14971
15064
  `The main agent requests this review focus:\n${options.question}`,
14972
15065
  options.transcript.sourceSystem,
14973
15066
  ...gaps
@@ -15081,6 +15174,11 @@ function routeOf$1(config) {
15081
15174
  ...reasoningEffort === "" || reasoningEffort === "auto" ? {} : { reasoningEffort }
15082
15175
  };
15083
15176
  }
15177
+ /** 顾问回复跟随进展更新的语言档位;配置写错时按 auto 处理。 */
15178
+ function progressLanguageOf(config) {
15179
+ const language = value(config.progressUpdatesLanguage, "auto");
15180
+ return typeof language === "string" && PROGRESS_UPDATE_LANGUAGES.includes(language) ? language : "auto";
15181
+ }
15084
15182
  /** Which model the conversation itself runs on, used only for the weaker-advisor warning. */
15085
15183
  function mainRouteOf(agent) {
15086
15184
  const config = agent?.session?.requestHeader?.()?.config;
@@ -15097,9 +15195,11 @@ function spentTokens(usage) {
15097
15195
  var AdvisorService = class {
15098
15196
  selections;
15099
15197
  llm;
15100
- constructor(selections, llm) {
15198
+ languageOf;
15199
+ constructor(selections, llm, languageOf = () => "auto") {
15101
15200
  this.selections = selections;
15102
15201
  this.llm = llm;
15202
+ this.languageOf = languageOf;
15103
15203
  }
15104
15204
  async consult(args, agentInput, signal) {
15105
15205
  const agent = agentInput;
@@ -15146,7 +15246,8 @@ var AdvisorService = class {
15146
15246
  timeoutMs: state.limits.timeoutMs,
15147
15247
  maxRetries: state.limits.maxRetries,
15148
15248
  sessionId,
15149
- signal
15249
+ signal,
15250
+ language: this.languageOf()
15150
15251
  });
15151
15252
  if (result.status === "ok" || result.status === "truncated" || result.status === "declined") {
15152
15253
  const usage = await this.selections.addUsage(sessionId, {
@@ -15182,7 +15283,7 @@ function installAdvisor(ctx, config) {
15182
15283
  contextTokenBudget: value(config.advisorContextTokenBudget, 1e5),
15183
15284
  sessionTokenBudget: value(config.advisorSessionTokenBudget, 2e5)
15184
15285
  }), void 0, (sessionId) => sessionHeaderOf(ctx, sessionId), () => firstAvailableAdvisorRoute(ctx.llm));
15185
- const service = new AdvisorService(store, ctx.llm);
15286
+ const service = new AdvisorService(store, ctx.llm, () => progressLanguageOf(config));
15186
15287
  const disposeTool = ctx.tools.register(defineTool({
15187
15288
  name: CONSULT_ADVISOR_TOOL_NAME,
15188
15289
  description: ADVISOR_TOOL_DESCRIPTION,
@@ -47608,10 +47709,11 @@ function longcatHeaders(apiKey) {
47608
47709
  * live listing as its catalog and a small bundled table for the capabilities the
47609
47710
  * listing does not carry.
47610
47711
  *
47611
- * Capability source: models.dev's `longcat` provider (LongCat-2.5 sees text, image and
47612
- * video input; LongCat-2.0 sees text only; both declare reasoning and tool calls, and
47613
- * both publish a 1M context window). Everything else is a conservative local budget
47614
- * and is overridable per model in the settings card.
47712
+ * Capability source: models.dev's `longcat` provider (LongCat-2.5 lists text, image and
47713
+ * video input; LongCat-2.0 text only; both declare reasoning and tool calls, and both
47714
+ * publish a 1M context window). This line maps image input only, so it advertises
47715
+ * text+image until a video wire path is verified; everything else is a conservative
47716
+ * local budget and is overridable per model in the settings card.
47615
47717
  */
47616
47718
  function entry$1(input) {
47617
47719
  return {
@@ -56382,10 +56484,10 @@ const OPENCODE_ZEN_MODEL_CATALOG = [
56382
56484
  id: "deepseek-v4.1-flash-free",
56383
56485
  name: "DeepSeek V4.1 Flash Free",
56384
56486
  description: null,
56385
- canonicalId: null,
56487
+ canonicalId: "deepseek/deepseek-v4.1-flash-1017",
56386
56488
  contextWindow: 2e5,
56387
56489
  maxOutputTokens: 32e3,
56388
- reasoningEfforts: [],
56490
+ reasoningEfforts: ["low", "high"],
56389
56491
  supportsTools: true,
56390
56492
  supportsImages: true,
56391
56493
  free: true,
@@ -56395,10 +56497,10 @@ const OPENCODE_ZEN_MODEL_CATALOG = [
56395
56497
  id: "deepseek-v4.1-flash",
56396
56498
  name: "DeepSeek V4.1 Flash 1017",
56397
56499
  description: null,
56398
- canonicalId: null,
56500
+ canonicalId: "deepseek/deepseek-v4.1-flash-1017",
56399
56501
  contextWindow: 1e6,
56400
56502
  maxOutputTokens: 384e3,
56401
- reasoningEfforts: [],
56503
+ reasoningEfforts: ["low", "high"],
56402
56504
  supportsTools: true,
56403
56505
  supportsImages: true,
56404
56506
  free: false,
@@ -56408,10 +56510,10 @@ const OPENCODE_ZEN_MODEL_CATALOG = [
56408
56510
  id: "deepseek-v4-pro",
56409
56511
  name: "DeepSeek V4 Pro",
56410
56512
  description: null,
56411
- canonicalId: null,
56513
+ canonicalId: "deepseek/deepseek-v4-pro",
56412
56514
  contextWindow: 1e6,
56413
56515
  maxOutputTokens: 384e3,
56414
- reasoningEfforts: [],
56516
+ reasoningEfforts: ["high"],
56415
56517
  supportsTools: true,
56416
56518
  supportsImages: false,
56417
56519
  free: false,
@@ -56421,10 +56523,10 @@ const OPENCODE_ZEN_MODEL_CATALOG = [
56421
56523
  id: "glm-5.3",
56422
56524
  name: "GLM-5.3",
56423
56525
  description: null,
56424
- canonicalId: null,
56526
+ canonicalId: "zhipuai/glm-5.3",
56425
56527
  contextWindow: 1e6,
56426
56528
  maxOutputTokens: 131072,
56427
- reasoningEfforts: [],
56529
+ reasoningEfforts: ["low", "high"],
56428
56530
  supportsTools: true,
56429
56531
  supportsImages: false,
56430
56532
  free: false,
@@ -56434,10 +56536,10 @@ const OPENCODE_ZEN_MODEL_CATALOG = [
56434
56536
  id: "glm-5.3-flash",
56435
56537
  name: "GLM-5.3-Flash",
56436
56538
  description: null,
56437
- canonicalId: null,
56539
+ canonicalId: "zhipuai/glm-5.3-flash",
56438
56540
  contextWindow: 1e6,
56439
56541
  maxOutputTokens: 131072,
56440
- reasoningEfforts: [],
56542
+ reasoningEfforts: ["low", "high"],
56441
56543
  supportsTools: true,
56442
56544
  supportsImages: true,
56443
56545
  free: false,
@@ -104186,7 +104288,7 @@ const STATIC_GLOBAL_SEEDS = [
104186
104288
  id: "Auto",
104187
104289
  upstreamKey: "auto",
104188
104290
  name: "Auto",
104189
- reasoning: true,
104291
+ reasoning: false,
104190
104292
  supportsEffort: false,
104191
104293
  supportsImages: true
104192
104294
  },
@@ -104212,7 +104314,8 @@ const STATIC_GLOBAL_SEEDS = [
104212
104314
  name: "Efficient",
104213
104315
  reasoning: false,
104214
104316
  supportsEffort: false,
104215
- supportsImages: true
104317
+ supportsImages: true,
104318
+ contextWindow: 2e5
104216
104319
  },
104217
104320
  {
104218
104321
  id: "Lite",
@@ -104226,7 +104329,7 @@ const STATIC_GLOBAL_SEEDS = [
104226
104329
  id: "Qwen3.7Plus",
104227
104330
  upstreamKey: "qmodel",
104228
104331
  name: "Qwen3.7 Plus",
104229
- reasoning: false,
104332
+ reasoning: true,
104230
104333
  supportsEffort: false,
104231
104334
  supportsImages: true
104232
104335
  },
@@ -104236,7 +104339,12 @@ const STATIC_GLOBAL_SEEDS = [
104236
104339
  name: "Qwen4-Max",
104237
104340
  reasoning: true,
104238
104341
  supportsEffort: true,
104239
- supportsImages: true
104342
+ supportsImages: true,
104343
+ efforts: [
104344
+ "low",
104345
+ "high",
104346
+ "xhigh"
104347
+ ]
104240
104348
  },
104241
104349
  {
104242
104350
  id: "Qwen3.8-Max",
@@ -104244,7 +104352,12 @@ const STATIC_GLOBAL_SEEDS = [
104244
104352
  name: "Qwen3.8-Max",
104245
104353
  reasoning: true,
104246
104354
  supportsEffort: true,
104247
- supportsImages: true
104355
+ supportsImages: true,
104356
+ efforts: [
104357
+ "low",
104358
+ "medium",
104359
+ "xhigh"
104360
+ ]
104248
104361
  },
104249
104362
  {
104250
104363
  id: "GLM-5.4",
@@ -104252,7 +104365,12 @@ const STATIC_GLOBAL_SEEDS = [
104252
104365
  name: "GLM-5.4",
104253
104366
  reasoning: true,
104254
104367
  supportsEffort: true,
104255
- supportsImages: true
104368
+ supportsImages: true,
104369
+ efforts: [
104370
+ "low",
104371
+ "high",
104372
+ "max"
104373
+ ]
104256
104374
  },
104257
104375
  {
104258
104376
  id: "DeepSeek-V4-Pro",
@@ -104260,7 +104378,8 @@ const STATIC_GLOBAL_SEEDS = [
104260
104378
  name: "DeepSeek-V4-Pro",
104261
104379
  reasoning: true,
104262
104380
  supportsEffort: true,
104263
- supportsImages: true
104381
+ supportsImages: true,
104382
+ efforts: ["high", "max"]
104264
104383
  },
104265
104384
  {
104266
104385
  id: "DeepSeek-V4-Flash",
@@ -104268,30 +104387,44 @@ const STATIC_GLOBAL_SEEDS = [
104268
104387
  name: "DeepSeek-V4-Flash",
104269
104388
  reasoning: true,
104270
104389
  supportsEffort: true,
104271
- supportsImages: true
104390
+ supportsImages: true,
104391
+ efforts: [
104392
+ "low",
104393
+ "high",
104394
+ "max"
104395
+ ]
104272
104396
  },
104273
104397
  {
104274
- id: "Kimi-K2.7-Code",
104398
+ id: "Kimi-K2.8-Preview",
104275
104399
  upstreamKey: "kmodel",
104276
- name: "Kimi-K2.7-Code",
104277
- reasoning: false,
104278
- supportsEffort: false,
104400
+ name: "Kimi-K2.8-Preview",
104401
+ reasoning: true,
104402
+ supportsEffort: true,
104279
104403
  supportsImages: true,
104280
- contextWindow: 256e3
104404
+ efforts: [
104405
+ "low",
104406
+ "high",
104407
+ "max"
104408
+ ]
104281
104409
  },
104282
104410
  {
104283
- id: "Kimi-K3",
104411
+ id: "Kimi-K3.1-Pro",
104284
104412
  upstreamKey: "kmodel_latest",
104285
- name: "Kimi-K3",
104286
- reasoning: false,
104287
- supportsEffort: false,
104288
- supportsImages: true
104413
+ name: "Kimi-K3.1-Pro",
104414
+ reasoning: true,
104415
+ supportsEffort: true,
104416
+ supportsImages: true,
104417
+ efforts: [
104418
+ "low",
104419
+ "high",
104420
+ "max"
104421
+ ]
104289
104422
  },
104290
104423
  {
104291
104424
  id: "MiniMax-M3",
104292
104425
  upstreamKey: "mmodel",
104293
104426
  name: "MiniMax-M3",
104294
- reasoning: false,
104427
+ reasoning: true,
104295
104428
  supportsEffort: false,
104296
104429
  supportsImages: true
104297
104430
  }
@@ -104302,7 +104435,7 @@ const STATIC_CN_SEEDS = [
104302
104435
  id: "Auto",
104303
104436
  upstreamKey: "auto",
104304
104437
  name: "Auto",
104305
- reasoning: true,
104438
+ reasoning: false,
104306
104439
  supportsEffort: false,
104307
104440
  supportsImages: true,
104308
104441
  contextWindow: 2e5
@@ -104343,9 +104476,14 @@ const STATIC_CN_SEEDS = [
104343
104476
  id: "DeepSeek-V4-Flash",
104344
104477
  upstreamKey: "dfmodel",
104345
104478
  name: "DeepSeek-V4-Flash",
104346
- reasoning: false,
104347
- supportsEffort: false,
104348
- supportsImages: false
104479
+ reasoning: true,
104480
+ supportsEffort: true,
104481
+ supportsImages: true,
104482
+ efforts: [
104483
+ "low",
104484
+ "high",
104485
+ "max"
104486
+ ]
104349
104487
  },
104350
104488
  {
104351
104489
  id: "GLM-5.4",
@@ -104369,7 +104507,7 @@ const STATIC_CN_SEEDS = [
104369
104507
  id: "MiniMax-M2.7",
104370
104508
  upstreamKey: "mmodel",
104371
104509
  name: "MiniMax-M2.7",
104372
- reasoning: false,
104510
+ reasoning: true,
104373
104511
  supportsEffort: false,
104374
104512
  supportsImages: false,
104375
104513
  contextWindow: 2e5
@@ -104397,7 +104535,7 @@ function seedToEntry(seed, region) {
104397
104535
  source: "system",
104398
104536
  regions: [region],
104399
104537
  reasoning: seed.reasoning,
104400
- reasoningEfforts: seed.reasoning && seed.supportsEffort ? STATIC_EFFORT_LADDER : [],
104538
+ reasoningEfforts: seed.reasoning && seed.supportsEffort ? seed.efforts ?? STATIC_EFFORT_LADDER : [],
104401
104539
  thinkingDisableable: true,
104402
104540
  supportsImages: seed.supportsImages,
104403
104541
  defaultContextWindow: seed.contextWindow ?? QODER_DEFAULT_CONTEXT_WINDOW[region],
@@ -106128,6 +106266,14 @@ function createQoderReplayDiagnostics() {
106128
106266
  };
106129
106267
  }
106130
106268
  /**
106269
+ * Qoder 的 V4.1 Flash 在模型选择器里叫 `DeepSeek-Flash`,上行 key 是 `dfmodel`。
106270
+ * 自有回放标记按上行 key 生成,示范信封按可见 id 生成;两者必须视为同一模型,
106271
+ * 但仍只放行这一对已知别名,换到 Qwen/GLM/Kimi 时继续拒绝。
106272
+ */
106273
+ function qoderReplayModelMatches(responseModel, model) {
106274
+ return responseModel === model || responseModel === "DeepSeek-Flash" && model === "dfmodel" || responseModel === "dfmodel" && model === "DeepSeek-Flash";
106275
+ }
106276
+ /**
106131
106277
  * 把助手消息拆成上游要的三段,并决定**这条消息的推理能不能回放**。
106132
106278
  *
106133
106279
  * 回放的前提是 `message.source.replayState` 记着同一 provider、同一模型:Qoder 这条线路
@@ -106139,7 +106285,7 @@ function createQoderReplayDiagnostics() {
106139
106285
  function qoderAssistantContent(message, model, replay) {
106140
106286
  const state = isRecord$47(message.source?.replayState) ? message.source.replayState : void 0;
106141
106287
  const response = isRecord$47(state?.response) ? state.response : void 0;
106142
- const markedBlocks = response?.provider === PROVIDER_ID$8 && response.model === model && Array.isArray(state?.blocks) ? state.blocks : void 0;
106288
+ const markedBlocks = response?.provider === PROVIDER_ID$8 && qoderReplayModelMatches(response.model, model) && Array.isArray(state?.blocks) ? state.blocks : void 0;
106143
106289
  const textParts = [];
106144
106290
  const toolCalls = [];
106145
106291
  const reasoningParts = [];
@@ -125061,8 +125207,9 @@ function installDeepSeekV41FlashProgressGovernor(ctx, options = {}) {
125061
125207
  * ## 绝对隔离保证
125062
125208
  *
125063
125209
  * 全部四个子能力均通过 {@link isDeepSeekV41Flash} 严格门控:任何其它线路与任何其它
125064
- * 模型(包括 `deepseek-v4-pro`、`deepseek-v4-flash`、Qoder `DeepSeek-Flash`、
125210
+ * 模型(包括 `deepseek-v4-pro`、`deepseek-v4-flash`、Qoder 的其它模型、
125065
125211
  * Claude、GPT、Kimi、MiniMax、GLM、Qwen 等)均 100% 旁路,零字节改动、零行为变化。
125212
+ * Qoder 的 `DeepSeek-Flash` 是同一 V4.1-1017,属于本总成的正常命中范围。
125066
125213
  *
125067
125214
  * @module @eddyskywalker/dsh-chatgpt-subscription/host/deepseek-v41-flash
125068
125215
  */
@@ -125236,7 +125383,8 @@ const ENVELOPE_PROVIDERS = /* @__PURE__ */ new Set([
125236
125383
  "tencent-tokenhub",
125237
125384
  "qianfan-token-plan",
125238
125385
  "alibaba-token-plan",
125239
- "qianwen-token-plan"
125386
+ "qianwen-token-plan",
125387
+ "qoder"
125240
125388
  ]);
125241
125389
  const MARKER_PROVIDERS = /* @__PURE__ */ new Set([
125242
125390
  "opencode-zen",
@@ -137184,6 +137332,13 @@ const RETRY_POLICY$3 = resolveRetryPolicy({
137184
137332
  const prefixRequests = new PrefixRequestCoordinator({ waitMs: 2500 });
137185
137333
  const activityStore = promptCacheActivityStore(PROVIDER_ID$6);
137186
137334
  const ttlMs = (ttl) => ttl === "1h" ? 60 * 6e4 : 5 * 6e4;
137335
+ /** 目录的图片/视频布尔值必须完整投影到 DSH 的输入模态,否则视频附件会在准入层被拒。 */
137336
+ function qianwenInputModalities(entry) {
137337
+ const modalities = ["text"];
137338
+ if (entry.supportsImages) modalities.push("image");
137339
+ if (entry.supportsVideo) modalities.push("video");
137340
+ return modalities;
137341
+ }
137187
137342
  var QianwenTokenPlanAdapter = class extends LlmAdapter {
137188
137343
  store;
137189
137344
  settingsStore;
@@ -137217,7 +137372,7 @@ var QianwenTokenPlanAdapter = class extends LlmAdapter {
137217
137372
  provider: provider || PROVIDER_ID$6,
137218
137373
  id: model.id,
137219
137374
  name: model.name,
137220
- inputModalities: model.supportsImages ? ["text", "image"] : ["text"]
137375
+ inputModalities: qianwenInputModalities(model)
137221
137376
  }));
137222
137377
  }
137223
137378
  async resolveModel(provider, model, signal) {
@@ -137231,7 +137386,7 @@ var QianwenTokenPlanAdapter = class extends LlmAdapter {
137231
137386
  provider,
137232
137387
  id: model,
137233
137388
  name: entry.name,
137234
- inputModalities: entry.supportsImages ? ["text", "image"] : ["text"],
137389
+ inputModalities: qianwenInputModalities(entry),
137235
137390
  toolUpdate: "in-history",
137236
137391
  context: { contextWindow },
137237
137392
  ...outputReservation(contextWindow, entry.maxOutputTokens),
@@ -141006,9 +141161,27 @@ function templateFor(id, name) {
141006
141161
  known: false
141007
141162
  };
141008
141163
  }
141164
+ /** `[1m]` 是同一模型的 1M 上下文别名;能力必须继承基名行,不能套 CURRENT 模板。 */
141165
+ function longContextBaseId(id) {
141166
+ return id.endsWith("[1m]") ? id.slice(0, -4) : void 0;
141167
+ }
141168
+ function knownModelEntry(id, catalog) {
141169
+ const exact = catalog?.find((entry) => entry.id === id) ?? CLAUDE_API_MODELS.find((entry) => entry.id === id);
141170
+ if (exact !== void 0) return exact;
141171
+ const baseId = longContextBaseId(id);
141172
+ if (baseId === void 0) return void 0;
141173
+ const base = catalog?.find((entry) => entry.id === baseId) ?? CLAUDE_API_MODELS.find((entry) => entry.id === baseId);
141174
+ if (base === void 0) return void 0;
141175
+ return {
141176
+ ...base,
141177
+ id,
141178
+ name: base.name + " [1m]",
141179
+ contextWindow: Math.max(base.contextWindow, 1e6)
141180
+ };
141181
+ }
141009
141182
  /** Facts for one model id: the caller's catalog first, then the shipped table, then a template. */
141010
141183
  function resolveClaudeApiModel(id, catalog) {
141011
- return catalog?.find((entry) => entry.id === id) ?? CLAUDE_API_MODELS.find((entry) => entry.id === id) ?? templateFor(id, id);
141184
+ return knownModelEntry(id, catalog) ?? templateFor(id, id);
141012
141185
  }
141013
141186
  /** The shipped table as a fresh array; the cold-start placeholder before any live listing. */
141014
141187
  function claudeApiFallbackEntries() {
@@ -141018,7 +141191,7 @@ function isRecord$13(value) {
141018
141191
  return typeof value === "object" && value !== null && !Array.isArray(value);
141019
141192
  }
141020
141193
  function entryFor(id, displayName) {
141021
- const known = CLAUDE_API_MODELS.find((entry) => entry.id === id);
141194
+ const known = knownModelEntry(id);
141022
141195
  if (known !== void 0) return { ...known };
141023
141196
  return templateFor(id, displayName !== void 0 && displayName !== "" ? displayName : id);
141024
141197
  }
@@ -144237,6 +144410,8 @@ function chatGptApiUrl(baseUrl, path) {
144237
144410
  //#region src/host/providers/chatgpt-api/model-catalog.ts
144238
144411
  const FALLBACK_CONTEXT_WINDOW = 128e3;
144239
144412
  const FALLBACK_MAX_OUTPUT_TOKENS = 16384;
144413
+ /** Public API advertises 1.05M for the GPT-6 / GPT-5.6 families; Codex subscription rows carry smaller plan windows. */
144414
+ const PUBLIC_API_GPT_CONTEXT_WINDOW = 105e4;
144240
144415
  function isRecord$5(value) {
144241
144416
  return typeof value === "object" && value !== null && !Array.isArray(value);
144242
144417
  }
@@ -144252,7 +144427,7 @@ function chatGptApiFallbackEntries() {
144252
144427
  supportsImages: entry.inputModalities.includes("image"),
144253
144428
  supportsVerbosity: "supportsOutputVerbosity" in entry && entry.supportsOutputVerbosity === true
144254
144429
  }),
144255
- contextWindow: entry.contextWindow,
144430
+ contextWindow: entry.reasoningProfile === "gpt-6" || entry.reasoningProfile === "gpt-5.6" ? PUBLIC_API_GPT_CONTEXT_WINDOW : entry.contextWindow,
144256
144431
  maxOutputTokens: "maxTokens" in entry && entry.maxTokens !== void 0 ? entry.maxTokens : entry.reasoningProfile === "gpt-6" ? GPT_6_MAX_TOKENS : CODEX_DEFAULT_MAX_TOKENS,
144257
144432
  reasoningEfforts: reasoningEffortsForModel$1(entry.id).filter(isChatGptApiReasoningEffort),
144258
144433
  supportsImages: entry.inputModalities.includes("image"),
@@ -144283,7 +144458,7 @@ function defaultLiveEntry(id, name) {
144283
144458
  function isChatGptApiChatModel(id) {
144284
144459
  const normalized = id.trim().toLowerCase();
144285
144460
  if (normalized === "") return false;
144286
- if (/(embedding|whisper|tts|dall-e|moderation|transcribe|realtime|image-|audio-|sora|babbage|davinci)/.test(normalized)) return false;
144461
+ if (/(embedding|whisper|tts|dall-e|moderation|transcribe|realtime|image-|audio|sora|babbage|davinci)/.test(normalized)) return false;
144287
144462
  return /^(gpt|chatgpt|o\d|codex)/.test(normalized);
144288
144463
  }
144289
144464
  function parseLiveChatGptApiModelEntries(value) {
@@ -146109,15 +146284,36 @@ function apply(ctx, pluginConfig = {}) {
146109
146284
  if (provider === PROVIDER_ID$4) return (await claudeApiPreferences?.read())?.autoCompactSubagents === true && !belowThreshold(threshold, contextTokens);
146110
146285
  return false;
146111
146286
  }
146112
- if (provider === void 0 || !await autoCompactAfterTasksOf(provider)) return false;
146113
- return taskCompleteSkipReason({
146287
+ return false;
146288
+ },
146289
+ taskPolicy: async (agent) => {
146290
+ const sessionId = agent.session?.id;
146291
+ const provider = resolveCompactAgentProvider(agent);
146292
+ if (provider === void 0) return void 0;
146293
+ if (isDelegatedCaller(agent, ctx) || typeof sessionId === "string" && isDelegatedSession(sessionId, ctx)) return {
146294
+ enabled: false,
146295
+ pendingWork: false,
146296
+ eligible: true
146297
+ };
146298
+ if (!await autoCompactAfterTasksOf(provider)) return {
146299
+ enabled: false,
146300
+ pendingWork: false,
146301
+ eligible: true
146302
+ };
146303
+ const writtenTtlMs = await mainTierMs(provider, typeof sessionId === "string" ? sessionId : void 0);
146304
+ const keepaliveTtlMs = keepaliveTierMs(provider);
146305
+ if (writtenTtlMs !== void 0 && keepaliveTtlMs !== void 0 && writtenTtlMs !== keepaliveTtlMs) return {
146306
+ enabled: false,
146307
+ pendingWork: false,
146308
+ eligible: true
146309
+ };
146310
+ const threshold = resolveCompactThreshold(pluginConfig);
146311
+ const contextTokens = typeof sessionId === "string" ? sessionActivity(provider, sessionId).totalTokens : void 0;
146312
+ return {
146114
146313
  enabled: true,
146115
- threshold,
146116
146314
  pendingWork: typeof sessionId === "string" && (cacheWaitPendingWork?.(sessionId) ?? false),
146117
- contextTokens,
146118
- writtenTtlMs: await mainTierMs(provider, typeof sessionId === "string" ? sessionId : void 0),
146119
- keepaliveTtlMs: keepaliveTierMs(provider)
146120
- }) === void 0;
146315
+ eligible: !belowThreshold(threshold, contextTokens)
146316
+ };
146121
146317
  },
146122
146318
  onController: (controller) => {
146123
146319
  requestTaskComplete = (sessionId) => controller.requestTaskComplete(sessionId);