clavarium 0.2.478-next.1 → 0.2.479-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.478-next.1",
3
+ "version": "0.2.479-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.478-next.1",
9
+ "version": "0.2.479-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -14,7 +14,7 @@
14
14
  "clavarium-binder": "0.1.63-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
16
  "clavarium-parley": "0.17.95-next.1",
17
- "clavarium-tether": "0.1.0-next.72",
17
+ "clavarium-tether": "0.1.0-next.73",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
20
20
  "node-pty": "^1.1.0",
@@ -800,9 +800,9 @@
800
800
  }
801
801
  },
802
802
  "node_modules/clavarium-tether": {
803
- "version": "0.1.0-next.72",
804
- "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.72.tgz",
805
- "integrity": "sha512-v8dr19nsZ+hY8GTZd0aLy6G5FP430yruhOZKVhjcQhJtT9X2iTnCzT8LNseEdSkHZ4pHPrfy00VxfvlPp13rAQ==",
803
+ "version": "0.1.0-next.73",
804
+ "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.73.tgz",
805
+ "integrity": "sha512-uCOyxj8aQGnspdXvp/E7eoCjwt0FwAGFKLQtJyHd61rulozuPkHswTH1fCis7yjmrc730eTkGpReWpdbOpbOnw==",
806
806
  "license": "MIT",
807
807
  "bin": {
808
808
  "tether": "bin/cli.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.478-next.1",
3
+ "version": "0.2.479-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -48,7 +48,7 @@
48
48
  "clavarium-binder": "0.1.63-next.1",
49
49
  "clavarium-docket": "0.1.2-next.2",
50
50
  "clavarium-parley": "0.17.95-next.1",
51
- "clavarium-tether": "0.1.0-next.72",
51
+ "clavarium-tether": "0.1.0-next.73",
52
52
  "mammoth": "1.13.0",
53
53
  "mermaid": "11.17.2",
54
54
  "node-pty": "^1.1.0",
package/server/agenda.mjs CHANGED
@@ -83,6 +83,9 @@ const SHOW = { busy: 'busy', free: 'free', tentative: 'tentative', oof: 'away',
83
83
  panels read only the top level, and fell back to the text lines: no invitation text, no link, no organizer). */
84
84
  export const handed = (got) => (got?.data?.data && typeof got.data.data === 'object' && !Array.isArray(got.data.data) ? { ...got, data: got.data.data } : got);
85
85
 
86
+ /* A meeting its organiser cancelled: Tether says so (Microsoft's isCancelled), or its title does, as the calendar
87
+ servers write it on an invitee's copy (« Annulé : », "Canceled:"). The page strikes it out (17-11). */
88
+ export const CANCELLED = /^\s*(annul[ée]e?|canceled|cancelled|abgesagt|cancelado|annullato)\s*:/i;
86
89
  /* One event Tether handed as data, kept to the fields the page shows. */
87
90
  export function eventOf(e) {
88
91
  const start = timeOf(e?.start);
@@ -93,6 +96,7 @@ export function eventOf(e) {
93
96
  id: line(e.id, 2048), title: line(e.title) || '(no title)', start, end: timeOf(e.end), allDay,
94
97
  location: line(e.location), organizer: line(e.organizer, 320), online: linkOf(e.online), notes: notesOf(e.notes),
95
98
  attendees: Number.isInteger(n) && n >= 0 ? n : null, show: SHOW[String(e.show ?? '').toLowerCase()] ?? null,
99
+ cancelled: e.cancelled === true || CANCELLED.test(String(e.title ?? '')),
96
100
  };
97
101
  }
98
102
 
package/server/api.mjs CHANGED
@@ -175,6 +175,8 @@
175
175
  * POST /api/tether/agenda {target, from?, to?}: a calendar's events of a window, read now (agenda.mjs)
176
176
  * POST /api/tether/mail-list|mail-read {target, folder?, text?} | {target, id, folder?}: a mailbox's latest messages, one as text (mailview.mjs)
177
177
  * POST /api/tether/contacts|contact {target, text?} | {target, id}: an address book's contacts, one (contactview.mjs)
178
+ * POST /api/tether/ssh-add {title, host, port?, user, key, pin?}: a machine over SSH, opened with a key made
179
+ * here; its host key read and pinned first (sshmachine.mjs)
178
180
  * POST /api/tether/console-journal {target}: a machine's shared console, its short journal (sshconsole.mjs);
179
181
  * the console itself is a WebSocket, /api/tether/console?target=ID
180
182
  * POST /api/files/import?c=...&r=...&p=<folder>&name=<file name>[&dir=<subfolders>&exists=keep|replace|skip&batch=<id>] the body IS the file
@@ -183,6 +185,7 @@
183
185
  * A request that changes something must come from this site's own pages: the
184
186
  * Origin header is compared, and the body must be JSON, which a form on
185
187
  * another site cannot send. */
188
+ import { addMachine } from './sshmachine.mjs';
186
189
  import { openCodeConfig } from './catalog.mjs';
187
190
  import { writeFileSync } from 'node:fs';
188
191
  import { suggest } from './suggest.mjs';
@@ -709,6 +712,7 @@ export async function handleApi(request, response, conversations, headers, resou
709
712
  /* External MCP servers (mcpx.mjs): added with their key (kept host-only in the vault, Tether given its name),
710
713
  imported from a pasted mcpServers block, listed again, a conversation's rights on their tools, new tools seen. */
711
714
  /* Signing in to one with OAuth: the link the owner opens ({ url }), or { need: 'client' } for a client id to paste. */
715
+ if (pathname === '/api/tether/ssh-add' && tethers && gitAccess) return send(201, await addMachine({ tethers, keys: gitAccess, ...(tethers.sshProbe ? { probe: tethers.sshProbe } : {}) }, body ?? {})), true;
712
716
  if (pathname === '/api/tether/mcp-oauth' && tethers?.oauth) return send(200, await tethers.oauth.start({ tethers }, body ?? {}, sharing?.origin?.(request.headers) ?? `http://${request.headers.host}`)), true;
713
717
  const mcpOp = /^\/api\/tether\/mcp-(add|import|refresh|rights|seen)$/.exec(pathname);
714
718
  if (mcpOp && tethers) {
@@ -146,7 +146,7 @@ const quote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
146
146
  const originOf = (address) => `https://${address.host}${address.port ? `:${address.port}` : ''}`;
147
147
 
148
148
  export class GitAccess {
149
- #keys; #credentials; #vault; #dir; #ssh;
149
+ #keys; #credentials; #vault; #dir; #ssh; #machines = () => [];
150
150
 
151
151
  /* `ssh`: the ssh program. A test gives a stand-in that plays a remote. */
152
152
  constructor({ vault, dataDir, keys = new Store(`${dataDir}/git-keys.json`), credentials = new Store(`${dataDir}/git-access.json`), ssh = 'ssh' }) {
@@ -160,7 +160,16 @@ export class GitAccess {
160
160
  /* Where a key lives for the length of one git command. */
161
161
  get runDir() { return `${this.#dir}/run`; }
162
162
 
163
- #usersOf(key) { return this.#credentials.all().filter((c) => c.method === 'ssh-key' && c.key === key).map((c) => c.name); }
163
+ #usersOf(key) { return [...this.#credentials.all().filter((c) => c.method === 'ssh-key' && c.key === key).map((c) => c.name), ...this.#machines(key)]; }
164
+
165
+ /* THE SAME KEYS OPEN MACHINES (Tether's SSH accesses, sshmachine.mjs, 17-11): `using(key)` names the machines a key
166
+ opens, so that "used by" says them and a key in use is not removed. */
167
+ machinesUsing(using) { this.#machines = typeof using === 'function' ? using : () => []; }
168
+ /* The private half, for Tether's SSH connector alone (tethers.mjs reveal): never sent to the page. */
169
+ privateKeyOf(name) {
170
+ const key = this.#keys.get(String(name ?? ''));
171
+ return key ? this.#vault.open(key.sealed) : undefined;
172
+ }
164
173
 
165
174
  /* What the page may know of the keys: the public half, never the private one. */
166
175
  keys() {
@@ -183,7 +192,7 @@ export class GitAccess {
183
192
  removeKey(name) {
184
193
  if (!this.#keys.get(String(name))) throw new Refusal(404, 'No such key.');
185
194
  const used = this.#usersOf(String(name));
186
- if (used.length > 0) throw new Refusal(409, `This key is how ${used.join(', ')} ${used.length > 1 ? 'are' : 'is'} reached: removing it would cut ${used.length > 1 ? 'them' : 'it'} off. Remove ${used.length > 1 ? 'those repositories' : 'that repository'} first.`);
195
+ if (used.length > 0) throw new Refusal(409, `This key is how ${used.join(', ')} ${used.length > 1 ? 'are' : 'is'} reached: removing it would cut ${used.length > 1 ? 'them' : 'it'} off. Remove ${used.length > 1 ? 'them' : 'it'} first.`);
187
196
  this.#keys.remove(String(name));
188
197
  }
189
198
 
package/server/main.mjs CHANGED
@@ -54,6 +54,7 @@ import { Mailboxes, recentMessages } from './mailbox.mjs';
54
54
  import { Grants } from './grants.mjs';
55
55
  import { Groups } from './groups.mjs';
56
56
  import { GitReview } from './gitpush.mjs';
57
+ import { machinesUsing } from './sshmachine.mjs';
57
58
  import { GitAccess } from './gitaccess.mjs';
58
59
  import { GitChecks } from './gitchecks.mjs';
59
60
  import { GitKeeper } from './gitkeeper.mjs';
@@ -312,7 +313,7 @@ const PARLEY_WAIT_MS = 20_000;
312
313
  /* The product: conversations are VMs. `host` is how the host program is
313
314
  reached on this installation, as an argument vector: it is the ONLY thing
314
315
  this server runs with more rights than its own. */
315
- export async function startHome({ port, host, dataDir, mntDir = dataDir, gitReserveBytes, env = process.env, conversations, resources, operators = [], publicOrigin, vaultKey, tools = loadTools(), stopDelayMs, mailReader, gitLocalRemotes = false, gitSsh, answerFetcher, answerEveryMs, wakeEveryMs, alertSend, talkEveryMs, gitEveryMs, shelfEveryMs, shelfFirstMs, healthEveryMs, healthSettleMs, setupPollMs, rereadAfterMs, serverRoomMs, updateState, updateConf, appName, startWaitMs = 20_000, vmWatchEveryMs, historyEveryMs = HISTORY_STEP_MS, tetherConnectors }) {
316
+ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitReserveBytes, env = process.env, conversations, resources, operators = [], publicOrigin, vaultKey, tools = loadTools(), stopDelayMs, mailReader, gitLocalRemotes = false, gitSsh, answerFetcher, answerEveryMs, wakeEveryMs, alertSend, talkEveryMs, gitEveryMs, shelfEveryMs, shelfFirstMs, healthEveryMs, healthSettleMs, setupPollMs, rereadAfterMs, serverRoomMs, updateState, updateConf, appName, startWaitMs = 20_000, vmWatchEveryMs, historyEveryMs = HISTORY_STEP_MS, tetherConnectors, sshProbe }) {
316
317
  /* The data, in the format this code reads, before anything reads it (dataformat.mjs). */
317
318
  const migrated = migrateData(dataDir);
318
319
  if (migrated.ran.length) console.log(`data: format ${migrated.from} -> ${migrated.to}`);
@@ -509,6 +510,11 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
509
510
  let tethers = null;
510
511
  const browsers = new Browsers({ dataDir, store: () => tethers?.store(), log: (line) => console.log(line) });
511
512
  tethers = new Tethers({ dataDir, resources: folders, conversations: () => all.list().map((c) => c.name), secrets, dockets, browsers, connectors: { voicebox: { run: (...a) => voiceboxConnector(boxes).run(...a) }, ...(tetherConnectors ?? {}) } });
513
+ /* The SSH keys made here open machines too (sshmachine.mjs): Tether asks the private half by name; "used by" names them. */
514
+ tethers.sshKeys = gitAccess;
515
+ gitAccess.machinesUsing(machinesUsing(tethers));
516
+ /* A test reads a machine's host key from a stand-in (no network). */
517
+ if (sshProbe) tethers.sshProbe = sshProbe;
512
518
  /* External MCP servers signed in with OAuth: their tokens held here, refreshed here (mcpoauth.mjs). */
513
519
  tethers.oauth = new McpOAuth({ secrets });
514
520
  const stopTethers = tethers.start();
@@ -212,6 +212,11 @@ export const SETTINGS_WORDS_FR = {
212
212
  'set-rt-mcp-hint-frame': 'Votre choix pour chaque sorte d\'outil',
213
213
  /* A browser paired through the Tether extension (browsers.mjs): the form, its panel, Frame's sites. */
214
214
  'set-na-k-browser': 'Navigateur', 'set-br-head': 'Associer un navigateur',
215
+ 'set-ag-cancelled': 'Annulé', 'set-na-k-machine': 'Machine (SSH)', 'set-mc-head': 'Ajouter une machine (SSH)', 'set-mc-hint': 'Sa console, ses fichiers ; la clé reste ici.',
216
+ 'set-mc-title': 'Nom', 'set-mc-host': 'Adresse', 'set-mc-user': 'Utilisateur', 'set-mc-key': 'Clé', 'set-mc-no-key': 'Pas encore de clé : en faire une', 'set-mc-key-name': 'Nom de la nouvelle clé',
217
+ 'set-mc-key-line': 'À ajouter dans ~/.ssh/authorized_keys', 'set-mc-more': 'Empreinte du serveur (facultatif)',
218
+ 'set-mc-pin-hint': 'Lue et retenue au premier contact.',
219
+ 'set-mc-add': 'Ajouter', 'set-mc-pinned': 'Empreinte du serveur retenue : {pin}',
215
220
  'set-br-step-install': 'Installez l\'extension Tether.', 'set-br-step-make': 'Créez la configuration, puis copiez-la.',
216
221
  'set-br-step-paste': 'Collez-la dans la fenêtre de l\'extension.', 'set-br-make': 'Créer la configuration',
217
222
  'set-br-config': 'Configuration (une fois, 10 minutes)', 'set-br-wait': 'En attente de l\'extension…',
@@ -0,0 +1,76 @@
1
+ /* A MACHINE REACHED OVER SSH, MADE FROM THE PAGE (17-11): Tether's SSH access (its `ssh` connector), opened
2
+ * with a key MADE HERE -- the same keys as the git repositories (gitaccess.mjs), one list. Its private half
3
+ * never leaves this server: the target names it (`secrets.key` = "sshkey:<name>"), and the keeper asks it
4
+ * of this server at connect time (tethers.mjs reveal), for the connector alone. The person adds the public
5
+ * half to the machine's ~/.ssh/authorized_keys.
6
+ *
7
+ * THE SERVER'S IDENTITY IS PINNED AT ONCE: before the target is made, this server reaches the machine once
8
+ * and reads its host key (no login: the key comes before any authentication). The fingerprint is kept
9
+ * in the target (`config.pin`); a different key later is refused by the connector. A pin given by the
10
+ * person is checked against what the machine shows: they must match.
11
+ *
12
+ * addMachine({ tethers, keys, probe }, body) body { title, host, port?, user, key, pin? }
13
+ * probeHostKey(host, port) -> "SHA256:…" (ssh2, no login)
14
+ */
15
+ import { createHash } from 'node:crypto';
16
+ import { Refusal } from './conversations.mjs';
17
+
18
+ const HOST = /^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]{0,252})|\[[0-9A-Fa-f:.]{2,45}\]|[0-9A-Fa-f:.]{2,45})$/;
19
+ const USER = /^[A-Za-z0-9._][A-Za-z0-9._-]{0,63}$/;
20
+ const KEY = /^[a-z]([a-z0-9-]{0,30}[a-z0-9])?$/;
21
+ export const PROBE_MS = 8000;
22
+ export const SSH_KEY_PREFIX = 'sshkey:';
23
+
24
+ export const fingerprint = (keyBuf) => `SHA256:${createHash('sha256').update(keyBuf).digest('base64').replace(/=+$/, '')}`;
25
+ const samePrint = (a, b) => String(a).replace(/=+$/, '').toLowerCase() === String(b).replace(/=+$/, '').toLowerCase();
26
+
27
+ /* The machine's host key, read once without logging in. */
28
+ export async function probeHostKey(host, port = 22, { Client = null, ms = PROBE_MS } = {}) {
29
+ const C = Client ?? (await import('ssh2')).Client;
30
+ return new Promise((ok, fail) => {
31
+ const client = new C();
32
+ let seen = null; let done = false;
33
+ const end = (fn, v) => { if (done) return; done = true; clearTimeout(timer); try { client.end(); } catch { /* gone */ } fn(v); };
34
+ const timer = setTimeout(() => end(fail, new Error('no answer')), ms);
35
+ client.on('error', (e) => (seen ? end(ok, seen) : end(fail, e)));
36
+ client.on('close', () => (seen ? end(ok, seen) : end(fail, new Error('closed'))));
37
+ client.on('ready', () => end(seen ? ok : fail, seen ?? new Error('no host key')));
38
+ try {
39
+ client.connect({ host, port, username: 'probe', readyTimeout: ms, tryKeyboard: false,
40
+ hostVerifier: (key, cb) => { seen = fingerprint(Buffer.isBuffer(key) ? key : Buffer.from(String(key), 'base64')); if (typeof cb === 'function') { cb(false); return undefined; } return false; } });
41
+ } catch (e) { end(fail, e); }
42
+ });
43
+ }
44
+
45
+ /* An id for the target: from its title, lower case, never taken. */
46
+ const idFrom = (title, taken) => {
47
+ const base = String(title).normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40) || 'machine';
48
+ let id = base; for (let n = 2; taken.has(id); n += 1) id = `${base}-${n}`;
49
+ return id;
50
+ };
51
+
52
+ export async function addMachine({ tethers, keys, probe = probeHostKey }, body) {
53
+ const title = String(body?.title ?? '').trim().slice(0, 80);
54
+ const host = String(body?.host ?? '').trim();
55
+ const user = String(body?.user ?? '').trim();
56
+ const key = String(body?.key ?? '').trim();
57
+ const port = body?.port === undefined || body?.port === '' || body?.port === null ? 22 : Number(body.port);
58
+ if (!title) throw new Refusal(400, 'Give the machine a name.');
59
+ if (!HOST.test(host)) throw new Refusal(400, 'The address is a host name or an IP address, without user or port.');
60
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Refusal(400, 'The port is a number from 1 to 65535.');
61
+ if (!USER.test(user)) throw new Refusal(400, 'The user is a login name: letters, digits, dot, hyphen, underscore.');
62
+ if (!KEY.test(key) || !keys?.keys?.().some((k) => k.name === key)) throw new Refusal(400, 'Choose a key made here, or make one.');
63
+ let seen;
64
+ try { seen = await probe(host, port); } catch (e) { throw new Refusal(502, `The machine could not be reached at ${host}:${port} (${String(e?.message ?? e).slice(0, 120)}).`); }
65
+ const given = String(body?.pin ?? '').trim();
66
+ if (given && !samePrint(given, seen)) throw new Refusal(409, `The machine shows ${seen}, not the fingerprint given: nothing was made. It may not be the machine you think.`);
67
+ const store = tethers.store();
68
+ const id = idFrom(title, new Set(store.targets().map((t) => t.id)));
69
+ const t = store.putTarget({ id, title, kind: 'ssh', connector: 'ssh', config: { host, port, user, pin: seen }, secrets: { key: `${SSH_KEY_PREFIX}${key}` } });
70
+ return { id: t.id, title: t.title, pin: seen };
71
+ }
72
+
73
+ /* The machines a key opens (their titles), for "used by". */
74
+ export const machinesUsing = (tethers) => (key) => {
75
+ try { return tethers.store().targets().filter((t) => t.kind === 'ssh' && (t.secrets?.key ?? '') === `${SSH_KEY_PREFIX}${key}`).map((t) => t.title || t.id); } catch { return []; }
76
+ };
@@ -252,6 +252,12 @@ export class Tethers {
252
252
  at once when Tether says the server refused the one it had (opts.fresh, 16-11). */
253
253
  const fresh = await this.oauth?.access?.(name, { fresh: opts?.fresh === true });
254
254
  if (fresh !== undefined) return fresh;
255
+ /* A machine's SSH key made here (sshmachine.mjs): its private half, from the keys of git access. */
256
+ if (String(name).startsWith('sshkey:')) {
257
+ const key = this.sshKeys?.privateKeyOf?.(String(name).slice('sshkey:'.length));
258
+ if (!key) throw new Error(`no SSH key named "${String(name).slice('sshkey:'.length)}" on this server`);
259
+ return key;
260
+ }
255
261
  const value = this.#secrets?.reveal?.(name);
256
262
  if (value === undefined || value === null) throw new Error(`no secret named "${name}" on this server`);
257
263
  return value;
package/web/app.js CHANGED
@@ -4546,7 +4546,7 @@
4546
4546
  line.append(summary, el('pre', '', rest));
4547
4547
  return line;
4548
4548
  }
4549
- const kindIcon = (kind) => { const name = kind === 'send' || kind === 'demandes' ? 'arrow-up' : kind === 'box' ? 'mic' : kind === 'device' ? 'smartphone' : kind === 'mcp' ? 'link' : kind === 'browser' ? 'globe' : ASSET_KINDS.find((k) => k[0] === kind)?.[2]; const holder = el('span', 'as-ic'); holder.dataset.kind = kind; const svg = kind === 'list' ? listIcon() : name ? window.clavariumIcons?.icon(name) : null; if (svg) holder.append(svg); return holder; };
4549
+ const kindIcon = (kind) => { const name = kind === 'send' || kind === 'demandes' ? 'arrow-up' : kind === 'box' ? 'mic' : kind === 'device' ? 'smartphone' : kind === 'mcp' ? 'link' : kind === 'browser' ? 'globe' : kind === 'machine' ? 'square-terminal' : ASSET_KINDS.find((k) => k[0] === kind)?.[2]; const holder = el('span', 'as-ic'); holder.dataset.kind = kind; const svg = kind === 'list' ? listIcon() : name ? window.clavariumIcons?.icon(name) : null; if (svg) holder.append(svg); return holder; };
4550
4550
  /* A list (Binder's): the set has no such sign, so it is drawn here, in its style. */
4551
4551
  function listIcon() {
4552
4552
  const SVG = 'http://www.w3.org/2000/svg';
@@ -5368,7 +5368,7 @@
5368
5368
  onKind: (k) => {
5369
5369
  giveNew.kind = k; giveNew.level = ''; justMade = null; $('cassets-error').hidden = true; void paintRoomAssets();
5370
5370
  /* Its keys, read here too: Assets may not have been opened yet. */
5371
- if (k === 'git') void getJson('/git-keys', []).then((keys) => paintKeys(keys));
5371
+ if (k === 'git' || k === 'machine') void getJson('/git-keys', []).then((keys) => paintKeys(keys));
5372
5372
  },
5373
5373
  onBack: () => { giveNew.kind = ''; $('cassets-error').hidden = true; void paintRoomAssets(); },
5374
5374
  onAnother: () => { giveNew.kind = made.kind; justMade = null; void paintRoomAssets(); },
@@ -5720,7 +5720,7 @@
5720
5720
  const newKinds = () => [['folder', uiSaid('set-na-k-folder', 'Folder')], ['git', uiSaid('set-na-k-git', 'Git repository')], ['mailbox', uiSaid('set-na-k-mailbox', 'Mailbox')],
5721
5721
  ['agenda', uiSaid('set-na-k-agenda', 'Calendar')], ['contacts', uiSaid('set-na-k-contacts', 'Contacts')], ['secret', uiSaid('set-na-k-secret', 'Secret')], ['list', uiSaid('set-na-k-list', LISTS_WORD.one)],
5722
5722
  /* Step 4: a voice box (paired with a code) and a device (the share sheet, its code) are two kinds of it too. */
5723
- ['box', uiSaid('set-na-k-box', 'Voice box')], ['device', uiSaid('set-na-k-device', 'Device')], ['mcp', uiSaid('set-na-k-mcp', 'MCP server')], ['browser', uiSaid('set-na-k-browser', 'Browser')]]
5723
+ ['box', uiSaid('set-na-k-box', 'Voice box')], ['device', uiSaid('set-na-k-device', 'Device')], ['mcp', uiSaid('set-na-k-mcp', 'MCP server')], ['machine', uiSaid('set-na-k-machine', 'Machine (SSH)')], ['browser', uiSaid('set-na-k-browser', 'Browser')]]
5724
5724
  .map(([kind, label]) => ({ kind, label, icon: kindIcon(kind) }));
5725
5725
  /* A voice box's steps after its kind (the flow: "A NEW VOICE BOX", with the boxes), and the one under way. */
5726
5726
  const BOX_STEPS = ['where', 'plug', 'pair'];
@@ -5750,6 +5750,7 @@
5750
5750
  if (kind === 'box') return paintBoxFlow();
5751
5751
  const form = $(`${addForm(kind)}-box`); form.hidden = false;
5752
5752
  if (kind === 'git') { fillKeyChoice(); showVia(); }
5753
+ if (kind === 'machine') { fillKeyChoice(); void getJson('/git-keys', []).then((keys) => paintKeys(keys)); }
5753
5754
  if (kind === 'list') void fillTemplates();
5754
5755
  if (kind === 'browser') $('browser-address').value = browserAddress();
5755
5756
  return form;
@@ -6302,11 +6303,14 @@
6302
6303
  }
6303
6304
  function agendaEvent(ev) {
6304
6305
  const box = el('details', 'ag-event'); box.dataset.show = ev.show ?? 'busy';
6306
+ if (ev.cancelled) box.dataset.cancelled = '';
6305
6307
  if (agendaOpen === ev.id) box.open = true;
6306
6308
  box.addEventListener('toggle', () => { if (box.open) agendaOpen = ev.id; else if (agendaOpen === ev.id) agendaOpen = ''; });
6307
6309
  const head = el('summary', 'ag-row');
6308
6310
  head.append(el('span', 'ag-time', ev.allDay ? uiSaid('set-ag-allday', 'All day') : hourOf(ev.start)));
6309
6311
  const what = el('span', 'ag-what'); what.append(el('span', 'ag-title', ev.title));
6312
+ /* Cancelled: struck out, and said in words (not by the line alone). */
6313
+ if (ev.cancelled) what.prepend(el('span', 'ag-cancelled', uiSaid('set-ag-cancelled', 'Cancelled')));
6310
6314
  if (ev.location) what.append(el('span', 'ag-where hint', ev.location));
6311
6315
  head.append(what);
6312
6316
  const facts = el('dl', 'ag-facts');
@@ -6400,7 +6404,7 @@
6400
6404
  function consoleView(target) {
6401
6405
  let v = consoleViews.get(target.id);
6402
6406
  if (v) { v.target = target; return v; }
6403
- v = { id: target.id, target, state: null, socket: null, phase: 'connecting', focused: false, full: false, chat: null, chatOf: '', chatPick: '', waiting: [], opened: false, retry: 0, away: 0, from: '' };
6407
+ v = { id: target.id, target, state: null, socket: null, phase: 'connecting', focused: false, full: false, below: false, chat: null, chatOf: '', chatPick: '', waiting: [], opened: false, retry: 0, away: 0, from: '' };
6404
6408
  consoleViews.set(target.id, v);
6405
6409
  const root = el('div', 'sc'); root.dataset.target = target.id;
6406
6410
  const presence = el('div', 'sc-presence'); presence.setAttribute('aria-live', 'polite');
@@ -6413,15 +6417,17 @@
6413
6417
  const secret = scButton('sc-secret', uiSaid('set-sc-secret', 'Hidden input')); secret.setAttribute('aria-pressed', 'false');
6414
6418
  const ctrlc = scButton('quiet sc-ctrlc', 'Ctrl C'); ctrlc.title = uiSaid('set-sc-ctrlc', 'Interrupts what is running');
6415
6419
  const full = scButton('quiet sc-full-btn', uiSaid('set-sc-full', 'Full screen')); full.setAttribute('aria-pressed', 'false');
6420
+ /* The chat of the conversation that holds the machine, under the console (17-11: the same chat, never one of its own). */
6421
+ const chatBtn = scButton('quiet sc-chat-btn', uiSaid('set-sc-chat', 'Chat')); chatBtn.setAttribute('aria-pressed', 'false');
6416
6422
  const reopen = scButton('primary sc-reopen', uiSaid('set-sc-reopen', 'Open it again')); reopen.hidden = true;
6417
- const tools = el('div', 'sc-tools'); tools.append(take, hideAi, secret, el('span', 'sc-space'), ctrlc, full);
6423
+ const tools = el('div', 'sc-tools'); tools.append(take, hideAi, secret, el('span', 'sc-space'), ctrlc, chatBtn, full);
6418
6424
  const main = el('div', 'sc-main'); main.append(presence, screen, banner, keys, tools);
6419
6425
  /* Full screen: the chat of a conversation that holds the machine, beside the console. */
6420
6426
  const chatHead = el('div', 'sc-chat-head');
6421
6427
  const chatBox = el('div', 'sc-chat-thread');
6422
6428
  const side = el('aside', 'sc-chat'); side.setAttribute('aria-label', uiSaid('set-sc-chat', 'Chat')); side.hidden = true; side.append(chatHead, chatBox);
6423
6429
  root.append(main, side);
6424
- Object.assign(v, { root, presence, screen, banner, take, hideAi, secret, fullBtn: full, reopen, chatHead, chatBox, side });
6430
+ Object.assign(v, { root, presence, screen, banner, take, hideAi, secret, fullBtn: full, chatBtn, reopen, chatHead, chatBox, side });
6425
6431
  const term = new Terminal({ ...terminalOptions(), scrollback: 3000 });
6426
6432
  const fitter = new FitAddon.FitAddon(); term.loadAddon(fitter);
6427
6433
  v.term = term; v.fit = () => { if (v.opened && screen.isConnected && screen.offsetWidth > 0) { try { fitter.fit(); } catch { /* not drawn yet */ } } };
@@ -6438,6 +6444,7 @@
6438
6444
  hideAi.addEventListener('click', () => { sendJson({ type: 'hide-ai', on: !(v.state?.hideAi) }); });
6439
6445
  secret.addEventListener('click', () => { sendJson({ type: 'hidden', on: !(v.state?.hidden) }); term.focus(); });
6440
6446
  full.addEventListener('click', () => consoleFull(v, !v.full));
6447
+ chatBtn.addEventListener('click', () => consoleBelow(v, !v.below));
6441
6448
  reopen.addEventListener('click', () => { reopen.hidden = true; consoleConnect(v); });
6442
6449
  /* Where the focus is, kept across paints: given back once the console is in the new panel. */
6443
6450
  root.addEventListener('focusin', () => { v.focused = true; });
@@ -6513,7 +6520,8 @@
6513
6520
  if (v.full === on) return;
6514
6521
  v.full = on;
6515
6522
  v.root.classList.toggle('sc-full', on);
6516
- v.side.hidden = !on;
6523
+ v.side.hidden = !on && !v.below;
6524
+ v.chatBtn.hidden = on;
6517
6525
  const b = v.fullBtn;
6518
6526
  b.setAttribute('aria-pressed', String(on));
6519
6527
  b.textContent = on ? uiSaid('set-sc-leave-full', 'Leave full screen') : uiSaid('set-sc-full', 'Full screen');
@@ -6526,10 +6534,21 @@
6526
6534
  void consoleChat(v);
6527
6535
  } else {
6528
6536
  if (v.fullStep) { const step = v.fullStep; v.fullStep = null; nav.drop(step); }
6529
- v.chat?.destroy(); v.chat = null; v.chatOf = '';
6537
+ if (!v.below) { v.chat?.destroy(); v.chat = null; v.chatOf = ''; }
6530
6538
  }
6531
6539
  requestAnimationFrame(() => { v.fit(); v.term.focus(); });
6532
6540
  }
6541
+ /* The chat under the console, out of full screen: shown or not (the button says which). */
6542
+ function consoleBelow(v, on) {
6543
+ if (v.below === on) return;
6544
+ v.below = on;
6545
+ v.root.classList.toggle('sc-below', on);
6546
+ v.chatBtn.setAttribute('aria-pressed', String(on));
6547
+ if (!v.full) v.side.hidden = !on;
6548
+ if (on) void consoleChat(v);
6549
+ else if (!v.full) { v.chat?.destroy(); v.chat = null; v.chatOf = ''; }
6550
+ requestAnimationFrame(() => v.fit());
6551
+ }
6533
6552
  /* The conversations that hold the machine; the one whose chat is shown: picked, else the one on the console now,
6534
6553
  else the conversation this panel is seen from, else the first. */
6535
6554
  function consoleHolders(v) {
@@ -6557,7 +6576,7 @@
6557
6576
  v.chatBox.replaceChildren();
6558
6577
  if (!conversations.find((c) => c.name === name)?.talk) { v.chatBox.append(el('p', 'hint', uiSaid('set-sc-chat-off', 'The chat of this conversation is off.'))); return; }
6559
6578
  const [{ mount }, words] = await Promise.all([parleyUi(), readWords()]);
6560
- if (!v.full || v.chatOf !== name) return;
6579
+ if (!(v.full || v.below) || v.chatOf !== name) return;
6561
6580
  v.chatBox.dataset.theme = document.documentElement.dataset.theme === 'light' ? 'light' : 'dark';
6562
6581
  /* Parley's own chat view, as in the conversation: its thread read and written the same way. */
6563
6582
  v.chat = mount(v.chatBox, {
@@ -7563,7 +7582,7 @@
7563
7582
  copy.addEventListener('click', () => { void copyField(field, copy); });
7564
7583
  const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Remove';
7565
7584
  const why = document.createElement('span'); why.className = 'hint';
7566
- if (key.usedBy.length) { remove.disabled = true; why.textContent = `removing it would cut ${key.usedBy.join(', ')} off: remove ${key.usedBy.length > 1 ? 'those repositories' : 'that repository'} first`; }
7585
+ if (key.usedBy.length) { remove.disabled = true; why.textContent = `removing it would cut ${key.usedBy.join(', ')} off: remove ${key.usedBy.length > 1 ? 'them' : 'it'} first`; }
7567
7586
  remove.addEventListener('click', () => {
7568
7587
  const sure = document.createElement('button'); sure.type = 'button'; sure.className = 'danger'; sure.textContent = `Yes, remove the key ${key.name} (it cannot be made again)`;
7569
7588
  sure.addEventListener('click', async () => {
@@ -7607,9 +7626,57 @@
7607
7626
  for (const [id, key] of [['git-key-new', 'set-na-new-key'], ['git-key-make-go', 'set-na-create']]) { const b = gitKeyPick.querySelector?.(`#${id}`); if (b) b.dataset.said = key; }
7608
7627
  /* The key offered in "New repository": the one chosen stays chosen. */
7609
7628
  function fillKeyChoice(chosen = $('git-key').value) {
7610
- gitKeyPick.set(gitKeys.map((key) => ({ value: key.name, label: key.usedBy.length ? `${key.name} (used by ${key.usedBy.join(', ')})` : key.name })), chosen);
7629
+ const offered = gitKeys.map((key) => ({ value: key.name, label: key.usedBy.length ? `${key.name} (used by ${key.usedBy.join(', ')})` : key.name }));
7630
+ gitKeyPick.set(offered, chosen);
7611
7631
  showChosenKey();
7632
+ machineKeyPick.set(offered, $('machine-key')?.value || chosen);
7633
+ showMachineKey();
7634
+ }
7635
+ /* A MACHINE (SSH, sshmachine.mjs): the same keys made here; the line for its authorized_keys under the one chosen. */
7636
+ const machineKeyPick = KIT.SecretPicker({
7637
+ ids: { select: 'machine-key', add: 'machine-key-new', row: 'machine-key-make', name: 'machine-key-name', go: 'machine-key-make-go' },
7638
+ none: uiSaid('set-mc-no-key', 'No key yet: make one'), addLabel: uiSaid('set-na-new-key', '+ New key…'), makeLabel: uiSaid('set-na-create', 'Create'), nameLabel: uiSaid('set-mc-key-name', 'Name of the new key'),
7639
+ nameAttrs: { maxlength: '32', pattern: '[a-z]([a-z0-9-]{0,30}[a-z0-9])?', placeholder: 'server-key', spellcheck: 'false', autocapitalize: 'off' },
7640
+ suggest: () => {
7641
+ const taken = new Set(gitKeys.map((k) => k.name));
7642
+ const wanted = $('machine-title').value.trim().normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^[^a-z]+|-+$/g, '').slice(0, 32);
7643
+ let suggestion = wanted && !taken.has(wanted) ? wanted : '';
7644
+ for (let n = 1; !suggestion; n += 1) if (!taken.has(`key-${n}`)) suggestion = `key-${n}`;
7645
+ return suggestion;
7646
+ },
7647
+ onMake: async (name) => {
7648
+ $('machine-error').hidden = true;
7649
+ try {
7650
+ const made = await post(`${API}/git-keys`, { name });
7651
+ paintKeys(await fetch(`${API}/git-keys`).then((r) => r.json()));
7652
+ machineKeyPick.set(gitKeys.map((key) => ({ value: key.name, label: key.name })), made.name);
7653
+ fillKeyChoice($('git-key').value);
7654
+ showMachineKey();
7655
+ return true;
7656
+ } catch (error) { $('machine-error').textContent = error.message; $('machine-error').hidden = false; return false; }
7657
+ },
7658
+ onChange: () => showMachineKey(),
7659
+ });
7660
+ $('machine-key-pick').append(machineKeyPick);
7661
+ function showMachineKey() {
7662
+ const key = gitKeys.find((k) => k.name === $('machine-key')?.value);
7663
+ $('machine-key-shown').hidden = !key;
7664
+ $('machine-key-line').value = key?.publicKey ?? '';
7612
7665
  }
7666
+ $('machine-key-copy').addEventListener('click', () => { void copyField($('machine-key-line'), $('machine-key-copy')); });
7667
+ $('machine-new').addEventListener('submit', async (event) => {
7668
+ event.preventDefault();
7669
+ $('machine-error').hidden = true;
7670
+ const btn = $('machine-add'); btn.disabled = true;
7671
+ try {
7672
+ const made = await post(`${API}/tether/ssh-add`, { title: $('machine-title').value.trim(), host: $('machine-host').value.trim(), port: $('machine-port').value.trim(), user: $('machine-user').value.trim(), key: $('machine-key').value, pin: $('machine-pin').value.trim() });
7673
+ $('machine-new').reset();
7674
+ paintKeys(await getJson('/git-keys', []));
7675
+ await assetMade($('machine-box'), { key: `connexion:${made.id}`, name: made.title, note: uiSaid('set-mc-pinned', 'Server fingerprint kept: {pin}', { pin: made.pin }), give: (to, level) => grantTarget(made.id, to, targetLevel(level)) });
7676
+ } catch (error) { $('machine-error').textContent = error.message; $('machine-error').hidden = false; }
7677
+ finally { btn.disabled = false; }
7678
+ await paintAssets();
7679
+ });
7613
7680
  function showChosenKey() {
7614
7681
  const key = gitKeys.find((k) => k.name === $('git-key').value);
7615
7682
  $('git-key-shown').hidden = !key;
package/web/index.html CHANGED
@@ -934,6 +934,29 @@
934
934
  </details>
935
935
  </form>
936
936
  </div>
937
+ <div id="machine-box" class="as-form" data-kind="machine"><h3 data-said="set-mc-head">Add a machine (SSH)</h3>
938
+ <p class="hint" data-said="set-mc-hint">Its console, its files; the key stays here.</p>
939
+ <form id="machine-new" autocomplete="off" novalidate>
940
+ <label for="machine-title" data-said="set-mc-title">Name</label>
941
+ <input id="machine-title" maxlength="80" spellcheck="false" placeholder="Home server">
942
+ <label for="machine-host" data-said="set-mc-host">Address</label>
943
+ <div class="row"><input id="machine-host" maxlength="253" spellcheck="false" autocapitalize="off" inputmode="url" placeholder="server.example.com"><input id="machine-port" class="mc-port" inputmode="numeric" maxlength="5" placeholder="22" aria-label="Port"></div>
944
+ <label for="machine-user" data-said="set-mc-user">User</label>
945
+ <input id="machine-user" maxlength="64" spellcheck="false" autocapitalize="off" placeholder="admin">
946
+ <label for="machine-key" data-said="set-mc-key">Key</label>
947
+ <div id="machine-key-pick"></div>
948
+ <div id="machine-key-shown" hidden>
949
+ <label for="machine-key-line" data-said="set-mc-key-line">Add to ~/.ssh/authorized_keys</label>
950
+ <div class="row"><textarea id="machine-key-line" class="public-key" readonly rows="3" spellcheck="false"></textarea><button type="button" id="machine-key-copy">Copy</button></div>
951
+ </div>
952
+ <details class="more"><summary data-said="set-mc-more">Server fingerprint (optional)</summary>
953
+ <p class="hint" data-said="set-mc-pin-hint">Read and kept on first contact.</p>
954
+ <input id="machine-pin" maxlength="200" spellcheck="false" autocapitalize="off" placeholder="SHA256:…" aria-label="Fingerprint">
955
+ </details>
956
+ <p id="machine-error" class="error" role="alert" hidden></p>
957
+ <div class="row"><button type="submit" id="machine-add" class="primary" data-said="set-mc-add">Add</button></div>
958
+ </form>
959
+ </div>
937
960
  <div id="browser-box" class="as-form" data-kind="browser"><h3 data-said="set-br-head">Pair a browser</h3>
938
961
  <ol class="hint br-steps"><li data-said="set-br-step-install">Install the Tether extension.</li><li data-said="set-br-step-make">Make the configuration below, then copy it.</li><li data-said="set-br-step-paste">Paste it in the extension's popup.</li></ol>
939
962
  <form id="browser-new" autocomplete="off">
package/web/style.css CHANGED
@@ -1278,6 +1278,8 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
1278
1278
  .ag-where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1279
1279
  .ag-event[data-show="tentative"] .ag-title { font-style: italic; }
1280
1280
  .ag-event[data-show="free"] .ag-title { font-weight: 400; color: var(--ink2); }
1281
+ .ag-event[data-cancelled] .ag-title, .ag-event[data-cancelled] .ag-where { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--ink2); }
1282
+ .ag-cancelled { align-self: flex-start; font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--danger); }
1281
1283
  .ag-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; padding: 4px 6px 8px calc(4.5em + 14px); font-size: .8125rem; }
1282
1284
  .ag-facts dt { color: var(--ink2); }
1283
1285
  .ag-facts dd { margin: 0; overflow-wrap: anywhere; }
@@ -3400,6 +3402,8 @@ span.tile-spark { display: block; height: 22px; }
3400
3402
  .sc-chat-pick { flex: 1; min-width: 0; font: inherit; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
3401
3403
  .sc-chat-thread { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
3402
3404
  .sc-chat-thread > .hint { padding: 12px; }
3405
+ /* Out of full screen, the chat under the console (its button): a fixed height, the thread scrolls inside. */
3406
+ .sc.sc-below:not(.sc-full) .sc-chat { height: min(440px, 60vh); margin-top: 10px; }
3403
3407
  :root[data-sc-full] body { overflow: hidden; }
3404
3408
  @media (max-width: 760px), (pointer: coarse) {
3405
3409
  .sc-keys { display: flex; }
@@ -3411,3 +3415,5 @@ span.tile-spark { display: block; height: 22px; }
3411
3415
  .sc.sc-full { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 58fr) minmax(0, 42fr); padding: 6px; gap: 6px; }
3412
3416
  }
3413
3417
  @media (prefers-reduced-motion: reduce) { .sc-main { transition: none; } }
3418
+ .mc-port { max-width: 6em; flex: 0 0 6em; }
3419
+ .kit-na-made .hint { overflow-wrap: anywhere; }