clavarium 0.2.494-next.1 → 0.2.495-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,20 +1,20 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.494-next.1",
3
+ "version": "0.2.495-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.494-next.1",
9
+ "version": "0.2.495-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
- "clavarium-binder": "0.1.65-next.1",
14
+ "clavarium-binder": "0.1.66-next.1",
15
15
  "clavarium-docket": "0.1.2-next.3",
16
16
  "clavarium-parley": "0.17.95-next.1",
17
- "clavarium-tether": "0.1.0-next.77",
17
+ "clavarium-tether": "0.1.0-next.78",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
20
20
  "node-pty": "^1.1.0",
@@ -761,9 +761,9 @@
761
761
  }
762
762
  },
763
763
  "node_modules/clavarium-binder": {
764
- "version": "0.1.65-next.1",
765
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.65-next.1.tgz",
766
- "integrity": "sha512-tUyR6SNNR12zgdSd6ODWo7sDK8gf+yr67WFNitDoXrFu5imlQcbE1HYYarUe6rq5WJXOYxXaoVrbpRAksU4Mwg==",
764
+ "version": "0.1.66-next.1",
765
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.66-next.1.tgz",
766
+ "integrity": "sha512-fidWpyIoxPlQ1IiBrtRf44A5ev7J/ydCuhNfLlz38FSnrHqIhSMc3vb2QUG4McOtc7C46Dr15ZvN5cjnHx2yZg==",
767
767
  "license": "MIT",
768
768
  "bin": {
769
769
  "binder": "bin/binder.mjs",
@@ -800,9 +800,9 @@
800
800
  }
801
801
  },
802
802
  "node_modules/clavarium-tether": {
803
- "version": "0.1.0-next.77",
804
- "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.77.tgz",
805
- "integrity": "sha512-rJ1lkgRmtGtw/mGN72o1jC77ELuI75dS5V+0u+D9xCzSaYixePQloslakR1TXn4XSvjYTdMK3A02/dmksadQRQ==",
803
+ "version": "0.1.0-next.78",
804
+ "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.78.tgz",
805
+ "integrity": "sha512-LUOpKGWS+ffxU8/EBxDm8PbLMSBUuMmITcWVCHS3bWn5s+wmQ1lDebjoCY6t/xgFbRqpUM0guRZ8MhfkQJsHEQ==",
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.494-next.1",
3
+ "version": "0.2.495-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.",
@@ -45,10 +45,10 @@
45
45
  "dependencies": {
46
46
  "@xterm/addon-fit": "^0.11.0",
47
47
  "@xterm/xterm": "^6.0.0",
48
- "clavarium-binder": "0.1.65-next.1",
48
+ "clavarium-binder": "0.1.66-next.1",
49
49
  "clavarium-docket": "0.1.2-next.3",
50
50
  "clavarium-parley": "0.17.95-next.1",
51
- "clavarium-tether": "0.1.0-next.77",
51
+ "clavarium-tether": "0.1.0-next.78",
52
52
  "mammoth": "1.13.0",
53
53
  "mermaid": "11.17.2",
54
54
  "node-pty": "^1.1.0",
package/server/api.mjs CHANGED
@@ -206,7 +206,7 @@ import { WORK_TAB } from './resources.mjs';
206
206
  import { transcribe, AUDIO_MAX } from './voice.mjs';
207
207
  import { FILE_MAX } from './setup.mjs';
208
208
  import { demandeView } from './demandes.mjs';
209
- import { mcpAdd, mcpImport, mcpRefresh, mcpRights, mcpSeen, forgetKey } from './mcpx.mjs';
209
+ import { mcpAdd, mcpImport, mcpRefresh, mcpRights, mcpSeen, mcpNewTools, forgetKey } from './mcpx.mjs';
210
210
  import { BACK_PATH, backPage } from './mcpoauth.mjs';
211
211
 
212
212
  const BODY_MAX = 16 * 1024;
@@ -718,10 +718,10 @@ export async function handleApi(request, response, conversations, headers, resou
718
718
  /* Signing in to one with OAuth: the link the owner opens ({ url }), or { need: 'client' } for a client id to paste. */
719
719
  if (pathname === '/api/tether/ssh-add' && tethers && gitAccess) return send(201, await addMachine({ tethers, keys: gitAccess, ...(tethers.sshProbe ? { probe: tethers.sshProbe } : {}) }, body ?? {})), true;
720
720
  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;
721
- const mcpOp = /^\/api\/tether\/mcp-(add|import|refresh|rights|seen)$/.exec(pathname);
721
+ const mcpOp = /^\/api\/tether\/mcp-(add|import|refresh|rights|seen|new-tools)$/.exec(pathname);
722
722
  if (mcpOp && tethers) {
723
723
  const ctx = { tethers, secrets };
724
- const done = await { add: mcpAdd, import: mcpImport, refresh: mcpRefresh, rights: mcpRights, seen: mcpSeen }[mcpOp[1]](ctx, body ?? {});
724
+ const done = await { add: mcpAdd, import: mcpImport, refresh: mcpRefresh, rights: mcpRights, seen: mcpSeen, 'new-tools': mcpNewTools }[mcpOp[1]](ctx, body ?? {});
725
725
  return send(mcpOp[1] === 'add' || mcpOp[1] === 'import' ? 201 : 200, done), true;
726
726
  }
727
727
  /* A browser paired through the Tether extension (browsers.mjs): the code its popup shows, and its name; or paired
package/server/mcpx.mjs CHANGED
@@ -147,6 +147,18 @@ export async function mcpSeen({ tethers }, body = {}) {
147
147
  return { seen: Array.isArray(r.data?.seen) ? r.data.seen : [] };
148
148
  }
149
149
 
150
+ /* WHAT ITS NEW TOOLS DO (#392, Tether 0.1.0-next.78), the owner's choice per server: { target, mode: 'ask' | 'read' | 'all' }
151
+ -> { newTools, seen: [names taken now] }. A Tether without the op says so. */
152
+ export async function mcpNewTools({ tethers }, body = {}) {
153
+ const target = String(body.target ?? '');
154
+ const t = tethers.store().target(target);
155
+ if (!t || t.kind !== 'mcp') throw new Refusal(404, 'No such MCP server.');
156
+ if (!['ask', 'read', 'all'].includes(body.mode)) throw new Refusal(400, 'mode: ask, read or all.');
157
+ const r = await tethers.act('mcp-new-tools', { target, mode: body.mode }, '');
158
+ if (!r.ok) throw new Refusal(/there is no mcp-new-tools/.test(r.text ?? '') ? 501 : 400, /there is no mcp-new-tools/.test(r.text ?? '') ? 'This Tether cannot set this yet: update it.' : r.text);
159
+ return { newTools: r.data?.newTools ?? body.mode, seen: Array.isArray(r.data?.seen) ? r.data.seen : [] };
160
+ }
161
+
150
162
  /* The vault's name for a server's OAuth tokens (mcpoauth.mjs): as long as its key's name. */
151
163
  export const oauthName = (id) => `${keyName(id).slice(0, -KEY_SUFFIX.length)}_TOK`;
152
164
  /* The vault's name for the client the owner pasted for it (an id and a secret, 16-11): host-only too. */
@@ -202,7 +202,7 @@ export const SETTINGS_WORDS_FR = {
202
202
  'set-mcp-notjson': 'Pas du JSON : collez tout le bloc.',
203
203
  'set-mcp-noserver': 'Pas de serveur dans ce bloc.', 'set-mcp-program': '« {name} » : programme à lancer, refusé ici.',
204
204
  'set-mcp-heads': '« {name} » : un seul en-tête pour sa clé.', 'set-mcp-basic': '« {name} » : clé non « Bearer », à la main.',
205
- 'set-mcp-need': 'Collez le bloc, ou donnez nom et adresse.', 'set-mcp-tools': 'Outils', 'set-mcp-refresh': 'Actualiser', 'set-mcp-seen': 'Marquer comme vu',
205
+ 'set-mcp-need': 'Collez le bloc, ou donnez nom et adresse.', 'set-mcp-tools': 'Outils', 'set-mcp-new': 'Nouveaux outils', 'set-mcp-new-ask': 'Demander une fois', 'set-mcp-new-read': 'Lecture : acceptés', 'set-mcp-new-all': 'Tous acceptés', 'set-mcp-refresh': 'Actualiser', 'set-mcp-seen': 'Marquer comme vu',
206
206
  'set-mcp-none': 'Aucun outil listé pour l\'instant.', 'set-mcp-unreached': 'Injoignable : {why}', 'set-mcp-open': 'atteint l\'extérieur',
207
207
  'set-mcp-fresh': 'Nouveau : demandé jusqu\'à ce que vous l\'ayez vu',
208
208
  'set-mcp-oauth': 'Se connecter', 'set-mcp-link': 'Ou ouvrez ce lien dans un autre navigateur :', 'set-mcp-link-copy': 'Copier', 'set-mcp-link-copied': 'Copié', 'set-mcp-link-open': 'Ouvrir', 'set-mcp-client': 'Identifiant client', 'set-mcp-client-need': 'Collez son identifiant et son secret, une fois.',
@@ -41,6 +41,9 @@ import { SOCKET } from './tmux.mjs';
41
41
  import { isConversationName } from './names.mjs';
42
42
 
43
43
  export const TICK_MS = 5000;
44
+ /* A folder is looked through (up to 5000 entries, at once) at most this often per arrival (18-11: every 5 s each, on
45
+ every turn of a busy server); the rest of the wake-ups still every TICK_MS. */
46
+ export const ARRIVAL_EVERY_MS = 30_000;
44
47
  export const MESSAGE_MAX = 1000;
45
48
  export const ITEMS_MAX = 8;
46
49
  export const DEFAULT_PER_HOUR = 12;
@@ -150,13 +153,14 @@ const FIRED_SHOWN = 120;
150
153
  const sameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
151
154
 
152
155
  export class Wakeups {
153
- #store; #vms; #conversations; #resources; #warm; #now; #fired; #docket; #typing; #pause; #held = new Map(); #busy = false;
156
+ #store; #vms; #conversations; #resources; #warm; #now; #fired; #docket; #typing; #pause; #held = new Map(); #busy = false; #looked = new Map(); #arrivalEveryMs;
154
157
 
155
158
  /* `warm(name)`: opens the terminal of a machine that runs, if it is not open.
156
159
  `fired(name, { text, item })`: a wake-up was typed (its chat says so: Talk.event). */
157
160
  /* `docket`: { on(name), post(name, {kind, text, data}) } (dockets.mjs), or none: typed always. */
158
161
  /* `typing(name)`: someone is typing in its terminal from a screen (see TypingWatch): a line is held until it is free. */
159
- constructor({ store, vms, conversations, resources, warm = async () => {}, now = () => new Date(), fired = () => {}, docket = null, typing = () => false, pause = (ms) => new Promise((ok) => setTimeout(ok, ms)) }) {
162
+ constructor({ store, vms, conversations, resources, warm = async () => {}, now = () => new Date(), fired = () => {}, docket = null, typing = () => false, pause = (ms) => new Promise((ok) => setTimeout(ok, ms)), arrivalEveryMs = ARRIVAL_EVERY_MS }) {
163
+ this.#arrivalEveryMs = arrivalEveryMs;
160
164
  this.#store = store; this.#vms = vms; this.#conversations = conversations; this.#resources = resources; this.#warm = warm; this.#now = now; this.#fired = fired; this.#docket = docket;
161
165
  this.#typing = typing; this.#pause = pause;
162
166
  }
@@ -300,6 +304,9 @@ export class Wakeups {
300
304
  /* An arrival. The folder must still be attached: what was taken back wakes nobody. */
301
305
  if (!this.#resources.of(name).some((x) => x.name === item.resource)) return undefined;
302
306
  const key = `${name}/${item.id}`;
307
+ const lookedAt = this.#looked.get(key) ?? 0;
308
+ if (this.#now().getTime() - lookedAt < this.#arrivalEveryMs) return undefined;
309
+ this.#looked.set(key, this.#now().getTime());
303
310
  const seen = look(this.#resources.folder(item.resource));
304
311
  /* A repository: a commit is an arrival too. Only the date and size of
305
312
  its journal are looked at; git is never run here. */
package/web/app.js CHANGED
@@ -5972,6 +5972,16 @@
5972
5972
  else if (t.catalog?.error) body.push(el('p', 'error', uiSaid('set-mcp-unreached', 'Not reached: {why}', { why: t.catalog.error })));
5973
5973
  body.push(tools.length ? list : el('p', 'hint', uiSaid('set-mcp-none', 'No tools listed yet.')));
5974
5974
  body.push(linkBox, clientBox);
5975
+ /* What its new tools do (#392): asked once, those that only read at once, or all at once -- the owner's choice. */
5976
+ const newTools = el('div', 'mcp-new-tools');
5977
+ newTools.append(el('span', '', uiSaid('set-mcp-new', 'New tools')), KIT.Segmented({
5978
+ options: [['ask', uiSaid('set-mcp-new-ask', 'Ask once')], ['read', uiSaid('set-mcp-new-read', 'Read-only: accepted')], ['all', uiSaid('set-mcp-new-all', 'All accepted')]].map(([value, label]) => ({ value, label })),
5979
+ value: t.newTools ?? 'ask', label: uiSaid('set-mcp-new', 'New tools'), onChange: async (mode) => {
5980
+ $(asErrId()).hidden = true;
5981
+ try { await post(`${API}/tether/mcp-new-tools`, { target: t.id, mode }); } catch (error) { sayAsErr(error); }
5982
+ await repaintAsset();
5983
+ } }));
5984
+ body.push(newTools);
5975
5985
  out.push({ title: uiSaid('set-mcp-tools', 'Tools'), extra: [seen, oauth, refresh], body, cls: 'as-mcp-tools' });
5976
5986
  /* Custom: each kind of tool Yes / Ask / No, for each conversation set to it. */
5977
5987
  const custom = Object.entries(t.grants ?? {}).filter(([id, g]) => id.startsWith('conversation:') && g?.level === 'frame');
package/web/style.css CHANGED
@@ -3443,3 +3443,6 @@ span.tile-spark { display: block; height: 22px; }
3443
3443
  @media (prefers-reduced-motion: reduce) { .sc-main { transition: none; } }
3444
3444
  .mc-port { max-width: 6em; flex: 0 0 6em; }
3445
3445
  .kit-na-made .hint { overflow-wrap: anywhere; }
3446
+
3447
+ /* An MCP server's new tools (#392): its label and the three choices, wrapping on a phone. */
3448
+ .mcp-new-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }