clavarium 0.2.111-next.1 → 0.2.114-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,20 +1,20 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.111-next.1",
3
+ "version": "0.2.114-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.111-next.1",
9
+ "version": "0.2.114-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.16-next.1",
14
+ "clavarium-binder": "0.1.19-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
16
  "clavarium-parley": "0.17.12-next.1",
17
- "clavarium-tether": "0.1.0-next.28",
17
+ "clavarium-tether": "0.1.0-next.29",
18
18
  "mermaid": "11.17.2",
19
19
  "node-pty": "^1.1.0",
20
20
  "pdfjs-dist": "6.4.299",
@@ -716,9 +716,9 @@
716
716
  }
717
717
  },
718
718
  "node_modules/clavarium-binder": {
719
- "version": "0.1.16-next.1",
720
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.16-next.1.tgz",
721
- "integrity": "sha512-T0Ys/nHzUoYYC2U8jB9QMKs406yBTPIHzp7JdmYNg9SgwAbqSFmWcg7C9te177V0UdewQWiQnAfLTeO+8WWIXQ==",
719
+ "version": "0.1.19-next.1",
720
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.19-next.1.tgz",
721
+ "integrity": "sha512-kjB250oZm7+K+gjl0kdSe7xpIImtObzJxqOoeZSoR3r1QlM/6ZGz+70cVURfk7j9jn8uXBpLxctLJrr7f10ALg==",
722
722
  "license": "MIT",
723
723
  "bin": {
724
724
  "binder": "bin/binder.mjs",
@@ -755,9 +755,9 @@
755
755
  }
756
756
  },
757
757
  "node_modules/clavarium-tether": {
758
- "version": "0.1.0-next.28",
759
- "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.28.tgz",
760
- "integrity": "sha512-0Oa5aZ2ercfQ2sGqeQkuqkNwtcQZJY/Twxiv3lSUg0cSipD9neSrWoCsfejbvfT+mROG184hnNqj37dL1Dq4ow==",
758
+ "version": "0.1.0-next.29",
759
+ "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.29.tgz",
760
+ "integrity": "sha512-iDnV6unqGcyvdbK5bCcmdBJy1USoZQbbeRJ//pr1wRRGKVDvTGF1tPdCjnVxcb2zQnbEsKuc/xV4yRYRxeYNKQ==",
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.111-next.1",
3
+ "version": "0.2.114-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,10 +44,10 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-binder": "0.1.16-next.1",
47
+ "clavarium-binder": "0.1.19-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
49
  "clavarium-parley": "0.17.12-next.1",
50
- "clavarium-tether": "0.1.0-next.28",
50
+ "clavarium-tether": "0.1.0-next.29",
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
@@ -19,6 +19,7 @@
19
19
  * POST /api/conversations/<name>/talk {text, answers?, files?, via?}: written in its chat; files from .../talk/file; via 'voice': dictated
20
20
  * POST /api/conversations/<name>/talk/react {to, reaction}: the owner's reaction to a message of the tool (null: taken back)
21
21
  * POST /api/conversations/<name>/chat-name {name}: the name the chat gives its tool ('' : the neutral word of the dictionary)
22
+ * POST /api/conversations/<name>/tasks-binder {binder}: the binder shown beside its chat ('' automatic, '-' none, else an id)
22
23
  * POST /api/conversations/<name>/voice-mark {on}: what is dictated into its terminal starts with a microphone sign (AI tools only)
23
24
  * POST /api/conversations/<name>/talk/file?name=<file name> the body IS a file the person attaches -> {path, name, size}
24
25
  * GET /api/conversations/<name>/talk?last=|days=|before=|from=|since= a part of its chat: the newest messages, those of the
@@ -638,6 +639,8 @@ export async function handleApi(request, response, conversations, headers, resou
638
639
  if (asking) return send(200, conversations.setAskFirst(decodeURIComponent(asking[1]), body.on)), true;
639
640
  const naming = /^\/api\/conversations\/([^/]+)\/chat-name$/.exec(pathname);
640
641
  if (naming) return send(200, conversations.setChatName(decodeURIComponent(naming[1]), body.name)), true;
642
+ const beside = /^\/api\/conversations\/([^/]+)\/tasks-binder$/.exec(pathname);
643
+ if (beside) return send(200, conversations.setTasksBinder(decodeURIComponent(beside[1]), body.binder)), true;
641
644
  /* The list: folders and order, the same on every device (conversations.mjs). */
642
645
  if (pathname === '/api/instance' && instance) return send(200, instance.setName(body.name)), true;
643
646
  if (pathname === '/api/dictation' && voice) return send(200, voice.set(body)), true;
@@ -608,6 +608,18 @@ export class Conversations {
608
608
  return this.#store.get(name);
609
609
  }
610
610
 
611
+ /* WHICH BINDER ITS CHAT SHOWS BESIDE IT (the side panel), the same on every device:
612
+ '' for the automatic choice (the first binder of batches it was given), '-' for none,
613
+ else a binder's id. Which binders it was given is Binder's: one it no longer has
614
+ falls back to the automatic choice on the page. */
615
+ setTasksBinder(name, given) {
616
+ const c = this.#store.get(name);
617
+ if (!c) throw new Refusal(404, 'No such conversation.');
618
+ if (typeof given !== 'string' || given.length > 100 || !/^(|-|[a-z0-9][a-z0-9._-]*)$/.test(given)) throw new Refusal(400, 'Give a binder\'s id, "-" for none, or nothing for the automatic choice.');
619
+ this.#store.patch(name, { tasksBinder: given || undefined });
620
+ return this.#store.get(name);
621
+ }
622
+
611
623
  /* THE NAME A PERSON READS, changed at any time; its identifier stays.
612
624
  Kept only when it differs from the identifier: a conversation made
613
625
  before free names is read by its identifier, and nothing is rewritten. */
package/web/app.js CHANGED
@@ -2602,11 +2602,16 @@
2602
2602
  let tasksTimer = null; let tasksChanges = -1;
2603
2603
  const tasksFolded = (name) => { try { const v = JSON.parse(localStorage.getItem('clavarium-tasks-folded') ?? '{}')[name]; return typeof v === 'boolean' ? v : null; } catch { return null; } };
2604
2604
  const keepTasksFolded = (name, on) => { try { const all = JSON.parse(localStorage.getItem('clavarium-tasks-folded') ?? '{}'); all[name] = on; localStorage.setItem('clavarium-tasks-folded', JSON.stringify(all)); } catch { /* a private window */ } };
2605
- /* Its binder of batches: the first of that template it was given, not archived. */
2605
+ /* Its binder beside the chat: the one chosen for it (its settings, the same on every
2606
+ device), else the first binder of batches it was given; '-' chosen: none. A chosen binder
2607
+ it no longer has, or archived, gives way to the automatic choice. */
2606
2608
  async function batchesOf(name) {
2609
+ const chosen = conversations.find((x) => x.name === name)?.tasksBinder ?? '';
2610
+ if (chosen === '-') return null;
2607
2611
  const lists = await binderCall('lists', {});
2608
2612
  if (!lists.ok || !Array.isArray(lists.data)) return undefined;
2609
- return lists.data.find((l) => !l.archived && l.template === TASKS_TEMPLATE && l.grants?.[`conversation:${name}`]) ?? null;
2613
+ const given = lists.data.filter((l) => !l.archived && l.grants?.[`conversation:${name}`]);
2614
+ return (chosen && given.find((l) => l.id === chosen)) || given.find((l) => l.template === TASKS_TEMPLATE) || null;
2610
2615
  }
2611
2616
  /* A card's description, as the panel shows it: plain words, no Markdown signs. */
2612
2617
  const plainText = (md) => String(md ?? '').replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/\*\*|__|`/g, '').replace(/^\s*[-*]\s+/gm, '').replace(/\s+/g, ' ').trim();
@@ -2763,6 +2768,7 @@
2763
2768
  if (DEVICE) { $('talk-box').hidden = true; $('voice-mark-box').hidden = true; return; }
2764
2769
  const here = conversations.find((x) => x.name === current);
2765
2770
  if (document.activeElement !== $('chat-name')) $('chat-name').value = here?.chatName ?? '';
2771
+ void paintTasksBinder(here);
2766
2772
  if (document.activeElement !== $('title-name')) $('title-name').value = shownName(here);
2767
2773
  $('title-box').hidden = $('hide-box').hidden = $('group-box').hidden = DEVICE || !here;
2768
2774
  if (document.activeElement !== $('group-name')) $('group-name').value = here?.group ?? '';
@@ -2821,6 +2827,25 @@
2821
2827
  catch (error) { $('panel-error').textContent = error.message; $('panel-error').hidden = false; }
2822
2828
  });
2823
2829
  }
2830
+ /* WHICH BINDER BESIDE ITS CHAT (#48): automatic, one of the binders it was given, or none.
2831
+ Shown only once it was given a binder. */
2832
+ async function paintTasksBinder(here) {
2833
+ const row = $('tasks-binder-row'); const pick = $('tasks-binder');
2834
+ if (DEVICE || !here) { row.hidden = true; return; }
2835
+ const lists = await binderCall('lists', {});
2836
+ const given = lists.ok && Array.isArray(lists.data) ? lists.data.filter((l) => !l.archived && l.grants?.[`conversation:${here.name}`]) : [];
2837
+ row.hidden = given.length === 0;
2838
+ if (row.hidden || document.activeElement === pick) return;
2839
+ const option = (value, text) => { const o = document.createElement('option'); o.value = value; o.textContent = text; return o; };
2840
+ pick.replaceChildren(option('', 'Automatic'), ...given.map((l) => option(l.id, l.title)), option('-', 'None'));
2841
+ const chosen = here.tasksBinder ?? '';
2842
+ pick.value = chosen === '-' || given.some((l) => l.id === chosen) ? chosen : '';
2843
+ }
2844
+ $('tasks-binder').addEventListener('change', async () => {
2845
+ $('panel-error').hidden = true;
2846
+ try { await post(`${API}/conversations/${encodeURIComponent(current)}/tasks-binder`, { binder: $('tasks-binder').value }); await refresh(); void paintTasks(current); }
2847
+ catch (error) { $('panel-error').textContent = error.message; $('panel-error').hidden = false; }
2848
+ });
2824
2849
  $('chat-name-form').addEventListener('submit', async (event) => {
2825
2850
  event.preventDefault();
2826
2851
  $('panel-error').hidden = true;
@@ -2928,6 +2953,29 @@
2928
2953
  return [label, select];
2929
2954
  }));
2930
2955
  }
2956
+ /* BINDERS (#49): Binder's own settings -- how many binders an agent may make, whether
2957
+ agents may add columns, fields or change a binder's type -- read and set through it. */
2958
+ async function paintBinderSettings() {
2959
+ if (DEVICE) return;
2960
+ const got = await binderCall('settings', {});
2961
+ if (!got.ok) return;
2962
+ const s = got.data;
2963
+ if (document.activeElement !== $('binders-agent-lists')) $('binders-agent-lists').value = String(s.agentLists ?? '');
2964
+ for (const [id, on] of [['binders-agent-columns', s.agentColumns === true], ['binders-agent-fields', s.agentFields === true]]) {
2965
+ for (const b of $(id).children) b.setAttribute('aria-pressed', String((b.dataset.on === 'true') === on));
2966
+ }
2967
+ }
2968
+ async function saveBinderSetting(change) {
2969
+ $('binders-error').hidden = true;
2970
+ const done = await binderCall('edit-settings', change);
2971
+ if (done.ok) { $('binders-saved').textContent = 'Saved.'; setTimeout(() => { $('binders-saved').textContent = ''; }, 2500); }
2972
+ else { $('binders-error').textContent = done.text; $('binders-error').hidden = false; }
2973
+ await paintBinderSettings();
2974
+ }
2975
+ $('binders-agent-lists').addEventListener('change', () => void saveBinderSetting({ agentLists: $('binders-agent-lists').value }));
2976
+ for (const [id, key] of [['binders-agent-columns', 'agentColumns'], ['binders-agent-fields', 'agentFields']]) {
2977
+ for (const b of $(id).children) b.addEventListener('click', () => void saveBinderSetting({ [key]: b.dataset.on === 'true' }));
2978
+ }
2931
2979
  async function saveThreadLevel(kind, level) {
2932
2980
  $('thread-error').hidden = true;
2933
2981
  try {
@@ -4941,6 +4989,7 @@
4941
4989
  void paintAlerts().catch(() => {});
4942
4990
  void paintWords().catch(() => {});
4943
4991
  void paintThreadLevels().catch(() => {});
4992
+ void paintBinderSettings().catch(() => {});
4944
4993
  void paintChatWindow().catch(() => {});
4945
4994
  const [platform, saved] = await Promise.all([fetch(`${API}/platform`).then((r) => r.json()).catch(() => ({})), fetch(`${API}/shortcuts`).then((r) => r.json()).catch(() => [])]);
4946
4995
  const list = $('settings-shortcuts'); list.replaceChildren();
package/web/index.html CHANGED
@@ -152,6 +152,7 @@
152
152
  <div class="set-row"><div class="set-what"><b>Chat</b><small id="talk-about">A chat screen instead of its terminal. What the tool posts there is read by this server</small></div><div class="set-control"><div class="levels" id="talk-on" role="group" aria-label="Talk through the app"><button type="button" data-on="true">On</button><button type="button" data-on="false">Off</button></div><button type="button" id="talk-invite" hidden>Ask the tool to use it</button></div></div>
153
153
  <p class="hint" id="talk-declare" hidden></p>
154
154
  <form id="chat-name-form" class="set-row" autocomplete="off"><div class="set-what"><label for="chat-name">Its name in the chat</label><small id="chat-name-hint">Empty: "Assistant"</small></div><div class="set-control"><input id="chat-name" maxlength="40" placeholder="Assistant" spellcheck="false"><button type="submit">Save</button></div></form>
155
+ <div class="set-row" id="tasks-binder-row" hidden><div class="set-what"><label for="tasks-binder">Binder beside the chat</label><small>Automatic: its first binder of batches</small></div><div class="set-control"><select id="tasks-binder"></select></div></div>
155
156
  </div>
156
157
  <!-- DICTATION INTO ITS TERMINAL: marked once per message, so that the tool knows it may hold recognition mistakes. -->
157
158
  <div id="voice-mark-box" hidden>
@@ -678,6 +679,20 @@
678
679
  <p class="error" id="instance-error" role="alert" hidden></p>
679
680
  </div>
680
681
  </details>
682
+ <!-- BINDERS (clavarium-binder's own settings, asked of it): what agents may do with binders. -->
683
+ <details class="chapter" id="settings-ch-binders" data-chapter="s-binders">
684
+ <summary><span class="chapter-title">Binders</span><span class="chapter-about">What agents may do with them.</span></summary>
685
+ <div class="chapter-body">
686
+ <div class="set-rows">
687
+ <div class="set-row"><div class="set-what"><label for="binders-agent-lists">Binders an agent may make</label><small>Not archived. 0: none</small></div><div class="set-control"><input id="binders-agent-lists" type="number" min="0" max="50" step="1" inputmode="numeric"></div></div>
688
+ <div class="set-row"><div class="set-what"><b>Agents add or rename columns</b><small>Never remove one, never move the gate</small></div><div class="set-control"><div class="levels" id="binders-agent-columns" role="group" aria-label="Agents add or rename columns"><button type="button" data-on="false">Off</button><button type="button" data-on="true">On</button></div></div></div>
689
+ <div class="set-row"><div class="set-what"><b>Agents add fields or change the type</b><small>Never remove a field</small></div><div class="set-control"><div class="levels" id="binders-agent-fields" role="group" aria-label="Agents add fields or change the type"><button type="button" data-on="false">Off</button><button type="button" data-on="true">On</button></div></div></div>
690
+ </div>
691
+ <p class="hint">The binder beside a chat is chosen in each conversation's settings (Chat).</p>
692
+ <p class="hint" id="binders-saved" role="status"></p>
693
+ <p class="error" id="binders-error" role="alert" hidden></p>
694
+ </div>
695
+ </details>
681
696
  <!-- WHO MAY SIGN IN (server/operators.mjs): hidden on this machine alone. -->
682
697
  <details class="chapter" id="settings-ch-operators" data-chapter="s-operators" hidden>
683
698
  <summary><span class="chapter-title">Administrators</span><span class="chapter-about">Who may sign in.</span></summary>