@jacebenson/jsn 5.5.7 → 5.5.8-dev.220.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +16 -1
  2. package/package.json +5 -6
  3. package/skills/servicenow/SKILL.md +9 -1
  4. package/src/app.js +4 -79
  5. package/src/auth/credential-store.js +33 -8
  6. package/src/auth/windows-credential-store.js +85 -0
  7. package/src/auth/windows-credential-store.ps1 +163 -0
  8. package/src/bounded-reads.js +13 -0
  9. package/src/capabilities.js +8 -3
  10. package/src/cli-adapter.js +26 -3
  11. package/src/cli.js +13 -14
  12. package/src/command-families.js +68 -0
  13. package/src/commands/_generic.js +1 -0
  14. package/src/commands/_ticket.js +1 -1
  15. package/src/commands/actions.js +9 -4
  16. package/src/commands/approvals.js +1 -1
  17. package/src/commands/atf.js +1 -1
  18. package/src/commands/attachments.js +1 -1
  19. package/src/commands/auth.js +21 -2
  20. package/src/commands/codesearch.js +11 -2
  21. package/src/commands/compare.js +22 -0
  22. package/src/commands/customizations.js +3 -4
  23. package/src/commands/decisiontables.js +4 -0
  24. package/src/commands/docs/docs.js +5 -5
  25. package/src/commands/domains.js +1 -1
  26. package/src/commands/eval.js +11 -5
  27. package/src/commands/flows.js +24 -7
  28. package/src/commands/groupmembers.js +1 -1
  29. package/src/commands/grouproles.js +1 -1
  30. package/src/commands/groups.js +1 -1
  31. package/src/commands/midservers.js +4 -11
  32. package/src/commands/perf.js +2 -3
  33. package/src/commands/plugins.js +9 -0
  34. package/src/commands/records.js +12 -2
  35. package/src/commands/scopes.js +1 -1
  36. package/src/commands/scrapi.js +2 -2
  37. package/src/commands/setup.js +4 -34
  38. package/src/commands/skipped-updates.js +2 -3
  39. package/src/commands/store.js +4 -1
  40. package/src/commands/subscriptions.js +47 -0
  41. package/src/commands/tickets.js +1 -1
  42. package/src/commands/users.js +1 -1
  43. package/src/commands/workflows.js +3 -5
  44. package/src/config.js +1 -0
  45. package/src/context.js +8 -56
  46. package/src/docs-links.js +28 -0
  47. package/src/flow-create.js +9 -0
  48. package/src/help.js +4 -0
  49. package/src/helpers.js +17 -24
  50. package/src/instance-inventory.js +184 -0
  51. package/src/intended-context.js +68 -0
  52. package/src/mutation-context.js +69 -46
  53. package/src/output.js +1 -1
  54. package/src/paginated-search.js +146 -178
  55. package/src/picker-ui.js +20 -0
  56. package/src/prompt-engine.js +176 -0
  57. package/src/prompts.js +293 -43
  58. package/src/records/inspect.js +30 -16
  59. package/src/records-engine.js +2 -2
  60. package/src/schedule-cache.js +96 -0
  61. package/src/schedules/itom-2026-04-09.json +121 -0
  62. package/src/schedules/public-inventory.json +6224 -0
  63. package/src/sdk-batch.js +2 -1
  64. package/src/sdk.js +42 -16
  65. package/src/setup-preferences.js +2 -2
  66. package/src/subscriptions.js +176 -0
@@ -1,195 +1,163 @@
1
1
  /**
2
- * Paginated search prompt built with @inquirer/core hooks.
2
+ * Paginated, searchable record picker built on src/prompt-engine.js.
3
+ *
4
+ * Contract (unchanged from the Inquirer version):
5
+ * paginatedSearch({ message, pageSize, totalCount, source }, context?)
6
+ * source(term, offset, { signal }) -> [{ name, value }]
7
+ * Enter resolves the active choice object; Escape resolves undefined.
8
+ * Down at the last loaded row loads more while loaded < totalCount;
9
+ * a null totalCount is unknown and continues until a successful empty page.
3
10
  */
4
11
 
5
-
6
- export const paginatedSearch = async (...args) => {
7
- const { createPrompt, useState, useKeypress, usePagination, useEffect, useRef, isEnterKey, isUpKey, isDownKey } = await import('@inquirer/core');
8
- return createPrompt((config, done) => {
9
- const { message, pageSize = 10, totalCount = 0, source } = config;
10
-
11
- const [status, setStatus] = useState('loading');
12
- const [searchTerm, setSearchTerm] = useState('');
13
- const [choices, setChoices] = useState([]);
14
- const [active, setActive] = useState(0);
15
- const [loaded, setLoaded] = useState(0);
16
- const [searchMode, setSearchMode] = useState(false);
17
-
18
- // Refs for mutable state (no functional updaters — @inquirer/core doesn't support them)
19
- const choicesRef = useRef([]);
20
- const loadedRef = useRef(0);
21
- const activeRef = useRef(0);
22
- const totalCountRef = useRef(totalCount);
23
- const searchModeRef = useRef(false);
24
-
25
- const fullMessage = totalCount > 0
26
- ? `${message} (${loaded} of ${totalCount} loaded)`
27
- : message;
28
-
29
- // Load initial page
30
- useEffect(() => {
31
- const controller = new AbortController();
32
- setStatus('loading');
33
-
34
- const load = async () => {
35
- try {
36
- const items = await source(searchTerm || undefined, 0, { signal: controller.signal });
37
- if (!controller.signal.aborted) {
38
- choicesRef.current = items;
39
- loadedRef.current = items.length;
40
- activeRef.current = 0;
41
- setChoices(items);
42
- setLoaded(items.length);
43
- setActive(0);
44
- setStatus('done');
45
- }
46
- } catch {
47
- if (!controller.signal.aborted) {
48
- setStatus('done');
49
- setChoices([]);
50
- setLoaded(0);
51
- }
52
- }
53
- };
54
- load();
55
- return () => controller.abort();
56
- }, []);
57
-
58
- // Load more when scrolling past end
59
- async function loadMore() {
60
- if (loadedRef.current >= totalCountRef.current || searchModeRef.current) return;
61
- setStatus('loading');
62
- try {
63
- const newItems = await source('', loadedRef.current, { signal: new AbortController().signal });
64
- const updated = choicesRef.current.concat(newItems);
65
- choicesRef.current = updated;
66
- loadedRef.current = updated.length;
67
- setChoices([...updated]);
68
- setLoaded(updated.length);
69
- } catch (err) {
70
- console.error('Scroll load error:', err.message || err);
71
- loadedRef.current = totalCountRef.current;
72
- setLoaded(totalCountRef.current);
12
+ import { pickerRows, pickerFooter } from './picker-ui.js';
13
+ import { runPrompt, normalizeChoices, escapeResult } from './prompt-engine.js';
14
+
15
+ export const paginatedSearch = async (config = {}, context = {}) => {
16
+ const { message, pageSize = 10, totalCount = 0, source } = config;
17
+ let request;
18
+ const state = {
19
+ status: 'loading',
20
+ term: '',
21
+ choices: [],
22
+ active: 0,
23
+ loaded: 0,
24
+ searchMode: false,
25
+ token: 0,
26
+ error: '',
27
+ };
28
+
29
+ const canLoadMore = () => !state.searchMode && !state.exhausted
30
+ && (totalCount == null || state.loaded < totalCount);
31
+
32
+ // Every request gets a token. A response may only be applied while its
33
+ // token is still current, so a stale (slower) search can never replace
34
+ // newer results or be selected by a later Enter.
35
+ const isCurrent = token => token === state.token && state.status !== 'cancelled';
36
+
37
+ async function load(term, offset, { append = false } = {}) {
38
+ request?.abort();
39
+ request = new AbortController();
40
+ const signal = context.signal ? AbortSignal.any([request.signal, context.signal]) : request.signal;
41
+ const token = ++state.token;
42
+ state.status = 'loading';
43
+ state.error = '';
44
+ try {
45
+ const items = normalizeChoices(await source(term || undefined, offset, { signal }) || []);
46
+ if (!isCurrent(token)) return;
47
+ state.choices = append ? state.choices.concat(items) : items;
48
+ state.loaded = state.choices.length;
49
+ state.exhausted = items.length === 0;
50
+ state.active = Math.min(state.active, Math.max(0, state.choices.length - 1));
51
+ state.status = 'done';
52
+ } catch (error) {
53
+ if (!isCurrent(token)) return;
54
+ state.status = 'done';
55
+ state.error = error?.message || String(error);
56
+ if (!append) {
57
+ state.choices = [];
58
+ state.loaded = 0;
73
59
  }
74
- setStatus('done');
60
+ // A failed load-more keeps the rows already on screen.
75
61
  }
76
-
77
- // Search when term changes
78
- useEffect(() => {
79
- if (!searchTerm) {
80
- setSearchMode(false);
81
- searchModeRef.current = false;
82
- const controller = new AbortController();
83
- setStatus('loading');
84
- source('', 0, { signal: controller.signal }).then(items => {
85
- if (!controller.signal.aborted) {
86
- choicesRef.current = items;
87
- loadedRef.current = Math.min(items.length, totalCount || Infinity);
88
- activeRef.current = 0;
89
- setChoices(items);
90
- setLoaded(items.length);
91
- setActive(0);
92
- setStatus('done');
93
- }
94
- }).catch(() => {
95
- if (!controller.signal.aborted) setStatus('done');
96
- });
97
- return () => controller.abort();
98
- }
99
-
100
- const controller = new AbortController();
101
- setStatus('loading');
102
- setSearchMode(true);
103
- searchModeRef.current = true;
104
-
105
- source(searchTerm, undefined, { signal: controller.signal }).then(items => {
106
- if (!controller.signal.aborted) {
107
- choicesRef.current = items;
108
- loadedRef.current = items.length;
109
- activeRef.current = 0;
110
- setChoices(items);
111
- setLoaded(items.length);
112
- setActive(0);
113
- setStatus('done');
114
- }
115
- }).catch(() => {
116
- if (!controller.signal.aborted) {
117
- setStatus('done');
118
- setChoices([]);
119
- }
62
+ }
63
+
64
+ let api;
65
+ const prompt = runPrompt({ ...config, message }, context, {
66
+ escapeValue: escapeResult(undefined),
67
+ init() {
68
+ // Kick off the first page. Enter is ignored while status is 'loading',
69
+ // so nothing is selectable until this resolves.
70
+ state.pending = load('', 0);
71
+ return state;
72
+ },
73
+ onReady(handle) {
74
+ api = handle;
75
+ state.pending.then(() => {
76
+ if (state.status !== 'cancelled') api.redraw();
120
77
  });
121
-
122
- return () => controller.abort();
123
- }, [searchTerm]);
124
-
125
- // Key handling
126
- useKeypress((key, rl) => {
127
- if (status === 'loading') return;
128
-
129
- if (isEnterKey(key)) {
130
- if (choicesRef.current.length > 0 && activeRef.current >= 0 && activeRef.current < choicesRef.current.length) {
131
- done(choicesRef.current[activeRef.current]);
132
- }
133
- return;
78
+ },
79
+ key(_state, key, handle) {
80
+ api = handle;
81
+ if (key.name === 'return' || key.name === 'enter') {
82
+ // No selecting a row while a request is in flight: the list on
83
+ // screen may be about to change.
84
+ if (state.status === 'loading' || !state.choices.length) return;
85
+ const choice = state.choices[state.active];
86
+ if (!choice || choice.disabled) return;
87
+ return { done: choice };
134
88
  }
135
-
136
- if (key.name === 'escape') {
137
- done(undefined);
89
+ if (key.name === 'up') {
90
+ if (state.active > 0) state.active -= 1;
91
+ api?.redraw();
138
92
  return;
139
93
  }
140
-
141
- if (isUpKey(key)) {
142
- if (activeRef.current > 0) {
143
- activeRef.current--;
144
- setActive(activeRef.current);
145
- }
146
- return;
147
- }
148
-
149
- if (isDownKey(key)) {
150
- if (activeRef.current < choicesRef.current.length - 1) {
151
- activeRef.current++;
152
- setActive(activeRef.current);
153
- } else if (!searchModeRef.current && loadedRef.current < totalCountRef.current) {
154
- loadMore().then(() => {
155
- activeRef.current++;
156
- setActive(activeRef.current);
94
+ if (key.name === 'down') {
95
+ if (state.status === 'loading') return;
96
+ if (state.active < state.choices.length - 1) {
97
+ state.active += 1;
98
+ api?.redraw();
99
+ } else if (canLoadMore()) {
100
+ const before = state.loaded;
101
+ const pending = load('', state.loaded, { append: true });
102
+ const token = state.token;
103
+ void pending.then(() => {
104
+ if (!isCurrent(token)) return;
105
+ if (state.status === 'done' && state.loaded > before) state.active = before;
106
+ api?.redraw();
157
107
  });
108
+ api?.redraw();
158
109
  }
159
110
  return;
160
111
  }
161
-
162
- // Use readline's built-in line buffer for text input
163
- const newTerm = rl.line;
164
- if (newTerm !== searchTerm) {
165
- setSearchTerm(newTerm);
112
+ const previous = state.term;
113
+ if (key.name === 'backspace') state.term = state.term.slice(0, -1);
114
+ else if (key.name === 'space') state.term += ' ';
115
+ else if (key.text) state.term += key.text;
116
+ else return;
117
+ if (state.term === previous) return;
118
+
119
+ if (!state.term) {
120
+ state.searchMode = false;
121
+ state.active = 0;
122
+ void load('', 0).then(() => api?.redraw());
123
+ api?.redraw();
124
+ return;
166
125
  }
167
- });
168
-
169
- // Paginated rendering
170
- const page = usePagination({
171
- items: Array.isArray(choices) ? choices : [],
172
- active,
173
- pageSize,
174
- renderItem: ({ item, isActive }) => {
175
- const prefix = isActive ? '\x1b[7m' : ' ';
176
- const suffix = isActive ? '\x1b[0m' : '';
177
- const name = item.name || String(item.value || item);
178
- const display = name.length > 70 ? name.slice(0, 67) + '...' : name;
179
- return ` ${prefix}${display}${suffix}`;
180
- },
181
- loop: false,
182
- });
183
-
184
- const helpText = loaded < totalCount && !searchMode
185
- ? '(scroll to load more, type to search, Esc to cancel)'
186
- : '(type to search, Esc to cancel)';
187
-
188
- return [
189
- `${fullMessage} Search: ${searchTerm}${status === 'loading' ? ' ...' : ''}`,
190
- `${page}\n\n${helpText}`,
191
- ];
192
- })(...args);
126
+ state.searchMode = true;
127
+ state.active = 0;
128
+ void load(state.term, undefined).then(() => api?.redraw());
129
+ api?.redraw();
130
+ },
131
+ render() {
132
+ const pages = Math.max(1, Math.ceil(state.choices.length / pageSize));
133
+ const current = Math.min(pages - 1, Math.floor(state.active / pageSize));
134
+ const start = current * pageSize;
135
+ const visible = state.choices.slice(start, start + pageSize);
136
+ const header = totalCount > 0 && !state.searchMode
137
+ ? `${message} (${state.loaded} of ${totalCount} loaded)`
138
+ : message;
139
+ const lines = [header ?? '', `Search: ${state.term}${state.status === 'loading' ? ' ...' : ''}`];
140
+ if (state.error) lines.push(` ${state.error}`);
141
+ else if (!state.choices.length) lines.push(state.status === 'loading' ? ' Loading...' : ' No matches');
142
+ lines.push(...pickerRows(visible, state.active - start));
143
+ lines.push(...pickerFooter({ more: canLoadMore() }));
144
+ return lines;
145
+ },
146
+ });
147
+
148
+ return prompt.then(value => {
149
+ // Mark the prompt so an in-flight source response cannot redraw or
150
+ // apply after the picker closed.
151
+ state.status = 'cancelled';
152
+ state.token += 1;
153
+ request?.abort();
154
+ return value;
155
+ }, error => {
156
+ state.status = 'cancelled';
157
+ state.token += 1;
158
+ request?.abort();
159
+ throw error;
160
+ }).then(value => value);
193
161
  };
194
162
 
195
163
  export default paginatedSearch;
@@ -0,0 +1,20 @@
1
+ export const PICKER_HELP = '↑↓ navigate • ⏎ select • type to search • Esc cancel';
2
+
3
+ export function pickerRows(choices, active, { picked } = {}) {
4
+ const lines = [];
5
+ choices.forEach((choice, index) => {
6
+ if (choice.section && choice.section !== choices[index - 1]?.section) {
7
+ if (index) lines.push('');
8
+ lines.push(` ${choice.section}`);
9
+ }
10
+ if (choice.separator) { lines.push(` ${choice.name}`); return; }
11
+ const check = picked ? `[${picked.has(choice) ? 'x' : ' '}] ` : '';
12
+ lines.push(`${index === active ? '❯' : ' '} ${check}${choice.name}${choice.disabled ? ' (disabled)' : ''}`);
13
+ if (index === active && choice.description) lines.push(` ${choice.description}`);
14
+ });
15
+ return lines;
16
+ }
17
+
18
+ export function pickerFooter({ checkbox = false, more = false } = {}) {
19
+ return ['', `${PICKER_HELP}${checkbox ? ' • Space toggle' : ''}${more ? ' • ↓ load more' : ''}`];
20
+ }
@@ -0,0 +1,176 @@
1
+ /**
2
+ * A small terminal prompt engine built on node:readline keypress events.
3
+ *
4
+ * This is deliberately not a general prompt library: it exists so JSN's
5
+ * observed prompt surface (input, password, confirm, select, search,
6
+ * checkbox, editor, paginated pickers) runs on Node built-ins with no
7
+ * runtime dependency, while keeping the existing caller contract
8
+ * `prompt(config, { input, output, signal })`.
9
+ *
10
+ * Every prompt restores raw mode and removes its listener in `finally`,
11
+ * on success, Escape, Ctrl+C and thrown errors alike.
12
+ */
13
+
14
+ import readline from 'node:readline';
15
+ import { stripVTControlCharacters } from 'node:util';
16
+
17
+ export class PromptCancelled extends Error {
18
+ constructor() {
19
+ super('Cancelled.');
20
+ this.name = 'PromptCancelled';
21
+ }
22
+ }
23
+
24
+ /** Choices may be strings or { name, value, disabled }. */
25
+ export function normalizeChoices(choices = []) {
26
+ return choices.map(choice => {
27
+ if (choice && typeof choice === 'object') {
28
+ return {
29
+ name: String(choice.name ?? choice.value ?? ''),
30
+ value: 'value' in choice ? choice.value : choice.name,
31
+ disabled: Boolean(choice.disabled) || choice.type === 'separator',
32
+ ...(choice.type === 'separator' ? { separator: true } : {}),
33
+ ...(choice.section !== undefined ? { section: choice.section } : {}),
34
+ ...(choice.description !== undefined ? { description: choice.description } : {}),
35
+ checked: Boolean(choice.checked),
36
+ };
37
+ }
38
+ return { name: String(choice), value: choice, disabled: false };
39
+ });
40
+ }
41
+
42
+ export function truncate(text, width = 70) {
43
+ const value = String(text ?? '');
44
+ return value.length > width ? `${value.slice(0, width - 3)}...` : value;
45
+ }
46
+
47
+ /**
48
+ * Run one interactive prompt.
49
+ *
50
+ * @param {object} config prompt config ({ message, ... })
51
+ * @param {object} context { input, output, signal }
52
+ * @param {object} spec
53
+ * init(config, context) -> state
54
+ * key(state, key, api) -> directive | undefined | Promise<...>
55
+ * directive: { done: value } finishes, { cancel: true } throws
56
+ * PromptCancelled, { escape: true } resolves undefined.
57
+ * render(config, state) -> string | string[]
58
+ * final(config, value, state) -> string | null — the settled answer line
59
+ * (Inquirer prints `✔ <message> <answer>`). Only written on a TTY after
60
+ * the live frame is erased, so one prompt yields exactly one final line
61
+ * and piped output keeps its existing byte contract.
62
+ * escapeValue — when the caller treats Escape as "leave this screen",
63
+ * pass a sentinel produced by `escapeResult(value)`.
64
+ */
65
+ export async function runPrompt(config, context, spec) {
66
+ const input = context.input || process.stdin;
67
+ const output = context.output || process.stdout;
68
+ const canRaw = typeof input.setRawMode === 'function';
69
+ const previousRaw = canRaw ? Boolean(input.isRaw) : false;
70
+
71
+ let state;
72
+ let height = 0;
73
+ let settled = false;
74
+ let resolveDone;
75
+ let rejectDone;
76
+
77
+ const done = new Promise((resolve, reject) => { resolveDone = resolve; rejectDone = reject; });
78
+
79
+ const draw = () => {
80
+ if (settled) return;
81
+ const rendered = spec.render(state);
82
+ const text = Array.isArray(rendered) ? rendered.join('\n') : String(rendered ?? '');
83
+ if (output.isTTY && height > 0) output.write(`\x1b[${height}A\x1b[0J`);
84
+ output.write(`${text}\n`);
85
+ // Count wrapped terminal rows as well as explicit newlines: the compact
86
+ // footer can still wrap in a narrow terminal.
87
+ const columns = output.isTTY && output.columns > 0 ? output.columns : Infinity;
88
+ height = text.split('\n').reduce((rows, line) => rows + Math.max(1, Math.ceil(Array.from(stripVTControlCharacters(line)).length / columns)), 0);
89
+ };
90
+
91
+ const finish = value => {
92
+ if (settled) return;
93
+ settled = true;
94
+ // The settled answer replaces the live frame rather than appending to it:
95
+ // rewind the frame height first so a terminal reader sees one final line.
96
+ if (spec.final && output.isTTY) {
97
+ const line = spec.final(config, value, state);
98
+ if (line) {
99
+ if (height > 0) output.write(`\x1b[${height}A\x1b[0J`);
100
+ output.write(`${line}\n`);
101
+ height = 0;
102
+ }
103
+ }
104
+ resolveDone(value);
105
+ };
106
+ const fail = error => {
107
+ if (settled) return;
108
+ settled = true;
109
+ rejectDone(error);
110
+ };
111
+
112
+ const api = { finish, fail, redraw: draw };
113
+ let queue = Promise.resolve();
114
+ const onKeypress = (_chunk, key) => {
115
+ if (!key || settled) return;
116
+ // Cancellation cannot wait behind validation or a source request.
117
+ if (key.name === 'escape') {
118
+ if (spec.escapeValue !== undefined) finish(spec.escapeValue.value);
119
+ else fail(new PromptCancelled());
120
+ return;
121
+ }
122
+ if (key.ctrl && (key.name === 'c' || key.name === 'd')) {
123
+ fail(new PromptCancelled());
124
+ return;
125
+ }
126
+ key = { ...key, text: !key.ctrl && !key.meta && typeof _chunk === 'string' && Array.from(_chunk).every(char => char.codePointAt(0) >= 32 && char.codePointAt(0) !== 127) ? _chunk : '' };
127
+ // Serialize handling: a chunk can carry several keys at once, and async
128
+ // handlers (search/load-more) must not reorder Enter ahead of arrows.
129
+ queue = queue.then(async () => {
130
+ if (settled) return;
131
+
132
+ const directive = await spec.key(state, key, api);
133
+ if (!directive || settled) return;
134
+ if ('done' in directive) finish(directive.done);
135
+ else if (directive.cancel) fail(new PromptCancelled());
136
+ else if (directive.escape) finish(undefined);
137
+ }).catch(error => fail(error));
138
+ };
139
+
140
+ const onAbort = () => fail(context.signal.reason || new PromptCancelled());
141
+ const onEnd = () => fail(new PromptCancelled());
142
+
143
+ try {
144
+ readline.emitKeypressEvents(input);
145
+ if (canRaw) input.setRawMode(true);
146
+ input.on('keypress', onKeypress);
147
+ input.on('end', onEnd);
148
+ input.on('close', onEnd);
149
+ input.on('error', fail);
150
+ if (context.signal) {
151
+ if (context.signal.aborted) onAbort();
152
+ else context.signal.addEventListener('abort', onAbort, { once: true });
153
+ }
154
+ state = spec.init(config, context);
155
+ if (input.readableEnded || input.destroyed) onEnd();
156
+ if (typeof input.resume === 'function') input.resume();
157
+ draw();
158
+ spec.onReady?.(api);
159
+ return await done;
160
+ } finally {
161
+ input.removeListener('keypress', onKeypress);
162
+ input.removeListener('end', onEnd);
163
+ input.removeListener('close', onEnd);
164
+ input.removeListener('error', fail);
165
+ if (context.signal) context.signal.removeEventListener('abort', onAbort);
166
+ if (canRaw) {
167
+ try { input.setRawMode(previousRaw); } catch { /* stream already closed */ }
168
+ }
169
+ if (typeof input.pause === 'function' && input.isTTY) input.pause();
170
+ }
171
+ }
172
+
173
+ /** Escape resolves `value` instead of cancelling (record pickers). */
174
+ export function escapeResult(value) {
175
+ return { value };
176
+ }