@eddyskywalker/dsh-chatgpt-subscription 0.99.1 → 1.0.1

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 (179) hide show
  1. package/README.md +2 -1
  2. package/lib/client.js +1565 -581
  3. package/lib/client.js.map +1 -1
  4. package/lib/codemode.js +107 -3
  5. package/lib/index.js +3409 -932
  6. package/lib/{preset-sync-CF9xlG1l.js → preset-sync-DWOAwSyl.js} +5 -4
  7. package/lib/reverse-board.js +1726 -0
  8. package/lib/{tool-result-pruner-Ds--y6hJ.js → tool-result-pruner-ClgRVOph.js} +4 -3
  9. package/lib/tool-result-pruner.js +1 -1
  10. package/lib/types/client/common/ModelChecklist.d.ts +3 -3
  11. package/lib/types/client/common/ModelChecklist.d.ts.map +1 -1
  12. package/lib/types/client/common/format.d.ts +10 -0
  13. package/lib/types/client/common/format.d.ts.map +1 -1
  14. package/lib/types/client/features/progress-updates/locales.d.ts +11 -5
  15. package/lib/types/client/features/progress-updates/locales.d.ts.map +1 -1
  16. package/lib/types/client/features/progress-updates/settings-binding.d.ts +3 -1
  17. package/lib/types/client/features/progress-updates/settings-binding.d.ts.map +1 -1
  18. package/lib/types/client/features/progress-updates/settings-section.d.ts +2 -0
  19. package/lib/types/client/features/progress-updates/settings-section.d.ts.map +1 -1
  20. package/lib/types/client/hub/brand-icons.d.ts +1 -1
  21. package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
  22. package/lib/types/client/hub/providers.d.ts.map +1 -1
  23. package/lib/types/client/index.d.ts +2 -0
  24. package/lib/types/client/index.d.ts.map +1 -1
  25. package/lib/types/client/locales-ru/claude-api.d.ts.map +1 -1
  26. package/lib/types/client/locales-ru/claude.d.ts.map +1 -1
  27. package/lib/types/client/locales-ru/hub.d.ts.map +1 -1
  28. package/lib/types/client/locales-ru/index.d.ts.map +1 -1
  29. package/lib/types/client/locales-ru/kimi-code.d.ts.map +1 -1
  30. package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
  31. package/lib/types/client/locales-ru/sub2api.d.ts +3 -0
  32. package/lib/types/client/locales-ru/sub2api.d.ts.map +1 -0
  33. package/lib/types/client/providers/claude/ClaudeSection.d.ts.map +1 -1
  34. package/lib/types/client/providers/claude/locales.d.ts +8 -2
  35. package/lib/types/client/providers/claude/locales.d.ts.map +1 -1
  36. package/lib/types/client/providers/claude/useClaudeSection.d.ts +1 -0
  37. package/lib/types/client/providers/claude/useClaudeSection.d.ts.map +1 -1
  38. package/lib/types/client/providers/claude-api/ClaudeApiSection.d.ts.map +1 -1
  39. package/lib/types/client/providers/claude-api/locales.d.ts +5 -1
  40. package/lib/types/client/providers/claude-api/locales.d.ts.map +1 -1
  41. package/lib/types/client/providers/claude-api/useClaudeApiSection.d.ts +1 -0
  42. package/lib/types/client/providers/claude-api/useClaudeApiSection.d.ts.map +1 -1
  43. package/lib/types/client/providers/codex-chatgpt/CodexSubscriptionSection.d.ts.map +1 -1
  44. package/lib/types/client/providers/codex-chatgpt/locales.d.ts +5 -3
  45. package/lib/types/client/providers/codex-chatgpt/locales.d.ts.map +1 -1
  46. package/lib/types/client/providers/codex-chatgpt/styles.d.ts.map +1 -1
  47. package/lib/types/client/providers/command-code/CommandCodeSection.d.ts.map +1 -1
  48. package/lib/types/client/providers/command-code/locales.d.ts +2 -2
  49. package/lib/types/client/providers/glm-coding-plan/GlmCodingPlanSection.d.ts.map +1 -1
  50. package/lib/types/client/providers/kimi-code/KimiCodeSection.d.ts.map +1 -1
  51. package/lib/types/client/providers/kimi-code/locales.d.ts +8 -2
  52. package/lib/types/client/providers/kimi-code/locales.d.ts.map +1 -1
  53. package/lib/types/client/providers/minimax-code/MinimaxCodeSection.d.ts.map +1 -1
  54. package/lib/types/client/providers/opencode-zen/useZenSection.d.ts +1 -0
  55. package/lib/types/client/providers/opencode-zen/useZenSection.d.ts.map +1 -1
  56. package/lib/types/client/providers/relayone/locales.d.ts +12 -12
  57. package/lib/types/client/providers/step-code/StepCodeSection.d.ts.map +1 -1
  58. package/lib/types/client/providers/sub2api/Sub2ApiSection.d.ts +7 -0
  59. package/lib/types/client/providers/sub2api/Sub2ApiSection.d.ts.map +1 -0
  60. package/lib/types/client/providers/sub2api/locales.d.ts +212 -0
  61. package/lib/types/client/providers/sub2api/locales.d.ts.map +1 -0
  62. package/lib/types/client/providers/sub2api/styles.d.ts +3 -0
  63. package/lib/types/client/providers/sub2api/styles.d.ts.map +1 -0
  64. package/lib/types/compat.d.ts +1 -1
  65. package/lib/types/compat.d.ts.map +1 -1
  66. package/lib/types/entries/reverse-board.d.ts +6 -0
  67. package/lib/types/entries/reverse-board.d.ts.map +1 -0
  68. package/lib/types/entries/tool-result-pruner.d.ts.map +1 -1
  69. package/lib/types/host/common/i18n/zh.d.ts +1 -1
  70. package/lib/types/host/common/model-request-control.d.ts +1 -1
  71. package/lib/types/host/common/model-request-control.d.ts.map +1 -1
  72. package/lib/types/host/common/prompt-cache-policy.d.ts.map +1 -1
  73. package/lib/types/host/common/request-diagnostics.d.ts +1 -1
  74. package/lib/types/host/common/request-diagnostics.d.ts.map +1 -1
  75. package/lib/types/host/providers/claude/routes.d.ts.map +1 -1
  76. package/lib/types/host/providers/claude/token-store.d.ts +3 -0
  77. package/lib/types/host/providers/claude/token-store.d.ts.map +1 -1
  78. package/lib/types/host/providers/claude-api/routes.d.ts.map +1 -1
  79. package/lib/types/host/providers/claude-api/token-store.d.ts +3 -0
  80. package/lib/types/host/providers/claude-api/token-store.d.ts.map +1 -1
  81. package/lib/types/host/providers/kimi-code/cache-wait.d.ts +12 -0
  82. package/lib/types/host/providers/kimi-code/cache-wait.d.ts.map +1 -1
  83. package/lib/types/host/providers/kimi-code/routes.d.ts.map +1 -1
  84. package/lib/types/host/providers/kimi-code/token-store.d.ts +4 -0
  85. package/lib/types/host/providers/kimi-code/token-store.d.ts.map +1 -1
  86. package/lib/types/host/providers/relayone/types.d.ts +1 -1
  87. package/lib/types/host/providers/relayone/types.d.ts.map +1 -1
  88. package/lib/types/host/providers/sub2api/account-pool.d.ts +34 -0
  89. package/lib/types/host/providers/sub2api/account-pool.d.ts.map +1 -0
  90. package/lib/types/host/providers/sub2api/adapter.d.ts +59 -0
  91. package/lib/types/host/providers/sub2api/adapter.d.ts.map +1 -0
  92. package/lib/types/host/providers/sub2api/cache-stats.d.ts +19 -0
  93. package/lib/types/host/providers/sub2api/cache-stats.d.ts.map +1 -0
  94. package/lib/types/host/providers/sub2api/client.d.ts +6 -0
  95. package/lib/types/host/providers/sub2api/client.d.ts.map +1 -0
  96. package/lib/types/host/providers/sub2api/mapper-gemini.d.ts +10 -0
  97. package/lib/types/host/providers/sub2api/mapper-gemini.d.ts.map +1 -0
  98. package/lib/types/host/providers/sub2api/mapper-messages.d.ts +14 -0
  99. package/lib/types/host/providers/sub2api/mapper-messages.d.ts.map +1 -0
  100. package/lib/types/host/providers/sub2api/mapper-responses.d.ts +7 -0
  101. package/lib/types/host/providers/sub2api/mapper-responses.d.ts.map +1 -0
  102. package/lib/types/host/providers/sub2api/mapper.d.ts +34 -0
  103. package/lib/types/host/providers/sub2api/mapper.d.ts.map +1 -0
  104. package/lib/types/host/providers/sub2api/model-catalog.d.ts +72 -0
  105. package/lib/types/host/providers/sub2api/model-catalog.d.ts.map +1 -0
  106. package/lib/types/host/providers/sub2api/remote-compaction.d.ts +32 -0
  107. package/lib/types/host/providers/sub2api/remote-compaction.d.ts.map +1 -0
  108. package/lib/types/host/providers/sub2api/routes.d.ts +16 -0
  109. package/lib/types/host/providers/sub2api/routes.d.ts.map +1 -0
  110. package/lib/types/host/providers/sub2api/token-store.d.ts +43 -0
  111. package/lib/types/host/providers/sub2api/token-store.d.ts.map +1 -0
  112. package/lib/types/host/providers/sub2api/types.d.ts +14 -0
  113. package/lib/types/host/providers/sub2api/types.d.ts.map +1 -0
  114. package/lib/types/host/runtime/advisor/catalog-route.d.ts +20 -0
  115. package/lib/types/host/runtime/advisor/catalog-route.d.ts.map +1 -0
  116. package/lib/types/host/runtime/advisor/index.d.ts.map +1 -1
  117. package/lib/types/host/runtime/advisor/selection-store.d.ts +9 -1
  118. package/lib/types/host/runtime/advisor/selection-store.d.ts.map +1 -1
  119. package/lib/types/host/runtime/codemode/transport.d.ts +5 -0
  120. package/lib/types/host/runtime/codemode/transport.d.ts.map +1 -1
  121. package/lib/types/host/runtime/compact-after-turn/index.d.ts +15 -0
  122. package/lib/types/host/runtime/compact-after-turn/index.d.ts.map +1 -1
  123. package/lib/types/host/runtime/compaction-gate.d.ts +67 -0
  124. package/lib/types/host/runtime/compaction-gate.d.ts.map +1 -0
  125. package/lib/types/host/runtime/deepseek-v41-flash/state-anchor.d.ts +8 -0
  126. package/lib/types/host/runtime/deepseek-v41-flash/state-anchor.d.ts.map +1 -1
  127. package/lib/types/host/runtime/guards/compaction-policy-guard.d.ts +1 -0
  128. package/lib/types/host/runtime/guards/compaction-policy-guard.d.ts.map +1 -1
  129. package/lib/types/host/runtime/guards/ptc-sdk-cache-guard.d.ts.map +1 -1
  130. package/lib/types/host/runtime/guards/timeline-cache-guard.d.ts.map +1 -1
  131. package/lib/types/host/runtime/open-models/profiles.d.ts.map +1 -1
  132. package/lib/types/host/runtime/open-models/state-anchor.d.ts.map +1 -1
  133. package/lib/types/host/runtime/presets/agent-preset.d.ts +10 -25
  134. package/lib/types/host/runtime/presets/agent-preset.d.ts.map +1 -1
  135. package/lib/types/host/runtime/presets/preset-sync.d.ts +2 -0
  136. package/lib/types/host/runtime/presets/preset-sync.d.ts.map +1 -1
  137. package/lib/types/host/runtime/presets/reverse-persona.d.ts +3 -0
  138. package/lib/types/host/runtime/presets/reverse-persona.d.ts.map +1 -0
  139. package/lib/types/host/runtime/reverse/frontier.d.ts +10 -0
  140. package/lib/types/host/runtime/reverse/frontier.d.ts.map +1 -0
  141. package/lib/types/host/runtime/reverse/ids.d.ts +8 -0
  142. package/lib/types/host/runtime/reverse/ids.d.ts.map +1 -0
  143. package/lib/types/host/runtime/reverse/index.d.ts +20 -0
  144. package/lib/types/host/runtime/reverse/index.d.ts.map +1 -0
  145. package/lib/types/host/runtime/reverse/indexer.d.ts +9 -0
  146. package/lib/types/host/runtime/reverse/indexer.d.ts.map +1 -0
  147. package/lib/types/host/runtime/reverse/policy.d.ts +5 -0
  148. package/lib/types/host/runtime/reverse/policy.d.ts.map +1 -0
  149. package/lib/types/host/runtime/reverse/route-policy.d.ts +10 -0
  150. package/lib/types/host/runtime/reverse/route-policy.d.ts.map +1 -0
  151. package/lib/types/host/runtime/reverse/store.d.ts +91 -0
  152. package/lib/types/host/runtime/reverse/store.d.ts.map +1 -0
  153. package/lib/types/host/runtime/reverse/templates.d.ts +10 -0
  154. package/lib/types/host/runtime/reverse/templates.d.ts.map +1 -0
  155. package/lib/types/host/runtime/reverse/tool.d.ts +25 -0
  156. package/lib/types/host/runtime/reverse/tool.d.ts.map +1 -0
  157. package/lib/types/host/runtime/reverse/types.d.ts +182 -0
  158. package/lib/types/host/runtime/reverse/types.d.ts.map +1 -0
  159. package/lib/types/index.d.ts +13 -0
  160. package/lib/types/index.d.ts.map +1 -1
  161. package/lib/types/shared/claude-api-contracts.d.ts +2 -0
  162. package/lib/types/shared/claude-api-contracts.d.ts.map +1 -1
  163. package/lib/types/shared/claude-contracts.d.ts +3 -0
  164. package/lib/types/shared/claude-contracts.d.ts.map +1 -1
  165. package/lib/types/shared/contracts.d.ts +1 -1
  166. package/lib/types/shared/contracts.d.ts.map +1 -1
  167. package/lib/types/shared/kimi-code-contracts.d.ts +3 -0
  168. package/lib/types/shared/kimi-code-contracts.d.ts.map +1 -1
  169. package/lib/types/shared/relayone-contracts.d.ts +2 -2
  170. package/lib/types/shared/relayone-contracts.d.ts.map +1 -1
  171. package/lib/types/shared/sub2api-contracts.d.ts +103 -0
  172. package/lib/types/shared/sub2api-contracts.d.ts.map +1 -0
  173. package/package.json +6 -2
  174. package/presets/reverse/README.md +30 -0
  175. package/presets/reverse/agent.cordis.yml +228 -0
  176. package/presets/reverse/preset.yml +3 -0
  177. package/presets/team/README.md +0 -72
  178. package/presets/team/agent.cordis.yml +0 -414
  179. package/presets/team/preset.yml +0 -3
package/lib/codemode.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as PLUGIN_MESSAGE_SOURCE_KIND, t as candidatePackageRoots } from "./preset-sync-CF9xlG1l.js";
1
+ import { c as PLUGIN_MESSAGE_SOURCE_KIND, t as candidatePackageRoots } from "./preset-sync-DWOAwSyl.js";
2
2
  import { createRequire } from "node:module";
3
3
  import * as dshLlm from "@deepseek-ai/dsh-llm";
4
4
  import { HarnessError, createUserMessage } from "@deepseek-ai/dsh-llm";
@@ -1337,6 +1337,15 @@ function createTransportDefinition(host, rules) {
1337
1337
  return [...inspection.blocks];
1338
1338
  },
1339
1339
  presentCall(args) {
1340
+ const directShell = directShellCallOf(args);
1341
+ if (directShell !== void 0) {
1342
+ const command = stringOf(directShell.record["command"]) ?? "";
1343
+ return {
1344
+ card: "generic",
1345
+ title: directShell.description ?? descriptionFromCode(command),
1346
+ kind: "execute"
1347
+ };
1348
+ }
1340
1349
  try {
1341
1350
  const input = readArguments(args);
1342
1351
  return {
@@ -1350,7 +1359,8 @@ function createTransportDefinition(host, rules) {
1350
1359
  }
1351
1360
  },
1352
1361
  async execute(args, exec) {
1353
- const input = readArguments(args);
1362
+ const directShell = directShellCallOf(args);
1363
+ const input = directShell === void 0 ? readArguments(args) : readShellArguments(directShell);
1354
1364
  const runtime = host.runtime();
1355
1365
  if (runtime === void 0) throw new CodemodeContextUnavailableError("codemode: no PTC runtime is mounted (ctx.ptcRuntime); the program transport is unavailable");
1356
1366
  if (input.timeoutMs !== void 0 && runtime.timeout !== void 0 === false && isStrictTimeoutUnsupported(runtime)) throw new CodemodeArgsError("timeoutMs is not available for this PTC runtime");
@@ -1359,6 +1369,12 @@ function createTransportDefinition(host, rules) {
1359
1369
  const prevalidatedEscalation = hasRawEscalation && runtime.sandboxMode !== void 0 ? validateEscalationArgs(input.rawSandboxPermissions, input.rawJustification) : void 0;
1360
1370
  await host.awaitPredecessors?.(exec.agent, exec.signal);
1361
1371
  const catalog = host.catalog(exec.agent, exec.toolStep ?? exec.toolSet);
1372
+ let code = input.code;
1373
+ if (directShell !== void 0) {
1374
+ const shell = shellToolOf(catalog);
1375
+ if (shell === void 0) throw missingCodeError(directShell.record, directShell.raw);
1376
+ code = shellProgramFor(shell, directShell.record);
1377
+ }
1362
1378
  const runController = new AbortController();
1363
1379
  const onOuterAbort = () => {
1364
1380
  runController.abort(exec.signal.reason);
@@ -1505,7 +1521,7 @@ function createTransportDefinition(host, rules) {
1505
1521
  controller: runController,
1506
1522
  signal: nestedSignal
1507
1523
  }) ?? (() => {});
1508
- const sanitizedCode = sanitizeReplTopLevelReturn(input.code, runtime.programFormat, runtime.language);
1524
+ const sanitizedCode = sanitizeReplTopLevelReturn(code, runtime.programFormat, runtime.language);
1509
1525
  const attempt = async () => {
1510
1526
  deferredProgramImages.length = 0;
1511
1527
  const authority = await host.runAuthority?.(exec.agent, nestedSignal);
@@ -1894,6 +1910,27 @@ const CODE_KEYS = Object.freeze([
1894
1910
  "program_source",
1895
1911
  "programSource"
1896
1912
  ]);
1913
+ /** 模型把 Shell 工具入参直接发给 `code_run` 时可能出现的键。 */
1914
+ const SHELL_ARG_KEYS = /* @__PURE__ */ new Set([
1915
+ "command",
1916
+ "workdir",
1917
+ "cwd",
1918
+ "workingDirectory",
1919
+ "working_directory",
1920
+ "timeoutMs",
1921
+ "timeout_ms",
1922
+ "run_in_background",
1923
+ "runInBackground",
1924
+ "description",
1925
+ "desc",
1926
+ "summary"
1927
+ ]);
1928
+ /** 可接住直接 Shell 调用的工具名;顺序即同场竞争时的优先级。 */
1929
+ const SHELL_TOOL_NAMES = Object.freeze([
1930
+ "win_bash",
1931
+ "bash",
1932
+ "pwsh"
1933
+ ]);
1897
1934
  /** 模型把「先汇报再执行」写成一次调用时,简报落在 `progress_update` 的那两个键上。 */
1898
1935
  const NARRATION_TITLE_KEY = "title";
1899
1936
  /** 见 {@link NARRATION_TITLE_KEY}。 */
@@ -1993,6 +2030,73 @@ function missingCodeError(record, raw) {
1993
2030
  const keys = Object.keys(record);
1994
2031
  return new CodemodeArgsError("codemode: invalid code: expected a non-empty string" + (keys.length === 0 ? "" : " (received keys: " + keys.join(", ") + (raw.trim().length > 0 ? "; raw: " + excerpt(raw) : "") + "; pass program source in \"code\")"));
1995
2032
  }
2033
+ /**
2034
+ * 认出「Shell 工具参数被直接发进 code_run」的形态。
2035
+ *
2036
+ * 审计(session-4ad29c19 turn 后期,约 37 万 token):模型连续 11 次把
2037
+ * `description`/`command`/`workdir` 直接发给 `code_run`,即使错误已要求程序源码,
2038
+ * 下一步仍重复同一形状。这里只接受字段集合完全吻合、且可选键类型正确的壳状参数;
2039
+ * 多一个陌生键就交给原来的拒绝路径,绝不把畸形对象猜成命令。
2040
+ *
2041
+ * @param args - 工具收到的原始参数。
2042
+ * @returns 壳状调用;不像时返回 `undefined`。
2043
+ */
2044
+ function directShellCallOf(args) {
2045
+ let parsed;
2046
+ try {
2047
+ parsed = parseArguments(args);
2048
+ } catch {
2049
+ return;
2050
+ }
2051
+ const record = parsed.record;
2052
+ if (codeOf(record) !== void 0) return void 0;
2053
+ if (stringOf(record["command"]) === void 0) return void 0;
2054
+ const keys = Object.keys(record);
2055
+ if (keys.length === 0 || keys.some((key) => !SHELL_ARG_KEYS.has(key))) return void 0;
2056
+ for (const key of [
2057
+ "workdir",
2058
+ "cwd",
2059
+ "workingDirectory",
2060
+ "working_directory"
2061
+ ]) if (record[key] !== void 0 && typeof record[key] !== "string") return void 0;
2062
+ for (const key of ["timeoutMs", "timeout_ms"]) {
2063
+ const value = record[key];
2064
+ if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || value <= 0)) return void 0;
2065
+ }
2066
+ for (const key of ["run_in_background", "runInBackground"]) if (record[key] !== void 0 && typeof record[key] !== "boolean") return void 0;
2067
+ const description = stringOf(record["description"])?.trim() ?? stringOf(record["desc"])?.trim() ?? stringOf(record["summary"])?.trim();
2068
+ return {
2069
+ record,
2070
+ ...description === void 0 ? {} : { description },
2071
+ raw: parsed.raw
2072
+ };
2073
+ }
2074
+ /** 在工具清单里挑一个能承接 Shell 参数的工具。 */
2075
+ function shellToolOf(catalog) {
2076
+ for (const name of SHELL_TOOL_NAMES) {
2077
+ const entry = catalog.find((candidate) => candidate.name === name);
2078
+ if (entry !== void 0) return entry;
2079
+ }
2080
+ }
2081
+ /** 把壳状参数包成一条调用真实 Shell 工具的程序。 */
2082
+ function shellProgramFor(entry, record) {
2083
+ const workdir = record["workdir"] ?? record["cwd"] ?? record["workingDirectory"] ?? record["working_directory"];
2084
+ const timeoutMs = record["timeoutMs"] ?? record["timeout_ms"];
2085
+ const runInBackground = record["run_in_background"] ?? record["runInBackground"];
2086
+ const args = { command: record["command"] };
2087
+ if (workdir !== void 0) args["workdir"] = workdir;
2088
+ if (timeoutMs !== void 0) args["timeoutMs"] = timeoutMs;
2089
+ if (runInBackground !== void 0) args["run_in_background"] = runInBackground;
2090
+ return "return await tools." + entry.name + "(" + JSON.stringify(args) + ")";
2091
+ }
2092
+ /** 把壳状调用读成程序传输的标题(真正源码要等工具清单才能生成)。 */
2093
+ function readShellArguments(direct) {
2094
+ const command = stringOf(direct.record["command"]) ?? "";
2095
+ return {
2096
+ code: "",
2097
+ description: direct.description ?? descriptionFromCode(command)
2098
+ };
2099
+ }
1996
2100
  /** 一段文本像不像程序源码(模型把源码直接发成字符串时判这个)。 */
1997
2101
  function looksLikeProgram(text) {
1998
2102
  return text.includes("\n") || /\b(await|return|const|let|function|import|console\.)\b/.test(text);