clavarium 0.2.16 → 0.2.17-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/launch/claude-pulse.mjs +6 -3
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/guide.mjs +1 -1
- package/server/main.mjs +13 -2
- package/server/talk.mjs +2 -0
- package/server/toolbox.mjs +20 -2
- package/web/app.js +1 -0
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Written only when it changes, readable by its owner alone. A file that is
|
|
7
7
|
* not a JSON object is not touched (exit 3), like json-set.
|
|
8
8
|
*
|
|
9
|
-
* The hooks print nothing
|
|
10
|
-
* agent, and a failing one may stop it.
|
|
9
|
+
* The hooks never fail, and print nothing but the Stop hook's answer: a
|
|
10
|
+
* hook's output may reach the agent, and a failing one may stop it.
|
|
11
11
|
*/
|
|
12
12
|
import { readFileSync, writeFileSync, mkdirSync, renameSync } from 'node:fs';
|
|
13
13
|
import { dirname, join, isAbsolute } from 'node:path';
|
|
@@ -16,8 +16,11 @@ import { homedir } from 'node:os';
|
|
|
16
16
|
const [chat] = process.argv.slice(2);
|
|
17
17
|
if (!chat || !isAbsolute(chat) || !/^[A-Za-z0-9._/-]+$/.test(chat)) { console.error('usage: claude-pulse <the chat folder, a whole path>'); process.exit(64); }
|
|
18
18
|
const ours = (end) => `parley pulse${end ? ' --end' : ''} --dir ${chat} >/dev/null 2>&1 || true`;
|
|
19
|
+
/* Stopping while its chat still says it works, it is asked once to say where it is: what parley prints
|
|
20
|
+
there is that hook's answer (a decision), so it is not thrown away; it never fails. */
|
|
21
|
+
const stopping = `parley pulse --end --stop-check --dir ${chat} 2>/dev/null || true`;
|
|
19
22
|
/* Notification: it asks the person in its terminal (leave to act), or waits for them: not working. */
|
|
20
|
-
const WANTED = { PreToolUse: ours(false), UserPromptSubmit: ours(false), Stop:
|
|
23
|
+
const WANTED = { PreToolUse: ours(false), UserPromptSubmit: ours(false), Stop: stopping, Notification: ours(true) };
|
|
21
24
|
const isOurs = (h) => typeof h?.command === 'string' && /^parley pulse\b/.test(h.command);
|
|
22
25
|
|
|
23
26
|
const at = join(homedir(), '.claude', 'settings.json');
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17-next.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.17-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-parley": "0.
|
|
14
|
+
"clavarium-parley": "0.12.0-next.1",
|
|
15
15
|
"mermaid": "11.17.2",
|
|
16
16
|
"node-pty": "^1.1.0",
|
|
17
17
|
"pdfjs-dist": "6.4.299",
|
|
@@ -686,9 +686,9 @@
|
|
|
686
686
|
}
|
|
687
687
|
},
|
|
688
688
|
"node_modules/clavarium-parley": {
|
|
689
|
-
"version": "0.
|
|
690
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.
|
|
691
|
-
"integrity": "sha512-
|
|
689
|
+
"version": "0.12.0-next.1",
|
|
690
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.12.0-next.1.tgz",
|
|
691
|
+
"integrity": "sha512-3MPHl35f4jaoB9QTObWM7fUC7J3FNPmXh0setpVKbWUeXbP9cvH4R30u9GHSrfYQUbq4Hrk0Z4mO7/MG/NWPqA==",
|
|
692
692
|
"license": "MIT",
|
|
693
693
|
"bin": {
|
|
694
694
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17-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.",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
|
-
"clavarium-parley": "0.
|
|
47
|
+
"clavarium-parley": "0.12.0-next.1",
|
|
48
48
|
"mermaid": "11.17.2",
|
|
49
49
|
"node-pty": "^1.1.0",
|
|
50
50
|
"pdfjs-dist": "6.4.299",
|
package/server/guide.mjs
CHANGED
|
@@ -115,7 +115,7 @@ export function ownText({ name, tool, workKept, resources = [], chat, online, se
|
|
|
115
115
|
out.push(`- ${repo}: its origin, read-only and kept up to date, is ${origin}.${auto} git -C ${repo} fetch ${origin} '+refs/heads/*:refs/remotes/origin/*'`);
|
|
116
116
|
}
|
|
117
117
|
out.push(!chat ? '- Chat with the person: off. Do not use parley.'
|
|
118
|
-
: '- Chat with the person: on. Parley is installed: run parley guide.');
|
|
118
|
+
: '- Chat with the person: on. Parley is installed: run parley guide. When you were given Parley as your own tools (MCP: tell, ask, doing, status...), use them to talk to the person, and say with doing what you do at each new step; the parley command does the same.');
|
|
119
119
|
/* How Parley is used is Parley's to say (parley guide); what is here is this chat's: it renders Markdown. */
|
|
120
120
|
if (chat) out.push('- The chat shows Markdown (lists, tables, "> [!IMPORTANT]") and pictures of /work: .');
|
|
121
121
|
out.push(online === false ? '- Internet: off.' : '- Internet: on.');
|
package/server/main.mjs
CHANGED
|
@@ -221,7 +221,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
221
221
|
const gitAccess = new GitAccess({ vault, dataDir, ...(gitSsh ? { ssh: gitSsh } : {}) });
|
|
222
222
|
/* The tools every machine sees at /tools, read-only: see toolbox.mjs. */
|
|
223
223
|
/* With /tools/CLAVARIUM.md in it: where a tool is, the same for all (guide.mjs). */
|
|
224
|
-
const toolbox = new Toolbox({ host: asHost, vms, mntDir, notes: () => commonText() })
|
|
224
|
+
const toolbox = new Toolbox({ host: asHost, vms, mntDir, notes: () => commonText(), launched: new Store(`${dataDir}/launched.json`),
|
|
225
|
+
launches: (name) => Boolean(tools.find((t) => t.id === all.list().find((c) => c.name === name)?.tool)?.launch) });
|
|
225
226
|
const folders = resources ?? new Resources({ store: new Store(`${dataDir}/resources.json`), vms, host: asHost, dataDir, mntDir, grants, access: gitAccess, toolbox });
|
|
226
227
|
/* The ready-made machine new conversations are copied from, kept fresh
|
|
227
228
|
in the background: see shelf.mjs. Tidied up at start, without making
|
|
@@ -313,7 +314,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
313
314
|
await rules;
|
|
314
315
|
};
|
|
315
316
|
/* The launcher of its tool, in /tools, before it starts: repaired when missing. */
|
|
316
|
-
all.launcherReady = (name, file) => toolbox.launcherIn(name, file);
|
|
317
|
+
all.launcherReady = async (name, file) => { const why = await toolbox.launcherIn(name, file); if (!why) toolbox.started(name); return why; };
|
|
317
318
|
all.through = [RUNNER];
|
|
318
319
|
/* Mailboxes kept as folders: brought up to date now and then, never
|
|
319
320
|
because a tool asked. */
|
|
@@ -370,6 +371,16 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
370
371
|
all.renewed = (name, text, running) => talk.renewed(name, text, running);
|
|
371
372
|
/* A device given a conversation that talks through the app talks there too. */
|
|
372
373
|
door.talk = talk;
|
|
374
|
+
/* AFTER AN UPDATE, the machines that run get the new tools at once (parley, docket: they serve from
|
|
375
|
+
their next command); a tool started with older launchers is told, in its chat, that a restart
|
|
376
|
+
gives it the rest (its hooks, its MCP servers: read only when it starts). Nothing is restarted. */
|
|
377
|
+
void hostSteps.then(async () => {
|
|
378
|
+
for (const name of all.awake()) {
|
|
379
|
+
await toolbox.installIn(name).catch(() => {});
|
|
380
|
+
if (!toolbox.stale(name)) continue;
|
|
381
|
+
try { if (talk.event(name, { kind: 'tools-updated', text: 'New tools are installed in its machine; some of them reach its tool only when it starts again: restart it to have them all (its session is taken up again).', topic: 'Tools', actions: ['restart'] })) toolbox.told(name); } catch { /* its chat is off */ }
|
|
382
|
+
}
|
|
383
|
+
});
|
|
373
384
|
/* The health of each machine, and folders that came loose put back: see health.mjs. */
|
|
374
385
|
const health = new Health({ vms, conversations: all, resources: folders, seen: new Store(`${dataDir}/health-seen.json`), ...(healthSettleMs === undefined ? {} : { settleMs: healthSettleMs }) });
|
|
375
386
|
const stopHealth = health.start(healthEveryMs);
|
package/server/talk.mjs
CHANGED
|
@@ -125,6 +125,8 @@ export const EVENT_LEVELS = Object.freeze({
|
|
|
125
125
|
wakeup: 'trace',
|
|
126
126
|
'machine-problem': 'needs-you',
|
|
127
127
|
restarted: 'news',
|
|
128
|
+
/* New tools in its machine that its tool reads only when it starts: a restart recommended (main.mjs). */
|
|
129
|
+
'tools-updated': 'news',
|
|
128
130
|
});
|
|
129
131
|
const TONES = ['warn', 'bad'];
|
|
130
132
|
/* Bounds of a line: its text, its group (topic), what the grouped line says of it (brief), its buttons. */
|
package/server/toolbox.mjs
CHANGED
|
@@ -57,7 +57,7 @@ export const integrityOf = (bytes) => `sha512-${createHash('sha512').update(byte
|
|
|
57
57
|
const firstLine = (text) => String(text ?? '').trim().split('\n').filter(Boolean).pop()?.slice(0, 200) ?? '';
|
|
58
58
|
|
|
59
59
|
export class Toolbox {
|
|
60
|
-
#host; #vms; #mnt; #uid; #gid; #sources; #notes; #launchers; #index = null;
|
|
60
|
+
#host; #vms; #mnt; #uid; #gid; #sources; #notes; #launchers; #launched; #launches; #index = null; #launchHash = '';
|
|
61
61
|
/* What is known of Parley in each machine, as the index is now:
|
|
62
62
|
conversation -> { sha256, why } (why: '' installed, or why it cannot be,
|
|
63
63
|
such as a machine without npm: not asked again at each opening). */
|
|
@@ -67,7 +67,10 @@ export class Toolbox {
|
|
|
67
67
|
`notes(find)`: the text of /tools/CLAVARIUM.md, given how to find a
|
|
68
68
|
tool of the index; none when not given. Nothing of one conversation
|
|
69
69
|
may be in it: every machine reads it. */
|
|
70
|
-
|
|
70
|
+
/* `launched`: a Store of what each tool was started with (its launchers' fingerprint): see stale(). */
|
|
71
|
+
/* `launches(name)`: does its tool start through a launcher? (only those read one) */
|
|
72
|
+
constructor({ host, vms, mntDir, uid = process.getuid(), gid = process.getgid(), sources = parleySource(), notes = null, launchers = LAUNCHERS, launched = null, launches = () => false }) {
|
|
73
|
+
this.#launched = launched; this.#launches = launches;
|
|
71
74
|
this.#host = host; this.#vms = vms; this.#mnt = mntDir; this.#uid = uid; this.#gid = gid; this.#sources = sources; this.#notes = notes; this.#launchers = launchers;
|
|
72
75
|
}
|
|
73
76
|
|
|
@@ -108,6 +111,7 @@ export class Toolbox {
|
|
|
108
111
|
if (!there || !there.equals(bytes)) { writeFileSync(`${launch}/.${n}.new`, bytes, { mode: 0o755 }); renameSync(`${launch}/.${n}.new`, `${launch}/${n}`); }
|
|
109
112
|
}
|
|
110
113
|
for (const n of readdirSync(launch)) if (!wanted.includes(n)) rmSync(`${launch}/${n}`, { recursive: true, force: true });
|
|
114
|
+
this.#launchHash = createHash('sha256').update(wanted.sort().map((n) => `${n}\n${readFileSync(join(this.#launchers, n), 'utf8')}`).join('\n')).digest('hex');
|
|
111
115
|
const kept = new Set([...tools.map((t) => t.file), 'index.json', LAUNCH, ...(this.#notes ? [NOTES] : [])]);
|
|
112
116
|
for (const name of readdirSync(dir)) if (!kept.has(name)) rmSync(`${dir}/${name}`, { recursive: true, force: true });
|
|
113
117
|
const index = { tools };
|
|
@@ -141,6 +145,20 @@ export class Toolbox {
|
|
|
141
145
|
return run;
|
|
142
146
|
}
|
|
143
147
|
|
|
148
|
+
/* WHAT ITS TOOL WAS STARTED WITH. A tool reads its launcher's settings (its hooks, its MCP servers)
|
|
149
|
+
only when it starts; the tools themselves (parley, docket) are installed again in a machine that
|
|
150
|
+
runs, and serve at once. `started(name)`: its tool starts with the launchers there now.
|
|
151
|
+
`stale(name)`: it was started with others, older -- a restart gives it what is new; said once
|
|
152
|
+
(`told`) for each version of the launchers. */
|
|
153
|
+
started(name) { if (this.#launched && this.#launchHash) this.#launched.put({ name, hash: this.#launchHash, told: '' }); }
|
|
154
|
+
/* Started before any was recorded (an older Clavarium): older too. */
|
|
155
|
+
stale(name) {
|
|
156
|
+
if (!this.#launched || !this.#launchHash || !this.#launches(name)) return false;
|
|
157
|
+
const r = this.#launched.get(name);
|
|
158
|
+
return r?.hash !== this.#launchHash && r?.told !== this.#launchHash;
|
|
159
|
+
}
|
|
160
|
+
told(name) { if (this.#launched) this.#launched.put({ ...(this.#launched.get(name) ?? { name, hash: '' }), told: this.#launchHash }); }
|
|
161
|
+
|
|
144
162
|
/* Its machine was built again, or restarted: looked at again at its next opening. */
|
|
145
163
|
forget(conversation) { this.#installed.delete(conversation); }
|
|
146
164
|
|
package/web/app.js
CHANGED
|
@@ -2475,6 +2475,7 @@
|
|
|
2475
2475
|
['wakeup', 'Wake-up', 'A wake-up was typed'],
|
|
2476
2476
|
['machine-problem', 'Machine in trouble', 'Memory, disk, no answer, a failed restart'],
|
|
2477
2477
|
['restarted', 'Machine restarted', 'Restarted or built again'],
|
|
2478
|
+
['tools-updated', 'New tools', 'After an update: a restart gives its tool all of them'],
|
|
2478
2479
|
];
|
|
2479
2480
|
const THREAD_LEVELS = [['needs-you', 'Needs you'], ['news', 'News'], ['trace', 'Trace']];
|
|
2480
2481
|
async function paintThreadLevels() {
|