@askdkc/dsh-cli 0.12.2 → 0.13.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 (161) hide show
  1. package/README.md +6 -1
  2. package/cordis.patch.yml +12 -131
  3. package/lib/types/adapter/channel/session-projection.d.ts.map +1 -1
  4. package/lib/types/adapter/channel/session-projection.js +0 -7
  5. package/lib/types/adapter/ports/channel-view.d.ts +1 -1
  6. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  7. package/lib/types/dsh-adapter/bundled-presets.d.ts +3 -8
  8. package/lib/types/dsh-adapter/bundled-presets.d.ts.map +1 -1
  9. package/lib/types/dsh-adapter/bundled-presets.js +5 -20
  10. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  11. package/lib/types/dsh-adapter/channel/binding-events.js +2 -9
  12. package/lib/types/dsh-adapter/channel/external-commands.d.ts.map +1 -1
  13. package/lib/types/dsh-adapter/channel/external-commands.js +9 -33
  14. package/lib/types/dsh-adapter/channel/local-actions.d.ts +2 -1
  15. package/lib/types/dsh-adapter/channel/local-actions.d.ts.map +1 -1
  16. package/lib/types/dsh-adapter/channel/local-actions.js +6 -2
  17. package/lib/types/dsh-adapter/channel/model-actions.js +3 -3
  18. package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
  19. package/lib/types/dsh-adapter/channel/model-switch.js +0 -1
  20. package/lib/types/dsh-adapter/channel/permissions.d.ts +1 -6
  21. package/lib/types/dsh-adapter/channel/permissions.d.ts.map +1 -1
  22. package/lib/types/dsh-adapter/channel/permissions.js +2 -54
  23. package/lib/types/dsh-adapter/channel/projection.d.ts.map +1 -1
  24. package/lib/types/dsh-adapter/channel/projection.js +15 -70
  25. package/lib/types/dsh-adapter/channel/session-fork.d.ts.map +1 -1
  26. package/lib/types/dsh-adapter/channel/session-fork.js +0 -1
  27. package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
  28. package/lib/types/dsh-adapter/channel/session-metadata.js +1 -4
  29. package/lib/types/dsh-adapter/channel/session-resume.js +2 -2
  30. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  31. package/lib/types/dsh-adapter/channel/session-rewind.js +0 -1
  32. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  33. package/lib/types/dsh-adapter/channel/session-tree-actions.js +1 -2
  34. package/lib/types/dsh-adapter/channel/session-tree.d.ts.map +1 -1
  35. package/lib/types/dsh-adapter/channel/session-tree.js +9 -62
  36. package/lib/types/dsh-adapter/channel/skill-catalog.js +1 -1
  37. package/lib/types/dsh-adapter/channel/subagent-projection.d.ts.map +1 -1
  38. package/lib/types/dsh-adapter/channel/subagent-projection.js +2 -8
  39. package/lib/types/dsh-adapter/channel/transcript.d.ts +0 -16
  40. package/lib/types/dsh-adapter/channel/transcript.d.ts.map +1 -1
  41. package/lib/types/dsh-adapter/channel/transcript.js +0 -43
  42. package/lib/types/dsh-adapter/channel.js +2 -2
  43. package/lib/types/dsh-adapter/compat/index.d.ts +5 -25
  44. package/lib/types/dsh-adapter/compat/index.d.ts.map +1 -1
  45. package/lib/types/dsh-adapter/compat/index.js +5 -25
  46. package/lib/types/dsh-adapter/compat/liveSession.d.ts +12 -23
  47. package/lib/types/dsh-adapter/compat/liveSession.d.ts.map +1 -1
  48. package/lib/types/dsh-adapter/compat/liveSession.js +15 -68
  49. package/lib/types/dsh-adapter/compat/messages.d.ts +1 -3
  50. package/lib/types/dsh-adapter/compat/messages.d.ts.map +1 -1
  51. package/lib/types/dsh-adapter/compat/messages.js +2 -10
  52. package/lib/types/dsh-adapter/compat/persistence.d.ts +2 -3
  53. package/lib/types/dsh-adapter/compat/persistence.d.ts.map +1 -1
  54. package/lib/types/dsh-adapter/compat/persistence.js +9 -14
  55. package/lib/types/dsh-adapter/compat/sessionLog.d.ts +10 -144
  56. package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
  57. package/lib/types/dsh-adapter/compat/sessionLog.js +45 -275
  58. package/lib/types/dsh-adapter/compat/settings.d.ts +4 -10
  59. package/lib/types/dsh-adapter/compat/settings.d.ts.map +1 -1
  60. package/lib/types/dsh-adapter/compat/settings.js +6 -23
  61. package/lib/types/dsh-adapter/compat/shell.d.ts +2 -3
  62. package/lib/types/dsh-adapter/compat/shell.d.ts.map +1 -1
  63. package/lib/types/dsh-adapter/compat/shell.js +2 -7
  64. package/lib/types/dsh-adapter/contract.d.ts +4 -34
  65. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  66. package/lib/types/dsh-adapter/contract.js +8 -83
  67. package/lib/types/dsh-adapter/packaged-presets.d.ts +0 -19
  68. package/lib/types/dsh-adapter/packaged-presets.d.ts.map +1 -1
  69. package/lib/types/dsh-adapter/packaged-presets.js +1 -83
  70. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  71. package/lib/types/dsh-adapter/plugin.js +25 -168
  72. package/lib/types/dsh-adapter/preset-resolution.d.ts +1 -22
  73. package/lib/types/dsh-adapter/preset-resolution.d.ts.map +1 -1
  74. package/lib/types/dsh-adapter/preset-resolution.js +0 -34
  75. package/lib/types/dsh-adapter/presets.d.ts +1 -4
  76. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  77. package/lib/types/dsh-adapter/presets.js +3 -6
  78. package/lib/types/dsh-adapter/questions-answerer.d.ts +5 -43
  79. package/lib/types/dsh-adapter/questions-answerer.d.ts.map +1 -1
  80. package/lib/types/dsh-adapter/questions-answerer.js +7 -63
  81. package/lib/types/dsh-adapter/sessionTree.d.ts +0 -19
  82. package/lib/types/dsh-adapter/sessionTree.d.ts.map +1 -1
  83. package/lib/types/dsh-adapter/sessionTree.js +2 -112
  84. package/lib/types/dsh-adapter/sessions/header.d.ts +2 -2
  85. package/lib/types/dsh-adapter/sessions/header.d.ts.map +1 -1
  86. package/lib/types/dsh-adapter/sessions/header.js +2 -8
  87. package/lib/types/dsh-adapter/sessions/list.d.ts +7 -28
  88. package/lib/types/dsh-adapter/sessions/list.d.ts.map +1 -1
  89. package/lib/types/dsh-adapter/sessions/list.js +48 -103
  90. package/lib/types/dsh-adapter/sessions/store.d.ts +1 -2
  91. package/lib/types/dsh-adapter/sessions/store.d.ts.map +1 -1
  92. package/lib/types/dsh-adapter/sessions/store.js +7 -10
  93. package/lib/types/dsh-adapter/sharp.d.ts.map +1 -1
  94. package/lib/types/dsh-adapter/sharp.js +0 -1
  95. package/lib/types/dsh-adapter/subagents.d.ts +1 -2
  96. package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
  97. package/lib/types/dsh-adapter/subagents.js +1 -12
  98. package/lib/types/dsh-adapter/trajectory/aggregate.d.ts +1 -1
  99. package/lib/types/dsh-adapter/trajectory/aggregate.js +1 -1
  100. package/lib/types/dsh-adapter/trajectory/guards.d.ts +5 -22
  101. package/lib/types/dsh-adapter/trajectory/guards.d.ts.map +1 -1
  102. package/lib/types/dsh-adapter/trajectory/guards.js +5 -23
  103. package/lib/types/dsh-adapter/trajectory/projection.d.ts +5 -21
  104. package/lib/types/dsh-adapter/trajectory/projection.d.ts.map +1 -1
  105. package/lib/types/dsh-adapter/trajectory/projection.js +4 -38
  106. package/lib/types/dsh-adapter/trajectory/types.d.ts +1 -1
  107. package/lib/types/dsh-adapter/trajectory/types.d.ts.map +1 -1
  108. package/lib/types/i18n.d.ts +2 -22
  109. package/lib/types/i18n.d.ts.map +1 -1
  110. package/lib/types/i18n.js +2 -10
  111. package/lib/types/presetPrefs.d.ts +1 -3
  112. package/lib/types/presetPrefs.d.ts.map +1 -1
  113. package/lib/types/presetPrefs.js +2 -4
  114. package/node_modules/@askdkc/dsh-auth/README.ja.md +28 -3
  115. package/node_modules/@askdkc/dsh-auth/README.md +19 -3
  116. package/node_modules/@askdkc/dsh-auth/dsh-plugin.json +3 -3
  117. package/node_modules/@askdkc/dsh-auth/lib/THIRD_PARTY_NOTICES.txt +168 -0
  118. package/node_modules/@askdkc/dsh-auth/lib/abortable.d.ts +2 -0
  119. package/node_modules/@askdkc/dsh-auth/lib/abortable.js +9 -0
  120. package/node_modules/@askdkc/dsh-auth/lib/auth-contract.d.ts +66 -0
  121. package/node_modules/@askdkc/dsh-auth/lib/auth-contract.js +1 -0
  122. package/node_modules/@askdkc/dsh-auth/lib/command.js +15 -1
  123. package/node_modules/@askdkc/dsh-auth/lib/credentials.d.ts +8 -14
  124. package/node_modules/@askdkc/dsh-auth/lib/credentials.js +1 -1
  125. package/node_modules/@askdkc/dsh-auth/lib/index.d.ts +8 -27
  126. package/node_modules/@askdkc/dsh-auth/lib/index.js +67 -64
  127. package/node_modules/@askdkc/dsh-auth/lib/interaction.d.ts +5 -5
  128. package/node_modules/@askdkc/dsh-auth/lib/opencode-adapter.d.ts +37 -0
  129. package/node_modules/@askdkc/dsh-auth/lib/opencode-adapter.js +197 -0
  130. package/node_modules/@askdkc/dsh-auth/lib/opencode-catalog.d.ts +72 -0
  131. package/node_modules/@askdkc/dsh-auth/lib/opencode-catalog.js +252 -0
  132. package/node_modules/@askdkc/dsh-auth/lib/opencode-codec.d.ts +6 -0
  133. package/node_modules/@askdkc/dsh-auth/lib/opencode-codec.js +93 -0
  134. package/node_modules/@askdkc/dsh-auth/lib/opencode-owned.generated.d.ts +113 -0
  135. package/node_modules/@askdkc/dsh-auth/lib/opencode-owned.generated.js +2866 -0
  136. package/node_modules/@askdkc/dsh-auth/lib/opencode-replay.d.ts +15 -0
  137. package/node_modules/@askdkc/dsh-auth/lib/opencode-replay.js +141 -0
  138. package/node_modules/@askdkc/dsh-auth/lib/opencode-sdk.d.ts +5 -0
  139. package/node_modules/@askdkc/dsh-auth/lib/opencode-sdk.js +43465 -0
  140. package/node_modules/@askdkc/dsh-auth/lib/opencode-sdk.js.map +7 -0
  141. package/node_modules/@askdkc/dsh-auth/lib/opencode-transport.d.ts +5 -0
  142. package/node_modules/@askdkc/dsh-auth/lib/opencode-transport.js +69 -0
  143. package/node_modules/@askdkc/dsh-auth/lib/pi-ai.d.ts +2 -1
  144. package/node_modules/@askdkc/dsh-auth/lib/pi-ai.js +2 -1
  145. package/node_modules/@askdkc/dsh-auth/lib/pi-routes.d.ts +32 -0
  146. package/node_modules/@askdkc/dsh-auth/lib/pi-routes.js +45 -0
  147. package/node_modules/@askdkc/dsh-auth/lib/profiles.d.ts +2 -20
  148. package/node_modules/@askdkc/dsh-auth/lib/profiles.js +6 -35
  149. package/node_modules/@askdkc/dsh-auth/lib/routes.d.ts +20 -0
  150. package/node_modules/@askdkc/dsh-auth/lib/routes.js +13 -0
  151. package/node_modules/@askdkc/dsh-auth/lib/service.d.ts +11 -2
  152. package/node_modules/@askdkc/dsh-auth/lib/service.js +26 -16
  153. package/node_modules/@askdkc/dsh-auth/package.json +26 -14
  154. package/package.json +100 -96
  155. package/lib/types/dsh-adapter/providerGuard.d.ts +0 -75
  156. package/lib/types/dsh-adapter/providerGuard.d.ts.map +0 -1
  157. package/lib/types/dsh-adapter/providerGuard.js +0 -104
  158. package/lib/types/migrationPrefs.d.ts +0 -60
  159. package/lib/types/migrationPrefs.d.ts.map +0 -1
  160. package/lib/types/migrationPrefs.js +0 -97
  161. package/presets/liangshen/.dsh-tui-managed.json +0 -5
@@ -0,0 +1,93 @@
1
+ /** Convert DSH conversation blocks into low-level SDK prompts without an agent loop. */
2
+ import { LlmError, projectToolUpdates, fileHandleText } from '@deepseek-ai/dsh-llm';
3
+ import { projectReplay, requireReplaySignature } from './opencode-replay.js';
4
+ export async function encodePrompt(options, model, attachments, warn) {
5
+ const prompt = [];
6
+ const names = new Map();
7
+ const callIds = new Map();
8
+ if (options.system)
9
+ prompt.push({ role: 'system', content: options.system });
10
+ const projection = projectToolUpdates(options.messages, options.tools, undefined, options.toolHistory);
11
+ let imageBytes = 0;
12
+ const imagePart = async (block) => {
13
+ if (block.offloaded || !model.inputModalities.includes('image'))
14
+ return { type: 'text', text: '[image omitted from this request]' };
15
+ const store = attachments?.();
16
+ if (!store)
17
+ throw new LlmError('Image attachment service unavailable', 'ATTACHMENT_UNAVAILABLE');
18
+ const { requestImageDimensions } = await import('@deepseek-ai/dsh-attachment');
19
+ const image = await store.readImageRequest(block.attachment, { ...requestImageDimensions(block.attachment.width, block.attachment.height, 4_194_304), maxBytes: 1024 * 1024 }, options.signal);
20
+ imageBytes += Math.ceil(image.bytes / 3) * 4;
21
+ if (imageBytes > 20 * 1024 * 1024)
22
+ throw new LlmError('Image request exceeds 20 MiB', 'IMAGE_OFFLOAD_REQUIRED', { offloadImages: 1 });
23
+ return { type: 'file', mediaType: image.mediaType, data: { type: 'data', data: image.data } };
24
+ };
25
+ for (const message of projection.messages) {
26
+ if (message.role === 'system') {
27
+ prompt.push({ role: 'system', content: message.content.filter(block => block.type === 'text').map(block => block.text).join('\n') });
28
+ continue;
29
+ }
30
+ if (message.role === 'developer') {
31
+ const text = message.content.filter(block => block.type === 'text').map(block => block.text).join('\n');
32
+ if (text)
33
+ prompt.push({ role: 'system', content: text });
34
+ continue;
35
+ }
36
+ if (message.role === 'tool') {
37
+ const toolName = names.get(message.toolCallId);
38
+ if (!toolName)
39
+ throw new LlmError('Stored tool result has no matching call', 'INVALID_REPLAY_STATE');
40
+ const parts = [];
41
+ for (const block of message.content) {
42
+ if (block.type === 'text')
43
+ parts.push({ type: 'text', text: block.text });
44
+ else if (block.type === 'file')
45
+ parts.push({ type: 'text', text: fileHandleText(block.attachment, attachments?.()?.fileHostPath(block.attachment)) });
46
+ else if (block.type === 'image')
47
+ parts.push(await imagePart(block));
48
+ }
49
+ prompt.push({ role: 'tool', content: [{ type: 'tool-result', toolCallId: callIds.get(message.toolCallId) ?? message.toolCallId, toolName,
50
+ output: message.isError ? { type: 'error-text', value: parts.map(part => part.type === 'text' ? part.text : '[image]').join('\n') } : { type: 'content', value: parts } }] });
51
+ continue;
52
+ }
53
+ const content = [];
54
+ const replay = projectReplay('source' in message ? message.source : undefined, message.content, model, options.provider, warn);
55
+ for (const [original, wire] of replay.callIds)
56
+ callIds.set(original, wire);
57
+ for (const [index, block] of message.content.entries()) {
58
+ const providerOptions = replay.blocks[index];
59
+ if (block.type === 'text')
60
+ content.push({ type: 'text', text: block.text, providerOptions });
61
+ else if (block.type === 'file')
62
+ content.push({ type: 'text', text: fileHandleText(block.attachment, attachments?.()?.fileHostPath(block.attachment)) });
63
+ else if (block.type === 'reasoning' && message.role === 'assistant') {
64
+ requireReplaySignature(block, model.protocol, providerOptions);
65
+ content.push({ type: 'reasoning', text: block.text, providerOptions });
66
+ }
67
+ else if (block.type === 'tool-call' && message.role === 'assistant') {
68
+ if (model.protocol === 'responses' && block.id.includes('|') && !replay.callIds.has(block.id))
69
+ throw new LlmError('Cannot restore legacy Responses tool call pairing', 'INVALID_REPLAY_STATE');
70
+ if (names.has(block.id))
71
+ throw new LlmError('Duplicate stored tool call id', 'INVALID_REPLAY_STATE');
72
+ if (model.protocol === 'google' && model.reasoning && !providerOptions?.google?.thoughtSignature && !message.content.slice(0, index).some(part => part.type === 'tool-call'))
73
+ throw new LlmError('Cannot replay Google tool call without its verified thought signature', 'INVALID_REPLAY_STATE');
74
+ names.set(block.id, block.name);
75
+ let input;
76
+ try {
77
+ input = JSON.parse(block.arguments);
78
+ }
79
+ catch {
80
+ throw new LlmError('Stored tool arguments are not valid JSON', 'INVALID_REPLAY_STATE');
81
+ }
82
+ content.push({ type: 'tool-call', toolCallId: callIds.get(block.id) ?? block.id, toolName: block.name, input, providerOptions });
83
+ }
84
+ else if (block.type === 'image') {
85
+ if (message.role === 'assistant')
86
+ throw new LlmError('Structured assistant image output is unsupported', 'UNSUPPORTED_CONTENT');
87
+ content.push(await imagePart(block));
88
+ }
89
+ }
90
+ prompt.push({ role: message.role, content });
91
+ }
92
+ return prompt;
93
+ }
@@ -0,0 +1,113 @@
1
+ /** Generated from official rosters and exact-route models.dev metadata. */
2
+ export declare const OPEN_CODE_SNAPSHOTS: {
3
+ opencode: {
4
+ version: number;
5
+ provider: string;
6
+ fetchedAt: number;
7
+ roster: string[];
8
+ models: ({
9
+ id: string;
10
+ name: string;
11
+ protocol: string;
12
+ contextWindow: number;
13
+ maxTokens: number;
14
+ inputModalities: string[];
15
+ toolCall: boolean;
16
+ reasoning: boolean;
17
+ temperature: boolean;
18
+ efforts: string[];
19
+ cost: {
20
+ input: number;
21
+ output: number;
22
+ cache_read: number;
23
+ cache_write: number;
24
+ input_audio?: undefined;
25
+ };
26
+ } | {
27
+ id: string;
28
+ name: string;
29
+ protocol: string;
30
+ contextWindow: number;
31
+ maxTokens: number;
32
+ inputModalities: string[];
33
+ toolCall: boolean;
34
+ reasoning: boolean;
35
+ temperature: boolean;
36
+ efforts: string[];
37
+ cost: {
38
+ input: number;
39
+ output: number;
40
+ cache_read: number;
41
+ cache_write?: undefined;
42
+ input_audio?: undefined;
43
+ };
44
+ } | {
45
+ id: string;
46
+ name: string;
47
+ protocol: string;
48
+ contextWindow: number;
49
+ maxTokens: number;
50
+ inputModalities: string[];
51
+ toolCall: boolean;
52
+ reasoning: boolean;
53
+ temperature: boolean;
54
+ efforts: string[];
55
+ cost: {
56
+ input: number;
57
+ output: number;
58
+ cache_read: number;
59
+ input_audio: number;
60
+ cache_write?: undefined;
61
+ };
62
+ })[];
63
+ excluded: {
64
+ id: string;
65
+ reason: string;
66
+ }[];
67
+ };
68
+ "opencode-go": {
69
+ version: number;
70
+ provider: string;
71
+ fetchedAt: number;
72
+ roster: string[];
73
+ models: ({
74
+ id: string;
75
+ name: string;
76
+ protocol: string;
77
+ contextWindow: number;
78
+ maxTokens: number;
79
+ inputModalities: string[];
80
+ toolCall: boolean;
81
+ reasoning: boolean;
82
+ temperature: boolean;
83
+ efforts: string[];
84
+ cost: {
85
+ input: number;
86
+ output: number;
87
+ cache_read: number;
88
+ cache_write?: undefined;
89
+ };
90
+ } | {
91
+ id: string;
92
+ name: string;
93
+ protocol: string;
94
+ contextWindow: number;
95
+ maxTokens: number;
96
+ inputModalities: string[];
97
+ toolCall: boolean;
98
+ reasoning: boolean;
99
+ temperature: boolean;
100
+ efforts: string[];
101
+ cost: {
102
+ input: number;
103
+ output: number;
104
+ cache_read: number;
105
+ cache_write: number;
106
+ };
107
+ })[];
108
+ excluded: {
109
+ id: string;
110
+ reason: string;
111
+ }[];
112
+ };
113
+ };