@mirrowel/opencode-openshare 0.0.0-stage → 0.1.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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -2
  3. package/ci/README.md +56 -0
  4. package/ci/openshare.config.json +5 -0
  5. package/ci/openshare.js +2265 -0
  6. package/dist/commands.d.ts +7 -0
  7. package/dist/commands.js +440 -0
  8. package/dist/config.d.ts +134 -0
  9. package/dist/config.js +517 -0
  10. package/dist/core.d.ts +117 -0
  11. package/dist/core.js +1944 -0
  12. package/dist/dialogs.d.ts +94 -0
  13. package/dist/dialogs.js +725 -0
  14. package/dist/server.d.ts +64 -0
  15. package/dist/server.js +30 -0
  16. package/dist/settings.d.ts +24 -0
  17. package/dist/settings.js +1226 -0
  18. package/dist/share-flow.d.ts +287 -0
  19. package/dist/share-flow.js +516 -0
  20. package/dist/sidebar.d.ts +19 -0
  21. package/dist/sidebar.js +144 -0
  22. package/dist/tui-host.d.ts +158 -0
  23. package/dist/tui-host.js +6 -0
  24. package/dist/tui.d.ts +17 -0
  25. package/dist/tui.js +4762 -0
  26. package/dist/ui-prefs.d.ts +16 -0
  27. package/dist/ui-prefs.js +27 -0
  28. package/dist/v2-server.d.ts +81 -0
  29. package/dist/v2-server.js +402 -0
  30. package/dist/v2-tui.d.ts +24 -0
  31. package/dist/v2-tui.js +313 -0
  32. package/dist/v2-types.d.ts +134 -0
  33. package/dist/v2-types.js +8 -0
  34. package/openshare.config.json +16 -0
  35. package/package.json +98 -4
  36. package/src/banner.txt +22 -0
  37. package/src/commands.ts +452 -0
  38. package/src/config.ts +518 -0
  39. package/src/core.ts +1997 -0
  40. package/src/dialogs.tsx +971 -0
  41. package/src/server.ts +47 -0
  42. package/src/settings.ts +1239 -0
  43. package/src/share-flow.ts +551 -0
  44. package/src/sidebar.tsx +187 -0
  45. package/src/tui-host.ts +134 -0
  46. package/src/tui.tsx +318 -0
  47. package/src/ui-prefs.ts +36 -0
  48. package/src/v2-server.ts +438 -0
  49. package/src/v2-tui.ts +315 -0
  50. package/src/v2-types.ts +102 -0
  51. package/tsconfig.json +18 -0
@@ -0,0 +1,452 @@
1
+ // OpenShare command registration. ONE user-facing /share command shadows
2
+ // the deprecated built-in (opncd.ai) by registering the same command name
3
+ // on a plugin keymap layer; running it on a shared session opens the
4
+ // share manager (copy link / stop sharing) instead — you can't share
5
+ // twice, so /share is a toggle. /openshare opens settings.
6
+ //
7
+ // LAYER SHAPE (live-caught 2026-10-19): the v1 host keymap gates layers
8
+ // that declare `mode` on the mode stack (resting mode is "base"), so a
9
+ // plugin layer MUST NOT pass mode ("global" made the whole layer
10
+ // unreachable — no palette entries, no slash commands, no shadow) and
11
+ // must not carry undefined-valued command fields. The registration shape
12
+ // is exactly what the proven family plugins use: {commands, bindings},
13
+ // commands with only defined fields, category "OpenShare" (own group,
14
+ // deliberately NOT joined into the shared family palette category).
15
+
16
+ import {
17
+ CONSENT_KV_KEY,
18
+ clearGoneBindingEntries,
19
+ confirmShare,
20
+ currentConfig,
21
+ isConfigured,
22
+ hostOf,
23
+ patchSessionBinding,
24
+ readBinding,
25
+ readBindings,
26
+ resolveRoot,
27
+ runShareFlow,
28
+ runUnshareFlow,
29
+ serverEntries,
30
+ verifyShare,
31
+ workerDeleteShare,
32
+ } from "./share-flow.js"
33
+ import { onboardingDialog, settingsDialog } from "./settings.js"
34
+ import { dbgLog } from "./sidebar.js"
35
+ import type { ShareHostApi, ShareHostLayerCommand } from "./tui-host.js"
36
+
37
+ export const PALETTE_CATEGORY = "OpenShare"
38
+
39
+ function finish(host: ShareHostApi, result: { ok: boolean; message: string; url?: string; unconfigured?: boolean }) {
40
+ // terminal point of a flow: the dialog chain is over — clear the host
41
+ // stack explicitly (done() no longer clears; replace-without-clear was
42
+ // the flicker fix, so chain ENDS own the clear)
43
+ try {
44
+ host.ui.dialog.clear()
45
+ } catch {}
46
+ host.ui.toast({
47
+ variant: result.ok ? "success" : result.unconfigured ? "warning" : "error",
48
+ title: "OpenShare",
49
+ message: result.message,
50
+ duration: result.ok ? 8000 : 15000,
51
+ })
52
+ }
53
+
54
+ /** The already-shared state: per-server management for the fan-out era.
55
+ * Single binding keeps the compact classic menu; multiple bindings get a
56
+ * per-server submenu (copy / stop here / leave as-is) plus all-stop.
57
+ * Opens with a liveness sweep: bindings whose page died server-side
58
+ * (purge/TTL/delete) are auto-cleared and surfaced in a gone modal. */
59
+ async function showShareManager(host: ShareHostApi, sessionID: () => string | undefined) {
60
+ const sid = sessionID()
61
+ if (!sid) return
62
+ const root = await resolveRoot(host.client, sid)
63
+ let all = await readBindings(host.client, root)
64
+
65
+ // collision first: the engine marked a server's credentials as rejected
66
+ const collided = all.find((b) => b.collided)
67
+ if (collided) return showCollisionDialog(host, root, collided.server, collided.id, collided.collided ?? "")
68
+
69
+ // liveness sweep: probe every live-bound server (credential-free /data
70
+ // check). GONE entries are removed from the binding automatically; the
71
+ // modal says what happened and offers to re-share. Network errors are
72
+ // "unknown" and never treated as gone.
73
+ const live = all.filter((b) => b.url && b.enabled !== false && b.id)
74
+ if (live.length) {
75
+ const verdicts = await Promise.all(live.map((b) => verifyShare(b.server, b.id)))
76
+ const gone = live.filter((b, i) => verdicts[i] === "gone")
77
+ if (gone.length) {
78
+ await clearGoneBindingEntries(host, root, gone.map((b) => b.server))
79
+ all = all.filter((b) => !gone.some((g) => g.server === b.server))
80
+ const list = gone.map((b) => `• ${hostOf(b.url || b.server)} — ${b.url}`).join("\n")
81
+ const choice = await host.ui.showMenu<string>({
82
+ title: "Share is gone",
83
+ hint: "The page was removed, expired, or purged on the server — sharing disabled for it.",
84
+ options: [
85
+ { title: "Share again", value: "again", description: "create a fresh page with the full history", help: `The stale binding was already cleared. Sharing again creates a brand-new page on the ACTIVE server with this session's full history backfilled.\n\nGone:\n${list}` },
86
+ { title: "Close", value: "close", description: "leave the session unshared", help: `The stale binding entries were cleared automatically; the session is not shared anymore. Run /share any time to share it fresh.\n\nGone:\n${list}` },
87
+ ],
88
+ })
89
+ if (choice === "again") {
90
+ finish(host, await runShareFlow(host, sid))
91
+ return
92
+ }
93
+ if (all.length === 0) return
94
+ }
95
+ }
96
+
97
+ if (all.length === 0) return
98
+
99
+ const otherServers = serverEntries().filter((s) => !all.some((b) => b.server === s.url))
100
+
101
+ if (all.length === 1 && otherServers.length === 0) {
102
+ // the classic single-server menu
103
+ const b = all[0]
104
+ void host.ui
105
+ .showMenu<string>({
106
+ title: "Session is shared",
107
+ hint: b.url,
108
+ options: [
109
+ {
110
+ title: "Copy share link",
111
+ value: "copy",
112
+ description: "copy the share URL to the clipboard",
113
+ help: `Copies the share URL to the clipboard (navigator + OSC52 fallback).\n\nURL: ${b.url}\nServer: ${b.server}\nShare id: ${b.id}\n\nAnyone with the link can read the page (plus the login, if read auth is set).`,
114
+ },
115
+ {
116
+ title: "Stop sharing",
117
+ value: "stop",
118
+ description: "Delete the share page — the link stops working for everyone",
119
+ help: `Deletes the page on ${hostOf(b.url || b.server)} server-side and clears this session's share flag. Viewers with the link see a final "gone" state. This cannot be undone — sharing again creates a NEW page with a new URL.`,
120
+ },
121
+ { title: "Cancel", value: "cancel" },
122
+ ],
123
+ })
124
+ .then(async (choice) => {
125
+ if (choice === "copy") {
126
+ const ok = await host.clipboard.write(b.url)
127
+ finish(host, ok ? { ok: true, message: `Share URL copied to clipboard: ${b.url}`, url: b.url } : { ok: false, message: `Could not write the clipboard — link: ${b.url}`, url: b.url })
128
+ return
129
+ }
130
+ if (choice === "stop") {
131
+ const how = await host.ui.showMenu<string>({
132
+ title: "Stop sharing",
133
+ hint: b.url,
134
+ options: [
135
+ {
136
+ title: "Delete the page",
137
+ value: "delete",
138
+ description: "the link stops working for everyone",
139
+ danger: true,
140
+ help: `Deletes the page on ${hostOf(b.url || b.server)} and clears this session's share flag. Viewers with the link see a final "gone" state. Sharing again later creates a fresh page with a new URL.`,
141
+ },
142
+ {
143
+ title: "Leave as-is (snapshot)",
144
+ value: "leave",
145
+ description: "stop updating; the page stays until its TTL",
146
+ help: `Stops mirroring WITHOUT deleting anything — viewers keep reading the snapshot until the share's TTL expires. Useful for handing someone a frozen copy while you keep working.`,
147
+ },
148
+ { title: "Cancel", value: "cancel" },
149
+ ],
150
+ })
151
+ if (!how || how === "cancel") return
152
+ if (how === "leave") {
153
+ await patchSessionBinding(host.client, root, (servers) => {
154
+ delete servers[b.server]
155
+ servers[b.server] = { optedOut: true }
156
+ })
157
+ finish(host, { ok: true, message: `${hostOf(b.url || b.server)} left as-is — a snapshot until its TTL.` })
158
+ return
159
+ }
160
+ const yes = await host.ui.showConfirm({
161
+ title: "Delete the share page",
162
+ message: `Delete the page on ${hostOf(b.url || b.server)}?\nThe link stops working for everyone.`,
163
+ confirmLabel: "Delete",
164
+ danger: true,
165
+ })
166
+ if (!yes) {
167
+ host.ui.dialog.clear()
168
+ return
169
+ }
170
+ finish(host, await runUnshareFlow(host, sessionID()))
171
+ }
172
+ })
173
+ return
174
+ }
175
+
176
+ // fan-out menu
177
+ const options: Array<{ title: string; value: string; description?: string; help?: string; danger?: boolean }> = all.map((b) => ({
178
+ title: `Copy link — ${hostOf(b.url || b.server)}`,
179
+ value: `copy:${b.server}`,
180
+ description: b.url,
181
+ help: `Copies this server's share URL to the clipboard.\n\nURL: ${b.url}\nServer: ${b.server}\nShare id: ${b.id}\n\nEach server carries an independent page of the same session.`,
182
+ }))
183
+ options.push({
184
+ title: "Manage per server…",
185
+ value: "manage",
186
+ description: `${all.length} servers — stop one, leave a snapshot`,
187
+ help: `Per-server actions: copy the link, stop sharing there (page deleted), or leave it as a read-only snapshot (updates stop, the page lives out its TTL). Other servers are unaffected.\n\nBound servers:\n${all.map((b) => `• ${b.server} — ${b.url}`).join("\n")}`,
188
+ })
189
+ if (otherServers.length) {
190
+ options.push({
191
+ title: "Share to another server…",
192
+ value: "more",
193
+ description: otherServers.map((s) => hostOf(s.url)).join(", "),
194
+ help: `Adds one of your other configured servers as a destination for THIS session: it becomes the active server and the full history is mirrored there within seconds.\n\nAvailable:\n${otherServers.map((s) => `• ${s.url}`).join("\n")}`,
195
+ })
196
+ }
197
+ options.push({
198
+ title: "Stop sharing (all)",
199
+ value: "stop-all",
200
+ description: "delete every server's page, or leave snapshots",
201
+ danger: true,
202
+ help: `Deletes the page on all ${all.length} servers (or leaves them as read-only snapshots — your choice on the next screen) and clears the share flag. Sharing again creates fresh pages.`,
203
+ })
204
+ options.push({ title: "Cancel", value: "cancel" })
205
+ const choice = await host.ui.showMenu<string>({ title: `Session is shared · ${all.length} servers`, options })
206
+ if (!choice || choice === "cancel") return
207
+ if (choice.startsWith("copy:")) {
208
+ const b = all.find((x) => `copy:${x.server}` === choice)
209
+ if (b) {
210
+ const ok = await host.clipboard.write(b.url)
211
+ finish(host, ok ? { ok: true, message: `Share URL copied: ${b.url}`, url: b.url } : { ok: false, message: `Clipboard failed — ${b.url}`, url: b.url })
212
+ }
213
+ return
214
+ }
215
+ if (choice === "stop-all") {
216
+ const how = await host.ui.showMenu<string>({
217
+ title: `Stop sharing · ${all.length} servers`,
218
+ options: [
219
+ { title: "Delete every page", value: "delete", description: "all links stop working", danger: true, help: `Deletes the page on every bound server (${all.map((b) => hostOf(b.url || b.server)).join(", ")}) and clears the share flag.` },
220
+ { title: "Leave all as-is (snapshots)", value: "leave", description: "stop updating; pages stay until their TTLs", help: `Stops mirroring everywhere without deleting anything — every page stays readable as a frozen snapshot until its TTL expires.` },
221
+ { title: "Cancel", value: "cancel" },
222
+ ],
223
+ })
224
+ if (!how || how === "cancel") return
225
+ if (how === "leave") {
226
+ await patchSessionBinding(host.client, root, (servers) => {
227
+ for (const b of all) {
228
+ delete servers[b.server]
229
+ servers[b.server] = { optedOut: true }
230
+ }
231
+ })
232
+ finish(host, { ok: true, message: `${all.length} server(s) left as-is — snapshots until their TTLs.` })
233
+ return
234
+ }
235
+ const yes = await host.ui.showConfirm({
236
+ title: "Stop sharing",
237
+ message: `Delete the share pages on all ${all.length} servers? The links stop working for everyone.`,
238
+ confirmLabel: "Stop all",
239
+ danger: true,
240
+ })
241
+ if (!yes) return
242
+ finish(host, await runUnshareFlow(host, sessionID()))
243
+ return
244
+ }
245
+ if (choice === "more") {
246
+ const pick = await host.ui.showMenu<string>({
247
+ title: "Share to another server",
248
+ options: [...otherServers.map((s) => ({ title: hostOf(s.url), value: s.url, description: s.entry.label })), { title: "Cancel", value: "__cancel" }],
249
+ })
250
+ if (!pick || pick === "__cancel") return
251
+ const { saveServerEntry } = await import("./share-flow.js")
252
+ for (const s of serverEntries()) if (s.url !== pick) saveServerEntry(s.url, { active: undefined })
253
+ saveServerEntry(pick, { active: true })
254
+ finish(host, { ok: true, message: `${hostOf(pick)} activated — this session mirrors there within seconds (new sessions share to it too).` })
255
+ return
256
+ }
257
+ if (choice === "manage") {
258
+ const pick = await host.ui.showMenu<string>({
259
+ title: "Manage server",
260
+ options: [...all.map((b) => ({ title: hostOf(b.url || b.server), value: b.server, description: b.url })), { title: "Cancel", value: "__cancel" }],
261
+ })
262
+ if (!pick || pick === "__cancel") return
263
+ const b = all.find((x) => x.server === pick)
264
+ if (!b) return
265
+ const action = await host.ui.showMenu<string>({
266
+ title: `${hostOf(b.url || b.server)}`,
267
+ hint: b.url,
268
+ options: [
269
+ {
270
+ title: "Copy link",
271
+ value: "copy",
272
+ description: "copy the share URL",
273
+ help: `Copies this server's share URL to the clipboard.\n\nURL: ${b.url}\nShare id: ${b.id}`,
274
+ },
275
+ {
276
+ title: "Stop sharing here",
277
+ value: "stop",
278
+ description: "delete THIS server's page; other servers unaffected",
279
+ help: `Deletes the page on ${hostOf(b.url || b.server)} and retires this server for the session (the engine stops mirroring here). Other servers keep streaming. Sharing here again later creates a new page.`,
280
+ },
281
+ {
282
+ title: "Leave as-is (snapshot)",
283
+ value: "leave",
284
+ description: "stop updating it; the page stays until its TTL",
285
+ help: `Stops mirroring to ${hostOf(b.url || b.server)} WITHOUT deleting anything — viewers keep reading the snapshot until the share's TTL expires. Useful for handing someone a frozen copy while you keep working.`,
286
+ },
287
+ { title: "Cancel", value: "cancel" },
288
+ ],
289
+ })
290
+ if (!action || action === "cancel") return
291
+ if (action === "copy") {
292
+ const ok = await host.clipboard.write(b.url)
293
+ finish(host, ok ? { ok: true, message: `Share URL copied: ${b.url}`, url: b.url } : { ok: false, message: `Clipboard failed — ${b.url}`, url: b.url })
294
+ return
295
+ }
296
+ if (action === "stop") {
297
+ const deleted = await workerDeleteShare(b.server || b.url.slice(0, b.url.indexOf("/s/")), b.id, b.secret)
298
+ await patchSessionBinding(host.client, root, (servers) => {
299
+ delete servers[b.server]
300
+ servers[b.server] = { optedOut: true }
301
+ })
302
+ finish(host, { ok: true, message: deleted ? `Stopped sharing on ${hostOf(b.url || b.server)} — page deleted.` : `Stopped sharing on ${hostOf(b.url || b.server)} (page deletion follows via the sweeper).` })
303
+ return
304
+ }
305
+ if (action === "leave") {
306
+ await patchSessionBinding(host.client, root, (servers) => {
307
+ delete servers[b.server]
308
+ servers[b.server] = { optedOut: true }
309
+ })
310
+ finish(host, { ok: true, message: `${hostOf(b.url || b.server)} left as-is — a snapshot until its TTL.` })
311
+ return
312
+ }
313
+ }
314
+ }
315
+
316
+ /** Credential collision: the engine refused to auto-recreate. The user
317
+ * chooses: copy debug info (for the hoster/issue), share on a new share,
318
+ * or don't share. */
319
+ async function showCollisionDialog(host: ShareHostApi, root: string, server: string, shareId: string, error: string) {
320
+ const debugInfo = JSON.stringify({ server, shareId, error, sessionID: root, plugin: "openshare", time: new Date().toISOString() }, null, 2)
321
+ const choice = await host.ui.showMenu<string>({
322
+ title: `Share conflict — ${hostOf(server)}`,
323
+ hint: `saved credentials for ${shareId.slice(0, 12)}… were rejected (${error})`,
324
+ options: [
325
+ {
326
+ title: "Copy debug info",
327
+ value: "debug",
328
+ description: "server, share id, error — for the hoster or an issue report",
329
+ help: `Copies a JSON blob with the server, share id, exact error, and session id — attach it when reporting to the hoster or filing an issue.\n\n${debugInfo}`,
330
+ },
331
+ {
332
+ title: "Share on a new share",
333
+ value: "new",
334
+ description: "abandon the old binding; create a fresh share with full history",
335
+ help: `Drops the rejected binding and lets the engine create a brand-new share on ${hostOf(server)} with the session's full history. The old page (whoever owns it now) is left untouched.`,
336
+ },
337
+ {
338
+ title: "Don't share here",
339
+ value: "no",
340
+ description: "leave the old page; this server stops receiving this session",
341
+ help: `Opts this session out on ${hostOf(server)}: the engine stops trying to attach. The rejected page stays as-is. Re-share here anytime via "Share to another server".`,
342
+ },
343
+ { title: "Cancel", value: "cancel" },
344
+ ],
345
+ })
346
+ if (!choice || choice === "cancel") return
347
+ if (choice === "debug") {
348
+ const ok = await host.clipboard.write(debugInfo)
349
+ finish(host, ok ? { ok: true, message: "Debug info copied to clipboard." } : { ok: false, message: `Clipboard failed:\n${debugInfo}` })
350
+ return
351
+ }
352
+ if (choice === "new") {
353
+ await patchSessionBinding(host.client, root, (servers) => {
354
+ delete servers[server]
355
+ })
356
+ finish(host, { ok: true, message: `Re-sharing on ${hostOf(server)} — a new share appears within seconds.` })
357
+ return
358
+ }
359
+ if (choice === "no") {
360
+ await patchSessionBinding(host.client, root, (servers) => {
361
+ delete servers[server]
362
+ servers[server] = { optedOut: true }
363
+ })
364
+ finish(host, { ok: true, message: `${hostOf(server)} opted out for this session.` })
365
+ }
366
+ }
367
+
368
+ export function buildShareCommand(host: ShareHostApi, sessionID: () => string | undefined): ShareHostLayerCommand {
369
+ return {
370
+ name: "session.share",
371
+ title: "Share session (re:share)",
372
+ desc: "Share this session via openshare; on a shared session: copy the link or stop sharing",
373
+ slashName: "share",
374
+ slashAliases: ["reshare"],
375
+ category: PALETTE_CATEGORY,
376
+ group: PALETTE_CATEGORY,
377
+ run: async () => {
378
+ dbgLog(`/share run: entered (sid=${sessionID() ?? "none"})`)
379
+ host.ui.dialog.clear()
380
+ const cfg = currentConfig()
381
+ if (!isConfigured(cfg)) {
382
+ void onboardingDialog(host)
383
+ return
384
+ }
385
+ const sid = sessionID()
386
+ if (!sid) {
387
+ finish(host, { ok: false, message: "No active session to share." })
388
+ return
389
+ }
390
+ const root = await resolveRoot(host.client, sid)
391
+ const bindings = await readBindings(host.client, root)
392
+ const binding = bindings[0]
393
+ dbgLog(`/share gate: sid=${sid} root=${root} bindings=${bindings.length}`)
394
+ // live ⇔ url && enabled !== false (all-mode bindings carry
395
+ // enabled:true since the fix; legacy all-mode bindings without the
396
+ // field are live too — only an explicit false is dormant)
397
+ if (bindings.some((b) => b.url && b.enabled !== false)) {
398
+ await showShareManager(host, sessionID)
399
+ host.ui.dialog.clear()
400
+ return
401
+ }
402
+ // not shared (or dormant): the normal flow — consent once, then share
403
+ const result = await runShareFlow(host, sid)
404
+ if (result.message === "consent required") {
405
+ const yes = await host.ui.showConfirm({
406
+ title: "Share Session",
407
+ message: "Publish this session (and its subagent sessions) to your openshare worker?\nThe link lets anyone with it read the conversation.",
408
+ confirmLabel: "Share",
409
+ })
410
+ if (!yes) return
411
+ try {
412
+ host.kv.set(CONSENT_KV_KEY, true)
413
+ dbgLog("consent kv.set ok")
414
+ } catch (e) {
415
+ dbgLog(`consent kv.set THREW: ${(e as Error)?.message ?? e}`)
416
+ }
417
+ try {
418
+ finish(host, await confirmShare(host, root))
419
+ } catch (e) {
420
+ dbgLog(`confirmShare rejected: ${(e as Error)?.stack ?? e}`)
421
+ finish(host, { ok: false, message: "Share failed (see debug log)." })
422
+ }
423
+ return
424
+ }
425
+ finish(host, result)
426
+ },
427
+ }
428
+ }
429
+
430
+ export function buildSettingsCommand(host: ShareHostApi, sessionID: () => string | undefined): ShareHostLayerCommand {
431
+ return {
432
+ name: "openshare.settings",
433
+ title: "OpenShare: Settings",
434
+ desc: "Worker connection, sharing defaults, read auth, this session",
435
+ slashName: "openshare",
436
+ category: PALETTE_CATEGORY,
437
+ group: PALETTE_CATEGORY,
438
+ run: async () => {
439
+ host.ui.dialog.clear()
440
+ await settingsDialog(host, sessionID())
441
+ },
442
+ }
443
+ }
444
+
445
+ /** Registers the /share toggle + /openshare settings on one keymap layer.
446
+ * Returns the unregister function. */
447
+ export function registerCommands(host: ShareHostApi, sessionID: () => string | undefined): () => void {
448
+ return host.keymap.registerLayer({
449
+ commands: [buildShareCommand(host, sessionID), buildSettingsCommand(host, sessionID)],
450
+ bindings: [],
451
+ })
452
+ }