clavarium 0.2.233-beta.1 → 0.2.234-beta.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 +10 -10
- package/package.json +3 -3
- package/server/api.mjs +3 -3
- package/server/mcpx.mjs +12 -0
- package/server/settingswords.mjs +1 -1
- package/server/wakeups.mjs +9 -2
- package/web/app.js +10 -0
- package/web/desk.js +35 -6
- package/web/style.css +3 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.234-beta.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.234-beta.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.
|
|
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.
|
|
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.
|
|
765
|
-
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.
|
|
766
|
-
"integrity": "sha512-
|
|
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.
|
|
804
|
-
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.
|
|
805
|
-
"integrity": "sha512-
|
|
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.
|
|
3
|
+
"version": "0.2.234-beta.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.
|
|
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.
|
|
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. */
|
package/server/settingswords.mjs
CHANGED
|
@@ -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.',
|
package/server/wakeups.mjs
CHANGED
|
@@ -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/desk.js
CHANGED
|
@@ -39,6 +39,25 @@
|
|
|
39
39
|
return { pos, rows, occ, cols };
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/* HOW IT IS SHOWN on a screen (18-11, the owner chose option A of the panel, bureau-centrage): the same picture
|
|
43
|
+
everywhere, arranged once (on a tablet, say). Out of edit mode: as many columns as the desk uses -- its
|
|
44
|
+
rightmost thing -- each cell between 75 % and 125 % of its size, the whole centred, kept at the top; a screen
|
|
45
|
+
too narrow even at 75 % (a phone) shows them in their reading order, packed. In edit mode: every column that
|
|
46
|
+
fits, from the left, to move things to. Nothing kept changes. `room`: the width there is (px), `cell`/`gap`: the
|
|
47
|
+
style sheet's. -> { cols, cell (px, or 0: the style's), order: 'own' | 'reading' }. */
|
|
48
|
+
const GROW = 1.25; const SHRINK = 0.75;
|
|
49
|
+
function fit(items, { room, cell, gap, editing = false }) {
|
|
50
|
+
const fill = Math.max(1, Math.floor((room + gap) / (cell + gap)));
|
|
51
|
+
/* Some never put anywhere (a first desk, one just added): every column, as before -- nothing to centre on. */
|
|
52
|
+
if (editing || !items.length || items.some((it) => !(it.c && it.r))) return { cols: fill, cell: 0, order: 'own' };
|
|
53
|
+
const used = Math.max(1, ...items.map((it) => it.c + W(it, 48) - 1));
|
|
54
|
+
const each = (room - gap * (used - 1)) / used;
|
|
55
|
+
if (each < cell * SHRINK) return { cols: fill, cell: 0, order: 'reading' };
|
|
56
|
+
return { cols: used, cell: Math.floor(Math.min(each, cell * GROW)), order: 'own' };
|
|
57
|
+
}
|
|
58
|
+
/* In their reading order, packed from the top left, for the screen only: rows first, then columns. */
|
|
59
|
+
const reading = (items) => [...items].sort((a, b) => ((a.r || 1e9) - (b.r || 1e9)) || ((a.c || 0) - (b.c || 0))).map(({ c, r, t, ...it }) => it);
|
|
60
|
+
|
|
42
61
|
/* PUT ONE ON A CELL: those it covers go to the first free cells; the others not placed yet keep the cell
|
|
43
62
|
they are seen in (nothing else moves). `pos`: layout(items, n).pos as seen now. Changes `items`. */
|
|
44
63
|
function moveTo(items, id, c, r, n, pos, now = Date.now()) {
|
|
@@ -202,12 +221,21 @@
|
|
|
202
221
|
|
|
203
222
|
function render() {
|
|
204
223
|
if (!ready || drag) return;
|
|
205
|
-
const
|
|
224
|
+
const m = measure(); if (!m) return;
|
|
225
|
+
const list = shown();
|
|
226
|
+
const cs = getComputedStyle(grid);
|
|
227
|
+
const gap = parseFloat(cs.columnGap) || 12; const cell = parseFloat(cs.getPropertyValue('--desk-cell')) || 104;
|
|
228
|
+
const row = parseFloat(cs.getPropertyValue('--desk-row')) || cell;
|
|
229
|
+
const room = grid.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
|
|
230
|
+
const view = fit(list, { room, cell, gap, editing });
|
|
231
|
+
const n = view.cols;
|
|
206
232
|
cols = n;
|
|
207
|
-
|
|
233
|
+
/* Its cells a little bigger or smaller, the rows as much, the whole centred; or every column, from the left. */
|
|
234
|
+
grid.style.gridTemplateColumns = view.cell ? `repeat(${n}, ${view.cell}px)` : `repeat(${n}, minmax(0, 1fr))`;
|
|
235
|
+
grid.style.justifyContent = view.cell ? 'center' : '';
|
|
236
|
+
grid.style.gridAutoRows = view.cell ? `${Math.round((row * view.cell) / cell)}px` : '';
|
|
208
237
|
grid.classList.toggle('desk-editing', editing);
|
|
209
|
-
const
|
|
210
|
-
const lay = layout(list, n); pos = lay.pos;
|
|
238
|
+
const lay = layout(view.order === 'reading' ? reading(list) : list, n); pos = lay.pos;
|
|
211
239
|
const nodes = [];
|
|
212
240
|
if (editing) {
|
|
213
241
|
for (let r = 1; r <= lay.rows + 2; r++) for (let c = 1; c <= n; c++) if (!lay.occ.has(`${c},${r}`)) {
|
|
@@ -475,7 +503,8 @@
|
|
|
475
503
|
tidyB.addEventListener('click', () => { items = tidy(items, pos); changed(); });
|
|
476
504
|
add.addEventListener('click', openAdd);
|
|
477
505
|
/* The screen narrower or wider: as many columns as it holds now (the places kept are not touched). */
|
|
478
|
-
|
|
506
|
+
let seenWidth = 0;
|
|
507
|
+
const watch = typeof ResizeObserver === 'function' ? new ResizeObserver(() => { if (ready && grid.clientWidth !== seenWidth) { seenWidth = grid.clientWidth; render(); } }) : null;
|
|
479
508
|
watch?.observe(grid);
|
|
480
509
|
|
|
481
510
|
/* READ: the desk kept; none yet, the home cards as they are today (nothing disappears); the
|
|
@@ -498,5 +527,5 @@
|
|
|
498
527
|
};
|
|
499
528
|
}
|
|
500
529
|
|
|
501
|
-
window.clavariumDesk = { layout, moveTo, moveBy, tidy, merge, unfold, takeOut, remove, addNew, idsOf, dropEmpty, Desk };
|
|
530
|
+
window.clavariumDesk = { layout, fit, reading, moveTo, moveBy, tidy, merge, unfold, takeOut, remove, addNew, idsOf, dropEmpty, Desk };
|
|
502
531
|
})();
|
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; }
|