clavarium 0.2.162-beta.1 → 0.2.163-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/boxes.mjs +13 -5
- package/server/main.mjs +1 -1
- package/server/talk.mjs +26 -5
- package/server/tethers.mjs +97 -11
- package/web/app.js +1 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.163-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.163-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
14
|
"clavarium-binder": "0.1.60-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
17
|
-
"clavarium-tether": "0.1.0-next.
|
|
16
|
+
"clavarium-parley": "0.17.71-next.1",
|
|
17
|
+
"clavarium-tether": "0.1.0-next.53",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
20
20
|
"node-pty": "^1.1.0",
|
|
@@ -787,9 +787,9 @@
|
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
789
|
"node_modules/clavarium-parley": {
|
|
790
|
-
"version": "0.17.
|
|
791
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
792
|
-
"integrity": "sha512-
|
|
790
|
+
"version": "0.17.71-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.71-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-98RGnKFb8sCl05HSzrWY7qCvlqBGY4wAL4kwNVKTO69d8F1x3++pLCHjyE8AXjKNNlt2BE5fCrxtbsu/BTsnLA==",
|
|
793
793
|
"license": "MIT",
|
|
794
794
|
"bin": {
|
|
795
795
|
"parley": "bin/parley.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.53",
|
|
804
|
+
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.53.tgz",
|
|
805
|
+
"integrity": "sha512-kFSGOQs0bNaURU4SG+IFO7C7zRmLavefZZ/BXvjceuTHM2WP5A58q8H8xkWb1HrHDrj74DqQXYl4TF3kKSNkiA==",
|
|
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.163-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.",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
47
|
"clavarium-binder": "0.1.60-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.2-next.2",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
50
|
-
"clavarium-tether": "0.1.0-next.
|
|
49
|
+
"clavarium-parley": "0.17.71-next.1",
|
|
50
|
+
"clavarium-tether": "0.1.0-next.53",
|
|
51
51
|
"mammoth": "1.13.0",
|
|
52
52
|
"mermaid": "11.17.2",
|
|
53
53
|
"node-pty": "^1.1.0",
|
package/server/boxes.mjs
CHANGED
|
@@ -44,7 +44,13 @@ export const wakeHeard = (text) => { const t = plainWords(text); return WAKE_HEA
|
|
|
44
44
|
the room's talk from afar, not someone speaking to the box. Every real call of 05-11 that the word missed
|
|
45
45
|
had a firm voice or none measured; the false wake of 05-11, 429. Said by one discreet line in the thread. */
|
|
46
46
|
export const WAKE_FAINT = 600;
|
|
47
|
-
|
|
47
|
+
/* 06-11: a radio or a TV read a whole news flash after a false wake (120 s, cut by the length limit, no voice measured):
|
|
48
|
+
a sentence never ended is not someone speaking to the box -- not heard AND cut by the length limit is dropped too. */
|
|
49
|
+
/* 06-11 (again): the wake's own 1.6 s held no word at all (heard: nothing) -- the word was certainly not said: a radio's
|
|
50
|
+
music or jingle. A real call missed by the check always held words (its sentence begun). */
|
|
51
|
+
/* NOT "a second miss within 10 min": checked against the owner's calls of 05-11, it would have dropped a real one (05:18,
|
|
52
|
+
five minutes after a missed 05:13). A radio that says words after a false wake still comes through; nothing is answered. */
|
|
53
|
+
export const dropsWake = (ok, voice, reason = '', heard = 'x') => !ok && (WAKE_DROP || reason === 'timeout' || !String(heard ?? '').trim() || (Number.isFinite(voice) && voice > 0 && voice < WAKE_FAINT));
|
|
48
54
|
const plainWords = (t) => String(t).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
49
55
|
export const SENTENCE_MAX = 300 * 32_000 + 32_000; /* 5 min of 16 kHz 16-bit mono, and some slack */
|
|
50
56
|
export const TRIES_PER_MINUTE = 10;
|
|
@@ -781,7 +787,7 @@ export class Boxes {
|
|
|
781
787
|
this.#log(`voice box ${box.name}: a sentence while recording here, the recording closed`);
|
|
782
788
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
783
789
|
}
|
|
784
|
-
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
790
|
+
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; link.voice = NaN; link.endReason = ''; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
785
791
|
if (m.t === 'listen.start') { if (this.stop(box.id)) this.#log(`voice box ${box.name}: stopped playing, someone speaks`); sentence = []; size = 0; return; }
|
|
786
792
|
if (m.t === 'listen.end' && sentence && m.reason === 'nobody') {
|
|
787
793
|
/* Listened again, nobody spoke: a conversation ends there, in silence. */
|
|
@@ -792,6 +798,8 @@ export class Boxes {
|
|
|
792
798
|
link.send({ t: 'cue', name: 'done' });
|
|
793
799
|
return;
|
|
794
800
|
}
|
|
801
|
+
/* How this sentence ended, said with or without its measures (a radio cut at the length limit may have none). */
|
|
802
|
+
if (m.t === 'listen.end') link.endReason = String(m.reason ?? '');
|
|
795
803
|
if (m.t === 'listen.end' && m.ep) {
|
|
796
804
|
const end = endOf(m.ep, m.reason ?? '');
|
|
797
805
|
link.why = `${link.why ? `${link.why} · ` : ''}${end}`;
|
|
@@ -919,10 +927,10 @@ export class Boxes {
|
|
|
919
927
|
/* First in the line: Parley keeps 120 characters of `why`, and the end stats after it can pass that. */
|
|
920
928
|
link.why = `mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »${link.why ? ` · ${link.why}` : ''}`;
|
|
921
929
|
this.#log(`voice box ${box.name}: wake word heard again: ${check.ok ? 'yes' : 'NO'} (« ${check.heard.slice(0, 40)} »)`);
|
|
922
|
-
if (dropsWake(check.ok, link.voice)) {
|
|
930
|
+
if (dropsWake(check.ok, link.voice, link.endReason, check.heard)) {
|
|
923
931
|
link.send({ t: 'cue', name: 'done' });
|
|
924
|
-
this.#log(`voice box ${box.name}: wake ignored (word not heard again, faint voice ${Math.round(link.voice || 0)})`);
|
|
925
|
-
try { this.#note?.(box.conversation, { kind: 'box-wake-ignored', text: `Wake ignored on ${box.name}: « ${check.heard.slice(0, 40)} », faint voice`, topic: 'Voice box', tone: 'info' }); } catch { /* the log has it */ }
|
|
932
|
+
this.#log(`voice box ${box.name}: wake ignored (word not heard again, ${link.endReason === 'timeout' ? 'a sentence that never ended' : !check.heard.trim() ? 'no word in its clip' : `faint voice ${Math.round(link.voice || 0)}`})`);
|
|
933
|
+
try { this.#note?.(box.conversation, { kind: 'box-wake-ignored', text: `Wake ignored on ${box.name}: « ${check.heard.slice(0, 40)} », ${link.endReason === 'timeout' ? 'a sound that never stopped (radio, TV)' : !check.heard.trim() ? 'no word where the wake word should be' : 'faint voice'}`, topic: 'Voice box', tone: 'info' }); } catch { /* the log has it */ }
|
|
926
934
|
return;
|
|
927
935
|
}
|
|
928
936
|
}
|
package/server/main.mjs
CHANGED
|
@@ -459,7 +459,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
459
459
|
mailbox, a calendar, an address book -- held here with their secrets read from
|
|
460
460
|
the vault by name, never in a machine: see tethers.mjs. */
|
|
461
461
|
/* Voice boxes are Tether targets too (boxes.mjs): their connector reaches them through `boxes`, made below. */
|
|
462
|
-
const tethers = new Tethers({ dataDir, resources: folders, conversations: () => all.list().map((c) => c.name), secrets, connectors: { voicebox: { run: (...a) => voiceboxConnector(boxes).run(...a) } } });
|
|
462
|
+
const tethers = new Tethers({ dataDir, resources: folders, conversations: () => all.list().map((c) => c.name), secrets, dockets, connectors: { voicebox: { run: (...a) => voiceboxConnector(boxes).run(...a) } } });
|
|
463
463
|
const stopTethers = tethers.start();
|
|
464
464
|
/* Connecting a mailbox, calendar or address book by token: the consent happens
|
|
465
465
|
in the owner's browser, the refresh token is kept host-only (never in a
|
package/server/talk.mjs
CHANGED
|
@@ -166,6 +166,9 @@ export const EVENT_LEVELS = Object.freeze({
|
|
|
166
166
|
Assets, or by the agent) is a trace that carries the call's id, so the buttons close with it. */
|
|
167
167
|
'tether-demande': 'needs-you',
|
|
168
168
|
'tether-done': 'trace',
|
|
169
|
+
/* Something that happened later to what its agent did (a mail that came back, an invitation declined):
|
|
170
|
+
news, raised to needs-you when it failed or was refused (tethers.mjs). */
|
|
171
|
+
'tether-notice': 'news',
|
|
169
172
|
});
|
|
170
173
|
const TONES = ['warn', 'bad'];
|
|
171
174
|
/* Bounds of a line: its text, its group (topic), what the grouped line says of it (brief), its buttons. */
|
|
@@ -176,6 +179,22 @@ const ACTIONS_MAX = 4;
|
|
|
176
179
|
const ACTION = /^[a-z]{1,20}(:[a-z0-9][a-z0-9._-]{0,63})?$/;
|
|
177
180
|
const REQUEST_MAX = 8000;
|
|
178
181
|
const OUTCOMES = ['yes', 'always', 'no', 'timeout', 'withdrawn', 'stopped'];
|
|
182
|
+
/* A LINE'S TEXT IN THE READER'S WORDS (Parley 0.17.71): plain text, or `{k, v, t}` -- a word of Parley's
|
|
183
|
+
dictionary, its values (text, a number, or such a word again), and `t`, the plain English an older screen
|
|
184
|
+
says. Kept bounded: `t` as long as a plain text may be; a word without its `t` is none. */
|
|
185
|
+
const WORD = /^[a-z0-9-]{1,60}$/;
|
|
186
|
+
function lineWords(x, max, depth = 0) {
|
|
187
|
+
if (typeof x === 'string') { const t = x.trim(); return t ? t.slice(0, max) : null; }
|
|
188
|
+
if (typeof x === 'number') return Number.isFinite(x) ? x : null;
|
|
189
|
+
if (!x || typeof x !== 'object' || Array.isArray(x) || depth > 3 || typeof x.k !== 'string' || !WORD.test(x.k)) return null;
|
|
190
|
+
const t = typeof x.t === 'string' ? x.t.trim().slice(0, max) : '';
|
|
191
|
+
if (!t) return null;
|
|
192
|
+
const v = x.v && typeof x.v === 'object' && !Array.isArray(x.v)
|
|
193
|
+
? Object.fromEntries(Object.entries(x.v).filter(([n]) => /^[a-z]{1,20}$/.test(n)).slice(0, 8).map(([n, y]) => [n, lineWords(y, EVENT_TEXT_MAX, depth + 1)]).filter(([, y]) => y !== null)) : null;
|
|
194
|
+
return { k: x.k, ...(v && Object.keys(v).length ? { v } : {}), t };
|
|
195
|
+
}
|
|
196
|
+
/* A line's text, topic or brief as given: text, or such a word; null when it says nothing. */
|
|
197
|
+
const lineSaid = (x, max) => lineWords(x && typeof x === 'object' ? x : String(x ?? ''), max);
|
|
179
198
|
/* Where the person's files go, in the bridge folder; one folder per file, named by an id. */
|
|
180
199
|
const FILES = 'files';
|
|
181
200
|
const ATTACHED = new RegExp(`^/work/\\${FOLDER}/${FILES}/([0-9a-f-]{36})/([^/]+)$`);
|
|
@@ -578,18 +597,20 @@ export class Talk {
|
|
|
578
597
|
line kept, or null. `actions`: ids the page maps to buttons. */
|
|
579
598
|
event(name, { kind, text, level, tone, topic, brief, actions = [], request, outcome } = {}) {
|
|
580
599
|
if (!Object.hasOwn(EVENT_LEVELS, kind)) throw new RangeError(`No such kind of event: ${kind}`);
|
|
581
|
-
const said =
|
|
582
|
-
if (
|
|
600
|
+
const said = lineSaid(text, EVENT_TEXT_MAX);
|
|
601
|
+
if (said === null) return null;
|
|
602
|
+
const group = lineSaid(topic, TOPIC_MAX);
|
|
603
|
+
const short = lineSaid(brief, BRIEF_MAX);
|
|
583
604
|
/* The owner's choice when there is one (stored only where it differs from the kind's own). */
|
|
584
605
|
const chosen = this.thread().levels[kind];
|
|
585
606
|
const line = {
|
|
586
607
|
/* Not `kind`: the page reads that of every message ('system' for these). */
|
|
587
608
|
event: kind,
|
|
588
|
-
text: said
|
|
609
|
+
text: said,
|
|
589
610
|
level: chosen !== EVENT_LEVELS[kind] ? chosen : LEVELS.includes(level) ? level : chosen,
|
|
590
611
|
...(TONES.includes(tone) ? { tone } : {}),
|
|
591
|
-
...(
|
|
592
|
-
...(
|
|
612
|
+
...(group !== null ? { topic: group } : {}),
|
|
613
|
+
...(short !== null ? { brief: short } : {}),
|
|
593
614
|
actions: (Array.isArray(actions) ? actions : []).filter((a) => typeof a === 'string' && ACTION.test(a)).slice(0, ACTIONS_MAX),
|
|
594
615
|
/* A request's card, as Parley draws it (demandes.mjs): plain data, bounded. */
|
|
595
616
|
...(request && typeof request === 'object' && !Array.isArray(request) && JSON.stringify(request).length <= REQUEST_MAX ? { request } : {}),
|
package/server/tethers.mjs
CHANGED
|
@@ -31,19 +31,74 @@ const AGENT = 'conversation:';
|
|
|
31
31
|
export const USB_DEVICE = 'usb-device';
|
|
32
32
|
/* Accepted calls whose result is awaited, at most (an act that never ends is forgotten after these). */
|
|
33
33
|
const ACTING_MAX = 200;
|
|
34
|
+
/* Notices already said (their ids), at most: each said once, across restarts. */
|
|
35
|
+
const NOTICES_MAX = 1000;
|
|
36
|
+
|
|
37
|
+
/* SOMETHING THAT HAPPENED LATER to what an agent did (Tether's notices: a mail that came back, a scheduled
|
|
38
|
+
send that failed, an invitation declined). One short head per kind, said before Tether's own sentence;
|
|
39
|
+
a failure, a bounce, a decline is a warning (needs the person), a delay or a late send is news. */
|
|
40
|
+
const NOTICE_HEADS = {
|
|
41
|
+
'mail.bounced': 'Mail came back',
|
|
42
|
+
'mail.delayed': 'Mail delayed',
|
|
43
|
+
'mail.send-failed': 'Mail not sent',
|
|
44
|
+
'mail.later-failed': 'Scheduled mail not sent',
|
|
45
|
+
'mail.later-unsure': 'Scheduled mail maybe sent',
|
|
46
|
+
'mail.later-late': 'Scheduled mail sent late',
|
|
47
|
+
'mail.sent-late': 'Mail sent late',
|
|
48
|
+
'mail.later-draft-kept': 'Scheduled mail sent, draft kept',
|
|
49
|
+
'calendar.declined': 'Invitation declined',
|
|
50
|
+
};
|
|
51
|
+
const NOTICE_INFO = /\.(delayed|later-late|sent-late)$/;
|
|
52
|
+
export const noticeHead = (kind) => NOTICE_HEADS[kind] ?? 'Later news';
|
|
53
|
+
/* The same head as a word of Parley's (notice-mail-bounced...), said in the reader's language. */
|
|
54
|
+
export const noticeWord = (kind) => (Object.hasOwn(NOTICE_HEADS, kind) ? { k: `notice-${kind.replace(/\./g, '-')}`, t: NOTICE_HEADS[kind] } : { k: 'notice-later', t: 'Later news' });
|
|
55
|
+
export const noticeWarns = (kind) => !NOTICE_INFO.test(String(kind ?? ''));
|
|
56
|
+
|
|
57
|
+
/* A LINE IN THE READER'S WORDS (Parley 0.17.71, as a request's card since 0.17.70, demandes.mjs): a word of
|
|
58
|
+
Parley's dictionary and its values, said by each screen in its own language; `t`, the plain English an
|
|
59
|
+
older screen says. Values that are data (a verb, a name, a reason, Tether's own sentence) stay as given. */
|
|
60
|
+
const said = (k, v, t) => ({ k, ...(v ? { v } : {}), t });
|
|
61
|
+
const TOPIC_REQUEST = Object.freeze({ k: 'line-topic-request', t: 'Request' });
|
|
62
|
+
const TOPIC_NOTICE = Object.freeze({ k: 'line-topic-notice', t: 'Later news' });
|
|
63
|
+
/* A call that ended without being done (not accepted): how it ended, by its outcome. */
|
|
64
|
+
const ENDED = {
|
|
65
|
+
no: ['line-refused', 'Refused'],
|
|
66
|
+
timeout: ['line-timeout', 'No answer in time'],
|
|
67
|
+
withdrawn: ['line-withdrawn', 'Withdrawn by the agent'],
|
|
68
|
+
stopped: ['line-stopped', 'Stopped'],
|
|
69
|
+
};
|
|
70
|
+
export function endedLine(verb, outcome) {
|
|
71
|
+
if (outcome === 'yes' || outcome === 'always') return said('line-accepted', { verb }, `Accepted: ${verb} — being done`);
|
|
72
|
+
const [k, head] = ENDED[outcome] ?? ['line-handled', 'Request handled'];
|
|
73
|
+
return said(k, { verb }, `${head}: ${verb}`);
|
|
74
|
+
}
|
|
75
|
+
export function resultLine(verb, error) {
|
|
76
|
+
if (error === undefined) return said('line-done', { verb }, `Done: ${verb}`);
|
|
77
|
+
const reason = String(error ?? '').trim();
|
|
78
|
+
return reason ? said('line-failed', { verb, reason }, `Failed: ${verb} — ${reason}`) : said('line-failed-plain', { verb }, `Failed: ${verb}`);
|
|
79
|
+
}
|
|
80
|
+
export function noticeLine(kind, target, text) {
|
|
81
|
+
const head = noticeWord(kind);
|
|
82
|
+
if (target && text) return said('line-notice', { head, target, text }, `${head.t} (${target}): ${text}`);
|
|
83
|
+
if (text) return said('line-notice-said', { head, text }, `${head.t}: ${text}`);
|
|
84
|
+
if (target) return said('line-notice-at', { head, target }, `${head.t} (${target})`);
|
|
85
|
+
return head;
|
|
86
|
+
}
|
|
34
87
|
|
|
35
88
|
export class Tethers {
|
|
36
|
-
#keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0; #seen = new Map(); #offered; #ended = new Map(); #acting = [];
|
|
89
|
+
#keeper; #resources; #conversations; #secrets; #dockets; #timers = []; #changes = 0; #seen = new Map(); #offered; #noticed; #ended = new Map(); #acting = [];
|
|
37
90
|
/* Set by the server once the thread is ready (main.mjs): (name, event) => talk.event(...).
|
|
38
91
|
A call waiting for the owner is said in its conversation's thread when there is one. */
|
|
39
92
|
announce = null;
|
|
40
93
|
|
|
41
94
|
/* `resources`: Resources (workFolder). `conversations()`: the names of the conversations.
|
|
42
|
-
`secrets`: the vault, read by name for a connector only (reveal).
|
|
43
|
-
|
|
44
|
-
|
|
95
|
+
`secrets`: the vault, read by name for a connector only (reveal). `dockets`: { on(name), post(name,
|
|
96
|
+
{kind, text, data}) } (dockets.mjs): what wakes an agent told of a notice. `make`: the keeper (tests). */
|
|
97
|
+
constructor({ dataDir, resources, conversations, secrets, connectors, dockets = null, now = () => Date.now(), make = keeper }) {
|
|
98
|
+
this.#resources = resources; this.#conversations = conversations; this.#secrets = secrets; this.#dockets = dockets;
|
|
45
99
|
this.#offered = new JsonFile(`${dataDir}/tether-offered.json`, []);
|
|
46
|
-
this.#
|
|
100
|
+
this.#noticed = new JsonFile(`${dataDir}/tether-notices-seen.json`, []);
|
|
101
|
+
this.#keeper = make(`${dataDir}/tether`, { sides: () => this.#sides(), secrets: (name) => this.#reveal(name), notify: (n) => this.#notified(n), now, ...(connectors ? { connectors } : {}) });
|
|
47
102
|
/* Every change a page shows -- a new approval waiting, one decided, the targets,
|
|
48
103
|
the journal -- bumps the counter the client watches, so the approvals screen
|
|
49
104
|
sees them all at once, not only when a store change happens to wake it. */
|
|
@@ -84,7 +139,7 @@ export class Tethers {
|
|
|
84
139
|
/* `request`: the card Parley draws (demandes.mjs); the text and its buttons stay for an older screen. */
|
|
85
140
|
let request;
|
|
86
141
|
try { request = demandeView(r); } catch { request = undefined; }
|
|
87
|
-
try { this.announce(name, { kind: 'tether-demande', text: text || (r.verb ?? 'A Tether call'), topic:
|
|
142
|
+
try { this.announce(name, { kind: 'tether-demande', text: text || (r.verb ?? 'A Tether call'), topic: TOPIC_REQUEST, tone: 'warn', actions: [`allow:${r.id}`, `deny:${r.id}`], ...(request ? { request } : {}) }); } catch { /* its chat is off */ }
|
|
88
143
|
}
|
|
89
144
|
/* An approved call only the owner's browser can do (a device to flash): said once, with where to do it. */
|
|
90
145
|
let jobs = [];
|
|
@@ -96,7 +151,9 @@ export class Tethers {
|
|
|
96
151
|
if (!who.startsWith(AGENT)) continue;
|
|
97
152
|
const name = who.slice(AGENT.length);
|
|
98
153
|
this.#seen.set(j.id, { name, verb: j.verb });
|
|
99
|
-
|
|
154
|
+
const text = j.args?.name ? said('line-flash', { name: String(j.args.name) }, `To do in your browser: flash ${j.args.name}. Plug it in by USB here, then start.`)
|
|
155
|
+
: said('line-flash-device', undefined, 'To do in your browser: flash a device. Plug it in by USB here, then start.');
|
|
156
|
+
try { this.announce(name, { kind: 'tether-job', text, topic: TOPIC_REQUEST, tone: 'warn', actions: [`flash:${j.id}`] }); } catch { /* its chat is off */ }
|
|
100
157
|
}
|
|
101
158
|
for (const [id, info] of [...this.#seen]) {
|
|
102
159
|
if (live.has(id)) continue;
|
|
@@ -107,8 +164,8 @@ export class Tethers {
|
|
|
107
164
|
fail): said as being done, and its result said when Tether journals it (#tellResult). */
|
|
108
165
|
const accepted = outcome === 'yes' || outcome === 'always';
|
|
109
166
|
if (accepted) { this.#acting.push({ id, ...info }); if (this.#acting.length > ACTING_MAX) this.#acting.shift(); }
|
|
110
|
-
const text =
|
|
111
|
-
try { this.announce(info.name, { kind: 'tether-done', text, topic:
|
|
167
|
+
const text = endedLine(info.verb, outcome);
|
|
168
|
+
try { this.announce(info.name, { kind: 'tether-done', text, topic: TOPIC_REQUEST, brief: id, ...(outcome ? { outcome } : {}) }); } catch { /* its chat is off */ }
|
|
112
169
|
}
|
|
113
170
|
for (const id of [...this.#ended.keys()]) if (!this.#seen.has(id)) this.#ended.delete(id);
|
|
114
171
|
}
|
|
@@ -124,8 +181,37 @@ export class Tethers {
|
|
|
124
181
|
if (i < 0) return;
|
|
125
182
|
const [call] = this.#acting.splice(i, 1);
|
|
126
183
|
const failed = l.ok === false;
|
|
127
|
-
const text =
|
|
128
|
-
try { this.announce(call.name, { kind: 'tether-done', text, topic:
|
|
184
|
+
const text = resultLine(call.verb, failed ? (l.error ?? '') : undefined);
|
|
185
|
+
try { this.announce(call.name, { kind: 'tether-done', text, topic: TOPIC_REQUEST, ...(failed ? { tone: 'bad', level: 'needs-you' } : {}) }); } catch { /* its chat is off */ }
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* A NOTICE (Tether calls `notify`): said once in the thread of the conversation whose agent did it,
|
|
189
|
+
and that agent woken through its docket where its chat is on (elsewhere its next Tether call
|
|
190
|
+
tells it: Tether puts what is new first in its answer). Each notice id kept, so a notice handed
|
|
191
|
+
twice -- or again after a restart -- is said once. An agent that is no conversation of this server: nothing. */
|
|
192
|
+
#notified(n) {
|
|
193
|
+
const id = String(n?.id ?? '');
|
|
194
|
+
const who = String(n?.agent ?? '');
|
|
195
|
+
if (!id || !who.startsWith(AGENT)) return;
|
|
196
|
+
const name = who.slice(AGENT.length);
|
|
197
|
+
let names;
|
|
198
|
+
try { names = this.#conversations(); } catch { return; }
|
|
199
|
+
if (!name || !names.includes(name)) return;
|
|
200
|
+
const seen = this.#noticed.get();
|
|
201
|
+
if (!Array.isArray(seen) || seen.includes(id)) return;
|
|
202
|
+
try { this.#noticed.set([...seen, id].slice(-NOTICES_MAX)); } catch { /* said anyway, this once */ }
|
|
203
|
+
const kind = String(n.kind ?? '');
|
|
204
|
+
const warns = noticeWarns(kind);
|
|
205
|
+
/* Clavarium's head and frame in the reader's words; Tether's own sentence as Tether wrote it. */
|
|
206
|
+
const line = noticeLine(kind, n.target?.title ? String(n.target.title) : '', String(n.text ?? '').trim());
|
|
207
|
+
const text = line.t;
|
|
208
|
+
try { this.announce?.(name, { kind: 'tether-notice', text: line, topic: TOPIC_NOTICE, ...(warns ? { tone: 'warn', level: 'needs-you' } : {}) }); } catch { /* its chat is off */ }
|
|
209
|
+
try {
|
|
210
|
+
if (this.#dockets?.on(name)) {
|
|
211
|
+
this.#dockets.post(name, { kind: 'tether-notice', text: `${text}${/[.!?]$/.test(text) ? '' : '.'} See more: tether notices.`,
|
|
212
|
+
data: { notice: id, kind, ...(n.ref ? { ref: String(n.ref) } : {}), ...(n.target?.id ? { target: String(n.target.id) } : {}) } });
|
|
213
|
+
}
|
|
214
|
+
} catch { /* its docket: its next Tether call tells it */ }
|
|
129
215
|
}
|
|
130
216
|
|
|
131
217
|
/* A secret's value for a connector, by name, from this server's vault; never seen by the agent.
|
package/web/app.js
CHANGED
|
@@ -3387,6 +3387,7 @@
|
|
|
3387
3387
|
['docket-failed', 'Could not be handled', 'Said failed by the tool, with why'],
|
|
3388
3388
|
['docket-unhandled', 'Not handled', 'Told three times, never said done'],
|
|
3389
3389
|
['docket-reminder', 'Reminder set', 'A reminder the tool set itself'],
|
|
3390
|
+
['tether-notice', 'Later news', 'A mail came back, an invitation was declined'],
|
|
3390
3391
|
['machine-problem', 'Machine in trouble', 'Memory, disk, no answer, a failed restart'],
|
|
3391
3392
|
['machine-ok', 'Machine well again', 'What was wrong with it went away'],
|
|
3392
3393
|
['restarted', 'Machine restarted', 'Restarted or built again'],
|