@fnndsc/chell 4.3.2 → 5.0.0

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 (233) hide show
  1. package/dist/builtins/sys/prompt.js +2 -2
  2. package/dist/builtins/sys/prompt.js.map +1 -1
  3. package/dist/chell.d.ts +2 -1
  4. package/dist/chell.js +2 -1
  5. package/dist/chell.js.map +1 -1
  6. package/dist/config/settings.d.ts +4 -2
  7. package/dist/config/settings.js +7 -2
  8. package/dist/config/settings.js.map +1 -1
  9. package/dist/core/boot.d.ts +3 -1
  10. package/dist/core/boot.js +93 -154
  11. package/dist/core/boot.js.map +1 -1
  12. package/dist/core/cli.d.ts +3 -1
  13. package/dist/core/cli.js +11 -1
  14. package/dist/core/cli.js.map +1 -1
  15. package/dist/core/cliSurface.d.ts +26 -0
  16. package/dist/core/cliSurface.js +152 -0
  17. package/dist/core/cliSurface.js.map +1 -0
  18. package/dist/core/progressRenderer.d.ts +42 -0
  19. package/dist/core/progressRenderer.js +176 -0
  20. package/dist/core/progressRenderer.js.map +1 -0
  21. package/dist/core/prompt/session.d.ts +45 -0
  22. package/dist/core/prompt/session.js +48 -0
  23. package/dist/core/prompt/session.js.map +1 -0
  24. package/dist/core/repl.d.ts +25 -5
  25. package/dist/core/repl.js +58 -45
  26. package/dist/core/repl.js.map +1 -1
  27. package/dist/core/surfaceDispatch.d.ts +21 -0
  28. package/dist/core/surfaceDispatch.js +33 -0
  29. package/dist/core/surfaceDispatch.js.map +1 -0
  30. package/dist/core/warnings.d.ts +14 -0
  31. package/dist/core/warnings.js +25 -0
  32. package/dist/core/warnings.js.map +1 -0
  33. package/dist/index.js +2 -12
  34. package/dist/index.js.map +1 -1
  35. package/dist/remote/client.d.ts +6 -0
  36. package/dist/remote/client.js +71 -0
  37. package/dist/remote/client.js.map +1 -0
  38. package/dist/remote/remoteEngine.d.ts +125 -0
  39. package/dist/remote/remoteEngine.js +286 -0
  40. package/dist/remote/remoteEngine.js.map +1 -0
  41. package/package.json +5 -3
  42. package/dist/builtins/debug.d.ts +0 -6
  43. package/dist/builtins/debug.js +0 -47
  44. package/dist/builtins/debug.js.map +0 -1
  45. package/dist/builtins/executable.d.ts +0 -22
  46. package/dist/builtins/executable.js +0 -115
  47. package/dist/builtins/executable.js.map +0 -1
  48. package/dist/builtins/fs/cat.d.ts +0 -16
  49. package/dist/builtins/fs/cat.js +0 -249
  50. package/dist/builtins/fs/cat.js.map +0 -1
  51. package/dist/builtins/fs/cd.d.ts +0 -41
  52. package/dist/builtins/fs/cd.js +0 -178
  53. package/dist/builtins/fs/cd.js.map +0 -1
  54. package/dist/builtins/fs/cp.d.ts +0 -7
  55. package/dist/builtins/fs/cp.js +0 -73
  56. package/dist/builtins/fs/cp.js.map +0 -1
  57. package/dist/builtins/fs/download.d.ts +0 -6
  58. package/dist/builtins/fs/download.js +0 -41
  59. package/dist/builtins/fs/download.js.map +0 -1
  60. package/dist/builtins/fs/du.d.ts +0 -58
  61. package/dist/builtins/fs/du.js +0 -210
  62. package/dist/builtins/fs/du.js.map +0 -1
  63. package/dist/builtins/fs/edit.d.ts +0 -7
  64. package/dist/builtins/fs/edit.js +0 -86
  65. package/dist/builtins/fs/edit.js.map +0 -1
  66. package/dist/builtins/fs/ls.d.ts +0 -8
  67. package/dist/builtins/fs/ls.js +0 -68
  68. package/dist/builtins/fs/ls.js.map +0 -1
  69. package/dist/builtins/fs/mkdir.d.ts +0 -6
  70. package/dist/builtins/fs/mkdir.js +0 -38
  71. package/dist/builtins/fs/mkdir.js.map +0 -1
  72. package/dist/builtins/fs/mv.d.ts +0 -7
  73. package/dist/builtins/fs/mv.js +0 -75
  74. package/dist/builtins/fs/mv.js.map +0 -1
  75. package/dist/builtins/fs/pull.args.d.ts +0 -22
  76. package/dist/builtins/fs/pull.args.js +0 -30
  77. package/dist/builtins/fs/pull.args.js.map +0 -1
  78. package/dist/builtins/fs/pull.d.ts +0 -26
  79. package/dist/builtins/fs/pull.js +0 -417
  80. package/dist/builtins/fs/pull.js.map +0 -1
  81. package/dist/builtins/fs/pwd.d.ts +0 -7
  82. package/dist/builtins/fs/pwd.js +0 -75
  83. package/dist/builtins/fs/pwd.js.map +0 -1
  84. package/dist/builtins/fs/rm.d.ts +0 -31
  85. package/dist/builtins/fs/rm.js +0 -148
  86. package/dist/builtins/fs/rm.js.map +0 -1
  87. package/dist/builtins/fs/touch.d.ts +0 -6
  88. package/dist/builtins/fs/touch.js +0 -64
  89. package/dist/builtins/fs/touch.js.map +0 -1
  90. package/dist/builtins/fs/tree.d.ts +0 -15
  91. package/dist/builtins/fs/tree.js +0 -84
  92. package/dist/builtins/fs/tree.js.map +0 -1
  93. package/dist/builtins/fs/upload.d.ts +0 -6
  94. package/dist/builtins/fs/upload.js +0 -45
  95. package/dist/builtins/fs/upload.js.map +0 -1
  96. package/dist/builtins/help.d.ts +0 -74
  97. package/dist/builtins/help.js +0 -1217
  98. package/dist/builtins/help.js.map +0 -1
  99. package/dist/builtins/index.d.ts +0 -45
  100. package/dist/builtins/index.js +0 -45
  101. package/dist/builtins/index.js.map +0 -1
  102. package/dist/builtins/net/connect.d.ts +0 -7
  103. package/dist/builtins/net/connect.js +0 -42
  104. package/dist/builtins/net/connect.js.map +0 -1
  105. package/dist/builtins/net/cubepath.d.ts +0 -18
  106. package/dist/builtins/net/cubepath.js +0 -102
  107. package/dist/builtins/net/cubepath.js.map +0 -1
  108. package/dist/builtins/net/logout.d.ts +0 -6
  109. package/dist/builtins/net/logout.js +0 -24
  110. package/dist/builtins/net/logout.js.map +0 -1
  111. package/dist/builtins/net/pacs.d.ts +0 -24
  112. package/dist/builtins/net/pacs.js +0 -121
  113. package/dist/builtins/net/pacs.js.map +0 -1
  114. package/dist/builtins/net/pacsUtils.d.ts +0 -85
  115. package/dist/builtins/net/pacsUtils.js +0 -184
  116. package/dist/builtins/net/pacsUtils.js.map +0 -1
  117. package/dist/builtins/net/query.d.ts +0 -60
  118. package/dist/builtins/net/query.js +0 -324
  119. package/dist/builtins/net/query.js.map +0 -1
  120. package/dist/builtins/parametersofplugin.d.ts +0 -13
  121. package/dist/builtins/parametersofplugin.js +0 -43
  122. package/dist/builtins/parametersofplugin.js.map +0 -1
  123. package/dist/builtins/pluginExecute.d.ts +0 -27
  124. package/dist/builtins/pluginExecute.js +0 -165
  125. package/dist/builtins/pluginExecute.js.map +0 -1
  126. package/dist/builtins/proc.d.ts +0 -6
  127. package/dist/builtins/proc.helpers.d.ts +0 -68
  128. package/dist/builtins/proc.helpers.js +0 -102
  129. package/dist/builtins/proc.helpers.js.map +0 -1
  130. package/dist/builtins/proc.js +0 -289
  131. package/dist/builtins/proc.js.map +0 -1
  132. package/dist/builtins/res/compute.d.ts +0 -6
  133. package/dist/builtins/res/compute.js +0 -55
  134. package/dist/builtins/res/compute.js.map +0 -1
  135. package/dist/builtins/res/feed.d.ts +0 -6
  136. package/dist/builtins/res/feed.js +0 -244
  137. package/dist/builtins/res/feed.js.map +0 -1
  138. package/dist/builtins/res/feed.notes.d.ts +0 -28
  139. package/dist/builtins/res/feed.notes.js +0 -24
  140. package/dist/builtins/res/feed.notes.js.map +0 -1
  141. package/dist/builtins/res/files.d.ts +0 -18
  142. package/dist/builtins/res/files.js +0 -85
  143. package/dist/builtins/res/files.js.map +0 -1
  144. package/dist/builtins/res/group.d.ts +0 -6
  145. package/dist/builtins/res/group.js +0 -54
  146. package/dist/builtins/res/group.js.map +0 -1
  147. package/dist/builtins/res/pipeline.args.d.ts +0 -22
  148. package/dist/builtins/res/pipeline.args.js +0 -28
  149. package/dist/builtins/res/pipeline.args.js.map +0 -1
  150. package/dist/builtins/res/pipeline.d.ts +0 -20
  151. package/dist/builtins/res/pipeline.js +0 -252
  152. package/dist/builtins/res/pipeline.js.map +0 -1
  153. package/dist/builtins/res/plugin.d.ts +0 -13
  154. package/dist/builtins/res/plugin.js +0 -140
  155. package/dist/builtins/res/plugin.js.map +0 -1
  156. package/dist/builtins/res/plugininstance.d.ts +0 -6
  157. package/dist/builtins/res/plugininstance.js +0 -53
  158. package/dist/builtins/res/plugininstance.js.map +0 -1
  159. package/dist/builtins/res/pluginmeta.d.ts +0 -6
  160. package/dist/builtins/res/pluginmeta.js +0 -53
  161. package/dist/builtins/res/pluginmeta.js.map +0 -1
  162. package/dist/builtins/res/tag.d.ts +0 -6
  163. package/dist/builtins/res/tag.js +0 -53
  164. package/dist/builtins/res/tag.js.map +0 -1
  165. package/dist/builtins/res/workflow.d.ts +0 -6
  166. package/dist/builtins/res/workflow.js +0 -53
  167. package/dist/builtins/res/workflow.js.map +0 -1
  168. package/dist/builtins/store.d.ts +0 -6
  169. package/dist/builtins/store.js +0 -108
  170. package/dist/builtins/store.js.map +0 -1
  171. package/dist/builtins/sys/context.d.ts +0 -6
  172. package/dist/builtins/sys/context.js +0 -50
  173. package/dist/builtins/sys/context.js.map +0 -1
  174. package/dist/builtins/sys/physicalmode.d.ts +0 -6
  175. package/dist/builtins/sys/physicalmode.js +0 -41
  176. package/dist/builtins/sys/physicalmode.js.map +0 -1
  177. package/dist/builtins/sys/timing.d.ts +0 -6
  178. package/dist/builtins/sys/timing.js +0 -41
  179. package/dist/builtins/sys/timing.js.map +0 -1
  180. package/dist/builtins/sys/whoami.d.ts +0 -12
  181. package/dist/builtins/sys/whoami.js +0 -37
  182. package/dist/builtins/sys/whoami.js.map +0 -1
  183. package/dist/builtins/utils.d.ts +0 -55
  184. package/dist/builtins/utils.js +0 -145
  185. package/dist/builtins/utils.js.map +0 -1
  186. package/dist/builtins/wildcard.d.ts +0 -26
  187. package/dist/builtins/wildcard.js +0 -120
  188. package/dist/builtins/wildcard.js.map +0 -1
  189. package/dist/command-keys.d.ts +0 -8
  190. package/dist/command-keys.js +0 -32
  191. package/dist/command-keys.js.map +0 -1
  192. package/dist/core/dispatch.d.ts +0 -48
  193. package/dist/core/dispatch.js +0 -544
  194. package/dist/core/dispatch.js.map +0 -1
  195. package/dist/core/preprocess.d.ts +0 -46
  196. package/dist/core/preprocess.js +0 -146
  197. package/dist/core/preprocess.js.map +0 -1
  198. package/dist/core/question.d.ts +0 -34
  199. package/dist/core/question.js +0 -76
  200. package/dist/core/question.js.map +0 -1
  201. package/dist/lib/completer/index.d.ts +0 -15
  202. package/dist/lib/completer/index.js +0 -212
  203. package/dist/lib/completer/index.js.map +0 -1
  204. package/dist/lib/completer/pathComplete.helpers.d.ts +0 -22
  205. package/dist/lib/completer/pathComplete.helpers.js +0 -49
  206. package/dist/lib/completer/pathComplete.helpers.js.map +0 -1
  207. package/dist/lib/parser.d.ts +0 -13
  208. package/dist/lib/parser.js +0 -52
  209. package/dist/lib/parser.js.map +0 -1
  210. package/dist/lib/pipe.d.ts +0 -11
  211. package/dist/lib/pipe.js +0 -90
  212. package/dist/lib/pipe.js.map +0 -1
  213. package/dist/lib/prefetch.d.ts +0 -25
  214. package/dist/lib/prefetch.js +0 -64
  215. package/dist/lib/prefetch.js.map +0 -1
  216. package/dist/lib/semicolonParser.d.ts +0 -22
  217. package/dist/lib/semicolonParser.js +0 -53
  218. package/dist/lib/semicolonParser.js.map +0 -1
  219. package/dist/lib/spinner.d.ts +0 -23
  220. package/dist/lib/spinner.js +0 -70
  221. package/dist/lib/spinner.js.map +0 -1
  222. package/dist/lib/vfs/providers/static.d.ts +0 -65
  223. package/dist/lib/vfs/providers/static.js +0 -164
  224. package/dist/lib/vfs/providers/static.js.map +0 -1
  225. package/dist/lib/vfs/providers/static_content.d.ts +0 -27
  226. package/dist/lib/vfs/providers/static_content.js +0 -180
  227. package/dist/lib/vfs/providers/static_content.js.map +0 -1
  228. package/dist/lib/vfs/vfs.d.ts +0 -59
  229. package/dist/lib/vfs/vfs.js +0 -198
  230. package/dist/lib/vfs/vfs.js.map +0 -1
  231. package/dist/session/index.d.ts +0 -76
  232. package/dist/session/index.js +0 -120
  233. package/dist/session/index.js.map +0 -1
@@ -0,0 +1,286 @@
1
+ /**
2
+ * @file The remote engine: a `BrasaEngine` backed by a daemon over the wire.
3
+ *
4
+ * This is the transport swap that lets the same REPL drive either an in-process
5
+ * engine or a CALYPSO daemon. It implements the engine interface by sending
6
+ * `execute` / `complete` messages over a WebSocket and awaiting the correlated
7
+ * `result` / completion replies, validating every message against calypso's
8
+ * wire contract at the boundary. Session-bus broadcasts (another surface's
9
+ * activity) are delivered to an optional callback so the host can render them.
10
+ *
11
+ * @module
12
+ */
13
+ import { WebSocket } from 'ws';
14
+ import { serverMessage_parse, CONTRACT_VERSION } from '@fnndsc/calypso';
15
+ import { envelope_deliver, sink_get } from '@fnndsc/brasa';
16
+ import { promptFromContext_render } from '../core/prompt/session.js';
17
+ /**
18
+ * A `BrasaEngine` implementation that drives a remote daemon.
19
+ */
20
+ export class RemoteEngine {
21
+ ws;
22
+ pending = new Map();
23
+ onSession;
24
+ onPrompt;
25
+ onPipe;
26
+ onEdit;
27
+ latestPrompt = '';
28
+ nextId = 0;
29
+ liveEnvelopeChannels = new Map();
30
+ /**
31
+ * @param ws - An open, already-attached socket to the daemon.
32
+ * @param options - The callbacks for session broadcasts and prompts.
33
+ */
34
+ constructor(ws, options) {
35
+ this.ws = ws;
36
+ this.onSession = options.onSession;
37
+ this.onPrompt = options.onPrompt;
38
+ this.onPipe = options.onPipe;
39
+ this.onEdit = options.onEdit;
40
+ }
41
+ /**
42
+ * Connects to a daemon, performs the attach handshake, and returns a ready
43
+ * remote engine.
44
+ *
45
+ * @param options - The daemon URL, attach token, and callbacks.
46
+ * @returns The connected remote engine.
47
+ * @throws {Error} When the connection fails or the attach is refused.
48
+ */
49
+ static connect(options) {
50
+ return new Promise((resolve, reject) => {
51
+ const ws = new WebSocket(options.url);
52
+ ws.once('error', (err) => reject(err));
53
+ ws.once('open', () => {
54
+ ws.send(JSON.stringify({ type: 'attach', protocolVersion: CONTRACT_VERSION, token: options.token }));
55
+ ws.once('message', (data) => {
56
+ const parsed = serverMessage_parse(safeJson_parse(data.toString()));
57
+ if (!parsed.ok || parsed.value === undefined) {
58
+ reject(new Error(`attach failed: ${parsed.error ?? 'invalid response'}`));
59
+ ws.close();
60
+ return;
61
+ }
62
+ const message = parsed.value;
63
+ if (message.type === 'error') {
64
+ reject(new Error(`attach refused: ${message.reason}`));
65
+ ws.close();
66
+ return;
67
+ }
68
+ if (message.type !== 'attached') {
69
+ reject(new Error(`unexpected attach response: ${message.type}`));
70
+ ws.close();
71
+ return;
72
+ }
73
+ const engine = new RemoteEngine(ws, options);
74
+ ws.on('message', (payload) => engine.message_handle(payload));
75
+ if (options.onClose) {
76
+ ws.on('close', () => options.onClose?.());
77
+ }
78
+ resolve(engine);
79
+ });
80
+ });
81
+ });
82
+ }
83
+ /** @inheritdoc */
84
+ async line_execute(line) {
85
+ const id = String(this.nextId++);
86
+ const envelopes = await this.request('execute', { line }, id);
87
+ const liveChannels = this.liveEnvelopeChannels.get(id);
88
+ this.liveEnvelopeChannels.delete(id);
89
+ // Deliver to the active sink exactly as the in-process engine delivers
90
+ // live, so the REPL host renders remote output without any change.
91
+ for (const envelope of envelopes) {
92
+ envelope_deliver(liveChannels ? {
93
+ ...envelope,
94
+ rendered: liveChannels.has('data') ? '' : envelope.rendered,
95
+ renderedErr: liveChannels.has('err') ? undefined : envelope.renderedErr,
96
+ } : envelope);
97
+ }
98
+ return envelopes;
99
+ }
100
+ /** @inheritdoc */
101
+ line_complete(linePrefix) {
102
+ return this.request('complete', { prefix: linePrefix });
103
+ }
104
+ /**
105
+ * Sends a correlated request and returns a promise for its reply.
106
+ *
107
+ * @param type - The request message type.
108
+ * @param fields - The message fields besides `type` and `id`.
109
+ * @returns The reply payload.
110
+ */
111
+ request(type, fields, requestId) {
112
+ const id = requestId ?? String(this.nextId++);
113
+ return new Promise((resolve, reject) => {
114
+ this.pending.set(id, { resolve, reject });
115
+ this.ws.send(JSON.stringify({ type, id, ...fields }));
116
+ });
117
+ }
118
+ /**
119
+ * Dispatches a message from the daemon: correlated replies resolve their
120
+ * pending request, session broadcasts reach the callback, and uncorrelated
121
+ * errors are surfaced.
122
+ *
123
+ * @param payload - The raw message bytes.
124
+ */
125
+ message_handle(payload) {
126
+ const parsed = serverMessage_parse(safeJson_parse(payload.toString()));
127
+ if (!parsed.ok || parsed.value === undefined) {
128
+ return;
129
+ }
130
+ const message = parsed.value;
131
+ switch (message.type) {
132
+ case 'result':
133
+ this.pending_settle(message.id, (p) => p.resolve(message.envelopes));
134
+ break;
135
+ case 'complete':
136
+ this.pending_settle(message.id, (p) => p.resolve({ candidates: message.candidates, prefix: message.prefix }));
137
+ break;
138
+ case 'session':
139
+ // The wire envelope is a CommandEnvelope; calypso's schema infers the
140
+ // model payload as optional-unknown, a zod nicety the runtime shape
141
+ // does not reflect. Narrow at this single boundary.
142
+ if (this.onSession)
143
+ this.onSession(message.surface, message.envelope);
144
+ break;
145
+ case 'prompt':
146
+ void this.prompt_answer(message.promptId, message.message, message.hidden);
147
+ break;
148
+ case 'promptline':
149
+ // Render the daemon's context with this surface's own theme, so a
150
+ // remote prompt looks the way the local operator configured it.
151
+ this.latestPrompt = promptFromContext_render(message.context);
152
+ break;
153
+ case 'progress':
154
+ {
155
+ const { type: _type, id: _id, ...event } = message;
156
+ sink_get().progress_write(event);
157
+ }
158
+ break;
159
+ case 'output':
160
+ if (message.channel === 'data' || message.channel === 'err') {
161
+ const channels = this.liveEnvelopeChannels.get(message.id) ?? new Set();
162
+ channels.add(message.channel);
163
+ this.liveEnvelopeChannels.set(message.id, channels);
164
+ }
165
+ this.output_render(message.channel, message.chunk);
166
+ break;
167
+ case 'pipe':
168
+ void this.pipe_run(message.pipeId, message.command, message.input);
169
+ break;
170
+ case 'edit':
171
+ void this.edit_run(message.editId, message.content, message.extension);
172
+ break;
173
+ case 'error':
174
+ if (message.id !== undefined) {
175
+ this.pending_settle(message.id, (p) => p.reject(new Error(message.reason)));
176
+ }
177
+ break;
178
+ default:
179
+ break;
180
+ }
181
+ }
182
+ /**
183
+ * Answers a prompt the daemon raised: asks the local surface and sends the
184
+ * answer back. With no prompt handler, answers empty so the command does not
185
+ * hang.
186
+ *
187
+ * @param promptId - The prompt correlation id.
188
+ * @param message - The prompt text.
189
+ * @param hidden - Whether the entry should be hidden (a password).
190
+ */
191
+ async prompt_answer(promptId, message, hidden) {
192
+ const answer = this.onPrompt ? await this.onPrompt(message, hidden) : '';
193
+ this.ws.send(JSON.stringify({ type: 'promptAnswer', promptId, answer }));
194
+ }
195
+ /**
196
+ * Runs a pipeline segment the daemon asked for on this machine and returns
197
+ * its output. Data crosses the wire base64-encoded. With no pipe handler,
198
+ * returns the input unchanged so the pipeline does not hang.
199
+ *
200
+ * @param pipeId - The pipe correlation id.
201
+ * @param command - The segment command line.
202
+ * @param input - The base64-encoded input bytes.
203
+ */
204
+ async pipe_run(pipeId, command, input) {
205
+ const inputBytes = Buffer.from(input, 'base64');
206
+ const output = this.onPipe ? await this.onPipe(command, inputBytes) : inputBytes;
207
+ this.ws.send(JSON.stringify({ type: 'pipeResult', pipeId, output: output.toString('base64') }));
208
+ }
209
+ /**
210
+ * Opens content in this machine's editor (the daemon asked for it) and
211
+ * returns the edited result. With no edit handler, returns the content
212
+ * unchanged so the command does not hang.
213
+ *
214
+ * @param editId - The edit correlation id.
215
+ * @param content - The content to edit.
216
+ * @param extension - An optional filename extension.
217
+ */
218
+ async edit_run(editId, content, extension) {
219
+ const result = this.onEdit
220
+ ? await this.onEdit(content, extension)
221
+ : { content, changed: false };
222
+ this.ws.send(JSON.stringify({ type: 'editResult', editId, content: result.content, changed: result.changed }));
223
+ }
224
+ /**
225
+ * Renders a streamed output chunk to the local sink on its channel.
226
+ *
227
+ * @param channel - The sink channel the chunk belongs to.
228
+ * @param chunk - The streamed text.
229
+ */
230
+ output_render(channel, chunk) {
231
+ const sink = sink_get();
232
+ if (channel === 'data') {
233
+ sink.data_write(chunk);
234
+ }
235
+ else if (channel === 'err') {
236
+ sink.err_write(chunk);
237
+ }
238
+ else {
239
+ sink.status_write(chunk);
240
+ }
241
+ }
242
+ /**
243
+ * Applies a settlement to the pending request for an id, if one exists.
244
+ *
245
+ * @param id - The correlation id.
246
+ * @param settle - The settlement to apply.
247
+ */
248
+ pending_settle(id, settle) {
249
+ const pending = this.pending.get(id);
250
+ if (pending) {
251
+ this.pending.delete(id);
252
+ settle(pending);
253
+ }
254
+ }
255
+ /**
256
+ * The latest themed prompt string the daemon pushed, or empty before the
257
+ * first push.
258
+ *
259
+ * @returns The current prompt string.
260
+ */
261
+ promptLine() {
262
+ return this.latestPrompt;
263
+ }
264
+ /**
265
+ * Closes the connection.
266
+ */
267
+ close() {
268
+ this.ws.close();
269
+ }
270
+ }
271
+ /**
272
+ * Parses JSON, returning `undefined` on failure so callers can validate the
273
+ * result rather than catch.
274
+ *
275
+ * @param text - The JSON text.
276
+ * @returns The parsed value, or undefined when the text is not valid JSON.
277
+ */
278
+ function safeJson_parse(text) {
279
+ try {
280
+ return JSON.parse(text);
281
+ }
282
+ catch {
283
+ return undefined;
284
+ }
285
+ }
286
+ //# sourceMappingURL=remoteEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteEngine.js","sourceRoot":"","sources":["../../src/remote/remoteEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAG5F,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AA0BrE;;GAEG;AACH,MAAM,OAAO,YAAY;IACN,EAAE,CAAY;IACd,OAAO,GAAyB,IAAI,GAAG,EAAmB,CAAC;IAC3D,SAAS,CAAqE;IAC9E,QAAQ,CAAsE;IAC9E,MAAM,CAAoE;IAC1E,MAAM,CAAmH;IAClI,YAAY,GAAW,EAAE,CAAC;IAC1B,MAAM,GAAW,CAAC,CAAC;IACV,oBAAoB,GAAqC,IAAI,GAAG,EAA+B,CAAC;IAEjH;;;OAGG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sc/chell",
3
- "version": "4.3.2",
3
+ "version": "5.0.0",
4
4
  "description": "ChELL Executes Layered Logic - Interactive ChRIS REPL Shell",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,8 +37,9 @@
37
37
  "author": "FNNDSC <dev@babyMRI.org>",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
+ "@fnndsc/brasa": "^0.1.0",
40
41
  "@fnndsc/chili": "^3.3.0",
41
- "@fnndsc/cumin": "^3.4.0",
42
+ "@fnndsc/cumin": "^3.5.0",
42
43
  "@fnndsc/salsa": "^3.2.6",
43
44
  "chalk": "^4.1.2",
44
45
  "cli-progress": "^3.12.0",
@@ -48,7 +49,8 @@
48
49
  "marked": "^15.0.12",
49
50
  "marked-terminal": "^7.3.0",
50
51
  "minimatch": "^10.1.1",
51
- "ws": "^8.21.0"
52
+ "ws": "^8.21.0",
53
+ "@fnndsc/calypso": "^0.3.0"
52
54
  },
53
55
  "devDependencies": {
54
56
  "@types/cli-progress": "^3.11.6",
@@ -1,6 +0,0 @@
1
- /**
2
- * Toggles or displays debug mode status.
3
- *
4
- * @param args - Command line arguments: 'on', 'off', or empty to display status.
5
- */
6
- export declare function builtin_debug(args: string[]): Promise<void>;
@@ -1,47 +0,0 @@
1
- /**
2
- * @file Debug Command
3
- *
4
- * Toggles debug mode for the application, enabling verbose error logging.
5
- */
6
- import chalk from 'chalk';
7
- import { session } from '../session/index.js';
8
- /**
9
- * Toggles or displays debug mode status.
10
- *
11
- * @param args - Command line arguments: 'on', 'off', or empty to display status.
12
- */
13
- export async function builtin_debug(args) {
14
- const subcommand = args[0];
15
- const config = session.connection.config;
16
- if (!config) {
17
- console.error(chalk.red('Error: Connection configuration not initialized.'));
18
- return;
19
- }
20
- if (!subcommand) {
21
- const status = config.debug ? 'enabled' : 'disabled';
22
- console.log(`Debug mode: ${chalk.yellow(status)}`);
23
- if (config.debug) {
24
- console.log(chalk.gray(' Verbose error logging is enabled.'));
25
- }
26
- else {
27
- console.log(chalk.gray(' Verbose error logging is disabled.'));
28
- }
29
- console.log(chalk.gray('\nUsage: debug [on|off]'));
30
- return;
31
- }
32
- if (subcommand === 'on') {
33
- config.debug = true;
34
- console.log(chalk.yellow('[!] Debug mode enabled'));
35
- console.log(chalk.gray(' Verbose error logging activated.'));
36
- }
37
- else if (subcommand === 'off') {
38
- config.debug = false;
39
- console.log(chalk.green('[+] Debug mode disabled'));
40
- console.log(chalk.gray(' Verbose error logging deactivated.'));
41
- }
42
- else {
43
- console.log(chalk.red(`Unknown argument: ${subcommand}`));
44
- console.log(chalk.gray('Usage: debug [on|off]'));
45
- }
46
- }
47
- //# sourceMappingURL=debug.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/builtins/debug.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;IAChD,MAAM,UAAU,GAAuB,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;IAEzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,MAAM,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC,CAAC;IAClE,CAAC;SAAM,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QAChC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC,CAAC;IACpE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * @file Builtin handler for executing a plugin as a shell command.
3
- *
4
- * @module
5
- */
6
- type PluginExecutableOptions = {
7
- piped?: boolean;
8
- };
9
- /**
10
- * Handles simulated execution of plugins (e.g., "pl-simpledsapp-v1.2.3 --parameters").
11
- *
12
- * This acts as an interceptor for the main shell loop. If the user input matches a
13
- * known plugin name format, it routes the request to the appropriate ChRIS/ChILI logic,
14
- * simulating a native executable experience.
15
- *
16
- * @param command - The command string (potentially a plugin name).
17
- * @param args - The arguments passed to the command.
18
- * @param options - Optional flags for piped/non-interactive handling.
19
- * @returns A Promise resolving to true if the command was handled as a plugin execution, false otherwise.
20
- */
21
- export declare function pluginExecutable_handle(command: string, args: string[], options?: PluginExecutableOptions): Promise<boolean>;
22
- export {};
@@ -1,115 +0,0 @@
1
- /**
2
- * @file Builtin handler for executing a plugin as a shell command.
3
- *
4
- * @module
5
- */
6
- import chalk from 'chalk';
7
- import { spinner } from '../lib/spinner.js';
8
- import { builtin_parametersofplugin } from './parametersofplugin.js';
9
- import { plugins_list, plugins_listAll } from '@fnndsc/salsa';
10
- import { pluginReadme_fetch, pluginReadme_render } from '@fnndsc/chili/commands/plugin/readme.js';
11
- /**
12
- * Handles simulated execution of plugins (e.g., "pl-simpledsapp-v1.2.3 --parameters").
13
- *
14
- * This acts as an interceptor for the main shell loop. If the user input matches a
15
- * known plugin name format, it routes the request to the appropriate ChRIS/ChILI logic,
16
- * simulating a native executable experience.
17
- *
18
- * @param command - The command string (potentially a plugin name).
19
- * @param args - The arguments passed to the command.
20
- * @param options - Optional flags for piped/non-interactive handling.
21
- * @returns A Promise resolving to true if the command was handled as a plugin execution, false otherwise.
22
- */
23
- export async function pluginExecutable_handle(command, args, options) {
24
- // Expected format: name-vVersion (e.g., "pl-simpledsapp-v2.1.3")
25
- const versionSeparatorIndex = command.lastIndexOf('-v');
26
- if (versionSeparatorIndex === -1) {
27
- return false;
28
- }
29
- const name = command.substring(0, versionSeparatorIndex);
30
- const version = command.substring(versionSeparatorIndex + 2);
31
- if (!name || !version) {
32
- return false;
33
- }
34
- const showHelp = args.includes('--help') || args.includes('-h');
35
- const isPipedOutput = !!options?.piped || !process.stdout.isTTY;
36
- if (showHelp) {
37
- console.log(chalk.cyan(`Plugin executable flags for ${name}-v${version}:`));
38
- console.log(' --parameters Show parameter definitions for this plugin version');
39
- console.log(' --readme Show README (rendered) from plugin metadata repository URL');
40
- console.log(' --readme --raw Output raw markdown, suitable for piping to glow or bat');
41
- return true;
42
- }
43
- const plugin_resolveExact = async () => {
44
- try {
45
- const resultsExactUnknown = await plugins_list({
46
- search: {
47
- name_exact: name,
48
- version: version
49
- }
50
- });
51
- const resultsExact = resultsExactUnknown;
52
- let candidate = resultsExact?.tableData?.[0];
53
- if (!candidate || candidate.name !== name || candidate.version !== version) {
54
- const allVersionsUnknown = await plugins_listAll({
55
- search: { name: name }
56
- });
57
- const allVersions = allVersionsUnknown;
58
- candidate = allVersions?.tableData?.find((p) => p.name === name && p.version === version);
59
- }
60
- if (!candidate ||
61
- typeof candidate.id !== 'number' ||
62
- typeof candidate.name !== 'string' ||
63
- typeof candidate.version !== 'string') {
64
- return null;
65
- }
66
- return { id: candidate.id, name: candidate.name, version: candidate.version };
67
- }
68
- catch (error) {
69
- console.error(chalk.red(`Error resolving plugin: ${error instanceof Error ? error.message : String(error)}`));
70
- return null;
71
- }
72
- };
73
- if (args.includes('--readme')) {
74
- const rawMode = args.includes('--raw');
75
- console.log(chalk.cyan(`Resolving plugin ${name} v${version} for README...`));
76
- const resolved = await plugin_resolveExact();
77
- if (!resolved) {
78
- console.log(chalk.red(`Plugin ${name} v${version} not found.`));
79
- return true;
80
- }
81
- spinner.start(`Fetching README for ${resolved.name} v${resolved.version}...`);
82
- try {
83
- const content = await pluginReadme_fetch(String(resolved.id));
84
- spinner.stop();
85
- if (content) {
86
- console.log(rawMode ? content : pluginReadme_render(content));
87
- }
88
- else {
89
- console.log(chalk.yellow(`No README found for ${resolved.name} v${resolved.version}.`));
90
- }
91
- }
92
- catch (error) {
93
- spinner.stop();
94
- const message = error instanceof Error ? error.message : String(error);
95
- console.log(chalk.red(`Failed to fetch README: ${message}`));
96
- }
97
- return true;
98
- }
99
- if (args.includes('--parameters')) {
100
- console.log(chalk.cyan(`Fetching parameters for plugin ${name} v${version}...`));
101
- const resolved = await plugin_resolveExact();
102
- if (!resolved) {
103
- console.log(chalk.red(`Plugin ${name} v${version} not found.`));
104
- return true; // Handled (attempted), but failed
105
- }
106
- console.log(chalk.cyan(`Resolved Plugin: ${resolved.name} v${resolved.version} (ID: ${resolved.id})`));
107
- // Delegate to parametersofplugin builtin with the resolved context
108
- await builtin_parametersofplugin(['list', '--plugin-id', String(resolved.id)]);
109
- return true;
110
- }
111
- // If command matches plugin format but no handled flags are present,
112
- // return false to let the main loop handle it (or show unknown command).
113
- return false;
114
- }
115
- //# sourceMappingURL=executable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executable.js","sourceRoot":"","sources":["../../src/builtins/executable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAclG;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,OAAe,EACf,IAAc,EACd,OAAiC;IAEjC,iEAAiE;IACjE,MAAM,qBAAqB,GAAW,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,qBAAqB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,GAAW,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;IACjE,MAAM,OAAO,GAAW,OAAO,CAAC,SAAS,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;IAErE,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAY,IAAI,CAAC,QAAQ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AAI,CAAC,oBAAoB,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO,SAAS,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAEvG,mEAAmE;QACnE,MAAM,0BAA0B,CAAC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,qEAAqE;IACrE,yEAAyE;IACzE,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Displays the content of one or more files.
3
- *
4
- * Supports multiple files and concatenates their output. Binary mode is applied
5
- * consistently to all files if any file is detected as binary or --binary is specified.
6
- *
7
- * @param args - Command line arguments (file paths and optional --binary flag).
8
- *
9
- * @example
10
- * ```typescript
11
- * await builtin_cat(['file1.txt', 'file2.txt']);
12
- * await builtin_cat(['--binary', 'image.dcm']);
13
- * await builtin_cat(['*.json']); // After wildcard expansion
14
- * ```
15
- */
16
- export declare function builtin_cat(args: string[]): Promise<void>;