clavarium 0.2.86-beta.1 → 0.2.87-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,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.86-beta.1",
3
+ "version": "0.2.87-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.86-beta.1",
9
+ "version": "0.2.87-beta.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.41-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
16
  "clavarium-parley": "0.17.20-next.1",
17
- "clavarium-tether": "0.1.0-next.33",
17
+ "clavarium-tether": "0.1.0-next.34",
18
18
  "mermaid": "11.17.2",
19
19
  "node-pty": "^1.1.0",
20
20
  "pdfjs-dist": "6.4.299",
@@ -755,9 +755,9 @@
755
755
  }
756
756
  },
757
757
  "node_modules/clavarium-tether": {
758
- "version": "0.1.0-next.33",
759
- "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.33.tgz",
760
- "integrity": "sha512-gcXJ1H1fYaAg5/JrXKG/yeV0RH4zNS/uUPPXPK0wLpRR0T0aHq34ZitciDoG5ZxOVRze423kTP84gVtLd3nXVw==",
758
+ "version": "0.1.0-next.34",
759
+ "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.34.tgz",
760
+ "integrity": "sha512-6AOHSkdeHE+K5W9NK3q282Hwx9QcETaxNAJb6rDyrEa8ddAHKjKkokJDsAYB/xjRI8Z0txl8GpQb0f4sfFC43Q==",
761
761
  "license": "MIT",
762
762
  "bin": {
763
763
  "tether": "bin/cli.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.86-beta.1",
3
+ "version": "0.2.87-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.",
@@ -47,7 +47,7 @@
47
47
  "clavarium-binder": "0.1.41-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
49
  "clavarium-parley": "0.17.20-next.1",
50
- "clavarium-tether": "0.1.0-next.33",
50
+ "clavarium-tether": "0.1.0-next.34",
51
51
  "mermaid": "11.17.2",
52
52
  "node-pty": "^1.1.0",
53
53
  "pdfjs-dist": "6.4.299",
package/server/api.mjs CHANGED
@@ -443,6 +443,16 @@ export async function handleApi(request, response, conversations, headers, resou
443
443
  keeper runs as the owner (person), never as an agent. */
444
444
  const tetherOp = /^\/api\/tether\/(level|allow|unallow|decide|remove-target|stop|resume)$/.exec(pathname);
445
445
  if (tetherOp && tethers) { const r = await tethers.act(tetherOp[1], body, ''); if (!r.ok) throw new Refusal(400, r.text); return send(200, r.data ?? { ok: true }), true; }
446
+ /* A mailbox's signature (Markdown), added under what the agent sends from it. */
447
+ if (pathname === '/api/tether/signature' && tethers) {
448
+ const t = tethers.store().target(String(body.target ?? ''));
449
+ if (!t || t.kind !== 'mail') throw new Refusal(404, 'No such mailbox.');
450
+ const signature = String(body.signature ?? '').replace(/\r\n?/g, '\n').trim();
451
+ if (signature.length > 2000) throw new Refusal(400, 'A signature is 2000 characters at most.');
452
+ const { signature: _old, ...config } = t.config ?? {};
453
+ tethers.store().putTarget({ ...t, config: signature ? { ...config, signature } : config });
454
+ return send(200, { ok: true, signature }), true;
455
+ }
446
456
  if (pathname === '/api/shortcuts' && shortcuts) return send(201, shortcuts.add(body)), true;
447
457
  if (pathname === '/api/secrets' && secrets) { const made = secrets.set(body); setup?.secretAdded(made.name); return send(201, made), true; }
448
458
  /* Asset groups (groups.mjs): a folder-style tidy-up, not a right. */
package/web/app.js CHANGED
@@ -3353,8 +3353,8 @@
3353
3353
  addBar.append(roundPlus('New group', () => { groupAdding = true; void paintAssets(); }), el('span', 'hint', 'New group'));
3354
3354
  holder.append(addBar);
3355
3355
  }
3356
- const section = (head, rows, none, { foldable } = {}) => {
3357
- const s = el('section', 'as-kind as-group'); s.append(head);
3356
+ const section = (head, rows, none, { foldable, drop } = {}) => {
3357
+ const s = el('section', 'as-kind as-group'); s.append(head); s.dataset.drop = drop;
3358
3358
  if (!foldable || !head.dataset.folded) {
3359
3359
  if (rows.length === 0) s.append(el('p', 'hint as-none', none));
3360
3360
  for (const item of rows) s.append(assetRow(item, { chosen, choose }));
@@ -3375,13 +3375,62 @@
3375
3375
  const gear = el('button', 'as-gear', '⚙'); gear.type = 'button'; gear.setAttribute('aria-label', `Settings for ${g.label}`); gear.title = 'Give, rename, remove';
3376
3376
  gear.addEventListener('click', (e) => { e.stopPropagation(); choose(`group:${g.id}`); });
3377
3377
  head.append(toggle, gear);
3378
- section(head, members, 'Empty. Open an asset to put it here.', { foldable: true });
3378
+ section(head, members, 'Empty. Drag an asset here, or open one to put it here.', { foldable: true, drop: g.id });
3379
3379
  }
3380
3380
  const grouped = new Set(groups.flatMap((g) => g.members ?? []));
3381
3381
  const loose = items.filter((i) => !grouped.has(i.key));
3382
3382
  const looseHead = el('div', 'as-kind-head'); looseHead.append(el('h3', '', 'No group'));
3383
- section(looseHead, loose, groups.length ? 'Every asset is in a group.' : 'Make a group above, then open an asset to put it in it.');
3383
+ section(looseHead, loose, groups.length ? 'Every asset is in a group.' : 'Make a group above, then open an asset to put it in it.', { drop: '' });
3384
3384
  if (items.length === 0 && empty) holder.append(el('p', 'hint', empty));
3385
+ if (groups.length) dragToGroups(holder);
3386
+ }
3387
+ /* DRAGGING AN ASSET ONTO A GROUP (#111), like a binder's Kanban: a mouse drags once it
3388
+ has moved a little; a finger after a short hold (so a swipe still scrolls). The row
3389
+ follows the pointer as a light copy; the group under it lights up; let go on it, and
3390
+ the asset is placed there ("No group" takes it out). A tap still opens the asset. */
3391
+ function dragToGroups(holder) {
3392
+ let drag = null;
3393
+ const sectionAt = (x, y) => document.elementFromPoint(x, y)?.closest?.('.as-group[data-drop]') ?? null;
3394
+ const end = () => { if (!drag) return; clearTimeout(drag.hold); drag.ghost?.remove(); drag.over?.classList.remove('as-drop-over'); document.body.classList.remove('as-dragging'); drag = null; };
3395
+ const start = (d) => {
3396
+ d.on = true;
3397
+ const r = d.row.getBoundingClientRect();
3398
+ d.ghost = d.row.cloneNode(true); d.ghost.classList.add('as-drag-ghost');
3399
+ Object.assign(d.ghost.style, { width: `${r.width}px`, left: `${r.left}px`, top: `${r.top}px` });
3400
+ d.dx = d.x0 - r.left; d.dy = d.y0 - r.top;
3401
+ document.body.append(d.ghost); document.body.classList.add('as-dragging');
3402
+ };
3403
+ holder.addEventListener('pointerdown', (e) => {
3404
+ const row = e.target.closest('.as-row[data-asset]');
3405
+ if (!row || !holder.contains(row) || e.button > 0) return;
3406
+ drag = { row, id: e.pointerId, x0: e.clientX, y0: e.clientY, on: false, touch: e.pointerType !== 'mouse', from: row.closest('.as-group')?.dataset.drop };
3407
+ if (drag.touch) { const d = drag; d.hold = setTimeout(() => { if (drag === d) { start(d); try { row.setPointerCapture(d.id); } catch { /* still heard */ } } }, 350); }
3408
+ });
3409
+ holder.addEventListener('pointermove', (e) => {
3410
+ if (!drag || e.pointerId !== drag.id) return;
3411
+ const far = Math.hypot(e.clientX - drag.x0, e.clientY - drag.y0) > 6;
3412
+ if (!drag.on) { if (drag.touch) { if (far) end(); return; } if (!far) return; start(drag); try { drag.row.setPointerCapture(drag.id); } catch { /* still heard */ } }
3413
+ e.preventDefault();
3414
+ drag.ghost.style.left = `${e.clientX - drag.dx}px`; drag.ghost.style.top = `${e.clientY - drag.dy}px`;
3415
+ const over = sectionAt(e.clientX, e.clientY);
3416
+ if (over !== drag.over) { drag.over?.classList.remove('as-drop-over'); drag.over = over; over?.classList.add('as-drop-over'); }
3417
+ });
3418
+ holder.addEventListener('pointerup', async (e) => {
3419
+ if (!drag || e.pointerId !== drag.id) return;
3420
+ const d = drag; const target = d.on ? sectionAt(e.clientX, e.clientY) : null;
3421
+ const was = d.on; end();
3422
+ if (!was) return;
3423
+ /* A drag is not a tap: the click that follows does not open the asset. */
3424
+ d.row.addEventListener('click', (c) => { c.stopImmediatePropagation(); c.preventDefault(); }, { capture: true, once: true });
3425
+ if (!target || target.dataset.drop === d.from) return;
3426
+ $('assets-error').hidden = true;
3427
+ try { await post(`${API}/asset-groups/place`, { asset: d.row.dataset.asset, group: target.dataset.drop || null }); }
3428
+ catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
3429
+ void paintAssets();
3430
+ });
3431
+ holder.addEventListener('pointercancel', end);
3432
+ /* Once a finger's drag has begun, the page must not scroll under it. */
3433
+ holder.addEventListener('touchmove', (e) => { if (drag?.on) e.preventDefault(); }, { passive: false });
3385
3434
  }
3386
3435
  /* The level buttons an asset takes, by its type (same sets as its own detail). */
3387
3436
  const levelOptionsFor = (item) => (item.target ? [['none', 'Off'], ['watch', 'Watch'], ['propose', 'Propose'], ['frame', 'Frame'], ['free', 'Free']]
@@ -4480,6 +4529,23 @@
4480
4529
  };
4481
4530
  draw(Array.isArray(t.config?.authorizedKinds) ? t.config.authorizedKinds : null);
4482
4531
  }
4532
+ /* A mailbox: its signature, in Markdown, added under what the agent sends. */
4533
+ if (t.kind === 'mail') {
4534
+ const box = el('div', 'as-signature');
4535
+ const lab = el('label', '', 'Signature'); lab.htmlFor = `sig-${t.id}`;
4536
+ const ta = document.createElement('textarea'); ta.id = `sig-${t.id}`; ta.rows = 3; ta.value = t.config?.signature ?? ''; ta.placeholder = 'Added under every mail the agent sends from this mailbox (Markdown: **bold**, links…)';
4537
+ const save = el('button', '', 'Save'); save.type = 'button';
4538
+ const said = el('small', 'hint', '');
4539
+ save.addEventListener('click', async () => {
4540
+ save.disabled = true;
4541
+ try { await post(`${API}/tether/signature`, { target: t.id, signature: ta.value }); said.textContent = ta.value.trim() ? 'Saved.' : 'Removed.'; t.config = { ...(t.config ?? {}), signature: ta.value.trim() }; }
4542
+ catch (e) { said.textContent = e.message; }
4543
+ save.disabled = false;
4544
+ });
4545
+ const row = el('div', 'row'); row.append(save, said);
4546
+ box.append(lab, ta, row);
4547
+ detail.append(box);
4548
+ }
4483
4549
  if (chosen.siblings?.length) {
4484
4550
  const a = el('p', 'as-assoc hint');
4485
4551
  a.append(el('b', '', 'Linked'), document.createTextNode(` to the same account: ${chosen.siblings.join(', ')}. They share the account's sign-in (kept on the server); rights are given separately.`));
package/web/style.css CHANGED
@@ -1940,3 +1940,9 @@ details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wr
1940
1940
  .dm-acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
1941
1941
  .dm-acts .dm-dots { padding-inline: .7em; }
1942
1942
  .dm-undo { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: .9rem; padding: 4px 0; }
1943
+ .as-signature { display: flex; flex-direction: column; gap: 6px; margin: .6rem 0; }
1944
+ .as-signature textarea { width: 100%; font: inherit; }
1945
+ .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); }
1946
+ .as-group.as-drop-over { outline: 2px dashed var(--brass); outline-offset: 2px; border-radius: 10px; background: rgba(210, 169, 78, .07); }
1947
+ body.as-dragging { user-select: none; -webkit-user-select: none; }
1948
+ body.as-dragging #assets-rows .as-row { touch-action: none; }