@eddyskywalker/dsh-chatgpt-subscription 0.59.0 → 0.61.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 (75) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +1 -1
  3. package/lib/client.js +1578 -232
  4. package/lib/client.js.map +1 -1
  5. package/lib/codemode.js +795 -178
  6. package/lib/entry-plan-mode-CLRKkgYG.js +1787 -0
  7. package/lib/{entry-progress-updates-CxQewio9.js → entry-progress-updates-DZ0ZRus4.js} +14 -1
  8. package/lib/index.js +1079 -754
  9. package/lib/llm-compat-u9mor0uu.js +110 -0
  10. package/lib/plan-mode.js +2 -779
  11. package/lib/progress-updates.js +1 -1
  12. package/lib/types/client/codemode/CodeRunToolView.d.ts +68 -0
  13. package/lib/types/client/codemode/CodeRunToolView.d.ts.map +1 -0
  14. package/lib/types/client/codemode/highlight.d.ts +25 -0
  15. package/lib/types/client/codemode/highlight.d.ts.map +1 -0
  16. package/lib/types/client/codemode/styles.d.ts +11 -0
  17. package/lib/types/client/codemode/styles.d.ts.map +1 -0
  18. package/lib/types/client/codemode/tool-name.d.ts +10 -0
  19. package/lib/types/client/codemode/tool-name.d.ts.map +1 -0
  20. package/lib/types/client/index.d.ts.map +1 -1
  21. package/lib/types/client/locales-ru/hub.d.ts.map +1 -1
  22. package/lib/types/client/locales.d.ts +23 -1
  23. package/lib/types/client/locales.d.ts.map +1 -1
  24. package/lib/types/compat.d.ts +1 -1
  25. package/lib/types/entry-codemode.d.ts.map +1 -1
  26. package/lib/types/entry-plan-mode.d.ts +136 -0
  27. package/lib/types/entry-plan-mode.d.ts.map +1 -1
  28. package/lib/types/host/agent-preset.d.ts.map +1 -1
  29. package/lib/types/host/claude/adapter.d.ts +16 -0
  30. package/lib/types/host/claude/adapter.d.ts.map +1 -1
  31. package/lib/types/host/claude/client.d.ts +7 -1
  32. package/lib/types/host/claude/client.d.ts.map +1 -1
  33. package/lib/types/host/claude/mapper.d.ts +9 -0
  34. package/lib/types/host/claude/mapper.d.ts.map +1 -1
  35. package/lib/types/host/claude/types.d.ts +10 -0
  36. package/lib/types/host/claude/types.d.ts.map +1 -1
  37. package/lib/types/host/cline-pass/mapper.d.ts.map +1 -1
  38. package/lib/types/host/codemode/discovery.d.ts.map +1 -1
  39. package/lib/types/host/codemode/executor.d.ts.map +1 -1
  40. package/lib/types/host/codemode/rules.d.ts +16 -6
  41. package/lib/types/host/codemode/rules.d.ts.map +1 -1
  42. package/lib/types/host/codemode/transport.d.ts +120 -41
  43. package/lib/types/host/codemode/transport.d.ts.map +1 -1
  44. package/lib/types/host/command-code/mapper.d.ts.map +1 -1
  45. package/lib/types/host/command-code/model-catalog.d.ts +14 -14
  46. package/lib/types/host/command-code/model-catalog.d.ts.map +1 -1
  47. package/lib/types/host/command-code/routes.d.ts.map +1 -1
  48. package/lib/types/host/common/orphan-tool-calls.d.ts +48 -0
  49. package/lib/types/host/common/orphan-tool-calls.d.ts.map +1 -0
  50. package/lib/types/host/dispatch-execution-guard.d.ts +32 -2
  51. package/lib/types/host/dispatch-execution-guard.d.ts.map +1 -1
  52. package/lib/types/host/glm-coding-plan/mapper-anthropic.d.ts.map +1 -1
  53. package/lib/types/host/glm-coding-plan/mapper-openai.d.ts.map +1 -1
  54. package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
  55. package/lib/types/host/minimax-code/mapper.d.ts.map +1 -1
  56. package/lib/types/host/model-catalog.d.ts +21 -0
  57. package/lib/types/host/model-catalog.d.ts.map +1 -1
  58. package/lib/types/host/opendesign/mapper.d.ts.map +1 -1
  59. package/lib/types/host/plan-mode-cache-guard.d.ts.map +1 -1
  60. package/lib/types/host/preset-sync.d.ts +19 -4
  61. package/lib/types/host/preset-sync.d.ts.map +1 -1
  62. package/lib/types/host/progress-updates/nudge.d.ts +13 -1
  63. package/lib/types/host/progress-updates/nudge.d.ts.map +1 -1
  64. package/lib/types/host/qoder/mapper.d.ts.map +1 -1
  65. package/lib/types/host/responses-client.d.ts.map +1 -1
  66. package/lib/types/host/responses-mapper.d.ts +12 -0
  67. package/lib/types/host/responses-mapper.d.ts.map +1 -1
  68. package/lib/types/host/settled-job-guard.d.ts +77 -0
  69. package/lib/types/host/settled-job-guard.d.ts.map +1 -0
  70. package/lib/types/host/step-code/mapper.d.ts.map +1 -1
  71. package/lib/types/host/workbuddy/mapper.d.ts.map +1 -1
  72. package/lib/types/index.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/presets/dispatch/README.md +8 -13
  75. package/presets/dispatch/agent.cordis.yml +11 -16
@@ -0,0 +1,110 @@
1
+ import { LlmError as LlmError$1 } from "@deepseek-ai/dsh-llm";
2
+ //#region src/host/common/llm-compat.ts
3
+ /** This package's kind in the harness message-source map. */
4
+ const PLUGIN_MESSAGE_SOURCE_KIND = "dsh-chatgpt-subscription";
5
+ function isRecord(value) {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7
+ }
8
+ /** Read a message body's blocks, keeping every entry that carries a block tag. */
9
+ function readBlocks(raw) {
10
+ if (!Array.isArray(raw)) return [];
11
+ return raw.filter((block) => isRecord(block) && typeof block.type === "string");
12
+ }
13
+ /**
14
+ * The first value that is a non-empty string.
15
+ *
16
+ * Used for fields the two generations spell in different places: a value that
17
+ * is present but empty must not shadow a real one further down the chain, which
18
+ * is what `??` alone does.
19
+ */
20
+ function firstNonEmptyString(...values) {
21
+ for (const value of values) if (typeof value === "string" && value !== "") return value;
22
+ return "";
23
+ }
24
+ /**
25
+ * The result block a `role: 'tool'` message already carries inside its body.
26
+ *
27
+ * Some harness generations deliver the call id inside the result block rather
28
+ * than on the message, and one shape carries both: `role: 'tool'` with a
29
+ * `tool-result` block holding the id. Reading only the message-level fields
30
+ * leaves {@link toolCallIdOf} nothing to find.
31
+ */
32
+ function embeddedToolResult(content) {
33
+ if (content.length !== 1) return void 0;
34
+ const [block] = content;
35
+ return block?.type === "tool-result" ? block : void 0;
36
+ }
37
+ /**
38
+ * The call id one `role: 'tool'` message associates with its `tool-call`.
39
+ *
40
+ * The id is the only thing tying a result to the call it answers: a mapper that
41
+ * sends it empty makes every result an orphan and tells the repair pass that no
42
+ * call was answered, which some gateways reject outright (WorkBuddy answers
43
+ * `11148`, "tool calls and tool results do not match"). It therefore has to be
44
+ * read from every place the harness generations put it — the message, the
45
+ * message's source, and the result block inside the body — and an empty string
46
+ * must not shadow a later, real one.
47
+ */
48
+ function toolCallIdOf(raw, source, embedded) {
49
+ return firstNonEmptyString(raw.toolCallId, raw.callId, source?.callId, embedded?.toolCallId);
50
+ }
51
+ /**
52
+ * Normalize one harness message list into {@link Message}.
53
+ *
54
+ * A 0.1.7 `role: 'tool'` message is re-wrapped as the user-role message holding
55
+ * one {@link ToolResultBlock} that the mappers expect, keeping the tool
56
+ * provenance (`kind: 'tool'`) they use to tell a real tool result from a user
57
+ * turn. A message that already carries that block keeps its own body instead of
58
+ * nesting a second `tool-result` around it. Everything a newer harness adds
59
+ * beside that keeps its own shape.
60
+ * @param messages - Messages straight off the request options, in either generation's shape.
61
+ * @returns The same conversation in the pre-0.1.7 vocabulary.
62
+ */
63
+ function normalizeMessages(messages) {
64
+ const normalized = [];
65
+ for (const raw of messages ?? []) {
66
+ if (!isRecord(raw)) continue;
67
+ const content = readBlocks(raw.content);
68
+ if (raw.role === "tool") {
69
+ const source = isRecord(raw.source) ? raw.source : void 0;
70
+ const embedded = embeddedToolResult(content);
71
+ const callId = toolCallIdOf(raw, source, embedded);
72
+ const isError = raw.isError === true || embedded?.isError === true;
73
+ normalized.push({
74
+ id: raw.id,
75
+ role: "user",
76
+ content: [{
77
+ type: "tool-result",
78
+ toolCallId: callId,
79
+ content: embedded === void 0 ? content : embedded.content,
80
+ ...isError ? { isError: true } : {}
81
+ }],
82
+ source: {
83
+ kind: "tool",
84
+ callId
85
+ }
86
+ });
87
+ continue;
88
+ }
89
+ normalized.push({
90
+ id: raw.id,
91
+ role: typeof raw.role === "string" ? raw.role : "user",
92
+ content,
93
+ ...isRecord(raw.source) ? { source: raw.source } : {}
94
+ });
95
+ }
96
+ return normalized;
97
+ }
98
+ /**
99
+ * Normalize request options for the mappers.
100
+ * @param options - Request options the harness handed the adapter.
101
+ * @returns The same options with {@link Message} history.
102
+ */
103
+ function normalizeGenerateOptions(options) {
104
+ return {
105
+ ...options,
106
+ messages: normalizeMessages(options.messages)
107
+ };
108
+ }
109
+ //#endregion
110
+ export { PLUGIN_MESSAGE_SOURCE_KIND as n, normalizeGenerateOptions as r, LlmError$1 as t };