@antst/dashi 0.1.0-alpha.17 → 0.1.0-alpha.19

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 (55) hide show
  1. package/README.md +6 -6
  2. package/package.json +38 -39
  3. package/lib/application.d.ts +0 -45
  4. package/lib/application.js +0 -273
  5. package/lib/at-trigger.d.ts +0 -8
  6. package/lib/at-trigger.js +0 -13
  7. package/lib/catalogs.d.ts +0 -28
  8. package/lib/catalogs.js +0 -308
  9. package/lib/clipboard-image.d.ts +0 -3
  10. package/lib/clipboard-image.js +0 -74
  11. package/lib/completion-trigger.d.ts +0 -6
  12. package/lib/completion-trigger.js +0 -19
  13. package/lib/diff-view.d.ts +0 -5
  14. package/lib/diff-view.js +0 -24
  15. package/lib/external-editor.d.ts +0 -3
  16. package/lib/external-editor.js +0 -39
  17. package/lib/help.d.ts +0 -2
  18. package/lib/help.js +0 -6
  19. package/lib/history-records.d.ts +0 -4
  20. package/lib/history-records.js +0 -14
  21. package/lib/image-input.d.ts +0 -8
  22. package/lib/image-input.js +0 -37
  23. package/lib/index.d.ts +0 -4
  24. package/lib/index.js +0 -329
  25. package/lib/input.d.ts +0 -17
  26. package/lib/input.js +0 -267
  27. package/lib/memory.d.ts +0 -3
  28. package/lib/memory.js +0 -27
  29. package/lib/mouse-input.d.ts +0 -1
  30. package/lib/mouse-input.js +0 -6
  31. package/lib/presentation.d.ts +0 -9
  32. package/lib/presentation.js +0 -54
  33. package/lib/renderer.d.ts +0 -21
  34. package/lib/renderer.js +0 -491
  35. package/lib/rewind.d.ts +0 -26
  36. package/lib/rewind.js +0 -107
  37. package/lib/session-export.d.ts +0 -3
  38. package/lib/session-export.js +0 -27
  39. package/lib/session-list.d.ts +0 -15
  40. package/lib/session-list.js +0 -65
  41. package/lib/session-runtime.d.ts +0 -49
  42. package/lib/session-runtime.js +0 -1455
  43. package/lib/shell-command.d.ts +0 -10
  44. package/lib/shell-command.js +0 -66
  45. package/lib/state.d.ts +0 -517
  46. package/lib/state.js +0 -678
  47. package/lib/terminal-guard.d.ts +0 -14
  48. package/lib/terminal-guard.js +0 -76
  49. package/lib/tool-presentation.d.ts +0 -14
  50. package/lib/tool-presentation.js +0 -156
  51. package/lib/transcript.d.ts +0 -12
  52. package/lib/transcript.js +0 -323
  53. package/lib/tui-root.d.ts +0 -20
  54. package/lib/tui-root.js +0 -25
  55. package/validated-dsh-versions.json +0 -3
@@ -1,10 +0,0 @@
1
- import type { Context } from '@deepseek-ai/cordis';
2
- import type { Agent } from '@deepseek-ai/dsh-agent';
3
- import { type UserMessage } from '@deepseek-ai/dsh-llm';
4
- import type { ShellRunResult } from '@deepseek-ai/dsh-shell';
5
- export declare const HUMAN_SHELL_TIMEOUT_MS = 30000;
6
- export declare const HUMAN_SHELL_STREAM_BYTES: number;
7
- export declare function shellResultText(command: string, result: ShellRunResult): string;
8
- export declare function quoteShellWord(value: string): string;
9
- /** Run an explicit human command through DSH and identify its next-step context. */
10
- export declare function runHumanShell(ctx: Context, agent: Agent, command: string, signal: AbortSignal, success?: string, useSessionSandbox?: boolean): Promise<readonly [UserMessage, ShellRunResult]>;
@@ -1,66 +0,0 @@
1
- import { boundContextSummary, createUserMessage } from '@deepseek-ai/dsh-llm';
2
- import { resolveDshHome } from '@deepseek-ai/dsh-home-paths';
3
- export const HUMAN_SHELL_TIMEOUT_MS = 30_000;
4
- export const HUMAN_SHELL_STREAM_BYTES = 32 * 1024;
5
- function tail(output) {
6
- const bytes = Buffer.from(output.text);
7
- if (bytes.length <= HUMAN_SHELL_STREAM_BYTES)
8
- return output;
9
- let start = bytes.length - HUMAN_SHELL_STREAM_BYTES;
10
- while (start < bytes.length && (bytes[start] & 0xc0) === 0x80)
11
- start++;
12
- return { text: bytes.subarray(start).toString(), truncated: true };
13
- }
14
- function section(label, output) {
15
- const bounded = tail(output);
16
- if (bounded.text === '' && !bounded.truncated)
17
- return undefined;
18
- return `[${label}${bounded.truncated ? ' · earlier output truncated' : ''}]\n${bounded.text}`;
19
- }
20
- export function shellResultText(command, result) {
21
- const parts = [`$ ${command}`];
22
- const stdout = section('stdout', result.stdout);
23
- const stderr = section('stderr', result.stderr);
24
- if (stdout !== undefined)
25
- parts.push(stdout);
26
- if (stderr !== undefined)
27
- parts.push(stderr);
28
- if (stdout === undefined && stderr === undefined)
29
- parts.push('(no output)');
30
- if (result.sandbox?.denied === true)
31
- parts.push(`[sandbox denied file access · ${result.sandbox.mode}]`);
32
- if (result.timedOut) {
33
- parts.push(`[timed out after ${String(result.timeoutMs)} ms · suspend dashi with Ctrl+Z before running interactive programs]`);
34
- }
35
- else if (result.aborted) {
36
- parts.push('[cancelled]');
37
- }
38
- else if (result.signal !== null) {
39
- parts.push(`[signal ${result.signal}]`);
40
- }
41
- else {
42
- parts.push(result.exitCode === null ? '[exit unavailable]' : `[exit ${String(result.exitCode)}]`);
43
- }
44
- return parts.join('\n');
45
- }
46
- export function quoteShellWord(value) { return `'${value.replaceAll("'", "'\\''")}'`; }
47
- /** Run an explicit human command through DSH and identify its next-step context. */
48
- export async function runHumanShell(ctx, agent, command, signal, success, useSessionSandbox = true) {
49
- const result = await ctx.shell.run(ctx.shell.resolve({
50
- command,
51
- env: { DSH_HOME: resolveDshHome() },
52
- sandboxPolicy: ctx.sandboxPolicy.resolve(useSessionSandbox
53
- ? { session: agent.session } : { mode: 'danger-full-access' }),
54
- signal,
55
- stdoutMaxBytes: HUMAN_SHELL_STREAM_BYTES,
56
- timeoutMs: HUMAN_SHELL_TIMEOUT_MS,
57
- workdir: agent.session.header.cwd,
58
- }));
59
- return [createUserMessage({
60
- content: [{ type: 'text', text: shellResultText(command, result) + (result.exitCode === 0 && success ? `\n${success}` : '') }],
61
- source: {
62
- form: 'notice', kind: 'plugin', plugin: 'dashi',
63
- summary: boundContextSummary(`Shell: ${command.replace(/\s+/gu, ' ').trim()}`),
64
- },
65
- }), result];
66
- }
package/lib/state.d.ts DELETED
@@ -1,517 +0,0 @@
1
- export interface RootView {
2
- readonly contextPercent?: number;
3
- readonly cwd: string;
4
- readonly effort?: string;
5
- readonly id: string;
6
- readonly model: string;
7
- readonly jobs?: readonly JobView[];
8
- readonly parent?: string;
9
- readonly parentTurn?: number;
10
- readonly permission?: string;
11
- readonly provider?: string;
12
- readonly status: 'idle' | 'running';
13
- readonly subagents?: readonly SubagentView[];
14
- readonly title?: string;
15
- }
16
- export interface JobView {
17
- readonly detail?: string;
18
- readonly finishedAt?: number;
19
- readonly id: string;
20
- readonly kind: string;
21
- readonly label: string;
22
- readonly startedAt: number;
23
- readonly status: 'running' | 'stopping' | 'completed' | 'killed' | 'failed';
24
- }
25
- export interface SubagentView {
26
- readonly active?: {
27
- readonly since: number;
28
- readonly through: number;
29
- };
30
- readonly elapsedMs?: number;
31
- readonly id: string;
32
- readonly label: string;
33
- readonly mode: 'continuable' | 'one-shot';
34
- readonly state: 'inactive' | 'running';
35
- readonly summary?: string;
36
- readonly tokens?: number;
37
- }
38
- export interface ToolDiff {
39
- readonly added: number;
40
- readonly lines: readonly string[];
41
- readonly path: string;
42
- readonly removed: number;
43
- }
44
- export interface ToolCard {
45
- readonly body?: string;
46
- readonly card: 'diff' | 'generic' | 'read' | 'search' | 'terminal' | 'web';
47
- readonly diffs?: readonly ToolDiff[];
48
- readonly status?: string;
49
- readonly title: string;
50
- }
51
- export interface TerminalCell {
52
- readonly collapsed?: boolean;
53
- readonly detail?: string;
54
- readonly elapsedMs?: number;
55
- readonly key: string;
56
- readonly kind: 'assistant' | 'command' | 'compaction' | 'context' | 'error' | 'outcome' | 'reasoning' | 'shell' | 'todo' | 'tool' | 'user';
57
- readonly pending?: boolean;
58
- readonly startedAt?: number;
59
- readonly text: string;
60
- readonly tool?: ToolCard;
61
- }
62
- export interface DraftAttachment {
63
- readonly bytes: number;
64
- readonly data: Uint8Array;
65
- readonly mediaType: 'image/gif' | 'image/jpeg' | 'image/png' | 'image/webp';
66
- readonly name: string;
67
- readonly path: string;
68
- }
69
- export interface ComposerCursor {
70
- readonly col: number;
71
- readonly line: number;
72
- }
73
- export interface DecisionOwner {
74
- readonly id: string;
75
- readonly label?: string;
76
- }
77
- export interface ApprovalDecision {
78
- readonly cursor: number;
79
- readonly id: string;
80
- readonly kind: 'approval';
81
- readonly owner: DecisionOwner;
82
- readonly prompt: string;
83
- readonly toolName: string;
84
- }
85
- export interface QuestionOption {
86
- readonly description?: string;
87
- readonly label: string;
88
- }
89
- export interface QuestionItem {
90
- readonly allowCustom?: boolean;
91
- readonly detail?: string;
92
- readonly header?: string;
93
- readonly id: string;
94
- readonly intent?: {
95
- readonly approve: string;
96
- readonly kind: 'plan-review';
97
- };
98
- readonly multiSelect: boolean;
99
- readonly options: readonly QuestionOption[];
100
- readonly question: string;
101
- readonly secret?: boolean;
102
- }
103
- export interface QuestionAnswer {
104
- readonly custom?: string;
105
- readonly id: string;
106
- readonly selected: readonly string[];
107
- }
108
- export interface QuestionDecision {
109
- readonly answers: readonly QuestionAnswer[];
110
- readonly cursor: number;
111
- readonly custom: string;
112
- readonly id: string;
113
- readonly index: number;
114
- readonly kind: 'question';
115
- readonly owner: DecisionOwner;
116
- readonly questions: readonly QuestionItem[];
117
- readonly selected: readonly string[];
118
- }
119
- export type PendingDecision = ApprovalDecision | QuestionDecision;
120
- export type ApprovalOutcome = 'allowed-once' | 'cancelled' | 'rejected';
121
- export type DecisionAnswer = ApprovalOutcome | {
122
- readonly answers: readonly QuestionAnswer[];
123
- };
124
- export type SendMode = 'next-turn' | 'steer';
125
- export type ToolMode = 'collapsed' | 'expanded' | 'hidden';
126
- export type OverlayValue = {
127
- readonly kind: 'agent-preset';
128
- readonly preset: string;
129
- } | {
130
- readonly kind: 'attach';
131
- readonly path: string;
132
- readonly source: string;
133
- readonly text: string;
134
- } | {
135
- readonly kind: 'copy';
136
- readonly text: string;
137
- } | {
138
- readonly kind: 'insert';
139
- readonly text: string;
140
- } | {
141
- readonly jobId: string;
142
- readonly kind: 'job-output';
143
- } | {
144
- readonly kind: 'model';
145
- readonly effort?: string;
146
- readonly model: string;
147
- readonly provider: string;
148
- } | {
149
- readonly kind: 'open-file';
150
- readonly path: string;
151
- } | {
152
- readonly interrupt?: true;
153
- readonly kind: 'fork';
154
- } | {
155
- readonly agentPreset?: string;
156
- readonly interrupt?: true;
157
- readonly kind: 'new';
158
- readonly title?: string;
159
- } | {
160
- readonly all?: boolean;
161
- readonly interrupt?: true;
162
- readonly kind: 'open-resume';
163
- } | {
164
- readonly interrupt?: true;
165
- readonly kind: 'open-rewind';
166
- } | {
167
- readonly kind: 'permission';
168
- readonly preset: string;
169
- } | {
170
- readonly all?: boolean;
171
- readonly interrupt?: true;
172
- readonly kind: 'resume';
173
- readonly sessionId: string;
174
- } | {
175
- readonly atSeq?: number;
176
- readonly kind: 'rewind-boundary';
177
- readonly prompt: string;
178
- readonly roller: boolean;
179
- } | {
180
- readonly atSeq?: number;
181
- readonly interrupt?: true;
182
- readonly kind: 'rewind';
183
- readonly mode: 'both' | 'code' | 'conversation';
184
- readonly prompt: string;
185
- } | {
186
- readonly kind: 'search-result';
187
- readonly rootId: string;
188
- readonly seq: number;
189
- readonly sessionId: string;
190
- };
191
- export type ActivatableOverlayValue = Exclude<OverlayValue, {
192
- kind: 'attach';
193
- } | {
194
- kind: 'copy';
195
- } | {
196
- kind: 'insert';
197
- }>;
198
- export interface OverlayOption {
199
- readonly active?: boolean;
200
- readonly confirmDetail?: readonly string[];
201
- readonly danger?: boolean;
202
- readonly detail?: string;
203
- readonly group?: 'Commands' | 'Files' | 'Skills';
204
- readonly label: string;
205
- readonly submitOnEnter?: boolean;
206
- readonly value: OverlayValue;
207
- }
208
- export type Overlay = {
209
- readonly cursor: number;
210
- readonly kind: 'list';
211
- readonly notice?: string;
212
- readonly options: readonly OverlayOption[];
213
- readonly purpose: 'agents' | 'completion' | 'copy' | 'memory' | 'model' | 'permission' | 'resume' | 'rewind' | 'rewind-action' | 'search' | 'skills';
214
- readonly title: string;
215
- } | {
216
- readonly cells?: readonly TerminalCell[];
217
- readonly kind: 'info';
218
- readonly lines: readonly string[];
219
- readonly scrollOffset?: number;
220
- readonly title: string;
221
- } | {
222
- readonly cursor: number;
223
- readonly expanded: boolean;
224
- readonly kind: 'details';
225
- } | {
226
- readonly cursor: number;
227
- readonly expanded: boolean;
228
- readonly kind: 'history';
229
- } | {
230
- readonly acceptLabel: string;
231
- readonly cursor: number;
232
- readonly detail: readonly string[];
233
- readonly kind: 'confirm';
234
- readonly title: string;
235
- readonly value: ActivatableOverlayValue;
236
- };
237
- export interface ViewState {
238
- readonly attachments: readonly DraftAttachment[];
239
- readonly cells: readonly TerminalCell[];
240
- readonly composer: string;
241
- readonly cwd: string;
242
- readonly decisions: readonly PendingDecision[];
243
- readonly exitArmed: boolean;
244
- readonly historyHasMore: boolean;
245
- readonly inline: boolean;
246
- readonly newOutput: number;
247
- readonly overlay?: Overlay;
248
- readonly prompts: readonly string[];
249
- readonly recall?: {
250
- readonly cursor: number;
251
- readonly draft: string;
252
- } | undefined;
253
- readonly rewindArmed: boolean;
254
- readonly root?: RootView;
255
- readonly scrollOffset: number;
256
- readonly search?: {
257
- readonly cursor: number;
258
- readonly matches: readonly number[];
259
- readonly query: string;
260
- readonly scope: 'history' | 'transcript';
261
- } | undefined;
262
- readonly sendMode: SendMode;
263
- readonly stash?: {
264
- readonly attachments: readonly DraftAttachment[];
265
- readonly composer: string;
266
- readonly cursor: ComposerCursor;
267
- };
268
- readonly toolMode: ToolMode;
269
- }
270
- export type UiAction = {
271
- readonly attachment: DraftAttachment;
272
- readonly source?: string;
273
- readonly text?: string;
274
- readonly type: 'attachment-added';
275
- } | {
276
- readonly path: string;
277
- readonly type: 'attachment-path';
278
- } | {
279
- readonly index: number;
280
- readonly type: 'attachment-remove';
281
- } | {
282
- readonly type: 'clipboard-paste';
283
- } | {
284
- readonly caret?: number;
285
- readonly completion?: boolean;
286
- readonly type: 'composer-changed';
287
- readonly text: string;
288
- } | {
289
- readonly cursor?: ComposerCursor;
290
- readonly type: 'composer-set';
291
- readonly text: string;
292
- } | {
293
- readonly type: 'ctrl-c';
294
- } | {
295
- readonly type: 'ctrl-d';
296
- } | {
297
- readonly type: 'decision-cancel';
298
- } | {
299
- readonly type: 'decision-enqueued';
300
- readonly decision: PendingDecision;
301
- } | {
302
- readonly type: 'decision-move';
303
- readonly offset: number;
304
- } | {
305
- readonly type: 'decision-number';
306
- readonly number: number;
307
- } | {
308
- readonly type: 'decision-submit';
309
- } | {
310
- readonly type: 'decision-toggle';
311
- } | {
312
- readonly type: 'decision-withdrawn';
313
- readonly id: string;
314
- } | {
315
- readonly type: 'disarm-exit';
316
- } | {
317
- readonly type: 'escape';
318
- } | {
319
- readonly type: 'exit';
320
- } | {
321
- readonly type: 'external-edit';
322
- } | {
323
- readonly type: 'help';
324
- } | {
325
- readonly type: 'history-copy';
326
- } | {
327
- readonly type: 'history-move';
328
- readonly offset: -1 | 1;
329
- } | {
330
- readonly type: 'history-page';
331
- readonly cells: readonly TerminalCell[];
332
- readonly hasMore: boolean;
333
- readonly rootId: string;
334
- } | {
335
- readonly type: 'history-toggle';
336
- } | {
337
- readonly type: 'open-history';
338
- } | {
339
- readonly type: 'open-details';
340
- } | {
341
- readonly path: string;
342
- readonly type: 'open-file';
343
- } | {
344
- readonly type: 'completion-ready';
345
- readonly options: readonly OverlayOption[];
346
- readonly query: string;
347
- } | {
348
- readonly type: 'open-overlay';
349
- readonly overlay: Overlay;
350
- } | {
351
- readonly type: 'overlay-close';
352
- } | {
353
- readonly limit?: number;
354
- readonly type: 'overlay-move';
355
- readonly offset: number;
356
- } | {
357
- readonly type: 'overlay-number';
358
- readonly number: number;
359
- } | {
360
- readonly execute?: boolean;
361
- readonly type: 'overlay-submit';
362
- } | {
363
- readonly type: 'redraw';
364
- } | {
365
- readonly type: 'prompt-recorded';
366
- readonly rootId: string;
367
- readonly text: string;
368
- } | {
369
- readonly type: 'recall-move';
370
- readonly offset: -1 | 1;
371
- } | {
372
- readonly caret: number;
373
- readonly type: 'request-completion';
374
- } | {
375
- readonly type: 'request-search';
376
- } | {
377
- readonly type: 'root-bound';
378
- readonly cells: readonly TerminalCell[];
379
- readonly hasMore: boolean;
380
- readonly prompts: readonly string[];
381
- readonly root: RootView;
382
- } | {
383
- readonly type: 'root-cleared';
384
- } | {
385
- readonly type: 'root-model';
386
- readonly effort?: string;
387
- readonly model: string;
388
- readonly provider: string;
389
- readonly rootId: string;
390
- } | {
391
- readonly contextPercent?: number | null;
392
- readonly jobs?: readonly JobView[];
393
- readonly rootId: string;
394
- readonly subagents?: readonly SubagentView[];
395
- readonly type: 'root-presentation';
396
- } | {
397
- readonly type: 'root-permission';
398
- readonly preset: string;
399
- readonly rootId: string;
400
- } | {
401
- readonly type: 'root-status';
402
- readonly rootId: string;
403
- readonly status: 'idle' | 'running';
404
- } | {
405
- readonly type: 'root-title';
406
- readonly rootId: string;
407
- readonly title: string;
408
- } | {
409
- readonly type: 'runtime-error';
410
- readonly message: string;
411
- readonly rootId?: string;
412
- } | {
413
- readonly type: 'scroll';
414
- readonly direction: 'end' | 'home' | 'page-down' | 'page-up';
415
- readonly lines?: number;
416
- } | {
417
- readonly type: 'search-close';
418
- } | {
419
- readonly type: 'search-move';
420
- readonly offset: -1 | 1;
421
- } | {
422
- readonly type: 'search-open';
423
- readonly scope: 'history' | 'transcript';
424
- } | {
425
- readonly type: 'submit';
426
- } | {
427
- readonly type: 'suspend';
428
- } | {
429
- readonly cursor: ComposerCursor;
430
- readonly type: 'stash-toggle';
431
- } | {
432
- readonly type: 'terminal-lost';
433
- } | {
434
- readonly type: 'cycle-permission';
435
- } | {
436
- readonly type: 'toggle-send-mode';
437
- } | {
438
- readonly type: 'toggle-tool-mode';
439
- } | {
440
- readonly durationMs: number;
441
- readonly rootId: string;
442
- readonly type: 'turn-ended';
443
- } | {
444
- readonly type: 'transcript-changed';
445
- readonly cells: readonly TerminalCell[];
446
- readonly hasMore?: boolean;
447
- readonly rootId?: string;
448
- } | {
449
- readonly selection: number | 'code';
450
- readonly type: 'copy-assistant';
451
- };
452
- export type UiEffect = {
453
- readonly type: 'activate-overlay';
454
- readonly value: ActivatableOverlayValue;
455
- } | {
456
- readonly type: 'bell';
457
- } | {
458
- readonly path: string;
459
- readonly source: string;
460
- readonly text: string;
461
- readonly type: 'attach';
462
- } | {
463
- readonly type: 'clipboard-image';
464
- } | {
465
- readonly caret: number;
466
- readonly query: string;
467
- readonly type: 'complete';
468
- } | {
469
- readonly type: 'copy';
470
- readonly text: string;
471
- } | {
472
- readonly type: 'cycle-permission';
473
- } | {
474
- readonly type: 'exit';
475
- } | {
476
- readonly armed: boolean;
477
- readonly type: 'exit-timer';
478
- } | {
479
- readonly cwd: string;
480
- readonly text: string;
481
- readonly type: 'external-edit';
482
- } | {
483
- readonly type: 'interrupt';
484
- } | {
485
- readonly type: 'load-history';
486
- readonly rootId: string;
487
- } | {
488
- readonly type: 'redraw';
489
- readonly force: boolean;
490
- } | {
491
- readonly type: 'reject-decision';
492
- readonly id: string;
493
- readonly reason: 'terminal' | 'withdrawn';
494
- } | {
495
- readonly cursor?: ComposerCursor;
496
- readonly type: 'set-composer';
497
- readonly text: string;
498
- } | {
499
- readonly type: 'search';
500
- readonly query: string;
501
- readonly rootId: string;
502
- } | {
503
- readonly type: 'settle-decision';
504
- readonly answer: DecisionAnswer;
505
- readonly id: string;
506
- } | {
507
- readonly attachments: readonly DraftAttachment[];
508
- readonly type: 'submit';
509
- readonly mode: SendMode;
510
- readonly text: string;
511
- } | {
512
- readonly type: 'suspend';
513
- };
514
- export declare function initialViewState(cwd: string, inline: boolean, root?: RootView, cells?: readonly TerminalCell[], prompts?: readonly string[], historyHasMore?: boolean, attachments?: readonly DraftAttachment[], toolMode?: ToolMode): ViewState;
515
- export declare const TURN_BELL_THRESHOLD_MS = 10000;
516
- export declare const PAGE_CELLS = 8;
517
- export declare function reduce(state: ViewState, action: UiAction): readonly [ViewState, readonly UiEffect[]];