clavarium 0.2.24-next.2 → 0.2.24-next.3
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/README.md +6 -2
- package/deploy/updater.mjs +1 -1
- package/npm-shrinkwrap.json +20 -6
- package/package.json +3 -2
- package/server/api.mjs +16 -2
- package/server/binders.mjs +90 -0
- package/server/door.mjs +4 -2
- package/server/guide.mjs +12 -5
- package/server/main.mjs +15 -6
- package/server/parley.mjs +2 -0
- package/server/secrets.mjs +2 -0
- package/server/talk.mjs +71 -10
- package/server/voice.mjs +14 -5
- package/web/app.js +79 -3
- package/web/index.html +11 -1
- package/web/style.css +4 -0
package/README.md
CHANGED
|
@@ -103,8 +103,12 @@ Built slice by slice; the plan is in `blueprint/architecture.html`, tab
|
|
|
103
103
|
ways: what the tool shows, and what the person attaches to a message (put
|
|
104
104
|
under /work/.parley/files/, the tool given its path). What is wrong with its
|
|
105
105
|
machine, and its restarts, are grey lines in the thread, with what can be
|
|
106
|
-
done; after a restart the tool is told once to read the
|
|
107
|
-
(`parley read --
|
|
106
|
+
done; after a restart the tool is told once to read the end of the thread
|
|
107
|
+
(`parley read --last 100`, or as the owner chose in Settings), and reads
|
|
108
|
+
further back as it needs. The page shows the end of the thread too (the
|
|
109
|
+
last 200 messages, or as each device chose), "Earlier messages" on demand;
|
|
110
|
+
the search looks in the whole thread, and each look brings only what
|
|
111
|
+
changed. Nothing is ever cut or summarised. The server keeps its own copy of the thread, out of
|
|
108
112
|
the machine: a line the tool rewrites or deletes in /work/.parley, the
|
|
109
113
|
owner's too, is shown as it was, and the thread says "History changed
|
|
110
114
|
here". Off by default, per conversation; what the tool
|
package/deploy/updater.mjs
CHANGED
|
@@ -61,7 +61,7 @@ export { ensureTunnel, tunnelUnit, relayOfUnit, TUNNEL_UNIT, TUNNEL_PROGRAM };
|
|
|
61
61
|
export const PATHS = { code: '/opt/clavarium', conf: '/etc/clavarium/update.conf', stateDir: '/var/lib/clavarium/update', data: '/home/clavarium', host: '/usr/local/sbin/clavarium-host', gitRead: '/usr/lib/clavarium/git-read', tunnel: '/usr/local/sbin/clavarium-tunnel' };
|
|
62
62
|
export const NAME = 'clavarium';
|
|
63
63
|
/* Where each package checked here must have been built: its provenance says so. */
|
|
64
|
-
export const REPOS = { clavarium: 'https://github.com/clavarium/clavarium', 'clavarium-parley': 'https://github.com/clavarium/clavarium-parley', 'clavarium-docket': 'https://github.com/clavarium/clavarium-docket' };
|
|
64
|
+
export const REPOS = { clavarium: 'https://github.com/clavarium/clavarium', 'clavarium-parley': 'https://github.com/clavarium/clavarium-parley', 'clavarium-docket': 'https://github.com/clavarium/clavarium-docket', 'clavarium-binder': 'https://github.com/clavarium/clavarium-binder' };
|
|
65
65
|
export const VERSION = /^\d{1,4}\.\d{1,4}\.\d{1,6}(-[0-9A-Za-z.-]{1,40})?$/;
|
|
66
66
|
export const LOCAL = /^local-\d{8}-\d{6}$/;
|
|
67
67
|
export const MODES = ['auto', 'asap', 'ask', 'off'];
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.24-next.
|
|
3
|
+
"version": "0.2.24-next.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.24-next.
|
|
9
|
+
"version": "0.2.24-next.3",
|
|
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.0-next.1",
|
|
14
15
|
"clavarium-docket": "0.1.0",
|
|
15
|
-
"clavarium-parley": "0.15.0-next.
|
|
16
|
+
"clavarium-parley": "0.15.0-next.3",
|
|
16
17
|
"mermaid": "11.17.2",
|
|
17
18
|
"node-pty": "^1.1.0",
|
|
18
19
|
"pdfjs-dist": "6.4.299",
|
|
@@ -686,6 +687,19 @@
|
|
|
686
687
|
"node": ">=6"
|
|
687
688
|
}
|
|
688
689
|
},
|
|
690
|
+
"node_modules/clavarium-binder": {
|
|
691
|
+
"version": "0.1.0-next.1",
|
|
692
|
+
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.0-next.1.tgz",
|
|
693
|
+
"integrity": "sha512-bwqNIICb23royK8h+qI8NuOmMaZVop3lTSAfOC9cCxY0PmHLLfIMhsFqteL65miL64eTtJdTFJo2yYIZJWQTZQ==",
|
|
694
|
+
"license": "MIT",
|
|
695
|
+
"bin": {
|
|
696
|
+
"binder": "bin/binder.mjs",
|
|
697
|
+
"binder-mcp": "server/binder.mjs"
|
|
698
|
+
},
|
|
699
|
+
"engines": {
|
|
700
|
+
"node": ">=22"
|
|
701
|
+
}
|
|
702
|
+
},
|
|
689
703
|
"node_modules/clavarium-docket": {
|
|
690
704
|
"version": "0.1.0",
|
|
691
705
|
"resolved": "https://registry.npmjs.org/clavarium-docket/-/clavarium-docket-0.1.0.tgz",
|
|
@@ -700,9 +714,9 @@
|
|
|
700
714
|
}
|
|
701
715
|
},
|
|
702
716
|
"node_modules/clavarium-parley": {
|
|
703
|
-
"version": "0.15.0-next.
|
|
704
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.15.0-next.
|
|
705
|
-
"integrity": "sha512-
|
|
717
|
+
"version": "0.15.0-next.3",
|
|
718
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.15.0-next.3.tgz",
|
|
719
|
+
"integrity": "sha512-OxTa1hJlMRLKc/1UIVYvFCRAFcbPIsjD20MTCkStupdn8BzvAx6FfB7nV6lTvXEvVjIStqOBVfhctr8MS4aQ0g==",
|
|
706
720
|
"license": "MIT",
|
|
707
721
|
"bin": {
|
|
708
722
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.24-next.
|
|
3
|
+
"version": "0.2.24-next.3",
|
|
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,8 +44,9 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
|
+
"clavarium-binder": "0.1.0-next.1",
|
|
47
48
|
"clavarium-docket": "0.1.0",
|
|
48
|
-
"clavarium-parley": "0.15.0-next.
|
|
49
|
+
"clavarium-parley": "0.15.0-next.3",
|
|
49
50
|
"mermaid": "11.17.2",
|
|
50
51
|
"node-pty": "^1.1.0",
|
|
51
52
|
"pdfjs-dist": "6.4.299",
|
package/server/api.mjs
CHANGED
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
* POST /api/conversations/<name>/chat-name {name}: the name the chat gives its tool ('' : the neutral word of the dictionary)
|
|
21
21
|
* POST /api/conversations/<name>/voice-mark {on}: what is dictated into its terminal starts with a microphone sign (AI tools only)
|
|
22
22
|
* POST /api/conversations/<name>/talk/file?name=<file name> the body IS a file the person attaches -> {path, name, size}
|
|
23
|
+
* GET /api/conversations/<name>/talk?last=|days=|before=|from=|since= a part of its chat: the newest messages, those of the
|
|
24
|
+
* last days, the page before a message, up to a message found, what changed since a cursor
|
|
25
|
+
* GET /api/conversations/<name>/talk/search?q= its whole chat searched: {matches: [{id, at, from, kind, text}], count}
|
|
26
|
+
* GET /api/talk/window what a tool reads of its chat after a restart: {ai, default, choices}
|
|
27
|
+
* POST /api/talk/window {ai: 'messages:100'|'messages:200'|'messages:500'|'days:1'|'days:3'|'days:7'}
|
|
23
28
|
* GET /api/talk/thread what a chat shows of each kind of event: {levels, defaults, choices}
|
|
24
29
|
* POST /api/talk/thread {levels: {kind: 'needs-you'|'news'|'trace'}}: the owner's choice, whole or partial
|
|
25
30
|
* GET /api/conversations/<name>/guide what its tool is told about where it is: the exact texts, the owner's lines
|
|
@@ -56,6 +61,8 @@
|
|
|
56
61
|
* POST /api/conversations/<c>/git/<name>/auto {branches?, quietSeconds?, perHour?, create?, checks?, sure?}
|
|
57
62
|
* POST /api/git/<name>/refresh fetch the origin into its mirror now
|
|
58
63
|
* POST /api/git/<name>/check {head, target?}: run the checks in the machine
|
|
64
|
+
* GET /api/binder/people who may own a record, or be given a list; and the number of changes so far
|
|
65
|
+
* POST /api/binder {op, args}: the owner's change to the lists (binders.mjs), as Binder's keeper answers it
|
|
59
66
|
* POST /api/resources/<name>/remove only when attached nowhere; content is moved aside
|
|
60
67
|
* POST /api/conversations/<name>/resources {resource, access: read|write|none}
|
|
61
68
|
* POST /api/conversations/<name>/share {rights?} -> {url, minutes, qr}: a one-use pairing code;
|
|
@@ -137,7 +144,7 @@ function readBody(request, max = BODY_MAX) {
|
|
|
137
144
|
}
|
|
138
145
|
|
|
139
146
|
/* Returns true when the request was an API request (answered here). */
|
|
140
|
-
export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi) {
|
|
147
|
+
export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders) {
|
|
141
148
|
const { pathname } = new URL(request.url ?? '/', 'http://local');
|
|
142
149
|
if (!pathname.startsWith('/api/')) return false;
|
|
143
150
|
let send = (status, body) => {
|
|
@@ -273,6 +280,7 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
273
280
|
if (pathname === '/api/wifi' && wifi) return send(200, await wifi.status()), true;
|
|
274
281
|
if (pathname === '/api/wifi/scan' && wifi) return send(200, await wifi.scan()), true;
|
|
275
282
|
if (pathname === '/api/operators') return send(200, team ? { operators: team.list(), me: identity } : { local: true }), true;
|
|
283
|
+
if (pathname === '/api/binder/people' && binders) return send(200, { people: binders.people(identity), changes: binders.changes() }), true;
|
|
276
284
|
if (pathname === '/api/certificate' && certificate) return send(200, await certificate.about({ fresh: query.get('fresh') === '1' })), true;
|
|
277
285
|
/* This server's disk and memory (capacity.mjs): everything for Settings; only whether it is high for the list. */
|
|
278
286
|
if (pathname === '/api/server' && capacity) return send(200, await capacity.about()), true;
|
|
@@ -296,10 +304,13 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
296
304
|
if (pathname === '/api/talk/words' && talk) return send(200, talk.words(query.get('lang') ?? 'en')), true;
|
|
297
305
|
if (pathname === '/api/talk/settings' && talk) return send(200, talk.settings()), true;
|
|
298
306
|
if (pathname === '/api/talk/thread' && talk) return send(200, talk.thread()), true;
|
|
307
|
+
if (pathname === '/api/talk/window' && talk) return send(200, talk.window()), true;
|
|
308
|
+
const searched = /^\/api\/conversations\/([^/]+)\/talk\/search$/.exec(pathname);
|
|
309
|
+
if (searched && talk) return send(200, talk.search(decodeURIComponent(searched[1]), query.get('q') ?? '')), true;
|
|
299
310
|
const guided = /^\/api\/conversations\/([^/]+)\/guide$/.exec(pathname);
|
|
300
311
|
if (guided && guide) return send(200, guide.about(decodeURIComponent(guided[1]))), true;
|
|
301
312
|
const talked = /^\/api\/conversations\/([^/]+)\/talk$/.exec(pathname);
|
|
302
|
-
if (talked && talk) return send(200, talk.of(decodeURIComponent(talked[1]))), true;
|
|
313
|
+
if (talked && talk) return send(200, talk.of(decodeURIComponent(talked[1]), query)), true;
|
|
303
314
|
/* Its docket: the reminders its tool set, the newest events (dockets.mjs). */
|
|
304
315
|
const docketRead = /^\/api\/conversations\/([^/]+)\/docket$/.exec(pathname);
|
|
305
316
|
if (docketRead && wakeups) return send(200, wakeups.docketOf(decodeURIComponent(docketRead[1]))), true;
|
|
@@ -345,6 +356,8 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
345
356
|
/* What was done, once it was done: said in What happened (events.mjs), for those worth saying. */
|
|
346
357
|
if (events) { const answer = send; send = (status, out) => { if (status < 300) { try { events.fromRequest(pathname, body, identity, out); } catch { /* never in the way */ } } answer(status, out); }; }
|
|
347
358
|
if (pathname === '/api/conversations') { await conversations.admit?.(body); return send(201, conversations.create(body)), true; }
|
|
359
|
+
/* The lists: every answer is 200, a refusal said in it ({ ok: false, text }), as the keeper says it to a tool. */
|
|
360
|
+
if (pathname === '/api/binder' && binders) return send(200, binders.act(body.op, body.args, identity)), true;
|
|
348
361
|
/* Who gets what, and a whole setup in one file: see setup.mjs. */
|
|
349
362
|
if (pathname.startsWith('/api/setup/') || pathname === '/api/flows/name') {
|
|
350
363
|
if (!setup) return send(404, { error: 'Not found.' }), true;
|
|
@@ -426,6 +439,7 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
426
439
|
if (pathname === '/api/alerts/test' && alerts) return send(200, { reached: await alerts.tell({ title: instance?.name() ?? 'Clavarium', body: 'This is what an alert looks like.', url: '/' }) }), true;
|
|
427
440
|
if (pathname === '/api/talk/settings' && talk) return send(200, talk.setWords({ lang: body.lang, own: body.own })), true;
|
|
428
441
|
if (pathname === '/api/talk/thread' && talk) return send(200, talk.setThread({ levels: body.levels })), true;
|
|
442
|
+
if (pathname === '/api/talk/window' && talk) return send(200, talk.setWindow({ ai: body.ai })), true;
|
|
429
443
|
const guiding = /^\/api\/conversations\/([^/]+)\/guide(\/tell)?$/.exec(pathname);
|
|
430
444
|
if (guiding && guide) {
|
|
431
445
|
const conversation = decodeURIComponent(guiding[1]);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* BINDER, AS CLAVARIUM USES IT (clavarium-binder, a project of its own, an
|
|
2
|
+
* npm dependency installed in every machine as Parley and Docket are:
|
|
3
|
+
* toolbox.mjs). Lists of records -- batches, tasks, customers, people --
|
|
4
|
+
* kept together by the owner and the tools of the conversations.
|
|
5
|
+
*
|
|
6
|
+
* THE BINDER IS KEPT HERE, in this server's data (binder/), never in a
|
|
7
|
+
* machine: what a tool could write, it could rewrite. A tool asks through
|
|
8
|
+
* its work folder's .binder (beside .parley and .docket), and is answered
|
|
9
|
+
* there; who asks is said by the folder -- conversation:<name> -- never by
|
|
10
|
+
* the ask. The owner changes it from the page (Lists).
|
|
11
|
+
*
|
|
12
|
+
* A TOOL SEES ONLY THE LISTS IT WAS GIVEN (read, or change), and never
|
|
13
|
+
* approves: a gate (Batches: "Approved") is the owner's tick.
|
|
14
|
+
*
|
|
15
|
+
* ITS DOCKET IS TOLD (dockets.mjs) when the owner gives it a record, approves
|
|
16
|
+
* one it owns, or a record it owns comes due.
|
|
17
|
+
*/
|
|
18
|
+
import { mkdirSync, lstatSync } from 'node:fs';
|
|
19
|
+
import { keeper } from 'clavarium-binder/host';
|
|
20
|
+
|
|
21
|
+
export const FOLDER = '.binder';
|
|
22
|
+
export const PUMP_MS = 1000;
|
|
23
|
+
export const DUE_MS = 30_000;
|
|
24
|
+
const AGENT = 'conversation:';
|
|
25
|
+
|
|
26
|
+
export class Binders {
|
|
27
|
+
#keeper; #resources; #conversations; #dockets; #team; #timers = []; #changes = 0; #ready = new Set();
|
|
28
|
+
|
|
29
|
+
/* `conversations()`: the names of the conversations. `dockets`: Dockets (optional): a tool told.
|
|
30
|
+
`team`: the operators (optional), each a person who may own a record. */
|
|
31
|
+
constructor({ dataDir, resources, conversations, dockets = null, team = null, now = () => Date.now() }) {
|
|
32
|
+
this.#resources = resources; this.#conversations = conversations; this.#dockets = dockets; this.#team = team;
|
|
33
|
+
this.#keeper = keeper(`${dataDir}/binder`, { sides: () => this.#sides(), now });
|
|
34
|
+
this.#keeper.store.onChange((line) => { this.#changes++; this.#heard(line); });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Each conversation's folder, made when missing; one that is anything but a folder of its own is left out. */
|
|
38
|
+
#sides() {
|
|
39
|
+
const out = [];
|
|
40
|
+
for (const name of this.#conversations()) {
|
|
41
|
+
let dir;
|
|
42
|
+
try { dir = `${this.#resources.workFolder(name)}/${FOLDER}`; } catch { continue; }
|
|
43
|
+
const info = lstatSync(dir, { throwIfNoEntry: false });
|
|
44
|
+
if (info === undefined) { try { mkdirSync(dir); } catch { continue; } }
|
|
45
|
+
else if (!info.isDirectory() || info.isSymbolicLink()) continue;
|
|
46
|
+
out.push({ dir, who: { id: `${AGENT}${name}`, kind: 'agent', name } });
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* A tool told, through its docket, of what concerns it. */
|
|
52
|
+
#tell(id, text) {
|
|
53
|
+
if (!this.#dockets || !id.startsWith(AGENT)) return;
|
|
54
|
+
const name = id.slice(AGENT.length);
|
|
55
|
+
try { this.#dockets.post(name, { kind: 'binder', text }); } catch { /* its docket may be off */ }
|
|
56
|
+
}
|
|
57
|
+
#heard(line) {
|
|
58
|
+
if (line.by?.kind !== 'person' || !line.record) return;
|
|
59
|
+
let r;
|
|
60
|
+
try { r = this.#keeper.store.record(line.record, line.by).record; } catch { return; }
|
|
61
|
+
if (line.op === 'edit' && Array.isArray(line.change?.owners)) {
|
|
62
|
+
for (const id of line.change.owners) this.#tell(id, `Given to you in Binder: #${r.id} ${r.title} (binder get ${r.id})`);
|
|
63
|
+
}
|
|
64
|
+
if (line.op === 'move' && r.approved) for (const id of r.owners) this.#tell(id, `Approved in Binder: #${r.id} ${r.title}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
start() {
|
|
68
|
+
this.#timers.push(setInterval(() => { try { this.#keeper.pump(); } catch { /* the next turn */ } }, PUMP_MS));
|
|
69
|
+
this.#timers.push(setInterval(() => {
|
|
70
|
+
try { for (const { record: r } of this.#keeper.due()) for (const id of r.owners) this.#tell(id, `Due in Binder: #${r.id} ${r.title} (${r.due})`); } catch { /* the next turn */ }
|
|
71
|
+
}, DUE_MS));
|
|
72
|
+
for (const t of this.#timers) t.unref?.();
|
|
73
|
+
return () => { for (const t of this.#timers) clearInterval(t); this.#timers = []; };
|
|
74
|
+
}
|
|
75
|
+
pump() { return this.#keeper.pump(); }
|
|
76
|
+
|
|
77
|
+
/* The owner, from the page: `identity` is who signed in ('' on a server without sign-in). */
|
|
78
|
+
act(op, args, identity = '') {
|
|
79
|
+
const who = { id: `person:${identity || 'owner'}`, kind: 'person', name: identity || 'Owner' };
|
|
80
|
+
return this.#keeper.act(String(op ?? ''), args && typeof args === 'object' ? args : {}, who);
|
|
81
|
+
}
|
|
82
|
+
/* Who may own a record, or be given a list. */
|
|
83
|
+
people(identity = '') {
|
|
84
|
+
const persons = (this.#team?.list?.() ?? []).map((o) => ({ id: `person:${String(o.email ?? o.id ?? '').toLowerCase()}`, kind: 'person', name: String(o.email ?? o.id ?? '') })).filter((p) => p.name);
|
|
85
|
+
if (!persons.length) persons.push({ id: `person:${identity || 'owner'}`, kind: 'person', name: identity || 'Owner' });
|
|
86
|
+
return [...persons, ...this.#conversations().map((name) => ({ id: `${AGENT}${name}`, kind: 'agent', name }))];
|
|
87
|
+
}
|
|
88
|
+
/* A number that moves with every change: the page reads again when it moved. */
|
|
89
|
+
changes() { return this.#changes; }
|
|
90
|
+
}
|
package/server/door.mjs
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
* GET .../files/thumb|text POST .../files/save|make|rename|move|remove|taken (see files.mjs)
|
|
21
21
|
* POST /c/api/<pairing>/leave the device removes this pairing itself
|
|
22
22
|
* GET /c/api/<pairing>/talk/words?lang=
|
|
23
|
-
* GET /c/api/<pairing>/conversations/<any>/talk POST the same {text, answers}
|
|
23
|
+
* GET /c/api/<pairing>/conversations/<any>/talk POST the same {text, answers}; ?last= ?days= ?before= ?from= ?since=: a part of it
|
|
24
|
+
* GET /c/api/<pairing>/conversations/<any>/talk/search?q= its whole chat searched
|
|
24
25
|
* POST /c/api/<pairing>/conversations/<any>/talk/remind
|
|
25
26
|
* POST /c/api/<pairing>/conversations/<any>/talk/react {to, reaction}: a reaction to a message of the tool (null: taken back)
|
|
26
27
|
* POST /c/api/<pairing>/conversations/<any>/talk/file?name= a file attached to a message
|
|
@@ -174,7 +175,8 @@ export async function handleDoor(request, response, { devices, conversations, re
|
|
|
174
175
|
if (talk && (route === '/talk/words' || talking)) need(part.chat !== null, 'the chat');
|
|
175
176
|
if (talk && request.method === 'GET' && route === '/talk/words') return send(200, talk.words(url.searchParams.get('lang') ?? 'en'));
|
|
176
177
|
if (talk && talking) {
|
|
177
|
-
if (request.method === 'GET' && !talking[1]) return send(200, talk.of(name));
|
|
178
|
+
if (request.method === 'GET' && !talking[1]) return send(200, talk.of(name, url.searchParams));
|
|
179
|
+
if (request.method === 'GET' && talking[1] === '/search') return send(200, talk.search(name, url.searchParams.get('q') ?? ''));
|
|
178
180
|
/* Reminding the tool and writing to it: a chat given to write in. Nothing else (turning it on, inviting the tool) is a device's. */
|
|
179
181
|
if (request.method === 'POST' && (talking[1] === undefined || talking[1] === '/remind' || talking[1] === '/file' || talking[1] === '/react')) need(part.chat === 'write', 'the chat to write in');
|
|
180
182
|
if (request.method === 'POST' && talking[1] === '/react') { const body = await readJson(request); return send(200, await talk.react(name, body.to, body.reaction ?? null)); }
|
package/server/guide.mjs
CHANGED
|
@@ -97,8 +97,9 @@ export function commonText() {
|
|
|
97
97
|
const list = (items) => items.join(', ');
|
|
98
98
|
|
|
99
99
|
/* THE PART OF ONE CONVERSATION, from its facts:
|
|
100
|
-
{ name, tool, workKept, resources: [{ name, access, type, origin }], chat, online, secrets: [names], lines }
|
|
101
|
-
|
|
100
|
+
{ name, tool, workKept, resources: [{ name, access, type, origin }], chat, online, secrets: [names], lines, reread }
|
|
101
|
+
`reread`: the command that reads the end of its chat after a restart (the owner's choice, talk.mjs). */
|
|
102
|
+
export function ownText({ name, tool, workKept, resources = [], chat, online, secrets = [], lines = [], reread }) {
|
|
102
103
|
const out = [`# This conversation: ${plain(name, 40)}`, ''];
|
|
103
104
|
if (tool) out.push(`- Tool running here: ${plain(tool, 40)}.`);
|
|
104
105
|
out.push(workKept ? '- /work is kept by the server: the person sees it in Files, and it outlives the machine.' : '- /work is on this machine\'s own disk: it goes with the machine.');
|
|
@@ -118,8 +119,12 @@ export function ownText({ name, tool, workKept, resources = [], chat, online, se
|
|
|
118
119
|
: '- 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
120
|
/* How Parley is used is Parley's to say (parley guide); what is here is this chat's: it renders Markdown. */
|
|
120
121
|
if (chat) out.push('- The chat shows Markdown (lists, tables, "> [!IMPORTANT]") and pictures of /work: .');
|
|
122
|
+
/* The thread is kept whole: after a restart, its end is read, and further back on demand. */
|
|
123
|
+
if (chat && reread) out.push(`- After a restart: ${plain(reread, 60)}, the end of the chat; it says how to read further back.`);
|
|
121
124
|
/* Its docket (dockets.mjs): what wakes it waits there until it says done or failed. */
|
|
122
125
|
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.');
|
|
126
|
+
/* Its lists (binders.mjs): kept on the server, asked for through .binder; a person approves. */
|
|
127
|
+
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.');
|
|
123
128
|
out.push(online === false ? '- Internet: off.' : '- Internet: on.');
|
|
124
129
|
if (secrets.length) out.push(`- Secrets given, by name only: ${list(secrets.map((s) => plain(s, 40)))}.`);
|
|
125
130
|
const own = lines.map((l) => plain(l)).filter(Boolean).slice(0, LINES_MAX);
|
|
@@ -182,10 +187,12 @@ const firstLine = (text) => String(text ?? '').trim().split('\n').filter(Boolean
|
|
|
182
187
|
const sha = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
|
|
183
188
|
|
|
184
189
|
export class Guide {
|
|
185
|
-
#store; #vms; #conversations; #resources; #secrets; #toolbox; #tools; #chat; #say; #written = new Map(); #pointed = new Set();
|
|
190
|
+
#store; #vms; #conversations; #resources; #secrets; #toolbox; #tools; #chat; #say; #reread; #written = new Map(); #pointed = new Set();
|
|
186
191
|
|
|
187
192
|
/* `chat(name)`: is its chat on. `say(name, line)`: types a line in its terminal (wakeups.mjs). */
|
|
188
|
-
|
|
193
|
+
/* `reread()`: the command its tool runs after a restart to read the end of its chat. */
|
|
194
|
+
constructor({ store, vms, conversations, resources, secrets = null, toolbox = null, tools = [], chat = () => false, say = async () => false, reread = () => null }) {
|
|
195
|
+
this.#reread = reread;
|
|
189
196
|
this.#store = store; this.#vms = vms; this.#conversations = conversations; this.#resources = resources; this.#secrets = secrets;
|
|
190
197
|
this.#toolbox = toolbox; this.#tools = tools; this.#chat = chat; this.#say = say;
|
|
191
198
|
}
|
|
@@ -207,7 +214,7 @@ export class Guide {
|
|
|
207
214
|
const type = this.#resources.get(r.name)?.type ?? 'folder';
|
|
208
215
|
return { name: r.name, access: r.access, type, origin: type === 'git' && this.#resources.hasOrigin?.(r.name) ? originFolder(r.name) : undefined };
|
|
209
216
|
});
|
|
210
|
-
return ownText({ name, tool: this.#tool(c)?.label ?? c.tool, workKept: c.work === 'kept', resources, chat: Boolean(this.#chat(name)), online: c.offline !== true, secrets: (this.#secrets?.given ?? this.#secrets?.of)?.call(this.#secrets, name) ?? [], lines: this.lines(name) });
|
|
217
|
+
return ownText({ name, tool: this.#tool(c)?.label ?? c.tool, workKept: c.work === 'kept', resources, chat: Boolean(this.#chat(name)), online: c.offline !== true, secrets: (this.#secrets?.given ?? this.#secrets?.of)?.call(this.#secrets, name) ?? [], lines: this.lines(name), reread: this.#reread() });
|
|
211
218
|
}
|
|
212
219
|
|
|
213
220
|
/* What the page shows: the exact texts, where each is, and the line in the tool's own file. */
|
package/server/main.mjs
CHANGED
|
@@ -63,6 +63,7 @@ import { Operators } from './operators.mjs';
|
|
|
63
63
|
import { HealthReact } from './healthreact.mjs';
|
|
64
64
|
import { MachinesMove } from './machinesmove.mjs';
|
|
65
65
|
import { Wifi } from './wifi.mjs';
|
|
66
|
+
import { Binders } from './binders.mjs';
|
|
66
67
|
import { ServerLogs } from './serverlogs.mjs';
|
|
67
68
|
import { History, STEP_MS as HISTORY_STEP_MS } from './history.mjs';
|
|
68
69
|
import { Events } from './events.mjs';
|
|
@@ -99,6 +100,11 @@ export const FILES = {
|
|
|
99
100
|
'/vendor/parley-ui.css': [packageFile(PARLEY, 'ui/parley-ui.css'), 'text/css; charset=utf-8'],
|
|
100
101
|
/* Its icons (Lucide, copied in Parley): the chat's, and this page's own. */
|
|
101
102
|
'/vendor/parley-icons.js': [packageFile(PARLEY, 'ui/parley-icons.js'), 'text/javascript; charset=utf-8'],
|
|
103
|
+
/* Binder's screen: it draws the lists, this page gives it a place (Lists). */
|
|
104
|
+
'/vendor/binder-ui.js': [packageFile('clavarium-binder', 'ui/binder-ui.js'), 'text/javascript; charset=utf-8'],
|
|
105
|
+
'/vendor/binder-ui.css': [packageFile('clavarium-binder', 'ui/binder-ui.css'), 'text/css; charset=utf-8'],
|
|
106
|
+
'/vendor/binder-en.json': [packageFile('clavarium-binder', 'ui/texts/en.json'), 'application/json; charset=utf-8'],
|
|
107
|
+
'/vendor/binder-fr.json': [packageFile('clavarium-binder', 'ui/texts/fr.json'), 'application/json; charset=utf-8'],
|
|
102
108
|
'/vendor/pdf.mjs': [packageFile('pdfjs-dist', 'build/pdf.min.mjs'), 'text/javascript; charset=utf-8'],
|
|
103
109
|
'/vendor/pdf.worker.mjs': [packageFile('pdfjs-dist', 'build/pdf.worker.min.mjs'), 'text/javascript; charset=utf-8'],
|
|
104
110
|
/* Drawings in the chat (```mermaid), at the version package.json fixes: asked for only when one is shown. */
|
|
@@ -146,7 +152,7 @@ const withoutTmux = (env) => Object.fromEntries(Object.entries(env).filter(([key
|
|
|
146
152
|
|
|
147
153
|
const REFUSED = 'This Clavarium belongs to someone else: your account is not one of its operators.\n';
|
|
148
154
|
|
|
149
|
-
function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi } = {}) {
|
|
155
|
+
function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders } = {}) {
|
|
150
156
|
/* Its manifest carries the name of this Clavarium, or the one a device chose (instance.mjs). */
|
|
151
157
|
const sendManifest = (response, url) => response.writeHead(200, { ...HEADERS, 'content-type': 'application/manifest+json' }).end(instance.manifest(new URL(url ?? '/', 'http://local').searchParams.get('name') ?? undefined));
|
|
152
158
|
const sendFile = async (response, file) => {
|
|
@@ -189,7 +195,7 @@ function serve(port, conversations, resources, { gate = () => 'local', originOk,
|
|
|
189
195
|
response.writeHead(403, { ...HEADERS, 'content-type': 'text/plain; charset=utf-8' }).end(REFUSED);
|
|
190
196
|
return;
|
|
191
197
|
}
|
|
192
|
-
if (conversations && await handleApi(request, response, conversations, HEADERS, resources, originOk, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi)) return;
|
|
198
|
+
if (conversations && await handleApi(request, response, conversations, HEADERS, resources, originOk, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders)) return;
|
|
193
199
|
if (pathname === '/manifest.webmanifest' && request.method === 'GET') { sendManifest(response, request.url); return; }
|
|
194
200
|
const file = FILES[pathname];
|
|
195
201
|
if (!file || (request.method !== 'GET' && request.method !== 'HEAD')) {
|
|
@@ -284,7 +290,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
284
290
|
await bounded(hostSteps, startWaitMs, 'the host program');
|
|
285
291
|
const shortcuts = new Shortcuts(new Store(`${dataDir}/shortcuts.json`));
|
|
286
292
|
/* The engine of dictation: chosen in Settings, else the environment's (voice.mjs). */
|
|
287
|
-
const voice = new Dictation({ file: new JsonFile(`${dataDir}/dictation.json`, {}), env, secret: (name) => secrets.reveal(name) });
|
|
293
|
+
const voice = new Dictation({ file: new JsonFile(`${dataDir}/dictation.json`, {}), env, secret: (name) => secrets.reveal(name), expired: (name) => secrets.isExpired(name) });
|
|
288
294
|
/* Read here already: a device paired before a conversation was shared in
|
|
289
295
|
two parts keeps the chat it reached then (see devices.mjs). */
|
|
290
296
|
const talkStore = new Store(`${dataDir}/talk.json`);
|
|
@@ -323,7 +329,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
323
329
|
its machine at a start and when a setting changes. `talk` and
|
|
324
330
|
`wakeups` are made below; only asked once the server runs. */
|
|
325
331
|
const guide = new Guide({ store: new Store(`${dataDir}/guide.json`), vms, conversations: all, resources: folders, secrets, toolbox, tools,
|
|
326
|
-
chat: (name) => Boolean(talk?.brief(name)), say: (name, line) => wakeups.say(name, line) });
|
|
332
|
+
chat: (name) => Boolean(talk?.brief(name)), say: (name, line) => wakeups.say(name, line), reread: () => talk?.rereadCommand() ?? null });
|
|
327
333
|
/* Why Parley is not in a machine, said once in the log, not at each opening. */
|
|
328
334
|
const parleySaid = new Map();
|
|
329
335
|
all.prepare = async (name, woke) => {
|
|
@@ -384,6 +390,9 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
384
390
|
fired: (name, { text }) => talk.event(name, { kind: 'wakeup', text, topic: 'Wake-up' }) });
|
|
385
391
|
const wakeTimer = wakeups.start(wakeEveryMs);
|
|
386
392
|
const docketTimer = dockets.start(wakeEveryMs);
|
|
393
|
+
/* Lists kept with the tools, held here: see binders.mjs. */
|
|
394
|
+
const binders = new Binders({ dataDir, resources: folders, conversations: () => all.list().map((c) => c.name), dockets, team });
|
|
395
|
+
const stopBinders = binders.start();
|
|
387
396
|
/* A repository's origin kept up to date, checks run in the machine, and
|
|
388
397
|
automatic sending to the branches the owner listed: see gitkeeper.mjs. */
|
|
389
398
|
/* What could not be read is told to the agents that write in the repository, where they can act. */
|
|
@@ -479,8 +488,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
479
488
|
void team.refresh().catch((error) => console.error(`operators: ${error.message}`));
|
|
480
489
|
const watching = setInterval(() => { void team.watch().catch(() => {}); }, 60_000); watching.unref?.();
|
|
481
490
|
}
|
|
482
|
-
const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
|
|
483
|
-
server.on('close', () => { closing = true; clearInterval(historyTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
491
|
+
const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
|
|
492
|
+
server.on('close', () => { closing = true; stopBinders(); clearInterval(historyTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
484
493
|
let closing = false;
|
|
485
494
|
bridge = attachBridge(server, {
|
|
486
495
|
onRejoin: (name) => all.rejoin(name),
|
package/server/parley.mjs
CHANGED
|
@@ -21,12 +21,14 @@ const require = createRequire(import.meta.url);
|
|
|
21
21
|
export const APP = fileURLToPath(new URL('..', import.meta.url));
|
|
22
22
|
export const PARLEY = 'clavarium-parley';
|
|
23
23
|
export const DOCKET = 'clavarium-docket';
|
|
24
|
+
export const BINDER = 'clavarium-binder';
|
|
24
25
|
/* THE TOOLS EVERY MACHINE IS GIVEN, each an npm dependency at an exact version, as Parley is:
|
|
25
26
|
installed by this server in every machine (toolbox.mjs), from its archive here. `usage`
|
|
26
27
|
is what /tools/index.json says of it. Adding one is adding a line here and its dependency. */
|
|
27
28
|
export const MACHINE_TOOLS = Object.freeze([
|
|
28
29
|
{ name: 'parley', pkg: PARLEY, usage: 'Installed in every machine: parley --help. Talk with the person you work for, on their screen, when their chat is on.' },
|
|
29
30
|
{ name: 'docket', pkg: DOCKET, usage: 'Installed in every machine: docket --help. What woke you, waiting until you say done or failed; and reminders you set yourself.' },
|
|
31
|
+
{ name: 'binder', pkg: BINDER, usage: 'Installed in every machine: binder --help. The lists you were given (batches, tasks, customers...): read them, add to them, note and attach; a person approves.' },
|
|
30
32
|
]);
|
|
31
33
|
|
|
32
34
|
/* Where an installed package is, by the lookup Node itself makes from here
|
package/server/secrets.mjs
CHANGED
|
@@ -93,6 +93,8 @@ export class Secrets {
|
|
|
93
93
|
return this.#store.all().map((s) => ({ name: s.name, conversations: this.#users(s.name), createdAt: s.createdAt,
|
|
94
94
|
expires: s.expires ?? null, days: s.expires ? daysTo(s.expires, this.#now()) : null, expired: this.#expired(s) }));
|
|
95
95
|
}
|
|
96
|
+
/* Past its expiry day: kept, not used (nor by dictation, voice.mjs). */
|
|
97
|
+
isExpired(name) { const s = this.#store.get(name); return Boolean(s) && this.#expired(s); }
|
|
96
98
|
/* Handed to it, expired or not (its Assets show both). */
|
|
97
99
|
of(conversation) { return this.#store.all().filter((s) => this.#handed(conversation, s.name)).map((s) => s.name); }
|
|
98
100
|
/* Delivered to it at its next start. */
|
package/server/talk.mjs
CHANGED
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
* there), each with what can be done about it.
|
|
40
40
|
* AFTER A RESTART the tool starts again with no memory of the
|
|
41
41
|
* chat: once it had time to start, REREAD is typed
|
|
42
|
-
* in its terminal, once (it reads the
|
|
42
|
+
* in its terminal, once (it reads the end of the
|
|
43
|
+
* thread, as far as the owner chose, and further
|
|
44
|
+
* back as it needs).
|
|
43
45
|
* THE THREAD, KEPT HERE Parley's own copy (its `keep`): every line read
|
|
44
46
|
* or written is kept in this server's data, one
|
|
45
47
|
* folder per conversation, out of the machine's
|
|
@@ -57,9 +59,9 @@
|
|
|
57
59
|
* the tool agrees to use it.
|
|
58
60
|
*/
|
|
59
61
|
import { posix, join } from 'node:path';
|
|
60
|
-
import { randomUUID } from 'node:crypto';
|
|
62
|
+
import { randomUUID, createHash } from 'node:crypto';
|
|
61
63
|
import { mkdirSync, lstatSync, rmSync } from 'node:fs';
|
|
62
|
-
import { install, Parley, WAKE,
|
|
64
|
+
import { install, Parley, WAKE, reread, texts, fill, LANGUAGES, SHOWN_MAX, FILES_MAX } from 'clavarium-parley/host';
|
|
63
65
|
import { importFile } from './files.mjs';
|
|
64
66
|
import { KEYS } from 'clavarium-parley/ui';
|
|
65
67
|
import { Refusal, SESSION } from './conversations.mjs';
|
|
@@ -68,6 +70,17 @@ import { isConversationName } from './names.mjs';
|
|
|
68
70
|
|
|
69
71
|
export const FOLDER = '.parley';
|
|
70
72
|
const IN_MACHINE = `/work/${FOLDER}`;
|
|
73
|
+
/* A part of the thread as the page asks for it (?last=200, ?days=3, ?before=ID, ?from=ID, ?since=CURSOR): Parley's options, or null. */
|
|
74
|
+
export function partOf(query) {
|
|
75
|
+
if (!query || typeof query !== 'object') return null;
|
|
76
|
+
const get = (k) => (typeof query.get === 'function' ? query.get(k) : query[k]);
|
|
77
|
+
/* ?state=1: whether it is on, and no message (the page asks it often). */
|
|
78
|
+
if (String(get('state') ?? '') === '1') return { state: true };
|
|
79
|
+
const out = {};
|
|
80
|
+
for (const k of ['last', 'days']) { const v = get(k); if (v !== null && v !== undefined && /^[1-9]\d{0,4}$/.test(String(v))) out[k] = Number(v); }
|
|
81
|
+
for (const k of ['before', 'from', 'since']) { const v = get(k); if (typeof v === 'string' && PART.test(v)) out[k] = v; }
|
|
82
|
+
return Object.keys(out).length ? out : null;
|
|
83
|
+
}
|
|
71
84
|
const PANE = `=${SESSION}:`;
|
|
72
85
|
/* Nothing is typed in a terminal somebody typed in this recently. */
|
|
73
86
|
export const TYPING_QUIET_MS = 4000;
|
|
@@ -156,6 +169,15 @@ const WORD_MAX = 500;
|
|
|
156
169
|
/* The words of the page and of the alerts. */
|
|
157
170
|
const WORDS = Object.freeze([...KEYS, 'alert-asks', 'alert-waits']);
|
|
158
171
|
|
|
172
|
+
/* WHAT IS READ OF THE THREAD AT FIRST: the newest messages, or those of the last days. The
|
|
173
|
+
screen chooses for itself (each device, app.js); the tool's choice is the owner's, here:
|
|
174
|
+
what REREAD asks it to read after a restart, and what its guide says. Either way the rest
|
|
175
|
+
is there, read on demand: the thread is never cut, summarised nor compacted. */
|
|
176
|
+
export const WINDOWS = Object.freeze(['messages:100', 'messages:200', 'messages:500', 'days:1', 'days:3', 'days:7']);
|
|
177
|
+
export const AI_WINDOW = 'messages:100';
|
|
178
|
+
export const windowOf = (choice) => { const [kind, n] = String(choice).split(':'); return kind === 'days' ? { days: Number(n) } : { last: Number(n) }; };
|
|
179
|
+
/* What the page may ask for: a part of the thread (Parley's read(options)), its own cursor for "since". */
|
|
180
|
+
const PART = /^[A-Za-z0-9._~-]{1,200}$/;
|
|
159
181
|
export class Talk {
|
|
160
182
|
#store; #words; #vms; #conversations; #resources; #toolbox; #warm; #alert; #listening = new Map(); #every; #now;
|
|
161
183
|
#typedAt = new Map(); #nextTry = new Map(); #trying = new Map(); #timer; #lastLang = 'en'; #rereadAfter;
|
|
@@ -266,18 +288,56 @@ export class Talk {
|
|
|
266
288
|
#listen(name) { if (!this.#listening.has(name)) { try { this.#listening.set(name, this.#parley(name).listen({ every: this.#every })); } catch { /* its folder is not there yet */ } } }
|
|
267
289
|
#deaf(name) { this.#listening.get(name)?.(); this.#listening.delete(name); }
|
|
268
290
|
|
|
269
|
-
of(
|
|
291
|
+
/* `part`: a part of the thread (the page's window, the page before it, what changed since its
|
|
292
|
+
cursor: Parley's read(options)); none, the newest SHOWN_MAX, as before. The cursor given back
|
|
293
|
+
is Parley's and this server's own lines', together. */
|
|
294
|
+
of(name, part) {
|
|
270
295
|
const c = this.#known(name);
|
|
271
296
|
const possible = c.work === 'kept';
|
|
272
297
|
const record = this.#store.get(name);
|
|
273
298
|
const tools = Boolean(this.#toolbox?.find('parley'));
|
|
274
299
|
if (record?.on !== true || !possible) return { on: false, possible, tools, messages: [], waiting: 0, status: null, steps: [], files: [], unread: 0 };
|
|
275
|
-
const
|
|
300
|
+
const wake = { waits: record.pending === true || record.reread === true, typed: record.typedAt ?? null, why: record.reread === true ? 'restarting' : record.why ?? null };
|
|
276
301
|
/* The machine's lines go among the messages, where they happened. */
|
|
277
302
|
const lines = (record.system ?? []).map((l) => ({ from: 'system', kind: 'system', choices: [], ...l }));
|
|
278
|
-
const
|
|
279
|
-
return { on: true, possible, tools,
|
|
303
|
+
const asked = partOf(part);
|
|
304
|
+
if (asked?.state) return { on: true, possible, tools, wake };
|
|
305
|
+
if (!asked) {
|
|
306
|
+
const read = this.#parley(name).read();
|
|
307
|
+
const messages = [...read.messages, ...lines].sort((a, b) => String(a.at).localeCompare(String(b.at))).slice(-SHOWN_MAX);
|
|
308
|
+
return { on: true, possible, tools, ...read, messages, wake };
|
|
309
|
+
}
|
|
310
|
+
/* Its own lines change apart from the thread (and their buttons with what was marked seen): their stamp is part of the cursor. */
|
|
311
|
+
const stamp = createHash('sha256').update(JSON.stringify([record.system ?? [], this.#health?.of?.(name)?.seenAt ?? null])).digest('hex').slice(0, 10);
|
|
312
|
+
const [thread, ours] = asked.since ? String(asked.since).split('~') : [];
|
|
313
|
+
const read = this.#parley(name).read({ ...asked, ...(asked.since ? { since: thread } : {}) });
|
|
314
|
+
const cursor = `${read.cursor}~${stamp}`;
|
|
315
|
+
if (read.since === true) return { on: true, possible, tools, ...read, messages: [...read.messages, ...(ours === stamp ? [] : lines)].sort((a, b) => String(a.at).localeCompare(String(b.at))), cursor, wake };
|
|
316
|
+
/* A part: the lines of its time. */
|
|
317
|
+
const w = read.window ?? {};
|
|
318
|
+
const mine = lines.filter((l) => (!(w.more > 0) || String(l.at) >= String(w.from ?? '')) && (w.until === null || w.until === undefined || String(l.at) < String(w.until)));
|
|
319
|
+
return { on: true, possible, tools, ...read, messages: [...read.messages, ...mine].sort((a, b) => String(a.at).localeCompare(String(b.at))), cursor, wake };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/* The whole thread searched, however little of it a screen shows (Parley's search). */
|
|
323
|
+
search(name, text) {
|
|
324
|
+
if (!this.of(name).on) throw new Refusal(409, 'Its chat is off.');
|
|
325
|
+
return this.#parley(name).search(String(text ?? '').slice(0, 200));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* What the tool reads of its chat after a restart (REREAD), the owner's choice of WINDOWS. */
|
|
329
|
+
window() {
|
|
330
|
+
const ai = this.#words?.get('window')?.ai;
|
|
331
|
+
return { ai: WINDOWS.includes(ai) ? ai : AI_WINDOW, default: AI_WINDOW, choices: [...WINDOWS] };
|
|
332
|
+
}
|
|
333
|
+
setWindow({ ai } = {}) {
|
|
334
|
+
if (!WINDOWS.includes(ai)) throw new Refusal(400, `The window is one of: ${WINDOWS.join(', ')}.`);
|
|
335
|
+
this.#words.put({ name: 'window', ai });
|
|
336
|
+
return this.window();
|
|
280
337
|
}
|
|
338
|
+
/* The line typed after a restart, and the command it names (for its guide). */
|
|
339
|
+
rereadLine() { return reread(windowOf(this.window().ai)); }
|
|
340
|
+
rereadCommand() { const w = windowOf(this.window().ai); return w.days ? `parley read --days ${w.days}` : `parley read --last ${w.last}`; }
|
|
281
341
|
|
|
282
342
|
/* For the list of conversations: does it wait for its owner? Cheap: two small files read. */
|
|
283
343
|
brief(name) {
|
|
@@ -285,7 +345,8 @@ export class Talk {
|
|
|
285
345
|
if (r?.on !== true) return null;
|
|
286
346
|
/* On, but unreadable just now: still said to be on (the share sheet offers its chat by that). */
|
|
287
347
|
try {
|
|
288
|
-
|
|
348
|
+
/* Its open questions, however old, come with the newest messages (Parley's window). */
|
|
349
|
+
const now = this.#parley(name).read({ last: SHOWN_MAX });
|
|
289
350
|
/* Its last message, either way: the list says when it last spoke, and what (app.js, Recent). */
|
|
290
351
|
/* What the person or the tool said -- never a line of this server (a restart, a machine put to sleep):
|
|
291
352
|
those are no one using it, and would lift it in Recent. */
|
|
@@ -426,7 +487,7 @@ export class Talk {
|
|
|
426
487
|
picture placed in the text), or attached by the person. */
|
|
427
488
|
shown(name, reference) {
|
|
428
489
|
if (!this.of(name).on || typeof reference !== 'string' || !reference) return false;
|
|
429
|
-
return this.#parley(name).read().messages.some((m) => m.open === reference || (m.files ?? []).some((f) => f.open === reference) || (m.refs ?? []).some((r) => r.open === reference));
|
|
490
|
+
return this.#parley(name).read({ all: true }).messages.some((m) => m.open === reference || (m.files ?? []).some((f) => f.open === reference) || (m.refs ?? []).some((r) => r.open === reference));
|
|
430
491
|
}
|
|
431
492
|
|
|
432
493
|
/* ---- lines of the machine, and of what happened to its repositories ---- */
|
|
@@ -522,7 +583,7 @@ export class Talk {
|
|
|
522
583
|
if (wait > 0) return later(wait + 100);
|
|
523
584
|
}
|
|
524
585
|
}
|
|
525
|
-
if (!(await this.#type(name,
|
|
586
|
+
if (!(await this.#type(name, this.rereadLine()).catch(() => false))) return later(RETRY_MS);
|
|
526
587
|
/* Reading the whole thread, it reads what waits too: that line is not typed after it. */
|
|
527
588
|
const waits = this.#parley(name).unread() > 0;
|
|
528
589
|
this.#store.put({ ...this.#store.get(name), reread: false, ...(waits ? { pending: false, woke: true, why: null, again: false } : {}), typedAt: new Date(this.#now()).toISOString() });
|
package/server/voice.mjs
CHANGED
|
@@ -207,11 +207,14 @@ export function dictationProblem(c) {
|
|
|
207
207
|
return undefined;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
export const KEY_EXPIRED = 'Dictation key expired: replace it in Assets > Secrets.';
|
|
211
|
+
|
|
210
212
|
export class Dictation {
|
|
211
|
-
#file; #env; #secret; #lookup; #fetcher;
|
|
212
|
-
/* `secret(name)`: the value of a secret, or undefined. `
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
#file; #env; #secret; #expired; #lookup; #fetcher;
|
|
214
|
+
/* `secret(name)`: the value of a secret, or undefined. `expired(name)`: past its expiry
|
|
215
|
+
day (secrets.mjs): then not used. `lookup(host)`: the addresses a name resolves to. */
|
|
216
|
+
constructor({ file = new JsonFile(undefined, {}), env = process.env, secret = () => undefined, expired = () => false, lookup = (host) => dnsLookup(host, { all: true }), fetcher = fetch } = {}) {
|
|
217
|
+
this.#file = file; this.#env = env; this.#secret = secret; this.#expired = expired; this.#lookup = lookup; this.#fetcher = fetcher;
|
|
215
218
|
}
|
|
216
219
|
/* A secret renamed: the key of dictation follows it. */
|
|
217
220
|
secretRenamed(from, to) {
|
|
@@ -236,6 +239,7 @@ export class Dictation {
|
|
|
236
239
|
on: this.#saved() !== undefined,
|
|
237
240
|
provider: saved.provider ?? null, url: saved.url ?? '', model: saved.model ?? '', secret: saved.secret ?? '', language: saved.language ?? '',
|
|
238
241
|
secretMissing: Boolean(saved.secret) && this.#secret(saved.secret) === undefined,
|
|
242
|
+
secretExpired: Boolean(saved.secret) && this.#expired(saved.secret),
|
|
239
243
|
env: env ? { model: env.model } : null,
|
|
240
244
|
source: this.#saved() ? 'settings' : env ? 'env' : null,
|
|
241
245
|
providers: Object.entries(PROVIDERS).map(([id, p]) => ({ id, ...p })),
|
|
@@ -259,14 +263,19 @@ export class Dictation {
|
|
|
259
263
|
try { addresses = isIP(host.replace(/^\[|\]$/g, '')) ? [{ address: host }] : await this.#lookup(host); } catch { throw new Refusal(502, 'The speech-to-text engine cannot be reached.'); }
|
|
260
264
|
if (addresses.some((a) => isPrivateHost(a.address))) throw new Refusal(400, 'This address leads into this server\'s own network: only "Other (compatible)" may.');
|
|
261
265
|
}
|
|
266
|
+
/* An expired key is never sent: said in one line instead (still offered, so the line is seen). */
|
|
267
|
+
#fresh(c) { if (c?.secret && this.#expired(c.secret)) throw new Refusal(409, KEY_EXPIRED); }
|
|
262
268
|
async transcribe(audio) {
|
|
269
|
+
this.#fresh(this.#saved());
|
|
263
270
|
const config = this.current();
|
|
264
271
|
if (config) await this.#guard(config);
|
|
265
272
|
return transcribe(config, audio, this.#fetcher);
|
|
266
273
|
}
|
|
267
274
|
/* "Try it": what is in the form, not saved, on one short recording. */
|
|
268
275
|
async try(body, audio) {
|
|
269
|
-
const
|
|
276
|
+
const checked = this.#checked(body);
|
|
277
|
+
this.#fresh(checked);
|
|
278
|
+
const config = this.#configOf(checked);
|
|
270
279
|
await this.#guard(config);
|
|
271
280
|
return transcribe(config, audio, this.#fetcher);
|
|
272
281
|
}
|
package/web/app.js
CHANGED
|
@@ -2374,11 +2374,21 @@
|
|
|
2374
2374
|
return chatWords;
|
|
2375
2375
|
}
|
|
2376
2376
|
/* The same on this server's own page and on a device's (which speaks for its own conversation). */
|
|
2377
|
-
const talkPath = (name, tail = ''
|
|
2377
|
+
const talkPath = (name, tail = '', params = {}) => {
|
|
2378
|
+
const q = new URLSearchParams({ ...(DEVICE ? { c: name } : {}), ...Object.fromEntries(Object.entries(params).filter(([, v]) => v !== undefined && v !== null).map(([k, v]) => [k, String(v)])) });
|
|
2379
|
+
return `${API}/conversations/${encodeURIComponent(name)}/talk${tail}${String(q) ? `?${q}` : ''}`;
|
|
2380
|
+
};
|
|
2381
|
+
/* WHAT THE CHAT SHOWS AT FIRST, chosen on each device (Settings, Chat screen): the newest
|
|
2382
|
+
messages, or those of the last days; the rest on demand ("Earlier messages"). */
|
|
2383
|
+
const CHAT_WINDOWS = [['messages:100', 'Last 100 messages'], ['messages:200', 'Last 200 messages'], ['messages:500', 'Last 500 messages'], ['days:1', 'Last day'], ['days:3', 'Last 3 days'], ['days:7', 'Last 7 days']];
|
|
2384
|
+
let chatWindow = 'messages:200';
|
|
2385
|
+
try { const kept = localStorage.getItem('clavarium-chat-window'); if (CHAT_WINDOWS.some(([v]) => v === kept)) chatWindow = kept; } catch { /* a private window */ }
|
|
2386
|
+
const windowFor = (choice) => { const [kind, n] = choice.split(':'); return kind === 'days' ? { days: Number(n) } : { messages: Number(n) }; };
|
|
2378
2387
|
async function readTalk() {
|
|
2379
2388
|
/* A device not given the chat does not ask for it: the server would refuse. */
|
|
2380
2389
|
if (!current || (DEVICE && deviceParts.chat === null)) { talk = { on: false, messages: [] }; talkOf = current; return talk; }
|
|
2381
|
-
|
|
2390
|
+
/* Whether it is on, nothing of the thread: asked every few seconds. */
|
|
2391
|
+
talk = await fetch(talkPath(current, '', { state: 1 })).then((r) => (r.ok ? r.json() : { on: false, messages: [] })).catch(() => ({ on: false, messages: [] }));
|
|
2382
2392
|
talkOf = current;
|
|
2383
2393
|
return talk;
|
|
2384
2394
|
}
|
|
@@ -2413,10 +2423,22 @@
|
|
|
2413
2423
|
const name = current;
|
|
2414
2424
|
if (name !== current || (thread && threadOf === current)) return;
|
|
2415
2425
|
threadOf = name;
|
|
2426
|
+
/* The lines of its machine seen so far: what changed comes alone, and their buttons are worked out on all of them. */
|
|
2427
|
+
const lines = new Map();
|
|
2428
|
+
const withLines = (data, asked) => {
|
|
2429
|
+
if (!Array.isArray(data?.messages)) return data;
|
|
2430
|
+
if (data.since !== true && !asked?.before) lines.clear();
|
|
2431
|
+
for (const m of data.messages) if (m.from === 'system') lines.set(m.id, m);
|
|
2432
|
+
return data.since === true ? { ...data, messages: [...data.messages.filter((m) => m.from !== 'system'), ...lines.values()] } : data;
|
|
2433
|
+
};
|
|
2416
2434
|
thread = mount(box, {
|
|
2417
2435
|
words, view: chatView,
|
|
2418
2436
|
onView: (v) => { chatView = v; try { localStorage.setItem('clavarium-chat-view', v); } catch { /* as above */ } },
|
|
2419
|
-
|
|
2437
|
+
/* A part of the thread: its end at first, then what changed, the page before on demand (Parley's window). */
|
|
2438
|
+
window: windowFor(chatWindow),
|
|
2439
|
+
load: (asked = {}) => fetch(talkPath(name, '', asked)).then((r) => r.json()).then((data) => withLines(data, asked)).then(machineLines).then((data) => withMachine(data, name)),
|
|
2440
|
+
/* The whole thread searched, however little of it is shown. */
|
|
2441
|
+
search: (q) => fetch(talkPath(name, '/search', { q })).then((r) => (r.ok ? r.json() : { matches: [], count: 0 })),
|
|
2420
2442
|
/* `via: 'voice'`: part of it was dictated, said to the tool. */
|
|
2421
2443
|
send: (text, answers, files, extra) => post(talkPath(name), { text, answers, ...(files ? { files: files.map((f) => (f.note ? { path: f.path, note: f.note } : f.path)) } : {}), ...(extra?.via === 'voice' ? { via: 'voice' } : {}),
|
|
2422
2444
|
/* The choices ticked, the answers of a group, the zone of a picture the answer is about. */
|
|
@@ -2682,6 +2704,24 @@
|
|
|
2682
2704
|
await paintWords();
|
|
2683
2705
|
} catch (error) { $('words-error').textContent = error.message; $('words-error').hidden = false; }
|
|
2684
2706
|
}
|
|
2707
|
+
/* Settings: what the chat shows at first, on this device; what its tool reads again after a restart, on this server. */
|
|
2708
|
+
async function paintChatWindow() {
|
|
2709
|
+
const option = ([value, text], chosen) => { const o = document.createElement('option'); o.value = value; o.textContent = text; o.selected = value === chosen; return o; };
|
|
2710
|
+
$('chat-window').replaceChildren(...CHAT_WINDOWS.map((c) => option(c, chatWindow)));
|
|
2711
|
+
if (DEVICE) return;
|
|
2712
|
+
const now = await fetch(`${API}/talk/window`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
2713
|
+
if (now) $('chat-window-ai').replaceChildren(...CHAT_WINDOWS.filter(([v]) => now.choices.includes(v)).map((c) => option(c, now.ai)));
|
|
2714
|
+
}
|
|
2715
|
+
$('chat-window').addEventListener('change', () => {
|
|
2716
|
+
chatWindow = $('chat-window').value;
|
|
2717
|
+
try { localStorage.setItem('clavarium-chat-window', chatWindow); } catch { /* a private window */ }
|
|
2718
|
+
/* Drawn again with it. */
|
|
2719
|
+
thread?.destroy(); thread = null; threadOf = ''; void paintThread();
|
|
2720
|
+
});
|
|
2721
|
+
$('chat-window-ai').addEventListener('change', async () => {
|
|
2722
|
+
try { await post(`${API}/talk/window`, { ai: $('chat-window-ai').value }); } catch (error) { $('words-error').textContent = error.message; $('words-error').hidden = false; }
|
|
2723
|
+
await paintChatWindow();
|
|
2724
|
+
});
|
|
2685
2725
|
/* Settings: what the chat's thread shows of each kind of event (server/talk.mjs EVENT_LEVELS). */
|
|
2686
2726
|
const THREAD_KINDS = [
|
|
2687
2727
|
['sent', 'Sent automatically', 'A branch went to the remote by itself'],
|
|
@@ -3940,6 +3980,8 @@
|
|
|
3940
3980
|
$('settings').hidden = which !== 'settings';
|
|
3941
3981
|
$('assets').hidden = which !== 'assets';
|
|
3942
3982
|
$('newconv').hidden = which !== 'new';
|
|
3983
|
+
$('lists').hidden = which !== 'lists';
|
|
3984
|
+
if (which === 'lists') void paintLists(); else stopLists();
|
|
3943
3985
|
if (which !== 'access') composing = false;
|
|
3944
3986
|
/* What the conversation had open (its tab) waits under the place, as it was. */
|
|
3945
3987
|
if (which !== 'conversations') { for (const id of ['files', 'copy']) $(id).hidden = true; view('room'); }
|
|
@@ -4012,6 +4054,34 @@
|
|
|
4012
4054
|
}
|
|
4013
4055
|
/* `of`: the conversation it is filtered on ('' for none; left as it is when not given).
|
|
4014
4056
|
`face`: on the devices tab, 'compose' keeps what openCompose prepared. */
|
|
4057
|
+
/* LISTS: the binder, drawn by Binder (clavarium-binder) in its place; read again when it changed. */
|
|
4058
|
+
let binderView = null; let binderPeople = []; let binderChanges = -1; let binderTimer = null;
|
|
4059
|
+
function openListsPlace({ push = true } = {}) { if (DEVICE) return; if (place !== 'lists') enterPlace('lists', push); }
|
|
4060
|
+
async function paintLists() {
|
|
4061
|
+
const lang = /^fr\b/i.test(navigator.language ?? '') ? 'fr' : 'en';
|
|
4062
|
+
const seen = await getJson('/binder/people', null);
|
|
4063
|
+
if (seen) { binderPeople = seen.people; binderChanges = seen.changes; }
|
|
4064
|
+
if (!binderView) {
|
|
4065
|
+
const [{ mount }, words] = await Promise.all([import(new URL('vendor/binder-ui.js', new URL('/', location.href)).href), fetch(`/vendor/binder-${lang}.json`).then((r) => r.json()).catch(() => ({}))]);
|
|
4066
|
+
if (place !== 'lists' || binderView) return;
|
|
4067
|
+
binderView = mount($('lists-binder'), {
|
|
4068
|
+
words, lang, people: () => binderPeople,
|
|
4069
|
+
call: (op, args) => fetch(`${API}/binder`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ op, args }) })
|
|
4070
|
+
.then((r) => r.json()).catch(() => ({ ok: false, text: 'The server could not be reached.' })),
|
|
4071
|
+
/* A message or a file attached opens where this page opens them; a conversation's own, by its path. */
|
|
4072
|
+
openAttached: (a) => { if (a.kind === 'asset') void openAssetsPlace(a.ref); },
|
|
4073
|
+
});
|
|
4074
|
+
} else void binderView.refresh();
|
|
4075
|
+
stopLists();
|
|
4076
|
+
binderTimer = setInterval(async () => {
|
|
4077
|
+
if (place !== 'lists' || document.hidden) return;
|
|
4078
|
+
const now = await getJson('/binder/people', null);
|
|
4079
|
+
if (!now) return;
|
|
4080
|
+
binderPeople = now.people;
|
|
4081
|
+
if (now.changes !== binderChanges) { binderChanges = now.changes; void binderView?.refresh(); }
|
|
4082
|
+
}, 4000);
|
|
4083
|
+
}
|
|
4084
|
+
function stopLists() { if (binderTimer) clearInterval(binderTimer); binderTimer = null; }
|
|
4015
4085
|
async function openAccessPage(tab = accessTab, { mode, of, face: shown = 'manage', push = true, pin } = {}) {
|
|
4016
4086
|
if (DEVICE) return;
|
|
4017
4087
|
/* Assets left Access: a conversation's own, or the server's. */
|
|
@@ -4046,6 +4116,7 @@
|
|
|
4046
4116
|
if (/^[a-z]{1,20}$/.test(at)) openChapter(`s-${at}`)?.scrollIntoView({ block: 'start' });
|
|
4047
4117
|
return;
|
|
4048
4118
|
}
|
|
4119
|
+
if (open === 'lists') { openListsPlace({ push: false }); return; }
|
|
4049
4120
|
/* Assets, a place of its own now (it was a tab of Access). */
|
|
4050
4121
|
if (open === 'assets' || (open === 'access' && q.get('tab') === 'assets')) { await openAssetsPlace(q.get('a') ?? undefined, { push: false }); return; }
|
|
4051
4122
|
const former = FORMER[open === 'access' ? (q.get('tab') ?? 'map') : open];
|
|
@@ -4054,6 +4125,8 @@
|
|
|
4054
4125
|
}
|
|
4055
4126
|
nav.outside = () => { if (!DEVICE) void followAddress(); };
|
|
4056
4127
|
$('nav-conversations').addEventListener('click', () => { leavePlace({ list: true }); });
|
|
4128
|
+
$('nav-lists').addEventListener('click', () => openListsPlace());
|
|
4129
|
+
$('lists-close').addEventListener('click', () => leavePlace());
|
|
4057
4130
|
$('nav-access').addEventListener('click', () => { if (place !== 'access' || accessTab !== 'map' || mapMode !== 'map') void openAccessPage('map', { mode: 'map' }); });
|
|
4058
4131
|
$('nav-assets').addEventListener('click', () => { if (place !== 'assets') void openAssetsPlace(); });
|
|
4059
4132
|
$('map-new-device').addEventListener('click', () => { void openCompose(accessFor ? [[`conversation:${accessFor}`, partsFor(accessFor)]] : []); });
|
|
@@ -4122,6 +4195,7 @@
|
|
|
4122
4195
|
void paintAlerts().catch(() => {});
|
|
4123
4196
|
void paintWords().catch(() => {});
|
|
4124
4197
|
void paintThreadLevels().catch(() => {});
|
|
4198
|
+
void paintChatWindow().catch(() => {});
|
|
4125
4199
|
const [platform, saved] = await Promise.all([fetch(`${API}/platform`).then((r) => r.json()).catch(() => ({})), fetch(`${API}/shortcuts`).then((r) => r.json()).catch(() => [])]);
|
|
4126
4200
|
const list = $('settings-shortcuts'); list.replaceChildren();
|
|
4127
4201
|
for (const shortcut of saved) {
|
|
@@ -4170,6 +4244,8 @@
|
|
|
4170
4244
|
$('settings-dictation').textContent = about.source === 'settings' ? `On · "${about.model}" · chosen here`
|
|
4171
4245
|
: about.source === 'env' ? `On · "${about.env.model}" · set on the server` : 'Off · choose a provider';
|
|
4172
4246
|
$('settings-dictation').dataset.tone = about.source ? 'ok' : '';
|
|
4247
|
+
/* Its key past its expiry day: not used (voice.mjs); said in red, a dot on the chapter. */
|
|
4248
|
+
if (about.source === 'settings' && about.secretExpired) { $('settings-dictation').textContent = 'Key expired: replace it in Assets > Secrets'; $('settings-dictation').dataset.tone = 'bad'; }
|
|
4173
4249
|
if (about.secretMissing) dictationSay(`The secret "${about.secret}" is gone: choose another key.`);
|
|
4174
4250
|
dictationProviders = about.providers;
|
|
4175
4251
|
const provider = $('dictation-provider');
|
package/web/index.html
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<link rel="stylesheet" href="/vendor/xterm.css">
|
|
11
11
|
<link rel="stylesheet" href="/style.css">
|
|
12
12
|
<link rel="stylesheet" href="/vendor/parley-ui.css">
|
|
13
|
+
<link rel="stylesheet" href="/vendor/binder-ui.css">
|
|
13
14
|
<link rel="stylesheet" href="/vendor/diff2html.css">
|
|
14
15
|
<div id="app" data-place="conversations">
|
|
15
16
|
<aside id="list" hidden>
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
<div id="list-resize" role="separator" aria-orientation="vertical" aria-label="Width of the list" title="Drag to widen or narrow the list; double click for its usual width" tabindex="0" hidden></div>
|
|
34
35
|
<nav id="nav" aria-label="Places" hidden>
|
|
35
36
|
<button type="button" id="nav-conversations" data-place="conversations" aria-current="page"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="message-square"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414 .586l-2.202 2.202A.71 .71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"/></svg><span>Conversations</span></button>
|
|
37
|
+
<button type="button" id="nav-lists" data-place="lists"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="list-checks"><path d="m3 17 2 2 4-4"/><path d="m3 7 2 2 4-4"/><path d="M13 6h8"/><path d="M13 12h8"/><path d="M13 18h8"/></svg><span>Lists</span></button>
|
|
36
38
|
<button type="button" id="nav-assets" data-place="assets"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="layers"><path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/></svg><span>Assets</span></button>
|
|
37
39
|
<button type="button" id="nav-access" data-place="access"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="waypoints"><path d="m10.586 5.414-5.172 5.172"/><path d="m18.586 13.414-5.172 5.172"/><path d="M6 12h12"/><circle cx="12" cy="20" r="2"/><circle cx="12" cy="4" r="2"/><circle cx="20" cy="12" r="2"/><circle cx="4" cy="12" r="2"/></svg><span>Access</span></button>
|
|
38
40
|
<button type="button" id="nav-settings" data-place="settings"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="settings"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/></svg><span>Settings</span></button>
|
|
@@ -438,6 +440,11 @@
|
|
|
438
440
|
right: who uses it, its state, its settings. The forms that make
|
|
439
441
|
one, and a repository's remote, wait in #assets-forms and are moved
|
|
440
442
|
into the detail when asked for. -->
|
|
443
|
+
<!-- LISTS: the binder (clavarium-binder), drawn by Binder itself in #lists-binder. -->
|
|
444
|
+
<div id="lists" class="sheet as-place" hidden>
|
|
445
|
+
<div class="panel-top"><b>Lists</b><button type="button" id="lists-close" class="as-link place-back">‹ Conversations</button></div>
|
|
446
|
+
<div id="lists-binder"></div>
|
|
447
|
+
</div>
|
|
441
448
|
<div id="assets" class="sheet as-place" hidden>
|
|
442
449
|
<div class="panel-top"><b>Assets</b><button type="button" id="assets-close" class="as-link place-back">‹ Conversations</button></div>
|
|
443
450
|
<p id="assets-error" class="error" role="alert" hidden></p>
|
|
@@ -569,9 +576,12 @@
|
|
|
569
576
|
<section class="settings-group" id="settings-group-chat" data-group="chat">
|
|
570
577
|
<h3 class="chapter-group">Chat</h3>
|
|
571
578
|
<details class="chapter" id="settings-ch-words" data-chapter="s-words">
|
|
572
|
-
<summary><span class="chapter-title">Chat screen</span><span class="chapter-about">Language
|
|
579
|
+
<summary><span class="chapter-title">Chat screen</span><span class="chapter-about">Language, wording, history.</span></summary>
|
|
573
580
|
<div class="chapter-body">
|
|
574
581
|
<div class="set-row"><div class="set-what"><label for="words-lang">Language</label><small>Of the chat screen, every device</small></div><div class="set-control"><select id="words-lang"><option value="device">The language of each device</option></select></div></div>
|
|
582
|
+
<!-- THE END OF THE THREAD, the rest on demand: never cut (server/talk.mjs WINDOWS). -->
|
|
583
|
+
<div class="set-row"><div class="set-what"><label for="chat-window">Shown at first</label><small>On this device; the rest on demand</small></div><div class="set-control"><select id="chat-window"></select></div></div>
|
|
584
|
+
<div class="set-row"><div class="set-what"><label for="chat-window-ai">Read after a restart</label><small>By its tool; older on demand</small></div><div class="set-control"><select id="chat-window-ai"></select></div></div>
|
|
575
585
|
<details id="words-box">
|
|
576
586
|
<summary>Your own words</summary>
|
|
577
587
|
<p class="hint">Any word of the chat, replaced for every device: <code>{"send": "Go"}</code>.</p>
|
package/web/style.css
CHANGED
|
@@ -1699,3 +1699,7 @@ span.callout.confirm { display: inline-flex; justify-content: flex-end; padding:
|
|
|
1699
1699
|
|
|
1700
1700
|
/* Something asks for the person in this chapter (a callout, a warning): a dot on its title, and on its category. */
|
|
1701
1701
|
details.chapter[data-attention] > summary .chapter-title::after, #settings-nav button[data-attention]::after, #nav-assets[data-attention] > span::after, #view-assets[data-attention] > span::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--warn); vertical-align: middle; }
|
|
1702
|
+
/* LISTS: Binder's screen, in this page's colours. */
|
|
1703
|
+
#lists-binder { display: flex; flex-direction: column; min-height: 0; overflow: auto; padding: 16px 16px 24px; }
|
|
1704
|
+
#lists-binder .binder { --binder-bg: var(--bg); --binder-text: var(--ink); --binder-dim: var(--ink2); --binder-line: var(--line); --binder-panel: var(--panel);
|
|
1705
|
+
--binder-action: var(--brass); --binder-on-action: #1b1405; --binder-ok: var(--ok); --binder-ask: var(--warn); --binder-danger: var(--danger); }
|