@agi-fans/dsh-tui 0.18.0 → 0.20.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 (227) hide show
  1. package/lib/CHANGELOG.md +115 -1
  2. package/lib/chrome/box.d.ts +2 -0
  3. package/lib/chrome/box.js +6 -12
  4. package/lib/chrome/box.js.map +1 -1
  5. package/lib/chrome/code-highlight.d.ts +26 -18
  6. package/lib/chrome/code-highlight.js +114 -39
  7. package/lib/chrome/code-highlight.js.map +1 -1
  8. package/lib/chrome/diff-render.d.ts +1 -2
  9. package/lib/chrome/diff-render.js +41 -90
  10. package/lib/chrome/diff-render.js.map +1 -1
  11. package/lib/chrome/main-screen-renderer.d.ts +52 -30
  12. package/lib/chrome/main-screen-renderer.js +1730 -79
  13. package/lib/chrome/main-screen-renderer.js.map +1 -1
  14. package/lib/chrome/markdown.js +144 -101
  15. package/lib/chrome/markdown.js.map +1 -1
  16. package/lib/chrome/math.d.ts +4 -0
  17. package/lib/chrome/math.js +340 -0
  18. package/lib/chrome/math.js.map +1 -0
  19. package/lib/chrome/md-style.d.ts +3 -0
  20. package/lib/chrome/md-style.js.map +1 -1
  21. package/lib/chrome/mermaid.d.ts +6 -0
  22. package/lib/chrome/mermaid.js +56 -0
  23. package/lib/chrome/mermaid.js.map +1 -0
  24. package/lib/chrome/renderer.d.ts +78 -0
  25. package/lib/chrome/renderer.js.map +1 -1
  26. package/lib/chrome/status-config.d.ts +5 -0
  27. package/lib/chrome/status-config.js +3 -0
  28. package/lib/chrome/status-config.js.map +1 -1
  29. package/lib/chrome/status-line.d.ts +0 -21
  30. package/lib/chrome/status-line.js +8 -65
  31. package/lib/chrome/status-line.js.map +1 -1
  32. package/lib/chrome/terminal-images.d.ts +31 -0
  33. package/lib/chrome/terminal-images.js +34 -0
  34. package/lib/chrome/terminal-images.js.map +1 -0
  35. package/lib/chrome/theme.d.ts +23 -6
  36. package/lib/chrome/theme.js +217 -109
  37. package/lib/chrome/theme.js.map +1 -1
  38. package/lib/chrome/tool-args.d.ts +24 -1
  39. package/lib/chrome/tool-args.js +40 -1
  40. package/lib/chrome/tool-args.js.map +1 -1
  41. package/lib/chrome/tool-renderers.d.ts +11 -0
  42. package/lib/chrome/tool-renderers.js +55 -5
  43. package/lib/chrome/tool-renderers.js.map +1 -1
  44. package/lib/chrome/welcome-tips.js +2 -2
  45. package/lib/chrome/welcome-tips.js.map +1 -1
  46. package/lib/chrome/width.d.ts +7 -3
  47. package/lib/chrome/width.js +78 -14
  48. package/lib/chrome/width.js.map +1 -1
  49. package/lib/commands/diff.js +49 -3
  50. package/lib/commands/diff.js.map +1 -1
  51. package/lib/commands/export.js +28 -5
  52. package/lib/commands/export.js.map +1 -1
  53. package/lib/commands/files.d.ts +8 -0
  54. package/lib/commands/files.js +137 -0
  55. package/lib/commands/files.js.map +1 -0
  56. package/lib/commands/plugins.d.ts +8 -0
  57. package/lib/commands/plugins.js +158 -0
  58. package/lib/commands/plugins.js.map +1 -0
  59. package/lib/commands/session-configuration.d.ts +4 -0
  60. package/lib/commands/session-configuration.js +39 -8
  61. package/lib/commands/session-configuration.js.map +1 -1
  62. package/lib/commands/session.js +47 -15
  63. package/lib/commands/session.js.map +1 -1
  64. package/lib/commands/steer.js +2 -2
  65. package/lib/commands/steer.js.map +1 -1
  66. package/lib/commands/terminal.d.ts +7 -0
  67. package/lib/commands/terminal.js +99 -0
  68. package/lib/commands/terminal.js.map +1 -0
  69. package/lib/definition.d.ts +180 -14
  70. package/lib/definition.js.map +1 -1
  71. package/lib/input/clipboard.d.ts +12 -7
  72. package/lib/input/clipboard.js +79 -20
  73. package/lib/input/clipboard.js.map +1 -1
  74. package/lib/input/composer-files.d.ts +26 -0
  75. package/lib/input/composer-files.js +50 -0
  76. package/lib/input/composer-files.js.map +1 -0
  77. package/lib/input/editor-discovery.d.ts +21 -0
  78. package/lib/input/editor-discovery.js +99 -0
  79. package/lib/input/editor-discovery.js.map +1 -0
  80. package/lib/input/editor.d.ts +26 -1
  81. package/lib/input/editor.js +126 -12
  82. package/lib/input/editor.js.map +1 -1
  83. package/lib/input/external-editor.d.ts +5 -2
  84. package/lib/input/external-editor.js +14 -12
  85. package/lib/input/external-editor.js.map +1 -1
  86. package/lib/input/fuzzy-search.d.ts +9 -0
  87. package/lib/input/fuzzy-search.js +113 -0
  88. package/lib/input/fuzzy-search.js.map +1 -0
  89. package/lib/input/keybindings-config.d.ts +1 -1
  90. package/lib/input/keybindings-config.js +7 -1
  91. package/lib/input/keybindings-config.js.map +1 -1
  92. package/lib/input/keys.d.ts +17 -0
  93. package/lib/input/keys.js +21 -5
  94. package/lib/input/keys.js.map +1 -1
  95. package/lib/input/mouse-policy.d.ts +3 -0
  96. package/lib/input/mouse-policy.js +14 -0
  97. package/lib/input/mouse-policy.js.map +1 -0
  98. package/lib/input/paste-burst.d.ts +16 -0
  99. package/lib/input/paste-burst.js +61 -0
  100. package/lib/input/paste-burst.js.map +1 -0
  101. package/lib/input/text-selection.d.ts +20 -0
  102. package/lib/input/text-selection.js +195 -0
  103. package/lib/input/text-selection.js.map +1 -0
  104. package/lib/runtime/composer-images.d.ts +1 -0
  105. package/lib/runtime/composer-images.js +11 -3
  106. package/lib/runtime/composer-images.js.map +1 -1
  107. package/lib/runtime/file-open.d.ts +2 -0
  108. package/lib/runtime/file-open.js +12 -0
  109. package/lib/runtime/file-open.js.map +1 -0
  110. package/lib/runtime/file-review.d.ts +24 -0
  111. package/lib/runtime/file-review.js +188 -0
  112. package/lib/runtime/file-review.js.map +1 -0
  113. package/lib/runtime/herdr-agent.d.ts +7 -15
  114. package/lib/runtime/herdr-agent.js +151 -79
  115. package/lib/runtime/herdr-agent.js.map +1 -1
  116. package/lib/runtime/hook-settings.d.ts +17 -0
  117. package/lib/runtime/hook-settings.js +57 -0
  118. package/lib/runtime/hook-settings.js.map +1 -0
  119. package/lib/runtime/human-interaction.js +1 -1
  120. package/lib/runtime/human-interaction.js.map +1 -1
  121. package/lib/runtime/image-preview.d.ts +8 -0
  122. package/lib/runtime/image-preview.js +119 -0
  123. package/lib/runtime/image-preview.js.map +1 -0
  124. package/lib/runtime/plain-tui.d.ts +2 -0
  125. package/lib/runtime/plain-tui.js +2 -2
  126. package/lib/runtime/plain-tui.js.map +1 -1
  127. package/lib/runtime/plugin-settings.d.ts +17 -0
  128. package/lib/runtime/plugin-settings.js +154 -0
  129. package/lib/runtime/plugin-settings.js.map +1 -0
  130. package/lib/runtime/provider-local.d.ts +58 -7
  131. package/lib/runtime/provider-local.js +1394 -137
  132. package/lib/runtime/provider-local.js.map +1 -1
  133. package/lib/runtime/runner.js +3 -3
  134. package/lib/runtime/runner.js.map +1 -1
  135. package/lib/runtime/session-archive.d.ts +5 -0
  136. package/lib/runtime/session-archive.js +114 -0
  137. package/lib/runtime/session-archive.js.map +1 -0
  138. package/lib/runtime/subagent-model-selection.d.ts +5 -0
  139. package/lib/runtime/subagent-model-selection.js +15 -0
  140. package/lib/runtime/subagent-model-selection.js.map +1 -0
  141. package/lib/runtime/terminal-notifications.d.ts +8 -0
  142. package/lib/runtime/terminal-notifications.js +16 -0
  143. package/lib/runtime/terminal-notifications.js.map +1 -1
  144. package/lib/runtime/terminal-reader.d.ts +11 -0
  145. package/lib/runtime/terminal-reader.js +87 -0
  146. package/lib/runtime/terminal-reader.js.map +1 -0
  147. package/lib/runtime/tool-presentation.js +43 -30
  148. package/lib/runtime/tool-presentation.js.map +1 -1
  149. package/lib/session/composer-drafts.d.ts +20 -0
  150. package/lib/session/composer-drafts.js +103 -0
  151. package/lib/session/composer-drafts.js.map +1 -0
  152. package/lib/session/conversation-turns.d.ts +16 -0
  153. package/lib/session/conversation-turns.js +33 -0
  154. package/lib/session/conversation-turns.js.map +1 -0
  155. package/lib/session/feature-toggles.d.ts +79 -0
  156. package/lib/session/feature-toggles.js +139 -0
  157. package/lib/session/feature-toggles.js.map +1 -0
  158. package/lib/session/fold-policy.d.ts +4 -0
  159. package/lib/session/fold-policy.js +4 -0
  160. package/lib/session/fold-policy.js.map +1 -0
  161. package/lib/session/interaction-adapter.d.ts +2 -2
  162. package/lib/session/interaction-adapter.js +156 -25
  163. package/lib/session/interaction-adapter.js.map +1 -1
  164. package/lib/session/job-notice.d.ts +4 -0
  165. package/lib/session/job-notice.js +44 -3
  166. package/lib/session/job-notice.js.map +1 -1
  167. package/lib/session/message-queue.d.ts +22 -0
  168. package/lib/session/message-queue.js +157 -0
  169. package/lib/session/message-queue.js.map +1 -0
  170. package/lib/session/project-file-search.js +3 -21
  171. package/lib/session/project-file-search.js.map +1 -1
  172. package/lib/session/session-controller.d.ts +11 -18
  173. package/lib/session/session-controller.js +246 -100
  174. package/lib/session/session-controller.js.map +1 -1
  175. package/lib/session/session-library.d.ts +11 -3
  176. package/lib/session/session-library.js +48 -8
  177. package/lib/session/session-library.js.map +1 -1
  178. package/lib/session/session-tree.d.ts +26 -0
  179. package/lib/session/session-tree.js +112 -0
  180. package/lib/session/session-tree.js.map +1 -0
  181. package/lib/session/steering.d.ts +3 -0
  182. package/lib/session/steering.js +9 -0
  183. package/lib/session/steering.js.map +1 -0
  184. package/lib/session/tui-settings.d.ts +23 -1
  185. package/lib/session/tui-settings.js +15 -2
  186. package/lib/session/tui-settings.js.map +1 -1
  187. package/lib/session/workflow-projection.d.ts +9 -0
  188. package/lib/session/workflow-projection.js +44 -0
  189. package/lib/session/workflow-projection.js.map +1 -0
  190. package/lib/views/agent-hub.js +9 -4
  191. package/lib/views/agent-hub.js.map +1 -1
  192. package/lib/views/autocomplete.js +5 -25
  193. package/lib/views/autocomplete.js.map +1 -1
  194. package/lib/views/document-reader.d.ts +34 -0
  195. package/lib/views/document-reader.js +145 -0
  196. package/lib/views/document-reader.js.map +1 -0
  197. package/lib/views/event-views.d.ts +26 -2
  198. package/lib/views/event-views.js +196 -42
  199. package/lib/views/event-views.js.map +1 -1
  200. package/lib/views/hotkeys.d.ts +2 -0
  201. package/lib/views/hotkeys.js +20 -8
  202. package/lib/views/hotkeys.js.map +1 -1
  203. package/lib/views/prompt-selector.d.ts +33 -3
  204. package/lib/views/prompt-selector.js +287 -43
  205. package/lib/views/prompt-selector.js.map +1 -1
  206. package/lib/views/prompt-tree.d.ts +11 -0
  207. package/lib/views/prompt-tree.js +74 -0
  208. package/lib/views/prompt-tree.js.map +1 -0
  209. package/lib/views/session-files.d.ts +7 -0
  210. package/lib/views/session-files.js +62 -0
  211. package/lib/views/session-files.js.map +1 -0
  212. package/lib/views/settings-list.d.ts +32 -4
  213. package/lib/views/settings-list.js +148 -37
  214. package/lib/views/settings-list.js.map +1 -1
  215. package/lib/views/transcript-render.d.ts +117 -18
  216. package/lib/views/transcript-render.js +1084 -126
  217. package/lib/views/transcript-render.js.map +1 -1
  218. package/lib/views/transcript-types.d.ts +80 -2
  219. package/lib/views/transcript-types.js +11 -0
  220. package/lib/views/transcript-types.js.map +1 -1
  221. package/lib/views/workspace-changes.d.ts +27 -0
  222. package/lib/views/workspace-changes.js +128 -0
  223. package/lib/views/workspace-changes.js.map +1 -0
  224. package/package.json +77 -41
  225. package/lib/chrome/style.d.ts +0 -22
  226. package/lib/chrome/style.js +0 -23
  227. package/lib/chrome/style.js.map +0 -1
@@ -0,0 +1,103 @@
1
+ /** Private composer recovery files, separate from Harness logs and attachment storage. */
2
+ import { createHash } from 'node:crypto';
3
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { fileMarker } from "../input/composer-files.js";
6
+ import { imageMarker } from "../input/image-paste.js";
7
+ import { readJsonFile, writeJsonAtomic } from "./json-file.js";
8
+ const imageTypes = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif']);
9
+ const digest = (value) => createHash('sha256').update(value).digest('hex');
10
+ const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
11
+ const integer = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
12
+ function editorSnapshot(value) {
13
+ if (!object(value) || typeof value.text !== 'string' || !integer(value.cursor) || value.cursor > value.text.length || !Array.isArray(value.pastes))
14
+ return undefined;
15
+ const pastes = [];
16
+ let end = 0;
17
+ for (const atom of value.pastes) {
18
+ if (!object(atom) || !integer(atom.start) || !integer(atom.end) || atom.start < end || atom.end <= atom.start || atom.end > value.text.length
19
+ || typeof atom.content !== 'string' || !/^\[Pasted #\d+: \d+ (?:lines|chars)\]$/u.test(value.text.slice(atom.start, atom.end)))
20
+ return undefined;
21
+ pastes.push({ start: atom.start, end: atom.end, content: atom.content });
22
+ end = atom.end;
23
+ }
24
+ return { text: value.text, cursor: value.cursor, pastes };
25
+ }
26
+ function fileSnapshot(value, text) {
27
+ if (!object(value) || !integer(value.next) || !Array.isArray(value.entries))
28
+ return undefined;
29
+ const entries = [];
30
+ for (const item of value.entries) {
31
+ if (!object(item) || typeof item.marker !== 'string' || !object(item.file) || typeof item.file.attachmentId !== 'string'
32
+ || typeof item.file.name !== 'string' || !integer(item.file.bytes) || !text.includes(item.marker))
33
+ return undefined;
34
+ const file = { attachmentId: item.file.attachmentId, name: item.file.name, bytes: item.file.bytes };
35
+ const ordinal = Number(/^\[File:(\d+) /u.exec(item.marker)?.[1]);
36
+ if (!integer(ordinal) || ordinal === 0 || ordinal > value.next || item.marker !== fileMarker(file, ordinal))
37
+ return undefined;
38
+ entries.push({ marker: item.marker, file });
39
+ }
40
+ return { next: value.next, entries };
41
+ }
42
+ export class ComposerDraftStore {
43
+ root;
44
+ #imageHashes = new WeakMap();
45
+ constructor(root) {
46
+ this.root = root;
47
+ }
48
+ /** Hash opaque session identifiers so they cannot select arbitrary filesystem paths. */
49
+ path(id) { return join(this.root, digest(id), 'draft.json'); }
50
+ #directory(id) { return join(this.root, digest(id)); }
51
+ load(id) {
52
+ const path = this.path(id);
53
+ if (!existsSync(path))
54
+ return undefined;
55
+ const raw = readJsonFile(path);
56
+ if (!object(raw) || raw.version !== 1 || raw.session !== id || typeof raw.literal !== 'boolean' || !Array.isArray(raw.images))
57
+ throw new Error('Saved composer draft is invalid.');
58
+ const editor = editorSnapshot(raw.editor);
59
+ const files = editor === undefined ? undefined : fileSnapshot(raw.files, editor.text);
60
+ if (editor === undefined || files === undefined)
61
+ throw new Error('Saved composer draft is invalid.');
62
+ const images = [];
63
+ for (const record of raw.images) {
64
+ if (!object(record) || typeof record.blob !== 'string' || !/^[a-f0-9]{64}$/u.test(record.blob) || typeof record.mediaType !== 'string' || !imageTypes.has(record.mediaType)
65
+ || record.name !== undefined && typeof record.name !== 'string' || record.width !== undefined && (!integer(record.width) || record.width === 0)
66
+ || record.height !== undefined && (!integer(record.height) || record.height === 0))
67
+ throw new Error('Saved composer image is invalid.');
68
+ const data = new Uint8Array(readFileSync(join(this.#directory(id), record.blob + '.image')));
69
+ if (digest(data) !== record.blob)
70
+ throw new Error('Saved composer image is incomplete.');
71
+ this.#imageHashes.set(data, record.blob);
72
+ images.push({ data, mediaType: record.mediaType,
73
+ ...(record.name === undefined ? {} : { name: record.name }),
74
+ ...(record.width === undefined ? {} : { width: record.width }), ...(record.height === undefined ? {} : { height: record.height }) });
75
+ }
76
+ if (images.some((image, at) => !editor.text.includes(imageMarker(at, image))))
77
+ throw new Error('Saved composer image marker is missing.');
78
+ return { editor, files, images, literal: raw.literal };
79
+ }
80
+ save(id, draft) {
81
+ if (draft.editor.text === '' && draft.images.length === 0 && draft.files.entries.length === 0) {
82
+ this.clear(id);
83
+ return;
84
+ }
85
+ const directory = this.#directory(id);
86
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
87
+ const images = draft.images.map(({ data, ...metadata }) => {
88
+ const blob = this.#imageHashes.get(data) ?? digest(data);
89
+ this.#imageHashes.set(data, blob);
90
+ const path = join(directory, blob + '.image');
91
+ if (!existsSync(path)) {
92
+ const temp = `${path}.${process.pid}.${Date.now()}.tmp`;
93
+ writeFileSync(temp, data, { mode: 0o600 });
94
+ chmodSync(temp, 0o600);
95
+ renameSync(temp, path);
96
+ }
97
+ return { ...metadata, blob };
98
+ });
99
+ writeJsonAtomic(this.path(id), { version: 1, session: id, editor: draft.editor, images, files: draft.files, literal: draft.literal });
100
+ }
101
+ clear(id) { rmSync(this.#directory(id), { recursive: true, force: true }); }
102
+ }
103
+ //# sourceMappingURL=composer-drafts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composer-drafts.js","sourceRoot":"","sources":["../../src/session/composer-drafts.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC3G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,UAAU,EAAsB,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAErD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAS9D,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAA;AAClF,MAAM,MAAM,GAAG,CAAC,KAA0B,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACvG,MAAM,MAAM,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACzI,MAAM,OAAO,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;AAE3H,SAAS,cAAc,CAAC,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AAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA,CAAC,CAAC;CAC1F"}
@@ -0,0 +1,16 @@
1
+ import type { SessionEvent } from '@deepseek-ai/dsh-session';
2
+ /** One direct human turn that can become a safe fork boundary. */
3
+ export interface ConversationTurn {
4
+ /** Harness turn number shown to the user. */
5
+ turn: number;
6
+ /** Index of the direct user/message event in the immutable log. */
7
+ messageIndex: number;
8
+ /** Balanced seed boundary immediately before this turn starts. */
9
+ branchIndex: number;
10
+ /** Single-line selector preview. */
11
+ preview: string;
12
+ /** Number of image blocks in the selected message. */
13
+ imageCount: number;
14
+ }
15
+ /** Find direct human messages whose preceding log prefix is safe to seed into a fork. */
16
+ export declare function conversationTurns(events: readonly SessionEvent[]): ConversationTurn[];
@@ -0,0 +1,33 @@
1
+ import { blocksText } from "./content-text.js";
2
+ /** Find direct human messages whose preceding log prefix is safe to seed into a fork. */
3
+ export function conversationTurns(events) {
4
+ const turns = [];
5
+ let open;
6
+ for (let index = 0; index < events.length; index += 1) {
7
+ const event = events[index];
8
+ if (event.type === 'turn/start') {
9
+ open = { turn: event.data.turn, branchIndex: index };
10
+ continue;
11
+ }
12
+ if (event.type === 'turn/end') {
13
+ if (open?.turn === event.data.turn)
14
+ open = undefined;
15
+ continue;
16
+ }
17
+ if (open === undefined || event.type !== 'user/message' || event.data.source.kind !== 'user')
18
+ continue;
19
+ const text = blocksText(event.data.content, { collapse: true });
20
+ const imageCount = event.data.content.filter(block => block.type === 'image').length;
21
+ if (text === '' && imageCount === 0)
22
+ continue;
23
+ turns.push({
24
+ turn: open.turn,
25
+ messageIndex: index,
26
+ branchIndex: open.branchIndex,
27
+ preview: text === '' ? (imageCount === 1 ? 'Image' : `${imageCount} images`) : text,
28
+ imageCount,
29
+ });
30
+ }
31
+ return turns;
32
+ }
33
+ //# sourceMappingURL=conversation-turns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-turns.js","sourceRoot":"","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C;YACT,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;YACnF,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Optional product features and their managed Profile-patch overrides.
3
+ *
4
+ * A feature is a composition row a deployment may not want: it costs context,
5
+ * runtime, or transcript noise. The row's `disabled` field is a Loader option
6
+ * rather than plugin config, so the settings service cannot write it — the
7
+ * Loader does read a Profile patch's `disabled`, and that patch is the
8
+ * documented, user-authored surface for exactly this.
9
+ *
10
+ * The writes therefore maintain one clearly delimited block in the Profile
11
+ * patch and touch nothing else in the file, so hand-written rows, `!!js`
12
+ * expressions, and comments all survive a toggle. Toggling takes effect on the
13
+ * next launch, or after the host's configuration watcher recomposes the tree.
14
+ * @module @agi-fans/dsh-tui
15
+ */
16
+ /** One optional product feature, addressed by its composition row id. */
17
+ export interface FeatureToggle {
18
+ /** Composition row id; the key a Profile patch keys its override by. */
19
+ id: string;
20
+ /** Short row label for the settings overlay. */
21
+ label: string;
22
+ /** What the feature does, and what turning it off costs. */
23
+ description: string;
24
+ /** Whether the shipped composition mounts it. */
25
+ enabledByDefault: boolean;
26
+ }
27
+ /**
28
+ * Features this build can enable or disable.
29
+ *
30
+ * Rows that make the agent non-functional (`tool-fs`, `tool-bash`, `todo`), rows
31
+ * that back a command (`session-query` backs `/sessions`, `workspace` backs
32
+ * `@` mentions), and rows that are already conditional at no cost
33
+ * (`mcp-resources` appears only with a connected MCP server) are deliberately
34
+ * absent. `tool-web` is absent for a different reason: `web_search` and
35
+ * `web_fetch` share one row, so no row-level toggle can express "search off,
36
+ * fetch on".
37
+ */
38
+ export declare const FEATURE_TOGGLES: readonly FeatureToggle[];
39
+ /** Opening delimiter of the block this module owns. */
40
+ export declare const FEATURE_BLOCK_BEGIN = "# >>> omdsh feature toggles >>>";
41
+ /** Closing delimiter of the block this module owns. */
42
+ export declare const FEATURE_BLOCK_END = "# <<< omdsh feature toggles <<<";
43
+ /** Current on/off state of every feature, keyed by row id. */
44
+ export type FeatureStates = Readonly<Record<string, boolean>>;
45
+ /** The shipped composition's state, before any Profile patch override. */
46
+ export declare function defaultFeatureStates(features?: readonly FeatureToggle[]): Record<string, boolean>;
47
+ /**
48
+ * Render only states that differ from the shipped defaults. Returning a
49
+ * feature to its default removes its override, including shipped-off features.
50
+ *
51
+ * @param states - desired feature state.
52
+ * @returns the block text, including a trailing newline.
53
+ */
54
+ export declare function renderFeatureBlock(states: FeatureStates): string;
55
+ /**
56
+ * Replace the managed block, leaving every other byte of the patch untouched.
57
+ *
58
+ * A patch that carries no block is simply appended to, so a file the user has
59
+ * been editing by hand keeps its formatting, comments, and `!!js` expressions.
60
+ *
61
+ * @param text - current patch file contents.
62
+ * @param block - the block to install.
63
+ * @returns the new patch file contents.
64
+ */
65
+ export declare function replaceFeatureBlock(text: string, block: string): string;
66
+ /**
67
+ * Read the feature state a patch file currently declares.
68
+ *
69
+ * Only the managed block is parsed, by row id, so a hand-written
70
+ * overrides elsewhere in the file are left for the composition to honour
71
+ * and is not double-counted as a feature toggle.
72
+ *
73
+ * @param text - patch file contents.
74
+ * @param features - known features; defaults to the shipped registry.
75
+ * @returns the state the block declares over the shipped defaults.
76
+ */
77
+ export declare function featureStatesFromPatch(text: string, features?: readonly FeatureToggle[]): Record<string, boolean>;
78
+ /** Absolute path of the Profile patch this build edits. */
79
+ export declare function featurePatchPath(dshHome: string): string;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Optional product features and their managed Profile-patch overrides.
3
+ *
4
+ * A feature is a composition row a deployment may not want: it costs context,
5
+ * runtime, or transcript noise. The row's `disabled` field is a Loader option
6
+ * rather than plugin config, so the settings service cannot write it — the
7
+ * Loader does read a Profile patch's `disabled`, and that patch is the
8
+ * documented, user-authored surface for exactly this.
9
+ *
10
+ * The writes therefore maintain one clearly delimited block in the Profile
11
+ * patch and touch nothing else in the file, so hand-written rows, `!!js`
12
+ * expressions, and comments all survive a toggle. Toggling takes effect on the
13
+ * next launch, or after the host's configuration watcher recomposes the tree.
14
+ * @module @agi-fans/dsh-tui
15
+ */
16
+ import { join } from 'node:path';
17
+ /**
18
+ * Features this build can enable or disable.
19
+ *
20
+ * Rows that make the agent non-functional (`tool-fs`, `tool-bash`, `todo`), rows
21
+ * that back a command (`session-query` backs `/sessions`, `workspace` backs
22
+ * `@` mentions), and rows that are already conditional at no cost
23
+ * (`mcp-resources` appears only with a connected MCP server) are deliberately
24
+ * absent. `tool-web` is absent for a different reason: `web_search` and
25
+ * `web_fetch` share one row, so no row-level toggle can express "search off,
26
+ * fetch on".
27
+ */
28
+ export const FEATURE_TOGGLES = [
29
+ {
30
+ id: 'workspace-changes',
31
+ label: 'Changed-file summary',
32
+ description: 'End every turn with the files it changed and their line counts. Off skips two Git snapshots per turn and the transcript row.',
33
+ enabledByDefault: true,
34
+ },
35
+ {
36
+ id: 'tool-session-query',
37
+ label: 'Session history tools',
38
+ description: 'Five tools that let the model search, trace and read its own earlier sessions. Off removes five tool schemas from every request.',
39
+ enabledByDefault: true,
40
+ },
41
+ {
42
+ id: 'tool-ralph',
43
+ label: 'Ralph loop',
44
+ description: 'Let the model re-run a task until it reports completion. Off by default because the tool is a self-report, not an evaluation.',
45
+ enabledByDefault: false,
46
+ },
47
+ {
48
+ id: 'repeat-tool-reminder',
49
+ label: 'Repeat-tool reminder',
50
+ description: 'Nudge the model out of identical tool-call loops. Off removes the advisory text those nudges add to the context.',
51
+ enabledByDefault: true,
52
+ },
53
+ ];
54
+ /** Opening delimiter of the block this module owns. */
55
+ export const FEATURE_BLOCK_BEGIN = '# >>> omdsh feature toggles >>>';
56
+ /** Closing delimiter of the block this module owns. */
57
+ export const FEATURE_BLOCK_END = '# <<< omdsh feature toggles <<<';
58
+ /** The shipped composition's state, before any Profile patch override. */
59
+ export function defaultFeatureStates(features = FEATURE_TOGGLES) {
60
+ return Object.fromEntries(features.map(feature => [feature.id, feature.enabledByDefault]));
61
+ }
62
+ /**
63
+ * Render only states that differ from the shipped defaults. Returning a
64
+ * feature to its default removes its override, including shipped-off features.
65
+ *
66
+ * @param states - desired feature state.
67
+ * @returns the block text, including a trailing newline.
68
+ */
69
+ export function renderFeatureBlock(states) {
70
+ const lines = [FEATURE_BLOCK_BEGIN];
71
+ for (const feature of FEATURE_TOGGLES) {
72
+ const enabled = states[feature.id] ?? feature.enabledByDefault;
73
+ if (enabled !== feature.enabledByDefault)
74
+ lines.push(`- id: ${feature.id}`, ` disabled: ${!enabled}`);
75
+ }
76
+ lines.push(FEATURE_BLOCK_END, '');
77
+ return lines.join('\n');
78
+ }
79
+ /**
80
+ * Replace the managed block, leaving every other byte of the patch untouched.
81
+ *
82
+ * A patch that carries no block is simply appended to, so a file the user has
83
+ * been editing by hand keeps its formatting, comments, and `!!js` expressions.
84
+ *
85
+ * @param text - current patch file contents.
86
+ * @param block - the block to install.
87
+ * @returns the new patch file contents.
88
+ */
89
+ export function replaceFeatureBlock(text, block) {
90
+ const begin = text.indexOf(FEATURE_BLOCK_BEGIN);
91
+ const end = text.indexOf(FEATURE_BLOCK_END);
92
+ if (begin < 0 || end < 0 || end < begin) {
93
+ const head = text.trimEnd();
94
+ return head === '' ? block : `${head}\n\n${block}`;
95
+ }
96
+ const before = text.slice(0, begin).trimEnd();
97
+ const after = text.slice(end + FEATURE_BLOCK_END.length).replace(/^\n+/, '');
98
+ const head = before === '' ? '' : `${before}\n\n`;
99
+ const tail = after.trim() === '' ? '' : `\n${after}`;
100
+ return `${head}${block.trimEnd()}${tail}\n`;
101
+ }
102
+ /**
103
+ * Read the feature state a patch file currently declares.
104
+ *
105
+ * Only the managed block is parsed, by row id, so a hand-written
106
+ * overrides elsewhere in the file are left for the composition to honour
107
+ * and is not double-counted as a feature toggle.
108
+ *
109
+ * @param text - patch file contents.
110
+ * @param features - known features; defaults to the shipped registry.
111
+ * @returns the state the block declares over the shipped defaults.
112
+ */
113
+ export function featureStatesFromPatch(text, features = FEATURE_TOGGLES) {
114
+ const begin = text.indexOf(FEATURE_BLOCK_BEGIN);
115
+ const end = text.indexOf(FEATURE_BLOCK_END);
116
+ const states = Object.fromEntries(features.map(f => [f.id, f.enabledByDefault]));
117
+ if (begin < 0 || end < 0 || end < begin)
118
+ return states;
119
+ let current;
120
+ for (const raw of text.slice(begin, end).split('\n')) {
121
+ const id = raw.match(/^\s*-\s*id:\s*(\S+)\s*$/u);
122
+ if (id !== null) {
123
+ current = id[1];
124
+ continue;
125
+ }
126
+ const disabled = raw.match(/^\s*disabled:\s*(true|false)\s*$/u);
127
+ if (disabled !== null && current !== undefined) {
128
+ if (Object.hasOwn(states, current))
129
+ states[current] = disabled[1] === 'false';
130
+ current = undefined;
131
+ }
132
+ }
133
+ return states;
134
+ }
135
+ /** Absolute path of the Profile patch this build edits. */
136
+ export function featurePatchPath(dshHome) {
137
+ return join(dshHome, 'profiles', 'omdsh', 'cordis.patch.yml');
138
+ }
139
+ //# sourceMappingURL=feature-toggles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-toggles.js","sourceRoot":"","sources":["../../src/session/feature-toggles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAchC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD;QACE,EAAE,EAAE,mBAAmB;QACvB,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,8HAA8H;QAC3I,gBAAgB,EAAE,IAAI;KACvB;IACD;QACE,EAAE,EAAE,oBAAoB;QACxB,KAAK,EAAE,uBAAuB;QAC9B,W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,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAChF,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,KAAK;QAAE,OAAO,MAAM,CAAA;IACtD,IAAI,OAA2B,CAAA;IAC/B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAChD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YAAC,SAAQ;QAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;QAC/D,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/C,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAAE,MAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;YAC7E,OAAO,GAAG,SAAS,CAAA;QACrB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAA;AAC/D,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Compatibility for stored transcript preferences from earlier versions. */
2
+ export declare const FOLD_DENSITIES: readonly ["compact", "standard", "detailed", "verbose"];
3
+ export type FoldDensity = typeof FOLD_DENSITIES[number];
4
+ export declare const DEFAULT_FOLD_DENSITY: FoldDensity;
@@ -0,0 +1,4 @@
1
+ /** Compatibility for stored transcript preferences from earlier versions. */
2
+ export const FOLD_DENSITIES = ['compact', 'standard', 'detailed', 'verbose'];
3
+ export const DEFAULT_FOLD_DENSITY = 'standard';
4
+ //# sourceMappingURL=fold-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fold-policy.js","sourceRoot":"","sources":["../../src/session/fold-policy.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,CAAU,CAAA;AAGrF,MAAM,CAAC,MAAM,oBAAoB,GAAgB,UAAU,CAAA"}
@@ -8,7 +8,7 @@
8
8
  import type { Context } from '@deepseek-ai/cordis';
9
9
  import type { Agent } from '@deepseek-ai/dsh-agent';
10
10
  import type { ApprovalRequest } from '@deepseek-ai/dsh-user-approval';
11
- import type { AskUserQuestionItem } from '@deepseek-ai/dsh-user-questions';
11
+ import { type AskUserQuestionItem } from '@deepseek-ai/dsh-user-questions';
12
12
  import type { TuiService } from '../definition.ts';
13
13
  /** Resolve a label/number list while preserving unmatched input as custom text. */
14
14
  export declare function parsePromptAnswer(input: string, question: Pick<AskUserQuestionItem, 'options' | 'multiSelect'>): {
@@ -25,4 +25,4 @@ export declare function approvalDetail(tui: TuiService, request: ApprovalRequest
25
25
  detail?: string;
26
26
  };
27
27
  /** Bind the global question provider and route approvals to the active root agent only. */
28
- export declare function bindHumanInteraction(ctx: Context, tui: TuiService, activeAgent: () => Agent | undefined): () => void;
28
+ export declare function bindHumanInteraction(ctx: Context, tui: TuiService, activeAgent: () => Agent | undefined): () => Promise<void>;