@cmdless/ui-sdk 0.0.0 → 0.0.5
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/LICENSE +21 -0
- package/README.md +22 -43
- package/dist/browser/index.d.ts +10 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +22 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/node/host.d.ts +246 -0
- package/dist/node/host.d.ts.map +1 -0
- package/dist/node/host.js +378 -0
- package/dist/node/host.js.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +3 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/utils.d.ts +12 -0
- package/dist/node/utils.d.ts.map +1 -0
- package/dist/node/utils.js +62 -0
- package/dist/node/utils.js.map +1 -0
- package/dist/node/utils.test.d.ts +2 -0
- package/dist/node/utils.test.d.ts.map +1 -0
- package/dist/node/utils.test.js +17 -0
- package/dist/node/utils.test.js.map +1 -0
- package/dist/prompts.d.ts +33 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +66 -0
- package/dist/prompts.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -7
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { WebSocketServer } from 'ws';
|
|
3
|
+
import { defineProtocol } from '@cmdless/rpc-sdk';
|
|
4
|
+
import { connectSocket } from '@cmdless/rpc-sdk/node';
|
|
5
|
+
import { createWebSocket } from '@cmdless/rpc-sdk/ws';
|
|
6
|
+
import { closeWebSocketServer, getWebSocketUrl, waitForWebSocketListening } from '@cmdless/rpc-sdk/ws/node';
|
|
7
|
+
import { resolvePackageBin, waitForService } from '@cmdless/core/node';
|
|
8
|
+
import { getCmdlessUIVersion, setCmdlessApp } from './utils.js';
|
|
9
|
+
import { elicitationCard, elicitationResult, permissionCard, permissionResult } from '../prompts.js';
|
|
10
|
+
const uiHostProtocol = defineProtocol(({ side, request, notification }) => ({
|
|
11
|
+
clientToServer: side({
|
|
12
|
+
requests: {
|
|
13
|
+
init: request('init'),
|
|
14
|
+
windowOpen: request('window/open'),
|
|
15
|
+
dialogOpen: request('dialog/open'),
|
|
16
|
+
trayCreate: request('tray/create'),
|
|
17
|
+
trayUpdate: request('tray/update'),
|
|
18
|
+
handleClose: request('handle/close'),
|
|
19
|
+
shellOpenExternal: request('shell/openExternal'),
|
|
20
|
+
clipboardWriteText: request('clipboard/writeText'),
|
|
21
|
+
notificationShow: request('notification/show'),
|
|
22
|
+
cardOpen: request('card/open'),
|
|
23
|
+
cardUpdate: request('card/update'),
|
|
24
|
+
formOpen: request('form/open'),
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
serverToClient: side({
|
|
28
|
+
notifications: {
|
|
29
|
+
handleClosed: notification('handle/closed'),
|
|
30
|
+
trayEvent: notification('tray/event'),
|
|
31
|
+
cardEvent: notification('card/event'),
|
|
32
|
+
},
|
|
33
|
+
requests: {
|
|
34
|
+
windowConnect: request('window/connect'),
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
}));
|
|
38
|
+
// how long an end that arrived ahead of its handle's open is kept
|
|
39
|
+
const UNCLAIMED_MS = 60_000;
|
|
40
|
+
// how a remote handle is ended - by its UIHost, which hears it
|
|
41
|
+
const end = Symbol('end');
|
|
42
|
+
// a window, dialog or tray a UIHost has opened on its host
|
|
43
|
+
export class RemoteHandle {
|
|
44
|
+
host;
|
|
45
|
+
id;
|
|
46
|
+
// the value it ends with: a window's resolve, the redirect it caught, or
|
|
47
|
+
// nothing if it was closed by hand. Rejects if it failed, or the host went.
|
|
48
|
+
closed;
|
|
49
|
+
settle;
|
|
50
|
+
constructor(host, id) {
|
|
51
|
+
this.host = host;
|
|
52
|
+
this.id = id;
|
|
53
|
+
this.closed = new Promise((resolve, reject) => this.settle = { resolve, reject });
|
|
54
|
+
// nobody has to wait on how it ends
|
|
55
|
+
this.closed.catch(() => { });
|
|
56
|
+
}
|
|
57
|
+
// ends it, with the value it ends with
|
|
58
|
+
close(value) {
|
|
59
|
+
return this.host.client.request.handleClose({ id: this.id, value });
|
|
60
|
+
}
|
|
61
|
+
// opens a window in front of this one
|
|
62
|
+
openWindow(params, backend) {
|
|
63
|
+
return this.host.openWindow({ ...params, parent: this.id }, backend);
|
|
64
|
+
}
|
|
65
|
+
// shows a dialog in front of this one
|
|
66
|
+
openDialog(params) {
|
|
67
|
+
return this.host.openDialog({ ...params, parent: this.id });
|
|
68
|
+
}
|
|
69
|
+
// opens a card window in front of this one
|
|
70
|
+
openCard(params) {
|
|
71
|
+
return this.host.openCard({ ...params, parent: this.id });
|
|
72
|
+
}
|
|
73
|
+
// opens a form window in front of this one
|
|
74
|
+
openForm(params) {
|
|
75
|
+
return this.host.openForm({ ...params, parent: this.id });
|
|
76
|
+
}
|
|
77
|
+
[end]({ value, error }) {
|
|
78
|
+
if (error !== undefined)
|
|
79
|
+
this.settle.reject(new Error(error));
|
|
80
|
+
else
|
|
81
|
+
this.settle.resolve(value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class RemoteWindow extends RemoteHandle {
|
|
85
|
+
}
|
|
86
|
+
export class RemoteDialog extends RemoteHandle {
|
|
87
|
+
}
|
|
88
|
+
// a notification ends with 'click' if it was clicked, or nothing if it was
|
|
89
|
+
// dismissed (or closed from here)
|
|
90
|
+
export class RemoteNotification extends RemoteHandle {
|
|
91
|
+
}
|
|
92
|
+
// how a remote tray hears what happened to it - from its UIHost
|
|
93
|
+
const emit = Symbol('emit');
|
|
94
|
+
// a tray stays until it's closed, telling whoever listens when it's clicked
|
|
95
|
+
export class RemoteTray extends RemoteHandle {
|
|
96
|
+
listeners = new Set();
|
|
97
|
+
// changes its icon, tooltip, title or menu - anything left out stays
|
|
98
|
+
update(params) {
|
|
99
|
+
return this.host.client.request.trayUpdate({ ...params, id: this.id });
|
|
100
|
+
}
|
|
101
|
+
onEvent(listener) {
|
|
102
|
+
this.listeners.add(listener);
|
|
103
|
+
return { dispose: () => { this.listeners.delete(listener); } };
|
|
104
|
+
}
|
|
105
|
+
[emit](event) {
|
|
106
|
+
for (const listener of [...this.listeners])
|
|
107
|
+
listener(event);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// a card ends with the Action.Submit chosen on it (and its inputs), or
|
|
111
|
+
// nothing if it was closed instead. Until then, whoever listens hears each
|
|
112
|
+
// Action.Execute chosen on it - and can show another card in its place.
|
|
113
|
+
export class RemoteCard extends RemoteHandle {
|
|
114
|
+
listeners = new Set();
|
|
115
|
+
// shows another card in its place
|
|
116
|
+
update(card) {
|
|
117
|
+
return this.host.client.request.cardUpdate({ id: this.id, card });
|
|
118
|
+
}
|
|
119
|
+
onEvent(listener) {
|
|
120
|
+
this.listeners.add(listener);
|
|
121
|
+
return { dispose: () => { this.listeners.delete(listener); } };
|
|
122
|
+
}
|
|
123
|
+
[emit](event) {
|
|
124
|
+
for (const listener of [...this.listeners])
|
|
125
|
+
listener(event);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// a form ends with the data it was submitted with, or nothing if it was
|
|
129
|
+
// cancelled or closed
|
|
130
|
+
export class RemoteForm extends RemoteHandle {
|
|
131
|
+
}
|
|
132
|
+
// what the host can do on the desktop beyond its own windows - Electron's
|
|
133
|
+
// shell, through the host
|
|
134
|
+
export class UIShellHandler {
|
|
135
|
+
host;
|
|
136
|
+
constructor(host) {
|
|
137
|
+
this.host = host;
|
|
138
|
+
}
|
|
139
|
+
// opens a link in the default browser (http and https), or mail app
|
|
140
|
+
// (mailto) - anything else is refused
|
|
141
|
+
openExternal(url) {
|
|
142
|
+
return this.host.client.request.shellOpenExternal({ url });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// the system clipboard, through the host
|
|
146
|
+
export class UIClipboardHandler {
|
|
147
|
+
host;
|
|
148
|
+
constructor(host) {
|
|
149
|
+
this.host = host;
|
|
150
|
+
}
|
|
151
|
+
writeText(text) {
|
|
152
|
+
return this.host.client.request.clipboardWriteText({ text });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export class UIHost {
|
|
156
|
+
client;
|
|
157
|
+
params;
|
|
158
|
+
static protocol = uiHostProtocol;
|
|
159
|
+
shell = new UIShellHandler(this);
|
|
160
|
+
clipboard = new UIClipboardHandler(this);
|
|
161
|
+
remotes = new Map();
|
|
162
|
+
// A handle can end before the reply saying it opened arrives: on macOS a
|
|
163
|
+
// dialog with no parent holds the host up until it's answered, so its end
|
|
164
|
+
// goes out ahead of the reply to dialog/open. An end for a handle not known
|
|
165
|
+
// yet is kept here until its open is answered - for a while, not forever.
|
|
166
|
+
unclaimed = new Map();
|
|
167
|
+
// each window opened with a backend: what accepts a connection to it, and
|
|
168
|
+
// the name of the protocol it speaks
|
|
169
|
+
backends = new Map();
|
|
170
|
+
// windows being opened with a backend, until the host has answered with
|
|
171
|
+
// their ids - a page asking for one waits on these rather than on time
|
|
172
|
+
opening = new Set();
|
|
173
|
+
// tokens handed out and not yet used, each good for one connection to one
|
|
174
|
+
// window's backend
|
|
175
|
+
tokens = new Map();
|
|
176
|
+
// where every window's backend is reached, started when a page first asks
|
|
177
|
+
backendServer;
|
|
178
|
+
constructor(client, params) {
|
|
179
|
+
this.client = client;
|
|
180
|
+
this.params = params;
|
|
181
|
+
client.onRequest.windowConnect(params => this.connectWindow(params));
|
|
182
|
+
client.onNotification.handleClosed(params => {
|
|
183
|
+
this.forgetBackend(params.id);
|
|
184
|
+
const remote = this.remotes.get(params.id);
|
|
185
|
+
this.remotes.delete(params.id);
|
|
186
|
+
if (remote)
|
|
187
|
+
return remote[end](params);
|
|
188
|
+
this.unclaimed.set(params.id, params);
|
|
189
|
+
setTimeout(() => this.unclaimed.delete(params.id), UNCLAIMED_MS).unref();
|
|
190
|
+
});
|
|
191
|
+
client.onNotification.trayEvent(({ id, ...event }) => {
|
|
192
|
+
const remote = this.remotes.get(id);
|
|
193
|
+
if (remote instanceof RemoteTray)
|
|
194
|
+
remote[emit](event);
|
|
195
|
+
});
|
|
196
|
+
client.onNotification.cardEvent(({ id, ...event }) => {
|
|
197
|
+
const remote = this.remotes.get(id);
|
|
198
|
+
if (remote instanceof RemoteCard)
|
|
199
|
+
remote[emit](event);
|
|
200
|
+
});
|
|
201
|
+
client.onClose(() => {
|
|
202
|
+
for (const remote of this.remotes.values())
|
|
203
|
+
remote[end]({ error: 'the host went away' });
|
|
204
|
+
this.remotes.clear();
|
|
205
|
+
void this.closeBackendServer();
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// a window's page asking for its backend: a token for one connection,
|
|
209
|
+
// once the window is known to have one - if it's still being opened, once
|
|
210
|
+
// the host has said which it is
|
|
211
|
+
async connectWindow({ id }) {
|
|
212
|
+
if (!this.backends.has(id) && this.opening.size > 0)
|
|
213
|
+
await Promise.allSettled([...this.opening]);
|
|
214
|
+
if (!this.backends.has(id))
|
|
215
|
+
throw new Error('this window was opened without a backend');
|
|
216
|
+
const server = await (this.backendServer ??= this.startBackendServer());
|
|
217
|
+
const token = randomBytes(24).toString('base64url');
|
|
218
|
+
this.tokens.set(token, id);
|
|
219
|
+
return { url: getWebSocketUrl(server), token };
|
|
220
|
+
}
|
|
221
|
+
// one loopback WebSocket server for every window's backend. Anything on
|
|
222
|
+
// this machine can reach it, so a connection gets in only with a token
|
|
223
|
+
// from connectWindow - used once, and only for the window it was made for.
|
|
224
|
+
async startBackendServer() {
|
|
225
|
+
const server = new WebSocketServer({ host: '127.0.0.1', port: 0 });
|
|
226
|
+
server.on('connection', (socket, request) => {
|
|
227
|
+
const token = new URL(request.url ?? '/', 'ws://backend').searchParams.get('token') ?? '';
|
|
228
|
+
const id = this.tokens.get(token);
|
|
229
|
+
this.tokens.delete(token);
|
|
230
|
+
const backend = id === undefined ? undefined : this.backends.get(id);
|
|
231
|
+
if (!backend)
|
|
232
|
+
return socket.close(1008, 'not a token for an open window');
|
|
233
|
+
backend(createWebSocket(socket)).listen();
|
|
234
|
+
});
|
|
235
|
+
return waitForWebSocketListening(server);
|
|
236
|
+
}
|
|
237
|
+
async closeBackendServer() {
|
|
238
|
+
const server = await this.backendServer;
|
|
239
|
+
this.backendServer = undefined;
|
|
240
|
+
if (!server)
|
|
241
|
+
return;
|
|
242
|
+
for (const socket of server.clients)
|
|
243
|
+
socket.terminate();
|
|
244
|
+
await closeWebSocketServer(server).catch(() => { });
|
|
245
|
+
}
|
|
246
|
+
// a window that's gone takes its backend, and any tokens for it, with it
|
|
247
|
+
forgetBackend(id) {
|
|
248
|
+
if (!this.backends.delete(id))
|
|
249
|
+
return;
|
|
250
|
+
for (const [token, owner] of this.tokens)
|
|
251
|
+
if (owner === id)
|
|
252
|
+
this.tokens.delete(token);
|
|
253
|
+
}
|
|
254
|
+
// starts ui-runtime's host, detached, for it to report where it can be
|
|
255
|
+
// reached: its own address when it gets the app's single-instance lock, or
|
|
256
|
+
// the lock holder's when it doesn't. Everything it needs goes through its
|
|
257
|
+
// env - the app (CMDLESS_APP), the root (CMDLESS_ROOT) and where to report
|
|
258
|
+
// (CMDLESS_SERVICE_SOCKET).
|
|
259
|
+
static async create({ app, cmdlessRoot, timeoutMs } = {}) {
|
|
260
|
+
const sdkVersion = await getCmdlessUIVersion();
|
|
261
|
+
const { binPath, env } = await resolvePackageBin(import.meta, '@cmdless/ui-runtime', sdkVersion, cmdlessRoot);
|
|
262
|
+
if (app)
|
|
263
|
+
setCmdlessApp(app, env);
|
|
264
|
+
const { value } = await waitForService(process.execPath, [binPath, 'host'], { env, timeoutMs });
|
|
265
|
+
const client = await connectSocket(uiHostProtocol, { path: value.address });
|
|
266
|
+
client.listen();
|
|
267
|
+
try {
|
|
268
|
+
return new UIHost(client, await client.request.init({ sdkVersion }));
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
client.dispose();
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// starts or joins a host, shows one window on it, and hands back the
|
|
276
|
+
// value it ends with - leaving the host once it has
|
|
277
|
+
static showWindow(options, params, backend) {
|
|
278
|
+
return UIHost.once(options, host => host.openWindow(params, backend));
|
|
279
|
+
}
|
|
280
|
+
// the same for a dialog, handing back what was chosen
|
|
281
|
+
static showDialog(options, params) {
|
|
282
|
+
return UIHost.once(options, host => host.openDialog(params));
|
|
283
|
+
}
|
|
284
|
+
// the same for a card, handing back the Action.Submit chosen on it - or
|
|
285
|
+
// nothing, if it was closed
|
|
286
|
+
static showCard(options, params) {
|
|
287
|
+
return UIHost.once(options, host => host.openCard(params));
|
|
288
|
+
}
|
|
289
|
+
// asks an elicitation's question as a card, handing back its answer -
|
|
290
|
+
// cancel, if the card was closed
|
|
291
|
+
static async showElicitation(options, request) {
|
|
292
|
+
return elicitationResult(await UIHost.showCard(options, { card: elicitationCard(request), window: request.window }));
|
|
293
|
+
}
|
|
294
|
+
// asks a permission request as a card, handing back its outcome -
|
|
295
|
+
// cancelled, if the card was closed
|
|
296
|
+
static async showPermission(options, request) {
|
|
297
|
+
return permissionResult(await UIHost.showCard(options, { card: permissionCard(request), window: request.window }));
|
|
298
|
+
}
|
|
299
|
+
// the same for a form, handing back what it was submitted with - or
|
|
300
|
+
// nothing, if it was cancelled
|
|
301
|
+
static showForm(options, params) {
|
|
302
|
+
return UIHost.once(options, host => host.openForm(params));
|
|
303
|
+
}
|
|
304
|
+
static async once(options, open) {
|
|
305
|
+
const host = await UIHost.create(options);
|
|
306
|
+
try {
|
|
307
|
+
return await (await open(host)).closed;
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
host.dispose();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// opens a window, once the host has - with a backend, its page can
|
|
314
|
+
// connect() to this process directly, the host only introducing them
|
|
315
|
+
async openWindow(params, backend) {
|
|
316
|
+
if (!backend) {
|
|
317
|
+
const { id } = await this.client.request.windowOpen(params);
|
|
318
|
+
return this.track(new RemoteWindow(this, id));
|
|
319
|
+
}
|
|
320
|
+
// the backend is known by the time anything can hear of the window's id
|
|
321
|
+
const opened = this.client.request.windowOpen(params).then(({ id }) => {
|
|
322
|
+
this.backends.set(id, backend);
|
|
323
|
+
return id;
|
|
324
|
+
});
|
|
325
|
+
this.opening.add(opened);
|
|
326
|
+
try {
|
|
327
|
+
return this.track(new RemoteWindow(this, await opened));
|
|
328
|
+
}
|
|
329
|
+
finally {
|
|
330
|
+
this.opening.delete(opened);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// shows a dialog, once the host has. On macOS, as in Electron, one with no
|
|
334
|
+
// parent holds up the whole host until it's answered, and can't be closed
|
|
335
|
+
// from here - open it from a window (RemoteHandle.openDialog) to avoid that.
|
|
336
|
+
async openDialog(params) {
|
|
337
|
+
const { id } = await this.client.request.dialogOpen(params);
|
|
338
|
+
return this.track(new RemoteDialog(this, id));
|
|
339
|
+
}
|
|
340
|
+
// shows an OS notification, once the host has
|
|
341
|
+
async showNotification(params) {
|
|
342
|
+
const { id } = await this.client.request.notificationShow(params);
|
|
343
|
+
return this.track(new RemoteNotification(this, id));
|
|
344
|
+
}
|
|
345
|
+
// puts an icon in the tray, once the host has - it stays until it's closed
|
|
346
|
+
async createTray(params) {
|
|
347
|
+
const { id } = await this.client.request.trayCreate(params);
|
|
348
|
+
return this.track(new RemoteTray(this, id));
|
|
349
|
+
}
|
|
350
|
+
// opens a window showing an Adaptive Card, once the host has
|
|
351
|
+
async openCard(params) {
|
|
352
|
+
const { id } = await this.client.request.cardOpen(params);
|
|
353
|
+
return this.track(new RemoteCard(this, id));
|
|
354
|
+
}
|
|
355
|
+
// opens a window showing a form, once the host has
|
|
356
|
+
async openForm(params) {
|
|
357
|
+
const { id } = await this.client.request.formOpen(params);
|
|
358
|
+
return this.track(new RemoteForm(this, id));
|
|
359
|
+
}
|
|
360
|
+
track(remote) {
|
|
361
|
+
const ended = this.unclaimed.get(remote.id);
|
|
362
|
+
this.unclaimed.delete(remote.id);
|
|
363
|
+
if (ended)
|
|
364
|
+
remote[end](ended);
|
|
365
|
+
else
|
|
366
|
+
this.remotes.set(remote.id, remote);
|
|
367
|
+
return remote;
|
|
368
|
+
}
|
|
369
|
+
onClose(listener) {
|
|
370
|
+
return this.client.onClose(listener);
|
|
371
|
+
}
|
|
372
|
+
// leaves the host - which, for its owner, ends it
|
|
373
|
+
dispose() {
|
|
374
|
+
this.client.dispose();
|
|
375
|
+
void this.closeBackendServer();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/node/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAsIrG,MAAM,cAAc,GAAG,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;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AAM,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,QAAoB;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,kDAAkD;IAClD,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getEphemeralPrefix(): string;
|
|
2
|
+
export { getTmpSocketPath, listenOnce, sendTo, resolveService, rejectService } from '@cmdless/core/node';
|
|
3
|
+
export { runAsPackage } from '@cmdless/core/node';
|
|
4
|
+
export declare function getCmdlessApp(): string;
|
|
5
|
+
export declare function setCmdlessApp(app: string, env?: NodeJS.ProcessEnv): string;
|
|
6
|
+
export declare function resolveCmdlessApp(): string;
|
|
7
|
+
export declare function getCmdlessUIVersion(): Promise<string>;
|
|
8
|
+
export declare function isEphemeralCmdlessApp(appName: string): boolean;
|
|
9
|
+
export declare function isEphemeralUserData(userData: string): boolean;
|
|
10
|
+
export declare function setCmdlessUrl(url: string, env?: NodeJS.ProcessEnv): void;
|
|
11
|
+
export declare function acquireCmdlessUrl(): string;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/node/utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,kBAAkB,WAEjC;AAGD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAUlD,wBAAgB,aAAa,WAE5B;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,UAG9E;AAED,wBAAgB,iBAAiB,WAEhC;AAID,wBAAgB,mBAAmB,oBAElC;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,WAEpD;AAOD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,WAKnD;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,QAE9E;AAID,wBAAgB,iBAAiB,WAIhC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { getMetaPackageVersion } from '@cmdless/core/node';
|
|
3
|
+
const APP_KEY = 'CMDLESS_APP';
|
|
4
|
+
const URL_KEY = 'CMDLESS_URL';
|
|
5
|
+
export function getEphemeralPrefix() {
|
|
6
|
+
return '.cmdless.ui/';
|
|
7
|
+
}
|
|
8
|
+
// what ui-runtime's host listens, reports and forwards with
|
|
9
|
+
export { getTmpSocketPath, listenOnce, sendTo, resolveService, rejectService } from '@cmdless/core/node';
|
|
10
|
+
// what @cmdless/ui's package command runs with
|
|
11
|
+
export { runAsPackage } from '@cmdless/core/node';
|
|
12
|
+
// the setters below write to this process's env by default, or - given an
|
|
13
|
+
// env to spawn with - only to a child's; an empty value removes the key.
|
|
14
|
+
function setEnv(key, value, env) {
|
|
15
|
+
if (value)
|
|
16
|
+
env[key] = value;
|
|
17
|
+
else
|
|
18
|
+
delete env[key];
|
|
19
|
+
}
|
|
20
|
+
// the app name, which groups processes under one userData
|
|
21
|
+
export function getCmdlessApp() {
|
|
22
|
+
return process.env[APP_KEY] ?? '';
|
|
23
|
+
}
|
|
24
|
+
export function setCmdlessApp(app, env = process.env) {
|
|
25
|
+
setEnv(APP_KEY, app, env);
|
|
26
|
+
return app;
|
|
27
|
+
}
|
|
28
|
+
export function resolveCmdlessApp() {
|
|
29
|
+
return setCmdlessApp(getCmdlessApp() || `${getEphemeralPrefix()}${crypto.randomUUID()}`);
|
|
30
|
+
}
|
|
31
|
+
// this package's own version - what a host and the UIHosts connecting to it
|
|
32
|
+
// have to agree on
|
|
33
|
+
export function getCmdlessUIVersion() {
|
|
34
|
+
return getMetaPackageVersion('@cmdless/ui-sdk', import.meta);
|
|
35
|
+
}
|
|
36
|
+
export function isEphemeralCmdlessApp(appName) {
|
|
37
|
+
return appName.startsWith(getEphemeralPrefix());
|
|
38
|
+
}
|
|
39
|
+
const EPHEMERAL_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
40
|
+
// whether a directory is an ephemeral app's userData: one named as an
|
|
41
|
+
// ephemeral app is, directly inside the ephemeral prefix's folder - wherever
|
|
42
|
+
// that folder is, and whatever separators the platform uses
|
|
43
|
+
export function isEphemeralUserData(userData) {
|
|
44
|
+
if (!path.isAbsolute(userData))
|
|
45
|
+
return false;
|
|
46
|
+
const resolved = path.resolve(userData);
|
|
47
|
+
const folder = getEphemeralPrefix().replace(/[\\/]+$/, '');
|
|
48
|
+
return path.basename(path.dirname(resolved)) === folder && EPHEMERAL_ID.test(path.basename(resolved));
|
|
49
|
+
}
|
|
50
|
+
// a dev server's URL, which a launcher shows instead of its built files
|
|
51
|
+
export function setCmdlessUrl(url, env = process.env) {
|
|
52
|
+
setEnv(URL_KEY, url, env);
|
|
53
|
+
}
|
|
54
|
+
// deletes the env var once read, so a later process spawned down the line
|
|
55
|
+
// (which inherits process.env) doesn't also see it and keep swapping to it.
|
|
56
|
+
export function acquireCmdlessUrl() {
|
|
57
|
+
const url = process.env[URL_KEY] ?? '';
|
|
58
|
+
if (url)
|
|
59
|
+
delete process.env[URL_KEY];
|
|
60
|
+
return url;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/node/utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,OAAO,GAAG,aAAa,CAAC;AAC9B,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B,MAAM,UAAU,kBAAkB;IAChC,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,4DAA4D;AAC5D,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzG,+CAA+C;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,0EAA0E;AAC1E,yEAAyE;AACzE,SAAS,MAAM,CAAC,GAAW,EAAE,KAAa,EAAE,GAAsB;IAChE,IAAI,KAAK;QAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;;QACvB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,GAAG,GAAsB,OAAO,CAAC,GAAG;IAC7E,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,aAAa,CAAC,aAAa,EAA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,OAAO,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/node/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { getEphemeralPrefix, isEphemeralUserData } from './utils.js';
|
|
6
|
+
test('isEphemeralUserData only accepts an ephemeral app\'s directory inside the ephemeral folder', () => {
|
|
7
|
+
const id = '1b85461e-34c0-4186-91c6-f8f134158e2e';
|
|
8
|
+
const root = path.join(os.tmpdir(), getEphemeralPrefix());
|
|
9
|
+
assert.equal(isEphemeralUserData(path.join(root, id)), true);
|
|
10
|
+
assert.equal(isEphemeralUserData(path.join('/anywhere/else', getEphemeralPrefix(), id)), true);
|
|
11
|
+
assert.equal(isEphemeralUserData(path.join(os.tmpdir(), id)), false);
|
|
12
|
+
assert.equal(isEphemeralUserData(path.join(root, 'not-an-id')), false);
|
|
13
|
+
assert.equal(isEphemeralUserData(path.join(root, id, '..')), false);
|
|
14
|
+
assert.equal(isEphemeralUserData(path.join(root, id, 'nested')), false);
|
|
15
|
+
assert.equal(isEphemeralUserData(path.join('.cmdless.ui', id)), false);
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../src/node/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM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|
+
export type ElicitationRequest = {
|
|
3
|
+
message: string;
|
|
4
|
+
requestedSchema: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
export type ElicitationResult = {
|
|
7
|
+
action: 'accept';
|
|
8
|
+
content: Record<string, unknown>;
|
|
9
|
+
} | {
|
|
10
|
+
action: 'decline';
|
|
11
|
+
} | {
|
|
12
|
+
action: 'cancel';
|
|
13
|
+
};
|
|
14
|
+
export declare function elicitationCard({ message, requestedSchema }: ElicitationRequest): AdaptiveCard;
|
|
15
|
+
export declare function elicitationResult(submitted: CardEvent | undefined): ElicitationResult;
|
|
16
|
+
export type PermissionRequest = {
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
options: {
|
|
20
|
+
optionId: string;
|
|
21
|
+
name: string;
|
|
22
|
+
kind: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export type PermissionOutcome = {
|
|
26
|
+
outcome: 'selected';
|
|
27
|
+
optionId: string;
|
|
28
|
+
} | {
|
|
29
|
+
outcome: 'cancelled';
|
|
30
|
+
};
|
|
31
|
+
export declare function permissionCard({ title, description, options }: PermissionRequest): AdaptiveCard;
|
|
32
|
+
export declare function permissionResult(submitted: CardEvent | undefined): PermissionOutcome;
|
|
33
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ1D,MAAM,MAAM,kBAAkB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAE/F,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACtD;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAuBzB,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,kBAAkB,GAAG,YAAY,CAc9F;AAGD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,iBAAiB,CAKrF;AAID,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAIrG,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAe/F;AAGD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,iBAAiB,CAGpF"}
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// what the form in an elicitation card is called among the card's inputs
|
|
2
|
+
const CONTENT = 'content';
|
|
3
|
+
// the requested schema as react-jsonschema-form wants it, with the uiSchema
|
|
4
|
+
// that goes with it: legacy enumNames are labels it reads from the uiSchema,
|
|
5
|
+
// and a multi-select's items are unique (or it draws a list to add to)
|
|
6
|
+
function formSchema(requested) {
|
|
7
|
+
const properties = {};
|
|
8
|
+
const uiSchema = {};
|
|
9
|
+
for (const [name, field] of Object.entries((requested.properties ?? {}))) {
|
|
10
|
+
const { enumNames, ...rest } = field;
|
|
11
|
+
properties[name] = rest.type === 'array' ? { ...rest, uniqueItems: true } : rest;
|
|
12
|
+
if (Array.isArray(enumNames))
|
|
13
|
+
uiSchema[name] = { 'ui:enumNames': enumNames };
|
|
14
|
+
}
|
|
15
|
+
return { schema: { ...requested, type: 'object', properties }, uiSchema };
|
|
16
|
+
}
|
|
17
|
+
// a card asking what an elicitation asks: its message, its schema as a form,
|
|
18
|
+
// and Accept (once the form is valid) or Decline (whatever's in it)
|
|
19
|
+
export function elicitationCard({ message, requestedSchema }) {
|
|
20
|
+
const { schema, uiSchema } = formSchema(requestedSchema);
|
|
21
|
+
return {
|
|
22
|
+
type: 'AdaptiveCard',
|
|
23
|
+
version: '1.5',
|
|
24
|
+
body: [
|
|
25
|
+
{ type: 'TextBlock', text: message, wrap: true },
|
|
26
|
+
{ type: 'Input.JsonSchema', id: CONTENT, schema, uiSchema },
|
|
27
|
+
],
|
|
28
|
+
actions: [
|
|
29
|
+
{ type: 'Action.Submit', title: 'Accept', style: 'positive', data: { action: 'accept' } },
|
|
30
|
+
{ type: 'Action.Submit', title: 'Decline', associatedInputs: 'none', data: { action: 'decline' } },
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// what an elicitation card ended with, as the elicitation's answer
|
|
35
|
+
export function elicitationResult(submitted) {
|
|
36
|
+
const action = submitted?.action.data?.action;
|
|
37
|
+
if (action === 'accept')
|
|
38
|
+
return { action, content: (submitted.inputs[CONTENT] ?? {}) };
|
|
39
|
+
if (action === 'decline')
|
|
40
|
+
return { action };
|
|
41
|
+
return { action: 'cancel' };
|
|
42
|
+
}
|
|
43
|
+
// a card asking a permission request: its title and description, and a
|
|
44
|
+
// button per option - allowing ones first in line, rejecting ones in red
|
|
45
|
+
export function permissionCard({ title, description, options }) {
|
|
46
|
+
return {
|
|
47
|
+
type: 'AdaptiveCard',
|
|
48
|
+
version: '1.5',
|
|
49
|
+
body: [
|
|
50
|
+
{ type: 'TextBlock', text: title, weight: 'Bolder', size: 'Medium', wrap: true },
|
|
51
|
+
...(description ? [{ type: 'TextBlock', text: description, wrap: true, isSubtle: true }] : []),
|
|
52
|
+
],
|
|
53
|
+
actions: options.map(({ optionId, name, kind }) => ({
|
|
54
|
+
type: 'Action.Submit',
|
|
55
|
+
title: name,
|
|
56
|
+
style: kind.startsWith('allow') ? 'positive' : kind.startsWith('reject') ? 'destructive' : 'default',
|
|
57
|
+
data: { optionId },
|
|
58
|
+
})),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// what a permission card ended with, as the request's outcome
|
|
62
|
+
export function permissionResult(submitted) {
|
|
63
|
+
const optionId = submitted?.action.data?.optionId;
|
|
64
|
+
return optionId === undefined ? { outcome: 'cancelled' } : { outcome: 'selected', optionId };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAeA,yEAAyE;AACzE,MAAM,OAAO,GAAG,SAAS,CAAC;AAI1B,4EAA4E;AAC5E,6EAA6E;AAC7E,uEAAuE;AACvE,SAAS,UAAU,CAAC,SAAiB;IACnC,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,CAA2B,CAAC,EAAE,CAAC;QACnG,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QACrC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACjF,IAAI,KAAK,CA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