clavarium 0.2.327-next.1 → 0.2.329-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/api.mjs +7 -1
- package/server/demandes.mjs +5 -2
- package/server/guide.mjs +1 -1
- package/server/tethers.mjs +28 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.329-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.329-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"clavarium-binder": "0.1.60-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
16
|
"clavarium-parley": "0.17.70-next.1",
|
|
17
|
-
"clavarium-tether": "0.1.0-next.
|
|
17
|
+
"clavarium-tether": "0.1.0-next.52",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
20
20
|
"node-pty": "^1.1.0",
|
|
@@ -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.52",
|
|
804
|
+
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.52.tgz",
|
|
805
|
+
"integrity": "sha512-dlFlZB6z286H6pqWMEWGQ8bAjH69tqvp8eqCDhUmEX1xKCQQV9c0fwlUVOUuS6nua9Uk+RLXXuVeTiiGOEMCiw==",
|
|
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.329-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"clavarium-binder": "0.1.60-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.2-next.2",
|
|
49
49
|
"clavarium-parley": "0.17.70-next.1",
|
|
50
|
-
"clavarium-tether": "0.1.0-next.
|
|
50
|
+
"clavarium-tether": "0.1.0-next.52",
|
|
51
51
|
"mammoth": "1.13.0",
|
|
52
52
|
"mermaid": "11.17.2",
|
|
53
53
|
"node-pty": "^1.1.0",
|
package/server/api.mjs
CHANGED
|
@@ -603,7 +603,13 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
603
603
|
if (renaming && secrets) { const done = secrets.rename(renaming[1], String(body.name ?? '').trim()); await redeliver(String(body.name ?? '').trim()); return send(200, done), true; }
|
|
604
604
|
/* A new value (never sent back) and/or a new expiry, in place. */
|
|
605
605
|
const replacing = /^\/api\/secrets\/([A-Z][A-Z0-9_]{0,39})\/replace$/.exec(pathname);
|
|
606
|
-
if (replacing && secrets) {
|
|
606
|
+
if (replacing && secrets) {
|
|
607
|
+
const done = secrets.replace(replacing[1], { value: body.value, expires: body.expires });
|
|
608
|
+
await redeliver(replacing[1]);
|
|
609
|
+
/* Its new value is in each machine's /run/secrets now; their tools are told again what that means (guide.mjs). */
|
|
610
|
+
for (const c of conversations.list()) if (secrets.of(c.name).includes(replacing[1])) void guide?.changed(c.name).catch(() => {});
|
|
611
|
+
return send(200, done), true;
|
|
612
|
+
}
|
|
607
613
|
const dropped = /^\/api\/secrets\/([A-Z][A-Z0-9_]{0,39})\/remove$/.exec(pathname);
|
|
608
614
|
if (dropped && secrets) { secrets.remove(dropped[1]); return send(200, { ok: true }), true; }
|
|
609
615
|
if (pathname === '/api/alerts' && alerts) return send(201, alerts.add(body.subscription, body.label)), true;
|
package/server/demandes.mjs
CHANGED
|
@@ -104,8 +104,11 @@ export function demandeView(q) {
|
|
|
104
104
|
if (c.action === 'delete') v.irreversible = true;
|
|
105
105
|
} else if (c.kind === 'contacts') {
|
|
106
106
|
const who = (x) => (x ? String(x) : w('req-a-contact'));
|
|
107
|
-
v.title = c.action === 'create' ? w('req-contact-add', { who: who(c.name || c.email) }) : c.action === 'update' ? w('req-contact-update', { who: who(c.name) }) : c.action === 'delete' ? w('req-contact-delete', { who: who(c.name) }) : c.action === 'attach' ? w('req-contact-photo', { who: who(c.name) }) : raw(c.action ?? 'contacts');
|
|
108
|
-
|
|
107
|
+
v.title = c.action === 'create' ? w('req-contact-add', { who: who(c.name || c.email) }) : c.action === 'update' ? w('req-contact-update', { who: who(about.name || c.name) }) : c.action === 'delete' ? w('req-contact-delete', { who: who(about.name || c.name) }) : c.action === 'attach' ? w('req-contact-photo', { who: who(about.name || c.name) }) : raw(c.action ?? 'contacts');
|
|
108
|
+
/* Who it is now (Tether reads the contact before a change or a delete, 05-11), then what changes. */
|
|
109
|
+
if (about.name && c.action !== 'create') v.facts.push(fact('name', String(about.name)));
|
|
110
|
+
if (about.email && c.action !== 'create' && about.email !== c.email) v.facts.push(fact('email', String(about.email)));
|
|
111
|
+
if (c.name && c.action !== 'create' && c.name !== about.name) v.facts.push(fact('name', String(c.name)));
|
|
109
112
|
if (c.email) v.facts.push(fact('email', String(c.email)));
|
|
110
113
|
if (c.phone) v.facts.push(fact('phone', String(c.phone)));
|
|
111
114
|
if (where) sub.push(where);
|
package/server/guide.mjs
CHANGED
|
@@ -130,7 +130,7 @@ export function ownText({ name, tool, workKept, resources = [], chat, online, se
|
|
|
130
130
|
/* Its binder of batches is shown beside the chat (web/app.js): the person ticks there. */
|
|
131
131
|
if (chat) out.push('- When you work in batches: keep them in a binder of batches, shown beside the chat. None yet: make it once (binder new batches; MCP: new-list, template batches). Then one card each (binder add Batches "title"), kept up to date; start only those the person ticked.');
|
|
132
132
|
out.push(online === false ? '- Internet: off.' : '- Internet: on.');
|
|
133
|
-
if (secrets.length) out.push(`- Secrets given, by name only: ${list(secrets.map((s) => plain(s, 40)))}.`);
|
|
133
|
+
if (secrets.length) out.push(`- Secrets given, by name only: ${list(secrets.map((s) => plain(s, 40)))}. Each value is the file /run/secrets/NAME, always the current one (updated within a minute when the person changes it); the variable $NAME holds the value your tool started with -- read the file when you use a key, so a key the person replaced works at once.`);
|
|
134
134
|
/* A secret pasted in the chat is lifted out (talk.mjs, secret-scan.mjs): the message shows a marker, the value waits in /run/secrets. */
|
|
135
135
|
if (chat) out.push('- A secret the person pastes in the chat is kept OUT of it: the message shows ⟨secret:NAME⟩ and the value waits at /run/secrets/NAME for a few minutes. Use it only from there, inside a command (clv-run, or $(cat /run/secrets/NAME)); never write its value back into the chat. It clears itself when its time runs out, or at once with `parley forget NAME` when you are done.');
|
|
136
136
|
const own = lines.map((l) => plain(l)).filter(Boolean).slice(0, LINES_MAX);
|
package/server/tethers.mjs
CHANGED
|
@@ -29,9 +29,11 @@ export const FOLDER = '.tether';
|
|
|
29
29
|
export const PUMP_MS = 1000;
|
|
30
30
|
const AGENT = 'conversation:';
|
|
31
31
|
export const USB_DEVICE = 'usb-device';
|
|
32
|
+
/* Accepted calls whose result is awaited, at most (an act that never ends is forgotten after these). */
|
|
33
|
+
const ACTING_MAX = 200;
|
|
32
34
|
|
|
33
35
|
export class Tethers {
|
|
34
|
-
#keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0; #seen = new Map(); #offered; #ended = new Map();
|
|
36
|
+
#keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0; #seen = new Map(); #offered; #ended = new Map(); #acting = [];
|
|
35
37
|
/* Set by the server once the thread is ready (main.mjs): (name, event) => talk.event(...).
|
|
36
38
|
A call waiting for the owner is said in its conversation's thread when there is one. */
|
|
37
39
|
announce = null;
|
|
@@ -50,6 +52,9 @@ export class Tethers {
|
|
|
50
52
|
const end = what?.approvals;
|
|
51
53
|
if (end?.op === 'end' && end.id) this.#ended.set(end.id, String(end.decision ?? ''));
|
|
52
54
|
this.#changes++; this.#tellNew();
|
|
55
|
+
/* An accepted call is said again once it was done, with how it went: Tether journals each act
|
|
56
|
+
when it ends (ok, or its error). */
|
|
57
|
+
if (what?.journal) this.#tellResult(what.journal);
|
|
53
58
|
});
|
|
54
59
|
/* A device plugged into the owner's computer: one target, always there, flashed from the
|
|
55
60
|
owner's browser (Tether's device connector). The owner gives it to a conversation as any other. */
|
|
@@ -73,7 +78,7 @@ export class Tethers {
|
|
|
73
78
|
const who = r.agent?.id ?? '';
|
|
74
79
|
if (!who.startsWith(AGENT)) continue;
|
|
75
80
|
const name = who.slice(AGENT.length);
|
|
76
|
-
this.#seen.set(r.id, { name, verb: r.verb ?? 'action' });
|
|
81
|
+
this.#seen.set(r.id, { name, verb: r.verb ?? 'action', agent: who, target: r.target?.id ?? '' });
|
|
77
82
|
const what = [r.verb ?? 'action', r.detail].filter(Boolean).join(' ');
|
|
78
83
|
const text = [what, r.target?.title ? `(${r.target.title})` : '', r.why ? `-- ${r.why}` : ''].filter(Boolean).join(' ');
|
|
79
84
|
/* `request`: the card Parley draws (demandes.mjs); the text and its buttons stay for an older screen. */
|
|
@@ -98,11 +103,31 @@ export class Tethers {
|
|
|
98
103
|
this.#seen.delete(id);
|
|
99
104
|
const outcome = this.#ended.get(id) ?? '';
|
|
100
105
|
this.#ended.delete(id);
|
|
101
|
-
|
|
106
|
+
/* Accepted is not done (05-11: "Request handled (yes)" was said before the act, which could still
|
|
107
|
+
fail): said as being done, and its result said when Tether journals it (#tellResult). */
|
|
108
|
+
const accepted = outcome === 'yes' || outcome === 'always';
|
|
109
|
+
if (accepted) { this.#acting.push({ id, ...info }); if (this.#acting.length > ACTING_MAX) this.#acting.shift(); }
|
|
110
|
+
const text = accepted ? `Accepted: ${info.verb} — being done` : `Request handled: ${info.verb}${outcome ? ` (${outcome})` : ''}`;
|
|
111
|
+
try { this.announce(info.name, { kind: 'tether-done', text, topic: 'Demande', brief: id, ...(outcome ? { outcome } : {}) }); } catch { /* its chat is off */ }
|
|
102
112
|
}
|
|
103
113
|
for (const id of [...this.#ended.keys()]) if (!this.#seen.has(id)) this.#ended.delete(id);
|
|
104
114
|
}
|
|
105
115
|
|
|
116
|
+
/* AN ACCEPTED CALL, DONE OR FAILED: the journal line of the act (it carries ok, or its error). Matched by
|
|
117
|
+
the request's id where Tether writes it in the line (0.1.0-next.52 on), else by who, which target and
|
|
118
|
+
which verb -- the oldest accepted call of that kind still waiting for its result. Said in its thread:
|
|
119
|
+
done, a trace; failed, it needs the person, with the reason. */
|
|
120
|
+
#tellResult(l) {
|
|
121
|
+
if (!this.announce || !l || l.op || l.ok === undefined || !(l.decision === 'yes' || l.decision === 'always')) return;
|
|
122
|
+
const i = l.request ? this.#acting.findIndex((x) => x.id === l.request)
|
|
123
|
+
: this.#acting.findIndex((x) => x.agent === l.agent?.id && x.target === (l.target?.id ?? '') && x.verb === l.verb);
|
|
124
|
+
if (i < 0) return;
|
|
125
|
+
const [call] = this.#acting.splice(i, 1);
|
|
126
|
+
const failed = l.ok === false;
|
|
127
|
+
const text = failed ? `Failed: ${call.verb}${l.error ? ` — ${l.error}` : ''}` : `Done: ${call.verb}`;
|
|
128
|
+
try { this.announce(call.name, { kind: 'tether-done', text, topic: 'Demande', ...(failed ? { tone: 'bad', level: 'needs-you' } : {}) }); } catch { /* its chat is off */ }
|
|
129
|
+
}
|
|
130
|
+
|
|
106
131
|
/* A secret's value for a connector, by name, from this server's vault; never seen by the agent.
|
|
107
132
|
An unknown or expired secret is a plain refusal the connector turns into "Refused". */
|
|
108
133
|
async #reveal(name) {
|