@eddyskywalker/dsh-chatgpt-subscription 0.66.2 → 0.68.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 (72) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +1 -1
  3. package/lib/client.js +111 -631
  4. package/lib/client.js.map +1 -1
  5. package/lib/codemode.js +28 -7
  6. package/lib/{entry-plan-mode-CLRKkgYG.js → entry-plan-mode-gqE4UeU5.js} +5 -2
  7. package/lib/{entry-progress-updates-DZ0ZRus4.js → entry-progress-updates-DpzbX1GP.js} +5 -1
  8. package/lib/index.js +408 -2062
  9. package/lib/plan-mode-pipeline.js +1 -1
  10. package/lib/plan-mode.js +1 -1
  11. package/lib/progress-updates.js +1 -1
  12. package/lib/types/client/cline-pass/ClinePassSection.d.ts +1 -1
  13. package/lib/types/client/cline-pass/ClinePassSection.d.ts.map +1 -1
  14. package/lib/types/client/cline-pass/api.d.ts +2 -36
  15. package/lib/types/client/cline-pass/api.d.ts.map +1 -1
  16. package/lib/types/client/cline-pass/locales.d.ts +30 -264
  17. package/lib/types/client/cline-pass/locales.d.ts.map +1 -1
  18. package/lib/types/client/cline-pass/styles.d.ts +2 -2
  19. package/lib/types/client/cline-pass/styles.d.ts.map +1 -1
  20. package/lib/types/client/locales-ru/cline-pass.d.ts.map +1 -1
  21. package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
  22. package/lib/types/client/progress-updates/locales.d.ts +8 -2
  23. package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
  24. package/lib/types/client/progress-updates/settings-binding.d.ts +3 -1
  25. package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
  26. package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
  27. package/lib/types/compat.d.ts +1 -1
  28. package/lib/types/entry-codemode.d.ts.map +1 -1
  29. package/lib/types/entry-plan-mode-pipeline.d.ts.map +1 -1
  30. package/lib/types/entry-plan-mode.d.ts.map +1 -1
  31. package/lib/types/host/agent-preset.d.ts.map +1 -1
  32. package/lib/types/host/antigravity/adapter.d.ts.map +1 -1
  33. package/lib/types/host/antigravity/client-version.d.ts.map +1 -1
  34. package/lib/types/host/antigravity/types.d.ts +5 -5
  35. package/lib/types/host/antigravity/types.d.ts.map +1 -1
  36. package/lib/types/host/cline-pass/adapter.d.ts +3 -4
  37. package/lib/types/host/cline-pass/adapter.d.ts.map +1 -1
  38. package/lib/types/host/cline-pass/client.d.ts +0 -22
  39. package/lib/types/host/cline-pass/client.d.ts.map +1 -1
  40. package/lib/types/host/cline-pass/engine.d.ts +9 -147
  41. package/lib/types/host/cline-pass/engine.d.ts.map +1 -1
  42. package/lib/types/host/cline-pass/line.d.ts.map +1 -1
  43. package/lib/types/host/cline-pass/mapper.d.ts +1 -3
  44. package/lib/types/host/cline-pass/mapper.d.ts.map +1 -1
  45. package/lib/types/host/cline-pass/protocol.d.ts +1 -161
  46. package/lib/types/host/cline-pass/protocol.d.ts.map +1 -1
  47. package/lib/types/host/cline-pass/routes.d.ts +2 -7
  48. package/lib/types/host/cline-pass/routes.d.ts.map +1 -1
  49. package/lib/types/host/cline-pass/store.d.ts +11 -35
  50. package/lib/types/host/cline-pass/store.d.ts.map +1 -1
  51. package/lib/types/host/cline-pass/token-store.d.ts +1 -10
  52. package/lib/types/host/cline-pass/token-store.d.ts.map +1 -1
  53. package/lib/types/host/cline-pass/tools.d.ts.map +1 -1
  54. package/lib/types/host/cline-pass/types.d.ts +7 -76
  55. package/lib/types/host/cline-pass/types.d.ts.map +1 -1
  56. package/lib/types/host/codemode/rules.d.ts +13 -5
  57. package/lib/types/host/codemode/rules.d.ts.map +1 -1
  58. package/lib/types/host/command-code/adapter.d.ts.map +1 -1
  59. package/lib/types/host/dispatch-execution-guard.d.ts.map +1 -1
  60. package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
  61. package/lib/types/host/kimi-code/tool-argument-guard.d.ts +7 -0
  62. package/lib/types/host/kimi-code/tool-argument-guard.d.ts.map +1 -1
  63. package/lib/types/host/kimi-code/tool-argument-recovery.d.ts.map +1 -1
  64. package/lib/types/host/progress-updates/prompt.d.ts.map +1 -1
  65. package/lib/types/host/progress-updates/tool.d.ts.map +1 -1
  66. package/lib/types/index.d.ts +14 -4
  67. package/lib/types/index.d.ts.map +1 -1
  68. package/lib/types/shared/cline-pass-contracts.d.ts +6 -92
  69. package/lib/types/shared/cline-pass-contracts.d.ts.map +1 -1
  70. package/package.json +1 -1
  71. package/presets/dispatch/README.md +9 -9
  72. package/presets/dispatch/agent.cordis.yml +26 -18
package/lib/codemode.js CHANGED
@@ -506,6 +506,7 @@ function normalizeConfig(config) {
506
506
  nativeScope: source.nativeScope !== false,
507
507
  hiddenPrefixes: Object.freeze(stringList(source.hiddenPrefixes, DEFAULT_HIDDEN_PREFIXES)),
508
508
  nativeTools: Object.freeze(stringList(source.nativeTools, DEFAULT_NATIVE_TOOLS)),
509
+ nativeToolsOnly: source.nativeToolsOnly === true,
509
510
  hiddenTools: Object.freeze(stringList(source.hiddenTools, [])),
510
511
  metaTools: Object.freeze(metaTools),
511
512
  runToolName,
@@ -528,7 +529,7 @@ const DISABLED_VIEW = Object.freeze({
528
529
  * 判定一个名字是否要从模型清单里剥离。
529
530
  *
530
531
  * 顺序:显式例外(`nativeTools` / 传输工具 / 发现工具)→ 显式遮蔽
531
- * (`hiddenTools`)→ 名字前缀 → 作用域归属。
532
+ * (`hiddenTools`)→ 名字前缀 → `nativeToolsOnly` 白名单 → 作用域归属。
532
533
  *
533
534
  * 作用域归属只在能确认归属时遮蔽:
534
535
  *
@@ -546,6 +547,7 @@ function isMaskedName(name, rules, view) {
546
547
  if (rules.native.has(name)) return false;
547
548
  if (rules.hidden.has(name)) return true;
548
549
  for (const prefix of rules.options.hiddenPrefixes) if (prefix.length > 0 && name.startsWith(prefix)) return true;
550
+ if (rules.options.nativeToolsOnly) return true;
549
551
  if (!rules.options.nativeScope || !view.enabled) return false;
550
552
  if (view.globalNames.has(name)) return true;
551
553
  if (view.presetNames.has(name)) return false;
@@ -583,15 +585,15 @@ function summarizeHidden(names) {
583
585
  *
584
586
  * ## 恒定契约
585
587
  *
586
- * 这段正文**只**依赖入参里的两个工具名与部署级的 `language` / `programFormat`。它刻意不含遮蔽
587
- * 工具的数量、namespace 分布、会话 id 或时间,因此同一部署下逐字节恒定:挂载或卸载
588
- * MCP 服务端不会改写它,前缀缓存不会因为它失效。
588
+ * 这段正文**只**依赖入参里的工具名与部署级的 `language` / `programFormat` / native 白名单
589
+ * 配置。它刻意不含遮蔽工具的数量、namespace 分布、会话 id 或时间,因此同一部署下逐字节恒定:
590
+ * 挂载或卸载 MCP 服务端不会改写它,前缀缓存不会因为它失效。
589
591
  *
590
592
  * 结果形状索引(`read` / `glob` / `grep` … 的顶层字段)也**必须是静态的**:它照抄自各工具
591
593
  * 声明过的 output schema,不读活 catalog。按 catalog 生成会让「挂一个 MCP 服务端」改写系统
592
594
  * 提示词首段,正好毁掉这一层要保住的前缀缓存。
593
595
  *
594
- * @param input - 传输工具名、发现工具名与程序形态。
596
+ * @param input - 传输工具名、发现工具名、程序形态与部署级 native 白名单。
595
597
  * @returns 说明段正文。
596
598
  */
597
599
  function buildCodemodeSectionText(input) {
@@ -617,11 +619,28 @@ function buildCodemodeSectionText(input) {
617
619
  retained ? "pages.flatMap((r) => r.lines.filter((l) => l.text.includes(\"TODO\")).map((l) => l.text))" : "return pages.flatMap((r) => r.lines.filter((l) => l.text.includes(\"TODO\")).map((l) => l.text))",
618
620
  "```"
619
621
  ];
622
+ const nativeNames = [run, ...(input.nativeTools ?? []).filter((name) => name !== run)];
623
+ const nativeOnly = input.nativeToolsOnly === true;
624
+ const introduction = nativeOnly ? "This session runs in Code Mode with a native whitelist: " + nativeNames.map((name) => "`" + name + "`").join(", ") + ". Every other registered tool—including MCP tools, external plugin tools, and non-whitelist tools owned by this preset—is program-only. Reach them through `tools.<name>(...)` inside " + run + "." : "This session runs in Code Mode. The tools in your tool list are called directly, exactly as usual. A second, larger set of tools is deliberately **not** in your context: every MCP tool, and every tool contributed by a plugin outside this preset. Reach them from inside " + run + ".";
625
+ const commonProgramTools = [
626
+ "read",
627
+ "glob",
628
+ "grep",
629
+ "edit",
630
+ "write",
631
+ "read_image",
632
+ "ask_user_question",
633
+ "subagent",
634
+ "win_bash"
635
+ ].filter((name) => !nativeNames.includes(name));
636
+ const whitelistGuidance = nativeOnly ? ["Whenever another instruction names a non-whitelist tool, it means the corresponding `tools.<name>(...)` call inside " + run + ", never a top-level call." + (commonProgramTools.length > 0 ? " Common mappings: " + commonProgramTools.map((name) => "`" + name + "` → `tools." + name + "`").join(", ") + "." : "")] : [];
620
637
  return [
621
638
  "## Code Mode",
622
639
  "",
623
- "This session runs in Code Mode. The tools in your tool list are called directly, exactly as usual. A second, larger set of tools is deliberately **not** in your context: every MCP tool, and every tool contributed by a plugin outside this preset. Reach them from inside " + run + ".",
640
+ introduction,
624
641
  "",
642
+ ...whitelistGuidance,
643
+ ...whitelistGuidance.length > 0 ? [""] : [],
625
644
  "### Calling tools from a program",
626
645
  "",
627
646
  ...example,
@@ -2671,7 +2690,9 @@ function apply(ctx, config = {}) {
2671
2690
  runToolName: rules.options.runToolName,
2672
2691
  metaTools: rules.options.metaTools,
2673
2692
  language: runtime?.language,
2674
- programFormat: runtime?.programFormat
2693
+ programFormat: runtime?.programFormat,
2694
+ nativeToolsOnly: rules.options.nativeToolsOnly,
2695
+ nativeTools: rules.options.nativeTools
2675
2696
  });
2676
2697
  },
2677
2698
  onCatalog: (definitions) => {
@@ -528,7 +528,10 @@ function validateAskUserQuestionArgs(args) {
528
528
  const at = `questions[${index}]`;
529
529
  if (!isRecord(question)) return invalidAskUserQuestion(`${at} must be a question object. Known question keys: ${ASK_QUESTION_KEYS.join(", ")}.`);
530
530
  const misplaced = misplacedQuestionKey(question);
531
- if (misplaced !== void 0) return invalidAskUserQuestion(`${at} carries the misplaced key ${JSON.stringify(misplaced)}: option fields collapsed into the question object. Build ONE question object and nest its choices inside it: {"id": "palette", "question": "Which palette?", "options": [{"label": "Warm", "description": "…"}]}. Known question keys: ${ASK_QUESTION_KEYS.join(", ")}.`);
531
+ if (misplaced !== void 0) {
532
+ if (misplaced !== "options" && misplaced.trim() === "options") return invalidAskUserQuestion(`${at} has an options property whose key contains surrounding whitespace. Do not copy that malformed key or retry with another variant. Rebuild ONE fresh call with the exact, case-sensitive key "options" (no spaces, annotations, or underscores), and nest its choices inside it: {"questions":[{"id":"choice","question":"Which choice?","options":[{"label":"A","description":"…"}]}]}. The complete top-level object must contain the questions array.`);
533
+ return invalidAskUserQuestion(`${at} carries the misplaced key ${JSON.stringify(misplaced)}: option fields collapsed into the question object. Build ONE question object and nest its choices inside it: {"id": "palette", "question": "Which palette?", "options": [{"label": "Warm", "description": "…"}]}. Known question keys: ${ASK_QUESTION_KEYS.join(", ")}.`);
534
+ }
532
535
  const id = question["id"];
533
536
  if (typeof id !== "string" || id.trim().length === 0 || !READABLE_ID_PATTERN.test(id)) return invalidAskUserQuestion(`${at} needs "id" to be a non-empty string with at least one letter or digit. A blank string, whitespace, ":" or "---" is not a usable id: the answer is echoed back against that id, so use a stable slug such as "palette-choice".`);
534
537
  const trimmedId = id.trim();
@@ -1429,7 +1432,7 @@ var PlanModeController = class extends Service {
1429
1432
  * 冻结契约的一部分:只经 {@link createPlanNotice} 的尾部用户消息投递,**不进 system
1430
1433
  * 段、不动工具表**,所以它不会让任何前端前缀缓存重建。
1431
1434
  */
1432
- const PLAN_EXIT_REMINDER_TEXT = "Plan mode is still active, and the previous response ended in plain text without calling a tool. If the plan is ready, call exit_plan_mode now with the complete markdown plan (starting with a # heading) as the sole tool call. If an unsettled user decision blocks planning, call ask_user_question instead. If the user explicitly asked to abandon planning, call leave_plan_mode.";
1435
+ const PLAN_EXIT_REMINDER_TEXT = "Plan mode is still active, and the previous response ended in plain text without calling a tool. If the plan is ready, make ONE code_run program whose only sub-call is exit_plan_mode with the complete markdown plan (starting with a # heading), as the sole top-level tool call. If an unsettled user decision blocks planning, call ask_user_question inside code_run instead. If the user explicitly asked to abandon planning, call leave_plan_mode inside code_run.";
1433
1436
  /** 登记册在 `globalThis` 上的键。跨模块实例共享,值本身只由本模块写入。 */
1434
1437
  const EXIT_REMINDER_KEY = Symbol.for("dsh-chatgpt-subscription.plan-mode.exit-reminder.claimed");
1435
1438
  /**
@@ -96,7 +96,9 @@ const PROGRESS_UPDATE_DESCRIPTION = [
96
96
  "explain what you are waiting for before a long wait such as a test run, an install, or a build;",
97
97
  "and say what blocks you — and what you will try next, or what you need from the user — when you are stuck.",
98
98
  "Each update has one short title line (plain text, no Markdown, no trailing period) with the details in the message body.",
99
- "Do not repeat a status that has not changed.",
99
+ "Do not repeat a status that has not changed. Use exactly one opening and one closing update per task.",
100
+ "Never announce an intended tool call instead of making it. After an opening or intermediate update, perform actual work, ask a necessary question, or finish before considering another update.",
101
+ "If a repeat-tool reminder names progress_update, do not answer with another progress update: inspect the previous result and continue with a task tool, a necessary question, or the final response.",
100
102
  "When you run as a subagent, describe only your own subtask: finishing your subtask is not the same as finishing the overall task."
101
103
  ].join(" ");
102
104
  /**
@@ -304,6 +306,8 @@ const PROGRESS_GUIDANCE = [
304
306
  "- **Opening**: before the first tool call of the task, send one update stating the plan (which steps, what you touch first). The user must be able to redirect you before you disappear into execution.",
305
307
  "- **Closing**: after the work is done and before your final answer, send one update stating the result (what changed, what was verified, what is left). The panel and the conversation both close on this line.",
306
308
  "",
309
+ "Use exactly one opening and one closing update per task. Never announce an intended tool call instead of making it: after an opening or intermediate update, perform actual work, ask a necessary question, or finish before considering another update. If a repeat-tool reminder names `progress_update`, do not answer with another progress update; inspect the previous result and continue with a task tool, a necessary question, or the final response.",
310
+ "",
307
311
  "Beyond those two, these moments are worth a report:",
308
312
  "- **Early planning**: the opening update covers it; report again only when the plan really changes (different approach, smaller scope, a broken premise).",
309
313
  "- **A meaningful conclusion**: a key fact, a root cause, a verified assumption — report the conclusion itself, not \"I just read a file\".",