clavarium 0.2.511-next.1 → 0.2.513-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.
@@ -12,8 +12,9 @@
12
12
  * keys:PATTERN=K a question with one answer always: the keys K typed (Enter, Down, Up, Escape, 1, y...),
13
13
  * once per screen. Only what its launcher wrote: nothing else is ever typed.
14
14
  * type:PATTERN=TEXT the same with a few words (a command such as /login), then Enter; once per screen.
15
- * code:PATTERN the tool waits for a code the person gets after signing in: the next message they write
16
- * in the chat that looks like one (no space, 10 to 300 signs) is typed there, then Enter.
15
+ * code:PATTERN the tool waits for a code the person gets after signing in. Nothing here acts on it: the
16
+ * server reads the same rule, offers a field in the chat and types what is pasted there (#405).
17
+ * A chat message is never typed as a code.
17
18
  * Only the last LINES lines are read: what the tool prints of its own work above never counts.
18
19
  *
19
20
  * THE RULES FROM THE TOOLS' CONFIGURATION (15-11, #362): `--tool ID` reads the rules of that tool from
@@ -31,7 +32,7 @@
31
32
  */
32
33
  import { spawnSync } from 'node:child_process';
33
34
  import { randomUUID } from 'node:crypto';
34
- import { existsSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
35
+ import { existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
35
36
  import { dirname, join } from 'node:path';
36
37
  import { fileURLToPath } from 'node:url';
37
38
 
@@ -47,7 +48,7 @@ export function rulesOf(args) {
47
48
  try { return [{ kind: m[1], re: new RegExp(pattern, 'i'), value }]; } catch { return []; }
48
49
  });
49
50
  }
50
- /* What the person pastes, or the companion gives back, that may be typed as a code: no space, 10 to 300 signs. */
51
+ /* What the person pastes in the sign-in field, or the companion gives back, that may be typed as a code: no space, 10 to 300 signs. */
51
52
  export const CODE = /^[A-Za-z0-9_#.~+/=-]{10,300}$/;
52
53
  export const RULES_FILE = 'screen-rules.json';
53
54
  const SIGNIN_KINDS = new Set(['link', 'keys', 'type', 'code']);
@@ -85,27 +86,22 @@ export function actionsOn(screen, rules, seen) {
85
86
  }
86
87
 
87
88
  /* Where a sign-in link goes, step by step (15-11, #362): what to do, as a list of effects the caller runs --
88
- { do: 'ask', ask } (write signin-ask.json), 'tell-link' { a } (the link in the person's chat), 'arm' (the next
89
- code the person pastes is typed), 'tell-paste' (say so). `route()`: signin-route.json as read, or null. */
89
+ { do: 'ask', ask } (write signin-ask.json), 'tell-link' { a } (the link in the person's chat). `field: true` in
90
+ the ask: this watcher reads no code from the chat (#405; an older one does, see SigninHelp.oldWatcherArmed).
91
+ `route()`: signin-route.json as read, or null. */
90
92
  export const HAND_MS = 20_000;
91
93
  export class Relay {
92
94
  #ask = null; #now; #id; #route; #chat;
93
95
  constructor({ route = () => null, chat = () => true, now = () => Date.now(), id = () => randomUUID() } = {}) { this.#route = route; this.#chat = chat; this.#now = now; this.#id = id; }
94
96
  /* Told to the person: the ask says so too (`told`), so that a server that reads it late hands it to nobody. */
95
- #person() { const a = this.#ask; a.route = 'person'; return [{ do: 'ask', ask: { ...a.file, told: true } }, { do: 'tell-link', a: a.a }, ...(a.codeSeen ? [{ do: 'arm' }, { do: 'tell-paste' }] : [])]; }
97
+ #person() { const a = this.#ask; a.route = 'person'; return [{ do: 'ask', ask: { ...a.file, told: true } }, { do: 'tell-link', a: a.a }]; }
96
98
  link(a) {
97
99
  /* No chat folder: nowhere to hand it over, nobody but the person (and the chat is off anyway). */
98
100
  if (!this.#chat()) return [{ do: 'tell-link', a }];
99
101
  const id = this.#id(); const at = this.#now();
100
- this.#ask = { id, at, a, route: null, codeSeen: false, file: { id, at: new Date(at).toISOString(), link: a.match, around: a.around ?? '' } };
102
+ this.#ask = { id, at, a, route: null, file: { id, at: new Date(at).toISOString(), link: a.match, around: a.around ?? '', field: true } };
101
103
  return [{ do: 'ask', ask: this.#ask.file }];
102
104
  }
103
- code() {
104
- const a = this.#ask;
105
- if (!a || a.route === 'person') return [{ do: 'arm' }, { do: 'tell-paste' }];
106
- /* Handed over, or not known yet: the person is not asked to paste, unless it comes back to them. */
107
- a.codeSeen = true; return [];
108
- }
109
105
  step() {
110
106
  const a = this.#ask; if (!a || a.route === 'person') return [];
111
107
  const r = this.#route(); const mine = r && r.id === a.id ? r.route : null;
@@ -125,25 +121,6 @@ if (main) {
125
121
  const pane = process.env.SCREEN_WATCH_PANE ?? '=main:';
126
122
  const chat = process.env.PARLEY_DIR ?? '/work/.parley';
127
123
  const seen = new Set();
128
- /* Waiting for a code: the person's chat, from where it stood when the tool asked (to-agent.jsonl). */
129
- let awaiting = null;
130
- const inbox = `${chat}/to-agent.jsonl`;
131
- const codeFrom = () => { try { return statSync(inbox).size; } catch { return 0; } };
132
- const typeCode = () => {
133
- if (awaiting === null) return;
134
- let text = ''; try { const b = readFileSync(inbox); text = b.subarray(awaiting).toString('utf8'); } catch { return; }
135
- for (const line of text.split('\n').filter(Boolean)) {
136
- let m; try { m = JSON.parse(line); } catch { continue; }
137
- const code = String(m?.text ?? '').trim();
138
- if (CODE.test(code)) {
139
- spawnSync('tmux', [...tmux, 'send-keys', '-t', pane, '-l', '--', code], { timeout: 5000 });
140
- spawnSync('tmux', [...tmux, 'send-keys', '-t', pane, 'Enter'], { timeout: 5000 });
141
- /* Typed: the ask is over, so the next message that looks like a code is a secret again (#394). */
142
- try { rmSync(`${chat}/signin-ask.json`, { force: true }); } catch { /* left: it runs out on the server's side */ }
143
- awaiting = null; return;
144
- }
145
- }
146
- };
147
124
  /* The sign-in link's way (Relay): asked in the chat folder, routed by the server. */
148
125
  const readRoute = () => { try { return JSON.parse(readFileSync(`${chat}/signin-route.json`, 'utf8')); } catch { return null; } };
149
126
  const relay = new Relay({ route: readRoute, chat: () => existsSync(chat) });
@@ -151,12 +128,9 @@ if (main) {
151
128
  for (const e of effects) {
152
129
  if (e.do === 'ask') { try { writeFileSync(`${chat}/.signin-ask.json.new`, JSON.stringify(e.ask)); renameSync(`${chat}/.signin-ask.json.new`, `${chat}/signin-ask.json`); } catch { /* not written: no answer comes, told to the person after HAND_MS */ } }
153
130
  if (e.do === 'tell-link') spawnSync('parley', ['tell', `Your tool asks you to open this link: ${e.a.match}${e.a.around && e.a.around !== e.a.match ? `\n\n\`\`\`\n${e.a.around}\n\`\`\`` : ''}`, '--dir', chat], { timeout: 10_000 });
154
- if (e.do === 'arm') awaiting = codeFrom();
155
- if (e.do === 'tell-paste') spawnSync('parley', ['tell', 'Once signed in, paste here the code the page gives you.', '--dir', chat], { timeout: 10_000 });
156
131
  }
157
132
  };
158
133
  const look = () => {
159
- typeCode();
160
134
  run(relay.step());
161
135
  const r = spawnSync('tmux', [...tmux, 'capture-pane', '-p', '-t', pane], { encoding: 'utf8', timeout: 5000 });
162
136
  if (r.status !== 0) return;
@@ -165,7 +139,6 @@ if (main) {
165
139
  if (a.kind === 'notice') spawnSync('docket', ['remind', '--in', '1m', a.value, '--dir', process.env.DOCKET_DIR ?? '/work/.docket'], { timeout: 10_000 });
166
140
  if (a.kind === 'keys') for (const k of a.value) spawnSync('tmux', [...tmux, 'send-keys', '-t', pane, k], { timeout: 5000 });
167
141
  if (a.kind === 'type') { spawnSync('tmux', [...tmux, 'send-keys', '-t', pane, '-l', '--', a.value], { timeout: 5000 }); spawnSync('tmux', [...tmux, 'send-keys', '-t', pane, 'Enter'], { timeout: 5000 }); }
168
- if (a.kind === 'code') run(relay.code());
169
142
  }
170
143
  };
171
144
  /* Its life is the tool's: started just before the launcher becomes the tool (exec), it ends with it. */
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.511-next.1",
3
+ "version": "0.2.513-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.511-next.1",
9
+ "version": "0.2.513-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.511-next.1",
3
+ "version": "0.2.513-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.",
package/server/api.mjs CHANGED
@@ -32,6 +32,7 @@
32
32
  * POST /api/signin-companion {companion}: the conversation that signs the others' tools in with its browser ('' none; 15-11); {clicks}: it clicks Authorize itself
33
33
  * POST /api/conversations/<name>/signin-companion {companion}: its own (a conversation, "none"), or null for the general one; never itself
34
34
  * POST /api/conversations/<name>/signin-link its sign-in handed to a companion: shown to the person instead
35
+ * POST /api/conversations/<name>/signin-code {code}: typed into its tool at its code prompt; kept nowhere (#405)
35
36
  * POST /api/conversations/<name>/ask-first {on}: its tool asks before acting (true), or acts without asking in its machine (false, the default), from its next start
36
37
  * POST /api/conversations/<name>/resume {on}: its tool takes up its last session when it starts (true), or starts fresh
37
38
  * POST /api/conversations/<name>/terminal/repair its terminal does not come though its machine runs: repaired
@@ -590,6 +591,9 @@ export async function handleApi(request, response, conversations, headers, resou
590
591
  return send(403, { error: 'This request does not come from this site.' }), true;
591
592
  }
592
593
  const body = await readBody(request, pathname === '/api/setup/preview' || pathname === '/api/setup/import' ? SETUP_BODY_MAX : BODY_MAX);
594
+ /* A SIGN-IN CODE (#405): answered before anything below can see this body (the journal, say). */
595
+ const codeOf = /^\/api\/conversations\/([^/]+)\/signin-code$/.exec(pathname);
596
+ if (codeOf && conversations.signinHelp) return send(200, await conversations.signinHelp.enterCode(decodeURIComponent(codeOf[1]), body?.code)), true;
593
597
  /* What was done, once it was done: said in What happened (events.mjs), for those worth saying. */
594
598
  if (events) { const answer = send; send = (status, out) => { if (status < 300) { try { events.fromRequest(pathname, body, identity, out); } catch { /* never in the way */ } } answer(status, out); }; }
595
599
  if (rooms && pathname.startsWith('/api/rooms')) {
package/server/door.mjs CHANGED
@@ -27,6 +27,7 @@
27
27
  * POST /c/api/<pairing>/conversations/<any>/talk/react {to, reaction}: a reaction to a message of the tool (null: taken back)
28
28
  * POST /c/api/<pairing>/conversations/<any>/talk/file?name= a file attached to a message
29
29
  * POST /c/api/<pairing>/terminal/repair its terminal does not come (see conversations.mjs)
30
+ * POST /c/api/<pairing>/conversations/<any>/signin-code?c=<any> {code}: only a device given its terminal, which could type it there (#405)
30
31
  * the chat of its conversation, where it talks through the app (see
31
32
  * talk.mjs): read, written to, reminded. Turning it on and inviting
32
33
  * the tool stay the owner's.
@@ -86,7 +87,7 @@ export function devicePairing(devices, headers, pairing) {
86
87
  }
87
88
 
88
89
  /* Returns true when the request was under /c/api/ (answered here). */
89
- export async function handleDoor(request, response, { devices, conversations, resources, shortcuts, voice, originOk, headers, secure, talk, repair, tethers, mailboxes }) {
90
+ export async function handleDoor(request, response, { devices, conversations, resources, shortcuts, voice, originOk, headers, secure, talk, repair, tethers, mailboxes, signinCode }) {
90
91
  const url = new URL(request.url ?? '/', 'http://local');
91
92
  if (!url.pathname.startsWith('/c/api/')) return false;
92
93
  /* "/<pairing>/me" -> the pairing and "/me"; "/pair" has no pairing yet. */
@@ -190,6 +191,13 @@ export async function handleDoor(request, response, { devices, conversations, re
190
191
  }
191
192
  if (request.method === 'POST' && talking[1] === undefined) { const body = await readJson(request); return send(201, await talk.say(name, body.text, body.answers, body.files, body.via, { quick: body.quick === true })); }
192
193
  }
194
+ /* A sign-in code (#405): a device given its terminal could type it there; no other. Named twice, never guessed. */
195
+ const codeFor = /^\/conversations\/([^/]+)\/signin-code$/.exec(route);
196
+ if (request.method === 'POST' && codeFor && signinCode) {
197
+ need(part.terminal, 'the terminal');
198
+ if (decodeURIComponent(codeFor[1]) !== name) throw new Refusal(403, 'This device was not given the terminal of this conversation.');
199
+ return send(200, await signinCode(name, (await readJson(request)).code));
200
+ }
193
201
  /* Its terminal does not come: only a device given it asks for it to be repaired. */
194
202
  if (request.method === 'POST' && route === '/terminal/repair') { need(part.terminal, 'the terminal'); return send(200, await repair(name)); }
195
203
  /* The device takes itself out: this pairing is removed, here and on the server. */
package/server/main.mjs CHANGED
@@ -502,8 +502,10 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
502
502
  /* A wake-up typed is said in its chat (talk, made below: called only once a wake-up fires). */
503
503
  /* Where its chat is on, what wakes a tool is an event it acknowledges: see dockets.mjs. */
504
504
  let signinHelp = null;
505
+ const atCodePrompt = async (name) => { try { return (await signinHelp?.atCodePrompt(name, (argv, options) => vms.exec(name, argv, options))) === true; } catch { return false; } };
505
506
  const dockets = new Dockets({ store: new Store(`${dataDir}/dockets.json`), resources: folders,
506
- say: (name, line) => wakeups.say(name, line),
507
+ /* Not while its tool waits for a sign-in code: the line would go into that field; the docket tries again. */
508
+ say: async (name, line) => ((await atCodePrompt(name)) ? false : wakeups.say(name, line)),
507
509
  event: (name, line) => talk.event(name, line),
508
510
  alert: (message) => { void alerts.tell({ ...message, title: `${instance.name()}: ${message.title}` }); },
509
511
  /* Not in a turn: its pulse ended, or is old (Parley's own measure). */
@@ -579,7 +581,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
579
581
  /* A conversation with a tool on a screen that is not its terminal: see talk.mjs. */
580
582
  /* Voice boxes: what the tool says in their conversation is read aloud (boxes.mjs). */
581
583
  let boxes; let rooms; let machineList;
582
- const talk = new Talk({ spoke: (name, text, to, how) => { void boxes?.agentSaid(name, text, to, how); }, inRoom: (name, entry, kind) => rooms?.answered(name, entry, kind), store: talkStore, words: new Store(`${dataDir}/talk-words.json`), keptDir: `${dataDir}/talk-kept`, vms, conversations: all, resources: folders, toolbox, warm: (name) => bridge?.warm(name), ...(talkEveryMs ? { listenEveryMs: talkEveryMs } : {}),
584
+ const talk = new Talk({ holdLine: atCodePrompt, spoke: (name, text, to, how) => { void boxes?.agentSaid(name, text, to, how); }, inRoom: (name, entry, kind) => rooms?.answered(name, entry, kind), store: talkStore, words: new Store(`${dataDir}/talk-words.json`), keptDir: `${dataDir}/talk-kept`, vms, conversations: all, resources: folders, toolbox, warm: (name) => bridge?.warm(name), ...(talkEveryMs ? { listenEveryMs: talkEveryMs } : {}),
583
585
  ...(rereadAfterMs === undefined ? {} : { rereadAfterMs }),
584
586
  /* A line typed down the terminal already open when there is one, and
585
587
  what is already known of a machine used instead of asking (talk.mjs). */
@@ -592,15 +594,17 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
592
594
  the chat shows as stars; the value reaches the machine as
593
595
  /run/secrets/<name>, and is swept after a few minutes. */
594
596
  screen: async (conversation, text) => {
595
- /* A sign-in code its tool waits for (#394): left whole, screen-watch types it in. */
596
- if (signinHelp?.awaitsCode(conversation, text)) return text;
597
- const hits = scan(text);
597
+ /* A chat message is never a sign-in code (#405). A tool still run by an older screen-watch would type this
598
+ one: lifted whole, so that only a marker reaches its inbox. */
599
+ const armed = signinHelp?.oldWatcherArmed(conversation, text) === true;
600
+ const whole = String(text).trim();
601
+ const hits = armed ? [{ start: text.indexOf(whole), end: text.indexOf(whole) + whole.length, value: whole }] : scan(text);
598
602
  if (!hits.length) return text;
599
603
  let out = ''; let last = 0; let any = false;
600
604
  for (const h of hits) {
601
605
  out += text.slice(last, h.start);
602
606
  try { const { name, expiresAt } = secrets.stash(conversation, h.value); out += secretRef(name, Date.parse(expiresAt)); any = true; }
603
- catch { out += text.slice(h.start, h.end); } /* cannot be stashed (too large): left as it is */
607
+ catch { out += armed ? '(not kept)' : text.slice(h.start, h.end); } /* cannot be stashed (too large): left as it is, but never for an older screen-watch to type */
604
608
  last = h.end;
605
609
  }
606
610
  out += text.slice(last);
@@ -644,9 +648,11 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
644
648
  workFolder: (name) => folders.workFolder(name),
645
649
  browsers: (name) => { try { return tethers.store().targets().filter((t) => t.kind === 'browser').map((t) => ({ id: t.id, level: t.grants?.[`conversation:${name}`]?.level ?? '' })).filter((b) => b.level); } catch { return []; } },
646
650
  post: (name, event) => dockets.post(name, event), type: (name, text) => typeInto(vms, name, text),
651
+ exec: (name, argv, options) => vms.exec(name, argv, options),
647
652
  event: (name, line) => talk.event(name, line) });
648
653
  const stopSigninHelp = signinHelp.start();
649
654
  all.signinHelp = signinHelp;
655
+ door.signinCode = (name, code) => signinHelp.enterCode(name, code);
650
656
  /* A device given a conversation that talks through the app talks there too. */
651
657
  door.talk = talk;
652
658
  /* A mail cited by its reference, opened on a device that may read its mailbox (mailref.mjs). */
@@ -11,6 +11,11 @@ export const SETTINGS_WORDS_FR = {
11
11
  'set-ch-s-words': 'Écran du chat', 'set-ch-s-dictation': 'Dictée', 'set-ch-s-shortcuts': 'Raccourcis', 'set-ch-s-thread': 'Événements du chat',
12
12
  'set-ch-s-updates': 'Mises à jour', 'set-ch-s-binders': 'Classeurs', 'set-ch-s-events': 'Activité', 'set-ch-s-jobs': 'Tâches', 'set-ch-s-logs': 'Journaux',
13
13
  'set-ch-s-usage': 'Usage', 'set-ch-s-backup': 'Sauvegarde', 'set-ch-s-advanced': 'Avancé',
14
+ /* The sign-in of a tool: its code pasted in a field, kept nowhere; the companion, its user's choice (#405). */
15
+ 'set-signin-code-line': 'Une fois connecté, collez le code.', 'set-signin-code-sent': 'Code envoyé à l\'outil.', 'set-signin-code-act': 'Coller le code',
16
+ 'set-signin-code-title': 'Code de connexion', 'set-signin-code-send': 'Envoyer', 'set-signin-code-bad': 'Ce n\'est pas un code.',
17
+ 'set-signin-code-late': 'L\'outil n\'attend plus de code.', 'set-signin-code-failed': 'Non envoyé. Réessayez.',
18
+ 'set-companion-yours': 'Votre choix, votre responsabilité',
14
19
  /* Chat › when its thread is archived (talk.mjs setSplit). */
15
20
  'set-chat-split': 'Archiver son fil', 'set-split-2000': 'Tous les 2 000 messages', 'set-split-5000': 'Tous les 5 000',
16
21
  'set-split-week': 'Chaque semaine', 'set-split-day': 'Chaque jour', 'set-split-never': 'Jamais',
@@ -16,7 +16,7 @@
16
16
  * WHAT HAPPENS. The link is written in the companion's docket folder (a file of its work folder, nowhere
17
17
  * else), and an event of kind KIND is posted to its docket: open it in its browser, let the person click
18
18
  * Authorize, read the code the page shows, give it back as the note of `docket done`. That note is typed
19
- * here into the asking tool, once, as screen-watch types a code the person pastes. The asking chat says
19
+ * here into the asking tool, once. The asking chat says
20
20
  * one line ("Signing in through « B »...") with a button that shows the link to the person instead.
21
21
  * No answer in WAIT_MS, a failure, or no code: the link goes to the person, as before.
22
22
  *
@@ -26,6 +26,11 @@
26
26
  * The link must be HTTPS and lead to a domain the tool declares ("signin.links"): an agent that writes a
27
27
  * forged ask in its own chat folder can have the companion open nothing else -- and the person still
28
28
  * sees the page and decides to click. No link is made here, none is reachable without signing in.
29
+ *
30
+ * THE PERSON'S OWN CODE (22-11, #405). Told the link, the person gets a line in the chat with a button that opens
31
+ * a small field. What is pasted there comes to enterCode: checked, typed into the tool once, and kept nowhere (not
32
+ * the thread, the inbox, a log, an event). A chat message is never typed as a code: the secret scan treats it as any
33
+ * other message.
29
34
  */
30
35
  import { lstatSync, readFileSync, writeFileSync, renameSync, rmSync } from 'node:fs';
31
36
  import { join } from 'node:path';
@@ -40,9 +45,14 @@ export const ROUTE = 'signin-route.json';
40
45
  export const CHAT = '.parley';
41
46
  export const DOCKET = '.docket';
42
47
  export const WAIT_MS = 10 * 60_000;
43
- /* How long after its tool asked a code pasted by the person is taken as that code (and not as a secret). */
48
+ /* How long after its tool asked its code field stays open. */
44
49
  export const CODE_WAIT_MS = 30 * 60_000;
45
50
  export const TICK_MS = 3000;
51
+ /* How often the screen of a tool told its link is read, until it shows its code prompt. */
52
+ export const OFFER_EVERY_MS = 6000;
53
+ const SCREEN_LINES = 12;
54
+ export const CODE_LINE = 'Once signed in, paste the code.';
55
+ export const CODE_SENT = 'Code sent to the tool.';
46
56
  export const NONE = 'none';
47
57
  const ASK_BYTES = 16_384;
48
58
  const LINK_MAX = 4000;
@@ -60,7 +70,7 @@ export function linkAllowed(link, domains = []) {
60
70
  }
61
71
  const cut = (s, n) => { const t = String(s ?? '').replace(/\s+/g, ' ').trim(); return t.length > n ? `${t.slice(0, n - 1)}…` : t; };
62
72
 
63
- /* The code typed into the tool, then Enter -- as screen-watch types a code the person pastes. Never logged. */
73
+ /* The code typed into the tool, then Enter. Never logged. */
64
74
  export async function typeInto(vms, name, text) {
65
75
  const tmux = ['tmux', '-L', SOCKET, 'send-keys', '-t', `=${SESSION}:`];
66
76
  if ((await vms.exec(name, [...tmux, '-l', '--', text], { timeoutMs: 30_000 })).code !== 0) return false;
@@ -68,18 +78,24 @@ export async function typeInto(vms, name, text) {
68
78
  }
69
79
 
70
80
  export class SigninHelp {
71
- #store; #conversations; #tools; #awake; #chatOn; #work; #browsers; #post; #type; #event; #now;
81
+ #store; #conversations; #tools; #awake; #chatOn; #work; #browsers; #post; #type; #event; #now; #exec;
72
82
  /* asker -> { id (its ask), companion, event (the docket event's id), at, file, code (a code is awaited) } */
73
83
  #open = new Map();
74
84
  /* asker -> the id of the last ask looked at: each is routed once. */
75
85
  #seen = new Map();
76
86
  #busy = false;
87
+ /* asker -> the ask whose field was offered in its chat; when its screen was last read for that; a code being typed. */
88
+ #offered = new Map();
89
+ #looked = new Map();
90
+ #typing = new Set();
77
91
 
78
92
  /* `store`: { get(), set(v) } of { general, per: { name: companion | NONE } }. `conversations()`: [{ name, tool }].
79
93
  `tools()`: config/tools.json as read. `awake()`, `chatOn(name)`. `workFolder(name)`. `browsers(name)`: the
80
94
  browser targets it was given, [{ id, level }]. `post(name, {kind, text, data})`: its docket. `type(name, text)`:
81
- typed into its tool, then Enter (resolves true when typed). `event(name, line)`: a line in its chat. */
82
- constructor({ store, conversations, tools, awake, chatOn, workFolder, browsers, post, type, event = () => {}, now = () => Date.now() }) {
95
+ typed into its tool, then Enter (resolves true when typed). `event(name, line)`: a line in its chat.
96
+ `exec(name, argv, options)`: a command in its machine (to read its tool's screen). */
97
+ constructor({ store, conversations, tools, awake, chatOn, workFolder, browsers, post, type, event = () => {}, now = () => Date.now(), exec = null }) {
98
+ this.#exec = exec;
83
99
  this.#store = store; this.#conversations = conversations; this.#tools = tools; this.#awake = awake; this.#chatOn = chatOn;
84
100
  this.#work = workFolder; this.#browsers = browsers; this.#post = post; this.#type = type; this.#event = event; this.#now = now;
85
101
  }
@@ -145,17 +161,71 @@ export class SigninHelp {
145
161
  if (!this.#own(dir)) return;
146
162
  try { writeFileSync(join(dir, `.${ROUTE}.new`), JSON.stringify(route)); renameSync(join(dir, `.${ROUTE}.new`), join(dir, ROUTE)); } catch { /* its chat folder cannot be written: screen-watch tells the person itself */ }
147
163
  }
148
- /* A CODE AWAITED FROM THE PERSON (20-11, #394): its tool asked to sign in, the link was told to the person (not
149
- handed to a companion), a short while ago. Then a message that is nothing but a code is that code: typed into
150
- the tool by screen-watch, never lifted out as a secret (19-11: « code#state » kept as two secrets, the tool
151
- never got it). */
152
- awaitsCode(name, text) {
164
+ /* The ask is the person's to answer: told the link, or routed to them, a short while ago. */
165
+ #personsAsk(name) {
166
+ const ask = this.#readAsk(name); if (!ask) return null;
167
+ const at = Date.parse(ask.at); if (!Number.isFinite(at) || this.#now() - at > CODE_WAIT_MS || at > this.#now() + 60_000) return null;
168
+ if (this.#open.has(name)) return null;
169
+ if (ask.told === true) return ask;
170
+ const route = this.#readRoute(name);
171
+ return route?.id === ask.id && route.route === 'person' ? ask : null;
172
+ }
173
+ /* DURING AN UPDATE: a tool started before #405 keeps its old screen-watch until it restarts (the launcher is read at
174
+ its start), and that one types the next code-like message of the chat. Its ask has no `field`. Such a message is
175
+ then lifted whole as a secret: what reaches the inbox is a marker, which it cannot take for a code. */
176
+ oldWatcherArmed(name, text) {
153
177
  if (!CODE.test(String(text ?? '').trim())) return false;
178
+ const ask = this.#personsAsk(name);
179
+ return ask !== null && ask.field !== true;
180
+ }
181
+ /* THE CODE PASTED IN ITS FIELD (#405). Typed once, only while its tool shows its prompt; the value is in no answer,
182
+ no error, no log, no file. */
183
+ async enterCode(name, value) {
184
+ if (!this.#exists(name)) throw new Refusal(404, 'No such conversation.');
185
+ const code = typeof value === 'string' ? value.trim() : '';
186
+ if (!CODE.test(code)) throw new Refusal(400, 'This is not a sign-in code.');
187
+ const ask = this.#personsAsk(name);
188
+ if (!ask) throw new Refusal(409, 'No sign-in is waiting for a code here.');
189
+ if (this.#typing.has(name)) throw new Refusal(409, 'A code is already being sent.');
190
+ this.#typing.add(name);
191
+ try {
192
+ const exec = (argv, options) => this.#exec(name, argv, options);
193
+ const at = this.#exec ? await this.atCodePrompt(name, exec).catch(() => false) : false;
194
+ if (!at) throw new Refusal(409, 'Its tool is not waiting for a code now.');
195
+ const typed = await Promise.resolve(this.#type(name, code)).catch(() => false);
196
+ if (!typed) throw new Refusal(502, 'The code could not be typed into the tool.');
197
+ /* Typed: the ask is over, whatever comes next is not this code. */
198
+ const dir = this.#chat(name);
199
+ if (this.#own(dir)) { try { rmSync(join(dir, ASK), { force: true }); } catch { /* it runs out by itself */ } }
200
+ this.#route(name, { id: ask.id, route: 'done' });
201
+ this.#offered.delete(name); this.#looked.delete(name);
202
+ this.#line(name, { kind: KIND, text: CODE_SENT, topic: 'Sign-in', brief: 'Code sent' });
203
+ return { ok: true };
204
+ } finally { this.#typing.delete(name); }
205
+ }
206
+ /* Its tool shows its prompt, its link told: one line in its chat, with the button that opens the field. */
207
+ async #offerCode(name, ask) {
208
+ if (ask.told !== true || !this.#exec || this.#offered.get(name) === ask.id || this.#open.has(name)) return;
209
+ if (this.#now() - (this.#looked.get(name) ?? -Infinity) < OFFER_EVERY_MS) return;
210
+ this.#looked.set(name, this.#now());
211
+ const at = await this.atCodePrompt(name, (argv, options) => this.#exec(name, argv, options)).catch(() => false);
212
+ if (!at || this.#readAsk(name)?.id !== ask.id) return;
213
+ this.#offered.set(name, ask.id);
214
+ this.#line(name, { kind: KIND, text: CODE_LINE, level: 'needs-you', topic: 'Sign-in', brief: 'Paste the code', actions: ['signincode'] });
215
+ }
216
+ /* ITS TOOL IS AT ITS « PASTE THE CODE » PROMPT (22-11, seen on a real machine): a line typed now goes into that field
217
+ and the sign-in fails. Asked of its screen, only while a sign-in is open and its tool has such a prompt. */
218
+ async atCodePrompt(name, exec) {
154
219
  const ask = this.#readAsk(name); if (!ask) return false;
155
- const at = Date.parse(ask.at); if (!Number.isFinite(at) || this.#now() - at > CODE_WAIT_MS || at > this.#now() + 60_000) return false;
156
- if (ask.told === true) return true;
157
- const route = this.#readRoute(name);
158
- return route?.id === ask.id && route.route === 'person';
220
+ const at = Date.parse(ask.at); if (!Number.isFinite(at) || this.#now() - at > CODE_WAIT_MS) return false;
221
+ const rules = (this.#tool(name)?.signin?.screen ?? []).filter((r) => String(r).startsWith('code:')).map((r) => String(r).slice(5));
222
+ if (!rules.length) return false;
223
+ const r = await exec(['tmux', '-L', SOCKET, 'capture-pane', '-p', '-t', `=${SESSION}:`], { timeoutMs: 10_000 });
224
+ if (r.code !== 0) return false;
225
+ /* As screen-watch reads it: the bottom of the screen, whatever the case. A prompt left higher up is over, and a
226
+ code typed then would go to the AI as a message. */
227
+ const bottom = String(r.stdout).replace(/\s+$/u, '').split('\n').slice(-SCREEN_LINES).join('\n');
228
+ return rules.some((p) => { try { return new RegExp(p, 'i').test(bottom); } catch { return false; } });
159
229
  }
160
230
  #readRoute(name) { try { return JSON.parse(readFileSync(join(this.#chat(name), ROUTE), 'utf8')); } catch { return null; } }
161
231
  #line(name, line) { try { this.#event(name, line); } catch { /* its chat may be off */ } }
@@ -167,13 +237,15 @@ export class SigninHelp {
167
237
  this.#busy = true;
168
238
  try {
169
239
  for (const [name, o] of [...this.#open]) if (this.#now() - o.at > WAIT_MS) this.#toPerson(name, `« ${o.companion} » did not answer in ${Math.round(WAIT_MS / 60_000)} minutes: the sign-in link is shown to you.`);
240
+ const offers = [];
170
241
  for (const name of this.#awake()) {
171
242
  if (!this.#chatOn(name)) continue;
172
243
  const ask = this.#readAsk(name);
173
- if (!ask || this.#seen.get(name) === ask.id) continue;
174
- this.#seen.set(name, ask.id);
175
- this.#ask(name, ask);
244
+ if (!ask) continue;
245
+ if (this.#seen.get(name) !== ask.id) { this.#seen.set(name, ask.id); this.#ask(name, ask); }
246
+ offers.push(this.#offerCode(name, ask).catch(() => {}));
176
247
  }
248
+ await Promise.all(offers);
177
249
  } finally { this.#busy = false; }
178
250
  }
179
251
 
package/server/talk.mjs CHANGED
@@ -237,7 +237,7 @@ const PART = /^[A-Za-z0-9._~-]{1,200}$/;
237
237
  export class Talk {
238
238
  #store; #words; #vms; #conversations; #resources; #toolbox; #warm; #alert; #spoke; #inRoom; #listening = new Map(); #every; #now;
239
239
  #typedAt = new Map(); #nextTry = new Map(); #trying = new Map(); #ticking = new Map(); #timer; #lastLang = 'en'; #rereadAfter;
240
- #terminal; #health; #ranAt = new Map(); #kept; #screen; #dropSecret; #log;
240
+ #terminal; #health; #ranAt = new Map(); #kept; #screen; #dropSecret; #log; #holdLine;
241
241
 
242
242
  /* `alert({ title, body, url })`: told when the tool asks, or waits.
243
243
  `words`: a store for the owner's choice of words (one record). */
@@ -247,8 +247,8 @@ export class Talk {
247
247
  /* `keptDir`: where each conversation's thread is kept (its own folder),
248
248
  in this server's data -- never in the work folder, which its machine
249
249
  writes. Without it, the bridge folder is all there is. */
250
- constructor({ store, words, vms, conversations, resources, toolbox = null, warm = async () => {}, alert = () => {}, spoke = () => {}, inRoom = () => {}, listenEveryMs = 2000, now = () => Date.now(), rereadAfterMs = REREAD_AFTER_MS, terminal = null, health = null, keptDir = null, screen = null, dropSecret = null, log = (line) => console.log(line) }) {
251
- this.#log = log;
250
+ constructor({ store, words, vms, conversations, resources, toolbox = null, warm = async () => {}, alert = () => {}, spoke = () => {}, inRoom = () => {}, listenEveryMs = 2000, now = () => Date.now(), rereadAfterMs = REREAD_AFTER_MS, terminal = null, health = null, keptDir = null, screen = null, dropSecret = null, holdLine = null, log = (line) => console.log(line) }) {
251
+ this.#log = log; this.#holdLine = holdLine;
252
252
  this.#terminal = terminal; this.#health = health; this.#kept = keptDir; this.#screen = screen; this.#dropSecret = dropSecret;
253
253
  this.#store = store; this.#words = words; this.#vms = vms; this.#conversations = conversations; this.#resources = resources; this.#toolbox = toolbox; this.#warm = warm; this.#alert = alert; this.#spoke = spoke; this.#inRoom = inRoom; this.#every = listenEveryMs; this.#now = now; this.#rereadAfter = rereadAfterMs;
254
254
  for (const s of store.all()) if (s.on === true) this.#listen(s.name);
@@ -827,6 +827,8 @@ export class Talk {
827
827
  const quiet = this.#now() - (this.#typedAt.get(name) ?? 0);
828
828
  if (quiet < TYPING_QUIET_MS) return waits('typing', TYPING_QUIET_MS - quiet + 100);
829
829
  if (!(await this.#runs(name))) return waits('asleep', RETRY_MS);
830
+ /* At its sign-in code prompt: a line typed now would go into that field (signinhelp.mjs). It waits. */
831
+ if (await Promise.resolve(this.#holdLine?.(name)).catch(() => false)) return waits('signing-in', RETRY_MS);
830
832
  if (renudge) this.#log(`talk: ${name}: still unread ${Math.round((this.#now() - Date.parse(r.typedAt ?? '')) / 1000)} s after its line: typed again (${(r.renudged ?? 0) + 1})`);
831
833
  if (!(await this.#type(name, urgent ? URGENT : WAKE).catch((error) => { this.#log(`talk: ${name}: NOT typed: ${error?.message}`); return false; }))) return waits('failed', RETRY_MS);
832
834
  this.#store.put({ ...this.#store.get(name), pending: false, woke: true, why: null, again: false, renudge: false, typedAt: new Date(this.#now()).toISOString(), toldRead: this.#readCount(name), toldUnread: unread, renudged: renudge ? (r.renudged ?? 0) + 1 : 0 });
package/web/app.js CHANGED
@@ -3834,7 +3834,7 @@
3834
3834
  /* A message attached to a card (#180), from its menu: its id, as the card opens it again. */
3835
3835
  ...(!DEVICE ? { card: (m) => attachToCard({ kind: 'message', ref: m.id, title: String(m.short || m.text || '').replace(/\s+/g, ' ').trim().slice(0, 80) }) } : {}),
3836
3836
  /* The buttons of a line of the machine: what this screen may do. */
3837
- act: (id) => { if (id === 'seen-done') return; if (id.startsWith('salon:')) { void openSalon(id.slice('salon:'.length)); return; } if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id === 'signinlink') void signinLinkToMe(); else if (tetherAct(id, () => thread?.refresh?.())) return; else if (id.startsWith('flash:')) void flashFromThread(id.slice('flash:'.length)); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
3837
+ act: (id) => { if (id === 'seen-done') return; if (id.startsWith('salon:')) { void openSalon(id.slice('salon:'.length)); return; } if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id === 'signinlink') void signinLinkToMe(); else if (id === 'signincode') openSigninCode(); else if (tetherAct(id, () => thread?.refresh?.())) return; else if (id.startsWith('flash:')) void flashFromThread(id.slice('flash:'.length)); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
3838
3838
  /* What it opens over the thread (a picture, its media, a search...) is a step of this page's: one Back closes it. */
3839
3839
  back: { open: (name, close) => nav.over(`chat-${name}`, () => close(), { stack: true }), closed: (step) => { if (step) nav.drop(step); } },
3840
3840
  /* Files attached to a message: wherever the chat may be written in. */
@@ -3969,7 +3969,7 @@
3969
3969
  /* "commits:<repository>.<to>.<from>.<n>": those commits, in the review ("See the 3 commits"). A commit a
3970
3970
  line names (7 to 40 hexadecimal characters, a digit among them) is a link to its review, on a line about
3971
3971
  a repository; the agent's own messages are never read for this. */
3972
- const ACTIONS = { memory: 'More memory...', disk: 'Give it more disk...', room: 'See what takes room', restart: 'Restart...', terminal: 'See the terminal', review: 'Open the review', signinlink: 'Show me the link', seen: '\u2713 Seen', allow: 'Accept', deny: 'Refuse', flash: 'Plug it in and start' };
3972
+ const ACTIONS = { memory: 'More memory...', disk: 'Give it more disk...', room: 'See what takes room', restart: 'Restart...', terminal: 'See the terminal', review: 'Open the review', signinlink: 'Show me the link', signincode: 'Paste the code', seen: '\u2713 Seen', allow: 'Accept', deny: 'Refuse', flash: 'Plug it in and start' };
3973
3973
  const COMMITS = /^commits:([a-z0-9][a-z0-9-]*)\.([0-9a-f]{7,40})\.([0-9a-f]{7,40})\.(\d{1,4})$/;
3974
3974
  /* A Tether call an agent asked the owner to allow, offered right in the thread: allow:<id> / deny:<id>. */
3975
3975
  const DEMANDE = /^(allow|deny|always|flash):[0-9a-f-]{36}$/;
@@ -3983,11 +3983,12 @@
3983
3983
  if (many) void openGit(many[1], { commit: many[2], base: many[3], tab: Number(many[4]) > 1 ? 'commits' : 'changes' });
3984
3984
  else if (one) void openGit(one[1], { commit: one[2] });
3985
3985
  }
3986
+ const SIGNIN_SAID = { 'Once signed in, paste the code.': 'set-signin-code-line', 'Code sent to the tool.': 'set-signin-code-sent' };
3986
3987
  function machineLines(data) {
3987
3988
  if (!Array.isArray(data?.messages)) return data;
3988
3989
  const kindOf = (id) => String(id).split(':')[0];
3989
- const may = (id) => (id === 'terminal' || id === 'room' ? !noTerminal() : id === 'disk' ? !DEVICE && !narrow() : (id === 'memory' || id === 'restart' || id === 'seen' || id === 'seen-done' || id === 'signinlink' || DEMANDE.test(id) || /^review:[a-z0-9][a-z0-9._-]*$/.test(id) || COMMITS.test(id)) && !DEVICE);
3990
- const label = (id) => { const n = Number(COMMITS.exec(id)?.[4] ?? 0); return n ? (n === 1 ? 'See the commit' : `See the ${n} commits`) : ACTIONS[kindOf(id)]; };
3990
+ const may = (id) => (id === 'terminal' || id === 'room' || id === 'signincode' ? !noTerminal() : id === 'disk' ? !DEVICE && !narrow() : (id === 'memory' || id === 'restart' || id === 'seen' || id === 'seen-done' || id === 'signinlink' || DEMANDE.test(id) || /^review:[a-z0-9][a-z0-9._-]*$/.test(id) || COMMITS.test(id)) && !DEVICE);
3991
+ const label = (id) => { const n = Number(COMMITS.exec(id)?.[4] ?? 0); return n ? (n === 1 ? 'See the commit' : `See the ${n} commits`) : id === 'signincode' ? uiSaid('set-signin-code-act', ACTIONS.signincode) : ACTIONS[kindOf(id)]; };
3991
3992
  const linksOf = (m) => {
3992
3993
  const repo = DEVICE ? null : (m.actions ?? []).map((id) => /^review:([a-z0-9][a-z0-9-]*)$/.exec(id)?.[1]).find(Boolean);
3993
3994
  if (!repo) return [];
@@ -4016,9 +4017,9 @@
4016
4017
  if (!may(String(r.yes?.id ?? ''))) { const { yes: _y, no: _n, others: _o, ...shown } = r; return shown; }
4017
4018
  return r;
4018
4019
  };
4019
- const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(FIXED_GOES.has(id) && fixedAt && String(m.at ?? '') < fixedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1)))).filter((id) => !(id === 'signinlink' && String(m.at ?? '') < signinAt))
4020
+ const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(FIXED_GOES.has(id) && fixedAt && String(m.at ?? '') < fixedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1)))).filter((id) => !((id === 'signinlink' || id === 'signincode') && String(m.at ?? '') < signinAt))
4020
4021
  .map((id) => (id === 'seen' && seenAt && String(m.at ?? '') <= seenAt ? { id: 'seen-done', label: seenWords } : { id, label: label(id) }));
4021
- return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m), ...(m.request && typeof m.request === 'object' ? { request: requestOf(m) } : {}) } : m)) };
4022
+ return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, ...(m.event === 'signin-help' && SIGNIN_SAID[m.text] ? { text: uiSaid(SIGNIN_SAID[m.text], m.text) } : {}), actions: actionsOf(m), links: linksOf(m), ...(m.request && typeof m.request === 'object' ? { request: requestOf(m) } : {}) } : m)) };
4022
4023
  }
4023
4024
  /* ITS MACHINE, on the side of the detailed chat: as this page last knew it. */
4024
4025
  function withMachine(data, name) {
@@ -9087,6 +9088,42 @@
9087
9088
  void thread?.refresh?.();
9088
9089
  }
9089
9090
 
9091
+ /* The button of the line "Once signed in, paste the code" (#405): a field of its own, so that the code is never a
9092
+ message. Its value goes to the server, is typed into the tool, and is wiped here whatever the answer. */
9093
+ function openSigninCode() {
9094
+ const name = current;
9095
+ let box = document.getElementById('signin-code');
9096
+ if (!box) {
9097
+ box = document.createElement('dialog'); box.id = 'signin-code';
9098
+ const form = document.createElement('form');
9099
+ const label = document.createElement('label'); label.htmlFor = 'signin-code-value'; label.id = 'signin-code-title';
9100
+ const input = document.createElement('input'); input.id = 'signin-code-value'; input.type = 'password'; input.autocomplete = 'off'; input.spellcheck = false; input.setAttribute('autocapitalize', 'off'); input.maxLength = 300;
9101
+ const why = document.createElement('p'); why.id = 'signin-code-why'; why.className = 'error'; why.setAttribute('role', 'alert'); why.hidden = true;
9102
+ const send = document.createElement('button'); send.type = 'submit'; send.id = 'signin-code-send'; send.className = 'primary';
9103
+ form.append(label, input, why, send); box.append(form); document.body.append(box);
9104
+ box.addEventListener('click', (event) => { if (event.target === box) box.close(); });
9105
+ box.addEventListener('close', () => { input.value = ''; why.hidden = true; });
9106
+ form.addEventListener('submit', async (event) => {
9107
+ event.preventDefault();
9108
+ const code = input.value.trim();
9109
+ if (!code || send.disabled) return;
9110
+ input.value = ''; send.disabled = true; why.hidden = true;
9111
+ const to = box.dataset.conversation;
9112
+ let status = 0;
9113
+ try { status = (await fetch(`${API}/conversations/${encodeURIComponent(to)}/signin-code?c=${encodeURIComponent(to)}`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ code }) })).status; } catch { /* said below */ }
9114
+ send.disabled = false;
9115
+ if (status === 200) { box.close(); void thread?.refresh?.(); return; }
9116
+ why.textContent = status === 400 ? uiSaid('set-signin-code-bad', 'This is not a code.') : status === 409 ? uiSaid('set-signin-code-late', 'The tool is no longer waiting for a code.') : uiSaid('set-signin-code-failed', 'Not sent. Try again.');
9117
+ why.hidden = false; input.focus();
9118
+ });
9119
+ }
9120
+ box.dataset.conversation = name;
9121
+ $('signin-code-title').textContent = uiSaid('set-signin-code-title', 'Sign-in code');
9122
+ $('signin-code-send').textContent = uiSaid('set-signin-code-send', 'Send');
9123
+ if (!box.open) box.showModal();
9124
+ $('signin-code-value').focus();
9125
+ }
9126
+
9090
9127
  /* ---------- Updates: what runs, what is out, how it updates itself (server/updates.mjs) ---------- */
9091
9128
  let updatesTimer; let updatesBusy = false;
9092
9129
  const RESULT_WORDS = { done: 'Done', 'rolled-back': 'Did not work: went back', failed: 'Failed' };
package/web/index.html CHANGED
@@ -276,7 +276,7 @@
276
276
  <!-- ITS ASSETS (07-11, assets step 4): one line; what it was given lives in its Assets tab (Give…, its rights). -->
277
277
  <div class="row access-assets"><button type="button" id="access-assets" class="as-link"></button></div>
278
278
  <!-- ITS SIGN-IN COMPANION (15-11, #362): the conversation that signs its tool in, if not the general one. -->
279
- <div class="set-row" id="companion-here-row"><div class="set-what"><label for="companion-here">Sign-in companion</label><small id="companion-here-hint">Signs its tool in with its browser</small></div><div class="set-control"><select id="companion-here"></select></div></div>
279
+ <div class="set-row" id="companion-here-row"><div class="set-what"><label for="companion-here">Sign-in companion</label><small id="companion-here-hint">Signs its tool in with its browser</small><small data-said="set-companion-yours">Your choice, your responsibility</small></div><div class="set-control"><select id="companion-here"></select></div></div>
280
280
  <div id="signin-setup" hidden>
281
281
  <div class="panel-top"><b>Sign-in mailbox</b></div>
282
282
  <p class="hint">Its sign-in links, beside the terminal</p><p class="hint tip" hidden>A mailbox for this tool's account, read only; its password never enters the machine.</p>
@@ -1056,6 +1056,7 @@
1056
1056
  <!-- SIGN-IN COMPANION (15-11, #362): the conversation whose browser signs the others' tools in. -->
1057
1057
  <div class="set-row"><div class="set-what"><label for="companion-general">Sign-in companion</label><small id="companion-general-hint">Signs the tools in with its browser</small></div><div class="set-control"><select id="companion-general"></select></div></div>
1058
1058
  <div class="set-row"><div class="set-what"><label for="companion-clicks">It clicks Authorize itself</label><small>You have nothing to do</small></div><div class="set-control"><input type="checkbox" id="companion-clicks"></div></div>
1059
+ <p class="companion-yours" data-said="set-companion-yours">Your choice, your responsibility</p>
1059
1060
  <p class="error" id="companion-general-error" role="alert" hidden></p>
1060
1061
  </div>
1061
1062
  </details>
package/web/style.css CHANGED
@@ -3446,3 +3446,12 @@ span.tile-spark { display: block; height: 22px; }
3446
3446
 
3447
3447
  /* An MCP server's new tools (#392): its label and the three choices, wrapping on a phone. */
3448
3448
  .mcp-new-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
3449
+
3450
+ /* The field of a tool's sign-in code (#405). 16px: a phone does not zoom on it. */
3451
+ #signin-code { width: min(360px, calc(100vw - 32px)); padding: 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
3452
+ #signin-code form { display: flex; flex-direction: column; gap: 10px; }
3453
+ #signin-code label { font-weight: 700; }
3454
+ #signin-code input { width: 100%; min-height: 40px; box-sizing: border-box; padding: 0 10px; font: 1rem var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
3455
+ #signin-code .error { margin: 0; }
3456
+ #signin-code button { align-self: flex-end; min-height: 40px; }
3457
+ .companion-yours { margin: 2px 0 8px; font-size: .75rem; color: var(--ink2); }