@itookit/dsht 0.3.7 → 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.
- package/README.i18n.yaml +2 -2
- package/README.md +31 -11
- package/README.zh.md +31 -11
- package/dist/cli/dsht.js +207 -19
- package/dist/cli/startup.d.ts +40 -0
- package/dist/cli/startup.js +295 -0
- package/dist/cli/trace-summary.d.ts +78 -0
- package/dist/cli/trace-summary.js +241 -0
- package/dist/cli/verifier.d.ts +60 -0
- package/dist/cli/verifier.js +242 -0
- package/dist/contracts.d.ts +344 -0
- package/dist/contracts.js +1 -0
- package/dist/controller/commands.d.ts +47 -0
- package/dist/controller/commands.js +322 -0
- package/dist/controller/connection.d.ts +11 -29
- package/dist/controller/connection.js +26 -60
- package/dist/controller/controller.d.ts +619 -164
- package/dist/controller/controller.js +1420 -141
- package/dist/controller/index.d.ts +8 -1
- package/dist/controller/index.js +5 -0
- package/dist/controller/loop-contract.d.ts +136 -0
- package/dist/controller/loop-contract.js +308 -0
- package/dist/controller/loop-prompts-schema.d.ts +56 -0
- package/dist/controller/loop-prompts-schema.js +144 -0
- package/dist/controller/loop-prompts.d.ts +55 -0
- package/dist/controller/loop-prompts.generated.d.ts +104 -0
- package/dist/controller/loop-prompts.generated.js +185 -0
- package/dist/controller/loop-prompts.js +104 -0
- package/dist/controller/loop-protocols.d.ts +39 -0
- package/dist/controller/loop-protocols.js +115 -0
- package/dist/controller/loop.d.ts +275 -0
- package/dist/controller/loop.js +378 -0
- package/dist/controller/prompts.d.ts +54 -0
- package/dist/controller/prompts.js +162 -0
- package/dist/controller/trace-log.d.ts +45 -0
- package/dist/controller/trace-log.js +144 -0
- package/dist/controller/verifier.d.ts +126 -0
- package/dist/controller/verifier.js +75 -0
- package/dist/cost/index.d.ts +1 -1
- package/dist/cost/index.js +1 -1
- package/dist/cost/ledger.d.ts +0 -1
- package/dist/cost/ledger.js +0 -1
- package/dist/json.d.ts +18 -0
- package/dist/json.js +19 -0
- package/dist/references.d.ts +25 -0
- package/dist/references.js +26 -0
- package/dist/session/connection-view.d.ts +2 -11
- package/dist/session/controller.d.ts +82 -72
- package/dist/session/controller.js +211 -209
- package/dist/session/history.d.ts +9 -1
- package/dist/session/history.js +1 -9
- package/dist/session/index.d.ts +9 -4
- package/dist/session/index.js +7 -3
- package/dist/session/info.d.ts +25 -52
- package/dist/session/info.js +39 -25
- package/dist/session/markdown.js +1 -1
- package/dist/session/math.js +1 -1
- package/dist/session/mutation-gate.d.ts +51 -0
- package/dist/session/mutation-gate.js +73 -0
- package/dist/session/navigation.d.ts +2 -89
- package/dist/session/navigation.js +2 -129
- package/dist/session/peek.d.ts +38 -0
- package/dist/session/peek.js +103 -0
- package/dist/session/references.d.ts +2 -20
- package/dist/session/references.js +1 -26
- package/dist/session/runtime.d.ts +26 -0
- package/dist/session/runtime.js +28 -0
- package/dist/session/telemetry.d.ts +12 -13
- package/dist/session/telemetry.js +27 -58
- package/dist/session/transcript.d.ts +0 -6
- package/dist/session/transcript.js +2 -15
- package/dist/session/types.d.ts +25 -0
- package/dist/session/types.js +0 -1
- package/dist/session-title.d.ts +9 -0
- package/dist/session-title.js +21 -0
- package/dist/shell/controller.d.ts +97 -0
- package/dist/shell/controller.js +158 -0
- package/dist/shell/index.d.ts +5 -0
- package/dist/shell/index.js +3 -0
- package/dist/shell/runner.d.ts +38 -0
- package/dist/shell/runner.js +147 -0
- package/dist/slash/index.d.ts +10 -0
- package/dist/slash/index.js +7 -0
- package/dist/slash/parse.d.ts +166 -0
- package/dist/slash/parse.js +259 -0
- package/dist/slash/pipeline.d.ts +140 -0
- package/dist/slash/pipeline.js +115 -0
- package/dist/slash/registry.d.ts +88 -0
- package/dist/slash/registry.js +177 -0
- package/dist/state.d.ts +14 -4
- package/dist/state.js +3 -2
- package/dist/text.d.ts +28 -0
- package/dist/text.js +55 -0
- package/dist/transport/events.d.ts +104 -0
- package/dist/transport/events.js +149 -0
- package/dist/transport/wire.d.ts +9 -17
- package/dist/transport/wire.js +2 -27
- package/dist/ui/app.js +865 -431
- package/dist/ui/chat/header.js +1 -1
- package/dist/ui/chat/history-view.d.ts +1 -1
- package/dist/ui/chat/history-view.js +1 -1
- package/dist/ui/chat/loop-status.d.ts +11 -0
- package/dist/ui/chat/loop-status.js +28 -0
- package/dist/ui/chat/navigation-model.d.ts +86 -0
- package/dist/ui/chat/navigation-model.js +107 -0
- package/dist/ui/chat/shell-view.d.ts +47 -0
- package/dist/ui/chat/shell-view.js +145 -0
- package/dist/ui/chat/status.d.ts +47 -3
- package/dist/ui/chat/status.js +65 -50
- package/dist/ui/chat/viewport.d.ts +1 -1
- package/dist/ui/dialogs/cost.d.ts +21 -4
- package/dist/ui/dialogs/cost.js +7 -12
- package/dist/ui/dialogs/index.d.ts +22 -5
- package/dist/ui/dialogs/index.js +19 -3
- package/dist/ui/dialogs/loop.d.ts +43 -0
- package/dist/ui/dialogs/loop.js +224 -0
- package/dist/ui/dialogs/peek.d.ts +25 -0
- package/dist/ui/dialogs/peek.js +35 -0
- package/dist/ui/dialogs/picker.d.ts +2 -0
- package/dist/ui/dialogs/picker.js +4 -2
- package/dist/ui/input/mouse.d.ts +12 -2
- package/dist/ui/input/mouse.js +20 -7
- package/dist/ui/input/references.d.ts +1 -1
- package/dist/ui/status/model.d.ts +7 -0
- package/dist/ui/status/model.js +5 -0
- package/dist/ui/theme/index.d.ts +6 -1
- package/dist/ui/theme/index.js +2 -1
- package/package.json +6 -4
- package/dist/ui/commands/parse.d.ts +0 -99
- package/dist/ui/commands/parse.js +0 -126
- package/dist/ui/commands/registry.d.ts +0 -33
- 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
|
|
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
|
-
|
|
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):
|
|
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
|
|
67
|
-
* @param
|
|
68
|
-
* @returns Whether this domain retained the
|
|
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
|
-
|
|
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 -
|
|
113
|
+
* @param error - Already-normalized error text.
|
|
83
114
|
*/
|
|
84
|
-
reportError(sessionId:
|
|
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.
|
|
@@ -121,12 +159,36 @@ export declare class SessionController {
|
|
|
121
159
|
switchSession(query?: string): Promise<void>;
|
|
122
160
|
/** Prompt for a host path without starting a local agent. */
|
|
123
161
|
enterPath(): void;
|
|
162
|
+
/** Adopt the workspace whose registered path contains the directory this client runs in.
|
|
163
|
+
*
|
|
164
|
+
* Longest path wins, so a workspace nested in another is preferred, and the comparison is on whole
|
|
165
|
+
* path segments so `/srv/app-old` cannot match `/srv/app`. A remote host's paths usually differ
|
|
166
|
+
* from the client's, in which case nothing matches and the picker stays exactly as before.
|
|
167
|
+
* @param directory - Directory this client was started in.
|
|
168
|
+
* @returns The adopted workspace's id, or undefined when none matches.
|
|
169
|
+
*/
|
|
170
|
+
adoptLocalWorkspace(directory: string): string | undefined;
|
|
124
171
|
/** Register a host directory and move to its session picker.
|
|
125
172
|
* @param path - Absolute directory path on the host.
|
|
126
173
|
*/
|
|
127
174
|
createWorkspace(path: string): Promise<void>;
|
|
128
175
|
/** Create a session only after the user explicitly selects New session. */
|
|
129
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>;
|
|
130
192
|
/** Replace the selected transcript and cancel its preceding follow stream.
|
|
131
193
|
* @param sessionId - Session to follow.
|
|
132
194
|
*/
|
|
@@ -177,10 +239,18 @@ export declare class SessionController {
|
|
|
177
239
|
* @param text - Composed prompt text.
|
|
178
240
|
*/
|
|
179
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>;
|
|
180
250
|
/** Answer the oldest selected-session interaction, after explicit user action.
|
|
181
251
|
* @param value - Structured answer value or approval outcome.
|
|
182
252
|
*/
|
|
183
|
-
answer(value:
|
|
253
|
+
answer(value: AnswerValue): Promise<void>;
|
|
184
254
|
/** Restrict an approval command to an approval request.
|
|
185
255
|
* @param allowed - Whether the request is approved once.
|
|
186
256
|
*/
|
|
@@ -209,40 +279,12 @@ export declare class SessionController {
|
|
|
209
279
|
* @returns The recalled prompt, or the unsent draft.
|
|
210
280
|
*/
|
|
211
281
|
recall(direction: -1 | 1, current: string): string;
|
|
212
|
-
/** Composer draft, caret and parked draft, as the selected session holds them. */
|
|
213
|
-
get composer(): ComposerState;
|
|
214
|
-
/** Replace the composer text and caret, publishing only when either actually changed. */
|
|
215
|
-
setComposer(draft: string, cursor?: number): void;
|
|
216
|
-
/** Move the caret without changing the text. */
|
|
217
|
-
setComposerCursor(cursor: number): void;
|
|
218
|
-
/** Move a non-empty draft aside while a dialog owns the keyboard. */
|
|
219
|
-
parkComposer(): void;
|
|
220
|
-
/** Give a parked draft back once no dialog needs the keyboard. */
|
|
221
|
-
restoreComposer(): void;
|
|
222
|
-
/** How the selected session's record is being read right now. */
|
|
223
|
-
get view(): ViewState;
|
|
224
|
-
/** Show a detached history window, releasing the one it replaces.
|
|
225
|
-
* @param window - Record to display, or undefined to return to the live transcript.
|
|
226
|
-
*/
|
|
227
|
-
setViewWindow(window?: Transcript): void;
|
|
228
|
-
/** Move the reader's position inside the displayed record.
|
|
229
|
-
* @param scroll - Rows scrolled back from the live end.
|
|
230
|
-
*/
|
|
231
|
-
setScroll(scroll: number): void;
|
|
232
|
-
/** Replace the set of expanded reasoning blocks, keyed by message sequence.
|
|
233
|
-
* @param folds - Sequences to expand beyond the default fold.
|
|
234
|
-
*/
|
|
235
|
-
setFolds(folds: ReadonlySet<number>): void;
|
|
236
|
-
/** Set the fold mode of the live attempt's completed reasoning.
|
|
237
|
-
* @param reasoning - `row` to fold, `full` to keep the streamed text.
|
|
238
|
-
*/
|
|
239
|
-
setLiveReasoning(reasoning: Reasoning): void;
|
|
240
282
|
/** Local answer state for the selected session's pending waterfalls. */
|
|
241
283
|
get interaction(): InteractionState;
|
|
242
284
|
/** Replace the partly collected answers, keyed by the waterfall event id.
|
|
243
285
|
* @param answers - Answers collected so far, by event id.
|
|
244
286
|
*/
|
|
245
|
-
setAnswers(answers: Record<string,
|
|
287
|
+
setAnswers(answers: Record<string, AnswerValue['answers']>): void;
|
|
246
288
|
/** Replace the pending question's option keyboard state.
|
|
247
289
|
* @param option - Highlighted option, toggled labels and free-text mode; undefined clears it.
|
|
248
290
|
*/
|
|
@@ -251,38 +293,6 @@ export declare class SessionController {
|
|
|
251
293
|
* @param approval - Selected approval row; undefined clears the highlight.
|
|
252
294
|
*/
|
|
253
295
|
setApproval(approval?: InteractionState['approval']): void;
|
|
254
|
-
/** Composer-adjacent `@` reference menu state. */
|
|
255
|
-
get reference(): ReferenceState;
|
|
256
|
-
/** Highlight one row of the open reference menu.
|
|
257
|
-
* @param index - Row index into the current matches.
|
|
258
|
-
*/
|
|
259
|
-
setReferenceIndex(index: number): void;
|
|
260
|
-
/** Remember the draft that dismissed the reference menu, so it does not reopen while it stands.
|
|
261
|
-
* @param draft - Composer text at dismissal, or undefined to allow the menu again.
|
|
262
|
-
*/
|
|
263
|
-
setReferenceDismissed(draft?: string): void;
|
|
264
|
-
/** Panels the selected session has open. */
|
|
265
|
-
get panels(): PanelState;
|
|
266
|
-
/** Show or hide the reasoning panel.
|
|
267
|
-
* @param open - Whether `/think` is open.
|
|
268
|
-
*/
|
|
269
|
-
openThoughts(open: boolean): void;
|
|
270
|
-
/** Show or hide the pending-input panel.
|
|
271
|
-
* @param open - Whether `/queue` is open.
|
|
272
|
-
*/
|
|
273
|
-
openQueue(open: boolean): void;
|
|
274
|
-
/** Show the model dialog at one step, or close it.
|
|
275
|
-
* @param model - Catalog plus the provider or model being inspected; undefined closes the dialog.
|
|
276
|
-
*/
|
|
277
|
-
setModelPanel(model?: ModelState): void;
|
|
278
|
-
/** Show the history or content-search dialog, or close it.
|
|
279
|
-
* @param history - Query, content-search mode and matches; undefined closes the dialog.
|
|
280
|
-
*/
|
|
281
|
-
setHistoryPanel(history?: PanelState['history']): void;
|
|
282
|
-
/** Show the host session-search results, or close them.
|
|
283
|
-
* @param search - Query, results and truncation flag; undefined closes the dialog.
|
|
284
|
-
*/
|
|
285
|
-
setSearchPanel(search?: PanelState['search']): void;
|
|
286
296
|
/** Remember a locally submitted command, which never becomes a durable session record. */
|
|
287
297
|
recordRecall(value: string): void;
|
|
288
298
|
/** Leave recall navigation because the composer was edited or replaced. */
|