clavarium 0.2.458-next.1 → 0.2.461-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.458-next.1",
3
+ "version": "0.2.461-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.458-next.1",
9
+ "version": "0.2.461-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.458-next.1",
3
+ "version": "0.2.461-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
@@ -29,7 +29,7 @@
29
29
  * {} (no machine): out of its shared machine, into one of its own (15-11)
30
30
  * POST /api/conversations/<name>/copy {title?, machine?, machineMb?, reminders?}: a copy -- its work, its tool's state, its accesses (its reminders and wake-ups when asked); it untouched (202)
31
31
  * POST /api/conversations/<name>/rebuild {reset?, confirm?}: built again; reset (confirm: its name) for a working one too
32
- * POST /api/signin-companion {companion}: the conversation that signs the others' tools in with its browser ('' none; 15-11)
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
35
  * 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
@@ -1006,7 +1006,7 @@ export async function handleApi(request, response, conversations, headers, resou
1006
1006
  const later = /^\/api\/conversations\/([^/]+)\/machine\/cancel$/.exec(pathname);
1007
1007
  if (later) return send(200, conversations.cancelResize(decodeURIComponent(later[1]))), true;
1008
1008
  /* DELEGATED SIGN-IN (signinhelp.mjs, 15-11): the companion of all, of one conversation, and the link shown to the person instead. */
1009
- if (pathname === '/api/signin-companion' && conversations.signinHelp) return send(200, conversations.signinHelp.setGeneral(body.companion)), true;
1009
+ if (pathname === '/api/signin-companion' && conversations.signinHelp) return send(200, body.clicks !== undefined ? conversations.signinHelp.setClicks(body.clicks) : conversations.signinHelp.setGeneral(body.companion)), true;
1010
1010
  const companionOf = /^\/api\/conversations\/([^/]+)\/signin-companion$/.exec(pathname);
1011
1011
  if (companionOf && conversations.signinHelp) return send(200, conversations.signinHelp.setFor(decodeURIComponent(companionOf[1]), body.companion ?? null)), true;
1012
1012
  const linkOf = /^\/api\/conversations\/([^/]+)\/signin-link$/.exec(pathname);
package/server/guide.mjs CHANGED
@@ -91,7 +91,7 @@ export function commonText() {
91
91
  /* Dictation into the terminal is marked once per message (app.js); in the chat, parley read says it. */
92
92
  '- A message in your terminal that starts with a microphone sign (U+1F3A4), or that parley read says was dictated, came by voice: a word may be misheard; when a key word seems wrong, ask rather than guess.',
93
93
  /* The commands, the one path every assistant has, MCP or not (#352): MCP tools, where given, are the same. */
94
- '- Commands installed (each with --help): parley (the chat), docket (what woke you, your reminders), binder (the lists you were given), tether (your accesses, alone: what you were given; a server of tools: tether mcp TARGET, then tether mcp TARGET TOOL \'{json}\'). The same may also be among your tools (MCP).',
94
+ '- Commands installed (each with --help): parley (the chat), docket (what woke you, your reminders), binder (lists, "classeur": yours too), tether (your accesses, alone: what you were given; a server of tools: tether mcp TARGET, then tether mcp TARGET TOOL \'{json}\'). The same may also be among your tools (MCP).',
95
95
  '- The rest is yours to explore (ls, --help).',
96
96
  '',
97
97
  ].join('\n');
@@ -133,7 +133,7 @@ export function ownText({ name, tool, shared, workKept, resources = [], chat, on
133
133
  /* Its docket (dockets.mjs): what wakes it waits there until it says done or failed. */
134
134
  if (chat) out.push('- What wakes you (a file arrived, the clock, a call) waits in your docket: when told "run docket", run it, do each, then docket done ID or docket failed ID "why". To be reminded later: docket remind --at "2026-10-23 09:00" (or --in 2h, --cron "0 9 * * 1") "what for". docket --help says all.');
135
135
  /* Its lists (binders.mjs): kept on the server, asked for through .binder; a person approves. */
136
- out.push('- Lists kept with the person (batches, tasks, customers...): binder shows those you were given; add, note, attach, move them; a gate waits for the person\'s tick. binder --help says all.');
136
+ out.push('- Lists kept with the person (batches, tasks, customers, people...; "classeur", "fiches" in French): the binder command, in your terminal, not an MCP tool. binder shows those you were given; binder new TEMPLATE "name" makes one (templates: simple, people, customers, development, batches, priorities, roadmap); add, note, attach, move cards; a gate waits for the person\'s tick. binder --help says all.');
137
137
  /* Its binder of batches is shown beside the chat (web/app.js): the person ticks there. */
138
138
  if (chat) out.push('- When you work in batches: keep them in a binder of batches, shown beside the chat. None yet: make it once (binder new batches; MCP: new-list, template batches). Then one card each (binder add Batches "title"), kept up to date; start only those the person ticked.');
139
139
  out.push(online === false ? '- Internet: off.' : '- Internet: on.');
@@ -240,20 +240,30 @@ export class Guide {
240
240
  async setLines(name, input) {
241
241
  this.#known(name);
242
242
  const lines = readLines(input);
243
- if (lines.length) this.#store.put({ name, lines }); else this.#store.remove(name);
243
+ { const { lines: _old, ...kept } = this.#store.get(name) ?? { name }; this.#store.put(lines.length ? { ...kept, name, lines } : { ...kept, name }); }
244
244
  await this.changed(name);
245
245
  return this.about(name);
246
246
  }
247
247
 
248
248
  /* ---- into the machine ---- */
249
- async #writeOwn(name) {
249
+ async #writeOwn(name, fresh = false) {
250
250
  const text = this.own(name);
251
251
  /* In a shared machine, its own file, readable by its own user only: its door shows it at OWN_PATH (#221). */
252
252
  const shared = this.#vms.shared?.(name) === true;
253
253
  const r = await this.#vms.exec(name, ['sudo', '-n', 'install', '-D', '-m', shared ? '0440' : '0444', '-o', 'root', '-g', shared ? sharedUser(name) : 'root', '/dev/stdin', shared ? ownGuideFile(name) : OWN_PATH], { input: text, timeoutMs: 30_000 });
254
254
  if (r.code !== 0) throw new Error(`its guide could not be written: ${firstLine(r.stderr) || `exit ${r.code}`}`);
255
255
  this.#written.set(name, text);
256
+ /* WHAT IT READ (15-11, its owner's ask: a tool kept on with its old setup did not know it changed): its
257
+ guide as written, the common part with it; changed since it last read it, its docket tells it -- not at
258
+ its start (`fresh`), when it reads it anyway. */
259
+ const seen = sha(`${commonText()}\n${text}`);
260
+ const was = this.#store.get(name)?.read;
261
+ if (was === seen) return;
262
+ if (was && !fresh && typeof this.told === 'function') { try { this.told(name, TELL_AGAIN); } catch { /* its docket may be off */ } }
263
+ this.#store.put({ ...(this.#store.get(name) ?? { name }), read: seen });
256
264
  }
265
+ /* Set by the server (15-11): its docket told that its guide changed. (name, line) */
266
+ told = null;
257
267
 
258
268
  /* The marked block in the tool's own instruction file. Resolves with
259
269
  'written', 'same', or throws with why it was left alone. */
@@ -275,7 +285,7 @@ export class Guide {
275
285
  in the way of an opening: what fails is said in the server's log. */
276
286
  async prepared(name, woke) {
277
287
  try {
278
- if (woke || this.#written.get(name) !== this.own(name)) await this.#writeOwn(name);
288
+ if (woke || this.#written.get(name) !== this.own(name)) await this.#writeOwn(name, woke);
279
289
  /* Once per machine start, and once after this server started. */
280
290
  if (woke || !this.#pointed.has(name)) { await this.pointer(name); this.#pointed.add(name); }
281
291
  } catch (error) { this.#written.delete(name); console.error(`${name}: ${error.message}`); }
@@ -294,7 +304,7 @@ export class Guide {
294
304
  async tellAgain(name) {
295
305
  this.#known(name);
296
306
  if (!this.#conversations.awake?.().includes(name)) throw new Refusal(409, 'It is asleep: open it first.');
297
- try { await this.#writeOwn(name); await this.pointer(name); this.#pointed.add(name); }
307
+ try { await this.#writeOwn(name, true); await this.pointer(name); this.#pointed.add(name); }
298
308
  catch (error) { throw new Refusal(502, `Its machine could not be given its guide: ${error.message}`); }
299
309
  if (!(await this.#say(name, TELL_AGAIN))) throw new Refusal(502, 'The line could not be typed: is its tool running?');
300
310
  return { ...this.about(name), told: TELL_AGAIN };
package/server/main.mjs CHANGED
@@ -570,6 +570,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
570
570
  alert: (payload) => { void alerts.tell(payload); } });
571
571
  /* Its machine restarted or built again: said in its chat, and the tool told to read it again. */
572
572
  all.renewed = (name, text, running) => talk.renewed(name, text, running);
573
+ /* Its guide changed while its tool ran (15-11): its docket tells it to read it again. */
574
+ guide.told = (name, line) => { if (dockets.on(name)) dockets.post(name, { kind: 'guide-changed', text: line }); };
573
575
  /* Restarted with nothing written since (15-11): its docket tells it, once its tool is ready and free. */
574
576
  talk.restarted = (name, why) => {
575
577
  if (!dockets.on(name)) return false;
@@ -82,7 +82,7 @@ export class SigninHelp {
82
82
  this.#work = workFolder; this.#browsers = browsers; this.#post = post; this.#type = type; this.#event = event; this.#now = now;
83
83
  }
84
84
 
85
- #settings() { const s = this.#store.get() ?? {}; return { general: typeof s.general === 'string' ? s.general : '', per: s.per && typeof s.per === 'object' ? { ...s.per } : {} }; }
85
+ #settings() { const s = this.#store.get() ?? {}; return { general: typeof s.general === 'string' ? s.general : '', per: s.per && typeof s.per === 'object' ? { ...s.per } : {}, clicks: s.clicks === true }; }
86
86
  #exists(name) { return this.#conversations().some((c) => c.name === name); }
87
87
  #usable(name) { try { return (this.#browsers(name) ?? []).filter((b) => ACTS(b.level)); } catch { return []; } }
88
88
 
@@ -90,7 +90,7 @@ export class SigninHelp {
90
90
  view() {
91
91
  const s = this.#settings();
92
92
  const named = new Set([s.general, ...Object.values(s.per)].filter((c) => c && c !== NONE));
93
- return { general: s.general, per: s.per, browsers: Object.fromEntries([...named].map((c) => [c, this.#usable(c).map((b) => b.id)])) };
93
+ return { general: s.general, per: s.per, clicks: s.clicks, browsers: Object.fromEntries([...named].map((c) => [c, this.#usable(c).map((b) => b.id)])) };
94
94
  }
95
95
  /* '' for none. */
96
96
  setGeneral(companion) {
@@ -98,6 +98,13 @@ export class SigninHelp {
98
98
  this.#store.set({ ...this.#settings(), general: companion });
99
99
  return this.view();
100
100
  }
101
+ /* THE COMPANION CLICKS « AUTHORIZE » ITSELF (15-11, its owner's go): off unless its owner says so; then the
102
+ person has nothing to do. Only that button, on the page the link opened -- nothing else is clicked. */
103
+ setClicks(on) {
104
+ if (typeof on !== 'boolean') throw new Refusal(400, 'Say true or false.');
105
+ this.#store.set({ ...this.#settings(), clicks: on });
106
+ return this.view();
107
+ }
101
108
  /* null: as the general one; NONE: none for it; else that conversation -- never itself. */
102
109
  setFor(name, companion) {
103
110
  if (!this.#exists(name)) throw new Refusal(404, 'No such conversation.');
@@ -175,7 +182,9 @@ export class SigninHelp {
175
182
  /* The link itself is not in the event (an event is shown to the companion's owner): only where it is. */
176
183
  const at = `/work/${DOCKET}/${file}`;
177
184
  event = this.#post(companion, { kind: KIND, text: `Sign in « ${name} » (${tool.label}) with your browser. 1) tether browser ${target} open "$(head -n1 ${at})" `
178
- + '2) Tell your person, one line: "Click Authorize in your browser". '
185
+ + (this.#settings().clicks
186
+ ? '2) Your owner allowed you: on that page only, click the button that authorizes (Authorize, Allow, Continue, Accept) -- nothing else, no other page. '
187
+ : '2) Tell your person, one line: "Click Authorize in your browser". ')
179
188
  + (code ? `3) Read the code the page then shows (tether browser ${target} html --readable). 4) docket done ID "<the code>": the code alone, never in a chat. ` : '3) Once the page says it is done: docket done ID "ok". ')
180
189
  + 'Over 10 min old, or not possible: docket failed ID "why".', data: { conversation: name, tool: tool.id, link: at, browser: target } });
181
190
  if (!this.#own(docket)) throw new Error('its docket folder is not its own');
package/web/app.js CHANGED
@@ -8047,7 +8047,13 @@
8047
8047
  if (!view) return;
8048
8048
  fillCompanions($('companion-general'), [['', 'None']], view.general, null);
8049
8049
  $('companion-general-hint').textContent = companionWarn(view, view.general) || 'Signs the tools in with its browser';
8050
+ $('companion-clicks').checked = view.clicks === true;
8050
8051
  }
8052
+ $('companion-clicks').addEventListener('change', async () => {
8053
+ $('companion-general-error').hidden = true;
8054
+ try { await post(`${API}/signin-companion`, { clicks: $('companion-clicks').checked }); } catch (error) { $('companion-general-error').textContent = error.message; $('companion-general-error').hidden = false; }
8055
+ await paintCompanionGeneral();
8056
+ });
8051
8057
  $('companion-general').addEventListener('change', async () => {
8052
8058
  $('companion-general-error').hidden = true;
8053
8059
  try { await post(`${API}/signin-companion`, { companion: $('companion-general').value }); } catch (error) { $('companion-general-error').textContent = error.message; $('companion-general-error').hidden = false; }
package/web/index.html CHANGED
@@ -1020,6 +1020,7 @@
1020
1020
  <p class="error" id="instance-error" role="alert" hidden></p>
1021
1021
  <!-- SIGN-IN COMPANION (15-11, #362): the conversation whose browser signs the others' tools in. -->
1022
1022
  <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>
1023
+ <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>
1023
1024
  <p class="error" id="companion-general-error" role="alert" hidden></p>
1024
1025
  </div>
1025
1026
  </details>