clavarium 0.2.118-next.1 → 0.2.121-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.118-next.1",
3
+ "version": "0.2.121-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.118-next.1",
9
+ "version": "0.2.121-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
- "clavarium-binder": "0.1.28-next.1",
14
+ "clavarium-binder": "0.1.31-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
- "clavarium-parley": "0.17.12-next.1",
16
+ "clavarium-parley": "0.17.14-next.1",
17
17
  "clavarium-tether": "0.1.0-next.29",
18
18
  "mermaid": "11.17.2",
19
19
  "node-pty": "^1.1.0",
@@ -716,9 +716,9 @@
716
716
  }
717
717
  },
718
718
  "node_modules/clavarium-binder": {
719
- "version": "0.1.28-next.1",
720
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.28-next.1.tgz",
721
- "integrity": "sha512-/6YAE9OE+qAbzUxVPmPH83uIwqxfRXpASQN8dAAmh7dpQRHPXKtGIG6iz1hSYvvVru9Cx93y/niQWU0raxzE2A==",
719
+ "version": "0.1.31-next.1",
720
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.31-next.1.tgz",
721
+ "integrity": "sha512-r6nsAJxKzwv7zMIOiPzrOFIPApC2DCXjLaO6zCi9mOPMNuK016EWH9+jtTJsEbWvyCatFIbl5pyxZLs13P6d4g==",
722
722
  "license": "MIT",
723
723
  "bin": {
724
724
  "binder": "bin/binder.mjs",
@@ -742,9 +742,9 @@
742
742
  }
743
743
  },
744
744
  "node_modules/clavarium-parley": {
745
- "version": "0.17.12-next.1",
746
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.12-next.1.tgz",
747
- "integrity": "sha512-G20876winm0zAtnxHcJIRqWwl8XnOyg+SYPu2S6xieRYnocgSTdQew9zOoBWmNMirvyyXqI/p8bN0IBQ1caS+w==",
745
+ "version": "0.17.14-next.1",
746
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.14-next.1.tgz",
747
+ "integrity": "sha512-AFYoyBHK2NKEuFmIv5rtPy4rSeohUY14LKxMrbMYoqyzyc6VsXg8dLiHdA0VaWjjMMoRiSv6rMQV0cmaArtt6w==",
748
748
  "license": "MIT",
749
749
  "bin": {
750
750
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.118-next.1",
3
+ "version": "0.2.121-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.",
@@ -44,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-binder": "0.1.28-next.1",
47
+ "clavarium-binder": "0.1.31-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
- "clavarium-parley": "0.17.12-next.1",
49
+ "clavarium-parley": "0.17.14-next.1",
50
50
  "clavarium-tether": "0.1.0-next.29",
51
51
  "mermaid": "11.17.2",
52
52
  "node-pty": "^1.1.0",
package/web/app.js CHANGED
@@ -2562,6 +2562,8 @@
2562
2562
  },
2563
2563
  /* A reaction to one of its messages: wherever the chat may be written in. */
2564
2564
  ...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
2565
+ /* A message attached to a card (#180), from its menu: its id, as the card opens it again. */
2566
+ ...(!DEVICE ? { card: (m) => attachToCard({ kind: 'message', ref: m.id, title: String(m.short || m.text || '').replace(/\s+/g, ' ').trim().slice(0, 80) }) } : {}),
2565
2567
  /* The buttons of a line of the machine: what this screen may do. */
2566
2568
  act: (id) => { if (id === 'seen-done') 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('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
2567
2569
  /* What it opens over the thread (a picture, its media, a search...) is a step of this page's: one Back closes it. */
@@ -4834,6 +4836,56 @@
4834
4836
  if (!repo || !rest) return;
4835
4837
  void openGit(repo, kind === 'commit' ? { commit: rest } : { branch: rest });
4836
4838
  }
4839
+ /* ATTACH TO A CARD (#180): from where a thing is (a file shown, a message of the chat), a card
4840
+ picked among the binders this page may write in -- by its title, typed or scrolled -- and
4841
+ the thing attached to it, as the agent attaches with `binder attach`. */
4842
+ async function attachToCard({ kind, ref, title }) {
4843
+ document.getElementById('attach-pick')?.remove();
4844
+ const box = document.createElement('div'); box.id = 'attach-pick'; box.setAttribute('role', 'dialog'); box.setAttribute('aria-modal', 'true'); box.setAttribute('aria-label', 'Attach to a card');
4845
+ const card = document.createElement('div'); card.className = 'attach-card';
4846
+ const head = document.createElement('div'); head.className = 'row';
4847
+ const h = document.createElement('b'); h.textContent = 'Attach to a card';
4848
+ const sp = document.createElement('span'); sp.className = 'sp';
4849
+ const x = document.createElement('button'); x.type = 'button'; x.textContent = '\u00d7'; x.setAttribute('aria-label', 'Close');
4850
+ head.append(h, sp, x);
4851
+ const what = document.createElement('p'); what.className = 'dim attach-what'; what.textContent = title || ref;
4852
+ const find = document.createElement('input'); find.type = 'search'; find.placeholder = 'Find a card'; find.setAttribute('aria-label', 'Find a card');
4853
+ const list = document.createElement('div'); list.className = 'attach-list';
4854
+ const said = document.createElement('p'); said.className = 'attach-said'; said.hidden = true;
4855
+ card.append(head, what, find, list, said); box.append(card); document.body.append(box);
4856
+ const close = () => { box.remove(); document.removeEventListener('keydown', esc, true); };
4857
+ const esc = (e) => { if (e.key === 'Escape') { e.stopPropagation(); close(); } };
4858
+ document.addEventListener('keydown', esc, true);
4859
+ x.onclick = close; box.addEventListener('pointerdown', (e) => { if (e.target === box) close(); });
4860
+ list.textContent = 'Loading...';
4861
+ /* The cards of every binder this page may change, the conversation's own binder first. */
4862
+ const lists = ((await binderCall('lists', {})).data ?? []).filter((l) => !l.archived && l.access === 'write');
4863
+ const own = (l) => Object.keys(l.grants ?? {}).includes(`conversation:${current}`);
4864
+ lists.sort((a, b) => Number(own(b)) - Number(own(a)));
4865
+ const cards = [];
4866
+ for (const l of lists.slice(0, 12)) { const r = await binderCall('show', { list: l.id }); for (const rec of r.data?.records ?? []) cards.push({ list: l, rec }); }
4867
+ const draw = () => {
4868
+ const q = find.value.trim().toLowerCase();
4869
+ const shown = cards.filter(({ rec, list: l }) => !q || `#${rec.n} ${rec.title} ${l.title}`.toLowerCase().includes(q)).slice(0, 80);
4870
+ list.replaceChildren(...(shown.length ? shown.map(({ rec, list: l }) => {
4871
+ const b = document.createElement('button'); b.type = 'button'; b.className = 'attach-item';
4872
+ const t = document.createElement('span'); t.textContent = `#${rec.n} ${rec.title}`;
4873
+ const w = document.createElement('small'); w.textContent = l.title;
4874
+ b.append(t, w);
4875
+ b.onclick = async () => {
4876
+ for (const o of list.querySelectorAll('button')) o.disabled = true;
4877
+ const r = await binderCall('attach', { id: rec.id, kind, ref, ...(title ? { title } : {}) });
4878
+ said.hidden = false; said.textContent = r.ok ? `Attached to #${rec.n} ${rec.title}.` : (r.text || 'Not attached.');
4879
+ said.classList.toggle('bad', !r.ok);
4880
+ if (r.ok) setTimeout(close, 1400); else for (const o of list.querySelectorAll('button')) o.disabled = false;
4881
+ };
4882
+ return b;
4883
+ }) : [Object.assign(document.createElement('p'), { className: 'dim', textContent: cards.length ? 'No card by that name.' : 'No binder you can write in.' })]));
4884
+ };
4885
+ find.addEventListener('input', draw);
4886
+ draw();
4887
+ find.focus();
4888
+ }
4837
4889
  /* Read again every screen of a binder when the binders changed. Taken as seen only once every
4838
4890
  screen read it again: one that failed (the server restarting) is read again at the next turn. */
4839
4891
  async function catchUpBinders() {
@@ -7233,6 +7285,7 @@
7233
7285
  /* The file is shown in a WINDOW over the screen, wherever it was asked
7234
7286
  from: closing it leaves the terminal, or the list, as it was. */
7235
7287
  function closePreview() {
7288
+ if ($('viewer').classList.contains('viewer-full')) { $('viewer').classList.remove('viewer-full'); $('preview-full').setAttribute('aria-pressed', 'false'); try { if (document.fullscreenElement === $('viewer')) document.exitFullscreen?.(); } catch { /* already out */ } }
7236
7289
  if (shownUrl) { URL.revokeObjectURL(shownUrl); shownUrl = null; }
7237
7290
  for (const url of mdUrls) URL.revokeObjectURL(url);
7238
7291
  mdUrls.clear();
@@ -7262,12 +7315,14 @@
7262
7315
  const can = what && (what.text !== undefined || (what.picture && pictures));
7263
7316
  button.hidden = !can;
7264
7317
  copyLabel = what?.picture ? 'Copy image' : 'Copy';
7265
- button.textContent = copyLabel;
7318
+ /* An icon: its word is its name (hover, long press, reader); "Copied" shows a moment as a tick of colour. */
7319
+ const word = (w) => { button.title = w; button.setAttribute('aria-label', w); if (w === 'Copied') button.dataset.done = 'true'; else delete button.dataset.done; };
7320
+ word(copyLabel);
7266
7321
  button.onclick = !can ? null : () => {
7267
7322
  const done = (ok, why) => {
7268
- button.textContent = ok ? 'Copied' : copyLabel;
7323
+ word(ok ? 'Copied' : copyLabel);
7269
7324
  if (!ok && why) { $('preview-note').textContent = why; $('preview-note').hidden = false; }
7270
- if (ok) setTimeout(() => { if (button.textContent === 'Copied') button.textContent = copyLabel; }, 1800);
7325
+ if (ok) setTimeout(() => { if (button.dataset.done) word(copyLabel); }, 1800);
7271
7326
  };
7272
7327
  if (what.text !== undefined) {
7273
7328
  const fallback = () => { const at = select?.(); done(false, at ? 'The browser did not let this page copy: the text is selected, copy it yourself (Ctrl+C, or a long press).' : 'The browser did not let this page copy.'); };
@@ -7446,7 +7501,7 @@
7446
7501
  /* From the terminal, a way to the folder it sits in. */
7447
7502
  /* From the terminal or the chat, a way to the folder it sits in: the Assets tab, on it (Files, on a device). */
7448
7503
  $('preview-where').hidden = Boolean(from) || (!$('files').hidden && !$('files').classList.contains('embedded')) || noTerminal() || (!DEVICE && assetsShown);
7449
- $('preview-where').textContent = DEVICE ? 'Show in Files' : 'Show in Assets';
7504
+ { const word = DEVICE ? 'Show in Files' : 'Show in Assets'; $('preview-where').title = word; $('preview-where').setAttribute('aria-label', word); }
7450
7505
  $('preview-where').onclick = async () => {
7451
7506
  closePreview();
7452
7507
  const folder = inner.split('/').slice(0, -1).join('/');
@@ -7464,6 +7519,12 @@
7464
7519
  /* Text in a folder this conversation may write in: editable here. */
7465
7520
  $('preview-edit').hidden = Boolean(from) || !editable(name, size) || !canWrite(tab);
7466
7521
  $('preview-edit').onclick = () => { void editFile(tab, inner, name); };
7522
+ /* A file of the shared folders: attached to a card from here (#180). */
7523
+ $('preview-attach').hidden = Boolean(from) || DEVICE;
7524
+ /* Full screen: the file takes the whole screen (the real API where granted, else a cover); kept while it is open. */
7525
+ const full = (on) => { $('viewer').classList.toggle('viewer-full', on); $('preview-full').setAttribute('aria-pressed', String(on)); const w2 = on ? 'Leave full screen' : 'Full screen'; $('preview-full').title = w2; $('preview-full').setAttribute('aria-label', w2); try { if (on) $('viewer').requestFullscreen?.().catch(() => {}); else if (document.fullscreenElement === $('viewer')) document.exitFullscreen?.(); } catch { /* the cover stands in */ } };
7526
+ $('preview-full').onclick = () => full(!$('viewer').classList.contains('viewer-full'));
7527
+ $('preview-attach').onclick = () => void attachToCard({ kind: 'file', ref: tab === 'work' ? `/work/${inner}` : `/resources/${tab}/${inner}`, title: name });
7467
7528
  /* A file read from the machine's disk says so, whatever else is said. */
7468
7529
  const origin = from ? 'Read from the disk of the machine: this file is not kept here, and goes with the machine.' : '';
7469
7530
  const note = (text) => { const all = [text, text === 'Loading...' ? '' : origin].filter(Boolean).join(' '); $('preview-note').textContent = all; $('preview-note').hidden = !all; };
package/web/index.html CHANGED
@@ -1071,7 +1071,7 @@
1071
1071
  <!-- A file, shown over whatever is on the screen; closing it leaves you where you were. -->
1072
1072
  <div id="viewer" role="dialog" aria-modal="true" aria-labelledby="preview-name" hidden>
1073
1073
  <div id="viewer-card">
1074
- <div class="row"><b id="preview-name"></b><span class="sp"></span><button type="button" id="preview-where" hidden>Show in Files</button><button type="button" id="preview-edit" hidden>Edit</button><button type="button" id="preview-copy" hidden>Copy</button><a id="preview-download" class="button">Download</a><button type="button" id="preview-close" aria-label="Close" title="Close">&times;</button></div>
1074
+ <div class="row"><b id="preview-name"></b><span class="sp"></span><button type="button" id="preview-where" class="ico" hidden title="Show in Assets" aria-label="Show in Assets"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2 2 7l10 5 10-5-10-5z"/><path d="M2 17l10 5 10-5M2 12l10 5 10-5"/></svg></button><button type="button" id="preview-attach" class="ico" hidden title="Attach to a card" aria-label="Attach to a card"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg></button><button type="button" id="preview-edit" class="ico" hidden title="Edit" aria-label="Edit"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg></button><button type="button" id="preview-copy" class="ico" hidden title="Copy" aria-label="Copy"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg></button><button type="button" id="preview-full" class="ico" title="Full screen" aria-label="Full screen" aria-pressed="false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3"/></svg></button><a id="preview-download" class="button ico primary" title="Download" aria-label="Download"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v12M7 11l5 5 5-5"/><path d="M5 21h14"/></svg></a><button type="button" id="preview-close" aria-label="Close" title="Close">&times;</button></div>
1075
1075
  <p id="preview-note" class="hint" hidden></p>
1076
1076
  <div id="preview-body"></div>
1077
1077
  </div>
package/web/style.css CHANGED
@@ -1876,3 +1876,25 @@ details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wr
1876
1876
  }
1877
1877
  /* The review on a light screen: line numbers and the "changed" tag readable (diff2html's own greys are too pale). */
1878
1878
  :root[data-theme="light"] .rv-diff { --d2h-dim-color: #5d6b7a; --d2h-change-label-color: #8a5d00; }
1879
+
1880
+ /* Attach to a card (#180): a card picked by its title, over whatever is shown. */
1881
+ #attach-pick { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: max(6vh, env(safe-area-inset-top)) 12px 12px; background: rgba(8, 11, 15, 0.55); }
1882
+ #attach-pick .attach-card { display: flex; flex-direction: column; gap: 8px; width: min(520px, 100%); max-height: 80vh; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .5); }
1883
+ #attach-pick .row { display: flex; align-items: center; gap: 8px; }
1884
+ #attach-pick .sp { flex: 1; }
1885
+ #attach-pick .attach-what { margin: 0; overflow-wrap: anywhere; }
1886
+ #attach-pick .attach-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
1887
+ #attach-pick .attach-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%; }
1888
+ #attach-pick .attach-item small { color: var(--dim); }
1889
+ #attach-pick .attach-said { margin: 0; font-weight: 600; }
1890
+ #attach-pick .attach-said.bad { color: var(--bad, #c0392b); }
1891
+
1892
+ /* The file viewer's buttons are icons (#89): each says its name on hover, a long press, a reader;
1893
+ Download stands out. Full screen: the file takes the whole screen. */
1894
+ #viewer .ico { display: inline-flex; align-items: center; justify-content: center; width: 38px; min-width: 38px; height: 34px; padding: 0; }
1895
+ #viewer .ico svg { width: 18px; height: 18px; }
1896
+ #viewer .ico.primary { background: var(--brass); border-color: var(--brass); color: var(--on-brass); }
1897
+ #viewer #preview-copy[data-done="true"] { color: var(--ok); border-color: currentColor; }
1898
+ #viewer #preview-full[aria-pressed="true"] { border-color: var(--brass); }
1899
+ #viewer.viewer-full { padding: 0; }
1900
+ #viewer.viewer-full #viewer-card { width: 100%; max-width: none; border-radius: 0; border: 0; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }