@itookit/dsht 0.3.8 → 0.5.1

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 (130) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +30 -11
  3. package/README.zh.md +30 -11
  4. package/dist/cli/dsht.js +203 -18
  5. package/dist/cli/startup.d.ts +40 -0
  6. package/dist/cli/startup.js +295 -0
  7. package/dist/cli/trace-summary.d.ts +78 -0
  8. package/dist/cli/trace-summary.js +241 -0
  9. package/dist/cli/verifier.d.ts +60 -0
  10. package/dist/cli/verifier.js +242 -0
  11. package/dist/contracts.d.ts +344 -0
  12. package/dist/contracts.js +1 -0
  13. package/dist/controller/commands.d.ts +47 -0
  14. package/dist/controller/commands.js +322 -0
  15. package/dist/controller/connection.d.ts +11 -29
  16. package/dist/controller/connection.js +26 -60
  17. package/dist/controller/controller.d.ts +616 -166
  18. package/dist/controller/controller.js +1395 -146
  19. package/dist/controller/index.d.ts +8 -1
  20. package/dist/controller/index.js +5 -0
  21. package/dist/controller/loop-contract.d.ts +136 -0
  22. package/dist/controller/loop-contract.js +308 -0
  23. package/dist/controller/loop-prompts-schema.d.ts +56 -0
  24. package/dist/controller/loop-prompts-schema.js +144 -0
  25. package/dist/controller/loop-prompts.d.ts +55 -0
  26. package/dist/controller/loop-prompts.generated.d.ts +104 -0
  27. package/dist/controller/loop-prompts.generated.js +185 -0
  28. package/dist/controller/loop-prompts.js +104 -0
  29. package/dist/controller/loop-protocols.d.ts +39 -0
  30. package/dist/controller/loop-protocols.js +115 -0
  31. package/dist/controller/loop.d.ts +275 -0
  32. package/dist/controller/loop.js +378 -0
  33. package/dist/controller/prompts.d.ts +54 -0
  34. package/dist/controller/prompts.js +162 -0
  35. package/dist/controller/trace-log.d.ts +45 -0
  36. package/dist/controller/trace-log.js +144 -0
  37. package/dist/controller/verifier.d.ts +126 -0
  38. package/dist/controller/verifier.js +75 -0
  39. package/dist/cost/index.d.ts +1 -1
  40. package/dist/cost/index.js +1 -1
  41. package/dist/cost/ledger.d.ts +0 -1
  42. package/dist/cost/ledger.js +0 -1
  43. package/dist/json.d.ts +18 -0
  44. package/dist/json.js +19 -0
  45. package/dist/references.d.ts +25 -0
  46. package/dist/references.js +26 -0
  47. package/dist/session/connection-view.d.ts +2 -11
  48. package/dist/session/controller.d.ts +73 -72
  49. package/dist/session/controller.js +185 -209
  50. package/dist/session/history.d.ts +6 -18
  51. package/dist/session/history.js +1 -24
  52. package/dist/session/index.d.ts +9 -4
  53. package/dist/session/index.js +7 -3
  54. package/dist/session/info.d.ts +25 -52
  55. package/dist/session/info.js +39 -25
  56. package/dist/session/markdown.js +1 -1
  57. package/dist/session/math.js +1 -1
  58. package/dist/session/mutation-gate.d.ts +51 -0
  59. package/dist/session/mutation-gate.js +73 -0
  60. package/dist/session/navigation.d.ts +2 -89
  61. package/dist/session/navigation.js +2 -129
  62. package/dist/session/peek.d.ts +38 -0
  63. package/dist/session/peek.js +103 -0
  64. package/dist/session/references.d.ts +2 -20
  65. package/dist/session/references.js +1 -26
  66. package/dist/session/runtime.d.ts +26 -0
  67. package/dist/session/runtime.js +28 -0
  68. package/dist/session/telemetry.d.ts +12 -13
  69. package/dist/session/telemetry.js +27 -58
  70. package/dist/session/transcript.d.ts +0 -6
  71. package/dist/session/transcript.js +2 -15
  72. package/dist/session/types.d.ts +25 -0
  73. package/dist/session/types.js +0 -1
  74. package/dist/session-title.d.ts +9 -0
  75. package/dist/session-title.js +21 -0
  76. package/dist/shell/controller.d.ts +31 -1
  77. package/dist/shell/controller.js +34 -2
  78. package/dist/shell/index.d.ts +3 -3
  79. package/dist/shell/index.js +2 -2
  80. package/dist/shell/runner.d.ts +10 -0
  81. package/dist/shell/runner.js +48 -9
  82. package/dist/slash/index.d.ts +10 -0
  83. package/dist/slash/index.js +7 -0
  84. package/dist/slash/parse.d.ts +166 -0
  85. package/dist/slash/parse.js +259 -0
  86. package/dist/slash/pipeline.d.ts +140 -0
  87. package/dist/slash/pipeline.js +115 -0
  88. package/dist/slash/registry.d.ts +88 -0
  89. package/dist/slash/registry.js +177 -0
  90. package/dist/state.d.ts +14 -4
  91. package/dist/state.js +3 -2
  92. package/dist/text.d.ts +28 -0
  93. package/dist/text.js +55 -0
  94. package/dist/transport/events.d.ts +104 -0
  95. package/dist/transport/events.js +149 -0
  96. package/dist/transport/wire.d.ts +9 -17
  97. package/dist/transport/wire.js +2 -27
  98. package/dist/ui/app.js +856 -441
  99. package/dist/ui/chat/header.js +1 -1
  100. package/dist/ui/chat/history-view.d.ts +1 -1
  101. package/dist/ui/chat/loop-status.d.ts +11 -0
  102. package/dist/ui/chat/loop-status.js +28 -0
  103. package/dist/ui/chat/navigation-model.d.ts +86 -0
  104. package/dist/ui/chat/navigation-model.js +107 -0
  105. package/dist/ui/chat/shell-view.d.ts +15 -2
  106. package/dist/ui/chat/shell-view.js +37 -3
  107. package/dist/ui/chat/status.d.ts +47 -3
  108. package/dist/ui/chat/status.js +65 -50
  109. package/dist/ui/chat/viewport.d.ts +1 -1
  110. package/dist/ui/dialogs/cost.d.ts +21 -4
  111. package/dist/ui/dialogs/cost.js +7 -12
  112. package/dist/ui/dialogs/index.d.ts +22 -5
  113. package/dist/ui/dialogs/index.js +19 -3
  114. package/dist/ui/dialogs/loop.d.ts +43 -0
  115. package/dist/ui/dialogs/loop.js +224 -0
  116. package/dist/ui/dialogs/peek.d.ts +25 -0
  117. package/dist/ui/dialogs/peek.js +35 -0
  118. package/dist/ui/dialogs/picker.d.ts +2 -0
  119. package/dist/ui/dialogs/picker.js +4 -2
  120. package/dist/ui/input/mouse.d.ts +12 -2
  121. package/dist/ui/input/mouse.js +20 -7
  122. package/dist/ui/input/references.d.ts +1 -1
  123. package/dist/ui/status/model.d.ts +7 -0
  124. package/dist/ui/status/model.js +5 -0
  125. package/dist/ui/theme/index.d.ts +1 -1
  126. package/package.json +6 -4
  127. package/dist/ui/commands/parse.d.ts +0 -104
  128. package/dist/ui/commands/parse.js +0 -135
  129. package/dist/ui/commands/registry.d.ts +0 -33
  130. package/dist/ui/commands/registry.js +0 -73
@@ -1,13 +1,17 @@
1
1
  import type { HostAccess } from '../transport/host.ts';
2
2
  import { type Json, type ObjectValue } from '../transport/wire.ts';
3
3
  import type { ControllerStore, State } from '../state.ts';
4
+ import { type SessionRender } from './history.ts';
4
5
  import type { HistoryLimits } from './memory.ts';
5
6
  import { type FileReference } from './references.ts';
6
- import { type ComposerState, type InteractionState, type ModelState, type OptionState, type PanelState, type ReferenceState, type ViewState } from './info.ts';
7
+ import type { Telemetry } from './telemetry.ts';
8
+ import { type InteractionState, type OptionState } from './info.ts';
9
+ import type { MutationAdmission } from './mutation-gate.ts';
7
10
  import type { Reasoning } from './history.ts';
8
11
  import { Transcript } from './transcript.ts';
9
12
  import type { ConnectionView } from './connection-view.ts';
10
- import type { HistorySearch, RemovalTarget } from './types.ts';
13
+ import type { HistorySearch, AnswerValue, PendingInteraction, RemovalTarget } from './types.ts';
14
+ import { type ControlFrame, type HostEvent } from '../transport/events.ts';
11
15
  /** Owns the selected session: its follow stream, transcript, history window and interactions. */
12
16
  export declare class SessionController {
13
17
  private readonly store;
@@ -16,6 +20,10 @@ export declare class SessionController {
16
20
  private readonly historyLimits;
17
21
  private follow;
18
22
  private interactions;
23
+ /** Reading protection: reclamation pauses while the reader is away from the live end. */
24
+ private historyPinned;
25
+ /** Host runtime mirrors for every session this connection has seen. */
26
+ private readonly runtime;
19
27
  /** Cancels the background prompt backfill of the previous selection. */
20
28
  private promptBackfill?;
21
29
  /** Prompts of sessions this process has already read, so re-opening one costs no page request. */
@@ -26,7 +34,9 @@ export declare class SessionController {
26
34
  private stoppingSession?;
27
35
  private interruptTask;
28
36
  private admission;
29
- constructor(store: ControllerStore, host: HostAccess, connection: ConnectionView, historyLimits: HistoryLimits);
37
+ /** Admission order of this session's writes, so two concurrent decisions cannot interleave. */
38
+ private readonly mutations;
39
+ constructor(store: ControllerStore, host: HostAccess, connection: ConnectionView, historyLimits: HistoryLimits, report?: (admission: MutationAdmission) => void);
30
40
  /** Host running state covers model generation, tools, and waits between assistant attempts. */
31
41
  get running(): boolean;
32
42
  /** Current title projection, falling back to the list title and then the session ID. */
@@ -39,6 +49,27 @@ export declare class SessionController {
39
49
  get visibleSessions(): ObjectValue[];
40
50
  /** Whether a turn, cancellation or prompt admission is still in flight. */
41
51
  get active(): boolean;
52
+ /** @returns The detached history window the reader opened, if any. */
53
+ get window(): Transcript | undefined;
54
+ /** Show a detached history window, releasing the one it replaces.
55
+ * @param window - Record to display, or undefined to return to the live transcript.
56
+ */
57
+ setViewWindow(window?: Transcript): void;
58
+ /** @returns Host projection store of the current generation, owned by this session's runtime. */
59
+ get telemetry(): Telemetry;
60
+ /** Lay out one record for a terminal width.
61
+ *
62
+ * The projection engine stays in this domain; the UI receives plain rows and offsets instead of
63
+ * importing it, and `Reasoning` for committed messages is always the folded default.
64
+ */
65
+ render(input: {
66
+ transcript: Transcript;
67
+ width: number;
68
+ folds: ReadonlySet<number>;
69
+ liveReasoning: Reasoning;
70
+ }): SessionRender;
71
+ /** Apply one normalized control frame to this session's runtime. */
72
+ acceptControl(frame: ControlFrame): void;
42
73
  /** Whether reading protects the loaded window, suspending history reclamation. */
43
74
  get pinned(): boolean;
44
75
  /** Drop generation-scoped state before a new connection generation begins. */
@@ -53,7 +84,7 @@ export declare class SessionController {
53
84
  * @param state - State being published.
54
85
  * @returns Retained question and approval frames for that session.
55
86
  */
56
- pendingFor(state: State): ObjectValue[];
87
+ pendingFor(state: State): PendingInteraction[];
57
88
  /** Unanswered interactions by session, so a list can show who is waiting without opening them.
58
89
  *
59
90
  * The host delivers approval and question waterfalls for every session on one stream, and this
@@ -63,11 +94,11 @@ export declare class SessionController {
63
94
  * @returns One count per session holding at least one unanswered interaction.
64
95
  */
65
96
  pendingCounts(): ReadonlyMap<string, number>;
66
- /** Retain a recognized host waterfall; unknown events stay with the connection to delegate.
67
- * @param frame - One decoded waterfall frame.
68
- * @returns Whether this domain retained the frame for an answer.
97
+ /** Retain a recognized host interaction; anything else belongs to the connection to delegate.
98
+ * @param event - One normalized host event.
99
+ * @returns Whether this domain retained the event for an answer.
69
100
  */
70
- waterfall(frame: ObjectValue): boolean;
101
+ accept(event: HostEvent): boolean;
71
102
  /** Drop a waterfall the host cancelled.
72
103
  * @param eventId - Correlation id previously retained.
73
104
  */
@@ -79,9 +110,9 @@ export declare class SessionController {
79
110
  status(sessionId: string, running: boolean): void;
80
111
  /** Surface a host-reported error for the selected session.
81
112
  * @param sessionId - Session the host reported on.
82
- * @param error - Error payload as delivered by the host.
113
+ * @param error - Already-normalized error text.
83
114
  */
84
- reportError(sessionId: unknown, error: unknown): void;
115
+ reportError(sessionId: string, error: string): void;
85
116
  /** Stop the selected turn, or allow exit only while idle. Repeated keys share one request.
86
117
  * @param force - Send an explicit cancellation even when the cached running flag is idle.
87
118
  * @returns True when the caller may exit; cancellation failures retain the client.
@@ -97,6 +128,13 @@ export declare class SessionController {
97
128
  * @param screen - Picker to display after the refresh.
98
129
  */
99
130
  showPicker(screen: 'workspaces' | 'sessions'): Promise<void>;
131
+ /** Return to the selected conversation without re-selecting it.
132
+ *
133
+ * A picker opened over a conversation is a detour: leaving it must not re-subscribe, reload the
134
+ * transcript or lose the reading position, so this only changes which screen is shown.
135
+ * @returns Whether there was a selected conversation to return to.
136
+ */
137
+ showChat(): boolean;
100
138
  /** Resolve a removal command to one reviewable object without changing the selection.
101
139
  * @param kind - Workspace registration removal or session archival.
102
140
  * @param query - Exact name, ID, or unambiguous ID prefix.
@@ -136,6 +174,21 @@ export declare class SessionController {
136
174
  createWorkspace(path: string): Promise<void>;
137
175
  /** Create a session only after the user explicitly selects New session. */
138
176
  createSession(): Promise<void>;
177
+ /** Create a session for another purpose without selecting it, named so a reader can tell it apart.
178
+ *
179
+ * A verifier runs in its own session while the reviewed session stays selected, so this never
180
+ * follows the new session and never touches the reader's transcript.
181
+ * @param title - Session title to apply; hosts without a title service keep the default.
182
+ * @returns The new session's id, or undefined when its identity could not be read.
183
+ */
184
+ createNamedSession(title: string): Promise<string | undefined>;
185
+ /** Stop a session this client owns but has not selected, such as a verifier's.
186
+ *
187
+ * Killing the child client leaves the host's agent generation running, so the turn has to be
188
+ * cancelled on the host itself.
189
+ * @param sessionId - Session whose turn should stop.
190
+ */
191
+ cancelNamedSession(sessionId: string): Promise<void>;
139
192
  /** Replace the selected transcript and cancel its preceding follow stream.
140
193
  * @param sessionId - Session to follow.
141
194
  */
@@ -186,10 +239,18 @@ export declare class SessionController {
186
239
  * @param text - Composed prompt text.
187
240
  */
188
241
  prompt(text: string): Promise<void>;
242
+ /** Send one prompt the client assembled, keeping its durable echo out of composer recall.
243
+ *
244
+ * The host records every prompt as a user message, so an agent loop that submits a turn per
245
+ * attempt would otherwise crowd out the prompts the operator actually typed. Suppressing the text
246
+ * before sending is what makes the later echo invisible to ↑/↓.
247
+ * @param text - Prompt the client assembled, not text the operator typed.
248
+ */
249
+ promptInternal(text: string): Promise<void>;
189
250
  /** Answer the oldest selected-session interaction, after explicit user action.
190
251
  * @param value - Structured answer value or approval outcome.
191
252
  */
192
- answer(value: Json): Promise<void>;
253
+ answer(value: AnswerValue): Promise<void>;
193
254
  /** Restrict an approval command to an approval request.
194
255
  * @param allowed - Whether the request is approved once.
195
256
  */
@@ -218,40 +279,12 @@ export declare class SessionController {
218
279
  * @returns The recalled prompt, or the unsent draft.
219
280
  */
220
281
  recall(direction: -1 | 1, current: string): string;
221
- /** Composer draft, caret and parked draft, as the selected session holds them. */
222
- get composer(): ComposerState;
223
- /** Replace the composer text and caret, publishing only when either actually changed. */
224
- setComposer(draft: string, cursor?: number): void;
225
- /** Move the caret without changing the text. */
226
- setComposerCursor(cursor: number): void;
227
- /** Move a non-empty draft aside while a dialog owns the keyboard. */
228
- parkComposer(): void;
229
- /** Give a parked draft back once no dialog needs the keyboard. */
230
- restoreComposer(): void;
231
- /** How the selected session's record is being read right now. */
232
- get view(): ViewState;
233
- /** Show a detached history window, releasing the one it replaces.
234
- * @param window - Record to display, or undefined to return to the live transcript.
235
- */
236
- setViewWindow(window?: Transcript): void;
237
- /** Move the reader's position inside the displayed record.
238
- * @param scroll - Rows scrolled back from the live end.
239
- */
240
- setScroll(scroll: number): void;
241
- /** Replace the set of expanded reasoning blocks, keyed by message sequence.
242
- * @param folds - Sequences to expand beyond the default fold.
243
- */
244
- setFolds(folds: ReadonlySet<number>): void;
245
- /** Set the fold mode of the live attempt's completed reasoning.
246
- * @param reasoning - `row` to fold, `full` to keep the streamed text.
247
- */
248
- setLiveReasoning(reasoning: Reasoning): void;
249
282
  /** Local answer state for the selected session's pending waterfalls. */
250
283
  get interaction(): InteractionState;
251
284
  /** Replace the partly collected answers, keyed by the waterfall event id.
252
285
  * @param answers - Answers collected so far, by event id.
253
286
  */
254
- setAnswers(answers: Record<string, ObjectValue[]>): void;
287
+ setAnswers(answers: Record<string, AnswerValue['answers']>): void;
255
288
  /** Replace the pending question's option keyboard state.
256
289
  * @param option - Highlighted option, toggled labels and free-text mode; undefined clears it.
257
290
  */
@@ -260,38 +293,6 @@ export declare class SessionController {
260
293
  * @param approval - Selected approval row; undefined clears the highlight.
261
294
  */
262
295
  setApproval(approval?: InteractionState['approval']): void;
263
- /** Composer-adjacent `@` reference menu state. */
264
- get reference(): ReferenceState;
265
- /** Highlight one row of the open reference menu.
266
- * @param index - Row index into the current matches.
267
- */
268
- setReferenceIndex(index: number): void;
269
- /** Remember the draft that dismissed the reference menu, so it does not reopen while it stands.
270
- * @param draft - Composer text at dismissal, or undefined to allow the menu again.
271
- */
272
- setReferenceDismissed(draft?: string): void;
273
- /** Panels the selected session has open. */
274
- get panels(): PanelState;
275
- /** Show or hide the reasoning panel.
276
- * @param open - Whether `/think` is open.
277
- */
278
- openThoughts(open: boolean): void;
279
- /** Show or hide the pending-input panel.
280
- * @param open - Whether `/queue` is open.
281
- */
282
- openQueue(open: boolean): void;
283
- /** Show the model dialog at one step, or close it.
284
- * @param model - Catalog plus the provider or model being inspected; undefined closes the dialog.
285
- */
286
- setModelPanel(model?: ModelState): void;
287
- /** Show the history or content-search dialog, or close it.
288
- * @param history - Query, content-search mode and matches; undefined closes the dialog.
289
- */
290
- setHistoryPanel(history?: PanelState['history']): void;
291
- /** Show the host session-search results, or close them.
292
- * @param search - Query, results and truncation flag; undefined closes the dialog.
293
- */
294
- setSearchPanel(search?: PanelState['search']): void;
295
296
  /** Remember a locally submitted command, which never becomes a durable session record. */
296
297
  recordRecall(value: string): void;
297
298
  /** Leave recall navigation because the composer was edited or replaced. */