@orkestrel/terminal 0.0.8 → 0.0.10

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.
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _src_core = require("../core/index.cjs");
3
+ let _orkestrel_form = require("@orkestrel/form");
4
+ let _orkestrel_console = require("@orkestrel/console");
3
5
  let node_readline = require("node:readline");
4
6
  let node_process = require("node:process");
5
7
  //#region src/server/constants.ts
@@ -9,8 +11,8 @@ var ESCAPE = String.fromCharCode(27);
9
11
  var CSI = `[`;
10
12
  /**
11
13
  * The cursor-UP sequence TEMPLATE (`ESC[{count}A`) — {@link import('./helpers.js').moveUp}
12
- * interpolates `{count}` with the number of lines to climb (the `{count}` placeholder idiom the core
13
- * terminals' `RULE_MESSAGES` uses). Kept as a template so the count stays out of the constant.
14
+ * interpolates the `{count}` placeholder with the number of lines to climb. Kept as a template so
15
+ * the count stays out of the constant.
14
16
  */
15
17
  var CSI_UP = `${CSI}{count}A`;
16
18
  /**
@@ -31,13 +33,47 @@ var CARRIAGE_RETURN = String.fromCharCode(13);
31
33
  /** A line feed (`\n`, U+000A) — the line terminator the driver writes after the final committed prompt view. */
32
34
  var LINE_FEED = String.fromCharCode(10);
33
35
  /**
34
- * The numbered-list prompt the non-TTY {@link import('./Terminal.js').Terminal} `select` / `checkbox`
35
- * fallback appends — a piped (non-terminal) stream cannot navigate with arrow keys, so the choices are
36
- * printed numbered and the user types the number(s) on a single readline line.
36
+ * The numbered-list prompt the non-TTY {@link import('./Terminal.js').Terminal} `select` fallback
37
+ * appends — a piped (non-terminal) stream cannot navigate with arrow keys, so the choices are
38
+ * printed numbered and the user types one number on a single readline line.
37
39
  */
38
40
  var FALLBACK_SELECT_HINT = "Enter a number";
39
41
  /** The comma-separated multi-select hint the non-TTY `checkbox` fallback shows (the user types one or more numbers). */
40
42
  var FALLBACK_CHECKBOX_HINT = "Enter numbers separated by commas";
43
+ /** The hint the non-TTY `editor` fallback shows — a piped stream has no ctrl-d, so end of input finishes the block. */
44
+ var FALLBACK_EDITOR_HINT = "(end of input finishes)";
45
+ /** The hint the non-TTY `confirm` fallback shows — a piped stream sends a whole line, so the answer is typed rather than pressed. */
46
+ var FALLBACK_CONFIRM_HINT = "(y/n)";
47
+ /**
48
+ * The format cue appended to a field's label for each control the walk reads as a line of text —
49
+ * the terminal has no date picker, no color well, and no file chooser, so the accepted shape is
50
+ * stated instead. A control with no entry needs none: `text` and `editor` accept any line,
51
+ * `password` masks one, and `confirm`, `select`, and `checkbox` are answered by key rather than by
52
+ * format. The form's own rules still decide whether the typed value is acceptable.
53
+ */
54
+ var CONTROL_HINTS = Object.freeze({
55
+ number: "(number)",
56
+ date: "(YYYY-MM-DD)",
57
+ time: "(HH:MM)",
58
+ datetime: "(YYYY-MM-DDTHH:MM)",
59
+ color: "(#rrggbb)",
60
+ file: "(path)"
61
+ });
62
+ /** The instruction a `file` field with `multiple` shows before its entries — one path per line, and a blank line ends the list. */
63
+ var FILE_HINT = "One path per line, blank to finish";
64
+ /** The lead on the line listing an open `select`'s offered values, which a typed answer may ignore. */
65
+ var SUGGESTION_LEAD = "Suggestions";
66
+ /** The lead on the line listing the choices a `select` or `checkbox` shows but refuses, so a reader sees why one is missing from the list below. */
67
+ var UNAVAILABLE_LEAD = "Unavailable";
68
+ /** The mark on a locked field's line — the walk renders its value and moves on, because the form refuses an edit there. */
69
+ var LOCKED_MARK = "(locked)";
70
+ /**
71
+ * What a field is told when the walk read an answer the control cannot hold — a word typed into a
72
+ * `number`, an off-list value typed into an open `select` whose choice is refused. The value binds
73
+ * as absence and this message is invalidated onto the field, so the walk re-asks it with the reason
74
+ * on screen.
75
+ */
76
+ var REFUSAL_MESSAGE = "Enter a value this field accepts";
41
77
  //#endregion
42
78
  //#region src/server/helpers.ts
43
79
  /**
@@ -85,18 +121,6 @@ function isReadable(value) {
85
121
  return typeof value === "object" && value !== null && "read" in value && typeof value.read === "function" && "pipe" in value && typeof value.pipe === "function";
86
122
  }
87
123
  /**
88
- * Whether `value` is a Node {@link NodeJS.WritableStream} — a total structural guard (AGENTS §14)
89
- * checking for the callable `write` / `end` that `node:readline`'s `createInterface` accepts as its
90
- * `output`. Paired with {@link isReadable} so the non-TTY fallback narrows BOTH streams to the
91
- * readline boundary without an `as`. Never throws.
92
- *
93
- * @param value - The resolved output stream (or any value crossing the boundary)
94
- * @returns `true` when `value` has the writable methods readline needs
95
- */
96
- function isWritable(value) {
97
- return typeof value === "object" && value !== null && "write" in value && typeof value.write === "function" && "end" in value && typeof value.end === "function";
98
- }
99
- /**
100
124
  * Whether an input stream can be driven in RAW mode — it both reports `isTTY === true` AND exposes a
101
125
  * callable `setRawMode`. The {@link import('./Terminal.js').Terminal} probes this to choose its path:
102
126
  * `true` ⇒ the interactive raw-mode prompts (arrow-key navigation, live re-render); `false` ⇒ the
@@ -156,81 +180,389 @@ function moveUp(count) {
156
180
  function redrawPrefix(previousLines) {
157
181
  return `${moveUp(previousLines - 1)}\r${CLEAR_DOWN}`;
158
182
  }
183
+ /**
184
+ * Project any field the walk reads as a LINE OF TEXT into the {@link TextField} the text reducer
185
+ * takes — `text` itself, and the six controls a terminal has no widget for: `number`, `date`,
186
+ * `time`, `datetime`, `color`, and one `file` entry. The label carries that control's format cue
187
+ * from {@link CONTROL_HINTS}, and a declared `default` becomes the line a bare return submits. The
188
+ * projection carries no rule, because the AUTHORITATIVE form still evaluates the answer this line
189
+ * binds; it exists only so one reducer can render seven controls.
190
+ *
191
+ * @param field - The field being read
192
+ * @returns The text field the reducer renders for it
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * fieldToText({ control: 'date', name: 'born', label: 'Birthday' })
197
+ * // { control: 'text', name: 'born', label: 'Birthday (YYYY-MM-DD)' }
198
+ * ```
199
+ */
200
+ function fieldToText(field) {
201
+ const label = field.label ?? field.name;
202
+ const hint = CONTROL_HINTS[field.control];
203
+ const seed = "default" in field ? field.default : void 0;
204
+ const text = typeof seed === "number" ? String(seed) : seed;
205
+ return {
206
+ control: "text",
207
+ name: field.name,
208
+ label: hint === void 0 ? label : `${label} ${hint}`,
209
+ ...typeof text === "string" ? { default: text } : {}
210
+ };
211
+ }
212
+ /**
213
+ * Project one held answer into the text a read-only line shows — a scalar as itself, a boolean as
214
+ * `yes` / `no` (the word the confirm reducer commits), and a list joined by commas. Absence renders
215
+ * as nothing, because a locked field nobody has answered has nothing to show.
216
+ *
217
+ * @param value - The answer the form holds for a field, or absence
218
+ * @returns The text to render for it
219
+ */
220
+ function valueToText(value) {
221
+ if (value === void 0) return "";
222
+ if (typeof value === "string") return value;
223
+ if (typeof value === "number") return String(value);
224
+ if (typeof value === "boolean") return value ? "yes" : "no";
225
+ return value.join(", ");
226
+ }
227
+ /**
228
+ * The choices a `select` or `checkbox` field actually OFFERS — the form refuses a disabled choice's
229
+ * value at every door, including a fill, so the walk never puts one in front of the cursor. Pair
230
+ * with {@link disabledChoices} to tell the reader what was withheld.
231
+ *
232
+ * @param choices - The field's declared choices
233
+ * @returns The choices the walk offers, in declared order
234
+ */
235
+ function enabledChoices(choices) {
236
+ return choices.filter((choice) => choice.disabled !== true);
237
+ }
238
+ /**
239
+ * The choices a `select` or `checkbox` field SHOWS but refuses — the complement of
240
+ * {@link enabledChoices}, rendered by {@link unavailableLine} above the list so a reader sees why a
241
+ * declared choice is missing from it.
242
+ *
243
+ * @param choices - The field's declared choices
244
+ * @returns The refused choices, in declared order
245
+ */
246
+ function disabledChoices(choices) {
247
+ return choices.filter((choice) => choice.disabled === true);
248
+ }
249
+ /** The section header the walk writes when it enters a new field group, painted by the `message` role. */
250
+ function groupHeader(styler, theme, label) {
251
+ return styler.render(theme.roles.message, label);
252
+ }
253
+ /**
254
+ * The read-only line a LOCKED field renders — its label, the {@link LOCKED_MARK}, and the answer the
255
+ * form already holds. The walk writes this instead of a prompt, because the field is still
256
+ * validated and still submitted but must not be edited here.
257
+ *
258
+ * @param styler - The console styler that renders each role
259
+ * @param theme - The resolved prompt theme
260
+ * @param label - The field's label
261
+ * @param value - The held answer, from {@link valueToText}
262
+ * @returns The rendered line, with no trailing space when there is nothing to show
263
+ */
264
+ function lockedLine(styler, theme, label, value) {
265
+ const head = `${styler.render(theme.roles.muted, theme.icons.dot)} ${styler.render(theme.roles.message, label)} ${styler.render(theme.roles.hint, LOCKED_MARK)}`;
266
+ return value.length === 0 ? head : `${head} ${styler.render(theme.roles.content, value)}`;
267
+ }
268
+ /** The line listing an OPEN select's offered values above its text prompt — a suggestion list, because an open select admits an answer the list does not offer. */
269
+ function suggestionLine(styler, theme, choices) {
270
+ const values = choices.map((choice) => choice.value).join(", ");
271
+ return styler.render(theme.roles.hint, `${SUGGESTION_LEAD}: ${values}`);
272
+ }
273
+ /** The line naming the choices a field shows but refuses, written above the list the walk drives. */
274
+ function unavailableLine(styler, theme, choices) {
275
+ const labels = choices.map((choice) => choice.label).join(", ");
276
+ return styler.render(theme.roles.muted, `${UNAVAILABLE_LEAD}: ${labels}`);
277
+ }
278
+ /**
279
+ * The numbered choice list the non-TTY fallback prints — a piped stream cannot navigate with arrow
280
+ * keys, so each offered choice is printed with the number the reader types back. One line per
281
+ * choice, with no trailing newline.
282
+ *
283
+ * @param styler - The console styler that renders each role
284
+ * @param theme - The resolved prompt theme
285
+ * @param choices - The choices the walk offers, from {@link enabledChoices}
286
+ * @returns The rendered list
287
+ */
288
+ function numberedList(styler, theme, choices) {
289
+ return choices.map((choice, index) => ` ${styler.render(theme.roles.muted, `${String(index + 1)})`)} ${styler.render(theme.roles.content, choice.label)}`).join("\n");
290
+ }
159
291
  //#endregion
160
292
  //#region src/server/Terminal.ts
161
293
  /**
162
- * The interactive terminal prompt driver (T-c) — the third {@link TerminalInterface} surface (beside
163
- * the core headless `Prompt` broker and the SSE `PromptClient` bridge), and the ONLY impure part of
164
- * the prompt stack. It reads the TTY and DRIVES the pure core `*Reduce` reducers: it feeds raw-mode
165
- * stdin bytes through `parseKey` into the matching reducer, renders the returned `view` in place, and
166
- * resolves on a `submit` step / rejects with a {@link TerminalError} (`CANCEL`) on ctrl-c. It owns no
167
- * prompt logic of its own — state, view, validation, and the cancel signal all come from the pure
168
- * core; this class owns ONLY the cursor + raw-mode + in-place re-render mechanics.
294
+ * The interactive terminal form DRIVER — the {@link TerminalInterface} implementation for a human at
295
+ * this machine's keyboard, and the only impure part of the terminal stack. {@link ask} walks one
296
+ * form's fields in schema order, feeds raw-mode stdin bytes through `parseKey` into the matching
297
+ * pure reducer, renders each returned view in place, and binds every answer through the form's own
298
+ * `fill`. It owns no form logic: the schema, the rules, the values, and the settlement all belong to
299
+ * the form it is given, and this class owns only raw mode, the cursor, and the re-render.
169
300
  *
170
301
  * @remarks
171
- * See {@link TerminalInterface} for the behavioral contract (raw-mode leak-freedom, the in-place
172
- * re-render, the non-TTY readline fallback, event-free).
302
+ * See {@link TerminalInterface} for the driving contract. The walk itself:
303
+ *
304
+ * - **Twelve controls, seven reducers.** `text`, `number`, `date`, `time`, `datetime`, `color`, and
305
+ * each `file` entry are read as one line of text through {@link fieldToText}, which appends that
306
+ * control's format cue to the label. `password`, `confirm`, `editor`, `select`, and `checkbox`
307
+ * each drive their own reducer. An open `select` is a suggestion list plus a typed line, because
308
+ * `open` means the answer need not come from the list.
309
+ * - **The binding projects through `matchesAnswer`.** Every answer is filled as
310
+ * `fill(name, matchesAnswer(value) ? value : undefined)` after `parseValue` has coerced it to the
311
+ * control's own shape, so a bare return on a field with no default binds as ABSENCE and the
312
+ * form's `required` rule refuses it. A typed answer the control cannot hold binds as absence and
313
+ * invalidates the field, so the walk asks again with the reason on screen.
314
+ * - **Visibility is honored.** A `hidden` field and a field currently in `form.disabled` are
315
+ * skipped; a `locked` field renders read-only; entering a new group writes its label as a section
316
+ * header.
317
+ * - **Refusal re-asks.** After the walk the form is submitted. A refusal re-walks only the erroring
318
+ * fields the walk can edit and submits again. When every erroring field is one the walk cannot
319
+ * edit — hidden, locked, or disabled — the form is abandoned instead, because asking again could
320
+ * not change the answer.
321
+ * - **Raw-mode leak-free.** Raw mode is entered once per field and always cleaned up: on submit, on
322
+ * cancel, on a throw, and when the form is abandoned under an active read.
323
+ * - **Non-TTY fallback.** When `input` is not a TTY, the same walk runs over `node:readline` line
324
+ * input: `select` and `checkbox` print a numbered list, and `editor` reads to end of input.
173
325
  */
174
326
  var Terminal = class {
175
327
  #input;
176
328
  #output;
329
+ #styler;
330
+ #theme;
177
331
  #handlers = /* @__PURE__ */ new Map();
332
+ #queue = [];
333
+ #interface;
334
+ #taker;
335
+ #ended = false;
178
336
  constructor(options) {
179
337
  this.#input = isInputStream(options?.input) ? options.input : node_process.stdin;
180
338
  this.#output = isOutputStream(options?.output) ? options.output : node_process.stdout;
339
+ this.#styler = (0, _orkestrel_console.createStyler)();
340
+ this.#theme = (0, _src_core.createPromptTheme)(options?.theme);
341
+ }
342
+ async ask(form) {
343
+ try {
344
+ this.#report(form, form.errors);
345
+ await this.#walk(form, form.schema.fields);
346
+ for (;;) {
347
+ if (form.status !== "editing") return await form.answer;
348
+ const result = form.submit();
349
+ if (result.success) return await form.answer;
350
+ this.#report(form, result.error);
351
+ const again = this.#editable(form, result.error);
352
+ if (again.length === 0 || this.#ended) {
353
+ form.destroy();
354
+ return await form.answer;
355
+ }
356
+ await this.#walk(form, again);
357
+ }
358
+ } finally {
359
+ this.#close();
360
+ }
361
+ }
362
+ /**
363
+ * Ask `fields` in the order given, skipping what the walk must not touch and rendering what it
364
+ * must not edit. Returns early the moment the form stops being editable, so an abandoned form
365
+ * ends the walk between fields as well as under an active read.
366
+ */
367
+ async #walk(form, fields) {
368
+ let group;
369
+ for (const field of fields) {
370
+ if (form.status !== "editing") return;
371
+ if (field.hidden === true) continue;
372
+ if (form.disabled.has(field.name)) continue;
373
+ if (field.group !== group) {
374
+ group = field.group;
375
+ if (group !== void 0) this.#group(form, group);
376
+ }
377
+ if (field.locked === true) {
378
+ this.#locked(form, field);
379
+ continue;
380
+ }
381
+ const raw = await this.#read(form, field);
382
+ if (form.status !== "editing") return;
383
+ this.#bind(form, field, raw);
384
+ }
385
+ }
386
+ /** Write a group's label as a section header, resolving the schema's declared label and falling back to the group's own name. */
387
+ #group(form, name) {
388
+ const label = form.schema.groups?.find((group) => group.name === name)?.label ?? name;
389
+ this.#output.write(`
390
+ ${groupHeader(this.#styler, this.#theme, (0, _src_core.sanitizeDisplayText)(label))}
391
+ `);
392
+ }
393
+ /** Render a locked field read-only — its label, its mark, and the answer the form already holds. */
394
+ #locked(form, field) {
395
+ const line = lockedLine(this.#styler, this.#theme, (0, _src_core.sanitizeDisplayText)(field.label ?? field.name), (0, _src_core.sanitizeDisplayText)(valueToText(form.values[field.name])));
396
+ this.#output.write(`${line}
397
+ `);
398
+ }
399
+ /** Read one field through the reducer its control names, resolving the raw answer the binding projects. */
400
+ #read(form, field) {
401
+ if (field.control === "password") return this.#password(form, field);
402
+ if (field.control === "confirm") return this.#confirm(form, field);
403
+ if (field.control === "editor") return this.#editor(form, field);
404
+ if (field.control === "select") return this.#select(form, field);
405
+ if (field.control === "checkbox") return this.#checkbox(form, field);
406
+ if (field.control === "file") return this.#file(form, field);
407
+ return this.#text(form, field);
181
408
  }
182
- input(options) {
183
- const state = (0, _src_core.createInputState)(options);
184
- if (rawCapable(this.#input)) return this.#drive(state, _src_core.inputReduce);
185
- return this.#lineFallback(options.message, state.styler, state.theme, void 0, (answer) => {
186
- const value = answer.length > 0 ? answer : options.default ?? "";
187
- return (0, _src_core.resolveValidation)(options.validate)(value) === true ? { value } : void 0;
188
- }, (answer) => answer.length > 0 ? answer : options.default ?? "");
189
- }
190
- password(options) {
191
- const state = (0, _src_core.createPasswordState)(options);
192
- if (rawCapable(this.#input)) return this.#drive(state, _src_core.passwordReduce);
193
- return this.#lineFallback(options.message, state.styler, state.theme, void 0, (answer) => (0, _src_core.resolveValidation)(options.validate)(answer) === true ? { value: answer } : void 0, (answer) => answer, true);
194
- }
195
- confirm(options) {
196
- const state = (0, _src_core.createConfirmState)(options);
197
- if (rawCapable(this.#input)) return this.#drive(state, _src_core.confirmReduce);
198
- return this.#lineFallback(options.message, state.styler, state.theme, state.hint, (answer) => {
199
- const normalized = answer.trim().toLowerCase();
200
- if (normalized.length === 0) return { value: options.default ?? false };
201
- if (normalized === "y" || normalized === "yes") return { value: true };
202
- if (normalized === "n" || normalized === "no") return { value: false };
203
- }, () => options.default ?? false);
204
- }
205
- select(options) {
206
- const state = (0, _src_core.createSelectState)(options);
207
- if (rawCapable(this.#input)) return this.#drive(state, _src_core.selectReduce);
208
- return this.#listFallback(options.message, state.styler, state.theme, state.choices, state.hint ?? "Enter a number", (line) => {
209
- const index = Number.parseInt(line.trim(), 10) - 1;
210
- const choice = state.choices[index];
211
- return choice === void 0 ? void 0 : { value: choice.value };
212
- }, "");
213
- }
214
- checkbox(options) {
215
- const state = (0, _src_core.createCheckboxState)(options);
216
- if (rawCapable(this.#input)) return this.#drive(state, _src_core.checkboxReduce);
217
- return this.#listFallback(options.message, state.styler, state.theme, state.choices, state.hint ?? "Enter numbers separated by commas", (line) => {
218
- const indices = line.split(",").map((part) => Number.parseInt(part.trim(), 10) - 1).filter((index) => index >= 0 && index < state.choices.length);
219
- if (options.min !== void 0 && indices.length < options.min) return void 0;
220
- if (options.max !== void 0 && indices.length > options.max) return void 0;
221
- return { value: indices.map((index) => state.choices[index]?.value).filter((value) => value !== void 0) };
222
- }, []);
223
- }
224
- editor(options) {
225
- const state = (0, _src_core.createEditorState)(options);
226
- if (rawCapable(this.#input)) return this.#drive(state, _src_core.editorReduce);
227
- return this.#editorFallback(state);
409
+ /**
410
+ * Bind one raw answer to the form — the single binding, and the only place this driver writes a
411
+ * value. `parseValue` coerces the raw answer to the control's own shape and `matchesAnswer`
412
+ * projects a blank one to absence, which is what keeps `required` refusing a bare return. A raw
413
+ * answer the control cannot hold binds as absence and invalidates the field, so the field comes
414
+ * back on the next pass carrying the reason rather than vanishing silently.
415
+ */
416
+ #bind(form, field, raw) {
417
+ form.touch(field.name);
418
+ const value = raw === void 0 ? void 0 : (0, _orkestrel_form.parseValue)(field, raw);
419
+ form.fill(field.name, (0, _orkestrel_form.matchesAnswer)(value) ? value : void 0);
420
+ if (value === void 0 && (0, _orkestrel_form.matchesAnswer)(raw)) form.invalidate(field.name, REFUSAL_MESSAGE);
421
+ }
422
+ /** The erroring fields the walk can ask again — every field the walk skips or renders read-only is excluded, because a second pass could not change its answer. */
423
+ #editable(form, errors) {
424
+ const fields = [];
425
+ for (const error of errors) {
426
+ const field = form.field(error.field);
427
+ if (field === void 0) continue;
428
+ if (field.hidden === true || field.locked === true) continue;
429
+ if (form.disabled.has(field.name)) continue;
430
+ if (fields.some((held) => held.name === field.name)) continue;
431
+ fields.push(field);
432
+ }
433
+ return fields;
434
+ }
435
+ /** Write every supplied failure against its field's label. */
436
+ #report(form, errors) {
437
+ for (const error of errors) {
438
+ const label = (0, _src_core.sanitizeDisplayText)(form.field(error.field)?.label ?? error.field);
439
+ const message = (0, _src_core.sanitizeDisplayText)(error.message);
440
+ const line = (0, _src_core.errorLine)(this.#styler, this.#theme, `${label}: ${message}`);
441
+ this.#output.write(`${line}
442
+ `);
443
+ }
444
+ }
445
+ /** Read a field as one line of text — `text` itself and the six controls a terminal has no widget for. */
446
+ #text(form, field) {
447
+ const state = (0, _src_core.createInputState)(fieldToText(field), this.#styler, this.#theme);
448
+ if (rawCapable(this.#input)) return this.#drive(form, state, _src_core.inputReduce);
449
+ return this.#line(form, state.message, state.default);
450
+ }
451
+ /** Read a secret — masked live in raw mode, and read without echo through readline on a stream that cannot enter it. */
452
+ #password(form, field) {
453
+ const state = (0, _src_core.createPasswordState)(field, this.#styler, this.#theme);
454
+ if (rawCapable(this.#input)) return this.#drive(form, state, _src_core.passwordReduce);
455
+ return this.#prompt(form, (0, _src_core.promptHeader)(this.#styler, this.#theme, state.message));
456
+ }
457
+ /**
458
+ * Read a yes or no. The fallback accepts `y` / `yes` / `n` / `no` in any case and takes the
459
+ * field's default for a bare line; anything else is returned as typed, so the binding refuses it
460
+ * and the walk asks again rather than silently reading it as no.
461
+ */
462
+ async #confirm(form, field) {
463
+ const state = (0, _src_core.createConfirmState)(field, this.#styler, this.#theme);
464
+ if (rawCapable(this.#input)) return this.#drive(form, state, _src_core.confirmReduce);
465
+ const header = (0, _src_core.hintedHeader)(this.#styler, this.#theme, state.message, FALLBACK_CONFIRM_HINT);
466
+ const line = await this.#prompt(form, header);
467
+ const answer = line.trim().toLowerCase();
468
+ if (answer.length === 0) return state.default;
469
+ if (answer === "y" || answer === "yes") return true;
470
+ if (answer === "n" || answer === "no") return false;
471
+ return line.trim();
472
+ }
473
+ /** Read text over many lines — ctrl-d finishes in raw mode, and end of input finishes on a piped stream. */
474
+ #editor(form, field) {
475
+ const state = (0, _src_core.createEditorState)(field, this.#styler, this.#theme);
476
+ if (rawCapable(this.#input)) return this.#drive(form, state, _src_core.editorReduce);
477
+ return this.#block(form, state.message, state.default);
478
+ }
479
+ /**
480
+ * Read one choice. A disabled choice is named above the list and never offered, because the form
481
+ * refuses its value at every door. An open select is a suggestion list plus a typed line, since
482
+ * `open` admits an answer the list does not offer; a closed select with nothing left to offer
483
+ * resolves absence and lets the form's own rules report it.
484
+ */
485
+ async #select(form, field) {
486
+ const choices = enabledChoices(field.choices);
487
+ this.#unavailable(field.choices);
488
+ if (field.open === true) {
489
+ if (choices.length > 0) {
490
+ const display = choices.map((choice) => ({
491
+ ...choice,
492
+ value: (0, _src_core.sanitizeDisplayText)(choice.value)
493
+ }));
494
+ this.#output.write(`${suggestionLine(this.#styler, this.#theme, display)}
495
+ `);
496
+ }
497
+ return this.#text(form, field);
498
+ }
499
+ if (choices.length === 0) return void 0;
500
+ const state = (0, _src_core.createSelectState)({
501
+ ...field,
502
+ choices
503
+ }, this.#styler, this.#theme);
504
+ if (rawCapable(this.#input)) return this.#drive(form, state, _src_core.selectReduce);
505
+ this.#list(state.message, choices);
506
+ const line = await this.#prompt(form, this.#hint(`${FALLBACK_SELECT_HINT}:`));
507
+ return choices[Number.parseInt(line.trim(), 10) - 1]?.value;
508
+ }
509
+ /**
510
+ * Read any number of choices. Disabled choices are named above the list and never offered, so a
511
+ * box the form would refuse can never be ticked. An empty answer is an answered "none of them",
512
+ * which is what `matchesAnswer` says an empty list means.
513
+ */
514
+ async #checkbox(form, field) {
515
+ const choices = enabledChoices(field.choices);
516
+ this.#unavailable(field.choices);
517
+ const state = (0, _src_core.createCheckboxState)({
518
+ ...field,
519
+ choices
520
+ }, this.#styler, this.#theme);
521
+ if (rawCapable(this.#input)) return this.#drive(form, state, _src_core.checkboxReduce);
522
+ this.#list(state.message, choices);
523
+ return (await this.#prompt(form, this.#hint(`${FALLBACK_CHECKBOX_HINT}:`))).split(",").map((part) => choices[Number.parseInt(part.trim(), 10) - 1]?.value).filter((value) => value !== void 0);
524
+ }
525
+ /**
526
+ * Read file paths — names only, because bytes never enter a form. A `multiple` field collects one
527
+ * path per line until a blank one, and a single field takes one. No path at all is absence rather
528
+ * than an empty list, because the reader answered a blank line.
529
+ */
530
+ async #file(form, field) {
531
+ if (field.multiple === true) this.#output.write(`${this.#hint(FILE_HINT)}
532
+ `);
533
+ const paths = [];
534
+ for (;;) {
535
+ const entry = await this.#text(form, field);
536
+ if (entry.length === 0) break;
537
+ paths.push(entry);
538
+ if (field.multiple !== true || this.#ended) break;
539
+ }
540
+ return paths.length > 0 ? paths : void 0;
541
+ }
542
+ /** Name the choices a field shows but refuses, above the list the walk drives. */
543
+ #unavailable(choices) {
544
+ const refused = disabledChoices(choices);
545
+ if (refused.length === 0) return;
546
+ this.#output.write(`${unavailableLine(this.#styler, this.#theme, refused)}
547
+ `);
548
+ }
549
+ /** Write a field's header above its numbered choice list — the non-TTY presentation of a choice field. */
550
+ #list(message, choices) {
551
+ const header = (0, _src_core.promptHeader)(this.#styler, this.#theme, message);
552
+ const list = numberedList(this.#styler, this.#theme, choices);
553
+ this.#output.write(`${header}
554
+ ${list}
555
+ `);
556
+ }
557
+ /** Paint one line of supplementary instruction through the `hint` role. */
558
+ #hint(text) {
559
+ return this.#styler.render(this.#theme.roles.hint, text);
228
560
  }
229
561
  /**
230
562
  * The irreducible Node raw-mode primitive — the ONLY place raw mode is touched. Switches the input
231
563
  * into raw mode (each keypress delivered immediately, no echo), resumes its flow, and subscribes
232
564
  * `handler` to `'data'`. The paired {@link #leaveRaw} operation unsubscribes the exact handler,
233
- * leaves raw mode, and pauses the stream on submit, cancel, or throw.
565
+ * leaves raw mode, and pauses the stream on submit, cancel, abandon, or throw.
234
566
  */
235
567
  #enterRaw(token, handler) {
236
568
  this.#handlers.set(token, handler);
@@ -247,21 +579,20 @@ var Terminal = class {
247
579
  this.#input.pause?.();
248
580
  }
249
581
  /**
250
- * Drive ONE interactive prompt over raw-mode stdin — the generic engine all six TTY prompts share.
251
- * Renders the reducer's initial `view`, enters raw mode once, and on each keypress runs `parseKey`
252
- * → `reduce` → an in-place re-render; on `submit` it cleans up + resolves the reducer's `value`, on
253
- * `cancel` (ctrl-c) it cleans up + rejects a {@link TerminalError} (`CANCEL`). Raw mode is entered
254
- * exactly once and cleaned up on every exit path (submit / cancel / a throw inside a step), so no
255
- * raw mode and no `'data'` listener ever leak. The cursor is hidden for the duration and restored
256
- * on exit.
582
+ * Drive ONE field over raw-mode stdin — the generic engine every interactive control shares.
583
+ * Renders the reducer's initial view, enters raw mode once, and on each keypress runs `parseKey` →
584
+ * `reduce` → an in-place re-render; on `submit` it cleans up and resolves the reducer's value, on
585
+ * `cancel` (ctrl-c) it cleans up and rejects a {@link TerminalError} coded `CANCEL`. Abandoning
586
+ * the form ends the read too, through the rejection of its own `answer`. Raw mode is entered
587
+ * exactly once and cleaned up on every exit path, so no raw mode and no `'data'` listener ever
588
+ * leaks. The cursor is hidden for the duration and restored on exit.
257
589
  */
258
- #drive(initial, reduce) {
590
+ #drive(form, initial, reduce) {
259
591
  return new Promise((resolve, reject) => {
260
- const state = initial;
261
592
  this.#output.write(CURSOR_HIDE);
262
593
  let firstView;
263
594
  try {
264
- firstView = reduce(state, (0, _src_core.parseKey)("")).view;
595
+ firstView = reduce(initial, (0, _src_core.parseKey)("")).view;
265
596
  this.#output.write(firstView);
266
597
  } catch (error) {
267
598
  this.#output.write(`${CURSOR_SHOW}
@@ -270,8 +601,9 @@ var Terminal = class {
270
601
  return;
271
602
  }
272
603
  const token = {};
273
- const handler = this.#createHandler(token, state, lineCount(firstView), reduce, resolve, reject);
604
+ const handler = this.#createHandler(token, initial, lineCount(firstView), reduce, resolve, reject);
274
605
  this.#enterRaw(token, handler);
606
+ form.answer.catch((error) => this.#interrupt(token, reject, error));
275
607
  });
276
608
  }
277
609
  #createHandler(token, initial, initialLines, reduce, resolve, reject) {
@@ -301,163 +633,168 @@ var Terminal = class {
301
633
  }
302
634
  };
303
635
  }
304
- /** Redraw a prompt view in place — climb over the previous view's `previousLines`, clear, and write the new view (the pure cursor-math is {@link redrawPrefix}). */
636
+ /** End an active read that the form outlived — release raw mode exactly as a submit does, then fail the read with the form's own error. */
637
+ #interrupt(token, reject, error) {
638
+ if (!this.#handlers.has(token)) return;
639
+ this.#leaveRaw(token);
640
+ this.#output.write(`${CURSOR_SHOW}
641
+ `);
642
+ reject(error);
643
+ }
644
+ /** Redraw a field view in place — climb over the previous view's `previousLines`, clear, and write the new view (the pure cursor-math is {@link redrawPrefix}). */
305
645
  #render(view, previousLines) {
306
646
  this.#output.write(`${redrawPrefix(previousLines)}${view}`);
307
647
  }
648
+ /** Read one line for a text-shaped field, taking the field's default when the line is bare. */
649
+ async #line(form, message, seed) {
650
+ const answer = await this.#prompt(form, (0, _src_core.promptHeader)(this.#styler, this.#theme, message));
651
+ return answer.length > 0 ? answer : seed;
652
+ }
308
653
  /**
309
- * Read a single line via `node:readline` and accept it through `take` — the non-TTY line-input
310
- * fallback shared by `input` / `password` / `confirm`. Re-prompts until `take` returns a value (so
311
- * validation still gates), writing the prompt header each round. A piped stream cannot enter raw
312
- * mode, so there is no masking / live edit — just a validated line read.
313
- *
314
- * @remarks
315
- * The re-prompt loop is bounded by end-of-input: once the stream reaches EOF (a piped stream that
316
- * ran out, or one with no trailing newline) it can never deliver another line, so re-prompting
317
- * would SPIN. On EOF the loop accepts the final line through `take` if it passes, else returns the
318
- * caller's `eof` fallback (the default / empty value) — the prompt always settles, never spins.
654
+ * Read a whole block for an `editor` field — a piped stream has no ctrl-d keypress, so end of
655
+ * input is the terminator. It drains every remaining line, which is why nothing after an `editor`
656
+ * field can be asked on the same stream.
319
657
  */
320
- async #lineFallback(message, styler, theme, hint, take, eof, masked = false) {
658
+ async #block(form, message, seed) {
659
+ const header = (0, _src_core.hintedHeader)(this.#styler, this.#theme, message, FALLBACK_EDITOR_HINT);
660
+ this.#output.write(`${header}
661
+ `);
662
+ const collected = [];
321
663
  for (;;) {
322
- const { answer, ended } = await this.#question(`${(0, _src_core.hintedHeader)(styler, theme, message, hint)} `, masked);
323
- const accepted = take(answer);
324
- if (accepted !== void 0) return accepted.value;
325
- if (ended) return eof(answer);
664
+ const line = await this.#next(form);
665
+ if (line === void 0) break;
666
+ collected.push(line);
326
667
  }
668
+ const text = collected.join("\n");
669
+ return text.length > 0 ? text : seed;
670
+ }
671
+ /** Write one field's header and read back the line the reader answers it with, or `''` once the stream has ended. */
672
+ async #prompt(form, header) {
673
+ this.#output.write(`${header} `);
674
+ return await this.#next(form) ?? "";
327
675
  }
328
676
  /**
329
- * Print a numbered choice list, then read one readline line and accept it through `take` — the
330
- * non-TTY fallback for `select` / `checkbox`. The list is rendered once; the user types the
331
- * number(s); `take` parses + gates the line, re-prompting until it returns a value. Each index is
332
- * painted by the `muted` role and each choice name by the `content` role.
677
+ * Take the next line the input carries — from the buffer when the reader has already read ahead,
678
+ * and otherwise by waiting for one. It resolves ABSENCE once the stream has ended, so a walk over
679
+ * an exhausted stream settles instead of waiting forever, and it rejects when the form is
680
+ * abandoned, so an unanswerable read ends with the form rather than outliving it.
333
681
  */
334
- async #listFallback(message, styler, theme, choices, hint, take, eof) {
335
- let list = `${(0, _src_core.promptHeader)(styler, theme, message)}\n`;
336
- choices.forEach((choice, index) => {
337
- list += ` ${styler.render(theme.roles.muted, `${String(index + 1)})`)} ${styler.render(theme.roles.content, choice.name)}\n`;
682
+ #next(form) {
683
+ const buffered = this.#queue.shift();
684
+ if (buffered !== void 0) return Promise.resolve(buffered);
685
+ if (this.#ended) return Promise.resolve(void 0);
686
+ this.#reader();
687
+ return new Promise((resolve, reject) => {
688
+ this.#taker = resolve;
689
+ form.answer.catch((error) => {
690
+ if (this.#taker !== resolve) return;
691
+ this.#taker = void 0;
692
+ reject(error);
693
+ });
338
694
  });
339
- this.#output.write(list);
340
- for (;;) {
341
- const { answer, ended } = await this.#question(`${styler.render(theme.roles.hint, `${hint}:`)} `);
342
- const accepted = take(answer);
343
- if (accepted !== void 0) return accepted.value;
344
- if (ended) return eof;
345
- }
346
695
  }
347
696
  /**
348
- * The non-TTY `editor` fallback — read lines until EOF (the readline `close`), join them, and fall
349
- * back to the default when empty. A piped stream has no ctrl-d keypress, so end-of-input is the
350
- * natural terminator.
351
- *
352
- * @remarks
353
- * Single-pass by necessity: `#lines` drains the whole stream to EOF in one read, so there is no
354
- * second block to re-prompt for (re-reading an exhausted stream returns nothing forever). Validation
355
- * is still applied; on a validation FAILURE the best-effort block is returned rather than spinning
356
- * on the consumed stream — the EOF analogue of the raw-mode editor's re-edit, which a piped stream
357
- * cannot offer.
697
+ * Open the walk's ONE readline interface, or keep the open one. A whole form is many questions
698
+ * over one stream, and an interface reads ahead: a fresh interface per question would swallow
699
+ * every line it read past the one it was asked for, so the walk holds a single reader and buffers
700
+ * what arrives early. It is closed when the walk ends, so the process is free to exit.
358
701
  */
359
- async #editorFallback(state) {
360
- this.#output.write(`${(0, _src_core.hintedHeader)(state.styler, state.theme, state.message, state.hint ?? "(EOF to finish)")}\n`);
361
- const text = await this.#lines();
362
- return text.length > 0 ? text : state.default;
702
+ #reader() {
703
+ if (this.#interface !== void 0) return;
704
+ const rl = (0, node_readline.createInterface)(this.#readline());
705
+ rl.on("line", (line) => this.#accept(line));
706
+ rl.on("close", () => this.#finish());
707
+ this.#interface = rl;
363
708
  }
364
- /**
365
- * Ask one readline question on the resolved streams and resolve the typed (un-trimmed) line plus
366
- * whether the stream ENDED. EOF (the readline `close`) before `rl.question`'s callback fires
367
- * resolves instead of hanging — a piped stream commonly ends WITHOUT a trailing newline (or is
368
- * empty), and the `question` callback only fires on a NEWLINE-terminated line, so without this the
369
- * prompt would wait forever. The trailing unterminated line is still recovered: readline emits it
370
- * as a `'line'` event just before `'close'`, so the last seen line (or `''` for a truly empty
371
- * stream) is returned with `ended: true`. The `ended` flag lets the fallback loops settle rather
372
- * than re-prompt an exhausted stream (which would SPIN). Settling is one-shot (a `close` after a
373
- * delivered line is ignored, so a normal newline-terminated line reports `ended: false`).
374
- */
375
- #question(prompt, masked = false) {
376
- const rl = (0, node_readline.createInterface)(this.#readline(masked));
377
- return new Promise((resolve) => {
378
- let last = "";
379
- const settle = this.#createQuestionSettler(rl, resolve);
380
- rl.on("line", (line) => {
381
- last = line;
382
- });
383
- rl.question(prompt, (answer) => settle(answer, false));
384
- rl.on("close", () => settle(last, true));
385
- });
709
+ /** Hand a line to whoever is waiting for it, or buffer it for the next question. */
710
+ #accept(line) {
711
+ const taker = this.#taker;
712
+ if (taker === void 0) {
713
+ this.#queue.push(line);
714
+ return;
715
+ }
716
+ this.#taker = void 0;
717
+ taker(line);
386
718
  }
387
- #createQuestionSettler(rl, resolve) {
388
- let settled = false;
389
- return (answer, ended) => {
390
- if (settled) return;
391
- settled = true;
392
- rl.close();
393
- resolve({
394
- answer,
395
- ended
396
- });
397
- };
719
+ /** Record that no further line can arrive and release whoever was waiting for one. */
720
+ #finish() {
721
+ this.#ended = true;
722
+ const taker = this.#taker;
723
+ if (taker === void 0) return;
724
+ this.#taker = void 0;
725
+ taker(void 0);
398
726
  }
399
- /** Read every line from the input until EOF and resolve them joined by newlines (the editor fallback's reader). */
400
- #lines() {
401
- const rl = (0, node_readline.createInterface)(this.#readline());
402
- const collected = [];
403
- return new Promise((resolve) => {
404
- rl.on("line", (line) => collected.push(line));
405
- rl.on("close", () => resolve(collected.join("\n")));
406
- });
727
+ /** Close the walk's reader and release a waiting question — the walk is over, so the stream must stop holding the process open. */
728
+ #close() {
729
+ const taker = this.#taker;
730
+ this.#taker = void 0;
731
+ if (taker !== void 0) taker(void 0);
732
+ const rl = this.#interface;
733
+ if (rl === void 0) return;
734
+ this.#interface = void 0;
735
+ rl.removeAllListeners("close");
736
+ rl.close();
407
737
  }
408
738
  /**
409
- * Narrow the resolved streams to the `node:readline` `createInterface` boundary (§14, never an
410
- * `as`). The non-TTY fallback only runs on a real piped `process.stdin` (or a `PassThrough` a test
411
- * injects), both genuine readables; a minimal non-readable fake reaching here means the fallback
412
- * was driven with a stream it cannot use, which fails loudly rather than silently.
739
+ * Narrow the resolved input to the `node:readline` `createInterface` boundary, never an assertion.
740
+ * The fallback only runs on a real piped `process.stdin` (or a `PassThrough` a test injects), both
741
+ * genuine readables; a minimal non-readable fake reaching here means the walk was driven with a
742
+ * stream it cannot use, which fails loudly rather than silently. `terminal: false` leaves readline
743
+ * as a line decoder and nothing else: the walk writes every prompt itself, through the same output
744
+ * every other line goes to, so nothing is written twice and a secret is never echoed.
413
745
  */
414
- #readline(masked = false) {
746
+ #readline() {
415
747
  const input = this.#input;
416
- const output = this.#output;
417
748
  if (!isReadable(input)) throw new _src_core.TerminalError("DRIVER", "Terminal fallback requires a readable input stream");
418
749
  return {
419
750
  input,
420
- ...isWritable(output) ? { output } : {},
421
- ...masked ? { terminal: false } : {}
751
+ terminal: false
422
752
  };
423
753
  }
424
754
  };
425
755
  //#endregion
426
756
  //#region src/server/factories.ts
427
757
  /**
428
- * Create the interactive terminal prompt {@link TerminalInterface} (T-c) — the local-TTY arm of the
429
- * prompt tri-surface, the env-symmetric sibling of the core headless `createPrompt` broker and the
430
- * SSE `createPromptClient` bridge. A `Terminal` answers each prompt LOCALLY at this machine's
431
- * keyboard: it reads raw-mode stdin, drives the pure core `*Reduce` reducers, renders each `view` in
432
- * place, and resolves on submit / rejects with a {@link import('@src/core').TerminalError} (`CANCEL`)
433
- * on ctrl-c. It is the ONLY impure part of the prompt stack.
758
+ * Create the interactive terminal form driver — the local-keyboard arm of the terminal trio, beside
759
+ * the core headless `createPrompt` broker and the SSE `createPromptClient` bridge. Where the broker
760
+ * PARKS a live form until somebody elsewhere answers it, a `Terminal` answers one HERE: it walks the
761
+ * form's fields in schema order, drives each control's pure reducer over raw-mode stdin, binds every
762
+ * answer through the form's own `fill`, and submits. It is the only impure part of the terminal
763
+ * stack.
434
764
  *
435
765
  * @param options - See {@link TerminalOptions}
436
- * @returns A {@link TerminalInterface} — the six async prompt forms (`input` / `password` / `confirm`
437
- * / `select` / `checkbox` / `editor`) driven over the resolved streams
766
+ * @returns A {@link TerminalInterface} whose `ask` drives one whole form over the resolved streams
438
767
  *
439
768
  * @remarks
440
- * - **Drives the pure reducers.** Each prompt builds its initial state (`create*State`), enters raw
441
- * mode ONCE, and feeds each keypress through `parseKey` → the reducer → an in-place re-render; the
442
- * driver owns no prompt logic itself (state / view / validation / cancel all come from the core).
443
- * - **Raw-mode leak-free.** Raw mode is entered exactly once per prompt and ALWAYS cleaned up — on
444
- * submit, on cancel, and on a throw — leaving no raw mode and no leaked `'data'` listener.
445
- * - **Injectable + guard-narrowed.** `options.input` / `options.output` default to `process.stdin` /
446
- * `process.stdout` but accept ANY {@link import('./types.js').InputStreamInterface} /
447
- * {@link import('./types.js').OutputStreamInterface}, resolved through their §14 guards (never an
448
- * `as`), so a test drives every prompt with a fake TTY that emits scripted key chunks and records
449
- * the rendered output — and asserts the resolved value, cancel-on-ctrl-c, and no leaked raw mode.
450
- * - **Non-TTY fallback.** When `input` is not a TTY (piped), raw mode is unavailable, so the prompts
451
- * fall back to `node:readline` line input (still validating); `select` / `checkbox` present a
452
- * numbered list, and `editor` reads lines until EOF.
769
+ * - **The form is the unit.** `ask` takes the caller's live form and returns its settled values. The
770
+ * returned promise is that form's own `answer`, so a caller holding the form can await either one.
771
+ * - **Every control renders.** Seven controls are read as a line of text with their format cue,
772
+ * `password` masks, `confirm` takes a key, `editor` takes a block, `select` and `checkbox` drive a
773
+ * list, and an open `select` accepts a value its list does not offer.
774
+ * - **The form decides.** A blank answer binds as absence, the form evaluates, and a refusal
775
+ * re-walks only the fields the walk can still edit.
776
+ * - **Injectable and guard-narrowed.** `input` and `output` default to `process.stdin` and
777
+ * `process.stdout` but accept any stream of the declared minimal shape, resolved through their
778
+ * guards rather than an assertion, so a test drives a whole form with a fake TTY that emits
779
+ * scripted key chunks and records every rendered byte.
780
+ * - **Non-TTY fallback.** A piped stream cannot enter raw mode, so the same walk runs over
781
+ * `node:readline` line input.
453
782
  *
454
783
  * @example
455
784
  * ```ts
456
- * import { createTerminal } from '@src/server'
785
+ * import { createForm } from '@orkestrel/form'
786
+ * import { createTerminal } from '@orkestrel/terminal/server'
457
787
  *
458
788
  * const terminal = createTerminal()
459
- * const name = await terminal.input({ message: 'Your name' })
460
- * const proceed = await terminal.confirm({ message: 'Continue?', default: true })
789
+ * const values = await terminal.ask(
790
+ * createForm({
791
+ * label: 'Sign up',
792
+ * fields: [
793
+ * { control: 'text', name: 'email', label: 'Email', rule: { required: true, email: true } },
794
+ * { control: 'confirm', name: 'terms', label: 'I accept the terms' },
795
+ * ],
796
+ * }),
797
+ * )
461
798
  * ```
462
799
  */
463
800
  function createTerminal(options) {
@@ -466,23 +803,39 @@ function createTerminal(options) {
466
803
  //#endregion
467
804
  exports.CARRIAGE_RETURN = CARRIAGE_RETURN;
468
805
  exports.CLEAR_DOWN = CLEAR_DOWN;
806
+ exports.CONTROL_HINTS = CONTROL_HINTS;
469
807
  exports.CSI = CSI;
470
808
  exports.CSI_UP = CSI_UP;
471
809
  exports.CURSOR_HIDE = CURSOR_HIDE;
472
810
  exports.CURSOR_SHOW = CURSOR_SHOW;
473
811
  exports.ESCAPE = ESCAPE;
474
812
  exports.FALLBACK_CHECKBOX_HINT = FALLBACK_CHECKBOX_HINT;
813
+ exports.FALLBACK_CONFIRM_HINT = FALLBACK_CONFIRM_HINT;
814
+ exports.FALLBACK_EDITOR_HINT = FALLBACK_EDITOR_HINT;
475
815
  exports.FALLBACK_SELECT_HINT = FALLBACK_SELECT_HINT;
816
+ exports.FILE_HINT = FILE_HINT;
476
817
  exports.LINE_FEED = LINE_FEED;
818
+ exports.LOCKED_MARK = LOCKED_MARK;
819
+ exports.REFUSAL_MESSAGE = REFUSAL_MESSAGE;
820
+ exports.SUGGESTION_LEAD = SUGGESTION_LEAD;
477
821
  exports.Terminal = Terminal;
822
+ exports.UNAVAILABLE_LEAD = UNAVAILABLE_LEAD;
478
823
  exports.createTerminal = createTerminal;
824
+ exports.disabledChoices = disabledChoices;
825
+ exports.enabledChoices = enabledChoices;
826
+ exports.fieldToText = fieldToText;
827
+ exports.groupHeader = groupHeader;
479
828
  exports.isInputStream = isInputStream;
480
829
  exports.isOutputStream = isOutputStream;
481
830
  exports.isReadable = isReadable;
482
- exports.isWritable = isWritable;
483
831
  exports.lineCount = lineCount;
832
+ exports.lockedLine = lockedLine;
484
833
  exports.moveUp = moveUp;
834
+ exports.numberedList = numberedList;
485
835
  exports.rawCapable = rawCapable;
486
836
  exports.redrawPrefix = redrawPrefix;
837
+ exports.suggestionLine = suggestionLine;
838
+ exports.unavailableLine = unavailableLine;
839
+ exports.valueToText = valueToText;
487
840
 
488
841
  //# sourceMappingURL=index.cjs.map