@orkestrel/terminal 0.0.13 → 0.0.14

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.
@@ -20,11 +20,11 @@ import { StylerInterface } from '@orkestrel/console';
20
20
  import { TableInterface } from '@orkestrel/database';
21
21
  import { TextField } from '@orkestrel/form';
22
22
 
23
- /** The `Accept` header value that opens the broker's SSE stream. */
23
+ /** Names the `Accept` header value that opens the broker's SSE stream. */
24
24
  export declare const ACCEPT_EVENT_STREAM = "text/event-stream";
25
25
 
26
26
  /**
27
- * Why {@link PromptInterface.answer} refused. Names its axis with `reason`.
27
+ * Explains why {@link PromptInterface.answer} refused. Names its axis with `reason`.
28
28
  *
29
29
  * @remarks
30
30
  * - `unknown` — no form is parked under that id, or the one that was has already settled.
@@ -41,34 +41,47 @@ export declare type AnswerError = {
41
41
  readonly errors: readonly FieldError[];
42
42
  };
43
43
 
44
- /** Backspace (BS, U+0008) — Ctrl+H / some terminals' Backspace. */
44
+ /** Names the backspace byte (BS, U+0008) — Ctrl+H / some terminals' Backspace. */
45
45
  export declare const BACKSPACE: string;
46
46
 
47
47
  /**
48
- * Advance a checkbox prompt by one {@link KeyEvent} — the pure
49
- * `(state, key) → PromptStep<readonly string[]>` reducer. `up` / `down` (and `k` / `j`) move the
50
- * focus (wrapping); `space` toggles the focused index in the checked set; return submits the
51
- * checked values in choice order; ctrl-c cancels. The form applies selection-count rules.
52
- */
53
- export declare function checkboxReduce(state: ReturnType<typeof createCheckboxState>, key: KeyEvent): PromptStep<readonly string[], ReturnType<typeof createCheckboxState>>;
54
-
55
- /** Render a checkbox-field key state as a multi-line styled view. */
56
- export declare function checkboxView(state: ReturnType<typeof createCheckboxState>): string;
57
-
58
- /**
59
- * Advance a confirm prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<boolean>`
60
- * reducer. `y` / `Y` submits `true`, `n` / `N` submits `false`, return on an empty line submits
61
- * the `default`, ctrl-c cancels; any other key is ignored (stays active).
62
- */
63
- export declare function confirmReduce(state: ReturnType<typeof createConfirmState>, key: KeyEvent): PromptStep<boolean, ReturnType<typeof createConfirmState>>;
48
+ * Represents the immutable state a checkbox field's reducer carries — the select state plus the ticked set.
49
+ *
50
+ * @remarks
51
+ * - `message` — the sanitized label the header renders.
52
+ * - `choices` — the choices the list offers, in declared order.
53
+ * - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
54
+ * - `focused` — the index the cursor sits on.
55
+ * - `checked` — the ticked indices, in the order they were ticked; the reducer sorts them into
56
+ * choice order when it submits.
57
+ */
58
+ export declare interface CheckboxState {
59
+ readonly message: string;
60
+ readonly choices: readonly FieldChoice[];
61
+ readonly styler: StylerInterface;
62
+ readonly theme: PromptTheme;
63
+ readonly focused: number;
64
+ readonly checked: readonly number[];
65
+ }
64
66
 
65
67
  /**
66
- * Render a confirm-field key state as a styled view. The selected role paints the default letter.
67
- */
68
- export declare function confirmView(state: ReturnType<typeof createConfirmState>): string;
68
+ * Represents the immutable state a confirm field's reducer carries. It holds no typed value, because the
69
+ * answer is the key itself.
70
+ *
71
+ * @remarks
72
+ * - `message` — the sanitized label the header renders.
73
+ * - `default` — the answer a bare return submits, and the letter the view capitalizes.
74
+ * - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
75
+ */
76
+ export declare interface ConfirmState {
77
+ readonly message: string;
78
+ readonly default: boolean;
79
+ readonly styler: StylerInterface;
80
+ readonly theme: PromptTheme;
81
+ }
69
82
 
70
83
  /**
71
- * The control BYTE (or CRLF pair) → key descriptor table {@link import('./helpers.js').parseKey}
84
+ * Holds the control BYTE (or CRLF pair) → key descriptor table {@link import('./helpers.js').parseKey}
72
85
  * consults for the one-byte keys and the two-byte CRLF Enter chunk. Each entry carries the
73
86
  * canonical `name` and whether it is a `ctrl` combination. The source of truth for that decode;
74
87
  * frozen.
@@ -76,7 +89,7 @@ export declare function confirmView(state: ReturnType<typeof createConfirmState>
76
89
  * @remarks
77
90
  * `return` / `newline` / `return + newline` all map to `return` (one canonical Enter name) — a
78
91
  * terminal or a paste can deliver Enter as `\r`, `\n`, or the `\r\n` pair in one chunk;
79
- * `delete` / `backspace` both map to `backspace` (the two Backspace bytes); the Ctrl combos
92
+ * `delete` / `backspace` both map to `backspace` (the Backspace bytes); the Ctrl combos
80
93
  * (`c` / `d` / `u` / `a` / `e`) carry `ctrl: true` so a reducer can match
81
94
  * `key.ctrl && key.name === 'c'`. `escape` / `tab` / `space` are plain named keys.
82
95
  */
@@ -86,39 +99,27 @@ export declare const CONTROL_NAMES: Readonly<Record<string, {
86
99
  }>>;
87
100
 
88
101
  /**
89
- * Build the initial checkbox-field key state.
102
+ * Builds the initial checkbox-field key state.
90
103
  *
91
104
  * @param field - The checkbox field to render
92
105
  * @param styler - The styler used to render the view
93
106
  * @param theme - The optional terminal theme
94
107
  * @returns The initial immutable key state
95
108
  */
96
- export declare function createCheckboxState(field: CheckboxField, styler?: StylerInterface, theme?: PromptThemeOptions): {
97
- message: string;
98
- choices: FieldChoice[];
99
- styler: StylerInterface;
100
- theme: PromptTheme;
101
- focused: number;
102
- checked: readonly number[];
103
- };
109
+ export declare function createCheckboxState(field: CheckboxField, styler?: StylerInterface, theme?: PromptThemeOptions): CheckboxState;
104
110
 
105
111
  /**
106
- * Build the initial confirm-field key state.
112
+ * Builds the initial confirm-field key state.
107
113
  *
108
114
  * @param field - The confirm field to render
109
115
  * @param styler - The styler used to render the view
110
116
  * @param theme - The optional terminal theme
111
117
  * @returns The initial immutable key state
112
118
  */
113
- export declare function createConfirmState(field: ConfirmField, styler?: StylerInterface, theme?: PromptThemeOptions): {
114
- message: string;
115
- default: boolean;
116
- styler: StylerInterface;
117
- theme: PromptTheme;
118
- };
119
+ export declare function createConfirmState(field: ConfirmField, styler?: StylerInterface, theme?: PromptThemeOptions): ConfirmState;
119
120
 
120
121
  /**
121
- * Create a {@link TerminalStoreInterface} backed by one table of the `databases` layer — the
122
+ * Creates a {@link TerminalStoreInterface} backed by one table of the `databases` layer — the
122
123
  * driver-pluggable twin of {@link createMemoryTerminalStore}, storing each endpoint's config
123
124
  * snapshot as one opaque JSON column.
124
125
  *
@@ -127,7 +128,7 @@ export declare function createConfirmState(field: ConfirmField, styler?: StylerI
127
128
  *
128
129
  * @example
129
130
  * ```ts
130
- * import { createDatabaseTerminalStore } from '@src/core'
131
+ * import { createDatabaseTerminalStore } from '@orkestrel/terminal'
131
132
  *
132
133
  * const store = createDatabaseTerminalStore() // in-memory by default
133
134
  * ```
@@ -135,47 +136,34 @@ export declare function createConfirmState(field: ConfirmField, styler?: StylerI
135
136
  export declare function createDatabaseTerminalStore(driver?: DriverInterface): TerminalStoreInterface;
136
137
 
137
138
  /**
138
- * Build the initial editor-field key state.
139
+ * Builds the initial editor-field key state.
139
140
  *
140
141
  * @param field - The editor field to render
141
142
  * @param styler - The styler used to render the view
142
143
  * @param theme - The optional terminal theme
143
144
  * @returns The initial immutable key state
144
145
  */
145
- export declare function createEditorState(field: EditorField, styler?: StylerInterface, theme?: PromptThemeOptions): {
146
- message: string;
147
- default: string;
148
- styler: StylerInterface;
149
- theme: PromptTheme;
150
- lines: readonly string[];
151
- current: string;
152
- };
146
+ export declare function createEditorState(field: EditorField, styler?: StylerInterface, theme?: PromptThemeOptions): EditorState;
153
147
 
154
148
  /**
155
- * Build the initial text-field key state.
149
+ * Builds the initial text-field key state.
156
150
  *
157
151
  * @param field - The text field to render
158
152
  * @param styler - The styler used to render the view
159
153
  * @param theme - The optional terminal theme
160
154
  * @returns The initial immutable key state
161
155
  */
162
- export declare function createInputState(field: TextField, styler?: StylerInterface, theme?: PromptThemeOptions): {
163
- message: string;
164
- default: string;
165
- styler: StylerInterface;
166
- theme: PromptTheme;
167
- value: string;
168
- };
156
+ export declare function createInputState(field: TextField, styler?: StylerInterface, theme?: PromptThemeOptions): InputState;
169
157
 
170
158
  /**
171
- * Create the in-memory {@link TerminalStoreInterface} — a process-lifetime `Map` of endpoint
159
+ * Creates the in-memory {@link TerminalStoreInterface} — a process-lifetime `Map` of endpoint
172
160
  * config snapshots, the default store backing a {@link TerminalManagerInterface}'s `open` / `save`.
173
161
  *
174
162
  * @returns A {@link TerminalStoreInterface}
175
163
  *
176
164
  * @example
177
165
  * ```ts
178
- * import { createMemoryTerminalStore } from '@src/core'
166
+ * import { createMemoryTerminalStore } from '@orkestrel/terminal'
179
167
  *
180
168
  * const store = createMemoryTerminalStore()
181
169
  * ```
@@ -183,23 +171,17 @@ export declare function createInputState(field: TextField, styler?: StylerInterf
183
171
  export declare function createMemoryTerminalStore(): TerminalStoreInterface;
184
172
 
185
173
  /**
186
- * Build the initial password-field key state.
174
+ * Builds the initial password-field key state.
187
175
  *
188
176
  * @param field - The password field to render
189
177
  * @param styler - The styler used to render the view
190
178
  * @param theme - The optional terminal theme
191
179
  * @returns The initial immutable key state
192
180
  */
193
- export declare function createPasswordState(field: PasswordField, styler?: StylerInterface, theme?: PromptThemeOptions): {
194
- message: string;
195
- mask: string;
196
- styler: StylerInterface;
197
- theme: PromptTheme;
198
- value: string;
199
- };
181
+ export declare function createPasswordState(field: PasswordField, styler?: StylerInterface, theme?: PromptThemeOptions): PasswordState;
200
182
 
201
183
  /**
202
- * Create the headless {@link PromptInterface} broker. It parks live forms and applies remote
184
+ * Creates the headless {@link PromptInterface} broker. It parks live forms and applies remote
203
185
  * answers to the authoritative instances.
204
186
  *
205
187
  * @param options - See {@link PromptOptions}
@@ -212,7 +194,7 @@ export declare function createPasswordState(field: PasswordField, styler?: Style
212
194
  *
213
195
  * @example
214
196
  * ```ts
215
- * import { createPrompt } from '@src/core'
197
+ * import { createPrompt } from '@orkestrel/terminal'
216
198
  * import { createForm } from '@orkestrel/form'
217
199
  *
218
200
  * const prompt = createPrompt()
@@ -224,7 +206,7 @@ export declare function createPasswordState(field: PasswordField, styler?: Style
224
206
  export declare function createPrompt(options?: PromptOptions): PromptInterface;
225
207
 
226
208
  /**
227
- * Create the SSE prompt {@link PromptClientInterface} BRIDGE — it connects to a remote broker's SSE
209
+ * Creates the SSE prompt {@link PromptClientInterface} BRIDGE — it connects to a remote broker's SSE
228
210
  * endpoint, dispatches each received form to a local {@link import('./types.js').TerminalInterface},
229
211
  * and POSTs the answer back. Universal — `fetch` / SSE are web-standard.
230
212
  *
@@ -236,11 +218,11 @@ export declare function createPrompt(options?: PromptOptions): PromptInterface;
236
218
  * ends; it reconnects with the `delay` backoff unless `reconnect` is `false` / the client was
237
219
  * `destroy`ed. Inject `options.fetch` (a scripted `fetch`) and `options.timer` to drive it
238
220
  * deterministically in tests — no real network.
239
- * - **§14 wire narrowing.** Every decoded prompt is guard-narrowed before dispatch (never an `as`).
221
+ * - **Wire narrowing.** Every decoded prompt is guard-narrowed before dispatch (never an `as`).
240
222
  *
241
223
  * @example
242
224
  * ```ts
243
- * import { createPromptClient } from '@src/core'
225
+ * import { createPromptClient } from '@orkestrel/terminal'
244
226
  *
245
227
  * const client = createPromptClient({ url: 'http://host/prompts', terminal })
246
228
  * await client.connect()
@@ -249,7 +231,7 @@ export declare function createPrompt(options?: PromptOptions): PromptInterface;
249
231
  export declare function createPromptClient(options: PromptClientOptions): PromptClientInterface;
250
232
 
251
233
  /**
252
- * Build a complete {@link PromptTheme} by merging a partial one over
234
+ * Builds a complete {@link PromptTheme} by merging a partial one over
253
235
  * {@link DEFAULT_PROMPT_THEME}, leaf by leaf — each supplied icon replaces that glyph, each
254
236
  * supplied role replaces that {@link Style}, and everything else keeps its default. Each supplied
255
237
  * style is snapshotted through the console module's own
@@ -271,23 +253,17 @@ export declare function createPromptClient(options: PromptClientOptions): Prompt
271
253
  export declare function createPromptTheme(options?: PromptThemeOptions): PromptTheme;
272
254
 
273
255
  /**
274
- * Build the initial select-field key state.
256
+ * Builds the initial select-field key state.
275
257
  *
276
258
  * @param field - The select field to render
277
259
  * @param styler - The styler used to render the view
278
260
  * @param theme - The optional terminal theme
279
261
  * @returns The initial immutable key state
280
262
  */
281
- export declare function createSelectState(field: SelectField, styler?: StylerInterface, theme?: PromptThemeOptions): {
282
- message: string;
283
- choices: FieldChoice[];
284
- styler: StylerInterface;
285
- theme: PromptTheme;
286
- focused: number;
287
- };
263
+ export declare function createSelectState(field: SelectField, styler?: StylerInterface, theme?: PromptThemeOptions): SelectState;
288
264
 
289
265
  /**
290
- * Create the multi-endpoint {@link TerminalManager} — a named registry of
266
+ * Creates the multi-endpoint {@link TerminalManager} — a named registry of
291
267
  * {@link PromptInterface} brokers so several parties can `ask` prompts of each other by name,
292
268
  * with a transitive DEADLOCK check across every in-flight ask.
293
269
  *
@@ -296,7 +272,7 @@ export declare function createSelectState(field: SelectField, styler?: StylerInt
296
272
  *
297
273
  * @example
298
274
  * ```ts
299
- * import { createTerminalManager } from '@src/core'
275
+ * import { createTerminalManager } from '@orkestrel/terminal'
300
276
  *
301
277
  * const manager = createTerminalManager()
302
278
  * manager.add('agent')
@@ -304,23 +280,23 @@ export declare function createSelectState(field: SelectField, styler?: StylerInt
304
280
  */
305
281
  export declare function createTerminalManager(options?: TerminalManagerOptions): TerminalManagerInterface;
306
282
 
307
- /** Ctrl+A (SOH, U+0001) — move to start of line. */
283
+ /** Names the Ctrl+A byte (SOH, U+0001) — move to start of line. */
308
284
  export declare const CTRL_A: string;
309
285
 
310
- /** Ctrl+C (ETX, U+0003) — interrupt / cancel. */
286
+ /** Names the Ctrl+C byte (ETX, U+0003) — interrupt / cancel. */
311
287
  export declare const CTRL_C: string;
312
288
 
313
- /** Ctrl+D (EOT, U+0004) — end-of-transmission / finish (the editor's commit key). */
289
+ /** Names the Ctrl+D byte (EOT, U+0004) — end-of-transmission / finish (the editor's commit key). */
314
290
  export declare const CTRL_D: string;
315
291
 
316
- /** Ctrl+E (ENQ, U+0005) — move to end of line. */
292
+ /** Names the Ctrl+E byte (ENQ, U+0005) — move to end of line. */
317
293
  export declare const CTRL_E: string;
318
294
 
319
- /** Ctrl+U (NAK, U+0015) — clear the current line. */
295
+ /** Names the Ctrl+U byte (NAK, U+0015) — clear the current line. */
320
296
  export declare const CTRL_U: string;
321
297
 
322
298
  /**
323
- * A {@link TerminalStoreInterface} backed by one table of the `databases` layer — an endpoint's
299
+ * Implements a {@link TerminalStoreInterface} backed by one table of the `databases` layer — an endpoint's
324
300
  * durable CONFIG state IS a row, so persistence reduces to keyed point-access (`get` / `set` /
325
301
  * `delete`) over a {@link TableInterface}, the driver-pluggable twin of the plain-`Map`
326
302
  * {@link import('./MemoryTerminalStore.js').MemoryTerminalStore}.
@@ -330,7 +306,7 @@ export declare const CTRL_U: string;
330
306
  * JSON, SQLite, IndexedDB) is chosen by whoever builds it (the factories), so a JSON / SQLite /
331
307
  * IndexedDB backend swaps in WITHOUT touching the manager — the same seam as
332
308
  * {@link import('./MemoryTerminalStore.js').MemoryTerminalStore}. The driver defaults to memory
333
- * ({@link import('./factories.js').createDatabaseTerminalStore} passes `createMemoryDriver()`), so
309
+ * ({@link import('../factories.js').createDatabaseTerminalStore} passes `createMemoryDriver()`), so
334
310
  * it ALSO works in memory out of the box; you opt into the durable plumbing by passing a JSON /
335
311
  * SQLite / IndexedDB driver.
336
312
  *
@@ -342,18 +318,19 @@ export declare const CTRL_U: string;
342
318
  * - **`set(snapshot)` upserts under the snapshot's OWN `id`** (no separate id param) — it writes
343
319
  * the row `{ id: snapshot.id, snapshot }`.
344
320
  * - **`get(id)` resolves the stored snapshot for an id**, narrowing the opaque JSON column back to
345
- * a {@link TerminalSnapshot} ({@link import('./validators.js').isTerminalSnapshot} — the AGENTS §14
346
- * boundary narrow for an untrusted storage read), or `undefined` if none is stored.
321
+ * a {@link TerminalSnapshot} ({@link import('../validators.js').isTerminalSnapshot} — the total
322
+ * guard that narrows an untrusted storage read), or `undefined` if none is stored.
347
323
  * - **`delete(id)` drops a snapshot by id**; an absent id is a no-op (no throw).
348
324
  *
349
325
  * There is NO idle-TTL / eviction — a persisted config lives until an explicit `delete`. The public
350
- * surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method bijection with
351
- * {@link TerminalStoreInterface}). Hydration stays a caller concern: `open` always restores an EMPTY
326
+ * surface is EXACTLY `get` / `set` / `delete` — no extra members, so the class and
327
+ * {@link TerminalStoreInterface} carry the same methods. Hydration stays a caller concern: `open` always restores an EMPTY
352
328
  * broker — parked Promises are process-bound and never resurrected.
353
329
  *
354
330
  * @example
355
331
  * ```ts
356
- * import { createDatabaseTerminalStore, createMemoryDriver } from '@src/core'
332
+ * import { createDatabaseTerminalStore } from '@orkestrel/terminal'
333
+ * import { createMemoryDriver } from '@orkestrel/database'
357
334
  *
358
335
  * const store = createDatabaseTerminalStore(createMemoryDriver()) // a durable driver swaps in here
359
336
  * await store.set({ id: 'shell', timeout: 5000 }) // persist the config (one JSON column)
@@ -364,25 +341,42 @@ export declare const CTRL_U: string;
364
341
  export declare class DatabaseTerminalStore implements TerminalStoreInterface {
365
342
  #private;
366
343
  /**
367
- * Wrap a table as a terminal store.
344
+ * Wraps a table as a terminal store.
368
345
  *
369
346
  * @param table - The {@link TableInterface} holding the snapshots — its row is the
370
347
  * {@link TerminalSnapshotRow} `{ id; snapshot }` shape (the snapshot one opaque JSON column)
371
348
  */
372
349
  constructor(table: TableInterface<TerminalSnapshotRow>);
373
- /** Resolve the persisted snapshot for `id`, narrowing the opaque JSON column back to a `TerminalSnapshot`. */
350
+ /**
351
+ * Resolves the persisted snapshot for `id`, narrowing the opaque JSON column back to a
352
+ * `TerminalSnapshot`.
353
+ *
354
+ * @param id - The endpoint name the row is keyed by
355
+ * @returns The stored snapshot, or `undefined` when none is held or the column is off-shape
356
+ */
374
357
  get(id: string): Promise<TerminalSnapshot | undefined>;
375
- /** Insert or replace under the snapshot's OWN `id` (no separate id param) — the row is `{ id, snapshot }`. */
358
+ /**
359
+ * Inserts or replaces under the snapshot's OWN `id` (no separate id param) — the row is
360
+ * `{ id, snapshot }`.
361
+ *
362
+ * @param snapshot - The config snapshot to persist, carrying its own `id`
363
+ * @returns A promise that settles once the row is written
364
+ */
376
365
  set(snapshot: TerminalSnapshot): Promise<void>;
377
- /** Drop a snapshot by id; an absent id is a no-op (no throw). */
366
+ /**
367
+ * Drops a snapshot by id; an absent id is a no-op (no throw).
368
+ *
369
+ * @param id - The endpoint name to drop
370
+ * @returns A promise that settles once the row is gone
371
+ */
378
372
  delete(id: string): Promise<void>;
379
373
  }
380
374
 
381
- /** The default mask glyph {@link import('./helpers.js').createPasswordState} uses — `*`. */
375
+ /** Names the default mask glyph {@link import('./helpers.js').createPasswordState} uses — `*`. */
382
376
  export declare const DEFAULT_MASK = "*";
383
377
 
384
378
  /**
385
- * The {@link import('./types.js').PromptTheme} every prompt renders with unless its options supply
379
+ * Holds the {@link import('./types.js').PromptTheme} every prompt renders with unless its options supply
386
380
  * another — the glyph set assembled from {@link PROMPT_ICONS} plus the console
387
381
  * {@link import('@orkestrel/console').STATUS_ICONS} `success` / `error` marks, and the console
388
382
  * {@link import('@orkestrel/console').Style} each role is painted with. Deeply frozen through the
@@ -398,60 +392,69 @@ export declare const DEFAULT_MASK = "*";
398
392
  */
399
393
  export declare const DEFAULT_PROMPT_THEME: PromptTheme;
400
394
 
401
- /** How long (ms) the {@link import('./types.js').PromptInterface} broker parks an unanswered prompt before it expires — 5 minutes. */
395
+ /** Holds how long (ms) the {@link import('./types.js').PromptInterface} broker parks an unanswered prompt before it expires — 5 minutes. */
402
396
  export declare const DEFAULT_PROMPT_TIMEOUT_MS = 300000;
403
397
 
404
- /** How long (ms) the {@link import('./types.js').PromptClientInterface} waits before each reconnect attempt — 2 seconds. */
398
+ /** Holds how long (ms) the {@link import('./types.js').PromptClientInterface} waits before each reconnect attempt — 2 seconds. */
405
399
  export declare const DEFAULT_RECONNECT_DELAY_MS = 2000;
406
400
 
407
401
  /**
408
- * The default {@link import('./types.js').TimerHandler} — a thin host `setTimeout` / `clearTimeout`
409
- * wrapper that arms `callback` after `ms` and returns a {@link TimerCancel}. The deadline seam
402
+ * Implements the default {@link import('./types.js').TimerHandler} — a thin host `setTimeout` / `clearTimeout`
403
+ * wrapper that arms `callback` after `ms` and returns a {@link TimerCancelFunction}. The deadline seam
410
404
  * behind both the {@link import('./Prompt.js').Prompt} broker (its expiry) and the
411
405
  * {@link import('./PromptClient.js').PromptClient} (its reconnect backoff); a test injects a
412
406
  * deterministic timer instead, so neither entity touches real time.
407
+ *
408
+ * @param callback - The deadline callback to arm
409
+ * @param ms - How long to wait before firing it, in milliseconds
410
+ * @returns The {@link TimerCancelFunction} that clears the armed deadline
413
411
  */
414
- export declare function defaultTimer(callback: () => void, ms: number): TimerCancel;
412
+ export declare function defaultTimer(callback: () => void, ms: number): TimerCancelFunction;
415
413
 
416
- /** Delete (DEL, U+007F) — the usual Backspace byte on a Unix TTY. */
414
+ /** Names the delete byte (DEL, U+007F) — the usual Backspace byte on a Unix TTY. */
417
415
  export declare const DELETE: string;
418
416
 
419
417
  /**
420
- * Apply a single line-editing {@link KeyEvent} to a text buffer — the editing shared by input /
418
+ * Applies a single line-editing {@link KeyEvent} to a text buffer — the editing shared by input /
421
419
  * password / editor. A printable key appends its character; `backspace` drops the last character;
422
- * `space` appends a space; ctrl-u clears the line. Returns the new buffer, or `undefined` when the
423
- * key does not edit the line (so the caller can leave the state untouched).
420
+ * `space` appends a space; ctrl-u clears the line.
421
+ *
422
+ * @param value - The buffer the field holds so far
423
+ * @param key - The decoded keypress to apply
424
+ * @returns The new buffer, or `undefined` when the key does not edit the line, so the caller can
425
+ * leave the state untouched
424
426
  */
425
427
  export declare function editLine(value: string, key: KeyEvent): string | undefined;
426
428
 
427
429
  /**
428
- * Advance an editor prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
429
- * reducer. Printable characters extend the current line; backspace shrinks it; return commits the
430
- * current line and starts a fresh one; ctrl-d FINISHES (joining all lines, falling back to the
431
- * default when empty); ctrl-c cancels. The form validates the candidate after the driver fills it.
432
- */
433
- export declare function editorReduce(state: ReturnType<typeof createEditorState>, key: KeyEvent): PromptStep<string, ReturnType<typeof createEditorState>>;
434
-
435
- /**
436
- * Render an editor-field key state as a multi-line styled view with its finish hint.
437
- */
438
- export declare function editorView(state: ReturnType<typeof createEditorState>): string;
439
-
440
- /** The styled error line (`✖ message`) a form driver appends for a field failure. */
441
- export declare function errorLine(styler: StylerInterface, theme: PromptTheme, message: string): string;
442
-
443
- /** Escape (ESC, U+001B) — the lone byte, and the lead byte of every CSI / SS3 sequence. */
444
- export declare const ESCAPE: string;
430
+ * Represents the immutable state an editor field's reducer carries — the committed lines and the line still
431
+ * being typed, kept apart so a return commits one without ending the field.
432
+ *
433
+ * @remarks
434
+ * - `message` — the sanitized label the header renders.
435
+ * - `default` — the text an empty finish falls back to.
436
+ * - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
437
+ * - `lines` — the lines already committed with a return.
438
+ * - `current` — the line in progress.
439
+ */
440
+ export declare interface EditorState {
441
+ readonly message: string;
442
+ readonly default: string;
443
+ readonly styler: StylerInterface;
444
+ readonly theme: PromptTheme;
445
+ readonly lines: readonly string[];
446
+ readonly current: string;
447
+ }
445
448
 
446
449
  /**
447
- * A minimal `fetch` — the subset of the global `fetch` a {@link PromptClientInterface} uses: open
450
+ * Represents a minimal `fetch` — the subset of the global `fetch` a {@link PromptClientInterface} uses: open
448
451
  * the SSE stream, POST an answer. Injected so a test drives the client with a scripted `Response`
449
452
  * instead of a real network.
450
453
  */
451
454
  export declare type FetchHandler = (input: string, init?: FetchInit) => Promise<Response>;
452
455
 
453
456
  /**
454
- * The request init a {@link PromptClientInterface} passes to its {@link FetchHandler} — the
457
+ * Represents the request init a {@link PromptClientInterface} passes to its {@link FetchHandler} — the
455
458
  * `RequestInit` fields it actually sets.
456
459
  */
457
460
  export declare interface FetchInit {
@@ -461,43 +464,52 @@ export declare interface FetchInit {
461
464
  readonly signal?: AbortSignal;
462
465
  }
463
466
 
464
- /** The default {@link import('./types.js').FetchHandler} — the global `fetch`, adapted to the minimal injected shape the {@link import('./PromptClient.js').PromptClient} uses. */
467
+ /**
468
+ * Implements the default {@link import('./types.js').FetchHandler} — the global `fetch`, adapted to
469
+ * the minimal injected shape the {@link import('./PromptClient.js').PromptClient} uses.
470
+ *
471
+ * @param input - The request URL
472
+ * @param init - The request init the client sets — method, headers, body, and abort signal
473
+ * @returns The host `fetch` promise for that request
474
+ */
465
475
  export declare function globalFetch(input: string, init?: FetchInit): Promise<Response>;
466
476
 
467
- /** The auth-token request header the {@link import('./types.js').PromptClientInterface} sends. */
477
+ /** Names the auth-token request header the {@link import('./types.js').PromptClientInterface} sends. */
468
478
  export declare const HEADER_TOKEN = "x-orkestrel-token";
469
479
 
470
480
  /**
471
- * Render a prompt header followed by a key hint painted with the `hint` role, or the header alone
472
- * when no hint is supplied.
481
+ * Represents the immutable state a text field's reducer carries — built by
482
+ * {@link import('./helpers.js').createInputState}, rendered by
483
+ * {@link import('./helpers.js').renderInputView}, and advanced by
484
+ * {@link import('./helpers.js').reduceInput}.
473
485
  *
474
- * @param styler - The console styler that renders each role
475
- * @param theme - The resolved prompt theme
476
- * @param message - The prompt's question text
477
- * @param hint - The optional key hint to append
478
- * @returns The rendered header with the optional hint
479
- */
480
- export declare function hintedHeader(styler: StylerInterface, theme: PromptTheme, message: string, hint?: string): string;
481
-
482
- /**
483
- * Advance an input prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
484
- * reducer. Printable characters extend the value; backspace shrinks it; ctrl-u clears it; ctrl-c
485
- * cancels; return produces the candidate value, with an empty line falling back to the default.
486
- */
487
- export declare function inputReduce(state: ReturnType<typeof createInputState>, key: KeyEvent): PromptStep<string, ReturnType<typeof createInputState>>;
488
-
489
- /** Render a text-field key state as a styled view. */
490
- export declare function inputView(state: ReturnType<typeof createInputState>): string;
486
+ * @remarks
487
+ * - `message` — the sanitized label the header renders.
488
+ * - `default` — the declared default a bare return submits.
489
+ * - `styler` — the console styler every role is painted through.
490
+ * - `theme` — the resolved {@link PromptTheme}.
491
+ * - `value` — the characters typed so far.
492
+ */
493
+ export declare interface InputState {
494
+ readonly message: string;
495
+ readonly default: string;
496
+ readonly styler: StylerInterface;
497
+ readonly theme: PromptTheme;
498
+ readonly value: string;
499
+ }
491
500
 
492
501
  /**
493
- * Whether a caught value is an `AbortError` — the {@link import('./PromptClient.js').PromptClient}
502
+ * Checks whether a caught value is an `AbortError` — the {@link import('./PromptClient.js').PromptClient}
494
503
  * distinguishes a deliberate `disconnect` / teardown (an aborted `fetch`) from a real fault, so it
495
504
  * exits its connect loop quietly instead of emitting `error` / reconnecting.
505
+ *
506
+ * @param error - The caught value to test
507
+ * @returns True if the value is a host `Error` or `DOMException` named `AbortError`; false otherwise
496
508
  */
497
509
  export declare function isAbortError(error: unknown): boolean;
498
510
 
499
511
  /**
500
- * Whether `url` is an INSECURE remote endpoint — a plain `http://` URL whose host is NOT a
512
+ * Checks whether `url` is an INSECURE remote endpoint — a plain `http://` URL whose host is NOT a
501
513
  * loopback address. Pure string parsing (no `URL` global), so it stays total on malformed input.
502
514
  *
503
515
  * @remarks
@@ -506,7 +518,7 @@ export declare function isAbortError(error: unknown): boolean;
506
518
  * An `https://` URL (or any non-`http://` scheme) is never flagged.
507
519
  *
508
520
  * @param url - The candidate endpoint URL
509
- * @returns `true` when `url` is a non-loopback `http://` endpoint
521
+ * @returns True if `url` is a non-loopback `http://` endpoint; false otherwise
510
522
  *
511
523
  * @example
512
524
  * ```ts
@@ -518,28 +530,39 @@ export declare function isAbortError(error: unknown): boolean;
518
530
  export declare function isInsecureRemote(url: string): boolean;
519
531
 
520
532
  /**
521
- * Narrow an unknown wire value to a {@link PendingForm} envelope.
533
+ * Narrows an unknown wire value to a {@link PendingForm} envelope.
522
534
  *
523
535
  * @remarks
524
536
  * This guard checks the transport record and proves only that `schema` is a record. The Form
525
537
  * package's `parseForm` owns the schema payload and its semantic audit.
526
538
  *
527
539
  * @param value - The decoded wire value to inspect
528
- * @returns Whether the value is a complete pending-form envelope
540
+ * @returns True if the value is a complete pending-form envelope; false otherwise
529
541
  */
530
542
  export declare function isPendingForm(value: unknown): value is PendingForm;
531
543
 
532
- /** Narrow an unknown value to a {@link PendingFormStatus}. */
544
+ /**
545
+ * Narrows an unknown value to a {@link PendingFormStatus}.
546
+ *
547
+ * @param value - The candidate ticket status
548
+ * @returns True if the value is one of the declared ticket statuses; false otherwise
549
+ */
533
550
  export declare const isPendingFormStatus: Guard<PendingFormStatus>;
534
551
 
535
- /** Whether a single character is a printable (non-control) character — used by {@link parseKey}'s char fallback. */
552
+ /**
553
+ * Checks whether a single character is a printable (non-control) character — used by
554
+ * {@link parseKey}'s char fallback.
555
+ *
556
+ * @param character - The single character to test
557
+ * @returns True if the character is at or above space and is not DEL; false otherwise
558
+ */
536
559
  export declare function isPrintable(character: string): boolean;
537
560
 
538
561
  /**
539
- * Narrow an unknown caught value to a {@link TerminalError}.
562
+ * Narrows an unknown caught value to a {@link TerminalError}.
540
563
  *
541
564
  * @param value - The value to test (typically a `catch` binding or a rejected prompt call)
542
- * @returns `true` when `value` is a {@link TerminalError}
565
+ * @returns True if `value` is a {@link TerminalError}; false otherwise
543
566
  *
544
567
  * @example
545
568
  * ```ts
@@ -554,30 +577,33 @@ export declare function isPrintable(character: string): boolean;
554
577
  */
555
578
  export declare function isTerminalError(value: unknown): value is TerminalError;
556
579
 
557
- /** Narrow an unknown value to a {@link TerminalSnapshot}. */
580
+ /**
581
+ * Narrows an unknown value to a {@link TerminalSnapshot} — the read boundary a store applies to an
582
+ * untrusted persisted row.
583
+ *
584
+ * @param value - The candidate snapshot read back from storage
585
+ * @returns True if the value carries a non-empty `id` and an optional numeric `timeout`; false otherwise
586
+ */
558
587
  export declare const isTerminalSnapshot: Guard<TerminalSnapshot>;
559
588
 
560
589
  /**
561
- * Narrow an unknown value to a transport-neutral {@link WireEvent}.
590
+ * Narrows an unknown value to a transport-neutral {@link WireEvent}.
562
591
  *
563
592
  * @param value - The candidate wire event
564
- * @returns Whether the value carries an event name, serialized data, and an optional id
593
+ * @returns True if the value carries an event name, serialized data, and an optional id; false otherwise
565
594
  */
566
595
  export declare const isWireEvent: Guard<WireEvent>;
567
596
 
568
597
  /**
569
- * The Control Sequence Introducer lead (`ESC[`) for the navigation keys — the prefix of the
570
- * arrow / home / end / delete sequences {@link SEQUENCE_NAMES} is keyed by. Named `KEY_CSI`
571
- * (not `CSI`) so it never collides with the console module's SGR `CSI` (both barrel through
572
- * `@src/core`).
598
+ * Names the Single Shift Three lead (`ESCO`) — the alternate arrow-key prefix some terminals emit
599
+ * (`ESC O A`). Built from the console module's own {@link import('@orkestrel/console').ESC}; the
600
+ * navigation keys' CSI lead is that module's {@link import('@orkestrel/console').CSI}, which this
601
+ * package reuses rather than redeclaring.
573
602
  */
574
- export declare const KEY_CSI: string;
575
-
576
- /** The Single Shift Three lead (`ESCO`) — the alternate arrow-key prefix some terminals emit (`ESC O A`). */
577
603
  export declare const KEY_SS3: string;
578
604
 
579
605
  /**
580
- * One decoded keypress — the TTY-agnostic representation of a single key, the output of
606
+ * Represents one decoded keypress — the TTY-agnostic representation of a single key, the output of
581
607
  * {@link import('./helpers.js').parseKey}. A driver reads `name` and the modifier flags to decide
582
608
  * its transition; `sequence` is preserved so a printable character round-trips and an unknown
583
609
  * escape is never lost.
@@ -586,15 +612,15 @@ export declare const KEY_SS3: string;
586
612
  * - `name` — the canonical key name: a control or navigation key (`return`, `backspace`, `tab`,
587
613
  * `escape`, `up` / `down` / `left` / `right`, `space`, `home`, `end`, `delete`), a named ctrl
588
614
  * combo (`c` with `ctrl` true for ctrl-c, likewise `d` / `u` / `a` / `e`), or the printable
589
- * character itself (`'a'`, `'7'`, `'?'`). An unrecognized sequence yields `name: ''`; the decoder
590
- * is total and never throws.
615
+ * character itself (`'a'`, `'7'`, `'?'`). An unrecognized sequence carries NO `name` — absence,
616
+ * never an empty string — and the decoder stays total and never throws.
591
617
  * - `sequence` — the exact input bytes as a string (a `Uint8Array` is decoded UTF-8). The driver
592
618
  * writes this verbatim for a printable key.
593
619
  * - `ctrl` / `meta` / `shift` — the modifier flags. `ctrl` is true for a C0 control byte, `meta`
594
620
  * for an ESC-prefixed (Alt) sequence, `shift` for an uppercase-letter printable.
595
621
  */
596
622
  export declare interface KeyEvent {
597
- readonly name: string;
623
+ readonly name?: string;
598
624
  readonly sequence: string;
599
625
  readonly ctrl: boolean;
600
626
  readonly meta: boolean;
@@ -602,14 +628,14 @@ export declare interface KeyEvent {
602
628
  }
603
629
 
604
630
  /**
605
- * The in-memory {@link TerminalStoreInterface} — a process-lifetime `Map` of
631
+ * Implements the in-memory {@link TerminalStoreInterface} — a process-lifetime `Map` of
606
632
  * {@link TerminalSnapshot}s keyed by endpoint id, the DEFAULT store
607
- * {@link import('./factories.js').createMemoryTerminalStore} builds. The EXACT twin of
633
+ * {@link import('../factories.js').createMemoryTerminalStore} builds. The EXACT twin of
608
634
  * {@link import('./DatabaseTerminalStore.js').DatabaseTerminalStore}.
609
635
  *
610
636
  * @remarks
611
- * A plain `Map<string, TerminalSnapshot>` (AGENTS §21 — the snapshot is already pure, self-contained
612
- * CONFIG-only JSON, so no encoding is needed for the memory tier). There is NO idle-TTL and NO
637
+ * A plain `Map<string, TerminalSnapshot>` — the snapshot is already pure, self-contained CONFIG-only
638
+ * JSON, so the memory tier needs no encoding. There is NO idle-TTL and NO
613
639
  * eviction: a persisted config lives until an explicit `delete`. A durable backend (JSON / SQLite /
614
640
  * IndexedDB) swaps in through the SAME interface without touching the manager — its
615
641
  * driver-pluggable twin is {@link import('./DatabaseTerminalStore.js').DatabaseTerminalStore} (the
@@ -619,13 +645,13 @@ export declare interface KeyEvent {
619
645
  * - **`set` inserts / replaces under the snapshot's OWN `id`** (no separate id param).
620
646
  * - **`delete` drops a snapshot by id**; an absent id is a no-op (no throw).
621
647
  *
622
- * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
623
- * bijection with {@link TerminalStoreInterface}). Hydration is a caller concern: `open` always
648
+ * The public surface is EXACTLY `get` / `set` / `delete` — no extra members, so the class and
649
+ * {@link TerminalStoreInterface} carry the same methods. Hydration is a caller concern: `open` always
624
650
  * restores an EMPTY broker — parked Promises are process-bound and never resurrected.
625
651
  *
626
652
  * @example
627
653
  * ```ts
628
- * import { createMemoryTerminalStore } from '@src/core'
654
+ * import { createMemoryTerminalStore } from '@orkestrel/terminal'
629
655
  *
630
656
  * const store = createMemoryTerminalStore()
631
657
  * await store.set({ id: 'shell', timeout: 5000 }) // persist a config
@@ -635,16 +661,34 @@ export declare interface KeyEvent {
635
661
  */
636
662
  export declare class MemoryTerminalStore implements TerminalStoreInterface {
637
663
  #private;
664
+ /**
665
+ * Resolves the persisted snapshot for `id`.
666
+ *
667
+ * @param id - The endpoint name the snapshot is keyed by
668
+ * @returns The stored snapshot, or `undefined` when none is held
669
+ */
638
670
  get(id: string): Promise<TerminalSnapshot | undefined>;
671
+ /**
672
+ * Inserts or replaces under the snapshot's OWN `id` (no separate id param).
673
+ *
674
+ * @param snapshot - The config snapshot to persist, carrying its own `id`
675
+ * @returns A promise that settles once the snapshot is held
676
+ */
639
677
  set(snapshot: TerminalSnapshot): Promise<void>;
678
+ /**
679
+ * Drops a snapshot by id; an absent id is a no-op (no throw).
680
+ *
681
+ * @param id - The endpoint name to drop
682
+ * @returns A promise that settles once the snapshot is gone
683
+ */
640
684
  delete(id: string): Promise<void>;
641
685
  }
642
686
 
643
- /** Line feed (`\n`, U+000A) — Enter on some terminals / pasted input. */
687
+ /** Names the line feed byte (`\n`, U+000A) — Enter on some terminals / pasted input. */
644
688
  export declare const NEWLINE: string;
645
689
 
646
690
  /**
647
- * One parked form's runtime state inside the broker — the live form, the wire-safe record the
691
+ * Represents one parked form's runtime state inside the broker — the live form, the wire-safe record the
648
692
  * broker exposes, and the cancel for its expiry timer.
649
693
  *
650
694
  * @remarks
@@ -653,14 +697,14 @@ export declare const NEWLINE: string;
653
697
  * abandons it and settles the caller's promise through the form's own lifecycle. `pending` is the
654
698
  * wire record, whose `status` tracks the ticket.
655
699
  */
656
- export declare interface Parked {
700
+ export declare interface ParkedForm {
657
701
  readonly form: FormInterface;
658
702
  readonly pending: PendingForm;
659
- readonly cancel: TimerCancel;
703
+ readonly cancel: TimerCancelFunction;
660
704
  }
661
705
 
662
706
  /**
663
- * The parking envelope — everything the broker needs about a park that the form itself does not
707
+ * Represents the parking envelope — everything the broker needs about a park that the form itself does not
664
708
  * say.
665
709
  *
666
710
  * @remarks
@@ -673,10 +717,10 @@ export declare interface ParkRequest {
673
717
  }
674
718
 
675
719
  /**
676
- * Decode one keypress's bytes into a {@link KeyEvent} — total, never throws. A `Uint8Array` is
720
+ * Decodes one keypress's bytes into a {@link KeyEvent} — total, never throws. A `Uint8Array` is
677
721
  * read as UTF-8; the resulting string is matched against the known control bytes and the CRLF
678
722
  * pair ({@link CONTROL_NAMES}) and escape sequences ({@link SEQUENCE_NAMES}), falling back to a
679
- * single printable character. An unrecognized sequence yields `name: ''` with the raw `sequence`
723
+ * single printable character. An unrecognized sequence carries NO `name`, with the raw `sequence`
680
724
  * preserved.
681
725
  *
682
726
  * @remarks
@@ -689,8 +733,8 @@ export declare interface ParkRequest {
689
733
  * - **Printable character.** A single printable character becomes `name` = that character, with
690
734
  * `shift` set when it is an uppercase letter. A multi-code-point printable (an emoji, a pasted
691
735
  * run) keeps its first code point as the name and the whole input as `sequence`.
692
- * - **Unknown.** Anything else (an unrecognized escape, an empty input) yields `name: ''` —
693
- * total, so the driver never crashes on a stray byte.
736
+ * - **Unknown.** Anything else (an unrecognized escape, an empty input) yields an event with NO
737
+ * `name` — absence, never an empty string — total, so the driver never crashes on a stray byte.
694
738
  *
695
739
  * @param input - The raw keypress bytes, as a string or `Uint8Array`
696
740
  * @returns The decoded {@link KeyEvent}
@@ -707,17 +751,25 @@ export declare interface ParkRequest {
707
751
  export declare function parseKey(input: string | Uint8Array): KeyEvent;
708
752
 
709
753
  /**
710
- * Advance a password prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
711
- * reducer. Identical line-editing to {@link inputReduce} (printable extends, backspace shrinks,
712
- * ctrl-u clears, ctrl-c cancels) but the view masks the value. Return produces the candidate value.
713
- */
714
- export declare function passwordReduce(state: ReturnType<typeof createPasswordState>, key: KeyEvent): PromptStep<string, ReturnType<typeof createPasswordState>>;
715
-
716
- /** Render a password-field key state as a styled view. */
717
- export declare function passwordView(state: ReturnType<typeof createPasswordState>): string;
754
+ * Represents the immutable state a password field's reducer carries — the text state with the mask glyph in
755
+ * place of a default, because a secret is never seeded from the schema.
756
+ *
757
+ * @remarks
758
+ * - `message` — the sanitized label the header renders.
759
+ * - `mask` — the glyph each typed character renders as.
760
+ * - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
761
+ * - `value` — the characters typed so far, rendered only as the mask repeated.
762
+ */
763
+ export declare interface PasswordState {
764
+ readonly message: string;
765
+ readonly mask: string;
766
+ readonly styler: StylerInterface;
767
+ readonly theme: PromptTheme;
768
+ readonly value: string;
769
+ }
718
770
 
719
771
  /**
720
- * One form PARKED by the broker — an id-keyed, wire-safe record of a live form awaiting a remote
772
+ * Represents one form PARKED by the broker — an id-keyed, wire-safe record of a live form awaiting a remote
721
773
  * answer. The value a `pending` listener receives and the broker serializes over SSE to a
722
774
  * {@link PromptClientInterface}.
723
775
  *
@@ -743,7 +795,7 @@ export declare interface PendingForm {
743
795
  }
744
796
 
745
797
  /**
746
- * The lifecycle status of a parked {@link PendingForm} — where the TICKET stands, which is not
798
+ * Names the lifecycle status of a parked {@link PendingForm} — where the TICKET stands, which is not
747
799
  * where the form stands. A ticket is `pending` until somebody answers it; the form it carries has
748
800
  * its own status, and the two are separate facts about separate entities.
749
801
  *
@@ -755,7 +807,7 @@ export declare interface PendingForm {
755
807
  export declare type PendingFormStatus = 'pending' | 'answered' | 'expired';
756
808
 
757
809
  /**
758
- * The headless form broker. It parks live forms, exposes their serialized schemas, and applies
810
+ * Implements the headless form broker. It parks live forms, exposes their serialized schemas, and applies
759
811
  * remote answers to the authoritative form.
760
812
  *
761
813
  * @remarks
@@ -789,7 +841,7 @@ export declare class Prompt implements PromptInterface {
789
841
  }
790
842
 
791
843
  /**
792
- * The six default glyphs {@link DEFAULT_PROMPT_THEME} assembles its `icons` from. Read only when
844
+ * Holds the default glyphs {@link DEFAULT_PROMPT_THEME} assembles its `icons` from. Read only when
793
845
  * the default theme is assembled; a view reads its resolved theme and never this constant. Frozen.
794
846
  *
795
847
  * @remarks
@@ -808,14 +860,14 @@ export declare const PROMPT_ICONS: Readonly<{
808
860
  }>;
809
861
 
810
862
  /**
811
- * Every {@link import('./types.js').PromptRole}, in one frozen list — the role axis's source of
863
+ * Holds every {@link import('./types.js').PromptRole}, in one frozen list — the role axis's source of
812
864
  * truth. {@link import('./helpers.js').createPromptTheme} walks it to merge a partial theme, and
813
865
  * a consumer building a complete role map reads it rather than retyping every name.
814
866
  */
815
867
  export declare const PROMPT_ROLES: readonly PromptRole[];
816
868
 
817
869
  /**
818
- * The SSE form bridge. It ingests serialized forms from a remote broker, renders them through a
870
+ * Implements the SSE form bridge. It ingests serialized forms from a remote broker, renders them through a
819
871
  * local terminal, and posts answers back without blocking the event stream.
820
872
  *
821
873
  * @remarks
@@ -824,12 +876,12 @@ export declare const PROMPT_ROLES: readonly PromptRole[];
824
876
  * {@link disconnect} deliberately stopped it.
825
877
  * - **Ingest + render.** Each `pending` envelope passes through `isPendingForm`, Form's `parseForm`,
826
878
  * and terminal's `sanitizeSchema`, then enters a serial render queue. The SSE reader never awaits
827
- * that queue, so `expire` and `shutdown` remain live while a person is answering.
879
+ * that queue, so `expire` and `destroy` remain live while a person is answering.
828
880
  * - **Safe local form.** The rendering copy omits every wire `pattern`, because Form compiles a
829
881
  * pattern during local evaluation. The broker's parked form retains it and remains authoritative.
830
882
  * - **Refusal retry.** A structured `rejected` response seeds a new rendering form with the values
831
883
  * just submitted, applies every {@link FieldError} through `invalidate`, and asks again. No retry
832
- * counter truncates the loop; acceptance, expiry, and shutdown are its bounds.
884
+ * counter truncates the loop; acceptance, expiry, and the broker's own teardown are its bounds.
833
885
  * - **Replay safety.** A replayed id is skipped while it is queued, rendering, or posting. Once an
834
886
  * attempt ends, a later delivery of that id may be rendered again.
835
887
  *
@@ -854,7 +906,7 @@ export declare class PromptClient implements PromptClientInterface {
854
906
  }
855
907
 
856
908
  /**
857
- * The client's event map — lean, errors `unknown`, no listener-error event.
909
+ * Declares the client's event map — lean, errors `unknown`, no listener-error event.
858
910
  *
859
911
  * @remarks
860
912
  * - `connect` — the SSE stream opened.
@@ -872,7 +924,7 @@ export declare type PromptClientEventMap = {
872
924
  };
873
925
 
874
926
  /**
875
- * The SSE form BRIDGE — the client-side counterpart to {@link PromptInterface}. It receives
927
+ * Declares the SSE form BRIDGE — the client-side counterpart to {@link PromptInterface}. It receives
876
928
  * serialized {@link PendingForm} records from a remote broker, rebuilds each schema locally, drives
877
929
  * it through a {@link TerminalInterface}, and POSTs the answer back, so a human at this machine
878
930
  * answers forms a broker parked elsewhere.
@@ -900,7 +952,7 @@ export declare interface PromptClientInterface {
900
952
  }
901
953
 
902
954
  /**
903
- * Options for {@link import('./factories.js').createPromptClient} and the
955
+ * Configures {@link import('./factories.js').createPromptClient} and the
904
956
  * {@link PromptClientInterface}.
905
957
  *
906
958
  * @remarks
@@ -931,7 +983,7 @@ export declare interface PromptClientOptions {
931
983
  }
932
984
 
933
985
  /**
934
- * The broker's event map — lean, errors `unknown`, no listener-error event.
986
+ * Declares the broker's event map — lean, errors `unknown`, no listener-error event.
935
987
  *
936
988
  * @remarks
937
989
  * - `pending` — a form was parked; a transport forwards the wire record to remote clients.
@@ -944,11 +996,8 @@ export declare type PromptEventMap = {
944
996
  readonly expire: readonly [id: string];
945
997
  };
946
998
 
947
- /** The styled prompt-message header (`? message`) — the leading line every active prompt view shares, themed by the `question` + `message` roles. */
948
- export declare function promptHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
949
-
950
999
  /**
951
- * One glyph slot a rendered field draws — the icon axis of a {@link PromptTheme}. A named value
1000
+ * Names one glyph slot a rendered field draws — the icon axis of a {@link PromptTheme}. A named value
952
1001
  * set, not a toggle, so it stays a union.
953
1002
  *
954
1003
  * @remarks
@@ -961,7 +1010,7 @@ export declare function promptHeader(styler: StylerInterface, theme: PromptTheme
961
1010
  export declare type PromptIcon = 'question' | 'pointer' | 'dot' | 'selected' | 'checked' | 'unchecked' | 'success' | 'error';
962
1011
 
963
1012
  /**
964
- * The headless form BROKER — parks a live form until somebody elsewhere answers it. The headless
1013
+ * Declares the headless form BROKER — parks a live form until somebody elsewhere answers it. The headless
965
1014
  * arm of the local-TTY / headless / remote trio: there is no terminal here, so a transport forwards
966
1015
  * each `pending` record to whoever can answer, and {@link answer} drives the parked form to
967
1016
  * settlement.
@@ -1004,7 +1053,7 @@ export declare interface PromptInterface {
1004
1053
  }
1005
1054
 
1006
1055
  /**
1007
- * Options for {@link import('./factories.js').createPrompt} and every {@link PromptInterface}
1056
+ * Configures {@link import('./factories.js').createPrompt} and every {@link PromptInterface}
1008
1057
  * broker, including one a {@link TerminalManagerInterface} mounts per endpoint.
1009
1058
  *
1010
1059
  * @remarks
@@ -1028,7 +1077,7 @@ export declare interface PromptOptions {
1028
1077
  }
1029
1078
 
1030
1079
  /**
1031
- * One styling slot a rendered field paints through — the semantic axis of a {@link PromptTheme}. A
1080
+ * Names one styling slot a rendered field paints through — the semantic axis of a {@link PromptTheme}. A
1032
1081
  * role says what a fragment MEANS; the theme decides what that meaning looks like, so a consumer
1033
1082
  * re-maps styled output by naming roles rather than reimplementing a renderer.
1034
1083
  *
@@ -1051,14 +1100,14 @@ export declare interface PromptOptions {
1051
1100
  export declare type PromptRole = 'question' | 'pointer' | 'message' | 'content' | 'success' | 'error' | 'selected' | 'focus' | 'hint' | 'muted' | 'description';
1052
1101
 
1053
1102
  /**
1054
- * Where one field's reducer stands after a key. `active`: keep asking, because the key was
1103
+ * Names where one field's reducer stands after a key. `active`: keep asking, because the key was
1055
1104
  * consumed or the answer was refused. `submit`: the field resolved with its `value`. `cancel`: the
1056
1105
  * user aborted with ctrl-c. Names its axis, never `kind`.
1057
1106
  */
1058
1107
  export declare type PromptStatus = 'active' | 'submit' | 'cancel';
1059
1108
 
1060
1109
  /**
1061
- * The result of one reducer step — the next `state`, the rendered `view`, the `status`, and, on
1110
+ * Represents the result of one reducer step — the next `state`, the rendered `view`, the `status`, and, on
1062
1111
  * `submit`, the resolved `value`. The whole contract between a pure reducer and the impure driver:
1063
1112
  * the driver applies the next `state`, writes the `view`, and reads `value` on `submit`.
1064
1113
  *
@@ -1081,7 +1130,7 @@ export declare interface PromptStep<T, S> {
1081
1130
  }
1082
1131
 
1083
1132
  /**
1084
- * A resolved PRESENTATION — the glyph for every {@link PromptIcon} and the console {@link Style}
1133
+ * Represents a resolved PRESENTATION — the glyph for every {@link PromptIcon} and the console {@link Style}
1085
1134
  * for every {@link PromptRole}. Plain JSON data with no functions, so it crosses the wire with the
1086
1135
  * form it decorates. Built by {@link import('./helpers.js').createPromptTheme}.
1087
1136
  *
@@ -1098,7 +1147,7 @@ export declare interface PromptTheme {
1098
1147
  }
1099
1148
 
1100
1149
  /**
1101
- * The PARTIAL {@link PromptTheme} an option bag carries — every icon and every role is optional,
1150
+ * Represents the PARTIAL {@link PromptTheme} an option bag carries — every icon and every role is optional,
1102
1151
  * and {@link import('./helpers.js').createPromptTheme} merges what is supplied over
1103
1152
  * {@link import('./constants.js').DEFAULT_PROMPT_THEME} leaf by leaf. Supplying one icon or one
1104
1153
  * role leaves every other slot at its default.
@@ -1108,11 +1157,172 @@ export declare interface PromptThemeOptions {
1108
1157
  readonly roles?: Readonly<Partial<Record<PromptRole, Style>>>;
1109
1158
  }
1110
1159
 
1111
- /** Carriage return (`\r`, U+000D) — Enter on most terminals. */
1160
+ /**
1161
+ * Advances a checkbox prompt by one {@link KeyEvent} — the pure
1162
+ * `(state, key) → PromptStep<readonly string[]>` reducer. `up` / `down` (and `k` / `j`) move the
1163
+ * focus (wrapping); `space` toggles the focused index in the checked set; return submits the
1164
+ * checked values in choice order; ctrl-c cancels. The form applies selection-count rules.
1165
+ *
1166
+ * @param state - The checkbox field's current reducer state
1167
+ * @param key - The decoded keypress to apply
1168
+ * @returns The next step — the state, the rendered view, the status, and the ticked values on submit
1169
+ */
1170
+ export declare function reduceCheckbox(state: CheckboxState, key: KeyEvent): PromptStep<readonly string[], CheckboxState>;
1171
+
1172
+ /**
1173
+ * Advances a confirm prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<boolean>`
1174
+ * reducer. `y` / `Y` submits `true`, `n` / `N` submits `false`, return on an empty line submits
1175
+ * the `default`, ctrl-c cancels; any other key is ignored (stays active).
1176
+ *
1177
+ * @param state - The confirm field's current reducer state
1178
+ * @param key - The decoded keypress to apply
1179
+ * @returns The next step — the state, the rendered view, the status, and the answer on submit
1180
+ */
1181
+ export declare function reduceConfirm(state: ConfirmState, key: KeyEvent): PromptStep<boolean, ConfirmState>;
1182
+
1183
+ /**
1184
+ * Advances an editor prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
1185
+ * reducer. Printable characters extend the current line; backspace shrinks it; return commits the
1186
+ * current line and starts a fresh one; ctrl-d FINISHES (joining all lines, falling back to the
1187
+ * default when empty); ctrl-c cancels. The form validates the candidate after the driver fills it.
1188
+ *
1189
+ * @param state - The editor field's current reducer state
1190
+ * @param key - The decoded keypress to apply
1191
+ * @returns The next step — the state, the rendered view, the status, and the joined text on submit
1192
+ */
1193
+ export declare function reduceEditor(state: EditorState, key: KeyEvent): PromptStep<string, EditorState>;
1194
+
1195
+ /**
1196
+ * Advances an input prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
1197
+ * reducer. Printable characters extend the value; backspace shrinks it; ctrl-u clears it; ctrl-c
1198
+ * cancels; return produces the candidate value, with an empty line falling back to the default.
1199
+ *
1200
+ * @param state - The text field's current reducer state
1201
+ * @param key - The decoded keypress to apply
1202
+ * @returns The next step — the new state, the rendered view, the status, and the value on submit
1203
+ */
1204
+ export declare function reduceInput(state: InputState, key: KeyEvent): PromptStep<string, InputState>;
1205
+
1206
+ /**
1207
+ * Advances a password prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
1208
+ * reducer. Identical line-editing to {@link reduceInput} (printable extends, backspace shrinks,
1209
+ * ctrl-u clears, ctrl-c cancels) but the view masks the value. Return produces the candidate value.
1210
+ *
1211
+ * @param state - The password field's current reducer state
1212
+ * @param key - The decoded keypress to apply
1213
+ * @returns The next step — the new state, the masked view, the status, and the value on submit
1214
+ */
1215
+ export declare function reducePassword(state: PasswordState, key: KeyEvent): PromptStep<string, PasswordState>;
1216
+
1217
+ /**
1218
+ * Advances a select prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
1219
+ * reducer. `up` / `down` (and `k` / `j`) move the focus, WRAPPING at the ends; return submits the
1220
+ * focused choice's `value`; ctrl-c cancels. An empty choice list can never submit (a higher layer
1221
+ * guards against it); any other key is ignored.
1222
+ *
1223
+ * @param state - The select field's current reducer state
1224
+ * @param key - The decoded keypress to apply
1225
+ * @returns The next step — the state, the rendered view, the status, and the chosen value on submit
1226
+ */
1227
+ export declare function reduceSelect(state: SelectState, key: KeyEvent): PromptStep<string, SelectState>;
1228
+
1229
+ /**
1230
+ * Renders a checkbox-field key state as a multi-line styled view.
1231
+ *
1232
+ * @param state - The checkbox field's current reducer state
1233
+ * @returns The rendered view — the header, one box per choice, and the selected count
1234
+ */
1235
+ export declare function renderCheckboxView(state: CheckboxState): string;
1236
+
1237
+ /**
1238
+ * Renders a confirm-field key state as a styled view. The selected role paints the default letter.
1239
+ *
1240
+ * @param state - The confirm field's current reducer state
1241
+ * @returns The rendered view — the header and the yes/no group with the default capitalized
1242
+ */
1243
+ export declare function renderConfirmView(state: ConfirmState): string;
1244
+
1245
+ /**
1246
+ * Renders an editor-field key state as a multi-line styled view with its finish hint.
1247
+ *
1248
+ * @param state - The editor field's current reducer state
1249
+ * @returns The rendered view — the hinted header, the committed lines, and the line in progress
1250
+ */
1251
+ export declare function renderEditorView(state: EditorState): string;
1252
+
1253
+ /**
1254
+ * Renders the styled failure line (`✖ message`) a form driver appends for a refused field.
1255
+ *
1256
+ * @param styler - The console styler that renders each role
1257
+ * @param theme - The resolved prompt theme
1258
+ * @param message - The failure text, normally the field's label and the reason
1259
+ * @returns The rendered failure line
1260
+ */
1261
+ export declare function renderErrorLine(styler: StylerInterface, theme: PromptTheme, message: string): string;
1262
+
1263
+ /**
1264
+ * Renders a question header followed by a key hint painted with the `hint` role, or the header
1265
+ * alone when no hint is supplied.
1266
+ *
1267
+ * @param styler - The console styler that renders each role
1268
+ * @param theme - The resolved prompt theme
1269
+ * @param message - The prompt's question text
1270
+ * @param hint - The optional key hint to append
1271
+ * @returns The rendered header with the optional hint
1272
+ */
1273
+ export declare function renderHintedHeader(styler: StylerInterface, theme: PromptTheme, message: string, hint?: string): string;
1274
+
1275
+ /**
1276
+ * Renders a text-field key state as a styled view.
1277
+ *
1278
+ * @param state - The text field's current reducer state
1279
+ * @returns The rendered single-line view — header, pointer, and the typed value or the default
1280
+ */
1281
+ export declare function renderInputView(state: InputState): string;
1282
+
1283
+ /**
1284
+ * Renders a password-field key state as a styled view.
1285
+ *
1286
+ * @param state - The password field's current reducer state
1287
+ * @returns The rendered view, with the mask repeated in place of the typed value
1288
+ */
1289
+ export declare function renderPasswordView(state: PasswordState): string;
1290
+
1291
+ /**
1292
+ * Renders the styled question header (`? message`) — the leading line every active prompt view
1293
+ * shares, themed by the `question` + `message` roles.
1294
+ *
1295
+ * @param styler - The console styler that renders each role
1296
+ * @param theme - The resolved prompt theme
1297
+ * @param message - The prompt's question text
1298
+ * @returns The rendered question header
1299
+ */
1300
+ export declare function renderPromptHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
1301
+
1302
+ /**
1303
+ * Renders a select-field key state as a multi-line styled view.
1304
+ *
1305
+ * @param state - The select field's current reducer state
1306
+ * @returns The rendered view — the header, then one row per choice with the focused row marked
1307
+ */
1308
+ export declare function renderSelectView(state: SelectState): string;
1309
+
1310
+ /**
1311
+ * Renders the styled submit line (`✔ message`) — the committed header an interactive prompt shows
1312
+ * after it resolves, themed by the `success` + `message` roles.
1313
+ *
1314
+ * @param styler - The console styler that renders each role
1315
+ * @param theme - The resolved prompt theme
1316
+ * @param message - The settled prompt's question text
1317
+ * @returns The rendered committed header
1318
+ */
1319
+ export declare function renderSubmitHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
1320
+
1321
+ /** Names the carriage return byte (`\r`, U+000D) — Enter on most terminals. */
1112
1322
  export declare const RETURN: string;
1113
1323
 
1114
1324
  /**
1115
- * Sanitize text for one single-line display slot. Composes console's ANSI {@link strip} and C0
1325
+ * Sanitizes text for one single-line display slot. Composes console's ANSI {@link strip} and C0
1116
1326
  * {@link stripControls} passes with removal of tab, line feed, and carriage return.
1117
1327
  *
1118
1328
  * @param text - The text to sanitize for a glyph or hint slot
@@ -1126,7 +1336,7 @@ export declare const RETURN: string;
1126
1336
  export declare function sanitizeDisplayText(text: string): string;
1127
1337
 
1128
1338
  /**
1129
- * Sanitize every terminal-readable string in a parsed form schema.
1339
+ * Sanitizes every terminal-readable string in a parsed form schema.
1130
1340
  *
1131
1341
  * @remarks
1132
1342
  * Display strings pass through {@link sanitizeDisplayText}: labels, help, placeholders, masks,
@@ -1148,7 +1358,7 @@ export declare function sanitizeDisplayText(text: string): string;
1148
1358
  export declare function sanitizeSchema(schema: FormSchema): FormSchema;
1149
1359
 
1150
1360
  /**
1151
- * Sanitize every glyph a wire-supplied {@link PromptThemeOptions} carries for a single-line display
1361
+ * Sanitizes every glyph a wire-supplied {@link PromptThemeOptions} carries for a single-line display
1152
1362
  * slot. Only the icons need it: a role is guard-narrowed to a console {@link Style}, whose colors
1153
1363
  * and attributes are fixed name sets, so no role can carry a byte a terminal would act on.
1154
1364
  *
@@ -1158,20 +1368,26 @@ export declare function sanitizeSchema(schema: FormSchema): FormSchema;
1158
1368
  export declare function sanitizeThemeIcons(theme: PromptThemeOptions): PromptThemeOptions;
1159
1369
 
1160
1370
  /**
1161
- * Advance a select prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
1162
- * reducer. `up` / `down` (and `k` / `j`) move the focus, WRAPPING at the ends; return submits the
1163
- * focused choice's `value`; ctrl-c cancels. An empty choice list can never submit (a higher layer
1164
- * guards against it); any other key is ignored.
1165
- */
1166
- export declare function selectReduce(state: ReturnType<typeof createSelectState>, key: KeyEvent): PromptStep<string, ReturnType<typeof createSelectState>>;
1167
-
1168
- /** Render a select-field key state as a multi-line styled view. */
1169
- export declare function selectView(state: ReturnType<typeof createSelectState>): string;
1371
+ * Represents the immutable state a select field's reducer carries.
1372
+ *
1373
+ * @remarks
1374
+ * - `message` — the sanitized label the header renders.
1375
+ * - `choices` — the choices the list offers, in declared order.
1376
+ * - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
1377
+ * - `focused` — the index the cursor sits on, pre-placed on the declared default.
1378
+ */
1379
+ export declare interface SelectState {
1380
+ readonly message: string;
1381
+ readonly choices: readonly FieldChoice[];
1382
+ readonly styler: StylerInterface;
1383
+ readonly theme: PromptTheme;
1384
+ readonly focused: number;
1385
+ }
1170
1386
 
1171
1387
  /**
1172
- * The exact escape SEQUENCE → canonical key NAME table {@link import('./helpers.js').parseKey}
1388
+ * Holds the exact escape SEQUENCE → canonical key NAME table {@link import('./helpers.js').parseKey}
1173
1389
  * consults for the navigation / editing keys. Covers BOTH the CSI form (`ESC[A`…) and the SS3
1174
- * form (`ESCOA`…) of the four arrows, plus the `home` / `end` / `delete` CSI sequences (with
1390
+ * form (`ESCOA`…) of the arrows, plus the `home` / `end` / `delete` CSI sequences (with
1175
1391
  * their numeric-tilde variants). The source of truth for the multi-byte key decode; frozen.
1176
1392
  *
1177
1393
  * @remarks
@@ -1182,20 +1398,34 @@ export declare function selectView(state: ReturnType<typeof createSelectState>):
1182
1398
  */
1183
1399
  export declare const SEQUENCE_NAMES: Readonly<Record<string, string>>;
1184
1400
 
1185
- /** Serialize a parked prompt's expiry or release into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
1401
+ /**
1402
+ * Serializes the {@link WireEvent} a broker or manager sends when it is going away.
1403
+ *
1404
+ * @returns The `destroy` frame, whose `data` is empty because the signal carries no payload
1405
+ */
1406
+ export declare function serializeDestroy(): WireEvent;
1407
+
1408
+ /**
1409
+ * Serializes a parked prompt's expiry or release into a {@link WireEvent}.
1410
+ *
1411
+ * @param id - The id of the parked form that expired or was released
1412
+ * @returns The `expire` frame, carrying the JSON-stringified `{ id }` payload as `data`
1413
+ */
1186
1414
  export declare function serializeExpire(id: string): WireEvent;
1187
1415
 
1188
- /** Serialize a parked {@link PendingForm} into a {@link WireEvent}. */
1416
+ /**
1417
+ * Serializes a parked {@link PendingForm} into a {@link WireEvent}.
1418
+ *
1419
+ * @param form - The parked form's wire-safe record
1420
+ * @returns The `pending` frame — the JSON-stringified record as `data`, and the form's own `id`
1421
+ */
1189
1422
  export declare function serializePending(form: PendingForm): WireEvent;
1190
1423
 
1191
- /** The {@link WireEvent} a broker/manager sends when it is going away — event `'shutdown'`, no payload. */
1192
- export declare function serializeShutdown(): WireEvent;
1193
-
1194
- /** Space (U+0020). */
1424
+ /** Names the space byte (U+0020). */
1195
1425
  export declare const SPACE = " ";
1196
1426
 
1197
1427
  /**
1198
- * The maximum number of characters the {@link import('./types.js').PromptClientInterface} lets its
1428
+ * Sets the maximum number of characters the {@link import('./types.js').PromptClientInterface} lets its
1199
1429
  * SSE parser buffer before treating the stream as hostile — 1 MiB, comfortably above any
1200
1430
  * legitimate prompt payload. Passed as the `limit` to `createSSEParser` so an unterminated
1201
1431
  * or oversized `data:` field cannot grow the buffer without bound (a memory-exhaustion guard).
@@ -1203,37 +1433,35 @@ export declare const SPACE = " ";
1203
1433
  export declare const SSE_BUFFER_LIMIT = 1048576;
1204
1434
 
1205
1435
  /**
1206
- * The SSE `event:` names the broker emits and the {@link import('./types.js').PromptClientInterface}
1436
+ * Holds the SSE `event:` names the broker emits and the {@link import('./types.js').PromptClientInterface}
1207
1437
  * dispatches on. Frozen; the source of truth for the wire event vocabulary.
1208
1438
  *
1209
1439
  * @remarks
1210
1440
  * - `pending` — a serialized {@link import('./types.js').PendingForm} to dispatch and answer.
1211
1441
  * - `expire` — an `{ id }` payload: the broker expired or released a parked prompt (the client drops it).
1212
- * - `shutdown` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
1442
+ * - `destroy` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
1213
1443
  */
1214
1444
  export declare const SSE_EVENTS: Readonly<{
1215
1445
  pending: "pending";
1216
1446
  expire: "expire";
1217
- shutdown: "shutdown";
1447
+ destroy: "destroy";
1218
1448
  }>;
1219
1449
 
1220
- /** The styled submit line (`✔ message`) — the committed header an interactive prompt shows once resolved, themed by the `success` + `message` roles. */
1221
- export declare function submitHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
1222
-
1223
- /** Tab (`\t`, U+0009). */
1450
+ /** Names the tab byte (`\t`, U+0009). */
1224
1451
  export declare const TAB: string;
1225
1452
 
1226
1453
  /**
1227
- * Why a {@link TerminalManagerInterface.answer} call refused — an {@link AnswerError} from the
1228
- * endpoint's own broker, or `terminal` when no endpoint is mounted under that name. One
1229
- * discriminant, `reason`, across both.
1454
+ * Explains why a {@link TerminalManagerInterface.answer} call refused — an {@link AnswerError} from the
1455
+ * endpoint's own broker, or `target` when no endpoint is mounted under that name. That is the same
1456
+ * condition {@link TerminalErrorCode}'s `TARGET` names for {@link TerminalManagerInterface.ask}, so
1457
+ * one word carries it on both doors. One discriminant, `reason`, across every member.
1230
1458
  */
1231
1459
  export declare type TerminalAnswerError = AnswerError | {
1232
- readonly reason: 'terminal';
1460
+ readonly reason: 'target';
1233
1461
  };
1234
1462
 
1235
1463
  /**
1236
- * The error the terminal surfaces for its own refusals: parking on a destroyed or full broker, an
1464
+ * Represents the error the terminal surfaces for its own refusals: parking on a destroyed or full broker, an
1237
1465
  * unusable driver stream, a manager routing fault, or a ctrl-c cancellation. A parked form's own
1238
1466
  * lifecycle failures reject through the form's `answer` with the form package's error, never with
1239
1467
  * this one.
@@ -1244,15 +1472,22 @@ export declare type TerminalAnswerError = AnswerError | {
1244
1472
  * a caught value with {@link isTerminalError} and branch on `error.code`.
1245
1473
  */
1246
1474
  export declare class TerminalError extends Error {
1247
- /** The machine-readable condition — see {@link TerminalErrorCode}. */
1475
+ /** Holds the machine-readable condition — see {@link TerminalErrorCode}. */
1248
1476
  readonly code: TerminalErrorCode;
1249
- /** An optional context bag naming the offending values — see the class {@link TerminalError remarks}. */
1477
+ /** Holds an optional context bag naming the offending values — see the class {@link TerminalError remarks}. */
1250
1478
  readonly context?: Readonly<Record<string, unknown>>;
1479
+ /**
1480
+ * Builds one terminal refusal.
1481
+ *
1482
+ * @param code - The machine-readable {@link TerminalErrorCode} a caller branches on
1483
+ * @param message - The human-readable reason
1484
+ * @param context - The optional bag naming the offending values — see the class {@link TerminalError remarks}
1485
+ */
1251
1486
  constructor(code: TerminalErrorCode, message: string, context?: Readonly<Record<string, unknown>>);
1252
1487
  }
1253
1488
 
1254
1489
  /**
1255
- * The machine-readable condition carried by a {@link import('./errors.js').TerminalError} — the
1490
+ * Names the machine-readable condition carried by a {@link import('./errors.js').TerminalError} — the
1256
1491
  * axis a `catch` branches on. Names its axis (the failure condition), never `kind`.
1257
1492
  *
1258
1493
  * @remarks
@@ -1275,7 +1510,7 @@ export declare class TerminalError extends Error {
1275
1510
  export declare type TerminalErrorCode = 'EXPIRE' | 'CANCEL' | 'DRIVER' | 'DEADLOCK' | 'TARGET' | 'LIMIT' | 'DESTROYED';
1276
1511
 
1277
1512
  /**
1278
- * The contract for asking a form of a human at a keyboard — one method, because a form is one
1513
+ * Declares the contract for asking a form of a human at a keyboard — one method, because a form is one
1279
1514
  * question however many fields it holds. The server `Terminal` implements it against a real TTY;
1280
1515
  * a {@link PromptClientInterface} holds one to answer forms parked elsewhere.
1281
1516
  *
@@ -1295,10 +1530,9 @@ export declare interface TerminalInterface {
1295
1530
  }
1296
1531
 
1297
1532
  /**
1298
- * The multi-endpoint terminal MANAGER — a registry of named {@link PromptInterface} brokers (one
1299
- * per endpoint), so several parties can `ask` forms of each other by NAME with a `from` → `to`
1300
- * attribution edge on every parked form, and a transitive DEADLOCK check across all in-flight
1301
- * asks.
1533
+ * Registers named {@link PromptInterface} brokers (one per endpoint), so several parties can
1534
+ * `ask` forms of each other by NAME with a `from` → `to` attribution edge on every parked form,
1535
+ * and a transitive DEADLOCK check across all in-flight asks.
1302
1536
  *
1303
1537
  * @remarks
1304
1538
  * - **Registry.** `add(name, options?)` mints (or, if `name` is already mounted, returns the
@@ -1313,7 +1547,7 @@ export declare interface TerminalInterface {
1313
1547
  * - **Durable open / save.** `open(name)` restores an EMPTY broker from the `store` (parked
1314
1548
  * Promises are process-bound and never resurrected); `save(name)` persists the endpoint's
1315
1549
  * configured `timeout`.
1316
- * - **Removal.** `remove` drops one endpoint, a batch (§9.2, array overload FIRST), or every
1550
+ * - **Removal.** `remove` drops one endpoint, a batch (the array overload declared FIRST), or every
1317
1551
  * endpoint when called without an argument. It destroys each broker, which expires every form
1318
1552
  * still parked on it. `destroy` is idempotent.
1319
1553
  *
@@ -1333,7 +1567,7 @@ export declare class TerminalManager implements TerminalManagerInterface {
1333
1567
  get emitter(): EmitterInterface<TerminalManagerEventMap>;
1334
1568
  get count(): number;
1335
1569
  terminal(name: string): PromptInterface | undefined;
1336
- terminals(): readonly string[];
1570
+ terminals(): readonly PromptInterface[];
1337
1571
  add(name: string, options?: PromptOptions): PromptInterface;
1338
1572
  ask(from: string, to: string, form: FormInterface): Promise<FormValues>;
1339
1573
  pending(): readonly PendingForm[];
@@ -1348,7 +1582,7 @@ export declare class TerminalManager implements TerminalManagerInterface {
1348
1582
  }
1349
1583
 
1350
1584
  /**
1351
- * The manager's event map — the name-attributed re-emission of every mounted broker's events, so a
1585
+ * Declares the manager's event map — the name-attributed re-emission of every mounted broker's events, so a
1352
1586
  * caller subscribes once for ALL endpoints instead of once per broker.
1353
1587
  *
1354
1588
  * @remarks
@@ -1363,24 +1597,27 @@ export declare type TerminalManagerEventMap = {
1363
1597
  };
1364
1598
 
1365
1599
  /**
1366
- * The multi-endpoint terminal MANAGER — a registry of named {@link PromptInterface} brokers, one
1367
- * per endpoint, so several parties (agents, tools, humans) can ask forms of each other BY NAME,
1368
- * attributed with a `from` → `to` edge on every parked record.
1600
+ * Declares a registry of named {@link PromptInterface} brokers, one per endpoint, so several
1601
+ * parties (agents, tools, humans) can ask forms of each other BY NAME, attributed with a
1602
+ * `from` → `to` edge on every parked record.
1369
1603
  *
1370
1604
  * @remarks
1371
1605
  * - **Accessors.** `terminal(name)` looks up one endpoint's broker; `terminals()` lists every
1372
- * mounted endpoint name.
1606
+ * mounted broker, in insertion order. `terminals()` returns brokers, not keys; a name is an
1607
+ * argument the `terminal`, `add`, `ask`, `pending`, `answer`, `open`, `save`, and `remove`
1608
+ * methods take.
1373
1609
  * - **`add`** mints, or returns, the broker for `name`. Idempotent; it never clobbers a live
1374
1610
  * endpoint.
1375
- * - **`ask`** is the attributed convenience: it parks `form` from `from` to `to`, adding `to` if it
1376
- * is absent, and resolves with the settled values.
1611
+ * - **`ask`** is the attributed convenience: it parks `form` from `from` to `to` and resolves with
1612
+ * the settled values. It never mounts `to` — an unmounted target rejects with a
1613
+ * {@link import('./errors.js').TerminalError} coded `TARGET`, so `add` the endpoint first.
1377
1614
  * - **`pending()`** lists every endpoint's parked records; `pending(to)` scopes to one endpoint.
1378
1615
  * - **`answer`** routes to the named endpoint's broker.
1379
1616
  * - **`open`** restores, or returns the live, broker for `name` from the `store`.
1380
1617
  * - **`save`** persists an endpoint's config snapshot; false when there is no store, or `name` is
1381
1618
  * unknown.
1382
- * - **Batch `remove`.** The array overload is declared FIRST: `remove(names)` removes each listed
1383
- * endpoint and reports whether any named terminal was removed; `remove(name)` removes one;
1619
+ * - **Batch `remove`.** The array overload is declared FIRST: `remove(names)` removes every listed
1620
+ * endpoint and reports true only when all of them were mounted; `remove(name)` removes one;
1384
1621
  * `remove()` removes every endpoint without destroying the manager.
1385
1622
  * - **`destroy`** tears down every broker, then the manager's own emitter.
1386
1623
  */
@@ -1388,7 +1625,7 @@ export declare interface TerminalManagerInterface {
1388
1625
  readonly emitter: EmitterInterface<TerminalManagerEventMap>;
1389
1626
  readonly count: number;
1390
1627
  terminal(name: string): PromptInterface | undefined;
1391
- terminals(): readonly string[];
1628
+ terminals(): readonly PromptInterface[];
1392
1629
  add(name: string, options?: PromptOptions): PromptInterface;
1393
1630
  ask(from: string, to: string, form: FormInterface): Promise<FormValues>;
1394
1631
  pending(): readonly PendingForm[];
@@ -1403,7 +1640,7 @@ export declare interface TerminalManagerInterface {
1403
1640
  }
1404
1641
 
1405
1642
  /**
1406
- * Options for {@link import('./factories.js').createTerminalManager} and the
1643
+ * Configures {@link import('./factories.js').createTerminalManager} and the
1407
1644
  * {@link TerminalManagerInterface}.
1408
1645
  *
1409
1646
  * @remarks
@@ -1422,7 +1659,7 @@ export declare interface TerminalManagerOptions {
1422
1659
  }
1423
1660
 
1424
1661
  /**
1425
- * One endpoint's persisted CONFIG snapshot — `id` is the endpoint name and `timeout` its configured
1662
+ * Represents one endpoint's persisted CONFIG snapshot — `id` is the endpoint name and `timeout` its configured
1426
1663
  * default. Parked forms are process-bound and are never resurrected, so `open` always restores an
1427
1664
  * EMPTY broker.
1428
1665
  */
@@ -1432,7 +1669,7 @@ export declare interface TerminalSnapshot {
1432
1669
  }
1433
1670
 
1434
1671
  /**
1435
- * One opaque persisted row — the shape a `TableInterface<TerminalSnapshotRow>`-backed store reads
1672
+ * Represents one opaque persisted row — the shape a `TableInterface<TerminalSnapshotRow>`-backed store reads
1436
1673
  * and writes. `snapshot` is narrowed with {@link import('./validators.js').isTerminalSnapshot} on
1437
1674
  * read.
1438
1675
  */
@@ -1442,7 +1679,7 @@ export declare interface TerminalSnapshotRow {
1442
1679
  }
1443
1680
 
1444
1681
  /**
1445
- * The point-access persistence seam for a {@link TerminalManagerInterface}'s endpoint configs.
1682
+ * Declares the point-access persistence seam for a {@link TerminalManagerInterface}'s endpoint configs.
1446
1683
  * Every primitive is async; deleting an absent id is a no-op.
1447
1684
  */
1448
1685
  export declare interface TerminalStoreInterface {
@@ -1451,26 +1688,33 @@ export declare interface TerminalStoreInterface {
1451
1688
  delete(id: string): Promise<void>;
1452
1689
  }
1453
1690
 
1454
- /** Cancel a pending {@link TimerHandler} deadline — idempotent, safe to call after the timer fired. */
1455
- export declare type TimerCancel = () => void;
1691
+ /** Cancels a pending {@link TimerHandler} deadline — idempotent, safe to call after the timer fired. */
1692
+ export declare type TimerCancelFunction = () => void;
1456
1693
 
1457
1694
  /**
1458
- * One injected timer — arms a deadline `callback` to fire after `ms`, returning a
1459
- * {@link TimerCancel} that cancels it. The broker's timeout seam: the default wraps the host
1695
+ * Represents one injected timer — arms a deadline `callback` to fire after `ms`, returning a
1696
+ * {@link TimerCancelFunction} that cancels it. The broker's timeout seam: the default wraps the host
1460
1697
  * `setTimeout` and `clearTimeout`; a test injects a deterministic timer that captures the callback
1461
1698
  * and fires it on demand, with no real time and no global patching.
1462
1699
  */
1463
- declare type TimerHandler_2 = (callback: () => void, ms: number) => TimerCancel;
1700
+ declare type TimerHandler_2 = (callback: () => void, ms: number) => TimerCancelFunction;
1464
1701
  export { TimerHandler_2 as TimerHandler }
1465
1702
 
1466
- /** Toggle `index` in a readonly index list — copy-on-write, returning the new sorted-by-insertion list. */
1703
+ /**
1704
+ * Toggles `index` in a readonly index list — copy-on-write, returning the new sorted-by-insertion
1705
+ * list.
1706
+ *
1707
+ * @param indices - The ticked indices, in tick order
1708
+ * @param index - The index to add when absent, or drop when present
1709
+ * @returns A new list carrying the toggled membership; the input is never mutated
1710
+ */
1467
1711
  export declare function toggleIndex(indices: readonly number[], index: number): readonly number[];
1468
1712
 
1469
1713
  /**
1470
- * One SSE-shaped wire frame — the `event` name, its already-stringified `data` payload, and an
1714
+ * Represents one SSE-shaped wire frame — the `event` name, its already-stringified `data` payload, and an
1471
1715
  * optional `id`. The transport-neutral shape {@link import('./helpers.js').serializePending},
1472
1716
  * {@link import('./helpers.js').serializeExpire}, and
1473
- * {@link import('./helpers.js').serializeShutdown} build, with no `http` dependency.
1717
+ * {@link import('./helpers.js').serializeDestroy} build, with no `http` dependency.
1474
1718
  */
1475
1719
  export declare interface WireEvent {
1476
1720
  readonly event: string;