ai-agentmanager 1.57.3 → 1.59.0

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.
@@ -0,0 +1,105 @@
1
+ // Files: this computer's folders from the device in your hand. Send it a file (a photo from the
2
+ // phone, a document), or tap one there to fetch it (a log, a build, a screenshot). What is sent
3
+ // goes to the folder shown, the Downloads folder to begin with (src/files.js).
4
+
5
+ const fmtSize = (n) => (n < 1024 ? `${n} B` : n < 1048576 ? `${(n / 1024).toFixed(0)} KB` : n < 1073741824 ? `${(n / 1048576).toFixed(1)} MB` : `${(n / 1073741824).toFixed(2)} GB`);
6
+ const MAX_SEND = 250 * 1048576; // what the daemon takes in one file
7
+
8
+ export function initFiles({ api, esc, toast, ago, $ }) {
9
+ const dialog = $('#files-dialog');
10
+ const list = $('#files-list');
11
+ const note = $('#files-note');
12
+ const input = $('#files-input');
13
+ let here = null; // the folder shown, as the daemon gave it
14
+ let sending = 0;
15
+
16
+ function render() {
17
+ $('#files-path').value = here.dir;
18
+ $('#files-up').disabled = !here.parent;
19
+ const rows = here.entries.map((e) => {
20
+ const full = `${here.dir.replace(/\/$/, '')}/${e.name}`;
21
+ return e.dir
22
+ ? `<li><button type="button" class="files-row" data-dir="${esc(full)}"><span class="files-icon" aria-hidden="true">📁</span><span class="files-name">${esc(e.name)}</span><span class="hint">${ago(e.at)}</span></button></li>`
23
+ : `<li><a class="files-row" href="/api/machine/file?path=${encodeURIComponent(full)}" download="${esc(e.name)}" title="Fetch this file to this device"><span class="files-icon" aria-hidden="true">⬇</span><span class="files-name">${esc(e.name)}</span><span class="hint">${fmtSize(e.size)} · ${ago(e.at)}</span></a></li>`;
24
+ });
25
+ list.innerHTML = rows.join('') || '<li class="hint files-empty">Nothing here.</li>';
26
+ if (here.more) list.insertAdjacentHTML('beforeend', `<li class="hint files-empty">…and ${here.more} more: type the path above.</li>`);
27
+ if (!sending) note.textContent = `What you send goes into ${here.dir === here.home ? 'your home folder' : here.dir.split('/').pop()}.`;
28
+ }
29
+
30
+ async function go(dir) {
31
+ try {
32
+ here = await api('GET', `/machine/files?dir=${encodeURIComponent(dir ?? '')}${$('#files-hidden').checked ? '&hidden=1' : ''}`);
33
+ list.scrollTop = 0;
34
+ render();
35
+ return true;
36
+ } catch (err) {
37
+ toast(`Error: ${err.message}`, 6000);
38
+ return false;
39
+ }
40
+ }
41
+
42
+ async function send(picked) {
43
+ const into = here?.dir;
44
+ if (!into) return;
45
+ for (const file of picked) {
46
+ if (file.size > MAX_SEND) {
47
+ toast(`${file.name} is ${fmtSize(file.size)}: more than the ${fmtSize(MAX_SEND)} that can be sent at once`, 7000);
48
+ continue;
49
+ }
50
+ sending++;
51
+ note.textContent = `Sending ${file.name} (${fmtSize(file.size)})…`;
52
+ try {
53
+ const res = await fetch(`/api/machine/files?name=${encodeURIComponent(file.name || 'file')}&dir=${encodeURIComponent(into)}`, {
54
+ method: 'POST',
55
+ credentials: 'same-origin',
56
+ headers: { 'content-type': 'application/octet-stream', 'x-agentmgr': '1' },
57
+ body: file,
58
+ });
59
+ const saved = await res.json().catch(() => ({}));
60
+ if (!res.ok) throw new Error(saved.error || `HTTP ${res.status}`);
61
+ toast(`Sent: ${saved.path}`, 5000);
62
+ } catch (err) {
63
+ toast(`${file.name} was not sent: ${err.message}`, 7000);
64
+ }
65
+ sending--;
66
+ }
67
+ if (here?.dir === into) await go(into);
68
+ }
69
+
70
+ $('#files-pick').onclick = () => input.click();
71
+ input.addEventListener('change', () => {
72
+ const picked = [...input.files];
73
+ input.value = '';
74
+ send(picked);
75
+ });
76
+ dialog.addEventListener('dragover', (e) => e.preventDefault());
77
+ dialog.addEventListener('drop', (e) => {
78
+ e.preventDefault();
79
+ if (e.dataTransfer?.files.length) send([...e.dataTransfer.files]);
80
+ });
81
+ list.addEventListener('click', (e) => {
82
+ const dir = e.target.closest('[data-dir]');
83
+ if (dir) go(dir.dataset.dir);
84
+ });
85
+ $('#files-up').onclick = () => here?.parent && go(here.parent);
86
+ $('#files-home').onclick = () => go('~');
87
+ $('#files-inbox').onclick = () => go(here?.inbox ?? '~/Downloads');
88
+ $('#files-hidden').onchange = () => go(here?.dir);
89
+ $('#files-path').addEventListener('keydown', (e) => {
90
+ if (e.key !== 'Enter') return;
91
+ e.preventDefault();
92
+ go(e.target.value);
93
+ });
94
+ $('#files-close').onclick = () => dialog.close();
95
+
96
+ async function open() {
97
+ if (!dialog.open) dialog.showModal();
98
+ // Where sent files go, and where what you want is most often: Downloads. Home where there is none.
99
+ if (!here && !(await go('~/Downloads'))) await go('~');
100
+ else if (here) await go(here.dir);
101
+ }
102
+ for (const b of document.querySelectorAll('[data-open-files]')) b.addEventListener('click', open);
103
+
104
+ return { open };
105
+ }
package/public/index.html CHANGED
@@ -30,6 +30,7 @@
30
30
  </div>
31
31
  <div class="top-actions">
32
32
  <input id="filter" type="search" placeholder="Filter agents" aria-label="Filter agents" />
33
+ <button id="go-btn" class="go-btn" title="Go to: find a view, an agent or a setting by name (Ctrl+K or ⌘K)" aria-label="Go to a view, an agent or a setting">⌕ Go to</button>
33
34
  <nav class="top-nav" id="top-nav" aria-label="Views">
34
35
  <button id="today-btn" title="Today: what needs you, from every list, most pressing first, and why (y)">Today <span id="today-count" class="badge ready"></span></button>
35
36
  <button id="assistant-btn" title="An always-on session that finds new work and starts agents for it">Assistant <span id="assistant-dot" class="assistant-dot" hidden></span></button>
@@ -72,8 +73,9 @@
72
73
  <button role="menuitem" id="skills-btn" title="Skills: the Agent Skills Claude Code has here (yours and each project's), which agents used them, and adding more from a repository">Skills…</button>
73
74
  <button role="menuitem" id="settings-btn">Settings…</button>
74
75
  <button role="menuitem" id="worklog-btn" title="What your agents got done: pull requests, bugs fixed, issues filed; kept in a spreadsheet for reviews">Work record…</button>
76
+ <button role="menuitem" id="files-btn" data-open-files title="This computer's folders: send it a file from this device (a photo, a document), or fetch one from it (a log, a build)">Files on this computer…</button>
75
77
  <button role="menuitem" id="cleanup-btn" title="Close agents idle for a while, and delete old closed ones">Clean up…</button>
76
- <button role="menuitem" id="alerts-btn" class="local-only" title="Slack alerts when an agent needs you">Alerts…</button>
78
+ <button role="menuitem" id="alerts-btn" class="local-only" title="Alerts when an agent needs you: a Slack message, or a notification on the phone">Alerts…</button>
77
79
  <button role="menuitem" id="remote-btn" class="local-only" title="Open AI Agent Manager from your phone">Remote access…</button>
78
80
  <div class="menu-sep"></div>
79
81
  <div class="menu-theme"><span>Theme</span><span class="seg" role="radiogroup" aria-label="Theme"><button type="button" data-theme-set="auto" title="Follow this device's setting">Auto</button><button type="button" data-theme-set="light">Light</button><button type="button" data-theme-set="dark">Dark</button></span></div>
@@ -608,13 +610,19 @@
608
610
 
609
611
  <dialog id="alerts-dialog">
610
612
  <form id="alerts-form" method="dialog" class="alerts-body">
611
- <h2>Slack alerts</h2>
612
- <p class="hint">Get a Slack message when an agent needs you. Use a <b>Workflow Builder</b> webhook (<code>…/triggers/…</code>, with one Text variable named <code>text</code>), an app's <b>incoming webhook</b> (<code>…/services/…</code>), or a <b>bot token</b> and channel. Stored only on this computer.</p>
613
+ <h2>Alerts</h2>
614
+ <p class="hint">Get a Slack message, a notification on the phone, or both, when an agent needs you. <b>Slack:</b> use a <b>Workflow Builder</b> webhook (<code>…/triggers/…</code>, with one Text variable named <code>text</code>), an app's <b>incoming webhook</b> (<code>…/services/…</code>), or a <b>bot token</b> and channel. Stored only on this computer.</p>
613
615
  <label>Webhook URL <input name="webhookUrl" type="password" autocomplete="off" placeholder="https://hooks.slack.com/services/…" /></label>
614
616
  <div class="row">
615
617
  <label>or bot token <input name="botToken" type="password" autocomplete="off" placeholder="xoxb-…" /></label>
616
618
  <label>channel <input name="channel" placeholder="#agents" /></label>
617
619
  </div>
620
+ <p class="hint"><b>Phone:</b> install the <b>ntfy</b> app on it (App Store or Google Play) and subscribe there to the topic below; a tap on a notification opens the agent. Alerts pass through ntfy.sh, a public service, and whoever knows the topic can read them: keep it to yourself, or give a server of your own.</p>
621
+ <div class="row">
622
+ <label>Phone topic <input name="phoneTopic" autocomplete="off" spellcheck="false" placeholder="empty: nothing goes to the phone" /></label>
623
+ <label>ntfy server <input name="phoneServer" autocomplete="off" spellcheck="false" placeholder="https://ntfy.sh" /></label>
624
+ </div>
625
+ <p><button type="button" class="ghost small" id="alerts-phone-new" title="Fill in a new topic nobody can guess; Save, then subscribe to it in the ntfy app">New topic</button></p>
618
626
  <p class="hint" id="alerts-current"></p>
619
627
  <fieldset>
620
628
  <legend>Alert when an agent…</legend>
@@ -630,6 +638,7 @@
630
638
  <label class="check"><input type="checkbox" name="ev_standup" /> the daily standup is ready (with a link to play it)</label>
631
639
  <label class="check"><input type="checkbox" name="ev_value" /> value reports (weekly, monthly, quarterly, as set in Value)</label>
632
640
  <label class="check"><input type="checkbox" name="ev_usage" /> an engine's plan limit (Claude Code's 5-hour session or week, Codex's) is nearly used up (Usage)</label>
641
+ <label class="check"><input type="checkbox" name="ev_announce" /> an update for the people who asked is written and ready for you to send (when an agent finishes or opens a pull request)</label>
633
642
  <label class="check"><input type="checkbox" name="ev_decided" /> something was decided for you: a standing decision of yours applied, or it was within the autonomy you set (Decide)</label>
634
643
  <label class="check"><input type="checkbox" name="ev_milestone" /> a project's date (code complete, RC, GA) is 14, 7, 3 or 1 days away, today, or late (Plan → Dates)</label>
635
644
  <label class="check"><input type="checkbox" name="ev_waiting" /> finished its turn and is idle after <input name="waitingDelaySec" type="number" min="0" class="num" />s</label>
@@ -1026,23 +1035,56 @@
1026
1035
  <button class="ghost small" data-screen-key="tab" title="Tab">Tab</button>
1027
1036
  <button class="ghost small" data-screen-key="enter" title="Return">⏎</button>
1028
1037
  <select id="screen-combo" class="screen-combo" aria-label="Send a shortcut or a key" title="Shortcuts and keys a phone's keyboard does not have"><option value="">Keys…</option></select>
1038
+ <button class="ghost small" id="screen-clip-btn" data-screen="clip" title="The computer's clipboard: send text to it (and paste it), or fetch what was copied there" aria-pressed="false">Clip</button>
1029
1039
  <button class="ghost small" data-screen-zoom="-1" title="Zoom out" aria-label="Zoom out">−</button>
1030
1040
  <button class="ghost small" id="screen-zoom-now" data-screen-zoom="0" title="Fit the whole screen">Fit</button>
1031
1041
  <button class="ghost small" data-screen-zoom="1" title="Zoom in" aria-label="Zoom in">+</button>
1042
+ <button class="ghost small" id="screen-pad" data-screen="pad" title="Use the screen as a trackpad: drag to move the pointer and tap to click where it is, so your finger does not cover what you aim at. Two fingers scroll or, tapped, right-click; hold, then drag, to drag" aria-pressed="false" hidden>Pad</button>
1032
1043
  <button class="ghost small" id="screen-move" data-screen="move" title="Drag to move around the zoomed screen instead of clicking in it" aria-pressed="false" hidden>Move</button>
1033
1044
  </span>
1045
+ <button class="ghost small" data-open-files title="This computer's folders: send it a file from this device, or fetch one from it">Files</button>
1034
1046
  <button id="screen-off" class="ghost small" data-screen="off" title="No device can reach this computer's screen until you turn it on again here" hidden>Turn off</button>
1035
1047
  <button class="ghost small" data-screen="close" title="Close (ends your connection to the screen)">Close</button>
1036
1048
  </div>
1049
+ <div id="screen-clip" class="screen-clip" hidden>
1050
+ <textarea id="screen-clip-text" rows="2" aria-label="Text for the computer's clipboard, or fetched from it" placeholder="Text to put on the computer's clipboard. Or fetch what was copied there." autocapitalize="none" autocorrect="off" spellcheck="false"></textarea>
1051
+ <span class="screen-clip-acts">
1052
+ <button class="small primary" data-screen="clip-paste" title="Put it on the computer's clipboard and paste it where the cursor is there">Send and paste</button>
1053
+ <button class="ghost small" data-screen="clip-send" title="Put it on the computer's clipboard">Send</button>
1054
+ <button class="ghost small" data-screen="clip-get" title="Fetch the text on the computer's clipboard (copy there first: Keys… → copy)">Fetch</button>
1055
+ </span>
1056
+ </div>
1037
1057
  <div id="screen-body" class="screen-body"></div>
1038
1058
  <div id="screen-view" class="screen-view" hidden></div>
1039
1059
  </dialog>
1060
+ <dialog id="files-dialog" class="files-dialog">
1061
+ <div class="files-head">
1062
+ <b>Files on this computer</b>
1063
+ <span class="spacer"></span>
1064
+ <button id="files-close" class="ghost small">Close</button>
1065
+ </div>
1066
+ <div class="files-bar">
1067
+ <button id="files-up" class="ghost small" title="The folder above" aria-label="The folder above">↑</button>
1068
+ <input id="files-path" aria-label="Folder" title="The folder shown. Type another and press Return" autocomplete="off" autocapitalize="none" autocorrect="off" spellcheck="false" />
1069
+ <button id="files-home" class="ghost small" title="Your home folder">Home</button>
1070
+ <button id="files-inbox" class="ghost small" title="The Downloads folder">Downloads</button>
1071
+ </div>
1072
+ <div class="files-bar">
1073
+ <button id="files-pick" class="primary small" title="Pick files on this device (photos too) and put them in the folder shown. Or drop them here">Send files here…</button>
1074
+ <input id="files-input" type="file" multiple hidden />
1075
+ <label class="check"><input type="checkbox" id="files-hidden" /> hidden files</label>
1076
+ <span id="files-note" class="hint"></span>
1077
+ </div>
1078
+ <ul id="files-list" class="files-list"></ul>
1079
+ <p class="hint files-foot">Tap a folder to open it, a file to fetch it to this device.</p>
1080
+ </dialog>
1040
1081
  <dialog id="machine-dialog" class="machine-dialog">
1041
1082
  <div class="term-bar">
1042
1083
  <div class="term-tabs" id="machine-tabs" role="tablist"></div>
1043
1084
  <button class="term-tab term-add" id="machine-new" title="Open another terminal">+ Terminal</button>
1044
1085
  <span id="machine-title" class="hint"></span>
1045
1086
  <span class="spacer"></span>
1087
+ <button class="ghost small" data-open-files title="This computer's folders: send it a file from this device, or fetch one from it">Files</button>
1046
1088
  <button id="machine-copy" class="ghost small" title="Copy text from the terminal">Copy</button>
1047
1089
  <button id="machine-paste" class="ghost small" title="Paste into the terminal">Paste</button>
1048
1090
  <button id="machine-close" class="ghost small" title="Hide (the shells keep running)">Hide</button>
package/public/keys.js CHANGED
@@ -17,6 +17,7 @@ export const SHORTCUTS = [
17
17
  [['n'], 'New agents', 'new'],
18
18
  [['a'], 'Ask Agent (a general session)', 'ask'],
19
19
  [['/'], 'Filter agents', 'filter'],
20
+ [['Ctrl+K', 'Cmd+K'], 'Go to: find a view, an agent or a setting by name', null],
20
21
  [['w'], 'Watch: agents side by side', 'watch'],
21
22
  [['p'], 'Play the standup', 'standup'],
22
23
  [['m'], 'Map: where agents are in the code', 'map'],
@@ -0,0 +1,122 @@
1
+ // Go to: one box that finds a view, an agent or a setting by name, instead of looking for its
2
+ // button (on a phone most of them are in the More menu) or remembering its key. Ctrl+K or ⌘K.
3
+
4
+ /**
5
+ * The items that match what was typed, best first: every word must be in the name or its
6
+ * description; a name that starts with it comes before one that contains it, and that before a
7
+ * match in the description only. With nothing typed, all of them in their own order.
8
+ */
9
+ export function findMatches(items, query) {
10
+ const words = query.toLowerCase().split(/\s+/).filter(Boolean);
11
+ if (!words.length) return items;
12
+ const q = words.join(' ');
13
+ return items
14
+ .map((item, at) => {
15
+ const label = item.label.toLowerCase();
16
+ const all = `${label} ${(item.hint ?? '').toLowerCase()}`;
17
+ if (!words.every((w) => all.includes(w))) return null;
18
+ const rank = label.startsWith(q) ? 0 : label.split(/[\s/:-]+/).some((part) => part.startsWith(words[0])) ? 1 : words.every((w) => label.includes(w)) ? 2 : 3;
19
+ return { item, rank, at };
20
+ })
21
+ .filter(Boolean)
22
+ .sort((a, b) => a.rank - b.rank || a.at - b.at)
23
+ .map((m) => m.item);
24
+ }
25
+
26
+ const MAX = 60;
27
+
28
+ export function initPalette({ $, esc, agents, select }) {
29
+ const dialog = document.createElement('dialog');
30
+ dialog.id = 'go-dialog';
31
+ dialog.className = 'go-dialog';
32
+ dialog.innerHTML = `<input id="go-input" type="search" placeholder="Go to a view, an agent or a setting…" aria-label="Go to" aria-controls="go-list" autocomplete="off" autocapitalize="none" autocorrect="off" spellcheck="false" />
33
+ <ul id="go-list" class="go-list" role="listbox"></ul>
34
+ <p id="go-none" class="hint" hidden>Nothing by that name.</p>`;
35
+ document.body.appendChild(dialog);
36
+ const input = dialog.querySelector('#go-input');
37
+ const list = dialog.querySelector('#go-list');
38
+ let shown = [];
39
+ let at = 0;
40
+
41
+ /** A button as an item: its own words as the name, its tooltip as the description. */
42
+ function ofButton(b, kind) {
43
+ if (b.hidden || getComputedStyle(b).display === 'none') return null;
44
+ const label = [...b.childNodes].filter((n) => n.nodeType === Node.TEXT_NODE).map((n) => n.textContent).join(' ').replace(/[…▾]/g, '').replace(/^\+\s*/, '').trim();
45
+ if (!label) return null;
46
+ const count = b.querySelector('.badge')?.textContent.trim();
47
+ return { label, hint: b.title || '', kind, count, run: () => b.click() };
48
+ }
49
+
50
+ function collect() {
51
+ const views = [...document.querySelectorAll('#top-nav button:not(#top-more-btn), #new-btn')].map((b) => ofButton(b, 'View'));
52
+ const tabs = [...document.querySelectorAll('.side-tab')].map((b) => ofButton(b, 'List'));
53
+ const menu = [...document.querySelectorAll('#menu [role="menuitem"]')].map((b) => ofButton(b, 'Menu'));
54
+ const mine = agents().map((a) => ({ label: a.label, hint: a.hint, kind: 'Agent', run: () => select(a.id) }));
55
+ return [...views, ...tabs, ...menu, ...mine].filter(Boolean);
56
+ }
57
+
58
+ let items = [];
59
+ function render() {
60
+ shown = findMatches(items, input.value).slice(0, MAX);
61
+ at = Math.max(0, Math.min(at, shown.length - 1));
62
+ list.innerHTML = shown
63
+ .map((it, i) => `<li role="option" data-go="${i}" aria-selected="${i === at}"${i === at ? ' class="sel"' : ''}><span class="go-name">${esc(it.label)}${it.count ? ` <span class="badge">${esc(it.count)}</span>` : ''}</span><span class="go-hint">${esc(it.hint)}</span><span class="go-kind">${it.kind}</span></li>`)
64
+ .join('');
65
+ dialog.querySelector('#go-none').hidden = shown.length > 0;
66
+ list.querySelector('.sel')?.scrollIntoView({ block: 'nearest' });
67
+ }
68
+
69
+ function open() {
70
+ if (dialog.open) return dialog.close();
71
+ // Under another dialog it could not be used; that dialog has the page.
72
+ if (document.querySelector('dialog[open]')) return false;
73
+ items = collect();
74
+ input.value = '';
75
+ at = 0;
76
+ render();
77
+ dialog.showModal();
78
+ input.focus();
79
+ }
80
+
81
+ function go(i) {
82
+ const it = shown[i];
83
+ if (!it) return;
84
+ dialog.close();
85
+ // After the dialog is gone: what it opens may be a dialog of its own.
86
+ setTimeout(it.run);
87
+ }
88
+
89
+ input.addEventListener('input', () => {
90
+ at = 0;
91
+ render();
92
+ });
93
+ input.addEventListener('keydown', (e) => {
94
+ const step = { ArrowDown: 1, ArrowUp: -1 }[e.key];
95
+ if (step) {
96
+ e.preventDefault();
97
+ at = (at + step + shown.length) % Math.max(1, shown.length);
98
+ render();
99
+ } else if (e.key === 'Enter') {
100
+ e.preventDefault();
101
+ go(at);
102
+ }
103
+ });
104
+ list.addEventListener('click', (e) => {
105
+ const li = e.target.closest('[data-go]');
106
+ if (li) go(Number(li.dataset.go));
107
+ });
108
+ // A click beside the box closes it.
109
+ dialog.addEventListener('click', (e) => e.target === dialog && dialog.close());
110
+
111
+ // ⌘K anywhere; Ctrl+K too, except in a terminal, where it is the shell's (cut to the end of the line).
112
+ document.addEventListener('keydown', (e) => {
113
+ if (e.key.toLowerCase() !== 'k' || e.altKey || e.shiftKey || !(e.metaKey || e.ctrlKey)) return;
114
+ if (!e.metaKey && e.target.closest?.('.xterm')) return;
115
+ e.preventDefault();
116
+ e.stopPropagation();
117
+ open();
118
+ }, true);
119
+ $('#go-btn').onclick = () => open();
120
+
121
+ return { open };
122
+ }