@deepseek-harness-tui/dsh-tui 0.17.0 → 0.18.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 (186) hide show
  1. package/README.md +10 -8
  2. package/cli/adapters/dsh/index.mjs +2 -2
  3. package/guide/dsh-tui-guide/cli.en.md +1 -1
  4. package/guide/dsh-tui-guide/cli.md +1 -1
  5. package/guide/dsh-tui-guide/configuration.en.md +3 -2
  6. package/guide/dsh-tui-guide/configuration.md +3 -2
  7. package/guide/dsh-tui-guide/getting-started.en.md +6 -2
  8. package/guide/dsh-tui-guide/getting-started.md +4 -1
  9. package/guide/dsh-tui-guide/interaction.en.md +28 -7
  10. package/guide/dsh-tui-guide/interaction.md +17 -5
  11. package/guide/dsh-tui-guide/plugins.en.md +28 -7
  12. package/guide/dsh-tui-guide/plugins.md +18 -5
  13. package/guide/dsh-tui-guide/user-guide.en.md +29 -15
  14. package/guide/dsh-tui-guide/user-guide.md +20 -10
  15. package/lib/settings.json +3 -3
  16. package/lib/types/adapter/channel/ui-policy.d.ts +1 -0
  17. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  18. package/lib/types/adapter/channel/ui-policy.js +1 -0
  19. package/lib/types/adapter/ports/channel-ui.d.ts +5 -0
  20. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  21. package/lib/types/adapter/ports/channel-view.d.ts +3 -0
  22. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  23. package/lib/types/adapter/standard/grants.d.ts +60 -0
  24. package/lib/types/adapter/standard/grants.d.ts.map +1 -1
  25. package/lib/types/adapter/standard/grants.js +74 -0
  26. package/lib/types/agent/events.d.ts +7 -1
  27. package/lib/types/agent/events.d.ts.map +1 -1
  28. package/lib/types/commands.js +1 -1
  29. package/lib/types/components/GoalTodoPanel.d.ts +71 -6
  30. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  31. package/lib/types/components/GoalTodoPanel.js +165 -17
  32. package/lib/types/components/MessageList.d.ts.map +1 -1
  33. package/lib/types/components/MessageList.js +3 -2
  34. package/lib/types/components/PluginGrantList.d.ts +45 -0
  35. package/lib/types/components/PluginGrantList.d.ts.map +1 -0
  36. package/lib/types/components/PluginGrantList.js +126 -0
  37. package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
  38. package/lib/types/components/PluginInstallPane.js +35 -6
  39. package/lib/types/components/PluginManagePane.d.ts.map +1 -1
  40. package/lib/types/components/PluginManagePane.js +65 -8
  41. package/lib/types/components/PromptInput.js +2 -2
  42. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  43. package/lib/types/components/SubagentDashboard.js +10 -0
  44. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  45. package/lib/types/components/SubagentDetailScene.js +12 -0
  46. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
  47. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  48. package/lib/types/components/messages/AssistantToolUseMessage.js +11 -5
  49. package/lib/types/components/onboardingModel.d.ts +2 -2
  50. package/lib/types/components/onboardingModel.js +3 -3
  51. package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
  52. package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
  53. package/lib/types/components/onboardingProviderPlan.js +78 -0
  54. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +7 -0
  55. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  56. package/lib/types/components/sidePanel/btw/BtwComposer.js +16 -0
  57. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  58. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +8 -1
  59. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
  60. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  61. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +8 -1
  62. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
  63. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
  64. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
  65. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  66. package/lib/types/components/sidePanel/builtinPanels.js +14 -2
  67. package/lib/types/components/sidePanel/types.d.ts +2 -0
  68. package/lib/types/components/sidePanel/types.d.ts.map +1 -1
  69. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  70. package/lib/types/components/sidePanel/useSidePanel.js +15 -1
  71. package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
  72. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  73. package/lib/types/dsh-adapter/backend/session.js +62 -6
  74. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  75. package/lib/types/dsh-adapter/backend/translate.js +9 -5
  76. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
  77. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
  78. package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
  79. package/lib/types/dsh-adapter/channel/composer-images.d.ts +2 -0
  80. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  81. package/lib/types/dsh-adapter/channel/composer-images.js +10 -2
  82. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  83. package/lib/types/dsh-adapter/channel/composer-mentions.js +22 -7
  84. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +1 -1
  85. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  86. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +9 -5
  87. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +6 -0
  88. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  89. package/lib/types/dsh-adapter/channel/core/binding-feed.js +35 -1
  90. package/lib/types/dsh-adapter/channel/core/compose.d.ts +1 -1
  91. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  92. package/lib/types/dsh-adapter/channel/core/compose.js +5 -0
  93. package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
  94. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  95. package/lib/types/dsh-adapter/channel/input-actions.js +30 -0
  96. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +1 -1
  97. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  98. package/lib/types/dsh-adapter/channel/input-delivery.js +8 -4
  99. package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
  100. package/lib/types/dsh-adapter/channel/mentions.js +21 -7
  101. package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
  102. package/lib/types/dsh-adapter/channel/paths.js +11 -9
  103. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
  104. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
  105. package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
  106. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  107. package/lib/types/dsh-adapter/channel/session-reset.js +3 -1
  108. package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
  109. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  110. package/lib/types/dsh-adapter/channel/session-resume.js +10 -3
  111. package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
  112. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  113. package/lib/types/dsh-adapter/channel/session-rewind.js +3 -1
  114. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
  115. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  116. package/lib/types/dsh-adapter/channel/session-tree-actions.js +3 -1
  117. package/lib/types/dsh-adapter/contract.d.ts +4 -3
  118. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  119. package/lib/types/dsh-adapter/contract.js +6 -3
  120. package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
  121. package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
  122. package/lib/types/dsh-adapter/experimental-bundles.d.ts +3 -0
  123. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -1
  124. package/lib/types/dsh-adapter/experimental-bundles.js +4 -0
  125. package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
  126. package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
  127. package/lib/types/dsh-adapter/grant-file.js +178 -0
  128. package/lib/types/dsh-adapter/host-access.d.ts +4 -0
  129. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  130. package/lib/types/dsh-adapter/host-access.js +54 -4
  131. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  132. package/lib/types/dsh-adapter/host-contract.js +2 -2
  133. package/lib/types/dsh-adapter/host-dsh.js +3 -3
  134. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  135. package/lib/types/dsh-adapter/index.js +8 -5
  136. package/lib/types/dsh-adapter/panels.d.ts +7 -1
  137. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  138. package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
  139. package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
  140. package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
  141. package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
  142. package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
  143. package/lib/types/dsh-adapter/plugin-install.js +160 -13
  144. package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
  145. package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
  146. package/lib/types/dsh-adapter/plugin-manage.js +240 -51
  147. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  148. package/lib/types/dsh-adapter/plugin.js +64 -18
  149. package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
  150. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  151. package/lib/types/dsh-adapter/plugins-info.js +34 -21
  152. package/lib/types/dsh-adapter/presets.d.ts +6 -2
  153. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  154. package/lib/types/dsh-adapter/presets.js +23 -5
  155. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  156. package/lib/types/dsh-adapter/process-exit.js +1 -1
  157. package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
  158. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
  159. package/lib/types/dsh-adapter/providerWizard.js +11 -5
  160. package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
  161. package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
  162. package/lib/types/dsh-adapter/row-attachment.js +29 -0
  163. package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
  164. package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
  165. package/lib/types/dsh-adapter/worktree-tool.js +87 -0
  166. package/lib/types/heldInputs.d.ts +36 -0
  167. package/lib/types/heldInputs.d.ts.map +1 -0
  168. package/lib/types/heldInputs.js +173 -0
  169. package/lib/types/i18n.d.ts +352 -25
  170. package/lib/types/i18n.d.ts.map +1 -1
  171. package/lib/types/i18n.js +171 -18
  172. package/lib/types/onboardingDraft.d.ts +143 -0
  173. package/lib/types/onboardingDraft.d.ts.map +1 -0
  174. package/lib/types/onboardingDraft.js +71 -0
  175. package/lib/types/screens/Chat.d.ts.map +1 -1
  176. package/lib/types/screens/Chat.js +90 -30
  177. package/lib/types/screens/Onboarding.d.ts +22 -3
  178. package/lib/types/screens/Onboarding.d.ts.map +1 -1
  179. package/lib/types/screens/Onboarding.js +606 -36
  180. package/lib/types/settings/definitions.js +2 -2
  181. package/lib/types/utils/paths.d.ts +15 -0
  182. package/lib/types/utils/paths.d.ts.map +1 -1
  183. package/lib/types/utils/paths.js +25 -0
  184. package/package.json +111 -108
  185. package/tui-profile/feed/README.md +1 -1
  186. package/tui-profile/feed/first-party.json +1 -1
@@ -0,0 +1,173 @@
1
+ /**
2
+ * `/restart` carry-over of the composer queue (#1651): the queued and held
3
+ * texts the old process still showed are written to a per-restart file whose
4
+ * path rides the replacement's env, and the replacement parks them as held
5
+ * dock rows. The backend copies die with the old process (the kernel records
6
+ * them as canceled), so nothing re-sends them until the user sends the dock.
7
+ * Text only: staged images live in the old process's memory.
8
+ */
9
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
10
+ import { randomBytes } from 'node:crypto';
11
+ import { basename, dirname, join, resolve } from 'node:path';
12
+ import { DATA_DIR } from './utils/paths.js';
13
+ /** env marker naming the file the replacement takes its held texts from. */
14
+ export const HELD_INPUTS_ENV = 'DSH_TUI_HELD_INPUTS';
15
+ const HELD_INPUTS_FILE = /^held-inputs-\d+-[0-9a-f]{12}\.json$/u;
16
+ /** A restart that stalled leaves its file for the printed resume command; one
17
+ * nobody resumed within this long is swept at a later launch. */
18
+ const HELD_INPUTS_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
19
+ /**
20
+ * Write the texts for a replacement process to take.
21
+ * @returns The env marker to hand the replacement, or undefined when there
22
+ * is nothing to carry or the write failed (best effort: a restart never
23
+ * waits on it).
24
+ */
25
+ export function writeHeldInputs(texts, dir = DATA_DIR, pid = process.pid) {
26
+ const kept = texts.filter(text => text.trim() !== '');
27
+ if (kept.length === 0)
28
+ return undefined;
29
+ // Unique per restart: a stalled restart's file stays for its printed
30
+ // resume command, and a later process reusing the pid must not replace it.
31
+ const file = join(dir, `held-inputs-${pid}-${randomBytes(6).toString('hex')}.json`);
32
+ try {
33
+ mkdirSync(dir, { recursive: true });
34
+ // The user's own prompt text: readable by them alone.
35
+ writeFileSync(file, JSON.stringify({ texts: kept }), { mode: 0o600, flag: 'wx' });
36
+ return { [HELD_INPUTS_ENV]: file };
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ /**
43
+ * The one handoff this process has not settled yet. The DSH launcher's boot
44
+ * recompose applies the entry a second time, after the first pass consumed
45
+ * the env marker; that pass must still find the texts.
46
+ */
47
+ let waiting;
48
+ /** Read the marker once per handoff; without a fresh one, hand back the
49
+ * pending handoff (the recompose asking again). */
50
+ function carriedInputs(env, dir) {
51
+ if (env[HELD_INPUTS_ENV] !== undefined)
52
+ waiting = readHeldInputs(env, dir);
53
+ return waiting ?? { texts: [] };
54
+ }
55
+ /** Best effort: a file another process still holds open must not decide
56
+ * whether this one starts. */
57
+ function removeHeldFile(file) {
58
+ try {
59
+ rmSync(file, { force: true });
60
+ }
61
+ catch {
62
+ }
63
+ }
64
+ /**
65
+ * The replacement's side: park the texts a `/restart` handed this process as
66
+ * held rows once the screen's channel is ready (never sent by themselves).
67
+ * A pass that cannot reach a ready channel leaves the handoff pending for the
68
+ * next `apply()` instead of dropping it.
69
+ * @returns What stops waiting for a channel that is not ready yet.
70
+ */
71
+ export function adoptHeldInputs(channel, env = process.env, dir = DATA_DIR) {
72
+ const inputs = carriedInputs(env, dir);
73
+ const { texts, file } = inputs;
74
+ // The file goes only once its texts are on screen: a replacement that
75
+ // dies before its channel is ready leaves it for the resume command its
76
+ // parent prints. Then files nobody resumed are swept.
77
+ const settle = () => {
78
+ if (file !== undefined)
79
+ removeHeldFile(file);
80
+ waiting = undefined;
81
+ sweepHeldInputs(dir);
82
+ };
83
+ if (texts.length === 0) {
84
+ settle();
85
+ return undefined;
86
+ }
87
+ if (channel.ready) {
88
+ channel.holdInputs(texts);
89
+ settle();
90
+ return undefined;
91
+ }
92
+ const unsubscribe = channel.subscribe(() => {
93
+ if (!channel.ready)
94
+ return;
95
+ unsubscribe();
96
+ // A later apply may have taken the handoff first (the recompose); the
97
+ // same texts must never be parked twice.
98
+ if (waiting !== inputs)
99
+ return;
100
+ channel.holdInputs(texts);
101
+ settle();
102
+ });
103
+ return unsubscribe;
104
+ }
105
+ /**
106
+ * The resume command after a restart that ended before any replacement took
107
+ * the held texts (a stall, a failed spawn): their file stays, and the command
108
+ * hands it to the next launch. Windows has no shared env-assignment syntax:
109
+ * PowerShell and cmd.exe each get their own copy-pasteable line.
110
+ */
111
+ export function heldInputsResumeCommand(command, env, platform = process.platform) {
112
+ const file = env?.[HELD_INPUTS_ENV];
113
+ if (file === undefined || !existsSync(file))
114
+ return command;
115
+ if (platform === 'win32') {
116
+ // This line is the only way a stalled restart gets its texts back, and the
117
+ // two Windows shells disagree on how to set a variable: print both.
118
+ return `$env:${HELD_INPUTS_ENV}='${file.replaceAll('\'', '\'\'')}'; ${command}\nset "${HELD_INPUTS_ENV}=${file}" && ${command}`;
119
+ }
120
+ return `${HELD_INPUTS_ENV}='${file.replaceAll('\'', '\'\\\'\'')}' ${command}`;
121
+ }
122
+ /**
123
+ * Take (read and delete) the texts a `/restart` handed this process. One
124
+ * shot: the env marker is consumed too, so no child inherits it.
125
+ */
126
+ export function takeHeldInputs(env = process.env, dir = DATA_DIR) {
127
+ const marked = env[HELD_INPUTS_ENV] !== undefined;
128
+ const { texts, file } = readHeldInputs(env, dir);
129
+ if (file !== undefined)
130
+ removeHeldFile(file);
131
+ if (marked)
132
+ waiting = undefined;
133
+ return texts;
134
+ }
135
+ /** Read the texts and consume the env marker; `file` is what the caller
136
+ * deletes once it is done with them. */
137
+ function readHeldInputs(env, dir) {
138
+ const file = env[HELD_INPUTS_ENV];
139
+ delete env[HELD_INPUTS_ENV];
140
+ // Only ever a file writeHeldInputs named, in the directory it writes to:
141
+ // the marker is env input, and the caller deletes what it names.
142
+ if (file === undefined || !HELD_INPUTS_FILE.test(basename(file)) || dirname(resolve(file)) !== resolve(dir))
143
+ return { texts: [] };
144
+ try {
145
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
146
+ const texts = parsed !== null && typeof parsed === 'object' ? parsed.texts : undefined;
147
+ return { texts: Array.isArray(texts) ? texts.filter((text) => typeof text === 'string' && text.trim() !== '') : [], file };
148
+ }
149
+ catch {
150
+ return { texts: [], file };
151
+ }
152
+ }
153
+ /** Remove held-input files older than the resume window (best effort). */
154
+ export function sweepHeldInputs(dir = DATA_DIR, now = Date.now()) {
155
+ let names;
156
+ try {
157
+ names = readdirSync(dir);
158
+ }
159
+ catch {
160
+ return;
161
+ }
162
+ for (const name of names) {
163
+ if (!HELD_INPUTS_FILE.test(name))
164
+ continue;
165
+ const file = join(dir, name);
166
+ try {
167
+ if (now - statSync(file).mtimeMs > HELD_INPUTS_MAX_AGE_MS)
168
+ rmSync(file, { force: true });
169
+ }
170
+ catch {
171
+ }
172
+ }
173
+ }