@fnndsc/chell 4.4.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtins/sys/prompt.js +2 -2
- package/dist/builtins/sys/prompt.js.map +1 -1
- package/dist/chell.d.ts +2 -2
- package/dist/chell.js +2 -2
- package/dist/chell.js.map +1 -1
- package/dist/config/settings.d.ts +4 -2
- package/dist/config/settings.js +7 -2
- package/dist/config/settings.js.map +1 -1
- package/dist/core/boot.js +49 -60
- package/dist/core/boot.js.map +1 -1
- package/dist/core/cliSurface.d.ts +1 -1
- package/dist/core/cliSurface.js +1 -1
- package/dist/core/cliSurface.js.map +1 -1
- package/dist/core/progressRenderer.d.ts +2 -2
- package/dist/core/prompt/session.d.ts +26 -1
- package/dist/core/prompt/session.js +25 -20
- package/dist/core/prompt/session.js.map +1 -1
- package/dist/core/repl.d.ts +2 -2
- package/dist/core/repl.js +6 -4
- package/dist/core/repl.js.map +1 -1
- package/dist/core/surfaceDispatch.d.ts +21 -0
- package/dist/core/surfaceDispatch.js +33 -0
- package/dist/core/surfaceDispatch.js.map +1 -0
- package/dist/remote/client.js +2 -2
- package/dist/remote/client.js.map +1 -1
- package/dist/remote/remoteEngine.d.ts +3 -3
- package/dist/remote/remoteEngine.js +7 -4
- package/dist/remote/remoteEngine.js.map +1 -1
- package/package.json +6 -6
- package/dist/builtins/debug.d.ts +0 -8
- package/dist/builtins/debug.js +0 -39
- package/dist/builtins/debug.js.map +0 -1
- package/dist/builtins/executable.d.ts +0 -22
- package/dist/builtins/executable.js +0 -115
- package/dist/builtins/executable.js.map +0 -1
- package/dist/builtins/fs/cat.d.ts +0 -16
- package/dist/builtins/fs/cat.js +0 -266
- package/dist/builtins/fs/cat.js.map +0 -1
- package/dist/builtins/fs/cd.d.ts +0 -42
- package/dist/builtins/fs/cd.js +0 -193
- package/dist/builtins/fs/cd.js.map +0 -1
- package/dist/builtins/fs/cp.d.ts +0 -10
- package/dist/builtins/fs/cp.js +0 -86
- package/dist/builtins/fs/cp.js.map +0 -1
- package/dist/builtins/fs/download.d.ts +0 -6
- package/dist/builtins/fs/download.js +0 -45
- package/dist/builtins/fs/download.js.map +0 -1
- package/dist/builtins/fs/du.d.ts +0 -58
- package/dist/builtins/fs/du.js +0 -210
- package/dist/builtins/fs/du.js.map +0 -1
- package/dist/builtins/fs/edit.d.ts +0 -7
- package/dist/builtins/fs/edit.js +0 -104
- package/dist/builtins/fs/edit.js.map +0 -1
- package/dist/builtins/fs/ls.d.ts +0 -8
- package/dist/builtins/fs/ls.js +0 -68
- package/dist/builtins/fs/ls.js.map +0 -1
- package/dist/builtins/fs/mkdir.d.ts +0 -9
- package/dist/builtins/fs/mkdir.js +0 -52
- package/dist/builtins/fs/mkdir.js.map +0 -1
- package/dist/builtins/fs/mv.d.ts +0 -10
- package/dist/builtins/fs/mv.js +0 -88
- package/dist/builtins/fs/mv.js.map +0 -1
- package/dist/builtins/fs/pull.args.d.ts +0 -22
- package/dist/builtins/fs/pull.args.js +0 -30
- package/dist/builtins/fs/pull.args.js.map +0 -1
- package/dist/builtins/fs/pull.d.ts +0 -26
- package/dist/builtins/fs/pull.js +0 -445
- package/dist/builtins/fs/pull.js.map +0 -1
- package/dist/builtins/fs/pwd.d.ts +0 -10
- package/dist/builtins/fs/pwd.js +0 -73
- package/dist/builtins/fs/pwd.js.map +0 -1
- package/dist/builtins/fs/rm.d.ts +0 -37
- package/dist/builtins/fs/rm.js +0 -197
- package/dist/builtins/fs/rm.js.map +0 -1
- package/dist/builtins/fs/touch.d.ts +0 -9
- package/dist/builtins/fs/touch.js +0 -76
- package/dist/builtins/fs/touch.js.map +0 -1
- package/dist/builtins/fs/tree.d.ts +0 -15
- package/dist/builtins/fs/tree.js +0 -84
- package/dist/builtins/fs/tree.js.map +0 -1
- package/dist/builtins/fs/upload.d.ts +0 -6
- package/dist/builtins/fs/upload.js +0 -48
- package/dist/builtins/fs/upload.js.map +0 -1
- package/dist/builtins/help.d.ts +0 -74
- package/dist/builtins/help.js +0 -1217
- package/dist/builtins/help.js.map +0 -1
- package/dist/builtins/index.d.ts +0 -46
- package/dist/builtins/index.js +0 -46
- package/dist/builtins/index.js.map +0 -1
- package/dist/builtins/net/connect.d.ts +0 -7
- package/dist/builtins/net/connect.js +0 -42
- package/dist/builtins/net/connect.js.map +0 -1
- package/dist/builtins/net/cubepath.d.ts +0 -18
- package/dist/builtins/net/cubepath.js +0 -102
- package/dist/builtins/net/cubepath.js.map +0 -1
- package/dist/builtins/net/logout.d.ts +0 -6
- package/dist/builtins/net/logout.js +0 -24
- package/dist/builtins/net/logout.js.map +0 -1
- package/dist/builtins/net/pacs.d.ts +0 -24
- package/dist/builtins/net/pacs.js +0 -121
- package/dist/builtins/net/pacs.js.map +0 -1
- package/dist/builtins/net/pacsUtils.d.ts +0 -85
- package/dist/builtins/net/pacsUtils.js +0 -184
- package/dist/builtins/net/pacsUtils.js.map +0 -1
- package/dist/builtins/net/query.d.ts +0 -60
- package/dist/builtins/net/query.js +0 -324
- package/dist/builtins/net/query.js.map +0 -1
- package/dist/builtins/parametersofplugin.d.ts +0 -13
- package/dist/builtins/parametersofplugin.js +0 -43
- package/dist/builtins/parametersofplugin.js.map +0 -1
- package/dist/builtins/pluginExecute.d.ts +0 -27
- package/dist/builtins/pluginExecute.js +0 -165
- package/dist/builtins/pluginExecute.js.map +0 -1
- package/dist/builtins/proc.d.ts +0 -6
- package/dist/builtins/proc.helpers.d.ts +0 -68
- package/dist/builtins/proc.helpers.js +0 -102
- package/dist/builtins/proc.helpers.js.map +0 -1
- package/dist/builtins/proc.js +0 -289
- package/dist/builtins/proc.js.map +0 -1
- package/dist/builtins/res/compute.d.ts +0 -6
- package/dist/builtins/res/compute.js +0 -55
- package/dist/builtins/res/compute.js.map +0 -1
- package/dist/builtins/res/feed.d.ts +0 -6
- package/dist/builtins/res/feed.js +0 -244
- package/dist/builtins/res/feed.js.map +0 -1
- package/dist/builtins/res/feed.notes.d.ts +0 -28
- package/dist/builtins/res/feed.notes.js +0 -24
- package/dist/builtins/res/feed.notes.js.map +0 -1
- package/dist/builtins/res/files.d.ts +0 -18
- package/dist/builtins/res/files.js +0 -85
- package/dist/builtins/res/files.js.map +0 -1
- package/dist/builtins/res/group.d.ts +0 -6
- package/dist/builtins/res/group.js +0 -54
- package/dist/builtins/res/group.js.map +0 -1
- package/dist/builtins/res/pipeline.args.d.ts +0 -22
- package/dist/builtins/res/pipeline.args.js +0 -28
- package/dist/builtins/res/pipeline.args.js.map +0 -1
- package/dist/builtins/res/pipeline.d.ts +0 -20
- package/dist/builtins/res/pipeline.js +0 -252
- package/dist/builtins/res/pipeline.js.map +0 -1
- package/dist/builtins/res/plugin.d.ts +0 -13
- package/dist/builtins/res/plugin.js +0 -140
- package/dist/builtins/res/plugin.js.map +0 -1
- package/dist/builtins/res/plugininstance.d.ts +0 -6
- package/dist/builtins/res/plugininstance.js +0 -53
- package/dist/builtins/res/plugininstance.js.map +0 -1
- package/dist/builtins/res/pluginmeta.d.ts +0 -6
- package/dist/builtins/res/pluginmeta.js +0 -53
- package/dist/builtins/res/pluginmeta.js.map +0 -1
- package/dist/builtins/res/tag.d.ts +0 -6
- package/dist/builtins/res/tag.js +0 -53
- package/dist/builtins/res/tag.js.map +0 -1
- package/dist/builtins/res/workflow.d.ts +0 -6
- package/dist/builtins/res/workflow.js +0 -53
- package/dist/builtins/res/workflow.js.map +0 -1
- package/dist/builtins/store.d.ts +0 -6
- package/dist/builtins/store.js +0 -108
- package/dist/builtins/store.js.map +0 -1
- package/dist/builtins/sys/context.d.ts +0 -6
- package/dist/builtins/sys/context.js +0 -50
- package/dist/builtins/sys/context.js.map +0 -1
- package/dist/builtins/sys/physicalmode.d.ts +0 -8
- package/dist/builtins/sys/physicalmode.js +0 -34
- package/dist/builtins/sys/physicalmode.js.map +0 -1
- package/dist/builtins/sys/timing.d.ts +0 -8
- package/dist/builtins/sys/timing.js +0 -34
- package/dist/builtins/sys/timing.js.map +0 -1
- package/dist/builtins/sys/version.d.ts +0 -15
- package/dist/builtins/sys/version.js +0 -23
- package/dist/builtins/sys/version.js.map +0 -1
- package/dist/builtins/sys/whoami.d.ts +0 -17
- package/dist/builtins/sys/whoami.js +0 -44
- package/dist/builtins/sys/whoami.js.map +0 -1
- package/dist/builtins/utils.d.ts +0 -55
- package/dist/builtins/utils.js +0 -145
- package/dist/builtins/utils.js.map +0 -1
- package/dist/builtins/wildcard.d.ts +0 -26
- package/dist/builtins/wildcard.js +0 -120
- package/dist/builtins/wildcard.js.map +0 -1
- package/dist/calypso.d.ts +0 -13
- package/dist/calypso.js +0 -44
- package/dist/calypso.js.map +0 -1
- package/dist/command-keys.d.ts +0 -8
- package/dist/command-keys.js +0 -32
- package/dist/command-keys.js.map +0 -1
- package/dist/core/dispatch.d.ts +0 -101
- package/dist/core/dispatch.js +0 -636
- package/dist/core/dispatch.js.map +0 -1
- package/dist/core/engine.d.ts +0 -91
- package/dist/core/engine.js +0 -222
- package/dist/core/engine.js.map +0 -1
- package/dist/core/preprocess.d.ts +0 -46
- package/dist/core/preprocess.js +0 -146
- package/dist/core/preprocess.js.map +0 -1
- package/dist/core/progress.d.ts +0 -25
- package/dist/core/progress.js +0 -10
- package/dist/core/progress.js.map +0 -1
- package/dist/core/question.d.ts +0 -27
- package/dist/core/question.js +0 -33
- package/dist/core/question.js.map +0 -1
- package/dist/core/sink.d.ts +0 -201
- package/dist/core/sink.js +0 -300
- package/dist/core/sink.js.map +0 -1
- package/dist/core/surface.d.ts +0 -172
- package/dist/core/surface.js +0 -105
- package/dist/core/surface.js.map +0 -1
- package/dist/core/version.d.ts +0 -20
- package/dist/core/version.js +0 -82
- package/dist/core/version.js.map +0 -1
- package/dist/daemon/launch.d.ts +0 -9
- package/dist/daemon/launch.js +0 -82
- package/dist/daemon/launch.js.map +0 -1
- package/dist/lib/completer/index.d.ts +0 -15
- package/dist/lib/completer/index.js +0 -212
- package/dist/lib/completer/index.js.map +0 -1
- package/dist/lib/completer/pathComplete.helpers.d.ts +0 -22
- package/dist/lib/completer/pathComplete.helpers.js +0 -49
- package/dist/lib/completer/pathComplete.helpers.js.map +0 -1
- package/dist/lib/parser.d.ts +0 -13
- package/dist/lib/parser.js +0 -52
- package/dist/lib/parser.js.map +0 -1
- package/dist/lib/pipe.d.ts +0 -11
- package/dist/lib/pipe.js +0 -90
- package/dist/lib/pipe.js.map +0 -1
- package/dist/lib/prefetch.d.ts +0 -25
- package/dist/lib/prefetch.js +0 -64
- package/dist/lib/prefetch.js.map +0 -1
- package/dist/lib/semicolonParser.d.ts +0 -22
- package/dist/lib/semicolonParser.js +0 -53
- package/dist/lib/semicolonParser.js.map +0 -1
- package/dist/lib/spinner.d.ts +0 -23
- package/dist/lib/spinner.js +0 -71
- package/dist/lib/spinner.js.map +0 -1
- package/dist/lib/vfs/providers/static.d.ts +0 -65
- package/dist/lib/vfs/providers/static.js +0 -164
- package/dist/lib/vfs/providers/static.js.map +0 -1
- package/dist/lib/vfs/providers/static_content.d.ts +0 -27
- package/dist/lib/vfs/providers/static_content.js +0 -180
- package/dist/lib/vfs/providers/static_content.js.map +0 -1
- package/dist/lib/vfs/vfs.d.ts +0 -59
- package/dist/lib/vfs/vfs.js +0 -202
- package/dist/lib/vfs/vfs.js.map +0 -1
- package/dist/remote/discovery.d.ts +0 -23
- package/dist/remote/discovery.js +0 -55
- package/dist/remote/discovery.js.map +0 -1
- package/dist/session/index.d.ts +0 -76
- package/dist/session/index.js +0 -120
- package/dist/session/index.js.map +0 -1
package/dist/core/sink.d.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Output sink: the seam through which command output leaves the engine.
|
|
3
|
-
*
|
|
4
|
-
* Builtins historically printed straight to process stdout, which fuses the
|
|
5
|
-
* engine to a terminal. The sink inverts that: output is written to whatever
|
|
6
|
-
* sink the host installed, and only the host knows where bytes finally go
|
|
7
|
-
* (a terminal for the CLI REPL, a capture buffer for pipes, a connection for
|
|
8
|
-
* a remote surface).
|
|
9
|
-
*
|
|
10
|
-
* Three channels are distinguished. Data is the command's actual output: it
|
|
11
|
-
* is accumulated into the command's result envelope and is what capture,
|
|
12
|
-
* piping and redirection consume. Err is the error stream: presented to the
|
|
13
|
-
* user, never piped, never captured. Status is ephemeral (spinners,
|
|
14
|
-
* progress, transient messages): displayed live, never accumulated, never
|
|
15
|
-
* piped.
|
|
16
|
-
*
|
|
17
|
-
* This module also provides delivery helpers that bridge envelope-returning
|
|
18
|
-
* builtins into the existing dispatch table, so conversion can proceed one
|
|
19
|
-
* builtin at a time while unconverted builtins keep printing.
|
|
20
|
-
*
|
|
21
|
-
* @see docs/calypso.adoc for the governing design.
|
|
22
|
-
* @module
|
|
23
|
-
*/
|
|
24
|
-
import type { CommandEnvelope } from '@fnndsc/cumin';
|
|
25
|
-
import type { ProgressEvent } from './progress.js';
|
|
26
|
-
import { TerminalProgressRenderer } from './progressRenderer.js';
|
|
27
|
-
/**
|
|
28
|
-
* Destination for command output, installed by the host.
|
|
29
|
-
*/
|
|
30
|
-
export interface OutputSink {
|
|
31
|
-
/**
|
|
32
|
-
* Writes command output (the data channel).
|
|
33
|
-
*
|
|
34
|
-
* @param chunk - Printable text (ANSI permitted) or raw bytes.
|
|
35
|
-
*/
|
|
36
|
-
data_write(chunk: string | Buffer): void;
|
|
37
|
-
/**
|
|
38
|
-
* Writes error-stream output (the err channel).
|
|
39
|
-
*
|
|
40
|
-
* @param chunk - Printable text (ANSI permitted) or raw bytes.
|
|
41
|
-
*/
|
|
42
|
-
err_write(chunk: string | Buffer): void;
|
|
43
|
-
/**
|
|
44
|
-
* Writes an ephemeral status line (the status channel).
|
|
45
|
-
*
|
|
46
|
-
* @param text - Transient text; consumers may overwrite or drop it.
|
|
47
|
-
*/
|
|
48
|
-
status_write(text: string): void;
|
|
49
|
-
progress_write(event: ProgressEvent): void;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Sink that writes both channels to the process's standard output.
|
|
53
|
-
*
|
|
54
|
-
* This is the CLI host's sink and the default, preserving the shell's
|
|
55
|
-
* historical behavior exactly.
|
|
56
|
-
*/
|
|
57
|
-
export declare class StdoutSink implements OutputSink {
|
|
58
|
-
private readonly progressRenderer;
|
|
59
|
-
constructor(progressRenderer?: TerminalProgressRenderer);
|
|
60
|
-
/** @inheritdoc */
|
|
61
|
-
data_write(chunk: string | Buffer): void;
|
|
62
|
-
/** @inheritdoc */
|
|
63
|
-
err_write(chunk: string | Buffer): void;
|
|
64
|
-
/** @inheritdoc */
|
|
65
|
-
status_write(text: string): void;
|
|
66
|
-
progress_write(event: ProgressEvent): void;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Sink that accumulates the data channel in memory and drops status.
|
|
70
|
-
*
|
|
71
|
-
* Used by capture paths and tests; will carry the pipe and redirect
|
|
72
|
-
* machinery once those consume envelopes.
|
|
73
|
-
*/
|
|
74
|
-
export declare class BufferSink implements OutputSink {
|
|
75
|
-
private chunks;
|
|
76
|
-
/** @inheritdoc */
|
|
77
|
-
data_write(chunk: string | Buffer): void;
|
|
78
|
-
/** @inheritdoc */
|
|
79
|
-
err_write(chunk: string | Buffer): void;
|
|
80
|
-
/** @inheritdoc */
|
|
81
|
-
status_write(_text: string): void;
|
|
82
|
-
progress_write(_event: ProgressEvent): void;
|
|
83
|
-
/**
|
|
84
|
-
* Returns everything written to the data channel so far.
|
|
85
|
-
*
|
|
86
|
-
* @returns The accumulated bytes.
|
|
87
|
-
*/
|
|
88
|
-
buffer_get(): Buffer;
|
|
89
|
-
/**
|
|
90
|
-
* Returns the accumulated data channel as UTF-8 text.
|
|
91
|
-
*
|
|
92
|
-
* @returns The accumulated text.
|
|
93
|
-
*/
|
|
94
|
-
text_get(): string;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Sink that captures the data and err channels while passing status through
|
|
98
|
-
* to a live sink, so transients (spinners, progress) remain visible while a
|
|
99
|
-
* legacy printing command's output is being gathered into an envelope.
|
|
100
|
-
*/
|
|
101
|
-
export declare class CaptureSink implements OutputSink {
|
|
102
|
-
private dataChunks;
|
|
103
|
-
private errChunks;
|
|
104
|
-
private live;
|
|
105
|
-
private readonly forwardEnvelopeOutput;
|
|
106
|
-
/**
|
|
107
|
-
* Initializes the capture around a live sink for status passthrough.
|
|
108
|
-
*
|
|
109
|
-
* @param live - The sink that continues to receive status writes.
|
|
110
|
-
*/
|
|
111
|
-
constructor(live: OutputSink, options?: {
|
|
112
|
-
forwardEnvelopeOutput?: boolean;
|
|
113
|
-
});
|
|
114
|
-
/** @inheritdoc */
|
|
115
|
-
data_write(chunk: string | Buffer): void;
|
|
116
|
-
/** @inheritdoc */
|
|
117
|
-
err_write(chunk: string | Buffer): void;
|
|
118
|
-
/** @inheritdoc */
|
|
119
|
-
status_write(text: string): void;
|
|
120
|
-
progress_write(event: ProgressEvent): void;
|
|
121
|
-
/**
|
|
122
|
-
* Returns the captured data channel as UTF-8 text.
|
|
123
|
-
*
|
|
124
|
-
* @returns The captured data text.
|
|
125
|
-
*/
|
|
126
|
-
dataText_get(): string;
|
|
127
|
-
/**
|
|
128
|
-
* Returns the captured err channel as UTF-8 text.
|
|
129
|
-
*
|
|
130
|
-
* @returns The captured error-stream text.
|
|
131
|
-
*/
|
|
132
|
-
errText_get(): string;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Returns the currently installed sink.
|
|
136
|
-
*
|
|
137
|
-
* @returns The active output sink.
|
|
138
|
-
*/
|
|
139
|
-
export declare function sink_get(): OutputSink;
|
|
140
|
-
/**
|
|
141
|
-
* Installs a sink. Called by the host that owns the output destination.
|
|
142
|
-
*
|
|
143
|
-
* @param sink - The sink to install.
|
|
144
|
-
* @returns The previously installed sink, so callers can restore it.
|
|
145
|
-
*/
|
|
146
|
-
export declare function sink_set(sink: OutputSink): OutputSink;
|
|
147
|
-
/**
|
|
148
|
-
* Delivers a completed envelope to the active sink.
|
|
149
|
-
*
|
|
150
|
-
* Rendered text goes to the data channel and error-stream text to the err
|
|
151
|
-
* channel. The structured errors field is machine-facing and is not
|
|
152
|
-
* presented here: its terminal presentation, when any, travels in
|
|
153
|
-
* renderedErr.
|
|
154
|
-
*
|
|
155
|
-
* @param envelope - The completed command envelope.
|
|
156
|
-
*/
|
|
157
|
-
export declare function envelope_deliver(envelope: CommandEnvelope): void;
|
|
158
|
-
/**
|
|
159
|
-
* Adapts an envelope-returning builtin to the legacy printing handler shape.
|
|
160
|
-
*
|
|
161
|
-
* This is the compatibility bridge for incremental conversion: converted
|
|
162
|
-
* builtins return envelopes, and this wrapper delivers them through the
|
|
163
|
-
* active sink so the dispatch table, pipes and redirects need no changes.
|
|
164
|
-
* A handler that resolves without an envelope (as stubbed handlers in tests
|
|
165
|
-
* do) is treated as having produced no output.
|
|
166
|
-
*
|
|
167
|
-
* @param handler - An envelope-returning command handler.
|
|
168
|
-
* @returns A handler with the legacy void-returning shape.
|
|
169
|
-
*/
|
|
170
|
-
export declare function envelopeHandler_wrap(handler: (args: string[]) => Promise<CommandEnvelope>): (args: string[]) => Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Adapts a legacy printing builtin to the envelope-returning shape.
|
|
173
|
-
*
|
|
174
|
-
* This is the capture bridge for commands whose rendering lives below the
|
|
175
|
-
* seam (chili's table display prints internally): the handler runs with the
|
|
176
|
-
* data and err channels captured, console printing redirected into the
|
|
177
|
-
* capture, and status passed through live so spinners stay visible. The
|
|
178
|
-
* result is an envelope carrying the exact bytes each stream would have
|
|
179
|
-
* shown, with the status derived from the process exit code the handler set.
|
|
180
|
-
*
|
|
181
|
-
* Bridged commands gain envelope semantics without typed models; native
|
|
182
|
-
* conversion (models, streamed data) remains the end state for commands
|
|
183
|
-
* where a structural consumer exists.
|
|
184
|
-
*
|
|
185
|
-
* @param handler - A legacy printing command handler.
|
|
186
|
-
* @returns An envelope-returning handler with identical observable output.
|
|
187
|
-
*/
|
|
188
|
-
export declare function printingHandler_wrap(handler: (args: string[]) => Promise<void>): (args: string[]) => Promise<CommandEnvelope>;
|
|
189
|
-
/**
|
|
190
|
-
* Strips ANSI escape sequences from text.
|
|
191
|
-
*
|
|
192
|
-
* Applied at the pipe and redirect boundary so downstream consumers receive
|
|
193
|
-
* plain text, the way programs behind a real shell pipe see no color. This
|
|
194
|
-
* is a deliberate, documented deviation from the historical behavior, in
|
|
195
|
-
* which escape bytes leaked into pipes because color detection saw the
|
|
196
|
-
* terminal regardless of capture.
|
|
197
|
-
*
|
|
198
|
-
* @param text - Text possibly containing ANSI sequences.
|
|
199
|
-
* @returns The text with all ANSI sequences removed.
|
|
200
|
-
*/
|
|
201
|
-
export declare function ansi_strip(text: string): string;
|
package/dist/core/sink.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Output sink: the seam through which command output leaves the engine.
|
|
3
|
-
*
|
|
4
|
-
* Builtins historically printed straight to process stdout, which fuses the
|
|
5
|
-
* engine to a terminal. The sink inverts that: output is written to whatever
|
|
6
|
-
* sink the host installed, and only the host knows where bytes finally go
|
|
7
|
-
* (a terminal for the CLI REPL, a capture buffer for pipes, a connection for
|
|
8
|
-
* a remote surface).
|
|
9
|
-
*
|
|
10
|
-
* Three channels are distinguished. Data is the command's actual output: it
|
|
11
|
-
* is accumulated into the command's result envelope and is what capture,
|
|
12
|
-
* piping and redirection consume. Err is the error stream: presented to the
|
|
13
|
-
* user, never piped, never captured. Status is ephemeral (spinners,
|
|
14
|
-
* progress, transient messages): displayed live, never accumulated, never
|
|
15
|
-
* piped.
|
|
16
|
-
*
|
|
17
|
-
* This module also provides delivery helpers that bridge envelope-returning
|
|
18
|
-
* builtins into the existing dispatch table, so conversion can proceed one
|
|
19
|
-
* builtin at a time while unconverted builtins keep printing.
|
|
20
|
-
*
|
|
21
|
-
* @see docs/calypso.adoc for the governing design.
|
|
22
|
-
* @module
|
|
23
|
-
*/
|
|
24
|
-
import { TerminalProgressRenderer } from './progressRenderer.js';
|
|
25
|
-
function sink_streamsEnvelopeOutput(sink) {
|
|
26
|
-
return sink.liveEnvelopeOutput === true;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Sink that writes both channels to the process's standard output.
|
|
30
|
-
*
|
|
31
|
-
* This is the CLI host's sink and the default, preserving the shell's
|
|
32
|
-
* historical behavior exactly.
|
|
33
|
-
*/
|
|
34
|
-
export class StdoutSink {
|
|
35
|
-
progressRenderer;
|
|
36
|
-
constructor(progressRenderer = new TerminalProgressRenderer()) {
|
|
37
|
-
this.progressRenderer = progressRenderer;
|
|
38
|
-
}
|
|
39
|
-
/** @inheritdoc */
|
|
40
|
-
data_write(chunk) {
|
|
41
|
-
process.stdout.write(chunk);
|
|
42
|
-
}
|
|
43
|
-
/** @inheritdoc */
|
|
44
|
-
err_write(chunk) {
|
|
45
|
-
process.stderr.write(chunk);
|
|
46
|
-
}
|
|
47
|
-
/** @inheritdoc */
|
|
48
|
-
status_write(text) {
|
|
49
|
-
process.stdout.write(text);
|
|
50
|
-
}
|
|
51
|
-
progress_write(event) {
|
|
52
|
-
this.progressRenderer.write(event);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Sink that accumulates the data channel in memory and drops status.
|
|
57
|
-
*
|
|
58
|
-
* Used by capture paths and tests; will carry the pipe and redirect
|
|
59
|
-
* machinery once those consume envelopes.
|
|
60
|
-
*/
|
|
61
|
-
export class BufferSink {
|
|
62
|
-
chunks = [];
|
|
63
|
-
/** @inheritdoc */
|
|
64
|
-
data_write(chunk) {
|
|
65
|
-
this.chunks.push(typeof chunk === 'string' ? Buffer.from(chunk, 'utf-8') : chunk);
|
|
66
|
-
}
|
|
67
|
-
/** @inheritdoc */
|
|
68
|
-
err_write(chunk) {
|
|
69
|
-
// The err channel is never captured: today's pipe and redirect paths
|
|
70
|
-
// inherit stderr, so error output must keep reaching the terminal even
|
|
71
|
-
// while data is being buffered.
|
|
72
|
-
process.stderr.write(chunk);
|
|
73
|
-
}
|
|
74
|
-
/** @inheritdoc */
|
|
75
|
-
status_write(_text) {
|
|
76
|
-
// Status is ephemeral by contract: never accumulated.
|
|
77
|
-
}
|
|
78
|
-
progress_write(_event) {
|
|
79
|
-
// Progress is ephemeral by contract: never accumulated.
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Returns everything written to the data channel so far.
|
|
83
|
-
*
|
|
84
|
-
* @returns The accumulated bytes.
|
|
85
|
-
*/
|
|
86
|
-
buffer_get() {
|
|
87
|
-
return Buffer.concat(this.chunks);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Returns the accumulated data channel as UTF-8 text.
|
|
91
|
-
*
|
|
92
|
-
* @returns The accumulated text.
|
|
93
|
-
*/
|
|
94
|
-
text_get() {
|
|
95
|
-
return this.buffer_get().toString('utf-8');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Sink that captures the data and err channels while passing status through
|
|
100
|
-
* to a live sink, so transients (spinners, progress) remain visible while a
|
|
101
|
-
* legacy printing command's output is being gathered into an envelope.
|
|
102
|
-
*/
|
|
103
|
-
export class CaptureSink {
|
|
104
|
-
dataChunks = [];
|
|
105
|
-
errChunks = [];
|
|
106
|
-
live;
|
|
107
|
-
forwardEnvelopeOutput;
|
|
108
|
-
/**
|
|
109
|
-
* Initializes the capture around a live sink for status passthrough.
|
|
110
|
-
*
|
|
111
|
-
* @param live - The sink that continues to receive status writes.
|
|
112
|
-
*/
|
|
113
|
-
constructor(live, options = {}) {
|
|
114
|
-
this.live = live;
|
|
115
|
-
this.forwardEnvelopeOutput = options.forwardEnvelopeOutput ?? false;
|
|
116
|
-
}
|
|
117
|
-
/** @inheritdoc */
|
|
118
|
-
data_write(chunk) {
|
|
119
|
-
this.dataChunks.push(typeof chunk === 'string' ? Buffer.from(chunk, 'utf-8') : chunk);
|
|
120
|
-
if (this.forwardEnvelopeOutput) {
|
|
121
|
-
this.live.data_write(chunk);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** @inheritdoc */
|
|
125
|
-
err_write(chunk) {
|
|
126
|
-
this.errChunks.push(typeof chunk === 'string' ? Buffer.from(chunk, 'utf-8') : chunk);
|
|
127
|
-
if (this.forwardEnvelopeOutput) {
|
|
128
|
-
this.live.err_write(chunk);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/** @inheritdoc */
|
|
132
|
-
status_write(text) {
|
|
133
|
-
this.live.status_write(text);
|
|
134
|
-
}
|
|
135
|
-
progress_write(event) {
|
|
136
|
-
this.live.progress_write(event);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Returns the captured data channel as UTF-8 text.
|
|
140
|
-
*
|
|
141
|
-
* @returns The captured data text.
|
|
142
|
-
*/
|
|
143
|
-
dataText_get() {
|
|
144
|
-
return Buffer.concat(this.dataChunks).toString('utf-8');
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Returns the captured err channel as UTF-8 text.
|
|
148
|
-
*
|
|
149
|
-
* @returns The captured error-stream text.
|
|
150
|
-
*/
|
|
151
|
-
errText_get() {
|
|
152
|
-
return Buffer.concat(this.errChunks).toString('utf-8');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/** The active sink. Defaults to stdout so every entry point behaves as the CLI always has. */
|
|
156
|
-
let activeSink = new StdoutSink();
|
|
157
|
-
/**
|
|
158
|
-
* Returns the currently installed sink.
|
|
159
|
-
*
|
|
160
|
-
* @returns The active output sink.
|
|
161
|
-
*/
|
|
162
|
-
export function sink_get() {
|
|
163
|
-
return activeSink;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Installs a sink. Called by the host that owns the output destination.
|
|
167
|
-
*
|
|
168
|
-
* @param sink - The sink to install.
|
|
169
|
-
* @returns The previously installed sink, so callers can restore it.
|
|
170
|
-
*/
|
|
171
|
-
export function sink_set(sink) {
|
|
172
|
-
const previous = activeSink;
|
|
173
|
-
activeSink = sink;
|
|
174
|
-
return previous;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Delivers a completed envelope to the active sink.
|
|
178
|
-
*
|
|
179
|
-
* Rendered text goes to the data channel and error-stream text to the err
|
|
180
|
-
* channel. The structured errors field is machine-facing and is not
|
|
181
|
-
* presented here: its terminal presentation, when any, travels in
|
|
182
|
-
* renderedErr.
|
|
183
|
-
*
|
|
184
|
-
* @param envelope - The completed command envelope.
|
|
185
|
-
*/
|
|
186
|
-
export function envelope_deliver(envelope) {
|
|
187
|
-
if (envelope.rendered.length > 0) {
|
|
188
|
-
activeSink.data_write(envelope.rendered);
|
|
189
|
-
}
|
|
190
|
-
if (envelope.renderedErr !== undefined && envelope.renderedErr.length > 0) {
|
|
191
|
-
activeSink.err_write(envelope.renderedErr);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Adapts an envelope-returning builtin to the legacy printing handler shape.
|
|
196
|
-
*
|
|
197
|
-
* This is the compatibility bridge for incremental conversion: converted
|
|
198
|
-
* builtins return envelopes, and this wrapper delivers them through the
|
|
199
|
-
* active sink so the dispatch table, pipes and redirects need no changes.
|
|
200
|
-
* A handler that resolves without an envelope (as stubbed handlers in tests
|
|
201
|
-
* do) is treated as having produced no output.
|
|
202
|
-
*
|
|
203
|
-
* @param handler - An envelope-returning command handler.
|
|
204
|
-
* @returns A handler with the legacy void-returning shape.
|
|
205
|
-
*/
|
|
206
|
-
export function envelopeHandler_wrap(handler) {
|
|
207
|
-
return async (args) => {
|
|
208
|
-
const envelope = await handler(args);
|
|
209
|
-
if (!envelope) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
envelope_deliver(envelope);
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Adapts a legacy printing builtin to the envelope-returning shape.
|
|
217
|
-
*
|
|
218
|
-
* This is the capture bridge for commands whose rendering lives below the
|
|
219
|
-
* seam (chili's table display prints internally): the handler runs with the
|
|
220
|
-
* data and err channels captured, console printing redirected into the
|
|
221
|
-
* capture, and status passed through live so spinners stay visible. The
|
|
222
|
-
* result is an envelope carrying the exact bytes each stream would have
|
|
223
|
-
* shown, with the status derived from the process exit code the handler set.
|
|
224
|
-
*
|
|
225
|
-
* Bridged commands gain envelope semantics without typed models; native
|
|
226
|
-
* conversion (models, streamed data) remains the end state for commands
|
|
227
|
-
* where a structural consumer exists.
|
|
228
|
-
*
|
|
229
|
-
* @param handler - A legacy printing command handler.
|
|
230
|
-
* @returns An envelope-returning handler with identical observable output.
|
|
231
|
-
*/
|
|
232
|
-
export function printingHandler_wrap(handler) {
|
|
233
|
-
return async (args) => {
|
|
234
|
-
const capture = new CaptureSink(activeSink, {
|
|
235
|
-
forwardEnvelopeOutput: sink_streamsEnvelopeOutput(activeSink),
|
|
236
|
-
});
|
|
237
|
-
const previousSink = sink_set(capture);
|
|
238
|
-
const originalLog = console.log;
|
|
239
|
-
const originalError = console.error;
|
|
240
|
-
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
241
|
-
const exitCodeBefore = typeof process.exitCode === 'number' ? process.exitCode : 0;
|
|
242
|
-
console.log = (...logArgs) => {
|
|
243
|
-
const text = logArgs
|
|
244
|
-
.map((arg) => (typeof arg === 'string' ? arg : JSON.stringify(arg)))
|
|
245
|
-
.join(' ');
|
|
246
|
-
capture.data_write(`${text}\n`);
|
|
247
|
-
};
|
|
248
|
-
console.error = (...logArgs) => {
|
|
249
|
-
const text = logArgs
|
|
250
|
-
.map((arg) => (typeof arg === 'string' ? arg : JSON.stringify(arg)))
|
|
251
|
-
.join(' ');
|
|
252
|
-
capture.err_write(`${text}\n`);
|
|
253
|
-
};
|
|
254
|
-
process.stdout.write = ((chunk) => {
|
|
255
|
-
if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) {
|
|
256
|
-
capture.data_write(chunk);
|
|
257
|
-
}
|
|
258
|
-
else if (chunk instanceof Uint8Array) {
|
|
259
|
-
capture.data_write(Buffer.from(chunk));
|
|
260
|
-
}
|
|
261
|
-
return true;
|
|
262
|
-
});
|
|
263
|
-
try {
|
|
264
|
-
await handler(args);
|
|
265
|
-
}
|
|
266
|
-
finally {
|
|
267
|
-
console.log = originalLog;
|
|
268
|
-
console.error = originalError;
|
|
269
|
-
process.stdout.write = originalStdoutWrite;
|
|
270
|
-
sink_set(previousSink);
|
|
271
|
-
}
|
|
272
|
-
const exitCodeAfter = typeof process.exitCode === 'number' ? process.exitCode : 0;
|
|
273
|
-
const failed = exitCodeAfter !== 0 && exitCodeAfter !== exitCodeBefore;
|
|
274
|
-
const rendered = capture.dataText_get();
|
|
275
|
-
const renderedErr = capture.errText_get();
|
|
276
|
-
const envelope = { status: failed ? 'error' : 'ok', rendered };
|
|
277
|
-
if (renderedErr.length > 0) {
|
|
278
|
-
envelope.renderedErr = renderedErr;
|
|
279
|
-
}
|
|
280
|
-
return envelope;
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
/** Matches ANSI escape sequences (SGR colors, cursor movement, erase). */
|
|
284
|
-
const ANSI_PATTERN = /\x1b\[[0-9;?]*[a-zA-Z]/g;
|
|
285
|
-
/**
|
|
286
|
-
* Strips ANSI escape sequences from text.
|
|
287
|
-
*
|
|
288
|
-
* Applied at the pipe and redirect boundary so downstream consumers receive
|
|
289
|
-
* plain text, the way programs behind a real shell pipe see no color. This
|
|
290
|
-
* is a deliberate, documented deviation from the historical behavior, in
|
|
291
|
-
* which escape bytes leaked into pipes because color detection saw the
|
|
292
|
-
* terminal regardless of capture.
|
|
293
|
-
*
|
|
294
|
-
* @param text - Text possibly containing ANSI sequences.
|
|
295
|
-
* @returns The text with all ANSI sequences removed.
|
|
296
|
-
*/
|
|
297
|
-
export function ansi_strip(text) {
|
|
298
|
-
return text.replace(ANSI_PATTERN, '');
|
|
299
|
-
}
|
|
300
|
-
//# sourceMappingURL=sink.js.map
|
package/dist/core/sink.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sink.js","sourceRoot":"","sources":["../../src/core/s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AAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1F,MAAM,MAAM,GAAY,aAAa,KAAK,CAAC,IAAI,aAAa,KAAK,cAAc,CAAC;QAChF,MAAM,QAAQ,GAAW,OAAO,CAAC,YAAY,EAAE,CAAC;QAChD,MAAM,WAAW,GAAW,OAAO,CAAC,WAAW,EAAE,CAAC;QAElD,MAAM,QAAQ,GAAoB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;QAChF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;QACrC,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,MAAM,YAAY,GAAW,yBAAyB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/core/surface.d.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Surface capabilities: the input/interaction seam a host provides.
|
|
3
|
-
*
|
|
4
|
-
* The output sink (`./sink.js`) lets a host decide where a command's output
|
|
5
|
-
* goes. This module is its input-side counterpart: it lets a host declare
|
|
6
|
-
* what *interaction* it can offer — prompting for a line, reading a secret
|
|
7
|
-
* without echo, opening a local editor — and lets a builtin ask for a
|
|
8
|
-
* capability and fail with a clear message when the attached surface cannot
|
|
9
|
-
* provide it, rather than hanging on a standard input that is not there.
|
|
10
|
-
*
|
|
11
|
-
* The CLI host backs this with readline and the local `$EDITOR`; a future
|
|
12
|
-
* daemon backs it with request messages to a remote surface, and a surface
|
|
13
|
-
* that cannot (say) open a local editor simply declares `localEdit: false`.
|
|
14
|
-
*
|
|
15
|
-
* Capabilities the surface can act on directly (prompting) are methods here;
|
|
16
|
-
* capabilities a builtin still performs itself (local editing, whose editor
|
|
17
|
-
* mechanics remain in the `edit` builtin until a remote surface needs its
|
|
18
|
-
* own implementation) are declared as flags a builtin gates on via
|
|
19
|
-
* {@link capability_require}. This module is deliberately free of Node
|
|
20
|
-
* built-ins so it stays trivially testable and host-agnostic; the readline
|
|
21
|
-
* implementation lives in `./cliSurface.js`.
|
|
22
|
-
*
|
|
23
|
-
* @see docs/calypso.adoc — "Interactivity is a declared surface capability".
|
|
24
|
-
* @module
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* What interaction an attached surface can provide.
|
|
28
|
-
*
|
|
29
|
-
* @property hiddenInput - The surface can read a line without echoing it
|
|
30
|
-
* (password entry).
|
|
31
|
-
* @property localEdit - The surface can open content in a local editor and
|
|
32
|
-
* return the edited result.
|
|
33
|
-
* @property tty - The surface is an interactive terminal (as opposed to a
|
|
34
|
-
* pipe, a script, or a headless host).
|
|
35
|
-
* @property pipeSegments - The surface can run a pipeline's non-first
|
|
36
|
-
* segments (`... | grep foo`) through its own tools. Nothing ever spawns on
|
|
37
|
-
* a daemon host: the local CLI runs segments in-process, a remote CLI runs
|
|
38
|
-
* them on the client machine, and a browser surface lacks the capability
|
|
39
|
-
* and fails such pipelines with a clear message.
|
|
40
|
-
*/
|
|
41
|
-
export interface SurfaceCapabilities {
|
|
42
|
-
hiddenInput: boolean;
|
|
43
|
-
localEdit: boolean;
|
|
44
|
-
tty: boolean;
|
|
45
|
-
pipeSegments: boolean;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A request to prompt the user for a line of input.
|
|
49
|
-
*
|
|
50
|
-
* @property message - The prompt text to display.
|
|
51
|
-
* @property hidden - When true, the entered text is not echoed; requires the
|
|
52
|
-
* `hiddenInput` capability.
|
|
53
|
-
*/
|
|
54
|
-
export interface PromptRequest {
|
|
55
|
-
message: string;
|
|
56
|
-
hidden?: boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Content handed to a surface's local editor.
|
|
60
|
-
*
|
|
61
|
-
* @property content - The text to open in the editor.
|
|
62
|
-
* @property extension - Optional filename extension (e.g. `.txt`, `.json`) so
|
|
63
|
-
* the editor can apply the right syntax mode.
|
|
64
|
-
*/
|
|
65
|
-
export interface LocalEditRequest {
|
|
66
|
-
content: string;
|
|
67
|
-
extension?: string;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The outcome of a local edit.
|
|
71
|
-
*
|
|
72
|
-
* @property content - The content after editing.
|
|
73
|
-
* @property changed - Whether the content differs from what was opened.
|
|
74
|
-
*/
|
|
75
|
-
export interface LocalEditResult {
|
|
76
|
-
content: string;
|
|
77
|
-
changed: boolean;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* The interaction seam a host installs. Builtins reach it through
|
|
81
|
-
* {@link surface_get}; hosts declare their capabilities and back the
|
|
82
|
-
* prompt and local-edit operations with whatever their surface supports.
|
|
83
|
-
*/
|
|
84
|
-
export interface Surface {
|
|
85
|
-
/** What this surface can do; read by builtins before they interact. */
|
|
86
|
-
readonly capabilities: SurfaceCapabilities;
|
|
87
|
-
/**
|
|
88
|
-
* Prompts for a line of input.
|
|
89
|
-
*
|
|
90
|
-
* @param request - The prompt message and whether to hide the input.
|
|
91
|
-
* @returns The entered line, trimmed.
|
|
92
|
-
* @throws {CapabilityError} When hidden input is requested but the surface
|
|
93
|
-
* lacks the `hiddenInput` capability, or the surface cannot prompt.
|
|
94
|
-
*/
|
|
95
|
-
prompt(request: PromptRequest): Promise<string>;
|
|
96
|
-
/**
|
|
97
|
-
* Runs one pipeline segment against an input, returning its output. Where
|
|
98
|
-
* this runs is the surface's business — in-process for the local CLI, on
|
|
99
|
-
* the client machine for a remote CLI — but never on a daemon host.
|
|
100
|
-
*
|
|
101
|
-
* @param command - The segment command line (e.g. `grep foo`).
|
|
102
|
-
* @param input - The bytes to feed the segment on stdin.
|
|
103
|
-
* @returns The segment's stdout.
|
|
104
|
-
* @throws {CapabilityError} When the surface lacks the `pipeSegments`
|
|
105
|
-
* capability.
|
|
106
|
-
*/
|
|
107
|
-
pipeSegment(command: string, input: Buffer): Promise<Buffer>;
|
|
108
|
-
/**
|
|
109
|
-
* Opens content in the surface's local editor and returns the result. The
|
|
110
|
-
* editor mechanics are the surface's business — a temp file and `$EDITOR`
|
|
111
|
-
* for the local CLI, the client's editor for a remote CLI, an editor
|
|
112
|
-
* component in a browser.
|
|
113
|
-
*
|
|
114
|
-
* @param request - The content to edit and an optional extension.
|
|
115
|
-
* @returns The edited content and whether it changed.
|
|
116
|
-
* @throws {CapabilityError} When the surface lacks the `localEdit`
|
|
117
|
-
* capability.
|
|
118
|
-
*/
|
|
119
|
-
localEdit(request: LocalEditRequest): Promise<LocalEditResult>;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Raised when a builtin requests an interaction the attached surface cannot
|
|
123
|
-
* provide. Carries the capability name so a host can present it uniformly.
|
|
124
|
-
*/
|
|
125
|
-
export declare class CapabilityError extends Error {
|
|
126
|
-
/** The capability that was required but absent. */
|
|
127
|
-
readonly capability: keyof SurfaceCapabilities;
|
|
128
|
-
/**
|
|
129
|
-
* @param capability - The missing capability.
|
|
130
|
-
* @param message - Human-readable explanation.
|
|
131
|
-
*/
|
|
132
|
-
constructor(capability: keyof SurfaceCapabilities, message: string);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* The default surface for a host that has not installed one: it can do
|
|
136
|
-
* nothing interactive and says so clearly. This is the correct default for
|
|
137
|
-
* an unknown host — a CLI host replaces it (see `./cliSurface.js`), and any
|
|
138
|
-
* attempt to prompt or edit before a real surface is installed fails loudly
|
|
139
|
-
* instead of hanging.
|
|
140
|
-
*/
|
|
141
|
-
export declare class HeadlessSurface implements Surface {
|
|
142
|
-
/** @inheritdoc */
|
|
143
|
-
readonly capabilities: SurfaceCapabilities;
|
|
144
|
-
/** @inheritdoc */
|
|
145
|
-
prompt(_request: PromptRequest): Promise<string>;
|
|
146
|
-
/** @inheritdoc */
|
|
147
|
-
pipeSegment(_command: string, _input: Buffer): Promise<Buffer>;
|
|
148
|
-
/** @inheritdoc */
|
|
149
|
-
localEdit(_request: LocalEditRequest): Promise<LocalEditResult>;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Returns the currently installed surface.
|
|
153
|
-
*
|
|
154
|
-
* @returns The active surface.
|
|
155
|
-
*/
|
|
156
|
-
export declare function surface_get(): Surface;
|
|
157
|
-
/**
|
|
158
|
-
* Installs a surface. Called by the host that owns the interaction channel.
|
|
159
|
-
*
|
|
160
|
-
* @param surface - The surface to install.
|
|
161
|
-
* @returns The previously installed surface, so callers can restore it.
|
|
162
|
-
*/
|
|
163
|
-
export declare function surface_set(surface: Surface): Surface;
|
|
164
|
-
/**
|
|
165
|
-
* Asserts that the active surface has a capability, throwing a
|
|
166
|
-
* {@link CapabilityError} with a clear message when it does not.
|
|
167
|
-
*
|
|
168
|
-
* @param capability - The capability the caller needs.
|
|
169
|
-
* @param message - The message to present when it is absent.
|
|
170
|
-
* @throws {CapabilityError} When the active surface lacks the capability.
|
|
171
|
-
*/
|
|
172
|
-
export declare function capability_require(capability: keyof SurfaceCapabilities, message: string): void;
|