clavarium-parley 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium-parley",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A bridge between a command-line agent and a screen of its own: a command and an MCP server of five verbs, and a small library that shows the exchange.",
@@ -33,7 +33,7 @@ import { fileURLToPath } from 'node:url';
33
33
  import { randomUUID } from 'node:crypto';
34
34
  import { createInterface } from 'node:readline';
35
35
 
36
- export const VERSION = '0.13.2';
36
+ export const VERSION = '0.13.3';
37
37
  /* A message may be long: the screen folds it, and shows its short version first. */
38
38
  export const TEXT_MAX = 16000;
39
39
  /* Its short version: a title of one or two lines. */
package/ui/parley-ui.js CHANGED
@@ -173,7 +173,7 @@ export const VIEWS = Object.freeze(['simple', 'detailed']);
173
173
  export const KEYS = Object.freeze(['send', 'placeholder', 'empty', 'view', 'simple', 'detailed', 'working', 'waiting', 'done', 'no-status', 'asks', 'open', 'outside',
174
174
  'not-read', 'read', 'remind', 'reminded', 'steps', 'no-steps', 'files', 'no-files', 'terminal', 'not-sent', 'step-one', 'steps-many', 'today', 'yesterday', 'quiet', 'stopped',
175
175
  'mic', 'mic-stop', 'auto-send', 'auto-on', 'settings', 'voice-placeholder', 'voice-calibrating', 'voice-listening', 'voice-hearing', 'voice-transcribing', 'voice-wait', 'voice-off', 'replies', 'replies-more', 'replies-less',
176
- 'attach', 'remove-file', 'sending-files', 'attach-where', 'draw-open', 'draw-marked', 'draw-colour', 'draw-undo', 'draw-clear', 'draw-cancel', 'draw-done', 'draw-note', 'draw-hint',
176
+ 'attach', 'remove-file', 'sending-files', 'attach-where', 'draw-open', 'draw-again', 'drawn-from', 'draw-marked', 'draw-colour', 'draw-undo', 'draw-clear', 'draw-cancel', 'draw-done', 'draw-note', 'draw-hint',
177
177
  'copy', 'copied', 'see-details', 'see-more', 'see-less', 'note', 'tip', 'important', 'warning', 'caution', 'badge-ok', 'badge-todo', 'badge-blocked', 'badge-warn',
178
178
  'waits-you', 'waits-you-note', 'busy', 'pulse', 'state-sent', 'state-read', 'state-working', 'state-done', 'sent-at', 'read-at', 'done-at',
179
179
  'reply', 'replying', 'not-a-reply', 'in-reply', 'closed', 'you', 'agent', 'drop', 'picture', 'diagram', 'not-shown', 'grouped',
@@ -1019,6 +1019,7 @@ function zoomer(root, words, steps) {
1019
1019
  if (kind === 'left') b.append(icon('chevron-left', 'parley-sign'));
1020
1020
  else if (kind === 'right') b.append(icon('chevron-right', 'parley-sign'));
1021
1021
  else if (kind === 'close') b.append(icon('x', 'parley-sign'));
1022
+ else if (kind === 'draw') b.append(icon('pencil', 'parley-sign'));
1022
1023
  else if (kind === 'minus' || kind === 'plus') b.append(sign(kind));
1023
1024
  b.append(el('span', short ? 'parley-zoom-short' : 'parley-zoom-word', short ? said(words, short) : said(words, key)));
1024
1025
  b.addEventListener('click', act); return b;
@@ -1088,6 +1089,11 @@ function zoomer(root, words, steps) {
1088
1089
  const next = tool('right', 'next', () => go(1));
1089
1090
  const tools = el('div', 'parley-zoom-tools'); tools.setAttribute('role', 'group');
1090
1091
  tools.append(tool('minus', 'zoom-out', () => zoomTo(s / 1.5)), tool('plus', 'zoom-in', () => zoomTo(s * 1.5)), tool('actual', 'zoom-actual', () => zoomTo(1), 'zoom-actual-short'), tool('fit', 'zoom-fit', fitIn, 'zoom-fit-short'), prev, next);
1092
+ /* Drawn on, and sent again: the picture shown, taken into the box with its source (the chat says where). */
1093
+ let annotate = null;
1094
+ const redraw = tool('draw', 'draw-again', () => { const item = list[at]; if (!item || !annotate) return; close(); void annotate(item); });
1095
+ redraw.hidden = true;
1096
+ tools.append(redraw);
1091
1097
  const shut = tool('close', 'close', () => close(), 'close');
1092
1098
  bar.append(title, tools, shut);
1093
1099
  box.append(bar, stage, strip);
@@ -1108,6 +1114,7 @@ function zoomer(root, words, steps) {
1108
1114
  title.textContent = `${item.title || item.name}${list.length > 1 ? ` (${at + 1}/${list.length})` : ''}`;
1109
1115
  title.title = item.name;
1110
1116
  prev.hidden = next.hidden = list.length < 2;
1117
+ redraw.hidden = !annotate;
1111
1118
  img.style.transition = ''; img.style.opacity = ''; box.style.opacity = ''; delete box.dataset.dragging; delete box.dataset.sliding;
1112
1119
  const same = img.getAttribute('src') === item.url;
1113
1120
  img.src = item.url; img.alt = item.title || item.name;
@@ -1209,6 +1216,8 @@ function zoomer(root, words, steps) {
1209
1216
  },
1210
1217
  get open() { return !box.hidden; },
1211
1218
  close,
1219
+ /* `fn(item)`: what "draw on it and send it" does; none: not offered. */
1220
+ set annotate(fn) { annotate = typeof fn === 'function' ? fn : null; },
1212
1221
  };
1213
1222
  }
1214
1223
 
@@ -1489,7 +1498,7 @@ export function mount(root, { load, send, words = {}, open, terminal, remind, vi
1489
1498
  /* The pictures of the thread, each once: one shown in a gallery and cited in a text is one picture, as in the media. */
1490
1499
  const zoomFrom = (img) => {
1491
1500
  const seen = new Map();
1492
- for (const i of thread.querySelectorAll('img[data-zoom]')) if (!seen.has(i.dataset.zoom)) seen.set(i.dataset.zoom, { url: i.dataset.zoom, name: i.dataset.name || i.alt || '', title: i.dataset.title || '' });
1501
+ for (const i of thread.querySelectorAll('img[data-zoom]')) if (!seen.has(i.dataset.zoom)) seen.set(i.dataset.zoom, { url: i.dataset.zoom, name: i.dataset.name || i.alt || '', title: i.dataset.title || '', from: i.closest('.parley-said')?.dataset.id ?? '' });
1493
1502
  const all = [...seen.values()];
1494
1503
  zoom.show(all, Math.max(0, all.findIndex((x) => x.url === img.dataset.zoom)), img);
1495
1504
  };
@@ -1847,7 +1856,7 @@ export function mount(root, { load, send, words = {}, open, terminal, remind, vi
1847
1856
  const cell = el('figure', 'parley-media-item');
1848
1857
  const b = el('button', 'parley-media-thumb'); b.type = 'button'; b.title = `${x.f.title} - ${x.f.name}`;
1849
1858
  const img = el('img'); img.src = x.url; img.alt = x.f.title; img.loading = 'lazy'; b.append(img);
1850
- b.addEventListener('click', () => zoom.show(inOrder.map((y) => ({ url: y.url, name: y.f.name, title: y.f.title })), inOrder.indexOf(x), img));
1859
+ b.addEventListener('click', () => zoom.show(inOrder.map((y) => ({ url: y.url, name: y.f.name, title: y.f.title, from: y.f.id ?? '' })), inOrder.indexOf(x), img));
1851
1860
  const where = button(said(words, 'see-in-thread'), 'parley-media-where', () => find(x.f.id));
1852
1861
  where.title = x.f.when;
1853
1862
  cell.append(b, el('figcaption', '', x.f.title), where);
@@ -2129,6 +2138,27 @@ export function mount(root, { load, send, words = {}, open, terminal, remind, vi
2129
2138
  };
2130
2139
  /* Files from the button, pasted, or dropped: the same way, the same limits. */
2131
2140
  const add = (files) => { if (!attach?.upload) return; const list = [...files].filter((f) => f && typeof f.name === 'string'); if (!list.length) return; pending = [...pending, ...list].slice(0, FILES_MAX); paintPending(); };
2141
+ /* A PICTURE OF THE CHAT, DRAWN ON AND SENT AGAIN: taken from where it is shown, opened in the
2142
+ same drawing, then waiting in the box as any picture attached -- its note says where it came
2143
+ from, and the message answers the one it was in. Cancelled, nothing is attached. */
2144
+ const drawAgain = async (item) => {
2145
+ if (!attach?.upload || pending.length >= FILES_MAX) return;
2146
+ let blob;
2147
+ try { const r = await fetch(item.url); if (!r.ok) throw new Error(String(r.status)); blob = await r.blob(); } catch (error) { problem.textContent = said(words, 'not-sent', { error: String(error?.message ?? error) }); problem.hidden = false; return; }
2148
+ if (!/^image\/(png|jpeg|gif|webp)$/.test(blob.type)) return;
2149
+ const name = String(item.name || 'picture').replace(/[\\/]/g, '_') || 'picture';
2150
+ const file = new File([blob], /\.[A-Za-z0-9]{1,5}$/.test(name) ? name : `${name}.${blob.type === 'image/jpeg' ? 'jpg' : blob.type.slice(6)}`, { type: blob.type });
2151
+ pending = [...pending, file]; paintPending();
2152
+ const url = previewOf(file);
2153
+ const got = url ? await drawer.edit(file, url, {}) : null;
2154
+ if (!got || (!got.drawn && !got.note)) { pending = pending.filter((f) => f !== file); paintPending(); return; }
2155
+ const source = said(words, 'drawn-from', { name: item.title || item.name || name });
2156
+ marks.set(file, { ...got, note: cut(got.note ? `${got.note} (${source})` : source, 500) });
2157
+ const from = item.from ? latestItems().find((i) => i.id === item.from) : null;
2158
+ if (from && send) { replyTo = { id: from.id, text: cut(from.short || from.text || from.file?.name || name, 90), auto: false }; dismissed.delete(from.id); paintReply(); }
2159
+ paintPending(); focusBox();
2160
+ };
2161
+ zoom.annotate = attach?.upload ? drawAgain : null;
2132
2162
  let uploading = false;
2133
2163
  /* Emptied once sent. A keyboard's own dictation (a tablet's, a phone's) may still be composing the words when
2134
2164
  Send is touched: it puts them back as it ends. What comes back within a moment and is what was sent (or
package/ui/texts/en.json CHANGED
@@ -50,6 +50,8 @@
50
50
  "sending-files": "Sending the files...",
51
51
  "attach-where": "They go to its work folder: it opens them there, and so can whoever has this chat.",
52
52
  "draw-open": "Open {name}: draw on it, add a note",
53
+ "draw-again": "Draw on it and send it",
54
+ "drawn-from": "drawn on {name}, a picture of this chat",
53
55
  "draw-marked": "Drawn on",
54
56
  "draw-colour": "Colour",
55
57
  "draw-undo": "Undo",
package/ui/texts/fr.json CHANGED
@@ -50,6 +50,8 @@
50
50
  "sending-files": "Envoi des fichiers...",
51
51
  "attach-where": "Ils vont dans son dossier de travail : il les ouvre là, comme quiconque a ce chat.",
52
52
  "draw-open": "Ouvrir {name} : dessiner dessus, ajouter une note",
53
+ "draw-again": "Dessiner dessus et la renvoyer",
54
+ "drawn-from": "dessin sur {name}, une image de ce chat",
53
55
  "draw-marked": "Annotée",
54
56
  "draw-colour": "Couleur",
55
57
  "draw-undo": "Défaire",