clavarium 0.2.166-beta.1 → 0.2.167-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.
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.166-beta.1",
3
+ "version": "0.2.167-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.166-beta.1",
9
+ "version": "0.2.167-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.61-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
- "clavarium-parley": "0.17.71-next.1",
16
+ "clavarium-parley": "0.17.73-next.1",
17
17
  "clavarium-tether": "0.1.0-next.54",
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.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==",
790
+ "version": "0.17.73-next.1",
791
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.73-next.1.tgz",
792
+ "integrity": "sha512-JLyxAcpis2dnJg7Qb0alTyw+uuIG/RiIYBeEbnk3K1mzWoWlZKL5z0awox59ZiTyonY1YRJgvazNPVbQQm2iVA==",
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.166-beta.1",
3
+ "version": "0.2.167-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,7 +46,7 @@
46
46
  "@xterm/xterm": "^6.0.0",
47
47
  "clavarium-binder": "0.1.61-next.1",
48
48
  "clavarium-docket": "0.1.2-next.2",
49
- "clavarium-parley": "0.17.71-next.1",
49
+ "clavarium-parley": "0.17.73-next.1",
50
50
  "clavarium-tether": "0.1.0-next.54",
51
51
  "mammoth": "1.13.0",
52
52
  "mermaid": "11.17.2",
@@ -86,6 +86,12 @@ export function demandeView(q) {
86
86
  if (where) sub.push(where);
87
87
  if (c.body) { sub.push(count(String(c.body).split('\n').length, 'req-lines')); v.quote = plain(c.body); }
88
88
  if (c.files?.length) sub.push(count(c.files.length, 'req-attachments'));
89
+ /* The mail it answers, forwards or acts on (Tether's about.ref, 06-11): a chip under the title, « en réponse à
90
+ ✉ Subject · sender », opened in the mail viewer (Parley's `re`, app.js openMailRef) -- read only when tapped. */
91
+ if (typeof about.ref === 'string' && about.ref.startsWith('mail:') && ['reply', 'forward', 'move', 'flag', 'delete'].includes(c.action)) {
92
+ v.re = { ref: about.ref, label: about.subject ? String(about.subject) : w('req-a-message'), ...(about.from ? { note: nameOfAddr(about.from) } : {}),
93
+ ...(c.action === 'reply' ? {} : { lead: w(c.action === 'forward' ? 'request-re-forward' : 'request-re-mail') }) };
94
+ }
89
95
  } else if (c.kind === 'calendar') {
90
96
  const answer = { accept: 'accept', yes: 'accept', decline: 'decline', no: 'decline', refuse: 'decline', tentative: 'maybe', maybe: 'maybe' }[String(c.answer ?? '').toLowerCase()] ?? '';
91
97
  const was = c.action === 'create' ? null : about;
@@ -150,7 +156,7 @@ export function demandeView(q) {
150
156
  kind, title: v.title || (q?.verb ? String(q.verb) : w('req-a-request')), sub: sub.filter(Boolean).slice(0, 3),
151
157
  ...(v.risk.length ? { risk: v.risk } : {}), ...(v.facts.length ? { facts: v.facts } : {}),
152
158
  ...(v.before ? { before: v.before, after: v.after } : {}),
153
- ...(v.quote ? { quote: v.quote } : {}), ...(v.code ? { code: v.code } : {}),
159
+ ...(v.quote ? { quote: v.quote } : {}), ...(v.code ? { code: v.code } : {}), ...(v.re ? { re: v.re } : {}),
154
160
  ...(q?.why ? { why: String(q.why) } : {}),
155
161
  /* The technical line, in "See all" only. */
156
162
  detail: [q?.verb, q?.detail].filter(Boolean).join(' — '),
package/server/guide.mjs CHANGED
@@ -119,6 +119,8 @@ export function ownText({ name, tool, workKept, resources = [], chat, online, se
119
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.');
120
120
  /* How Parley is used is Parley's to say (parley guide); what is here is this chat's: it renders Markdown. */
121
121
  if (chat) out.push('- The chat shows Markdown (lists, tables, "> [!IMPORTANT]") and pictures of /work: ![before](/work/a.png).');
122
+ /* A mail cited by its reference (06-11): a chip the person opens in the mail viewer (Parley's schemes, app.js openMailRef). */
123
+ if (chat) out.push('- To cite a mail, write [its subject](mail:REF) with the ref Tether gives (ref: mail:...), copied whole: the person opens it with a tap.');
122
124
  /* The thread is kept whole: after a restart, its end is read, and further back on demand. */
123
125
  if (chat && reread) out.push(`- After a restart: ${plain(reread, 60)}, the end of the chat; it says how to read further back.`);
124
126
  /* 02-11: the one command a tool may ask of the server. */
package/server/talk.mjs CHANGED
@@ -595,7 +595,7 @@ export class Talk {
595
595
  Only where the chat is on; never counted as unread (the page counts
596
596
  the tool's messages only); at most SYSTEM_MAX kept. Resolves with the
597
597
  line kept, or null. `actions`: ids the page maps to buttons. */
598
- event(name, { kind, text, level, tone, topic, brief, actions = [], request, outcome } = {}) {
598
+ event(name, { kind, text, level, tone, topic, brief, actions = [], request, outcome, re } = {}) {
599
599
  if (!Object.hasOwn(EVENT_LEVELS, kind)) throw new RangeError(`No such kind of event: ${kind}`);
600
600
  const said = lineSaid(text, EVENT_TEXT_MAX);
601
601
  if (said === null) return null;
@@ -614,6 +614,8 @@ export class Talk {
614
614
  actions: (Array.isArray(actions) ? actions : []).filter((a) => typeof a === 'string' && ACTION.test(a)).slice(0, ACTIONS_MAX),
615
615
  /* A request's card, as Parley draws it (demandes.mjs): plain data, bounded. */
616
616
  ...(request && typeof request === 'object' && !Array.isArray(request) && JSON.stringify(request).length <= REQUEST_MAX ? { request } : {}),
617
+ /* What it is about (Parley's `re`, 06-11): the mail that came back, a chip after its text. */
618
+ ...(re && typeof re === 'object' && typeof re.ref === 'string' && re.ref.length <= 2000 && JSON.stringify(re).length <= 4000 ? { re } : {}),
617
619
  /* How the call a line closes ended (tether-done): yes, always, no, timeout, withdrawn, stopped. */
618
620
  ...(OUTCOMES.includes(outcome) ? { outcome } : {}),
619
621
  };
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import { mkdirSync, lstatSync } from 'node:fs';
23
23
  import { keeper } from 'clavarium-tether/host';
24
+ import { mailRef } from 'clavarium-tether/verbs';
24
25
  import { JsonFile } from './store.mjs';
25
26
  import { demandeView } from './demandes.mjs';
26
27
 
@@ -85,6 +86,18 @@ export function noticeLine(kind, target, text) {
85
86
  return head;
86
87
  }
87
88
 
89
+ /* THE MAIL A NOTICE IS ABOUT (06-11): a mail that came back, or is delayed, carries the Message-ID of the mail sent
90
+ (`ref`); with its mailbox, that is a reference (mail:TARGET/ID) the line shows as a chip (Parley's `re`), opened in
91
+ the mail viewer -- its subject, from Tether's sentence, as the chip's label. Other notices: none. */
92
+ const NOTICE_MAILS = new Set(['mail.bounced', 'mail.delayed']);
93
+ export function noticeRe(kind, targetId, messageId, text) {
94
+ if (!NOTICE_MAILS.has(kind) || !targetId || !messageId) return null;
95
+ const ref = mailRef(String(targetId), String(messageId));
96
+ if (!ref) return null;
97
+ const subject = /\bmail "([^"\n]{1,200})"/.exec(String(text ?? ''))?.[1]?.trim();
98
+ return { ref, label: subject || { k: 'req-a-message', t: 'a message' }, lead: { k: 'line-re-sent', t: 'the mail sent' } };
99
+ }
100
+
88
101
  export class Tethers {
89
102
  #keeper; #resources; #conversations; #secrets; #dockets; #timers = []; #changes = 0; #seen = new Map(); #offered; #noticed; #ended = new Map(); #acting = [];
90
103
  /* Set by the server once the thread is ready (main.mjs): (name, event) => talk.event(...).
@@ -205,7 +218,8 @@ export class Tethers {
205
218
  /* Clavarium's head and frame in the reader's words; Tether's own sentence as Tether wrote it. */
206
219
  const line = noticeLine(kind, n.target?.title ? String(n.target.title) : '', String(n.text ?? '').trim());
207
220
  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 */ }
221
+ const re = noticeRe(kind, n.target?.id, n.ref, n.text);
222
+ try { this.announce?.(name, { kind: 'tether-notice', text: line, topic: TOPIC_NOTICE, ...(warns ? { tone: 'warn', level: 'needs-you' } : {}), ...(re ? { re } : {}) }); } catch { /* its chat is off */ }
209
223
  try {
210
224
  if (this.#dockets?.on(name)) {
211
225
  this.#dockets.post(name, { kind: 'tether-notice', text: `${text}${/[.!?]$/.test(text) ? '' : '.'} See more: tether notices.`,
package/web/app.js CHANGED
@@ -2998,6 +2998,9 @@
2998
2998
  label: (ref) => (/^file:\/(work|resources)\//.test(ref) ? 'Open' : null),
2999
2999
  open: (ref) => { const m = /^file:\/(work|resources\/[^/]+)\/(.+)$/.exec(ref); if (!m) return; const tab = m[1] === 'work' ? 'work' : m[1].slice('resources/'.length); void openFromChat(tab, m[2]); },
3000
3000
  },
3001
+ /* A mail it cites ([Subject](mail:TARGET/ID), Parley's schemes), what a request answers, the mail that came back:
3002
+ a chip that opens the mail viewer, read when tapped, by whoever may read that mailbox (else the viewer says so). */
3003
+ schemes: { mail: { icon: 'mail', open: (ref, label) => { void openMailRef(ref, { label, of: name }); } } },
3001
3004
  /* A reaction to one of its messages: wherever the chat may be written in. */
3002
3005
  ...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
3003
3006
  /* A message attached to a card (#180), from its menu: its id, as the card opens it again. */
@@ -4827,7 +4830,9 @@
4827
4830
  for (const q of approvals) {
4828
4831
  if (!q.view) continue;
4829
4832
  const view = withWho && q.agent?.name ? { ...q.view, sub: [q.agent.name, ...(Array.isArray(q.view.sub) ? q.view.sub : [q.view.sub])].filter(Boolean) } : q.view;
4830
- box.append(P.requestCard(view, { act, words, steps: cardSteps, host: document.body }));
4833
+ /* The mail it answers (its `re`): opened in the mail viewer, Reply writing in the chat of the conversation that asks. */
4834
+ const schemes = { mail: { icon: 'mail', open: (ref, label) => { void openMailRef(ref, { label, of: String(q.agent?.id ?? '').startsWith('conversation:') ? q.agent.id.slice('conversation:'.length) : current }); } } };
4835
+ box.append(P.requestCard(view, { act, words, steps: cardSteps, host: document.body, schemes }));
4831
4836
  }
4832
4837
  });
4833
4838
  return box;
@@ -5336,6 +5341,8 @@
5336
5341
  $('salon-thread').dataset.theme = document.documentElement.dataset.theme === 'light' ? 'light' : 'dark';
5337
5342
  salonThread = mount($('salon-thread'), {
5338
5343
  words, markdown: true, agentName: '',
5344
+ /* A mail an AI of the room cites: the same chip and viewer as in a conversation's chat. */
5345
+ schemes: { mail: { icon: 'mail', open: (ref, label) => { void openMailRef(ref, { label }); } } },
5339
5346
  load: (asked = {}) => fetch(`${API}/rooms/${id}/talk${asked.last ? `?last=${asked.last}` : ''}`).then((x) => x.json()).then((d) => {
5340
5347
  /* Who was given a message and has not answered yet (#282): « Hugo réfléchit… ». */
5341
5348
  const who = thinkingOf(d);