clavarium 0.2.323-next.1 → 0.2.325-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.
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.323-next.1",
3
+ "version": "0.2.325-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.323-next.1",
9
+ "version": "0.2.325-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
14
  "clavarium-binder": "0.1.60-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
- "clavarium-parley": "0.17.67-next.1",
16
+ "clavarium-parley": "0.17.69-next.1",
17
17
  "clavarium-tether": "0.1.0-next.49",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
@@ -787,9 +787,9 @@
787
787
  }
788
788
  },
789
789
  "node_modules/clavarium-parley": {
790
- "version": "0.17.67-next.1",
791
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.67-next.1.tgz",
792
- "integrity": "sha512-6dQaElIA0BJi8ruT6uS8k+eRstjnBqVbwKLWZxsJwH6PVtr1CVQ7/9KzUuKabc5+PN+v8oBFFE8iZh4HHYq3qQ==",
790
+ "version": "0.17.69-next.1",
791
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.69-next.1.tgz",
792
+ "integrity": "sha512-NDT/l1J97PKnaNSu1srD+cldqMRRISfzBckwH2odMFaGLTtXnxHSVLifpZxEojwoRU2OPKXuNTQj1ZLLR3oPkg==",
793
793
  "license": "MIT",
794
794
  "bin": {
795
795
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.323-next.1",
3
+ "version": "0.2.325-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.",
@@ -46,7 +46,7 @@
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.67-next.1",
49
+ "clavarium-parley": "0.17.69-next.1",
50
50
  "clavarium-tether": "0.1.0-next.49",
51
51
  "mammoth": "1.13.0",
52
52
  "mermaid": "11.17.2",
package/server/api.mjs CHANGED
@@ -156,6 +156,7 @@ import { list, download, importFile, page, PAGE_HEADERS, changeRoute, IMAGE_HEAD
156
156
  import { WORK_TAB } from './resources.mjs';
157
157
  import { transcribe, AUDIO_MAX } from './voice.mjs';
158
158
  import { FILE_MAX } from './setup.mjs';
159
+ import { demandeView } from './demandes.mjs';
159
160
 
160
161
  const BODY_MAX = 16 * 1024;
161
162
  /* A setup file travels inside the JSON of a request: room for it, escaped. */
@@ -297,7 +298,13 @@ export async function handleApi(request, response, conversations, headers, resou
297
298
  if (pathname === '/api/accounts' && accounts) return send(200, { supported: accounts.supported() }), true;
298
299
  /* Assets > Access: the targets, who was given each at which level, the
299
300
  calls waiting, and the recent journal -- all the page needs to read. */
300
- if (pathname === '/api/tether' && tethers) { const r = await tethers.act('state', { agent: query.get('agent') ?? undefined }, ''); return send(200, { given: tethers.given(), changes: tethers.changes(), ...(r.data ?? {}) }), true; }
301
+ /* Each call waiting carries `view`: the card Parley draws for it (demandes.mjs), the same as in the thread. */
302
+ if (pathname === '/api/tether' && tethers) {
303
+ const r = await tethers.act('state', { agent: query.get('agent') ?? undefined }, '');
304
+ const data = r.data ?? {};
305
+ const approvals = Array.isArray(data.approvals) ? data.approvals.map((q) => { try { return { ...q, view: demandeView(q) }; } catch { return q; } }) : data.approvals;
306
+ return send(200, { given: tethers.given(), changes: tethers.changes(), ...data, ...(approvals ? { approvals } : {}) }), true;
307
+ }
301
308
  /* Every device, each with all it was given. */
302
309
  if (pathname === '/api/devices' && sharing) return send(200, sharing.devices.all()), true;
303
310
  if (pathname === '/api/git-keys' && gitAccess) return send(200, gitAccess.keys()), true;
@@ -0,0 +1,140 @@
1
+ /* A TETHER CALL WAITING FOR THE OWNER, AS PLAIN DATA FOR PARLEY'S REQUEST CARD (05-11, "B enrichie").
2
+ *
3
+ * One sentence that says what will happen ("Send “Quote” to sales@example.com"), one or two key
4
+ * facts, what should make one think (someone outside, a time already taken, administrator
5
+ * rights), and, unfolded, the facts, before -> after, the first lines of the text. Parley draws it
6
+ * (requestCard, docs/protocol.md "A request, as a card") wherever it is shown: in the thread
7
+ * (tethers.mjs puts it on the line that asks) and in Assets › Demandes (GET /api/tether gives it
8
+ * with each call). Built from `q.card`, the facts Tether attaches (server/cards.mjs), and
9
+ * `q.card.about`, what the act is about when its connector can tell (the event before a change).
10
+ *
11
+ * IRREVERSIBLE (an amber edge, unfolded when newest, never in "Accept all"): a mail that leaves
12
+ * the owner's domain (not a draft), any delete, a change or delete of an event others are invited
13
+ * to, a command run on a machine. The accept waits HOLD_S seconds with Undo before it is sent to
14
+ * Tether (the page holds it; Tether has no undo once decided). */
15
+ export const HOLD_S = 5;
16
+ const KINDS = new Set(['mail', 'calendar', 'contacts', 'files', 'terminal', 'browser', 'screen', 'device']);
17
+
18
+ const hhmm = (when) => /[T ](\d{2}:\d{2})/.exec(String(when ?? ''))?.[1] ?? '';
19
+ const dayWords = (when) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(when ?? '')); return m ? new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], 12)).toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' }) : String(when ?? ''); };
20
+ const span = (from, to) => [hhmm(from), hhmm(to)].filter(Boolean).join('–');
21
+ const whenWords = (from, to) => [dayWords(from), span(from, to)].filter(Boolean).join(' · ');
22
+ const nameOfAddr = (a) => { const m = /^\s*"?([^"<]*?)"?\s*<([^>]+)>/.exec(String(a ?? '')); return m && m[1] ? m[1] : String(a ?? '').split('@')[0]; };
23
+ const subj = (s) => (s ? `“${s}”` : 'a message');
24
+ const sizeOf = (kb) => (kb >= 1024 ? `${(kb / 1024).toFixed(1)} MB` : `${kb} KB`);
25
+ const filesLine = (files) => (files?.length ? files.map((f) => `${f.name}${f.kb ? ` (${sizeOf(f.kb)})` : ''}`).join(', ') : '');
26
+ const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
27
+ /* Whom: the first, and how many more. */
28
+ const whom = (list) => (list.length ? `${list[0]}${list.length > 1 ? ` +${list.length - 1}` : ''}` : '');
29
+ /* The body as it will read: the Markdown marks taken off. */
30
+ const plain = (body) => String(body ?? '').replace(/\*\*(\S[^*\n]*?)\*\*/g, '$1').replace(/__(\S[^_\n]*?)__/g, '$1').replace(/(^|[^*\w])\*(\S[^*\n]*?)\*(?!\w)/g, '$1$2')
31
+ .replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g, '$1 ($2)').replace(/^#{1,6}\s+/gm, '');
32
+
33
+ export function demandeView(q) {
34
+ const c = q?.card ?? {}; const about = c.about ?? {};
35
+ const kind = KINDS.has(c.kind) ? c.kind : 'other';
36
+ const own = String(c.self ?? '').split('@')[1] ?? '';
37
+ const outside = (list) => (own ? (list ?? []).filter((x) => !String(x).toLowerCase().endsWith(`@${own}`)) : []);
38
+ const chips = (list, ext = []) => (list ?? []).map((x) => ({ text: String(x), ...(ext.includes(x) ? { ext: true } : {}) }));
39
+ const where = q?.target?.title ?? '';
40
+ const v = { kind, title: '', sub: '', risk: [], facts: [], irreversible: false, yes: 'Accept' };
41
+ const sub = [];
42
+ if (c.kind === 'mail') {
43
+ const recipients = [...(c.to ?? []), ...(c.cc ?? []), ...(c.bcc ?? [])];
44
+ const ext = outside(recipients);
45
+ const sending = ['send', 'reply', 'forward'].includes(c.action);
46
+ if (sending && ext.length) v.risk.push('Goes outside your domain');
47
+ const sendWord = c.draft ? 'Save draft' : c.at ? 'Schedule' : 'Send';
48
+ const to = whom(c.to ?? []);
49
+ if (c.action === 'send') { v.title = c.draft ? `Draft ${subj(c.subject)}${to ? ` to ${to}` : ''}` : `${sendWord} ${subj(c.subject)}${to ? ` to ${to}` : ''}`; v.yes = sendWord; }
50
+ else if (c.action === 'reply') { v.title = `${c.all ? 'Reply to all on' : 'Reply to'} ${about.from ? nameOfAddr(about.from) : 'a message'}${about.subject ? ` on “${about.subject}”` : ''}`; v.yes = sendWord; }
51
+ else if (c.action === 'forward') {
52
+ v.title = `Forward ${subj(about.subject)}${to ? ` to ${to}` : ''}`; v.yes = c.draft ? 'Save draft' : 'Forward';
53
+ const k = String(c.keep ?? 'all').toLowerCase();
54
+ v.facts.push(['Keeps', /^(none|false|no)$/.test(k) ? 'without its files' : /^(all|true|yes|)$/.test(k) ? (about.files?.length ? filesLine(about.files) : 'its files') : String(c.keep)]);
55
+ } else if (c.action === 'move') { v.title = `Move ${subj(about.subject)} to ${c.mailbox ?? 'a folder'}`; v.yes = 'Move'; }
56
+ else if (c.action === 'flag') { v.title = `Mark ${subj(about.subject)} ${c.flag ?? ''}`.trim(); v.yes = 'Mark'; }
57
+ else if (c.action === 'delete') { v.title = `Delete ${subj(about.subject)}`; v.yes = 'Delete'; v.irreversible = true; }
58
+ else v.title = `${c.action ?? 'mail'} ${q?.detail ?? ''}`.trim();
59
+ if (sending && !c.draft && ext.length) v.irreversible = true;
60
+ if (about.from && c.action !== 'reply') v.facts.push(['From', String(about.from)]);
61
+ if (about.date && !sending) v.facts.push(['Date', String(about.date)]);
62
+ if (c.to?.length) v.facts.push(['To', chips(c.to, ext)]);
63
+ if (c.cc?.length) v.facts.push(['Cc', chips(c.cc, ext)]);
64
+ if (c.bcc?.length) v.facts.push(['Bcc', chips(c.bcc, ext)]);
65
+ if (c.files?.length) v.facts.push(['Joined', filesLine(c.files)]);
66
+ if (c.at) v.facts.push(['Leaves', `${whenWords(c.at)} (waits in Drafts)`]);
67
+ if (where) sub.push(where);
68
+ if (c.body) { const lines = String(c.body).split('\n').length; sub.push(plural(lines, 'line')); v.quote = plain(c.body); }
69
+ if (c.files?.length) sub.push(plural(c.files.length, 'attachment'));
70
+ } else if (c.kind === 'calendar') {
71
+ const answer = { accept: 'Accept', yes: 'Accept', decline: 'Decline', no: 'Decline', refuse: 'Decline', tentative: 'Maybe', maybe: 'Maybe' }[String(c.answer ?? '').toLowerCase()] ?? '';
72
+ const was = c.action === 'create' ? null : about;
73
+ const ev = c.action === 'create' ? c : { ...about, ...Object.fromEntries(Object.entries(c).filter(([k]) => ['title', 'start', 'end', 'where'].includes(k))) };
74
+ const name = was?.title || c.title || 'an event';
75
+ const guests = c.action === 'create' || c.action === 'update' ? (c.with?.length ? c.with : (about.attendees ?? [])) : (about.attendees ?? []);
76
+ const ext = outside(c.with ?? []);
77
+ if (c.action === 'respond') v.title = `${answer || 'Answer'} “${about.title || 'an invitation'}”${about.start ? ` (${whenWords(about.start, about.end)})` : ''}`;
78
+ else if (c.action === 'create') v.title = `Create “${c.title ?? 'New event'}”${c.start ? ` ${whenWords(c.start, c.end)}` : ''}`;
79
+ else if (c.action === 'delete') v.title = `Delete “${name}”${about.start ? ` (${whenWords(about.start, about.end)})` : ''}`;
80
+ else if (c.action === 'update') v.title = (c.start && c.start !== about.start) ? `Move “${name}” to ${whenWords(c.start, c.end ?? about.end)}` : `Change “${name}”`;
81
+ else if (c.action === 'attach') v.title = `Attach ${filesLine(c.files)} to “${name}”`;
82
+ else v.title = `${c.action ?? 'calendar'} ${q?.detail ?? ''}`.trim();
83
+ /* Before -> after: what changes of a change, and the event itself otherwise. */
84
+ if (c.action === 'update' && was?.start) {
85
+ v.before = [whenWords(was.start, was.end), was.where].filter(Boolean);
86
+ v.after = [whenWords(ev.start, ev.end), ev.where].filter(Boolean);
87
+ sub.push(`was ${whenWords(was.start, was.end)}`);
88
+ } else if (ev.start) { if (c.action !== 'respond' && c.action !== 'delete' && c.action !== 'create') sub.push(whenWords(ev.start, ev.end)); if (ev.where) v.facts.push(['Where', String(ev.where)]); }
89
+ if (guests.length && ['update', 'delete'].includes(c.action)) { sub.push(`${plural(guests.length, 'guest')} told`); v.irreversible = true; }
90
+ if (about.clashes?.length) v.risk.push(`Clashes with ${about.clashes.join(', ')}`);
91
+ if (ext.length) v.risk.push('Invites someone outside your domain');
92
+ if (about.organizer && c.action === 'respond') v.facts.push(['From', String(about.organizer)]);
93
+ if (guests.length) v.facts.push(['Guests', chips(guests, ext)]);
94
+ if (c.online === 'teams' || (c.action === 'create' && (c.with ?? []).length && !c.online)) v.facts.push(['Online', 'Teams meeting']);
95
+ if (where) sub.unshift(where);
96
+ if (c.notes) v.quote = String(c.notes);
97
+ v.yes = c.action === 'respond' ? (answer || 'Answer') : c.action === 'create' ? ((c.with ?? []).length ? 'Create and invite' : 'Create') : c.action === 'delete' ? 'Delete' : c.action === 'update' ? (v.before ? 'Move' : 'Change') : 'Accept';
98
+ if (c.action === 'delete') v.irreversible = true;
99
+ } else if (c.kind === 'contacts') {
100
+ v.title = c.action === 'create' ? `Add ${c.name || c.email || 'a contact'}` : c.action === 'update' ? `Update ${c.name || 'a contact'}` : c.action === 'delete' ? `Delete ${c.name || 'a contact'}` : c.action === 'attach' ? `Set ${c.name ? `${c.name}'s` : 'a contact\'s'} photo` : `${c.action ?? 'contacts'} ${q?.detail ?? ''}`.trim();
101
+ if (c.name && c.action !== 'create') v.facts.push(['Name', String(c.name)]);
102
+ if (c.email) v.facts.push(['Email', String(c.email)]);
103
+ if (c.phone) v.facts.push(['Phone', String(c.phone)]);
104
+ if (where) sub.push(where);
105
+ if (c.email && c.action === 'create') sub.push(String(c.email));
106
+ v.yes = c.action === 'create' ? 'Add' : c.action === 'delete' ? 'Delete' : 'Update';
107
+ if (c.action === 'delete') v.irreversible = true;
108
+ } else if (c.kind === 'terminal') {
109
+ const on = where || 'a machine';
110
+ v.title = c.action === 'run' ? `Run a command on ${on}` : c.action === 'type' ? `Type into a terminal on ${on}` : `Open a terminal on ${on}`;
111
+ if (/^\s*sudo\b/.test(c.command ?? '')) v.risk.push('As administrator');
112
+ if (c.command || c.text) { v.code = String(c.command ?? c.text); sub.push(v.code.split('\n')[0].slice(0, 60)); }
113
+ v.yes = c.action === 'run' ? 'Run' : c.action === 'type' ? 'Type' : 'Open';
114
+ if (c.action === 'run') v.irreversible = true;
115
+ } else if (c.kind === 'files') {
116
+ v.title = c.action === 'write' ? `Write ${c.path}` : c.action === 'delete' ? `Delete ${c.path}` : c.action === 'move' ? `Move ${c.from} → ${c.to}` : `${c.action ?? 'files'} ${c.path ?? ''}`.trim();
117
+ if (where) sub.push(where);
118
+ if (c.bytes !== undefined) { const size = c.bytes >= 1024 ? `${Math.round(c.bytes / 1024)} KB` : `${c.bytes} bytes`; sub.push(size); v.facts.push(['Size', size]); }
119
+ if (c.action === 'move') { v.before = [String(c.from ?? '')]; v.after = [String(c.to ?? '')]; }
120
+ else if (c.path) v.facts.push(['Path', String(c.path)]);
121
+ v.yes = c.action === 'delete' ? 'Delete' : c.action === 'move' ? 'Move' : 'Write';
122
+ if (c.action === 'delete') { v.irreversible = true; v.risk.push('Cannot be undone'); }
123
+ } else if (c.kind === 'browser' && c.action === 'open') { v.title = `Open ${c.url}`; v.yes = 'Open'; if (where) sub.push(where); }
124
+ else { v.title = `${q?.verb ?? 'action'}${q?.detail ? ` ${q.detail}` : ''}`; if (where) sub.push(where); }
125
+ const id = String(q?.id ?? '');
126
+ return {
127
+ kind, title: v.title || String(q?.verb ?? 'A request'), sub: sub.filter(Boolean).slice(0, 3).join(' · '),
128
+ ...(v.risk.length ? { risk: v.risk } : {}), ...(v.facts.length ? { facts: v.facts } : {}),
129
+ ...(v.before ? { before: v.before, after: v.after } : {}),
130
+ ...(v.quote ? { quote: v.quote } : {}), ...(v.code ? { code: v.code } : {}),
131
+ ...(q?.why ? { why: String(q.why) } : {}),
132
+ /* The technical line, in "See all" only. */
133
+ detail: [q?.verb, q?.detail].filter(Boolean).join(' — '),
134
+ irreversible: v.irreversible,
135
+ yes: { id: `allow:${id}`, label: v.yes }, no: { id: `deny:${id}`, label: 'Refuse' },
136
+ /* "Always allow ...": behind "⋯", as before. */
137
+ ...(q?.rule ? { others: [{ id: `always:${id}`, label: `Always allow ${q.rule.value ?? 'this'}` }] } : {}),
138
+ hold: HOLD_S,
139
+ };
140
+ }
package/server/talk.mjs CHANGED
@@ -174,6 +174,8 @@ const TOPIC_MAX = 40;
174
174
  const BRIEF_MAX = 60;
175
175
  const ACTIONS_MAX = 4;
176
176
  const ACTION = /^[a-z]{1,20}(:[a-z0-9][a-z0-9._-]{0,63})?$/;
177
+ const REQUEST_MAX = 8000;
178
+ const OUTCOMES = ['yes', 'always', 'no', 'timeout', 'withdrawn', 'stopped'];
177
179
  /* Where the person's files go, in the bridge folder; one folder per file, named by an id. */
178
180
  const FILES = 'files';
179
181
  const ATTACHED = new RegExp(`^/work/\\${FOLDER}/${FILES}/([0-9a-f-]{36})/([^/]+)$`);
@@ -574,7 +576,7 @@ export class Talk {
574
576
  Only where the chat is on; never counted as unread (the page counts
575
577
  the tool's messages only); at most SYSTEM_MAX kept. Resolves with the
576
578
  line kept, or null. `actions`: ids the page maps to buttons. */
577
- event(name, { kind, text, level, tone, topic, brief, actions = [] } = {}) {
579
+ event(name, { kind, text, level, tone, topic, brief, actions = [], request, outcome } = {}) {
578
580
  if (!Object.hasOwn(EVENT_LEVELS, kind)) throw new RangeError(`No such kind of event: ${kind}`);
579
581
  const said = String(text ?? '').trim();
580
582
  if (!said) return null;
@@ -589,6 +591,10 @@ export class Talk {
589
591
  ...(topic ? { topic: String(topic).slice(0, TOPIC_MAX) } : {}),
590
592
  ...(brief ? { brief: String(brief).slice(0, BRIEF_MAX) } : {}),
591
593
  actions: (Array.isArray(actions) ? actions : []).filter((a) => typeof a === 'string' && ACTION.test(a)).slice(0, ACTIONS_MAX),
594
+ /* A request's card, as Parley draws it (demandes.mjs): plain data, bounded. */
595
+ ...(request && typeof request === 'object' && !Array.isArray(request) && JSON.stringify(request).length <= REQUEST_MAX ? { request } : {}),
596
+ /* How the call a line closes ended (tether-done): yes, always, no, timeout, withdrawn, stopped. */
597
+ ...(OUTCOMES.includes(outcome) ? { outcome } : {}),
592
598
  };
593
599
  return this.#line(name, line);
594
600
  }
@@ -22,6 +22,7 @@
22
22
  import { mkdirSync, lstatSync } from 'node:fs';
23
23
  import { keeper } from 'clavarium-tether/host';
24
24
  import { JsonFile } from './store.mjs';
25
+ import { demandeView } from './demandes.mjs';
25
26
 
26
27
  export const FOLDER = '.tether';
27
28
  /* The keeper takes what the agents asked, this often. */
@@ -30,7 +31,7 @@ const AGENT = 'conversation:';
30
31
  export const USB_DEVICE = 'usb-device';
31
32
 
32
33
  export class Tethers {
33
- #keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0; #seen = new Map(); #offered;
34
+ #keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0; #seen = new Map(); #offered; #ended = new Map();
34
35
  /* Set by the server once the thread is ready (main.mjs): (name, event) => talk.event(...).
35
36
  A call waiting for the owner is said in its conversation's thread when there is one. */
36
37
  announce = null;
@@ -44,7 +45,12 @@ export class Tethers {
44
45
  /* Every change a page shows -- a new approval waiting, one decided, the targets,
45
46
  the journal -- bumps the counter the client watches, so the approvals screen
46
47
  sees them all at once, not only when a store change happens to wake it. */
47
- this.#keeper.onChange(() => { this.#changes++; this.#tellNew(); });
48
+ this.#keeper.onChange((what) => {
49
+ /* How a call ended (yes, always, no, timeout, withdrawn, stopped): said on the line that closes its card. */
50
+ const end = what?.approvals;
51
+ if (end?.op === 'end' && end.id) this.#ended.set(end.id, String(end.decision ?? ''));
52
+ this.#changes++; this.#tellNew();
53
+ });
48
54
  /* A device plugged into the owner's computer: one target, always there, flashed from the
49
55
  owner's browser (Tether's device connector). The owner gives it to a conversation as any other. */
50
56
  try {
@@ -70,7 +76,10 @@ export class Tethers {
70
76
  this.#seen.set(r.id, { name, verb: r.verb ?? 'action' });
71
77
  const what = [r.verb ?? 'action', r.detail].filter(Boolean).join(' ');
72
78
  const text = [what, r.target?.title ? `(${r.target.title})` : '', r.why ? `-- ${r.why}` : ''].filter(Boolean).join(' ');
73
- try { this.announce(name, { kind: 'tether-demande', text: text || (r.verb ?? 'A Tether call'), topic: 'Demande', tone: 'warn', actions: [`allow:${r.id}`, `deny:${r.id}`] }); } catch { /* its chat is off */ }
79
+ /* `request`: the card Parley draws (demandes.mjs); the text and its buttons stay for an older screen. */
80
+ let request;
81
+ try { request = demandeView(r); } catch { request = undefined; }
82
+ try { this.announce(name, { kind: 'tether-demande', text: text || (r.verb ?? 'A Tether call'), topic: 'Demande', tone: 'warn', actions: [`allow:${r.id}`, `deny:${r.id}`], ...(request ? { request } : {}) }); } catch { /* its chat is off */ }
74
83
  }
75
84
  /* An approved call only the owner's browser can do (a device to flash): said once, with where to do it. */
76
85
  let jobs = [];
@@ -87,8 +96,11 @@ export class Tethers {
87
96
  for (const [id, info] of [...this.#seen]) {
88
97
  if (live.has(id)) continue;
89
98
  this.#seen.delete(id);
90
- try { this.announce(info.name, { kind: 'tether-done', text: `Request handled: ${info.verb}`, topic: 'Demande', brief: id }); } catch { /* its chat is off */ }
99
+ const outcome = this.#ended.get(id) ?? '';
100
+ this.#ended.delete(id);
101
+ try { this.announce(info.name, { kind: 'tether-done', text: `Request handled: ${info.verb}${outcome ? ` (${outcome})` : ''}`, topic: 'Demande', brief: id, ...(outcome ? { outcome } : {}) }); } catch { /* its chat is off */ }
91
102
  }
103
+ for (const id of [...this.#ended.keys()]) if (!this.#seen.has(id)) this.#ended.delete(id);
92
104
  }
93
105
 
94
106
  /* A secret's value for a connector, by name, from this server's vault; never seen by the agent.
package/web/app.js CHANGED
@@ -3003,7 +3003,7 @@
3003
3003
  /* A message attached to a card (#180), from its menu: its id, as the card opens it again. */
3004
3004
  ...(!DEVICE ? { card: (m) => attachToCard({ kind: 'message', ref: m.id, title: String(m.short || m.text || '').replace(/\s+/g, ' ').trim().slice(0, 80) }) } : {}),
3005
3005
  /* The buttons of a line of the machine: what this screen may do. */
3006
- act: (id) => { if (id === 'seen-done') return; if (id.startsWith('salon:')) { void openSalon(id.slice('salon:'.length)); return; } if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id.startsWith('allow:')) void decideTether(id.slice('allow:'.length), 'yes'); else if (id.startsWith('deny:')) void decideTether(id.slice('deny:'.length), 'no'); else if (id.startsWith('flash:')) void flashFromThread(id.slice('flash:'.length)); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
3006
+ act: (id) => { if (id === 'seen-done') return; if (id.startsWith('salon:')) { void openSalon(id.slice('salon:'.length)); return; } if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (/^(allow|deny|always):/.test(id)) void decideTether(id.slice(id.indexOf(':') + 1), DECISION[id.slice(0, id.indexOf(':'))], () => thread?.refresh?.()); else if (id.startsWith('flash:')) void flashFromThread(id.slice('flash:'.length)); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
3007
3007
  /* What it opens over the thread (a picture, its media, a search...) is a step of this page's: one Back closes it. */
3008
3008
  back: { open: (name, close) => nav.over(`chat-${name}`, () => close(), { stack: true }), closed: (step) => { if (step) nav.drop(step); } },
3009
3009
  /* Files attached to a message: wherever the chat may be written in. */
@@ -3140,7 +3140,8 @@
3140
3140
  const ACTIONS = { memory: 'More memory...', disk: 'Give it more disk...', room: 'See what takes room', restart: 'Restart...', terminal: 'See the terminal', review: 'Open the review', seen: '\u2713 Seen', allow: 'Accept', deny: 'Refuse', flash: 'Plug it in and start' };
3141
3141
  const COMMITS = /^commits:([a-z0-9][a-z0-9-]*)\.([0-9a-f]{7,40})\.([0-9a-f]{7,40})\.(\d{1,4})$/;
3142
3142
  /* A Tether call an agent asked the owner to allow, offered right in the thread: allow:<id> / deny:<id>. */
3143
- const DEMANDE = /^(allow|deny|flash):[0-9a-f-]{36}$/;
3143
+ const DEMANDE = /^(allow|deny|always|flash):[0-9a-f-]{36}$/;
3144
+ const DECISION = { allow: 'yes', deny: 'no', always: 'always' };
3144
3145
  const COMMIT = /^commit:([a-z0-9][a-z0-9-]*)\.([0-9a-f]{7,40})$/;
3145
3146
  function openCommits(id) {
3146
3147
  if (DEVICE) return;
@@ -3168,10 +3169,20 @@
3168
3169
  const FIXED_GOES = new Set(['seen', 'room', 'disk', 'memory']);
3169
3170
  /* A Tether demande decided (here, from Assets, or by the agent) is marked done in the thread,
3170
3171
  carrying its id: Accept / Refuse are then offered no more on the line that asked. */
3171
- const settled = new Set(data.messages.filter((m) => m.from === 'system' && m.event === 'tether-done' && m.brief).map((m) => String(m.brief)));
3172
+ const settled = new Map(data.messages.filter((m) => m.from === 'system' && m.event === 'tether-done' && m.brief).map((m) => [String(m.brief), m]));
3173
+ /* Its card (Parley's request, demandes.mjs): decided, it folds to one line -- accepted, refused, or no longer
3174
+ waiting (timed out, taken back by the agent, stopped); where this screen may not decide, no buttons. */
3175
+ const requestOf = (m) => {
3176
+ const r = m.request;
3177
+ const id = /^allow:(.+)$/.exec(String(r.yes?.id ?? ''))?.[1] ?? '';
3178
+ const done = id ? settled.get(id) : null;
3179
+ if (done) { const o = String(done.outcome ?? ''); return { ...r, state: { decision: o === 'yes' || o === 'always' ? 'yes' : o === 'no' ? 'no' : 'ended', at: String(done.at ?? '') } }; }
3180
+ if (!may(String(r.yes?.id ?? ''))) { const { yes: _y, no: _n, others: _o, ...shown } = r; return shown; }
3181
+ return r;
3182
+ };
3172
3183
  const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(FIXED_GOES.has(id) && fixedAt && String(m.at ?? '') < fixedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1))))
3173
3184
  .map((id) => (id === 'seen' && seenAt && String(m.at ?? '') <= seenAt ? { id: 'seen-done', label: seenWords } : { id, label: label(id) }));
3174
- return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m) } : m)) };
3185
+ return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m), ...(m.request && typeof m.request === 'object' ? { request: requestOf(m) } : {}) } : m)) };
3175
3186
  }
3176
3187
  /* ITS MACHINE, on the side of the detailed chat: as this page last knew it. */
3177
3188
  function withMachine(data, name) {
@@ -4758,140 +4769,6 @@
4758
4769
  catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
4759
4770
  if (after) await after(); else await paintAssets();
4760
4771
  }
4761
- /* ONE TETHER CALL WAITING FOR THE OWNER, AS A CARD (#190): what it does in plain words,
4762
- then who / when / where in short lines, what should make one think (someone outside,
4763
- a time already taken, administrator rights) in an amber band, the AI's reason in a grey
4764
- line, and one row of buttons -- the act's own verb, Refuse beside it, "Always…" behind
4765
- "⋯". The whole card opens its detail (the technical line too). An accept waits a few
4766
- seconds with "Undo" before it goes. Built from `q.card` (Tether); a call without one
4767
- keeps its line. `withWho`: name the conversation that asks. */
4768
- const UNDO_MS = 5000;
4769
- const dayChip = (when) => {
4770
- const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(when ?? ''));
4771
- if (!m) return null;
4772
- const d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], 12));
4773
- const chip = el('div', 'dm-day');
4774
- chip.append(el('div', 'dm-day-w', d.toLocaleDateString('en-GB', { weekday: 'short', timeZone: 'UTC' }).toUpperCase()), el('div', 'dm-day-n', String(+m[3])));
4775
- return chip;
4776
- };
4777
- const hhmm = (when) => /[T ](\d{2}:\d{2})/.exec(String(when ?? ''))?.[1] ?? '';
4778
- const dayWords = (when) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(when ?? '')); return m ? new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], 12)).toLocaleDateString('en-GB', { weekday: 'long', day: 'numeric', month: 'short', timeZone: 'UTC' }) : String(when ?? ''); };
4779
- const span = (from, to) => [hhmm(from), hhmm(to)].filter(Boolean).join(' – ') || [from, to].filter(Boolean).join(' – ');
4780
- const nameOfAddr = (a) => { const m = /^\s*"?([^"<]*?)"?\s*<([^>]+)>/.exec(String(a ?? '')); return m && m[1] ? m[1] : String(a ?? '').split('@')[0]; };
4781
- const askedAgo = (at) => { const s = Math.round((Date.now() - Date.parse(at)) / 1000); if (!Number.isFinite(s)) return ''; return s < 60 ? 'just now' : s < 3600 ? `${Math.round(s / 60)} min ago` : s < 86400 ? `${Math.round(s / 3600)} h ago` : `${Math.round(s / 86400)} d ago`; };
4782
- const KIND_ICON = { mail: '✉', calendar: '📅', contacts: '👤', terminal: '⌘', files: '🗎', browser: '🌐', screen: '🖥', other: '•' };
4783
- /* What a card says, from its facts: { title, day?, sub?, facts: [[icon, text|node]], quote?, risk: [], yes } */
4784
- function demandeWords(q) {
4785
- const c = q.card ?? {}; const about = c.about ?? {};
4786
- const own = String(c.self ?? '').split('@')[1] ?? '';
4787
- const outside = (list) => (own ? (list ?? []).filter((x) => !String(x).toLowerCase().endsWith(`@${own}`)) : []);
4788
- const chips = (list, ext = []) => { const box = el('span', 'dm-chips'); for (const x of list ?? []) box.append(el('span', `dm-chip${ext.includes(x) ? ' ext' : ''}`, ext.includes(x) ? `${x} · outside` : x)); return box; };
4789
- const w = { facts: [], risk: [], yes: 'Accept' };
4790
- const subj = (s) => (s ? `“${s}”` : 'a message');
4791
- const filesLine = (files) => (files?.length ? files.map((f) => `${f.name}${f.kb ? ` (${f.kb >= 1024 ? `${(f.kb / 1024).toFixed(1)} MB` : `${f.kb} KB`})` : ''}`).join(', ') : '');
4792
- if (c.kind === 'mail') {
4793
- const ext = outside([...(c.to ?? []), ...(c.cc ?? []), ...(c.bcc ?? [])]);
4794
- if (ext.length) w.risk.push(`Goes outside: ${ext.join(', ')}`);
4795
- const sendWord = c.draft ? 'Save draft' : c.at ? 'Schedule' : 'Send';
4796
- if (c.action === 'send') { w.title = `${c.draft ? 'Draft' : 'Send'} ${subj(c.subject)}`; w.yes = sendWord; }
4797
- else if (c.action === 'reply') { w.title = `${c.all ? 'Reply to all on' : 'Reply to'} ${about.from ? nameOfAddr(about.from) : 'a message'}`; if (about.subject) w.facts.push(['≡', `On “${about.subject}”`]); w.yes = sendWord; }
4798
- else if (c.action === 'forward') {
4799
- w.title = `Forward ${subj(about.subject)}`; w.yes = c.draft ? 'Save draft' : 'Forward';
4800
- const k = String(c.keep ?? 'all').toLowerCase();
4801
- const kept = /^(none|false|no)$/.test(k) ? 'without its files' : /^(all|true|yes|)$/.test(k) ? (about.files?.length ? `with ${filesLine(about.files)}` : 'with its files') : `keeping ${c.keep}`;
4802
- w.facts.push(['📎', kept]);
4803
- } else if (c.action === 'move') { w.title = `Move ${subj(about.subject)} to ${c.mailbox ?? 'a folder'}`; w.yes = 'Move'; }
4804
- else if (c.action === 'flag') { w.title = `Mark ${subj(about.subject)} ${c.flag ?? ''}`.trim(); w.yes = 'Mark'; }
4805
- else if (c.action === 'delete') { w.title = `Delete ${subj(about.subject)}`; w.yes = 'Delete'; }
4806
- else w.title = `${c.action ?? 'mail'} ${q.detail ?? ''}`;
4807
- if (about.from && c.action !== 'reply') w.facts.push(['👤', `From ${about.from}`]);
4808
- if (c.to?.length) w.facts.push(['→', chips(c.to, ext)]);
4809
- if (c.cc?.length) w.facts.push(['cc', chips(c.cc, ext)]);
4810
- if (c.bcc?.length) w.facts.push(['bcc', chips(c.bcc, ext)]);
4811
- if (c.at) w.facts.push(['⏰', `Leaves ${dayWords(c.at)}${hhmm(c.at) ? `, ${hhmm(c.at)}` : ''} — waits in Drafts until then`]);
4812
- if (c.files?.length) w.facts.push(['📎', `Joined: ${filesLine(c.files)}`]);
4813
- /* The body as it will read: the Markdown marks taken off. */
4814
- if (c.body) w.quote = c.body.replace(/\*\*(\S[^*\n]*?)\*\*/g, '$1').replace(/__(\S[^_\n]*?)__/g, '$1').replace(/(^|[^*\w])\*(\S[^*\n]*?)\*(?!\w)/g, '$1$2').replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g, '$1 ($2)').replace(/^#{1,6}\s+/gm, '');
4815
- } else if (c.kind === 'calendar') {
4816
- const ev = c.action === 'create' ? c : { ...about, ...Object.fromEntries(Object.entries(c).filter(([k]) => ['title', 'start', 'end', 'where'].includes(k))) };
4817
- const answer = { accept: 'Accept', yes: 'Accept', decline: 'Decline', no: 'Decline', refuse: 'Decline', tentative: 'Maybe', maybe: 'Maybe' }[String(c.answer ?? '').toLowerCase()] ?? '';
4818
- w.day = dayChip(ev.start);
4819
- w.title = c.action === 'respond' ? `${answer || 'Answer'}: ${about.title || 'an invitation'}` : c.action === 'create' ? (c.title ?? 'New event') : c.action === 'delete' ? `Delete “${about.title || 'an event'}”` : c.action === 'update' ? `Change “${about.title || c.title || 'an event'}”` : c.action === 'attach' ? `Attach ${filesLine(c.files)} to “${about.title || 'an event'}”` : `${c.action} ${q.detail ?? ''}`;
4820
- if (ev.start) w.sub = `${dayWords(ev.start)} · ${span(ev.start, ev.end)}${ev.where ? ` · ${ev.where}` : ''}`;
4821
- if (about.clashes?.length) w.risk.push(`Clashes with ${about.clashes.join(', ')}`);
4822
- if (about.organizer && c.action === 'respond') w.facts.push(['👤', `From ${about.organizer}${about.attendees?.length ? ` · with ${about.attendees.length} people` : ''}`]);
4823
- const guests = c.with ?? [];
4824
- const ext = outside(guests);
4825
- if (ext.length) w.risk.push(`Invites someone outside: ${ext.join(', ')}`);
4826
- if (guests.length) w.facts.push(['👥', chips(guests, ext)]);
4827
- if (c.online === 'teams' || (c.action === 'create' && guests.length && !c.online)) w.facts.push(['🎥', 'With a Teams meeting (Microsoft)']);
4828
- if (c.notes) w.quote = c.notes;
4829
- w.yes = c.action === 'respond' ? (answer || 'Answer') : c.action === 'create' ? (guests.length ? 'Create and invite' : 'Create') : c.action === 'delete' ? 'Delete' : c.action === 'update' ? 'Change' : 'Accept';
4830
- } else if (c.kind === 'contacts') {
4831
- w.title = c.action === 'create' ? `Add ${c.name || c.email || 'a contact'}` : c.action === 'update' ? `Update ${c.name || 'a contact'}` : c.action === 'delete' ? 'Delete a contact' : c.action === 'attach' ? 'Set a contact\'s photo' : `${c.action} ${q.detail ?? ''}`;
4832
- if (c.email) w.facts.push(['✉', c.email]); if (c.phone) w.facts.push(['☎', c.phone]);
4833
- w.yes = c.action === 'create' ? 'Add' : c.action === 'delete' ? 'Delete' : 'Update';
4834
- } else if (c.kind === 'terminal') {
4835
- w.title = c.action === 'run' ? `Run a command on ${q.target?.title ?? 'a machine'}` : c.action === 'type' ? `Type into a terminal on ${q.target?.title ?? 'a machine'}` : `Open a terminal on ${q.target?.title ?? 'a machine'}`;
4836
- if (/^\s*sudo\b/.test(c.command ?? '')) w.risk.push('As administrator');
4837
- if (c.command || c.text) { const code = el('code', '', c.command ?? c.text); w.facts.push(['›_', code]); }
4838
- w.yes = c.action === 'run' ? 'Run' : 'Accept';
4839
- } else if (c.kind === 'files') {
4840
- w.title = c.action === 'write' ? `Write ${c.path}` : c.action === 'delete' ? `Delete ${c.path}` : c.action === 'move' ? `Move ${c.from} → ${c.to}` : `${c.action} ${c.path ?? ''}`;
4841
- if (c.bytes !== undefined) w.facts.push(['≡', `${c.bytes >= 1024 ? `${Math.round(c.bytes / 1024)} KB` : `${c.bytes} bytes`}`]);
4842
- w.yes = c.action === 'delete' ? 'Delete' : c.action === 'move' ? 'Move' : 'Write';
4843
- } else if (c.kind === 'browser' && c.action === 'open') { w.title = `Open ${c.url}`; w.yes = 'Open'; }
4844
- else { w.title = `${q.verb ?? 'action'}${q.detail ? ` ${q.detail}` : ''}`; }
4845
- return w;
4846
- }
4847
- function demandeRow(q, { withWho = false, after } = {}) {
4848
- const kind = q.card?.kind ?? String(q.verb ?? '').split('.')[0];
4849
- const w = demandeWords(q);
4850
- const card = el('div', `given-row demande dm-card dm-${kind}`);
4851
- const top = el('div', 'dm-top');
4852
- top.append(el('span', 'dm-ico', KIND_ICON[kind] ?? '•'), el('span', '', [q.target?.title, withWho ? q.agent?.name : '', askedAgo(q.at)].filter(Boolean).join(' · ')), el('span', 'dm-chev', '›'));
4853
- const head = el('div', 'dm-head');
4854
- if (w.day) head.append(w.day);
4855
- const hw = el('div', 'dm-hw'); hw.append(el('b', 'dm-title', w.title)); if (w.sub) hw.append(el('div', 'dm-sub', w.sub)); head.append(hw);
4856
- card.append(top, head);
4857
- for (const r of w.risk) card.append(el('div', 'dm-risk', `⚠ ${r}`));
4858
- if (w.facts.length) { const f = el('div', 'dm-facts'); for (const [ic, v] of w.facts) { f.append(el('span', 'dm-k', ic)); const cell = el('span', 'dm-v'); if (typeof v === 'string') cell.textContent = v; else cell.append(v); f.append(cell); } card.append(f); }
4859
- if (w.quote) card.append(el('div', 'dm-quote', w.quote));
4860
- if (q.why) card.append(el('div', 'dm-why', `Why: ${q.why}`));
4861
- /* The detail: the whole card opens it -- the technical line, its level, its rule. */
4862
- const more = el('div', 'dm-more'); more.hidden = true;
4863
- more.append(el('div', '', `${q.verb ?? ''}${q.detail ? ` — ${q.detail}` : ''}`), el('div', 'hint', [q.target?.title, q.agent?.name, q.level ? `level ${q.level}` : ''].filter(Boolean).join(' · ')));
4864
- card.append(more);
4865
- card.addEventListener('click', (e) => { if (e.target.closest('button')) return; more.hidden = !more.hidden; card.classList.toggle('open', !more.hidden); });
4866
- const acts = el('div', 'dm-acts');
4867
- const yes = el('button', 'primary', w.yes); yes.type = 'button';
4868
- const no = el('button', '', 'Refuse'); no.type = 'button';
4869
- const buttons = [yes, no];
4870
- let always = null;
4871
- if (q.rule) {
4872
- const dots = el('button', 'dm-dots', '⋯'); dots.type = 'button'; dots.setAttribute('aria-label', 'More');
4873
- always = el('button', '', `Always allow ${q.rule.value ?? 'this'}`); always.type = 'button'; always.hidden = true;
4874
- dots.addEventListener('click', () => { always.hidden = !always.hidden; });
4875
- acts.append(dots); buttons.push(always);
4876
- }
4877
- acts.append(no, yes);
4878
- card.append(acts);
4879
- if (always) card.append(always);
4880
- const lock = (on) => { for (const b of buttons) b.disabled = on; };
4881
- /* Accept: a few seconds to take it back, then it goes. Refuse goes at once (nothing happens). */
4882
- const accept = (decision) => {
4883
- lock(true);
4884
- const undo = el('div', 'dm-undo'); const ub = el('button', '', 'Undo'); ub.type = 'button';
4885
- undo.append(el('span', '', decision === 'always' ? 'Allowed, and from now on' : `${w.yes} — accepted`), ub);
4886
- acts.replaceWith(undo);
4887
- const timer = setTimeout(() => { ub.disabled = true; void decideTether(q.id, decision, after); }, UNDO_MS);
4888
- ub.addEventListener('click', () => { clearTimeout(timer); undo.replaceWith(acts); lock(false); });
4889
- };
4890
- yes.addEventListener('click', () => accept('yes'));
4891
- always?.addEventListener('click', () => accept('always'));
4892
- no.addEventListener('click', () => { lock(true); void decideTether(q.id, 'no', after); });
4893
- return card;
4894
- }
4895
4772
  /* Every call waiting for the owner, on one surface. `withWho`: name who asks. */
4896
4773
  /* A JOB: a call the owner approved that only this browser can do -- a device to flash
4897
4774
  over USB. The browser lets only a click reach a USB device, so it waits for one; then
@@ -4935,9 +4812,23 @@
4935
4812
  }
4936
4813
  return jobPlaces.get(job.id);
4937
4814
  }
4815
+ /* EVERY CALL WAITING FOR THE OWNER, AS CARDS: Parley's own request card (requestCard), the very one
4816
+ the thread shows, from the same data (`q.view`, server/demandes.mjs) -- one gesture, one
4817
+ implementation. Accept waits a few seconds with Undo (Parley holds it), then goes to Tether.
4818
+ `withWho`: name the conversation that asks. `after` repaints the surface it sits in. */
4819
+ let cardSteps = null;
4938
4820
  function demandesList(approvals, { withWho = false, after } = {}) {
4939
- const box = el('div', 'as-users demandes-box');
4940
- for (const q of approvals) box.append(demandeRow(q, { withWho, after }));
4821
+ const box = el('div', 'demandes-box');
4822
+ const act = (id) => { const m = /^(allow|deny|always):(.+)$/.exec(id); if (m) void decideTether(m[2], DECISION[m[1]], after); };
4823
+ void Promise.all([import(new URL('vendor/parley-ui.js', new URL('/', location.href)).href), readWords()]).then(([P, words]) => {
4824
+ if (typeof P.requestCard !== 'function') return;
4825
+ cardSteps ??= P.stepper({ open: (name, close) => nav.over(`demande-${name}`, () => close(), { stack: true }), closed: (step) => { if (step) nav.drop(step); } });
4826
+ for (const q of approvals) {
4827
+ if (!q.view) continue;
4828
+ const view = withWho && q.agent?.name ? { ...q.view, sub: [q.agent.name, q.view.sub].filter(Boolean).join(' · ') } : q.view;
4829
+ box.append(P.requestCard(view, { act, words, steps: cardSteps, host: document.body }));
4830
+ }
4831
+ });
4941
4832
  return box;
4942
4833
  }
4943
4834
  /* While the owner is on Assets or a room, the calls waiting for them appear and update
package/web/style.css CHANGED
@@ -453,7 +453,7 @@ footer button.careful { border-style: dashed; color: var(--ink2); }
453
453
  #chat-off p { margin: 0 0 10px; font-size: 1rem; }
454
454
  #chat-off p + p { color: var(--ink2); }
455
455
  #simple[data-chat] { display: flex; flex-direction: column; overflow: hidden; padding: 10px 14px 12px; }
456
- #simple-thread { flex: 1; min-height: 0; --parley-bg: var(--bg); --parley-text: var(--ink); --parley-dim: var(--ink2); --parley-line: var(--line); --parley-agent: var(--panel); --parley-person: var(--bar); --parley-ask: var(--brass-ink); --parley-wait: var(--wait); --parley-ok: var(--ok); --parley-action: var(--brass-ink); --parley-on-action: var(--on-brass); --parley-live: var(--danger); }
456
+ #simple-thread { flex: 1; min-height: 0; --parley-risk: var(--warn); --parley-bg: var(--bg); --parley-text: var(--ink); --parley-dim: var(--ink2); --parley-line: var(--line); --parley-agent: var(--panel); --parley-person: var(--bar); --parley-ask: var(--brass-ink); --parley-wait: var(--wait); --parley-ok: var(--ok); --parley-action: var(--brass-ink); --parley-on-action: var(--on-brass); --parley-live: var(--danger); }
457
457
 
458
458
 
459
459
  /* Private repositories: how the server gets in, and the keys made here. */
@@ -2109,35 +2109,9 @@ details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wr
2109
2109
  .tool-exit-lines { max-height: 14rem; overflow: auto; font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bar); padding: .5rem .6rem; border-radius: 8px; margin: .3rem 0; }
2110
2110
  .curve-legend-oom { color: var(--danger); }
2111
2111
 
2112
- /* A request of the AI as a card (#190). */
2113
- .dm-card.given-row { display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; padding: 10px 12px; cursor: pointer; position: relative; text-align: left; }
2114
- .dm-card > * { align-self: stretch; text-align: left; }
2115
- .dm-card > .dm-risk, .dm-card > .dm-acts { align-self: stretch; }
2116
- .dm-top { display: flex; justify-content: flex-start; gap: 8px; align-items: center; font-size: .8125rem; color: var(--ink2); }
2117
- .dm-ico { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--button); font-size: .8125rem; flex: none; }
2118
- .dm-chev { margin-left: auto; font-size: 1.125rem; line-height: 1; transition: transform .15s; }
2119
- .dm-card.open .dm-chev { transform: rotate(90deg); }
2120
- .dm-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
2121
- .dm-hw { min-width: 0; }
2122
- .dm-title { font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
2123
- .dm-sub { color: var(--ink2); font-size: .875rem; }
2124
- .dm-day { width: 46px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
2125
- .dm-day-w { background: var(--brass); color: var(--on-brass); font-size: .6875rem; font-weight: 600; letter-spacing: .06em; padding: 1px 0; }
2126
- .dm-day-n { font-size: 1.125rem; font-weight: 600; padding: 1px 0 3px; }
2127
- .dm-risk { padding: 5px 9px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: inherit; font-size: .875rem; font-weight: 600; }
2128
- .dm-facts { display: grid; justify-content: start; justify-items: start; grid-template-columns: 1.6em minmax(0, 1fr); gap: 3px 6px; font-size: .875rem; }
2129
- .dm-k { color: var(--ink2); text-align: center; }
2130
- .dm-v { min-width: 0; overflow-wrap: anywhere; }
2131
- .dm-chips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
2132
- .dm-chip { border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: .8125rem; }
2133
- .dm-chip.ext { border-color: color-mix(in srgb, var(--warn) 70%, transparent); }
2134
- .dm-quote { border-left: 3px solid var(--line); padding: 1px 9px; font-size: .875rem; white-space: pre-line; max-height: 7.5em; overflow: hidden; }
2135
- .dm-card.open .dm-quote { max-height: none; }
2136
- .dm-why { color: var(--ink2); font-size: .875rem; }
2137
- .dm-more { font-size: .8125rem; font-family: ui-monospace, monospace; overflow-wrap: anywhere; border-top: 1px dashed var(--line); padding-top: 6px; }
2138
- .dm-acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
2139
- .dm-acts .dm-dots { padding-inline: .7em; }
2140
- .dm-undo { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: .875rem; padding: 4px 0; }
2112
+ /* A request of the AI as a card (#190): Parley's own (requestCard), the same in the thread and here; its colours, this page's. */
2113
+ .demandes-box, body > .parley-request-shade { --parley-bg: var(--panel); --parley-text: var(--ink); --parley-dim: var(--ink2); --parley-line: var(--line); --parley-agent: var(--bar); --parley-ask: var(--brass-ink); --parley-ok: var(--ok); --parley-action: var(--brass-ink); --parley-risk: var(--warn); --parley-code-bg: var(--bar); }
2114
+ .demandes-box { display: flex; flex-direction: column; gap: 10px; }
2141
2115
  .as-signature { display: flex; flex-direction: column; gap: 6px; margin: .6rem 0; }
2142
2116
  .as-signature textarea { width: 100%; font: inherit; }
2143
2117
  .as-drag-ghost { position: fixed; z-index: 90; pointer-events: none; opacity: .9; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); border-radius: 10px; background: var(--panel); }
@@ -2328,7 +2302,7 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
2328
2302
  .salon-members-row > .hint { width: 4.5rem; }
2329
2303
  .salon-member { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; }
2330
2304
  .salon-host { font-size: .6875rem; color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
2331
- #salon-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 14px 12px; --parley-bg: var(--bg); --parley-text: var(--ink); --parley-dim: var(--ink2); --parley-line: var(--line); --parley-agent: var(--panel); --parley-person: var(--bar); --parley-ask: var(--brass-ink); --parley-wait: var(--wait); --parley-ok: var(--ok); --parley-action: var(--brass-ink); --parley-on-action: var(--on-brass); --parley-live: var(--danger); }
2305
+ #salon-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 14px 12px; --parley-risk: var(--warn); --parley-bg: var(--bg); --parley-text: var(--ink); --parley-dim: var(--ink2); --parley-line: var(--line); --parley-agent: var(--panel); --parley-person: var(--bar); --parley-ask: var(--brass-ink); --parley-wait: var(--wait); --parley-ok: var(--ok); --parley-action: var(--brass-ink); --parley-on-action: var(--on-brass); --parley-live: var(--danger); }
2332
2306
 
2333
2307
  .salon-thinking { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0 14px 8px; font-size: .75rem; color: var(--ink2); order: 2; }
2334
2308
  #salon-new { display: flex; flex-direction: column; }