ai-agentmanager 1.52.0 → 1.55.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,54 @@
1
+ // Board: which column an agent's card is in, why it needs the person, and what a drag does. No
2
+ // page needed, so it is tested by itself (board.js draws it).
3
+
4
+ export const BOARD_COLUMNS = [
5
+ { id: 'starting', label: 'Starting', hint: 'Its workspace is being prepared, or it is planning' },
6
+ { id: 'working', label: 'Working', hint: 'Producing output now' },
7
+ { id: 'needs', label: 'Needs you', hint: 'A prompt, a question, a plan to approve, a limit, an error, or it may be stuck' },
8
+ { id: 'idle', label: 'Waiting', hint: 'Its session is open and waits for its next instruction' },
9
+ { id: 'review', label: 'In review', hint: 'It has an open pull request' },
10
+ { id: 'done', label: 'Done', hint: 'Its pull request merged, or it reported its work done' },
11
+ { id: 'closed', label: 'Closed', hint: 'Its session is closed and can be resumed' },
12
+ ];
13
+
14
+ export const openPrs = (a) => (a.prs ?? []).filter((p) => p.land && p.land !== 'merged' && p.land !== 'closed');
15
+
16
+ /** Why an agent needs the person, in a few words, or null. */
17
+ export function needOf(a) {
18
+ const rt = a.runtime ?? {};
19
+ if (rt.attention) return 'a prompt to answer';
20
+ if (a.status === 'error') return 'an error';
21
+ if (rt.limited) return 'stopped at a limit';
22
+ if (a.planReview?.status === 'review') return 'a plan to approve';
23
+ const q = (a.questions ?? []).filter((x) => !x.answer).length;
24
+ if (q) return q === 1 ? 'a question' : `${q} questions`;
25
+ if (rt.waiting) return rt.waiting.kind === 'error' ? 'an error on its screen' : 'a question on its screen';
26
+ if (a.stuck?.length) return 'may be stuck';
27
+ return null;
28
+ }
29
+
30
+ /** The column an agent's card is in. */
31
+ export function columnOf(a) {
32
+ const rt = a.runtime ?? {};
33
+ if (needOf(a)) return 'needs';
34
+ if (a.status === 'preparing' || rt.planning) return 'starting';
35
+ if (rt.running && rt.busy) return 'working';
36
+ if (openPrs(a).length) return 'review';
37
+ if ((a.prs ?? []).some((p) => p.land === 'merged') || a.results?.outcome === 'done') return 'done';
38
+ return rt.running ? 'idle' : 'closed';
39
+ }
40
+
41
+ /** What a card dropped on a column does: { act: 'stop' | 'start' } or { why } when it does nothing. */
42
+ export function dropAction(a, to) {
43
+ const from = columnOf(a);
44
+ const rt = a.runtime ?? {};
45
+ if (from === to) return { why: null };
46
+ if (to === 'closed') {
47
+ if (!rt.running) return { why: 'Its session is already closed' };
48
+ if (rt.busy) return { why: 'It is working. Close its session from its detail if you mean to stop it' };
49
+ return { act: 'stop' };
50
+ }
51
+ if (to === 'idle' && !rt.running && a.workdir && a.status !== 'preparing') return { act: 'start' };
52
+ const col = BOARD_COLUMNS.find((c) => c.id === to);
53
+ return { why: `An agent moves to ${col?.label ?? to} by itself. Drag onto Closed to close a session, or from Closed onto Waiting to resume it` };
54
+ }
package/public/eval.js CHANGED
@@ -32,10 +32,10 @@ export function evalHtml(ev, esc, { canPost = false } = {}) {
32
32
  ${ev.criteria.length ? `<h4>Acceptance criteria</h4><ul class="eval-list">${ev.criteria.map((c) => `<li>${c.status === 'met' ? '✅' : c.status === 'not_met' ? '❌' : '⏳'} ${esc(c.criterion)}${c.evidence ? ` <span class="hint">— ${esc(c.evidence)}</span>` : ''}</li>`).join('')}</ul>` : ''}
33
33
  <h4>Tests run</h4>
34
34
  <ul class="eval-list">
35
- ${rerun && !rerun.running ? `<li>${rerun.passed ? '✅' : '❌'} <code>${esc(rerun.command)}</code> run again by AI Agent Manager${counts(rerun.counts)} <span class="hint">${esc(new Date(rerun.at).toLocaleString())}${rerun.ms ? ` · ${Math.round(rerun.ms / 1000)}s` : ''}</span>${rerun.passed ? '' : `<pre class="eval-tail">${esc(rerun.tail ?? '')}</pre>`}</li>` : ''}
35
+ ${rerun && !rerun.running ? `<li>${rerun.passed ? '✅' : rerun.flaky ? '🟡' : '❌'} <code>${esc(rerun.command)}</code> run again by AI Agent Manager${rerun.runs > 1 ? ` <b>${rerun.flaky ? `flaky: passed ${rerun.passes} of ${rerun.runs} runs` : `${rerun.runs} runs`}</b>` : ''}${counts(rerun.counts)} <span class="hint">${esc(new Date(rerun.at).toLocaleString())}${rerun.ms ? ` · ${Math.round(rerun.ms / 1000)}s` : ''}</span>${rerun.passed ? '' : `<pre class="eval-tail">${esc(rerun.tail ?? '')}</pre>`}</li>` : ''}
36
36
  ${[...last.values()].map((r) => `<li>${r.passed ? '✅' : '❌'} <code>${esc(r.command)}</code> by the agent${counts(r.counts)} ${ev.runs.filter((x) => x.command === r.command).length > 1 ? `<span class="hint">· ran ${ev.runs.filter((x) => x.command === r.command).length}×, last shown</span>` : ''}</li>`).join('') || '<li class="hint">The agent ran no tests in its session.</li>'}
37
37
  </ul>
38
- <form class="eval-command" data-eval-command><label class="hint">Test command for this project <input name="command" value="${esc(ev.testCommand ?? '')}" placeholder="e.g. npm test" autocomplete="off" /></label> <button class="small">Save</button></form>
38
+ <form class="eval-command" data-eval-command><label class="hint">Test command for this project <input name="command" value="${esc(ev.testCommand ?? '')}" placeholder="e.g. npm test" autocomplete="off" /></label> <label class="hint" title="How many times the tests are run each time, on the same code. More than one shows a flaky test: one that passes in some runs and fails in others. With 1, a run that fails is run once more">Runs <input name="runs" type="number" min="1" max="5" value="${ev.testRuns ?? 1}" /></label> <button class="small">Save</button></form>
39
39
  ${ev.pending.length ? `<h4>Pending</h4><ul class="eval-list">${ev.pending.map((p) => `<li>⏳ ${esc(p)}</li>`).join('')}</ul>` : '<p class="hint">Nothing pending.</p>'}
40
40
  <p class="hint">Confidence comes from fixed rules over these, not from a model: it is 100% only when the tests pass when run again on the code as it is now, every acceptance criterion is met, CI and the AI judge agree, and nothing is pending.</p>
41
41
  </div>`;
package/public/index.html CHANGED
@@ -45,6 +45,7 @@
45
45
  <button id="plan-btn" title="Plan: a project's dates (code complete, RC, GA) with their checklists and reminders, the decision log, and the tech debt radar">Plan <span id="plan-count" class="badge"></span></button>
46
46
  <button id="news-btn" title="AI News: the frontier labs' latest releases (Anthropic, OpenAI, Google and the other top labs), each summarized, with links">AI News <span id="news-count" class="badge ready"></span></button>
47
47
  <button id="map-btn" title="The codebase map: where each agent is changing and reading code, and who is about to collide">Map</button>
48
+ <button id="board-btn" title="Board: every agent as a card in the column for where its work stands: starting, working, needs you, waiting, in review, done, closed (B)">Board</button>
48
49
  <button id="watch-btn" title="Running agents' sessions side by side, live: follow them all without clicking from one to the next">Watch</button>
49
50
  <button id="mcp-btn" title="MCP: the MCP servers Claude Code has (yours, projects', claude.ai connectors and plugins), their tools, and running one in an agent's session or workspace">MCP</button>
50
51
  <button id="os-btn" title="OS: this computer and how loaded it is right now: processor, memory, disks, what each open agent session takes, and the busiest processes">OS</button>
@@ -437,6 +438,9 @@
437
438
  <dialog id="decide-dialog" class="issues-dialog decide-dialog" aria-label="Decide">
438
439
  <div id="decide-body"></div>
439
440
  </dialog>
441
+ <dialog id="board-dialog" class="issues-dialog board-dialog" aria-label="Board">
442
+ <div id="board-body"></div>
443
+ </dialog>
440
444
  <dialog id="os-dialog" class="issues-dialog os-dialog" aria-label="OS">
441
445
  <div id="os-body"></div>
442
446
  </dialog>
@@ -446,6 +450,7 @@
446
450
  <dialog id="standup-dialog" class="standup-dialog" aria-label="Standup">
447
451
  <div id="standup-body"></div>
448
452
  </dialog>
453
+ <datalist id="local-models-list"></datalist>
449
454
  <dialog id="ask-dialog">
450
455
  <form id="ask-form" method="dialog">
451
456
  <h2>Ask an agent</h2>
@@ -465,6 +470,10 @@
465
470
  <select name="engine"><option value="">Claude Code</option></select>
466
471
  <span class="hint warn" id="ask-engine-notice" hidden></span>
467
472
  </label>
473
+ <label id="ask-model-field" hidden>
474
+ Model
475
+ <input name="model" list="local-models-list" />
476
+ </label>
468
477
  </div>
469
478
  <p id="ask-error" class="error" hidden></p>
470
479
  <div class="dialog-actions">
package/public/keys.js CHANGED
@@ -30,6 +30,7 @@ export const SHORTCUTS = [
30
30
  [['l'], 'AI News: the latest frontier releases', 'news'],
31
31
  [['c'], 'Plan: project dates, decisions and tech debt', 'plan'],
32
32
  [['u'], 'OS: this computer and its load', 'os'],
33
+ [['B'], 'Board: every agent as a card, by where its work stands', 'board'],
33
34
  [['q'], 'Decide: recommendations, standing decisions, impact, dates at risk', 'decide'],
34
35
  [['z'], "Usage: each engine's plan limits, used and left", 'usage'],
35
36
  [['1'], 'Agents tab', 'tab:agents'],
@@ -75,11 +76,11 @@ export const SHORTCUTS = [
75
76
  // A single key, as an event names it, to its action.
76
77
  export const SINGLE = {
77
78
  j: 'next', k: 'prev', Enter: 'terminal', t: 'terminal',
78
- r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', o: 'actions', h: 'assistant', ',': 'settings', d: 'designs', g: 'reviews', v: 'value', l: 'news', c: 'plan', u: 'os', q: 'decide', z: 'usage', y: 'today', b: 'bugs', '?': 'help',
79
+ r: 'changes', s: 'start', X: 'stop', e: 'edit', n: 'new', a: 'ask', '/': 'filter', w: 'watch', p: 'standup', m: 'map', i: 'issues', o: 'actions', h: 'assistant', ',': 'settings', d: 'designs', g: 'reviews', v: 'value', l: 'news', c: 'plan', u: 'os', B: 'board', q: 'decide', z: 'usage', y: 'today', b: 'bugs', '?': 'help',
79
80
  1: 'tab:agents', 2: 'tab:inbox', 3: 'tab:backlog', 4: 'tab:land', 5: 'tab:built',
80
81
  };
81
82
  // While Watch is open: only what makes sense there.
82
- const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'news', 'plan', 'os', 'decide', 'usage', 'bugs', 'help']);
83
+ const ON_WATCH = new Set(['today', 'new', 'ask', 'watch', 'standup', 'map', 'issues', 'actions', 'assistant', 'settings', 'designs', 'reviews', 'value', 'news', 'plan', 'os', 'board', 'decide', 'usage', 'bugs', 'help']);
83
84
 
84
85
  /** Typing somewhere: a field, an editor or a terminal (xterm types through a textarea). */
85
86
  const typing = (el) => Boolean(el?.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], .xterm, .cm-editor'));
package/public/style.css CHANGED
@@ -621,6 +621,7 @@ dialog::backdrop { background: rgba(0, 0, 0, .45); }
621
621
  .del { color: var(--red); }
622
622
  .test.passed { color: var(--green); }
623
623
  .test.failed, .test.error { color: var(--red); }
624
+ .test.flaky { color: var(--yellow); }
624
625
  .test.running, .test.queued { color: var(--yellow); }
625
626
  .race-diff { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
626
627
  pre.diff { margin: 6px 0 0; max-height: 50vh; overflow: auto; font: 12px/1.45 var(--mono); background: var(--panel-2); padding: 8px 10px; border-radius: 6px; }
@@ -1746,4 +1747,42 @@ table.eval-items tr.eval-na td { color: var(--muted); }
1746
1747
  .eval-tail { margin: 4px 0 0 1.2em; text-indent: 0; max-height: 160px; overflow: auto; font-size: 11.5px; white-space: pre-wrap; }
1747
1748
  .eval-command { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
1748
1749
  .eval-command input { min-width: 220px; }
1750
+ .eval-command input[type='number'], .race-tests input[type='number'] { min-width: 0; width: 56px; }
1749
1751
  @media (max-width: 600px) { table.eval-items td:nth-child(2) { white-space: normal; } .eval-acts { margin-left: 0; } }
1752
+
1753
+ /* OS: an agent's lane of ports and what it listens on. */
1754
+ .os-ports { white-space: normal; font-variant-numeric: tabular-nums; }
1755
+ .os-port-out { color: var(--yellow); }
1756
+ .os-lanes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 8px 0 14px; font-size: 13px; }
1757
+ .os-lanes label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
1758
+ .os-lanes input { width: auto; flex: none; margin: 0; }
1759
+
1760
+ /* Board: agents as cards in columns by where their work stands. */
1761
+ .board-dialog { width: min(1500px, calc(100% - 32px)); height: min(820px, calc(100% - 32px)); }
1762
+ #board-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
1763
+ .board-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: 10px; flex: 1; min-height: 0; overflow-x: auto; padding-bottom: 6px; }
1764
+ .board-col { display: flex; flex-direction: column; min-height: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
1765
+ .board-col.drop { border-color: var(--accent); outline: 1px dashed var(--accent); }
1766
+ .board-col h3 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; }
1767
+ .board-col.col-needs h3 { color: var(--red); }
1768
+ .board-col.col-working h3 { color: var(--green); }
1769
+ .board-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 40px; flex: 1; }
1770
+ .board-card { padding: 8px; border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 6px; background: var(--panel); cursor: pointer; font-size: 13px; }
1771
+ .board-card:hover, .board-card:focus-visible { border-color: var(--accent); outline: none; }
1772
+ .board-card.pr0 { border-left-color: var(--red); }
1773
+ .board-card.pr1 { border-left-color: var(--yellow); }
1774
+ .board-card.dragging { opacity: .5; }
1775
+ .board-card-head { display: flex; gap: 6px; align-items: center; min-width: 0; }
1776
+ .board-card-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1777
+ .board-need { color: var(--red); margin-top: 2px; }
1778
+ .board-pr { margin-top: 2px; color: var(--muted); }
1779
+ .board-pr.ready, .board-pr.merged { color: var(--green); }
1780
+ .board-pr.fix { color: var(--red); }
1781
+ .board-pr.behind { color: var(--yellow); }
1782
+ .board-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; }
1783
+ .board-meta .fail { color: var(--red); }
1784
+ @media (max-width: 720px) {
1785
+ .board-cols { grid-auto-columns: minmax(220px, 80%); }
1786
+ }
1787
+ .os-local td:first-child { white-space: normal; overflow-wrap: anywhere; }
1788
+ .os-local-no code { opacity: 0.6; }
package/public/system.js CHANGED
@@ -13,17 +13,20 @@ export const bytes = (n) => (n >= 1024 ** 3 ? `${(n / 1024 ** 3).toFixed(1)} GB`
13
13
  /** 3d 4h, 5h 12m, 9m. */
14
14
  export const span = (sec) => (sec >= 86400 ? `${Math.floor(sec / 86400)}d ${Math.floor((sec % 86400) / 3600)}h` : sec >= 3600 ? `${Math.floor(sec / 3600)}h ${Math.floor((sec % 3600) / 60)}m` : `${Math.floor(sec / 60)}m`);
15
15
 
16
- export function initSystem({ api, $, esc, toast, openAgent }) {
16
+ export function initSystem({ api, $, esc, toast, openAgent, openPort }) {
17
17
  const dialog = $('#os-dialog');
18
18
  const body = $('#os-body');
19
19
  let data = null;
20
20
  let problem = null;
21
+ let local = null;
21
22
  let timer = null;
22
23
 
23
24
  async function load() {
24
25
  try {
25
26
  data = await api('GET', '/system');
26
27
  problem = null;
28
+ // The model servers running here (asked again by the daemon every few seconds at most).
29
+ local = await api('GET', '/local-models').catch(() => local);
27
30
  } catch (e) {
28
31
  problem = e.message;
29
32
  }
@@ -33,6 +36,14 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
33
36
  const tone = (p) => (p >= 90 ? 'heavy' : p >= 70 ? 'busy' : 'light');
34
37
  const meter = (p) => `<div class="os-meter ${tone(p)}" role="img" aria-label="${p}%"><span style="width:${Math.min(100, Math.max(0, p))}%"></span></div>`;
35
38
 
39
+ /** An agent's lane, what it listens on (a port outside its lane marked), and who else holds a port of its lane. */
40
+ function portsCell(a) {
41
+ const open = (a.ports ?? []).map((p) => `<button class="link${a.lane && !p.inLane ? ' os-port-out' : ''}" data-os-port="${p.port}" data-os-port-agent="${esc(a.id)}" title="${esc(p.name)} (PID ${p.pid}) listens on ${p.port}${a.lane && !p.inLane ? ': outside its lane' : ''}. Open it">${p.port}</button>`).join(' ');
42
+ const taken = (a.taken ?? []).map((t) => `<span class="os-port-out" title="${esc(t.name)} (PID ${t.pid})${t.by ? ', started by another agent,' : ''} holds ${t.port}, a port of this agent's lane">${t.port} taken</span>`).join(' ');
43
+ const lane = a.lane ? `<span class="hint" title="Lane ${a.lane.n}: its own ports. Names it creates end with ${esc(a.lane.suffix)}">${a.lane.first}–${a.lane.last}</span>` : '';
44
+ return [lane, open, taken].filter(Boolean).join(' · ') || '<span class="hint">—</span>';
45
+ }
46
+
36
47
  /** The last ten minutes of one measure (0 to 100) as a small line. */
37
48
  function spark(points, label) {
38
49
  if (points.length < 2) return '<div class="os-spark hint">Its last ten minutes are drawn as they pass.</div>';
@@ -44,11 +55,28 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
44
55
  <polygon points="0,${h} ${xy.join(' ')} ${w},${h}"></polygon><polyline points="${xy.join(' ')}"></polyline></svg>`;
45
56
  }
46
57
 
58
+ // A model named by its file (llama.cpp) is shown by the file's name; the whole of it is in the title.
59
+ const short = (id) => (id.length > 60 && id.includes('//') ? `${id.slice(0, id.indexOf('/'))}/…${id.slice(id.lastIndexOf('/'))}`.replace(/(.{28}).+(.{12})$/, '$1…$2') : id);
60
+
61
+ /** Models served on this computer, for agents on the "Local model" engine. */
62
+ function localHtml() {
63
+ const servers = (local?.servers ?? []).filter((s) => s.running);
64
+ if (!local?.enabled || !servers.length) return '';
65
+ const models = servers.flatMap((s) => s.models.map((m) => ({ ...m, server: s })));
66
+ const harnesses = (local.harnesses ?? []).filter((h) => h.installed);
67
+ return `<h3 title="Models served on this computer. Start an agent on one with a Local engine: the harness (Codex, OpenCode or Claude Code) is pointed at the server">Local models <span class="hint">${servers.map((s) => `${esc(s.label)}${s.version ? ` ${esc(s.version)}` : ''}`).join(', ')}${harnesses.length ? ` · run by ${harnesses.map((h) => esc(h.label)).join(', ')}` : ''}</span></h3>
68
+ ${models.length
69
+ ? `<table class="issues os-table os-local"><thead><tr><th>Model</th><th class="num">Size</th><th title="Whether an agent can work with it: it has to call tools to read and change files">For agents</th></tr></thead><tbody>
70
+ ${models.map((m) => `<tr class="${m.usable ? '' : 'os-local-no'}"><td><code title="${esc(m.id)}">${esc(short(m.id))}</code>${m.loaded ? ' <span class="tag" title="In memory now">loaded</span>' : ''}${m.notes.length ? `<div class="hint">${esc(m.notes.join('. '))}</div>` : ''}</td><td class="num">${[m.sizeBytes ? bytes(m.sizeBytes) : '', esc(m.params ?? '')].filter(Boolean).join(' · ')}</td><td>${m.usable ? 'Yes' : '<span class="os-port-out">No</span>'}</td></tr>`).join('')}
71
+ </tbody></table>`
72
+ : '<p class="hint">No model yet.</p>'}`;
73
+ }
74
+
47
75
  const row = (k, v) => (v ? `<tr><th>${esc(k)}</th><td>${v}</td></tr>` : '');
48
76
 
49
77
  function draw() {
50
78
  if (!data) return `<div class="issues-head"><h2>OS</h2><span class="spacer"></span><button class="small" data-os="close">Close</button></div><p class="hint">${problem ? esc(problem) : 'Loading…'}</p>`;
51
- const { host, cpu, memory: mem, disks, agents, processes, app, history } = data;
79
+ const { host, cpu, memory: mem, disks, agents, processes, app, history, lanes } = data;
52
80
  const minutes = Math.max(1, Math.round((history.length * data.sampleSeconds) / 60));
53
81
  return `
54
82
  <div class="issues-head">
@@ -107,10 +135,12 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
107
135
  <section>
108
136
  <h3>Agent sessions <span class="hint">${agents.open}</span></h3>
109
137
  ${agents.list.length
110
- ? `<table class="issues os-table"><thead><tr><th>Agent</th><th class="num" title="Of one core: 200% is two cores busy">Processor</th><th class="num">Memory</th><th class="num" title="The session and everything it started">Processes</th></tr></thead><tbody>
111
- ${agents.list.map((a) => `<tr><td><button class="link" data-os-agent="${esc(a.id)}">${esc(a.name)}</button></td><td class="num">${a.cpu}%</td><td class="num">${bytes(a.mem)}</td><td class="num">${a.count}</td></tr>`).join('')}
138
+ ? `<table class="issues os-table"><thead><tr><th>Agent</th><th class="num" title="Of one core: 200% is two cores busy">Processor</th><th class="num">Memory</th><th class="num" title="The session and everything it started">Processes</th><th title="Its own range of ports, and what it listens on now">Ports</th></tr></thead><tbody>
139
+ ${agents.list.map((a) => `<tr><td><button class="link" data-os-agent="${esc(a.id)}">${esc(a.name)}</button></td><td class="num">${a.cpu}%</td><td class="num">${bytes(a.mem)}</td><td class="num">${a.count}</td><td class="os-ports">${portsCell(a)}</td></tr>`).join('')}
112
140
  </tbody></table>`
113
141
  : '<p class="hint">No agent session is open.</p>'}
142
+ ${lanes ? `<div class="os-lanes"><label title="Each agent gets a range of ports and a name ending no other agent has, in its environment (AGENT_PORTS, AGENT_SUFFIX) and its instructions, so dev servers and test databases of agents working side by side don't collide. For sessions started from now on"><input type="checkbox" data-os-lanes="enabled" ${lanes.enabled ? 'checked' : ''} /> A lane of ports for each agent</label>${lanes.enabled ? `<label title="Many dev servers listen on PORT when it is set. Turn off if your projects use PORT for something else"><input type="checkbox" data-os-lanes="port" ${lanes.port ? 'checked' : ''} /> Set PORT to its first port</label><span class="hint">${lanes.size} port${lanes.size === 1 ? '' : 's'} each, from ${lanes.base}</span>` : ''}</div>` : ''}
143
+ ${localHtml()}
114
144
  <h3>Busiest processes <span class="hint">of ${processes.count}</span></h3>
115
145
  <table class="issues os-table"><thead><tr><th>Process</th><th class="num" title="Of one core: 200% is two cores busy">Processor</th><th class="num">Memory</th><th class="num">PID</th></tr></thead><tbody>
116
146
  ${processes.top.map((p) => `<tr><td title="${esc(p.command)}">${esc(p.name)}</td><td class="num">${p.cpu}%</td><td class="num">${bytes(p.mem)}</td><td class="num hint">${p.pid}</td></tr>`).join('')}
@@ -126,12 +156,30 @@ export function initSystem({ api, $, esc, toast, openAgent }) {
126
156
 
127
157
  body.addEventListener('click', (e) => {
128
158
  if (e.target.closest('[data-os="close"]')) return dialog.close();
159
+ const port = e.target.closest('[data-os-port]');
160
+ if (port) {
161
+ dialog.close();
162
+ return openPort?.(port.dataset.osPortAgent, Number(port.dataset.osPort));
163
+ }
129
164
  const a = e.target.closest('[data-os-agent]');
130
165
  if (a) {
131
166
  dialog.close();
132
167
  openAgent?.(a.dataset.osAgent);
133
168
  }
134
169
  });
170
+ // Lanes on or off, and PORT with them: for the sessions started from now on.
171
+ body.addEventListener('change', async (e) => {
172
+ const key = e.target.dataset?.osLanes;
173
+ if (!key) return;
174
+ try {
175
+ const { enabled, base, size, port } = await api('PUT', '/lanes', { [key]: e.target.checked });
176
+ if (data) data.lanes = { enabled, base, size, port };
177
+ toast?.(key === 'port' ? (port ? 'PORT is set for sessions started from now on' : 'PORT is left alone in sessions started from now on') : enabled ? 'Each agent gets its own ports, in sessions started from now on' : 'No lanes for sessions started from now on', 4000);
178
+ } catch (err) {
179
+ toast?.(err.message, 5000);
180
+ }
181
+ render();
182
+ });
135
183
 
136
184
  dialog.addEventListener('close', () => {
137
185
  clearInterval(timer);
package/src/cli.js CHANGED
@@ -344,7 +344,7 @@ export async function main(argv) {
344
344
  ]),
345
345
  )
346
346
  .option('-m, --model <model>', 'model (for the chosen engine)')
347
- .option('-e, --engine <engine>', 'agent engine: claude (default), codex, antigravity or muse')
347
+ .option('-e, --engine <engine>', 'agent engine: claude (default), codex, antigravity, muse, or local (local-codex, local-opencode, local-claude) with --model <server>/<model>: see agentmgr models')
348
348
  .option('--file-attach <path>', 'attach a file to the request (a screenshot, a log); repeat for more', collect)
349
349
  .option('--container', 'run each agent in its own Docker container (see agentmgr sandbox)')
350
350
  .option('--no-container', 'run on this computer even if containers are the default')
@@ -434,7 +434,7 @@ export async function main(argv) {
434
434
  .argument('[question...]', 'optional first question')
435
435
  .option('-n, --name <name>', 'display name')
436
436
  .option('-m, --model <model>', 'model (for the chosen engine)')
437
- .option('-e, --engine <engine>', 'agent engine: claude (default), codex, antigravity or muse')
437
+ .option('-e, --engine <engine>', 'agent engine: claude (default), codex, antigravity, muse, or local (local-codex, local-opencode, local-claude) with --model <server>/<model>: see agentmgr models')
438
438
  .option('--file-attach <path>', 'attach a file to the question (a screenshot, a log); repeat for more', collect)
439
439
  .option('--no-attach', 'start it in the background only')
440
440
  .action(async (words, opts) => {
@@ -869,6 +869,59 @@ export async function main(argv) {
869
869
  throw new Error(`Unknown action ${action} (ls, show, look, add, check, update, rm)`);
870
870
  });
871
871
 
872
+ program
873
+ .command('models')
874
+ .description('Models running on this computer (Ollama, LM Studio, llama.cpp, MLX), for agents on a local engine (Codex, OpenCode or Claude Code as the harness): --engine local --model <server>/<model>')
875
+ .option('--add <name=address>', 'also ask a server at this address, say mlx=http://127.0.0.1:8081')
876
+ .option('--remove <name>', 'stop asking a server')
877
+ .option('--context <tokens>', "the room Ollama gives a model for an agent (0: leave Ollama's own)")
878
+ .option('--default <model>', 'the model of a local agent started without one')
879
+ .option('--harness <name>', 'what runs the model when the engine is just "local": codex, opencode or claude')
880
+ .option('--on', 'look for local models')
881
+ .option('--off', 'stop looking')
882
+ .option('--json', 'print JSON')
883
+ .action(async (opts) => {
884
+ await daemon();
885
+ const patch = { ...(opts.on ? { enabled: true } : opts.off ? { enabled: false } : {}), ...(opts.context !== undefined ? { context: opts.context } : {}), ...(opts.default !== undefined ? { default: opts.default } : {}), ...(opts.harness !== undefined ? { harness: opts.harness } : {}), ...(opts.remove ? { remove: opts.remove } : {}) };
886
+ if (opts.add) {
887
+ const at = opts.add.indexOf('=');
888
+ if (at < 1) throw new Error('--add takes <name>=<address>, say mlx=http://127.0.0.1:8081');
889
+ patch.add = { name: opts.add.slice(0, at), url: opts.add.slice(at + 1) };
890
+ }
891
+ const v = Object.keys(patch).length ? await api('PUT', '/local-models/settings', patch) : await api('GET', '/local-models?fresh=1');
892
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
893
+ if (!v.enabled) return console.log(`Local models ${dim('off')} ${dim('(agentmgr models --on)')}`);
894
+ const gb = (n) => (n ? `${(n / 1024 ** 3).toFixed(1)} GB` : '');
895
+ if (!v.servers.some((s) => s.running)) console.log(dim('No local model server is running here (Ollama, LM Studio, llama.cpp or MLX at their usual addresses).'));
896
+ for (const s of v.servers) {
897
+ console.log(`${s.label}${s.version ? dim(` ${s.version}`) : ''} ${dim(s.url)}${s.running ? '' : dim(' · not running')}`);
898
+ for (const m of s.models) console.log(` ${m.usable ? green('✓') : dim('✗')} ${m.id.padEnd(36)} ${[gb(m.sizeBytes), m.params, m.loaded ? 'in memory' : ''].filter(Boolean).join(' · ')}${m.notes.length ? dim(` ${m.notes.join('; ')}`) : ''}`);
899
+ if (s.running && !s.models.length) console.log(dim(' No model yet.'));
900
+ }
901
+ console.log(`Harnesses: ${v.harnesses.map((h) => (h.installed ? `${h.id === v.harness ? green(`${h.label} (--engine local)`) : h.label} ${dim(`--engine ${h.engine}`)}` : dim(`${h.label} not installed`))).join(' · ')}`);
902
+ console.log(dim(`Start an agent on one: agentmgr add "<task>" --engine local --model <server>/<model>${v.context ? ` · Ollama models get ${v.context} tokens of context` : ''}${v.default ? ` · default ${v.default}` : ''}`));
903
+ });
904
+
905
+ program
906
+ .command('lanes')
907
+ .description("Every agent's own ports and name ending, so dev servers and test databases of agents working side by side don't collide")
908
+ .option('--on', 'give each agent a lane (sessions started from now on)')
909
+ .option('--off', 'stop giving agents lanes')
910
+ .option('--port <on|off>', "also set PORT to the lane's first port in the agent's environment")
911
+ .option('--base <port>', 'the first port of the first lane')
912
+ .option('--size <ports>', 'how many ports a lane has')
913
+ .option('--json', 'print JSON')
914
+ .action(async (opts) => {
915
+ await daemon();
916
+ const patch = { ...(opts.on ? { enabled: true } : opts.off ? { enabled: false } : {}), ...(opts.port !== undefined ? { port: /^(on|true|yes|1)$/i.test(opts.port) } : {}), ...(opts.base !== undefined ? { base: opts.base } : {}), ...(opts.size !== undefined ? { size: opts.size } : {}) };
917
+ const v = Object.keys(patch).length ? await api('PUT', '/lanes', patch) : await api('GET', '/lanes');
918
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
919
+ console.log(`Lanes ${v.enabled ? green('on') : dim('off')}${v.enabled ? dim(` · ${v.size} port${v.size === 1 ? '' : 's'} each from ${v.base} · PORT ${v.port ? 'set' : 'not set'}`) : ''}`);
920
+ if (!v.enabled) return;
921
+ for (const a of v.agents) console.log(` ${String(a.n).padStart(3)} ${`${a.first}-${a.last}`.padEnd(12)} ${a.suffix.padEnd(6)} ${a.name}${a.running ? '' : dim(' (closed)')}`);
922
+ if (!v.agents.length) console.log(dim(' No agent has a lane yet: one is given when a session starts.'));
923
+ });
924
+
872
925
  program
873
926
  .command('usage')
874
927
  .description("Each engine's plan limits: how much is used and left, and when it resets")
@@ -1912,9 +1965,10 @@ export async function main(argv) {
1912
1965
  .description("Run the race's test command in every attempt's worktree")
1913
1966
  .argument('<race>')
1914
1967
  .option('-t, --test <command>', 'set or change the test command')
1968
+ .option('--runs <n>', 'run it this many times in each attempt (1 to 5), to tell a flaky test from a broken one; with 1, a failed run is run once more')
1915
1969
  .action(async (id, opts) => {
1916
1970
  await daemon();
1917
- await api('POST', `/races/${id}/tests`, opts.test ? { command: opts.test } : {});
1971
+ await api('POST', `/races/${id}/tests`, { ...(opts.test ? { command: opts.test } : {}), ...(opts.runs !== undefined ? { runs: Number(opts.runs) } : {}) });
1918
1972
  console.log(`${green('…')} running; see agentmgr race show ${id}`);
1919
1973
  });
1920
1974
  raceCmd
package/src/config.js CHANGED
@@ -80,6 +80,11 @@ const DEFAULTS = {
80
80
  // Usage: each engine's plan limits, used and left; warn at a percent, hold new work at a percent (usage.js).
81
81
  usage: { enabled: true, warnAt: 80, holdAt: null },
82
82
  calendar: { ics: [], workStart: '09:00', workEnd: '18:00' },
83
+ // Lanes: every agent's own range of ports and name ending; `port` also sets PORT to its first port (lanes.js).
84
+ lanes: { enabled: true, base: 21000, size: 10, port: true },
85
+ // Local models: servers on this computer (Ollama, LM Studio, llama.cpp, MLX) and their models, for the
86
+ // "Local model" engine; `context` is the room Ollama gives a model for an agent (localmodels.js).
87
+ localModels: { enabled: true, context: 32768 },
83
88
  // AI News: the frontier labs' latest releases, summarized; see NEWS_DEFAULTS in news.js for every field.
84
89
  news: { enabled: true },
85
90
  demoPage: false,
@@ -321,8 +321,8 @@ export default {
321
321
  * Mark the folder trusted in $CODEX_HOME/config.toml, the record Codex writes for
322
322
  * "Trust and continue". Appends a table only when the folder isn't listed yet.
323
323
  */
324
- trust(dir) {
325
- const file = path.join(home(), 'config.toml');
324
+ trust(dir, codexHome = home()) {
325
+ const file = path.join(codexHome, 'config.toml');
326
326
  const key = real(dir).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
327
327
  let raw = '';
328
328
  try {
@@ -333,7 +333,7 @@ export default {
333
333
  if (raw.includes(`[projects."${key}"]`)) return false;
334
334
  const backup = `${file}.agentmgr-backup`;
335
335
  if (raw && !fs.existsSync(backup)) fs.writeFileSync(backup, raw, { mode: 0o600 });
336
- fs.mkdirSync(home(), { recursive: true });
336
+ fs.mkdirSync(codexHome, { recursive: true });
337
337
  fs.appendFileSync(file, `${raw && !raw.endsWith('\n') ? '\n' : ''}\n[projects."${key}"]\ntrust_level = "trusted"\n`);
338
338
  return true;
339
339
  },
@@ -5,10 +5,12 @@ import path from 'node:path';
5
5
  import antigravity from './antigravity.js';
6
6
  import claude from './claude.js';
7
7
  import codex from './codex.js';
8
+ import { LOCAL_ENGINES } from './local.js';
9
+ import { localSettings } from '../localmodels.js';
8
10
  import muse from './muse.js';
9
11
  import { acpEngines } from './acp.js';
10
12
 
11
- export const ENGINES = { claude, codex, antigravity, muse };
13
+ export const ENGINES = { claude, codex, antigravity, muse, ...Object.fromEntries(LOCAL_ENGINES.map((e) => [e.id, e])) };
12
14
  export const DEFAULT_ENGINE = 'claude';
13
15
 
14
16
  /** Adds an engine from a plugin. Built-in engines can't be replaced. */
@@ -40,15 +42,25 @@ export function notInstalled(engine, config) {
40
42
  return `${engine.label} not found: ${where}. ${how}, then run \`agentmgr restart\`. If it's installed somewhere else, set its path in config.json${engine.id === 'claude' ? ' ("claudeBin") or AGENTMGR_CLAUDE_BIN' : ` ("engines": {"${engine.id}": {"bin": "…"}})`}.`;
41
43
  }
42
44
 
45
+ /**
46
+ * The engine "local" stands for: the harness config.json names ("localModels": { "harness": … })
47
+ * when it is installed, else the first installed of Codex, OpenCode and Claude Code.
48
+ */
49
+ export function localEngineId(config = {}) {
50
+ const have = LOCAL_ENGINES.filter((e) => installed(e, config));
51
+ return (have.find((e) => e.harness === localSettings(config).harness) ?? have[0] ?? LOCAL_ENGINES[0]).id;
52
+ }
53
+
43
54
  /** Every engine, with whether it can run here, for pickers and the hub. */
44
55
  export function listEngines(config) {
45
56
  return Object.values(ENGINES).map((e) => {
46
- const ok = installed(e, config);
57
+ // Some engines also need something running (a local model server).
58
+ const ok = installed(e, config) && (e.available?.(config) ?? true);
47
59
  let notice = null;
48
60
  try {
49
61
  notice = ok ? (e.notice?.(config) ?? null) : null;
50
62
  } catch {}
51
- return { id: e.id, label: e.label, installed: ok, permissionModes: e.permissionModes, supports: e.supports, notice };
63
+ return { id: e.id, label: e.label, installed: ok, ...(e.local ? { local: true, harness: e.harness } : {}), permissionModes: e.permissionModes, supports: e.supports, notice };
52
64
  });
53
65
  }
54
66