@itookit/dsht 0.3.3 → 0.3.7
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 +10 -10
- package/README.zh.md +7 -7
- package/dist/cli/dsht.d.ts +2 -0
- package/dist/cli/dsht.js +125 -0
- package/dist/cli/index.js +16 -123
- package/dist/controller/controller.d.ts +115 -0
- package/dist/controller/controller.js +126 -1
- package/dist/controller/perf-measures.d.ts +34 -0
- package/dist/controller/perf-measures.js +78 -0
- package/dist/cost/controller.d.ts +5 -0
- package/dist/cost/controller.js +2 -1
- package/dist/cost/scanner.d.ts +4 -2
- package/dist/cost/scanner.js +6 -3
- package/dist/session/controller.d.ts +157 -1
- package/dist/session/controller.js +395 -29
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.js +1 -0
- package/dist/session/info.d.ts +262 -0
- package/dist/session/info.js +326 -0
- package/dist/session/navigation.d.ts +62 -8
- package/dist/session/navigation.js +72 -13
- package/dist/session/transcript.d.ts +37 -1
- package/dist/session/transcript.js +73 -0
- package/dist/state.d.ts +3 -2
- package/dist/state.js +2 -2
- package/dist/ui/app.js +230 -178
- package/dist/ui/chat/status.js +15 -10
- package/dist/ui/dialogs/index.d.ts +9 -8
- package/dist/ui/dialogs/index.js +3 -3
- package/dist/ui/dialogs/picker.d.ts +21 -3
- package/dist/ui/dialogs/picker.js +37 -5
- package/dist/ui/input/input.d.ts +18 -3
- package/dist/ui/input/input.js +61 -22
- package/dist/ui/input/viewport.d.ts +96 -0
- package/dist/ui/input/viewport.js +173 -0
- package/dsht-m.png +0 -0
- package/package.json +3 -3
- package/dist/ui/input/history.d.ts +0 -19
- package/dist/ui/input/history.js +0 -43
|
@@ -3,6 +3,8 @@ import { type Json, type ObjectValue } from '../transport/wire.ts';
|
|
|
3
3
|
import type { ControllerStore, State } from '../state.ts';
|
|
4
4
|
import type { HistoryLimits } from './memory.ts';
|
|
5
5
|
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 { Reasoning } from './history.ts';
|
|
6
8
|
import { Transcript } from './transcript.ts';
|
|
7
9
|
import type { ConnectionView } from './connection-view.ts';
|
|
8
10
|
import type { HistorySearch, RemovalTarget } from './types.ts';
|
|
@@ -14,7 +16,13 @@ export declare class SessionController {
|
|
|
14
16
|
private readonly historyLimits;
|
|
15
17
|
private follow;
|
|
16
18
|
private interactions;
|
|
17
|
-
|
|
19
|
+
/** Cancels the background prompt backfill of the previous selection. */
|
|
20
|
+
private promptBackfill?;
|
|
21
|
+
/** Prompts of sessions this process has already read, so re-opening one costs no page request. */
|
|
22
|
+
private readonly promptCache;
|
|
23
|
+
/** Prompt index, composer and reading view of the selected session; the instance `State.session` exposes. */
|
|
24
|
+
private get info();
|
|
25
|
+
private get prompts();
|
|
18
26
|
private stoppingSession?;
|
|
19
27
|
private interruptTask;
|
|
20
28
|
private admission;
|
|
@@ -46,6 +54,15 @@ export declare class SessionController {
|
|
|
46
54
|
* @returns Retained question and approval frames for that session.
|
|
47
55
|
*/
|
|
48
56
|
pendingFor(state: State): ObjectValue[];
|
|
57
|
+
/** Unanswered interactions by session, so a list can show who is waiting without opening them.
|
|
58
|
+
*
|
|
59
|
+
* The host delivers approval and question waterfalls for every session on one stream, and this
|
|
60
|
+
* client already retains them to answer later, so the counts are a fact of this generation rather
|
|
61
|
+
* than a new subscription. They live only as long as the connection: a reconnect clears the map
|
|
62
|
+
* until the host replays the pending waterfalls.
|
|
63
|
+
* @returns One count per session holding at least one unanswered interaction.
|
|
64
|
+
*/
|
|
65
|
+
pendingCounts(): ReadonlyMap<string, number>;
|
|
49
66
|
/** Retain a recognized host waterfall; unknown events stay with the connection to delegate.
|
|
50
67
|
* @param frame - One decoded waterfall frame.
|
|
51
68
|
* @returns Whether this domain retained the frame for an answer.
|
|
@@ -168,11 +185,150 @@ export declare class SessionController {
|
|
|
168
185
|
* @param allowed - Whether the request is approved once.
|
|
169
186
|
*/
|
|
170
187
|
approve(allowed: boolean): Promise<void>;
|
|
188
|
+
/** Dismiss the whole selected-session question set without answering it.
|
|
189
|
+
*
|
|
190
|
+
* The Web client's close button settles the same waterfall the same way — reject with
|
|
191
|
+
* `ASK_CANCELLED` — so the host records a user cancellation rather than an answer. A question
|
|
192
|
+
* batch is answered as one request, so dismissals also discard partial local answers.
|
|
193
|
+
*/
|
|
194
|
+
dismissQuestion(): Promise<void>;
|
|
171
195
|
/** Add a page before the retained window using its fixed opening cut.
|
|
196
|
+
*
|
|
197
|
+
* Reclamation is deliberately not pinned here. Every caller that needs the fetched page to
|
|
198
|
+
* survive is already covered by the view: scrolling back sets a scroll position, `/think` opens a
|
|
199
|
+
* panel, and a recall page folds its prompts into the index before this resolves. A pin set here
|
|
200
|
+
* had no clearing edge, so after one recall page the history budget silently stopped applying for
|
|
201
|
+
* the rest of the session while every following page kept adding records.
|
|
172
202
|
* @param signal - Cancels local paging without interrupting the remote agent.
|
|
173
203
|
* @param transcript - Transcript to extend; defaults to the live one.
|
|
174
204
|
*/
|
|
175
205
|
older(signal?: AbortSignal, transcript?: Transcript): Promise<void>;
|
|
206
|
+
/** Recall one step through the session's prompt index; navigation never touches the network.
|
|
207
|
+
* @param direction - Negative for older input, positive for newer input.
|
|
208
|
+
* @param current - Composer content before recall began, restored at the newest position.
|
|
209
|
+
* @returns The recalled prompt, or the unsent draft.
|
|
210
|
+
*/
|
|
211
|
+
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
|
+
/** Local answer state for the selected session's pending waterfalls. */
|
|
241
|
+
get interaction(): InteractionState;
|
|
242
|
+
/** Replace the partly collected answers, keyed by the waterfall event id.
|
|
243
|
+
* @param answers - Answers collected so far, by event id.
|
|
244
|
+
*/
|
|
245
|
+
setAnswers(answers: Record<string, ObjectValue[]>): void;
|
|
246
|
+
/** Replace the pending question's option keyboard state.
|
|
247
|
+
* @param option - Highlighted option, toggled labels and free-text mode; undefined clears it.
|
|
248
|
+
*/
|
|
249
|
+
setOption(option?: OptionState): void;
|
|
250
|
+
/** Replace the pending approval's selected row.
|
|
251
|
+
* @param approval - Selected approval row; undefined clears the highlight.
|
|
252
|
+
*/
|
|
253
|
+
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
|
+
/** Remember a locally submitted command, which never becomes a durable session record. */
|
|
287
|
+
recordRecall(value: string): void;
|
|
288
|
+
/** Leave recall navigation because the composer was edited or replaced. */
|
|
289
|
+
resetRecall(): void;
|
|
290
|
+
/** Whether recall is parked on the oldest prompt it retains in memory. */
|
|
291
|
+
get recallAtOldest(): boolean;
|
|
292
|
+
/** How many prompts the session retains for recall. */
|
|
293
|
+
get recallLength(): number;
|
|
294
|
+
/** Whether an older prompt is reachable at all: shed from the window, or still on the host. */
|
|
295
|
+
get recallHasOlder(): boolean;
|
|
296
|
+
/** Recover older prompts from the loaded window before spending a page request.
|
|
297
|
+
*
|
|
298
|
+
* The transcript window can still hold prompts the index's budgets evicted, so a backward step
|
|
299
|
+
* refills from memory first and only then asks the caller to page. That is what keeps recall
|
|
300
|
+
* complete across submissions, where the previous buffer lost them at the eviction boundary.
|
|
301
|
+
* @returns Whether any older prompt was recovered.
|
|
302
|
+
*/
|
|
303
|
+
refillRecall(): boolean;
|
|
304
|
+
/** Seed recall from a complete cached entry, so an open that follows a scan costs no request.
|
|
305
|
+
* @param sessionId - Session being opened.
|
|
306
|
+
* @returns Whether the cache covered this session.
|
|
307
|
+
*/
|
|
308
|
+
private adoptCachedPrompts;
|
|
309
|
+
/** Fold one history page the cost scan already read into the prompt cache.
|
|
310
|
+
*
|
|
311
|
+
* The scan reads every session's whole history on connect, so this is where two readers stop
|
|
312
|
+
* paying twice: it hands over pages it already has, and an open that follows reads the cache.
|
|
313
|
+
* @param sessionId - Session the page belongs to.
|
|
314
|
+
* @param records - Raw records of one scanned page.
|
|
315
|
+
*/
|
|
316
|
+
rememberScanPage(sessionId: string, records: readonly Json[]): void;
|
|
317
|
+
/** Report that the scanned session's history was read to its beginning.
|
|
318
|
+
* @param sessionId - Session the scan finished.
|
|
319
|
+
*/
|
|
320
|
+
rememberScanDone(sessionId: string): void;
|
|
321
|
+
/** Fold every prompt the host still holds into the recall index, in the background.
|
|
322
|
+
*
|
|
323
|
+
* Session start delivers only the newest window, so without this the arrows could reach older
|
|
324
|
+
* prompts but not show them without paging first. Each page is parsed into a temporary transcript
|
|
325
|
+
* and only its prompts are kept, so the live record, its memory window and the row cache never
|
|
326
|
+
* grow. The walk is bounded and the next selection cancels it; anything past the bound is still
|
|
327
|
+
* reachable through the lazy backward step.
|
|
328
|
+
* @param sessionId - Session being opened.
|
|
329
|
+
* @param selection - Selector generation that must still be current.
|
|
330
|
+
*/
|
|
331
|
+
private backfillPrompts;
|
|
176
332
|
/** Search one page at a time, preserving only the first 200 matches and releasing temporary content.
|
|
177
333
|
* @param query - Literal, case-insensitive text including folded reasoning.
|
|
178
334
|
* @param signal - Cancels HTTP and processing without cancelling the agent.
|