clavarium 0.2.477-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.
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/agenda.mjs +4 -0
- package/server/api.mjs +8 -0
- package/server/demandes.mjs +2 -0
- package/server/gitaccess.mjs +12 -3
- package/server/main.mjs +10 -1
- package/server/settingswords.mjs +25 -0
- package/server/sshconsole.mjs +99 -0
- package/server/sshmachine.mjs +76 -0
- package/server/tethers.mjs +15 -0
- package/web/app.js +378 -9
- package/web/index.html +23 -0
- package/web/style.css +79 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
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.
|
|
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.
|
|
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.
|
|
804
|
-
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.
|
|
805
|
-
"integrity": "sha512-
|
|
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.
|
|
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.
|
|
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,12 +175,17 @@
|
|
|
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)
|
|
180
|
+
* POST /api/tether/console-journal {target}: a machine's shared console, its short journal (sshconsole.mjs);
|
|
181
|
+
* the console itself is a WebSocket, /api/tether/console?target=ID
|
|
178
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
|
|
179
183
|
* GET /api/files/thumb|text POST /api/files/save|make|rename|move|remove|taken ?c=...&r=...&p=... (see files.mjs)
|
|
180
184
|
*
|
|
181
185
|
* A request that changes something must come from this site's own pages: the
|
|
182
186
|
* Origin header is compared, and the body must be JSON, which a form on
|
|
183
187
|
* another site cannot send. */
|
|
188
|
+
import { addMachine } from './sshmachine.mjs';
|
|
184
189
|
import { openCodeConfig } from './catalog.mjs';
|
|
185
190
|
import { writeFileSync } from 'node:fs';
|
|
186
191
|
import { suggest } from './suggest.mjs';
|
|
@@ -192,6 +197,7 @@ import { VmUnknown } from './vm.mjs';
|
|
|
192
197
|
import { list, download, importFile, page, PAGE_HEADERS, changeRoute, IMAGE_HEADERS, mailFile, mailPage } from './files.mjs';
|
|
193
198
|
import { mailRoute } from './mailref.mjs';
|
|
194
199
|
import { readAgenda } from './agenda.mjs';
|
|
200
|
+
import { consoleJournal } from './sshconsole.mjs';
|
|
195
201
|
import { readMailList, readMail } from './mailview.mjs';
|
|
196
202
|
import { readContacts, readContact } from './contactview.mjs';
|
|
197
203
|
import { WORK_TAB } from './resources.mjs';
|
|
@@ -706,6 +712,7 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
706
712
|
/* External MCP servers (mcpx.mjs): added with their key (kept host-only in the vault, Tether given its name),
|
|
707
713
|
imported from a pasted mcpServers block, listed again, a conversation's rights on their tools, new tools seen. */
|
|
708
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;
|
|
709
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;
|
|
710
717
|
const mcpOp = /^\/api\/tether\/mcp-(add|import|refresh|rights|seen)$/.exec(pathname);
|
|
711
718
|
if (mcpOp && tethers) {
|
|
@@ -735,6 +742,7 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
735
742
|
/* A mailbox's latest messages and one as text, an address book's contacts and one, read the same way (16-11:
|
|
736
743
|
mailview.mjs, contactview.mjs): never marked read, nothing changed. */
|
|
737
744
|
const peek = { '/api/tether/mail-list': readMailList, '/api/tether/mail-read': readMail, '/api/tether/contacts': readContacts, '/api/tether/contact': readContact }[pathname];
|
|
745
|
+
if (pathname === '/api/tether/console-journal' && tethers) return send(200, await consoleJournal(tethers, body ?? {})), true;
|
|
738
746
|
if (peek && tethers) return send(200, await peek(tethers, body ?? {}, { who: { id: `person:${identity || 'owner'}`, name: identity || 'Owner' } })), true;
|
|
739
747
|
/* A mailbox's signature (Markdown), added under what the agent sends from it. */
|
|
740
748
|
if (pathname === '/api/tether/signature' && tethers) {
|
package/server/demandes.mjs
CHANGED
|
@@ -220,6 +220,8 @@ export function demandeView(q) {
|
|
|
220
220
|
if (c.command || c.text) { v.code = String(c.command ?? c.text); sub.push(v.code.split('\n')[0].slice(0, 60)); }
|
|
221
221
|
v.yes = c.action === 'run' ? 'run' : c.action === 'type' ? 'type' : 'open';
|
|
222
222
|
if (c.action === 'run') v.irreversible = true;
|
|
223
|
+
/* A destructive line (Tether: rm -r, mkfs, reboot...): marked, never in Accept all, said as final. */
|
|
224
|
+
if (c.destructive) { v.irreversible = true; if (!v.risk.includes(w('req-risk-final'))) v.risk.push(w('req-risk-final')); }
|
|
223
225
|
} else if (c.kind === 'files') {
|
|
224
226
|
v.title = c.action === 'write' ? w('req-files-write', { path: String(c.path) }) : c.action === 'delete' ? w('req-files-delete', { path: String(c.path) }) : c.action === 'move' ? w('req-files-move', { from: String(c.from), to: String(c.to) }) : `${c.action ?? 'files'} ${c.path ?? ''}`.trim();
|
|
225
227
|
if (where) sub.push(where);
|
package/server/gitaccess.mjs
CHANGED
|
@@ -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 ? '
|
|
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';
|
|
@@ -96,6 +97,7 @@ import { Desks, handleDesktop } from './desktop.mjs';
|
|
|
96
97
|
import { ApiKeys, handleExternal, handleApiKeys, statusOf } from './apikeys.mjs';
|
|
97
98
|
import { RelayJoin, handleRelayJoin, RELAY_JOIN_PATH } from './relayjoin.mjs';
|
|
98
99
|
import { WebSocketServer } from 'ws';
|
|
100
|
+
import { attachConsole } from './sshconsole.mjs';
|
|
99
101
|
import { copyWorkFolder } from './copywork.mjs';
|
|
100
102
|
import { accessesOf, relinkAccesses } from './carry.mjs';
|
|
101
103
|
import { Jobs, withUpdates } from './jobs.mjs';
|
|
@@ -311,7 +313,7 @@ const PARLEY_WAIT_MS = 20_000;
|
|
|
311
313
|
/* The product: conversations are VMs. `host` is how the host program is
|
|
312
314
|
reached on this installation, as an argument vector: it is the ONLY thing
|
|
313
315
|
this server runs with more rights than its own. */
|
|
314
|
-
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 }) {
|
|
315
317
|
/* The data, in the format this code reads, before anything reads it (dataformat.mjs). */
|
|
316
318
|
const migrated = migrateData(dataDir);
|
|
317
319
|
if (migrated.ran.length) console.log(`data: format ${migrated.from} -> ${migrated.to}`);
|
|
@@ -508,6 +510,11 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
508
510
|
let tethers = null;
|
|
509
511
|
const browsers = new Browsers({ dataDir, store: () => tethers?.store(), log: (line) => console.log(line) });
|
|
510
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;
|
|
511
518
|
/* External MCP servers signed in with OAuth: their tokens held here, refreshed here (mcpoauth.mjs). */
|
|
512
519
|
tethers.oauth = new McpOAuth({ secrets });
|
|
513
520
|
const stopTethers = tethers.start();
|
|
@@ -921,6 +928,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
921
928
|
let closing = false;
|
|
922
929
|
boxes.attach(server, WebSocketServer);
|
|
923
930
|
browsers.attach(server, WebSocketServer); server.on('close', () => browsers.shutdown());
|
|
931
|
+
/* A machine's shared SSH console, live in its asset panel (sshconsole.mjs): the same checks as the terminal. */
|
|
932
|
+
attachConsole(server, { tethers, gate, originOk });
|
|
924
933
|
/* The wake word's weekly threshold tuning (Sunday from 03:00, each box's own time): looked at every 10 minutes. */
|
|
925
934
|
const wakeWeekly = setInterval(() => { try { boxes.wakeWeekly(); } catch (error) { console.error(`wake tuning: ${error.message}`); } }, 10 * 60_000); wakeWeekly.unref?.(); server.on('close', () => clearInterval(wakeWeekly));
|
|
926
935
|
/* A collect session's clock: the stations asked, its end, the speaker told to stop (boxcollect.mjs). */
|
package/server/settingswords.mjs
CHANGED
|
@@ -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…',
|
|
@@ -336,6 +341,26 @@ export const SETTINGS_WORDS_FR = {
|
|
|
336
341
|
'desk-add-rooms': 'Salons', 'desk-add-assets': 'Assets', 'desk-add-more': 'Dossiers', 'desk-add-all': 'Tout est déjà sur le bureau',
|
|
337
342
|
'desk-added': 'Ajouté au bureau', 'desk-editing': 'Mode modification', 'desk-drop-folder': 'Lâcher : faire un dossier',
|
|
338
343
|
'desk-drop-into': 'Lâcher : mettre dans le dossier', 'desk-create': 'Créer', 'desk-new-conv': 'Nouvelle conversation', 'desk-new-room': 'Nouveau salon',
|
|
344
|
+
/* A machine's shared console (16-11, app.js consoleParts). */
|
|
345
|
+
'set-sc-title': 'Console', 'set-sc-console': 'Console', 'set-sc-keys': 'Touches', 'set-sc-take': 'Reprendre la main', 'set-sc-hide-ai': 'Cacher à l’IA',
|
|
346
|
+
'set-sc-show-ai': 'Montrer à l’IA', 'set-sc-secret': 'Saisie cachée', 'set-sc-ctrlc': 'Interrompt ce qui tourne', 'set-sc-full': 'Plein écran',
|
|
347
|
+
'set-sc-leave-full': 'Quitter le plein écran', 'set-sc-reopen': 'Rouvrir', 'set-sc-chat': 'Chat', 'set-sc-chat-of': 'Chat de',
|
|
348
|
+
'set-sc-chat-off': 'Le chat de cette conversation est coupé.', 'set-sc-no-holder': 'Aucune conversation n’a cette machine.',
|
|
349
|
+
'set-sc-you': 'Vous', 'set-sc-you-av': 'V', 'set-sc-you-hidden': 'tapez (caché)', 'set-sc-you-watch': 'regardez', 'set-sc-you-control': 'aux commandes',
|
|
350
|
+
'set-sc-ai-av': 'IA', 'set-sc-ai-blind': 'ne voit plus', 'set-sc-ai-typing': 'tape', 'set-sc-ai-proposes': 'propose', 'set-sc-ai-watching': 'regarde',
|
|
351
|
+
'set-sc-no-ai': 'Aucun assistant dessus', 'set-sc-live': 'en direct', 'set-sc-connecting': 'connexion…', 'set-sc-off': 'fermée',
|
|
352
|
+
'set-sc-failed': 'La console n’a pas pu s’ouvrir.', 'set-sc-closed': 'La console est fermée.', 'set-sc-connecting-long': 'Connexion à la machine…',
|
|
353
|
+
'set-sc-hidden-prompt': 'Mot de passe demandé : saisie cachée à l’IA.', 'set-sc-hidden': 'Saisie cachée : l’IA ne voit rien.',
|
|
354
|
+
'set-sc-typing': '{name} tape. Une touche reprend la main.', 'set-sc-hidden-ai': 'Caché à l’IA jusqu’à « Montrer ».', 'set-sc-control': 'Vous avez la main.',
|
|
355
|
+
'set-sc-in-full': 'La console est en plein écran.', 'set-sc-ai-title': 'Assistant', 'set-sc-journal': 'Journal',
|
|
356
|
+
'set-sc-j-empty': 'Chaque saisie de l’IA est gardée ici.', 'set-sc-typed': 'Ses dernières saisies', 'set-sc-ai-none': 'Rien de proposé. Il suit la console.',
|
|
357
|
+
'set-sc-j-took': 'a repris la main', 'set-sc-j-prompt': 'mot de passe : saisie cachée', 'set-sc-j-hidden': 'saisie cachée', 'set-sc-j-hide-ai': 'caché à l’IA',
|
|
358
|
+
'set-sc-j-show-ai': 'montré à l’IA', 'set-sc-j-refused': 'refusée', 'set-sc-j-dropped': 'pas envoyée', 'set-sc-j-failed': 'pas faite', 'set-sc-j-edited': 'modifiée par vous',
|
|
359
|
+
'set-sc-destructive': 'Destructif', 'set-sc-to-approve': 'À valider', 'set-sc-run-apart': 'Lancée à part, montrée dans la console.',
|
|
360
|
+
'set-sc-risk-erase': 'Efface des fichiers. Sans retour.', 'set-sc-risk-disk': 'Écrase un disque. Sans retour.', 'set-sc-risk-power': 'Arrête ou redémarre la machine.',
|
|
361
|
+
'set-sc-risk-rights': 'Change les droits de tout le système.', 'set-sc-risk-other': 'Peut casser la machine.',
|
|
362
|
+
'set-sc-send': 'Envoyer', 'set-sc-send-anyway': 'Envoyer quand même', 'set-sc-sure': 'Sûr ? Envoyer', 'set-sc-edit': 'Modifier', 'set-sc-refuse': 'Refuser',
|
|
363
|
+
'set-sc-edit-line': 'La ligne à envoyer', 'set-sc-send-edited': 'Envoyer modifiée',
|
|
339
364
|
'set-ml-short': 'Manque de mémoire', 'set-ml-short-what': 'La plus grosse machine', 'set-ml-force': 'Forcer l’arrêt', 'set-ml-sleep': 'Mettre en veille', 'set-ml-alert': 'Alerter seulement',
|
|
340
365
|
};
|
|
341
366
|
export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* A MACHINE'S SHARED CONSOLE, SEEN BY ITS PERSON (16-11): the live SSH console of a machine asset (a Tether target
|
|
2
|
+
* of kind ssh), shown in its asset panel. ONE shell per machine, kept by Tether's keeper in this server: the person
|
|
3
|
+
* streams it from the page, the conversations given the machine reach the same shell through terminal.open / read /
|
|
4
|
+
* type (Tether's console.mjs says who sees and types what: the person's key always wins, password prompts hide the
|
|
5
|
+
* input from the AI, « hide from the AI », destructive lines always asked).
|
|
6
|
+
*
|
|
7
|
+
* WebSocket /api/tether/console?target=ID[&cols=N&rows=N]
|
|
8
|
+
* browser -> server binary frame keystrokes (the person's own: never read here, never kept)
|
|
9
|
+
* text frame {"type":"resize","cols":n,"rows":n} | {"type":"hidden","on":bool}
|
|
10
|
+
* | {"type":"hide-ai","on":bool} | {"type":"take-back"} | {"type":"interrupt"}
|
|
11
|
+
* server -> browser binary frame what the machine prints (first: the screen so far, for a page that comes back)
|
|
12
|
+
* text frame {"type":"ready","state":{...}} | {"type":"state","state":{...}}
|
|
13
|
+
* | {"type":"error","text":...} then close 1011
|
|
14
|
+
* close 1000 the shell ended (the page offers to open it again)
|
|
15
|
+
*
|
|
16
|
+
* POST /api/tether/console-journal {target} -> { lines: [...] }: the console's short journal -- the agents' inputs
|
|
17
|
+
* (sent, refused, edited, destructive), control taken back, input hidden; never
|
|
18
|
+
* what the person typed (Tether never journals it).
|
|
19
|
+
*
|
|
20
|
+
* THE SAME CHECKS AS THE TERMINAL BRIDGE (bridge.mjs): this site's own pages only (the Origin, compared by hand: a
|
|
21
|
+
* WebSocket is not covered by the same-origin policy), past the gate (a signed-in operator, as every asset route);
|
|
22
|
+
* a machine that exists. A device's page (/c/) has no way here: its console is not given to devices. What the
|
|
23
|
+
* machine prints is carried, never parsed nor kept here; the page draws it with xterm only (never as HTML). */
|
|
24
|
+
import { WebSocketServer } from 'ws';
|
|
25
|
+
import { Refusal } from './conversations.mjs';
|
|
26
|
+
import { IDENTITY_HEADER } from './gate.mjs';
|
|
27
|
+
|
|
28
|
+
export const CONSOLE_PATH = '/api/tether/console';
|
|
29
|
+
export const KEYS_MAX = 64 * 1024;
|
|
30
|
+
export const JOURNAL_MAX = 30;
|
|
31
|
+
const CLOSE_ENDED = 1000;
|
|
32
|
+
const CLOSE_FAILED = 1011;
|
|
33
|
+
|
|
34
|
+
const whoOf = (headers) => {
|
|
35
|
+
const identity = String(headers?.[IDENTITY_HEADER] ?? '').trim().toLowerCase();
|
|
36
|
+
return { id: `person:${identity || 'owner'}`, name: identity || 'Owner' };
|
|
37
|
+
};
|
|
38
|
+
const machineOf = (tethers, id) => {
|
|
39
|
+
const t = tethers?.store().target(String(id ?? ''));
|
|
40
|
+
return t && t.kind === 'ssh' ? t : null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export function attachConsole(server, { tethers, gate = () => 'local', originOk }) {
|
|
44
|
+
const sockets = new WebSocketServer({ noServer: true, maxPayload: KEYS_MAX });
|
|
45
|
+
server.on('upgrade', (request, socket, head) => {
|
|
46
|
+
const url = new URL(request.url ?? '/', 'http://local');
|
|
47
|
+
if (url.pathname !== CONSOLE_PATH) return;
|
|
48
|
+
const target = machineOf(tethers, url.searchParams.get('target'));
|
|
49
|
+
if (!originOk(request.headers) || gate(request.headers) === undefined || !target) { socket.destroy(); return; }
|
|
50
|
+
const cols = Number(url.searchParams.get('cols')); const rows = Number(url.searchParams.get('rows'));
|
|
51
|
+
sockets.handleUpgrade(request, socket, head, (ws) => { void seat(ws, target, whoOf(request.headers), { cols, rows }); });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
async function seat(ws, target, who, { cols, rows }) {
|
|
55
|
+
const send = (data, binary = false) => { if (ws.readyState === 1) ws.send(data, { binary }); };
|
|
56
|
+
let handle = null; let gone = false; const early = [];
|
|
57
|
+
const onEvent = (e) => {
|
|
58
|
+
if (!handle) { early.push(e); return; }
|
|
59
|
+
if (e.type === 'data') send(Buffer.from(e.data, 'utf8'), true);
|
|
60
|
+
else if (e.type === 'state') send(JSON.stringify({ type: 'state', state: e.state }));
|
|
61
|
+
else if (e.type === 'closed') { try { ws.close(CLOSE_ENDED, 'ended'); } catch { /* gone */ } }
|
|
62
|
+
};
|
|
63
|
+
ws.on('close', () => { gone = true; handle?.detach(); });
|
|
64
|
+
try { handle = await tethers.console(target.id, who, onEvent); } catch (error) {
|
|
65
|
+
send(JSON.stringify({ type: 'error', text: String(error?.message ?? error) }));
|
|
66
|
+
try { ws.close(CLOSE_FAILED, 'failed'); } catch { /* gone */ }
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (gone) { handle.detach(); return; }
|
|
70
|
+
handle.resize(cols, rows);
|
|
71
|
+
send(JSON.stringify({ type: 'ready', state: handle.state() }));
|
|
72
|
+
if (handle.replay) send(Buffer.from(handle.replay, 'utf8'), true);
|
|
73
|
+
/* What came meanwhile is in the replay already: only the latest state is said again. */
|
|
74
|
+
if (early.some((e) => e.type === 'closed')) { try { ws.close(CLOSE_ENDED, 'ended'); } catch { /* gone */ } return; }
|
|
75
|
+
ws.on('message', (data, binary) => {
|
|
76
|
+
if (binary) { handle.write(Buffer.from(data).toString('utf8')); return; }
|
|
77
|
+
let m; try { m = JSON.parse(String(data)); } catch { return; }
|
|
78
|
+
if (m?.type === 'resize') handle.resize(Number(m.cols), Number(m.rows));
|
|
79
|
+
else if (m?.type === 'hidden') handle.hidden(m.on === true);
|
|
80
|
+
else if (m?.type === 'hide-ai') handle.hideFromAi(m.on === true);
|
|
81
|
+
else if (m?.type === 'take-back') handle.takeBack();
|
|
82
|
+
else if (m?.type === 'interrupt') handle.interrupt();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return sockets;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* The console's short journal: the newest first, its agents' inputs and its events. */
|
|
89
|
+
export async function consoleJournal(tethers, body = {}) {
|
|
90
|
+
const target = machineOf(tethers, body.target);
|
|
91
|
+
if (!target) throw new Refusal(404, 'No such machine.');
|
|
92
|
+
const r = await tethers.act('journal', { target: target.id, limit: 200 }, '');
|
|
93
|
+
if (!r.ok) throw new Refusal(502, r.text);
|
|
94
|
+
const lines = (Array.isArray(r.data) ? r.data : []).filter((l) => l.op === 'console' || String(l.verb ?? '').startsWith('terminal.') && l.verb !== 'terminal.read' && l.verb !== 'terminal.open')
|
|
95
|
+
.slice(0, JOURNAL_MAX)
|
|
96
|
+
.map((l) => ({ at: l.at, ...(l.op ? { op: l.op } : {}), ...(l.verb ? { verb: l.verb } : {}), detail: String(l.detail ?? ''), ...(l.agent?.name ? { agent: l.agent.name } : {}), ...(l.by?.name ? { by: l.by.name } : {}),
|
|
97
|
+
...(l.decision ? { decision: l.decision } : {}), ...(l.ok !== undefined ? { ok: l.ok } : {}), ...(l.risk ? { risk: l.risk } : {}), ...(l.edited ? { edited: true } : {}), ...(l.error ? { error: String(l.error) } : {}) }));
|
|
98
|
+
return { lines };
|
|
99
|
+
}
|
|
@@ -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
|
+
};
|
package/server/tethers.mjs
CHANGED
|
@@ -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;
|
|
@@ -304,6 +310,15 @@ export class Tethers {
|
|
|
304
310
|
return this.#keeper.read(String(verb ?? ''), args && typeof args === 'object' ? args : {}, by);
|
|
305
311
|
}
|
|
306
312
|
|
|
313
|
+
/* A MACHINE'S SHARED CONSOLE, for the person's page (sshconsole.mjs): one shell per machine, the conversations given
|
|
314
|
+
it on the same one. `who`: { id, name }, the person the caller has already checked; `onEvent` gets what the machine
|
|
315
|
+
prints and the console's state. -> Tether's handle (write, resize, hidden, hideFromAi, takeBack, interrupt, detach). */
|
|
316
|
+
console(target, who, onEvent) {
|
|
317
|
+
const by = { id: String(who?.id ?? 'person:owner'), name: String(who?.name ?? 'Owner') };
|
|
318
|
+
if (typeof this.#keeper.console !== 'function') throw new Error('this Tether has no shared console');
|
|
319
|
+
return this.#keeper.console(String(target ?? ''), by, onEvent);
|
|
320
|
+
}
|
|
321
|
+
|
|
307
322
|
/* The store behind it, for the Assets page to create/give/remove targets. */
|
|
308
323
|
store() { return this.#keeper.store; }
|
|
309
324
|
|
package/web/app.js
CHANGED
|
@@ -483,13 +483,15 @@
|
|
|
483
483
|
document.addEventListener('keydown', (event) => {
|
|
484
484
|
if (event.key !== 'Escape' || event.defaultPrevented || event.isComposing) return;
|
|
485
485
|
const target = event.target instanceof Element ? event.target : null;
|
|
486
|
-
if (target?.closest('#terminal')) return;
|
|
486
|
+
if (target?.closest('#terminal, .sc-screen')) return;
|
|
487
487
|
if (target?.matches('input:not([type=checkbox]):not([type=radio]):not([type=button]), textarea, select, [contenteditable]:not([contenteditable=false])')) { target.blur(); return; }
|
|
488
488
|
if (nav.back()) event.preventDefault();
|
|
489
489
|
});
|
|
490
490
|
|
|
491
491
|
/* ---------- the terminal ---------- */
|
|
492
|
-
|
|
492
|
+
/* ONE TERMINAL, everywhere a terminal is drawn (a conversation's, a machine's shared console): the same xterm,
|
|
493
|
+
the same font and theme, the same links. What it is given to draw is only ever drawn by it, never as HTML. */
|
|
494
|
+
const terminalOptions = () => ({
|
|
493
495
|
cursorBlink: true, scrollback: 5000,
|
|
494
496
|
fontSize: innerWidth < 500 ? 11 : 14,
|
|
495
497
|
fontFamily: 'ui-monospace, Menlo, Consolas, monospace',
|
|
@@ -498,6 +500,7 @@
|
|
|
498
500
|
tab, with no way back to this page; anything else is not followed. */
|
|
499
501
|
linkHandler: { activate: (_event, uri) => openWeb(uri), allowNonHttpProtocols: false },
|
|
500
502
|
});
|
|
503
|
+
const terminal = new Terminal(terminalOptions());
|
|
501
504
|
/* A web address on screen opens in a new tab, on its own: nothing of this
|
|
502
505
|
page is handed to it. Only http and https. */
|
|
503
506
|
function openWeb(uri) {
|
|
@@ -981,7 +984,13 @@
|
|
|
981
984
|
A click from the keyboard (Enter or Space on the focused button)
|
|
982
985
|
sends once. */
|
|
983
986
|
const stopRepeats = new Set();
|
|
984
|
-
|
|
987
|
+
/* THE KEYS BAR, one behaviour wherever it is (a conversation's #keys, a machine's console): each button's
|
|
988
|
+
data-keys, sent to `sendKeys`, the focus given back by `focusBack`. */
|
|
989
|
+
function wireKeys(buttons, sendKeys, focusBack) {
|
|
990
|
+
for (const button of buttons) wireKey(button, sendKeys, focusBack);
|
|
991
|
+
}
|
|
992
|
+
wireKeys(document.querySelectorAll('#keys button[data-keys]'), (keys) => send(keys), () => focusTerminal());
|
|
993
|
+
function wireKey(button, send, focusTerminal) {
|
|
985
994
|
const key = button.dataset.keys;
|
|
986
995
|
let delay = null; let every = null;
|
|
987
996
|
const stop = () => { clearTimeout(delay); clearInterval(every); delay = null; every = null; };
|
|
@@ -4537,7 +4546,7 @@
|
|
|
4537
4546
|
line.append(summary, el('pre', '', rest));
|
|
4538
4547
|
return line;
|
|
4539
4548
|
}
|
|
4540
|
-
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; };
|
|
4541
4550
|
/* A list (Binder's): the set has no such sign, so it is drawn here, in its style. */
|
|
4542
4551
|
function listIcon() {
|
|
4543
4552
|
const SVG = 'http://www.w3.org/2000/svg';
|
|
@@ -5359,7 +5368,7 @@
|
|
|
5359
5368
|
onKind: (k) => {
|
|
5360
5369
|
giveNew.kind = k; giveNew.level = ''; justMade = null; $('cassets-error').hidden = true; void paintRoomAssets();
|
|
5361
5370
|
/* Its keys, read here too: Assets may not have been opened yet. */
|
|
5362
|
-
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));
|
|
5363
5372
|
},
|
|
5364
5373
|
onBack: () => { giveNew.kind = ''; $('cassets-error').hidden = true; void paintRoomAssets(); },
|
|
5365
5374
|
onAnother: () => { giveNew.kind = made.kind; justMade = null; void paintRoomAssets(); },
|
|
@@ -5711,7 +5720,7 @@
|
|
|
5711
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')],
|
|
5712
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)],
|
|
5713
5722
|
/* Step 4: a voice box (paired with a code) and a device (the share sheet, its code) are two kinds of it too. */
|
|
5714
|
-
['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')]]
|
|
5715
5724
|
.map(([kind, label]) => ({ kind, label, icon: kindIcon(kind) }));
|
|
5716
5725
|
/* A voice box's steps after its kind (the flow: "A NEW VOICE BOX", with the boxes), and the one under way. */
|
|
5717
5726
|
const BOX_STEPS = ['where', 'plug', 'pair'];
|
|
@@ -5741,6 +5750,7 @@
|
|
|
5741
5750
|
if (kind === 'box') return paintBoxFlow();
|
|
5742
5751
|
const form = $(`${addForm(kind)}-box`); form.hidden = false;
|
|
5743
5752
|
if (kind === 'git') { fillKeyChoice(); showVia(); }
|
|
5753
|
+
if (kind === 'machine') { fillKeyChoice(); void getJson('/git-keys', []).then((keys) => paintKeys(keys)); }
|
|
5744
5754
|
if (kind === 'list') void fillTemplates();
|
|
5745
5755
|
if (kind === 'browser') $('browser-address').value = browserAddress();
|
|
5746
5756
|
return form;
|
|
@@ -6127,6 +6137,8 @@
|
|
|
6127
6137
|
/* A CALENDAR'S AGENDA (16-11): its events, under who has it -- read through Tether as the owner's own read
|
|
6128
6138
|
(agenda.mjs), so the calendar need not stay open elsewhere. The owner's page only: a device reads no calendar. */
|
|
6129
6139
|
if (t?.kind === 'calendar' && !DEVICE) parts.push(agendaPart(t));
|
|
6140
|
+
/* A MACHINE'S SHARED CONSOLE (16-11): live, under who has it (sshconsole.mjs). The owner's page only: not given to devices. */
|
|
6141
|
+
if (t?.kind === 'ssh' && !DEVICE) parts.push(...consoleParts(t, tether, from));
|
|
6130
6142
|
/* A MAILBOX'S MAIL, AN ADDRESS BOOK'S CONTACTS (16-11): read the same way (mailview.mjs, contactview.mjs). */
|
|
6131
6143
|
if (t?.kind === 'mail' && !DEVICE) parts.push(mailPart(t));
|
|
6132
6144
|
if (t?.kind === 'contacts' && !DEVICE) parts.push(contactsPart(t));
|
|
@@ -6194,7 +6206,8 @@
|
|
|
6194
6206
|
/* An MCP server's rights say themselves (Off / Read / All with approval / All / Custom): no levels' words under them. */
|
|
6195
6207
|
if (t.kind !== 'mcp') parts.push(el('p', 'hint', 'A level is: watch (read only), propose (asks before each action), frame (acts within its rules, asks for the rest), free (acts, kept in the journal).'));
|
|
6196
6208
|
/* Calls waiting for a person (propose/frame). Accept or refuse each. */
|
|
6197
|
-
|
|
6209
|
+
/* A machine's terminal inputs are proposed beside its console (consoleAsk), not here again. */
|
|
6210
|
+
const waiting = (Array.isArray(tether.approvals) ? tether.approvals : []).filter((q) => (q.target?.id ?? q.target) === t.id && !(t.kind === 'ssh' && !DEVICE && String(q.verb ?? '').startsWith('terminal.')));
|
|
6198
6211
|
if (waiting.length) {
|
|
6199
6212
|
const box = el('div', 'as-users');
|
|
6200
6213
|
for (const q of waiting) {
|
|
@@ -6290,11 +6303,14 @@
|
|
|
6290
6303
|
}
|
|
6291
6304
|
function agendaEvent(ev) {
|
|
6292
6305
|
const box = el('details', 'ag-event'); box.dataset.show = ev.show ?? 'busy';
|
|
6306
|
+
if (ev.cancelled) box.dataset.cancelled = '';
|
|
6293
6307
|
if (agendaOpen === ev.id) box.open = true;
|
|
6294
6308
|
box.addEventListener('toggle', () => { if (box.open) agendaOpen = ev.id; else if (agendaOpen === ev.id) agendaOpen = ''; });
|
|
6295
6309
|
const head = el('summary', 'ag-row');
|
|
6296
6310
|
head.append(el('span', 'ag-time', ev.allDay ? uiSaid('set-ag-allday', 'All day') : hourOf(ev.start)));
|
|
6297
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')));
|
|
6298
6314
|
if (ev.location) what.append(el('span', 'ag-where hint', ev.location));
|
|
6299
6315
|
head.append(what);
|
|
6300
6316
|
const facts = el('dl', 'ag-facts');
|
|
@@ -6363,6 +6379,311 @@
|
|
|
6363
6379
|
}
|
|
6364
6380
|
agendaDays(holder, answer);
|
|
6365
6381
|
}
|
|
6382
|
+
/* A MACHINE'S SHARED CONSOLE (16-11): the live SSH console of a machine asset, under who has it -- ONE shell that
|
|
6383
|
+
the person and the conversations given the machine share (Tether's console.mjs, through sshconsole.mjs). Drawn by
|
|
6384
|
+
the same terminal as a conversation's (terminalOptions, xterm: what the machine prints is never HTML here), with
|
|
6385
|
+
the same keys bar (wireKeys). Big: most of the panel's height. Under it, the AI's proposals (Send / Edit / Refuse,
|
|
6386
|
+
destructive marked, sent in two steps) and its inputs, then a short journal. Full screen: the console large and,
|
|
6387
|
+
beside it (under it on a phone), the chat of the conversation that holds the machine (Parley's own view). The
|
|
6388
|
+
person's key always wins; « Take back control », « Hidden input », « Hide from the AI », Ctrl C.
|
|
6389
|
+
KEPT ACROSS PAINTS: the panel is drawn again with every Tether change, the console is not -- its element (and its
|
|
6390
|
+
terminal, its socket) is the same one, moved into the new panel, its focus given back. */
|
|
6391
|
+
const consoleViews = new Map(); /* target id -> view */
|
|
6392
|
+
const SC_KEYS = [['esc', 'Esc'], ['tab', 'Tab'], ['left', '←'], ['down', '↓'], ['up', '↑'], ['right', '→'], ['enter', 'Enter'], ['stop', 'Ctrl+C']];
|
|
6393
|
+
const SC_RISK = {
|
|
6394
|
+
erase: ['set-sc-risk-erase', 'Erases files. No way back.'], disk: ['set-sc-risk-disk', 'Writes over a disk. No way back.'],
|
|
6395
|
+
power: ['set-sc-risk-power', 'Stops or restarts the machine.'], rights: ['set-sc-risk-rights', 'Changes rights on the whole system.'],
|
|
6396
|
+
other: ['set-sc-risk-other', 'Can break the machine.'],
|
|
6397
|
+
};
|
|
6398
|
+
const SC_EVENTS = {
|
|
6399
|
+
'control taken back from the AI': ['set-sc-j-took', 'took back control'], 'input hidden: a password prompt': ['set-sc-j-prompt', 'password prompt: input hidden'],
|
|
6400
|
+
'input hidden by the person': ['set-sc-j-hidden', 'hidden input'], 'hidden from the AI': ['set-sc-j-hide-ai', 'hidden from the AI'], 'shown to the AI again': ['set-sc-j-show-ai', 'shown to the AI again'],
|
|
6401
|
+
};
|
|
6402
|
+
const scButton = (cls, text) => { const b = el('button', cls, text); b.type = 'button'; return b; };
|
|
6403
|
+
const hhmm = (at) => { const d = new Date(at); return Number.isNaN(d.getTime()) ? '' : d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); };
|
|
6404
|
+
function consoleView(target) {
|
|
6405
|
+
let v = consoleViews.get(target.id);
|
|
6406
|
+
if (v) { v.target = target; return v; }
|
|
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: '' };
|
|
6408
|
+
consoleViews.set(target.id, v);
|
|
6409
|
+
const root = el('div', 'sc'); root.dataset.target = target.id;
|
|
6410
|
+
const presence = el('div', 'sc-presence'); presence.setAttribute('aria-live', 'polite');
|
|
6411
|
+
const screen = el('div', 'sc-screen'); screen.setAttribute('role', 'log'); screen.setAttribute('aria-label', uiSaid('set-sc-console', 'Console'));
|
|
6412
|
+
const banner = el('div', 'sc-state'); banner.setAttribute('aria-live', 'assertive');
|
|
6413
|
+
const keys = el('div', 'sc-keys'); keys.setAttribute('role', 'group'); keys.setAttribute('aria-label', uiSaid('set-sc-keys', 'Keys'));
|
|
6414
|
+
for (const [k, label] of SC_KEYS) { const b = scButton(k === 'stop' ? 'careful' : '', label); b.dataset.keys = k; keys.append(b); }
|
|
6415
|
+
const take = scButton('danger sc-take', uiSaid('set-sc-take', 'Take back control')); take.hidden = true;
|
|
6416
|
+
const hideAi = scButton('sc-hide-ai', uiSaid('set-sc-hide-ai', 'Hide from the AI')); hideAi.setAttribute('aria-pressed', 'false');
|
|
6417
|
+
const secret = scButton('sc-secret', uiSaid('set-sc-secret', 'Hidden input')); secret.setAttribute('aria-pressed', 'false');
|
|
6418
|
+
const ctrlc = scButton('quiet sc-ctrlc', 'Ctrl C'); ctrlc.title = uiSaid('set-sc-ctrlc', 'Interrupts what is running');
|
|
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');
|
|
6422
|
+
const reopen = scButton('primary sc-reopen', uiSaid('set-sc-reopen', 'Open it again')); reopen.hidden = true;
|
|
6423
|
+
const tools = el('div', 'sc-tools'); tools.append(take, hideAi, secret, el('span', 'sc-space'), ctrlc, chatBtn, full);
|
|
6424
|
+
const main = el('div', 'sc-main'); main.append(presence, screen, banner, keys, tools);
|
|
6425
|
+
/* Full screen: the chat of a conversation that holds the machine, beside the console. */
|
|
6426
|
+
const chatHead = el('div', 'sc-chat-head');
|
|
6427
|
+
const chatBox = el('div', 'sc-chat-thread');
|
|
6428
|
+
const side = el('aside', 'sc-chat'); side.setAttribute('aria-label', uiSaid('set-sc-chat', 'Chat')); side.hidden = true; side.append(chatHead, chatBox);
|
|
6429
|
+
root.append(main, side);
|
|
6430
|
+
Object.assign(v, { root, presence, screen, banner, take, hideAi, secret, fullBtn: full, chatBtn, reopen, chatHead, chatBox, side });
|
|
6431
|
+
const term = new Terminal({ ...terminalOptions(), scrollback: 3000 });
|
|
6432
|
+
const fitter = new FitAddon.FitAddon(); term.loadAddon(fitter);
|
|
6433
|
+
v.term = term; v.fit = () => { if (v.opened && screen.isConnected && screen.offsetWidth > 0) { try { fitter.fit(); } catch { /* not drawn yet */ } } };
|
|
6434
|
+
new ResizeObserver(() => v.fit()).observe(screen);
|
|
6435
|
+
const sendJson = (m) => { if (v.socket?.readyState === 1) v.socket.send(JSON.stringify(m)); };
|
|
6436
|
+
const sendKeys = (data) => { if (v.socket?.readyState === 1) v.socket.send(new TextEncoder().encode(data)); };
|
|
6437
|
+
v.sendJson = sendJson;
|
|
6438
|
+
term.onData(sendKeys);
|
|
6439
|
+
term.onResize(({ cols, rows }) => sendJson({ type: 'resize', cols, rows }));
|
|
6440
|
+
keys.addEventListener('pointerdown', (event) => { if (event.target.closest('button')) event.preventDefault(); });
|
|
6441
|
+
wireKeys(keys.querySelectorAll('button[data-keys]'), sendKeys, () => term.focus());
|
|
6442
|
+
take.addEventListener('click', () => { sendJson({ type: 'take-back' }); term.focus(); });
|
|
6443
|
+
ctrlc.addEventListener('click', () => { sendJson({ type: 'interrupt' }); term.focus(); });
|
|
6444
|
+
hideAi.addEventListener('click', () => { sendJson({ type: 'hide-ai', on: !(v.state?.hideAi) }); });
|
|
6445
|
+
secret.addEventListener('click', () => { sendJson({ type: 'hidden', on: !(v.state?.hidden) }); term.focus(); });
|
|
6446
|
+
full.addEventListener('click', () => consoleFull(v, !v.full));
|
|
6447
|
+
chatBtn.addEventListener('click', () => consoleBelow(v, !v.below));
|
|
6448
|
+
reopen.addEventListener('click', () => { reopen.hidden = true; consoleConnect(v); });
|
|
6449
|
+
/* Where the focus is, kept across paints: given back once the console is in the new panel. */
|
|
6450
|
+
root.addEventListener('focusin', () => { v.focused = true; });
|
|
6451
|
+
document.addEventListener('pointerdown', (event) => { if (!root.contains(event.target)) v.focused = false; }, true);
|
|
6452
|
+
return v;
|
|
6453
|
+
}
|
|
6454
|
+
function consoleConnect(v) {
|
|
6455
|
+
if (v.socket && v.socket.readyState <= 1) return;
|
|
6456
|
+
v.phase = 'connecting'; consolePaint(v);
|
|
6457
|
+
const scheme = location.protocol === 'https:' ? 'wss' : 'ws';
|
|
6458
|
+
const ws = new WebSocket(`${scheme}://${location.host}${API}/tether/console?${new URLSearchParams({ target: v.id, cols: String(v.term.cols), rows: String(v.term.rows) })}`);
|
|
6459
|
+
ws.binaryType = 'arraybuffer';
|
|
6460
|
+
v.socket = ws;
|
|
6461
|
+
ws.addEventListener('message', (event) => {
|
|
6462
|
+
if (typeof event.data !== 'string') { v.term.write(new Uint8Array(event.data)); return; }
|
|
6463
|
+
let m; try { m = JSON.parse(event.data); } catch { return; }
|
|
6464
|
+
/* Ready: the screen so far comes next, drawn on a clean terminal (a page that came back draws it once). */
|
|
6465
|
+
if (m.type === 'ready') { v.term.reset(); v.phase = 'live'; v.retry = 0; v.state = m.state; consolePaint(v); v.fit(); }
|
|
6466
|
+
else if (m.type === 'state') { const was = v.state; v.state = m.state; consolePaint(v); if (was && !was.typing !== !m.state.typing) consoleSoon(v); }
|
|
6467
|
+
else if (m.type === 'error') { v.phase = 'failed'; v.error = String(m.text ?? ''); consolePaint(v); }
|
|
6468
|
+
});
|
|
6469
|
+
ws.addEventListener('close', (event) => {
|
|
6470
|
+
if (v.socket !== ws) return;
|
|
6471
|
+
v.socket = null;
|
|
6472
|
+
if (v.phase === 'failed') { v.reopen.hidden = false; return; }
|
|
6473
|
+
if (event.code === 1000) { v.phase = 'closed'; consolePaint(v); return; }
|
|
6474
|
+
/* Dropped: again in a moment while it is shown, said meanwhile; never its keys replayed. */
|
|
6475
|
+
v.phase = 'connecting'; consolePaint(v);
|
|
6476
|
+
if (v.root.isConnected && v.retry < 6) { v.retry++; setTimeout(() => { if (v.root.isConnected) consoleConnect(v); }, 1500 * v.retry); }
|
|
6477
|
+
else { v.phase = 'closed'; consolePaint(v); }
|
|
6478
|
+
});
|
|
6479
|
+
}
|
|
6480
|
+
/* After the AI typed: the journal and the proposals read again (a paint of the panel; the console stays). */
|
|
6481
|
+
function consoleSoon(v) { clearTimeout(v.soon); v.soon = setTimeout(() => { if (v.root.isConnected) void repaintAsset(); }, 600); }
|
|
6482
|
+
function consolePaint(v) {
|
|
6483
|
+
const st = v.state ?? {};
|
|
6484
|
+
const typing = st.typing ?? null;
|
|
6485
|
+
v.root.classList.toggle('ai-typing', Boolean(typing));
|
|
6486
|
+
v.root.classList.toggle('hidden-input', Boolean(st.hidden));
|
|
6487
|
+
v.root.classList.toggle('hidden-ai', Boolean(st.hideAi));
|
|
6488
|
+
/* Who has it: you, and each assistant on it -- what it does, in words, never by colour alone. */
|
|
6489
|
+
const chips = [];
|
|
6490
|
+
const me = el('span', `sc-chip me${typing ? '' : ' active'}`); me.append(el('span', 'sc-av', uiSaid('set-sc-you-av', 'Y')), el('span', '', uiSaid('set-sc-you', 'You')), el('small', '', st.hidden ? uiSaid('set-sc-you-hidden', 'typing (hidden)') : typing ? uiSaid('set-sc-you-watch', 'watching') : uiSaid('set-sc-you-control', 'in control')));
|
|
6491
|
+
chips.push(me);
|
|
6492
|
+
for (const a of st.agents ?? []) {
|
|
6493
|
+
const doing = st.hideAi ? uiSaid('set-sc-ai-blind', 'sees nothing') : typing?.agent === a.id ? uiSaid('set-sc-ai-typing', 'typing') : v.waiting.some((q) => q.agent?.id === a.id) ? uiSaid('set-sc-ai-proposes', 'proposes') : uiSaid('set-sc-ai-watching', 'watching');
|
|
6494
|
+
const c = el('span', `sc-chip ai${typing?.agent === a.id ? ' active' : ''}`); c.append(el('span', 'sc-av', uiSaid('set-sc-ai-av', 'AI')), el('span', '', a.name), el('small', '', doing));
|
|
6495
|
+
chips.push(c);
|
|
6496
|
+
}
|
|
6497
|
+
if (!(st.agents ?? []).length) chips.push(el('small', 'hint', uiSaid('set-sc-no-ai', 'No assistant on it now')));
|
|
6498
|
+
const live = el('span', `sc-live${v.phase === 'live' ? ' on' : ''}`, v.phase === 'live' ? uiSaid('set-sc-live', 'live') : v.phase === 'connecting' ? uiSaid('set-sc-connecting', 'connecting…') : uiSaid('set-sc-off', 'closed'));
|
|
6499
|
+
v.presence.replaceChildren(...chips, el('span', 'sc-space'), live);
|
|
6500
|
+
/* The one line that says the state (aria-live). */
|
|
6501
|
+
let text; let tone = '';
|
|
6502
|
+
if (v.phase === 'failed') { text = v.error || uiSaid('set-sc-failed', 'The console could not be opened.'); tone = 'bad'; }
|
|
6503
|
+
else if (v.phase === 'closed') { text = uiSaid('set-sc-closed', 'The console is closed.'); tone = 'pause'; }
|
|
6504
|
+
else if (v.phase === 'connecting') text = uiSaid('set-sc-connecting-long', 'Connecting to the machine…');
|
|
6505
|
+
else if (st.hidden) { text = st.hidden === 'prompt' ? uiSaid('set-sc-hidden-prompt', 'Password asked: hidden input, the AI sees nothing.') : uiSaid('set-sc-hidden', 'Hidden input: the AI sees nothing.'); tone = 'secret'; }
|
|
6506
|
+
else if (typing) { text = uiSaid('set-sc-typing', '{name} is typing. A key takes back control.', { name: typing.name }); tone = 'ai'; }
|
|
6507
|
+
else if (st.hideAi) { text = uiSaid('set-sc-hidden-ai', 'Hidden from the AI until you show it.'); tone = 'pause'; }
|
|
6508
|
+
else text = uiSaid('set-sc-control', 'You are in control.');
|
|
6509
|
+
v.banner.dataset.tone = tone;
|
|
6510
|
+
v.banner.replaceChildren(el('span', '', text), ...(v.phase === 'closed' || v.phase === 'failed' ? [v.reopen] : []));
|
|
6511
|
+
if (v.phase === 'closed' || v.phase === 'failed') v.reopen.hidden = false;
|
|
6512
|
+
v.take.hidden = !typing;
|
|
6513
|
+
v.hideAi.setAttribute('aria-pressed', String(Boolean(st.hideAi)));
|
|
6514
|
+
v.hideAi.textContent = st.hideAi ? uiSaid('set-sc-show-ai', 'Show to the AI') : uiSaid('set-sc-hide-ai', 'Hide from the AI');
|
|
6515
|
+
v.secret.setAttribute('aria-pressed', String(Boolean(st.hidden)));
|
|
6516
|
+
}
|
|
6517
|
+
/* FULL SCREEN: the console large, the chat of its conversation beside it (under it on a phone). Esc (outside the
|
|
6518
|
+
terminal, which keeps its Escape for the machine) or Back leaves. */
|
|
6519
|
+
function consoleFull(v, on) {
|
|
6520
|
+
if (v.full === on) return;
|
|
6521
|
+
v.full = on;
|
|
6522
|
+
v.root.classList.toggle('sc-full', on);
|
|
6523
|
+
v.side.hidden = !on && !v.below;
|
|
6524
|
+
v.chatBtn.hidden = on;
|
|
6525
|
+
const b = v.fullBtn;
|
|
6526
|
+
b.setAttribute('aria-pressed', String(on));
|
|
6527
|
+
b.textContent = on ? uiSaid('set-sc-leave-full', 'Leave full screen') : uiSaid('set-sc-full', 'Full screen');
|
|
6528
|
+
document.documentElement.toggleAttribute('data-sc-full', on);
|
|
6529
|
+
/* Over the whole page, out of the panel (drawn again meanwhile, it holds a line in its place); back in it after. */
|
|
6530
|
+
if (on) document.body.append(v.root);
|
|
6531
|
+
else if (v.root.parentElement === document.body) { v.root.remove(); void repaintAsset(); }
|
|
6532
|
+
if (on) {
|
|
6533
|
+
v.fullStep = nav.over('console-full', () => consoleFull(v, false));
|
|
6534
|
+
void consoleChat(v);
|
|
6535
|
+
} else {
|
|
6536
|
+
if (v.fullStep) { const step = v.fullStep; v.fullStep = null; nav.drop(step); }
|
|
6537
|
+
if (!v.below) { v.chat?.destroy(); v.chat = null; v.chatOf = ''; }
|
|
6538
|
+
}
|
|
6539
|
+
requestAnimationFrame(() => { v.fit(); v.term.focus(); });
|
|
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
|
+
}
|
|
6552
|
+
/* The conversations that hold the machine; the one whose chat is shown: picked, else the one on the console now,
|
|
6553
|
+
else the conversation this panel is seen from, else the first. */
|
|
6554
|
+
function consoleHolders(v) {
|
|
6555
|
+
return Object.keys(v.target.grants ?? {}).filter((id) => id.startsWith('conversation:')).map((id) => id.slice('conversation:'.length)).filter((n) => conversations.some((c) => c.name === n));
|
|
6556
|
+
}
|
|
6557
|
+
function consoleChatOf(v) {
|
|
6558
|
+
const holders = consoleHolders(v);
|
|
6559
|
+
if (v.chatPick && holders.includes(v.chatPick)) return v.chatPick;
|
|
6560
|
+
const on = (v.state?.agents ?? []).map((a) => String(a.id).replace(/^conversation:/, '')).find((n) => holders.includes(n));
|
|
6561
|
+
return on ?? (holders.includes(v.from) ? v.from : holders[0] ?? '');
|
|
6562
|
+
}
|
|
6563
|
+
async function consoleChat(v) {
|
|
6564
|
+
const holders = consoleHolders(v);
|
|
6565
|
+
const name = consoleChatOf(v);
|
|
6566
|
+
const label = (n) => conversations.find((c) => c.name === n)?.title || n;
|
|
6567
|
+
if (holders.length > 1) {
|
|
6568
|
+
const pick = el('select', 'sc-chat-pick'); pick.setAttribute('aria-label', uiSaid('set-sc-chat-of', 'Chat of'));
|
|
6569
|
+
for (const n of holders) { const o = el('option', '', label(n)); o.value = n; o.selected = n === name; pick.append(o); }
|
|
6570
|
+
pick.addEventListener('change', () => { v.chatPick = pick.value; void consoleChat(v); });
|
|
6571
|
+
v.chatHead.replaceChildren(el('b', '', uiSaid('set-sc-chat-of', 'Chat of')), pick);
|
|
6572
|
+
} else v.chatHead.replaceChildren(el('b', '', name ? label(name) : uiSaid('set-sc-chat', 'Chat')));
|
|
6573
|
+
if (!name) { v.chat?.destroy(); v.chat = null; v.chatOf = ''; v.chatBox.replaceChildren(el('p', 'hint', uiSaid('set-sc-no-holder', 'No conversation has this machine.'))); return; }
|
|
6574
|
+
if (v.chat && v.chatOf === name) return;
|
|
6575
|
+
v.chat?.destroy(); v.chat = null; v.chatOf = name;
|
|
6576
|
+
v.chatBox.replaceChildren();
|
|
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; }
|
|
6578
|
+
const [{ mount }, words] = await Promise.all([parleyUi(), readWords()]);
|
|
6579
|
+
if (!(v.full || v.below) || v.chatOf !== name) return;
|
|
6580
|
+
v.chatBox.dataset.theme = document.documentElement.dataset.theme === 'light' ? 'light' : 'dark';
|
|
6581
|
+
/* Parley's own chat view, as in the conversation: its thread read and written the same way. */
|
|
6582
|
+
v.chat = mount(v.chatBox, {
|
|
6583
|
+
words, view: chatView, window: windowFor(chatWindow),
|
|
6584
|
+
load: (asked = {}) => fetch(talkPath(name, '', asked)).then((r) => r.json()).then(machineLines),
|
|
6585
|
+
search: (q) => fetch(talkPath(name, '/search', { q })).then((r) => (r.ok ? r.json() : { matches: [], count: 0 })),
|
|
6586
|
+
send: (text, answers, files) => post(talkPath(name), { text, answers, quick: true, ...(files ? { files: files.map((f) => (f.note ? { path: f.path, note: f.note } : f.path)) } : {}) }),
|
|
6587
|
+
schemes: { mail: { icon: 'mail', open: (ref, label2) => { void openMailRef(ref, { label: label2, of: name }); } } },
|
|
6588
|
+
});
|
|
6589
|
+
}
|
|
6590
|
+
/* A console no longer shown for a while lets its shell go (the person's side): opened again when shown. */
|
|
6591
|
+
setInterval(() => {
|
|
6592
|
+
for (const v of consoleViews.values()) {
|
|
6593
|
+
if (v.root.isConnected) { v.away = 0; continue; }
|
|
6594
|
+
v.away += 1;
|
|
6595
|
+
if (v.away >= 3 && v.socket) { const ws = v.socket; v.socket = null; v.phase = 'closed'; try { ws.close(); } catch { /* gone */ } }
|
|
6596
|
+
}
|
|
6597
|
+
}, 10_000);
|
|
6598
|
+
/* The parts: the console (kept), then what the AI proposes and has typed, then the journal (drawn each paint). */
|
|
6599
|
+
function consoleParts(target, tether, from) {
|
|
6600
|
+
const v = consoleView(target);
|
|
6601
|
+
v.from = from || '';
|
|
6602
|
+
v.waiting = (Array.isArray(tether.approvals) ? tether.approvals : []).filter((q) => (q.target?.id ?? q.target) === target.id && String(q.verb ?? '').startsWith('terminal.'));
|
|
6603
|
+
const hadFocus = v.focused;
|
|
6604
|
+
let tries = 0;
|
|
6605
|
+
queueMicrotask(function place() {
|
|
6606
|
+
/* Put in the panel at the end of its paint; a paint overtaken by another never puts it: given up after a while. */
|
|
6607
|
+
if (!v.root.isConnected) { if (++tries < 120) requestAnimationFrame(place); return; }
|
|
6608
|
+
if (!v.opened) { v.term.open(v.screen); v.opened = true; }
|
|
6609
|
+
v.fit();
|
|
6610
|
+
if (!v.socket) consoleConnect(v);
|
|
6611
|
+
if (hadFocus) v.term.focus();
|
|
6612
|
+
});
|
|
6613
|
+
consolePaint(v);
|
|
6614
|
+
const ai = el('div', 'sc-ai'); ai.setAttribute('aria-live', 'polite');
|
|
6615
|
+
for (const q of v.waiting) ai.append(consoleAsk(q));
|
|
6616
|
+
const typed = el('div', 'sc-typed');
|
|
6617
|
+
ai.append(typed);
|
|
6618
|
+
const journal = el('div', 'sc-journal');
|
|
6619
|
+
journal.append(el('p', 'hint', uiSaid('set-sc-j-empty', 'Each AI input is kept here.')));
|
|
6620
|
+
void post(`${API}/tether/console-journal`, { target: target.id }).then((r) => {
|
|
6621
|
+
const lines = Array.isArray(r?.lines) ? r.lines : [];
|
|
6622
|
+
const inputs = lines.filter((l) => l.verb && l.ok === true).slice(0, 3);
|
|
6623
|
+
if (inputs.length) {
|
|
6624
|
+
typed.replaceChildren(el('h4', '', uiSaid('set-sc-typed', 'Its last inputs')));
|
|
6625
|
+
for (const l of inputs) { const row = el('div', 'sc-typed-row'); row.append(el('small', '', hhmm(l.at)), el('code', '', l.detail)); typed.append(row); }
|
|
6626
|
+
} else if (!v.waiting.length) typed.replaceChildren(el('p', 'hint', uiSaid('set-sc-ai-none', 'Nothing proposed. It follows the console.')));
|
|
6627
|
+
if (!lines.length) return;
|
|
6628
|
+
journal.replaceChildren(...lines.map((l) => {
|
|
6629
|
+
const row = el('div', 'sc-j-row');
|
|
6630
|
+
row.append(el('small', 'sc-j-at', hhmm(l.at)));
|
|
6631
|
+
if (l.op === 'console') {
|
|
6632
|
+
const [k, t] = SC_EVENTS[l.detail] ?? ['', l.detail];
|
|
6633
|
+
row.append(el('b', '', l.by ? uiSaid('set-sc-you', 'You') : uiSaid('set-sc-console', 'Console')), el('span', '', k ? uiSaid(k, t) : t));
|
|
6634
|
+
} else {
|
|
6635
|
+
row.append(el('b', '', l.agent ?? uiSaid('set-sc-ai-av', 'AI')), el('code', '', l.detail));
|
|
6636
|
+
const mark = l.decision === 'no' ? uiSaid('set-sc-j-refused', 'refused') : l.decision === 'stopped' || l.decision === 'timeout' || l.decision === 'withdrawn' ? uiSaid('set-sc-j-dropped', 'not sent')
|
|
6637
|
+
: l.ok === false ? uiSaid('set-sc-j-failed', 'not done') : l.edited ? uiSaid('set-sc-j-edited', 'edited by you') : '';
|
|
6638
|
+
if (mark) row.append(el('span', 'sc-j-mark', mark));
|
|
6639
|
+
if (l.risk) row.append(el('span', 'sc-risk', uiSaid('set-sc-destructive', 'Destructive')));
|
|
6640
|
+
}
|
|
6641
|
+
return row;
|
|
6642
|
+
}));
|
|
6643
|
+
}).catch(() => {});
|
|
6644
|
+
return [
|
|
6645
|
+
{ title: uiSaid('set-sc-title', 'Console'), body: [v.full ? el('p', 'hint', uiSaid('set-sc-in-full', 'The console is in full screen.')) : v.root], cls: 'as-console-part' },
|
|
6646
|
+
{ title: uiSaid('set-sc-ai-title', 'Assistant'), body: [ai], cls: 'as-console-ai' },
|
|
6647
|
+
{ title: uiSaid('set-sc-journal', 'Journal'), body: [journal], cls: 'as-console-journal' },
|
|
6648
|
+
];
|
|
6649
|
+
}
|
|
6650
|
+
/* A PROPOSAL: why, the line whole, Send / Edit / Refuse -- the same decision as any waiting call (decideTether);
|
|
6651
|
+
a destructive one marked, said in plain words, and sent in two steps. */
|
|
6652
|
+
function consoleAsk(q) {
|
|
6653
|
+
const risk = q.destructive ?? q.card?.destructive ?? '';
|
|
6654
|
+
const card = el('div', `sc-ask${risk ? ' risky' : ''}`); card.dataset.request = q.id;
|
|
6655
|
+
const head = el('div', 'sc-ask-head');
|
|
6656
|
+
head.append(el('span', 'sc-ai-tag', uiSaid('set-sc-ai-av', 'AI')), el('b', '', uiSaid('set-sc-to-approve', 'To approve')), el('small', 'hint', q.agent?.name ?? ''), el('span', 'sc-space'));
|
|
6657
|
+
if (risk) head.append(el('span', 'sc-risk', uiSaid('set-sc-destructive', 'Destructive')));
|
|
6658
|
+
card.append(head);
|
|
6659
|
+
if (q.why) card.append(el('p', 'sc-why', q.why));
|
|
6660
|
+
const key = (Array.isArray(q.editable) && q.editable[0]) || (q.verb === 'terminal.run' ? 'command' : 'text');
|
|
6661
|
+
const line = String(q.card?.[key] ?? q.detail ?? '');
|
|
6662
|
+
card.append(el('code', 'sc-cmd', line));
|
|
6663
|
+
if (q.verb === 'terminal.run') card.append(el('p', 'hint', uiSaid('set-sc-run-apart', 'Run apart, shown in the console.')));
|
|
6664
|
+
if (risk) { const [k, t] = SC_RISK[risk] ?? SC_RISK.other; card.append(el('p', 'sc-risk-say', uiSaid(k, t))); }
|
|
6665
|
+
const send = scButton(risk ? 'danger' : 'primary', risk ? uiSaid('set-sc-send-anyway', 'Send anyway') : uiSaid('set-sc-send', 'Send'));
|
|
6666
|
+
const edit = scButton('', uiSaid('set-sc-edit', 'Edit'));
|
|
6667
|
+
const refuse = scButton('quiet', uiSaid('set-sc-refuse', 'Refuse'));
|
|
6668
|
+
const acts = el('div', 'sc-ask-acts'); acts.append(send, edit, refuse);
|
|
6669
|
+
let armed = 0;
|
|
6670
|
+
send.addEventListener('click', () => {
|
|
6671
|
+
if (risk && Date.now() - armed > 5000) { armed = Date.now(); send.textContent = uiSaid('set-sc-sure', 'Sure? Send'); return; }
|
|
6672
|
+
send.disabled = true; void decideTether(q.id, 'yes', repaintAsset);
|
|
6673
|
+
});
|
|
6674
|
+
refuse.addEventListener('click', () => { refuse.disabled = true; void decideTether(q.id, 'no', repaintAsset); });
|
|
6675
|
+
card.append(acts);
|
|
6676
|
+
if (Array.isArray(q.editable) && q.editable.length) {
|
|
6677
|
+
const form = el('div', 'sc-edit'); form.hidden = true;
|
|
6678
|
+
const area = el('textarea'); area.rows = 2; area.value = line; area.spellcheck = false; area.setAttribute('aria-label', uiSaid('set-sc-edit-line', 'The line to send'));
|
|
6679
|
+
const go = scButton('primary', uiSaid('set-sc-send-edited', 'Send as edited'));
|
|
6680
|
+
go.addEventListener('click', () => { if (!area.value.trim()) return; go.disabled = true; void decideTether(q.id, 'yes', repaintAsset, { [key]: area.value }); });
|
|
6681
|
+
form.append(area, go);
|
|
6682
|
+
edit.addEventListener('click', () => { form.hidden = !form.hidden; send.hidden = !form.hidden; if (!form.hidden) area.focus(); });
|
|
6683
|
+
card.append(form);
|
|
6684
|
+
} else edit.hidden = true;
|
|
6685
|
+
return card;
|
|
6686
|
+
}
|
|
6366
6687
|
function agendaPart(target) {
|
|
6367
6688
|
const holder = el('div', 'as-agenda');
|
|
6368
6689
|
const move = (days) => {
|
|
@@ -7261,7 +7582,7 @@
|
|
|
7261
7582
|
copy.addEventListener('click', () => { void copyField(field, copy); });
|
|
7262
7583
|
const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Remove';
|
|
7263
7584
|
const why = document.createElement('span'); why.className = 'hint';
|
|
7264
|
-
if (key.usedBy.length) { remove.disabled = true; why.textContent = `removing it would cut ${key.usedBy.join(', ')} off: remove ${key.usedBy.length > 1 ? '
|
|
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`; }
|
|
7265
7586
|
remove.addEventListener('click', () => {
|
|
7266
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)`;
|
|
7267
7588
|
sure.addEventListener('click', async () => {
|
|
@@ -7305,9 +7626,57 @@
|
|
|
7305
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; }
|
|
7306
7627
|
/* The key offered in "New repository": the one chosen stays chosen. */
|
|
7307
7628
|
function fillKeyChoice(chosen = $('git-key').value) {
|
|
7308
|
-
|
|
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);
|
|
7309
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 ?? '';
|
|
7310
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
|
+
});
|
|
7311
7680
|
function showChosenKey() {
|
|
7312
7681
|
const key = gitKeys.find((k) => k.name === $('git-key').value);
|
|
7313
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; }
|
|
@@ -3338,3 +3340,80 @@ span.tile-spark { display: block; height: 22px; }
|
|
|
3338
3340
|
.desk-pick-row > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3339
3341
|
.desk-pick-row small { margin-left: auto; color: var(--ink2); }
|
|
3340
3342
|
.desk-plus { width: 30px; text-align: center; color: var(--brass-ink); font-size: 1.25rem; }
|
|
3343
|
+
|
|
3344
|
+
/* A MACHINE'S SHARED CONSOLE (16-11, app.js consoleParts): big -- most of the panel's height --, the same terminal as a
|
|
3345
|
+
conversation's; who has it above, the state in words under it, its keys bar on a touch screen, its tools; under it the
|
|
3346
|
+
AI's proposals, its inputs, the journal. Full screen: the console large, the conversation's chat beside it (under it on
|
|
3347
|
+
a phone). Colours never alone: each state is said in words too. */
|
|
3348
|
+
.as-console-part .sc { display: flex; flex-direction: column; }
|
|
3349
|
+
.sc-main { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0f141a; transition: box-shadow .2s, border-color .2s; }
|
|
3350
|
+
.sc.ai-typing .sc-main { border-color: var(--wait); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wait) 35%, transparent); }
|
|
3351
|
+
.sc.hidden-input .sc-main { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 30%, transparent); }
|
|
3352
|
+
.sc-presence { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 7px 10px; background: var(--bar); border-bottom: 1px solid var(--line); }
|
|
3353
|
+
.sc-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; padding: 2px 10px 2px 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
|
|
3354
|
+
.sc-chip small { color: var(--ink2); }
|
|
3355
|
+
.sc-chip .sc-av { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .6875rem; font-weight: 700; }
|
|
3356
|
+
.sc-chip.me .sc-av { background: var(--brass); color: var(--on-brass); }
|
|
3357
|
+
.sc-chip.ai .sc-av { background: var(--wait); color: #fff; }
|
|
3358
|
+
.sc-chip.me.active { border-color: var(--brass); }
|
|
3359
|
+
.sc-chip.ai.active { border-color: var(--wait); box-shadow: 0 0 0 2px color-mix(in srgb, var(--wait) 25%, transparent); }
|
|
3360
|
+
.sc-space { flex: 1; }
|
|
3361
|
+
.sc-live { font-size: .75rem; color: var(--ink2); white-space: nowrap; }
|
|
3362
|
+
.sc-live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--warn); }
|
|
3363
|
+
.sc-live.on { color: var(--ok); }
|
|
3364
|
+
.sc-live.on::before { background: var(--ok); }
|
|
3365
|
+
.sc-screen { height: max(340px, calc(100dvh - 330px)); padding: 6px 8px; background: #0f141a; min-width: 0; }
|
|
3366
|
+
.sc-screen .xterm { height: 100%; }
|
|
3367
|
+
.sc-state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 10px; font-size: .8125rem; background: var(--bar); color: var(--ink); border-top: 1px solid var(--line); }
|
|
3368
|
+
.sc-state[data-tone="ai"] { background: color-mix(in srgb, var(--wait) 16%, var(--panel)); border-top-color: var(--wait); }
|
|
3369
|
+
.sc-state[data-tone="secret"] { background: color-mix(in srgb, var(--ok) 14%, var(--panel)); border-top-color: var(--ok); }
|
|
3370
|
+
.sc-state[data-tone="pause"] { background: color-mix(in srgb, var(--warn) 14%, var(--panel)); border-top-color: var(--warn); }
|
|
3371
|
+
.sc-state[data-tone="bad"] { color: var(--danger); }
|
|
3372
|
+
.sc-keys { display: none; gap: 4px; padding: 5px; background: var(--bar); border-top: 1px solid var(--line); overflow-x: auto; }
|
|
3373
|
+
.sc-keys button { min-height: 38px; min-width: 44px; padding: 2px 8px; font: 600 .8125rem var(--mono, ui-monospace, Menlo, Consolas, monospace); flex: 0 0 auto; }
|
|
3374
|
+
.sc-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 7px 10px; background: var(--panel); border-top: 1px solid var(--line); }
|
|
3375
|
+
.sc-tools button[aria-pressed="true"] { border-color: var(--brass); color: var(--brass-ink); background: color-mix(in srgb, var(--brass) 12%, transparent); }
|
|
3376
|
+
.sc-tools .sc-take { font-size: .875rem; }
|
|
3377
|
+
/* Under the console: what the AI proposes, what it typed, the journal. */
|
|
3378
|
+
.sc-ai { display: flex; flex-direction: column; gap: 10px; }
|
|
3379
|
+
.sc-ask { border: 1px solid var(--wait); border-radius: 10px; padding: 10px 12px; background: var(--panel); box-shadow: 0 0 0 2px color-mix(in srgb, var(--wait) 20%, transparent); display: flex; flex-direction: column; gap: 6px; }
|
|
3380
|
+
.sc-ask.risky { border-color: var(--danger); box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 22%, transparent); }
|
|
3381
|
+
.sc-ask-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8125rem; }
|
|
3382
|
+
.sc-ai-tag { font-size: .6875rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--wait); color: var(--wait); }
|
|
3383
|
+
.sc-risk { font-size: .6875rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--danger); color: var(--danger); white-space: nowrap; }
|
|
3384
|
+
.sc-why { margin: 0; font-size: .875rem; }
|
|
3385
|
+
.sc-cmd { display: block; font: .8125rem/1.45 ui-monospace, Menlo, Consolas, monospace; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; white-space: pre-wrap; word-break: break-all; }
|
|
3386
|
+
.sc-risk-say { margin: 0; font-size: .8125rem; color: var(--danger); }
|
|
3387
|
+
.sc-ask-acts { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
3388
|
+
.sc-edit { display: flex; flex-direction: column; gap: 6px; }
|
|
3389
|
+
.sc-edit textarea { font: .8125rem ui-monospace, Menlo, Consolas, monospace; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; resize: vertical; }
|
|
3390
|
+
.sc-typed h4 { margin: 0 0 4px; font-size: .75rem; color: var(--ink2); letter-spacing: .05em; text-transform: uppercase; }
|
|
3391
|
+
.sc-typed-row, .sc-j-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: .8125rem; padding: 2px 0; }
|
|
3392
|
+
.sc-typed-row small, .sc-j-at { color: var(--ink2); font-variant-numeric: tabular-nums; }
|
|
3393
|
+
.sc-typed-row code, .sc-j-row code { font: .8125rem ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
|
|
3394
|
+
.sc-j-mark { font-size: .75rem; color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
|
|
3395
|
+
.sc-journal { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
|
|
3396
|
+
/* Full screen: over the page, the console large, the chat beside it. */
|
|
3397
|
+
.sc.sc-full { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 30%); gap: 10px; padding: 10px; background: var(--bg); }
|
|
3398
|
+
.sc.sc-full .sc-main { min-height: 0; }
|
|
3399
|
+
.sc.sc-full .sc-screen { height: auto; flex: 1; min-height: 0; }
|
|
3400
|
+
.sc-chat { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
|
|
3401
|
+
.sc-chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--bar); font-size: .875rem; }
|
|
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; }
|
|
3403
|
+
.sc-chat-thread { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
|
|
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; }
|
|
3407
|
+
:root[data-sc-full] body { overflow: hidden; }
|
|
3408
|
+
@media (max-width: 760px), (pointer: coarse) {
|
|
3409
|
+
.sc-keys { display: flex; }
|
|
3410
|
+
}
|
|
3411
|
+
@media (max-width: 760px) {
|
|
3412
|
+
.sc-screen { height: max(280px, calc(100dvh - 300px)); padding: 4px; }
|
|
3413
|
+
.sc-tools .sc-ctrlc { display: none; }
|
|
3414
|
+
.sc-tools .sc-take { flex: 1 1 100%; min-height: 42px; }
|
|
3415
|
+
.sc.sc-full { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 58fr) minmax(0, 42fr); padding: 6px; gap: 6px; }
|
|
3416
|
+
}
|
|
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; }
|