clavarium 0.2.514-next.1 → 0.2.516-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/config/tools.json CHANGED
@@ -77,6 +77,7 @@
77
77
  "type:(Not logged in|Login expired|OAuth token (has )?expired|Invalid API key)[^\\n]{0,24}/login=/login",
78
78
  "keys:Select login method:=Enter",
79
79
  "link:https://(claude\\.ai|claude\\.com|console\\.anthropic\\.com)/\\S*oauth\\S*",
80
+ "keys:OAuth error[\\s\\S]{0,160}Press Enter to retry=Enter",
80
81
  "code:Paste code here"
81
82
  ]
82
83
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.514-next.1",
3
+ "version": "0.2.516-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.514-next.1",
9
+ "version": "0.2.516-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.514-next.1",
3
+ "version": "0.2.516-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.",
@@ -1418,6 +1418,7 @@ export class Conversations {
1418
1418
  own disk is refused (its files would stay behind): kept first (its settings, Its files).
1419
1419
  -> the record, at once; `this.built`: the end of it. */
1420
1420
  async moveToShared(name, { machine, machineMb } = {}) {
1421
+ if (this.#store.get(name)?.offline === true) throw new Refusal(409, 'It is offline, which needs its own machine: put it online first.');
1421
1422
  const c = this.#busyCheck(name);
1422
1423
  if (c.sharedMachine) throw new Refusal(409, `It lives in the shared machine ${c.sharedMachine} already.`);
1423
1424
  if (typeof machine !== 'string' || !isConversationName(machine)) throw new Refusal(400, 'A machine name is 1 to 32 lower-case letters, digits or hyphens; it starts with a letter.');
@@ -2377,7 +2378,10 @@ export class Conversations {
2377
2378
 
2378
2379
  /* Online or offline: remembered here, enforced by network.mjs. */
2379
2380
  setOffline(name, offline) {
2380
- if (!this.#store.get(name)) throw new Refusal(404, 'No such conversation.');
2381
+ const c = this.#store.get(name);
2382
+ if (!c) throw new Refusal(404, 'No such conversation.');
2383
+ /* A shared machine has one network for all its agents: the rules, by machine, could not cut this one (#410). */
2384
+ if (offline === true && c.sharedMachine) throw new Refusal(409, 'Offline needs its own machine.');
2381
2385
  this.#store.patch(name, { offline: offline === true });
2382
2386
  }
2383
2387
 
@@ -14,7 +14,7 @@ export const SETTINGS_WORDS_FR = {
14
14
  /* The sign-in of a tool: its code pasted in a field, kept nowhere; the companion, its user's choice (#405). */
15
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
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.',
17
+ 'set-signin-code-late': 'L\'outil n\'attend plus de code.', 'set-signin-code-failed': 'Non envoyé. Réessayez.', 'set-signin-code-rejected': 'Code refusé. Collez-le à nouveau.',
18
18
  'set-companion-yours': 'Votre choix, votre responsabilité',
19
19
  /* Chat › when its thread is archived (talk.mjs setSplit). */
20
20
  'set-chat-split': 'Archiver son fil', 'set-split-2000': 'Tous les 2 000 messages', 'set-split-5000': 'Tous les 5 000',
@@ -272,7 +272,7 @@ export const SETTINGS_WORDS_FR = {
272
272
  'set-files-read-only': 'Lecture seule : rien ne peut y être changé.',
273
273
  'set-ai': 'IA', 'set-ai-back': 'Revenir à {name}', 'set-ai-ask': 'Passer à {name} ? Elle relira ce fil.', 'set-ai-go': 'Changer', 'set-ai-no': 'Annuler',
274
274
  'set-this-conv': 'Cette conversation · {name}', 'set-ask-first': 'Demander avant d\'agir',
275
- 'set-online': 'En ligne', 'set-offline-btn': 'Hors ligne', 'set-sleep': 'Endormir',
275
+ 'set-online': 'En ligne', 'set-offline-btn': 'Hors ligne', 'set-offline-shared': 'Demande sa propre machine', 'set-sleep': 'Endormir',
276
276
  'set-room-name': 'Nom', 'set-room-welcomes': 'Accueille', 'set-room-ais': 'Ses IA',
277
277
  'set-room-find': 'Chercher une conversation', 'set-room-boxes': 'Boîtiers vocaux',
278
278
  'set-room-remove': 'Supprimer le salon', 'set-room-remove-what': 'Le fil part · les IA et boîtiers restent',
@@ -53,6 +53,8 @@ export const OFFER_EVERY_MS = 6000;
53
53
  const SCREEN_LINES = 12;
54
54
  export const CODE_LINE = 'Once signed in, paste the code.';
55
55
  export const CODE_SENT = 'Code sent to the tool.';
56
+ /* How long its tool is given to leave its prompt once a code is typed: still there, the code was not accepted. */
57
+ export const CODE_SETTLE_MS = 12_000;
56
58
  export const NONE = 'none';
57
59
  const ASK_BYTES = 16_384;
58
60
  const LINK_MAX = 4000;
@@ -88,6 +90,7 @@ export class SigninHelp {
88
90
  #offered = new Map();
89
91
  #looked = new Map();
90
92
  #typing = new Set();
93
+ codeSettleMs = CODE_SETTLE_MS;
91
94
 
92
95
  /* `store`: { get(), set(v) } of { general, per: { name: companion | NONE } }. `conversations()`: [{ name, tool }].
93
96
  `tools()`: config/tools.json as read. `awake()`, `chatOn(name)`. `workFolder(name)`. `browsers(name)`: the
@@ -194,7 +197,16 @@ export class SigninHelp {
194
197
  if (!at) throw new Refusal(409, 'Its tool is not waiting for a code now.');
195
198
  const typed = await Promise.resolve(this.#type(name, code)).catch(() => false);
196
199
  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. */
200
+ /* STILL AT ITS PROMPT (22-11, a wrong code on a real machine): the ask stays, so that the field can be used
201
+ again and nothing else is typed into that prompt meanwhile. */
202
+ const end = Date.now() + this.codeSettleMs;
203
+ let waiting = await this.atCodePrompt(name, exec).catch(() => false);
204
+ while (waiting && Date.now() < end) {
205
+ await new Promise((r) => { setTimeout(r, 1000).unref?.(); });
206
+ waiting = await this.atCodePrompt(name, exec).catch(() => false);
207
+ }
208
+ if (waiting) throw new Refusal(422, 'The tool did not accept this code.');
209
+ /* Accepted: the ask is over, whatever comes next is not this code. */
198
210
  const dir = this.#chat(name);
199
211
  if (this.#own(dir)) { try { rmSync(join(dir, ASK), { force: true }); } catch { /* it runs out by itself */ } }
200
212
  this.#route(name, { id: ask.id, route: 'done' });
package/web/app.js CHANGED
@@ -2769,6 +2769,10 @@
2769
2769
  void paintGuide(here);
2770
2770
  const offline = here?.offline === true;
2771
2771
  for (const b of $('network').children) b.setAttribute('aria-pressed', String((b.dataset.online === 'true') !== offline));
2772
+ /* A shared machine has one network: Offline could not cut this agent alone (#410). */
2773
+ const oneNetwork = Boolean(here?.sharedMachine);
2774
+ $('network').querySelector('[data-online="false"]').disabled = oneNetwork;
2775
+ $('network-shared').hidden = !oneNetwork;
2772
2776
  void paintCompanionHere();
2773
2777
  await paintSignIn();
2774
2778
  }
@@ -9113,7 +9117,7 @@
9113
9117
  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
9118
  send.disabled = false;
9115
9119
  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.');
9120
+ 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.') : status === 422 ? uiSaid('set-signin-code-rejected', 'Code not accepted. Paste it again.') : uiSaid('set-signin-code-failed', 'Not sent. Try again.');
9117
9121
  why.hidden = false; input.focus();
9118
9122
  });
9119
9123
  }
package/web/index.html CHANGED
@@ -129,7 +129,7 @@
129
129
  <div id="rights-box" hidden>
130
130
  <div class="set-row"><div class="set-what"><b data-said="set-ask-first">Ask before acting</b><small id="rights-hint" class="tip" hidden>Off: <b>the tool acts without asking you</b>, inside its own machine. At its next start</small></div><div class="set-control"><div class="levels" id="ask-first" role="group" aria-label="Ask before acting"><button type="button" data-on="false" data-said="set-off">Off</button><button type="button" data-on="true" data-said="set-on">On</button></div></div></div>
131
131
  </div>
132
- <div class="set-row" id="network-row"><div class="set-what"><b data-said="set-online">Online</b><small class="tip" hidden>Offline: its machine reaches nothing outside. The tool cannot undo it.</small></div><div class="set-control"><div class="levels" id="network" role="group" aria-label="Network of this conversation"><button type="button" data-online="true" data-said="set-online">Online</button><button type="button" data-online="false" data-said="set-offline-btn">Offline</button></div></div></div>
132
+ <div class="set-row" id="network-row"><div class="set-what"><b data-said="set-online">Online</b><small class="tip" hidden>Offline: its machine reaches nothing outside. The tool cannot undo it.</small><small id="network-shared" data-said="set-offline-shared" hidden>Needs its own machine</small></div><div class="set-control"><div class="levels" id="network" role="group" aria-label="Network of this conversation"><button type="button" data-online="true" data-said="set-online">Online</button><button type="button" data-online="false" data-said="set-offline-btn">Offline</button></div></div></div>
133
133
  </div>
134
134
  <div class="hand-acts" id="panel-actions">
135
135
  <button type="button" id="quick-wake" class="primary" hidden>Wake it</button>