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.
- package/CHANGELOG.md +17 -0
- package/README.md +73 -1
- package/bin/local-run.js +86 -0
- package/package.json +1 -1
- package/public/app.js +61 -8
- package/public/board.js +177 -0
- package/public/boardcols.js +54 -0
- package/public/eval.js +2 -2
- package/public/index.html +9 -0
- package/public/keys.js +3 -2
- package/public/style.css +39 -0
- package/public/system.js +52 -4
- package/src/cli.js +57 -3
- package/src/config.js +5 -0
- package/src/engines/codex.js +3 -3
- package/src/engines/index.js +15 -3
- package/src/engines/local.js +156 -0
- package/src/eval.js +45 -8
- package/src/git.js +4 -2
- package/src/lanes.js +156 -0
- package/src/localmodels.js +260 -0
- package/src/manager.js +35 -4
- package/src/races.js +21 -12
- package/src/server.js +52 -6
- package/src/system.js +18 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.55.0 (2026-11-16)
|
|
4
|
+
|
|
5
|
+
- **Local models.** Agents can run on a model served from this computer: Ollama, LM Studio, llama.cpp or MLX. The app finds the servers on their usual ports and lists their models in **OS** and with `agentmgr models`, with a note on which an agent can use; a model that can't call tools is not offered. An agent's model names the server, say `ollama/qwen3-coder:30b`.
|
|
6
|
+
- **Three harnesses to choose from**, each an engine: **Local · Codex** (`local-codex`), **Local · OpenCode** (`local-opencode`) and **Local · Claude Code** (`local-claude`; Anthropic doesn't support Claude Code on other models, and the server has to speak Anthropic's API, which Ollama does). Each needs its own CLI installed. Sessions, resume and the inbox work as with the harness's own engine; nothing is costed, and summaries and reviews stay with your usual engine.
|
|
7
|
+
- **Room for an agent's context.** Ollama starts a model with a few thousand tokens of context, too little for an agent, so the app makes a copy of the model with more (32k by default; `agentmgr models --context`). Codex runs local models from a home of its own without your plugins and MCP servers, and Claude Code leaves MCP servers out, since those would fill a small context before the task starts. Your Codex sessions folder and AGENTS.md are still used.
|
|
8
|
+
- **Settings:** `agentmgr models --add name=address`, `--remove`, `--default`, `--harness`, `--on`, `--off`. Tried so far with a small model on Ollama only: a capable model (20 GB or more of memory) is what a real task needs.
|
|
9
|
+
- **Git:** the app's background `git status` no longer takes the index lock, which could make an agent's own `git add` or `git commit` fail with "index.lock: File exists" now and then.
|
|
10
|
+
|
|
11
|
+
## 1.54.0 (2026-11-15)
|
|
12
|
+
|
|
13
|
+
- **Repeat runs: flaky or broken.** One test run can pass or fail by chance, so the app's own test runs (the Eval's, and a race's) can be repeated on the same code. By default a run that passes is believed and a run that fails is run once more, which tells a flaky test from a broken one. **Runs** (1 to 5) beside the test command, in the Eval (kept for the project) or in a race (`agentmgr race test <race> --runs 3`), makes that many runs every time. Passed in some runs and failed in others is **flaky**: in the Eval it counts for part of the tests' weight, is listed as pending and keeps confidence under 100%, so nothing merges on it automatically; in a race the attempt shows `≈ flaky 2/3`. A failing test command now takes twice as long, since it is run again.
|
|
14
|
+
|
|
15
|
+
## 1.53.0 (2026-11-15)
|
|
16
|
+
|
|
17
|
+
- **Lanes: each agent's own ports.** Worktrees keep agents' files apart, but two dev servers still want the same port. Every agent now gets a range of ten ports (from 21000) and a name ending (`_a1`, `_a2`) no other agent has, in its environment (`AGENT_PORTS`, `AGENT_SUFFIX`, and `PORT` set to its first port) and in its instructions. A lane is given when a session next starts, stays across restarts, and is free again when the agent is deleted. **OS** has a **Ports** column with each open session's lane and what it listens on now; a port outside the lane is marked, and a click opens it in a browser tab. On by default; switches in OS, or `agentmgr lanes` (`--off`, `--port off` if your projects use `PORT` for something else, `--base`, `--size`). Not for agents in containers.
|
|
18
|
+
- **Board.** **Board** in the top bar (or `B`, `#board`): every agent as a card in the column for where its work stands: Starting, Working, Needs you, Waiting, In review, Done, Closed. Cards move by themselves. Drag one onto Closed to close its session, or from Closed onto Waiting to resume it; the Close and Resume buttons on the cards do the same.
|
|
19
|
+
|
|
3
20
|
## 1.52.0 (2026-11-14)
|
|
4
21
|
|
|
5
22
|
- **Lean output.** A switch in **Usage** (off by default; `agentmgr usage --lean on`): long command output (test runs, installs, builds) is trimmed before the agent reads it, so a plan's limits last longer. Colour codes and progress redraws go, runs of near-identical lines are folded, and of a long middle only the lines that look like errors or warnings stay. The start and end are kept, and the whole output is saved to a file the agent is told about and can read. Usage shows how many outputs were trimmed and about how many tokens were not read. Claude Code only, for sessions started after you switch it on.
|
package/README.md
CHANGED
|
@@ -34,6 +34,9 @@ Run one background [Claude Code](https://claude.com/claude-code) agent per inten
|
|
|
34
34
|
- **Reverse engineer.** Name a target (an app's folder, a binary, a website) and what you want to understand, in the **Reverse** tab beside an agent's session: the agent investigates with [REA](https://github.com/morluto/rea)'s tools and keeps a report with animated diagrams of how it works, the evidence, what could not be determined, and a plan to build your own version.
|
|
35
35
|
- **Security audit.** **🛡 Security audit** in an agent's detail (or the **Security** tab of the split, or `agentmgr audit`) has the agent audit the code in its session: it maps where untrusted input comes in, follows it through the code, runs the project's own dependency audit, and checks every finding a second time before listing it. The report beside the session has the attack surface as an animated diagram, findings by severity with evidence and a fix, what was checked and found sound, and what was not covered. It changes no code until you press **Fix findings**. It finds what a careful reader finds; it does not replace a penetration test.
|
|
36
36
|
- **Skills.** **Skills…** in the menu (or `agentmgr skills`) lists the Agent Skills Claude Code has here, yours and each project's, with which agents used them. Add more from a git repository (`anthropics/skills`, or any https address): you see what it offers first, with each skill's scripts flagged, then pick. A skill added here remembers its repository and commit, so **Check** says when a newer version is there and **Update** brings it; one you edited says so.
|
|
37
|
+
- **Board.** **Board** in the top bar (or `B`, `#board`): every agent as a card in the column for where its work stands: starting, working, needs you, waiting, in review, done, closed. Cards move by themselves; drag one onto **Closed** to close its session, or from Closed onto **Waiting** to resume it.
|
|
38
|
+
- **Lanes.** Every agent gets a range of ports and a name ending no other agent has, in its environment and its instructions, so dev servers and test databases of agents working side by side don't collide. **OS** shows what each open session listens on (`agentmgr lanes`).
|
|
39
|
+
- **Local models.** Models served on this computer by Ollama, LM Studio, llama.cpp or MLX are found by themselves, and an agent can run on one, with the Codex CLI, OpenCode or Claude Code as the harness: no plan, no limits, nothing leaves the machine (`agentmgr models`).
|
|
37
40
|
- **Lean output.** A switch in **Usage** (off by default; `agentmgr usage --lean on`): long command output (test runs, installs, builds) is trimmed before the agent reads it, so a plan's limits last longer. Colours and progress redraws go, runs of near-identical lines are folded, and of a long middle only the lines that look like errors or warnings stay; the start and end are kept, and the whole output is saved to a file the agent can read. Claude Code only, for sessions started after you switch it on. Usage shows how much was trimmed.
|
|
38
41
|
- **Runbooks for support.** A runbook for the support team written from a release ticket, every ticket of an epic, or a project's code changes in a time frame: what changed, what customers may see, how to check it, troubleshooting, rollback, when to escalate, and what to confirm with engineering.
|
|
39
42
|
- **Decide.** Help with the decisions, not only the tasks: a plan to review or an agent's question arrives with its options, the one recommended, why, and the risk; calls you keep making become standing decisions that are handled for you and reported; the backlog is ranked by impact; a date at risk is laid out as choices; and past decisions are looked back on.
|
|
@@ -200,6 +203,8 @@ agentmgr decisions [project] [--md] # the decision log; --add "<questi
|
|
|
200
203
|
agentmgr debt <project> --scan # the tech debt radar: files that change often and are hard to read
|
|
201
204
|
agentmgr audit <agent> --start # security audit in its session (a scope in words, --fix "1 and 3"; no arguments: the report)
|
|
202
205
|
agentmgr skills # Claude Code's skills here (look <repo>, add <repo> <names...>, check|update|rm <id>)
|
|
206
|
+
agentmgr lanes # every agent's own ports and name ending (--off, --port off, --base, --size)
|
|
207
|
+
agentmgr models # models served on this computer (Ollama, LM Studio, llama.cpp, MLX), for --engine local
|
|
203
208
|
agentmgr usage # each engine's plan limits: used, left, resets (--now, --lean on, --warn 80, --hold 95, --default codex)
|
|
204
209
|
agentmgr runbook --ticket REL-42 # a support runbook from a release ticket (or --epic KEY, or --since 2026-10-01 -p <project>; -o file.md)
|
|
205
210
|
agentmgr decide # what waits for your decision, with its recommendation (--do <n>, --handled, --standing, --autonomy p=level, --priority, --risk)
|
|
@@ -752,12 +757,22 @@ Either way, the roles hand off through Markdown files in the team's folder (`~/.
|
|
|
752
757
|
|
|
753
758
|
- **Status and outcome**, from each agent's brief, plus its checks
|
|
754
759
|
- **Change**: files and lines added and removed, with the smallest marked
|
|
755
|
-
- **Tests**: the race's test command, run in every attempt's worktree two at a time (15-minute limit each)
|
|
760
|
+
- **Tests**: the race's test command, run in every attempt's worktree two at a time (15-minute limit each). **Runs** beside the command (or `agentmgr race test <race> --runs 3`) runs it up to five times in each attempt; an attempt that passes some runs and fails others shows as **flaky**
|
|
756
761
|
- **Cost and time**
|
|
757
762
|
- **Diff**: each attempt's full changes against where it started
|
|
758
763
|
|
|
759
764
|
**Pick** marks the winner and can close and delete the other attempts, worktrees included.
|
|
760
765
|
|
|
766
|
+
### Repeat runs: flaky or broken
|
|
767
|
+
|
|
768
|
+
One test run can pass or fail by chance, so the app's own test runs can be repeated on the same code. This holds for a race's tests and for the **Eval** of an agent on a Jira issue (the tests the app runs again itself when the agent says it is done).
|
|
769
|
+
|
|
770
|
+
- **Once (the default)**: a run that passes is believed. A run that fails is run once more, which tells a flaky test (failed, then passed) from a broken one (failed twice). A run that timed out is not repeated.
|
|
771
|
+
- **More than once**: set **Runs** (2 to 5) beside the test command, in the race or in the Eval; for the Eval it is kept for the project. Every run is made, whatever the first says.
|
|
772
|
+
- **Flaky** means it passed some runs and failed others. In the Eval that counts for part of the tests' weight, is listed as pending, and keeps the confidence under 100%, so nothing is merged on it automatically. The output shown is a failed run's.
|
|
773
|
+
|
|
774
|
+
Repeating costs test time, not AI usage.
|
|
775
|
+
|
|
761
776
|
## Slack alerts
|
|
762
777
|
|
|
763
778
|
**Three ways to connect Slack:**
|
|
@@ -839,6 +854,27 @@ Google's **Antigravity CLI** (`agy`, signed in with your Google account) works t
|
|
|
839
854
|
|
|
840
855
|
Meta's **Muse Code** (`muse`, installed with `curl -fsSL https://dev.meta.ai/install.sh | bash` and signed in with `muse login`) works the same way: `--engine muse`. AI Agent Manager adopts the session Muse starts, resumes it with `muse resume` (a message for a resumed session is typed once Muse is idle), trusts the agent's folder for each run with `--trust-workspace` instead of saving it, reads the conversation and token usage from Muse's session log, shows its trust and approval questions in the inbox, stops it cleanly with SIGTERM, and runs Explain with `muse exec` in the read-only profile. Commands and edits aren't read from its log yet, so stuck detection has less to go on for Muse agents. When Muse runs in contributor mode (an account without a plan), the engine picker says so: Meta may use your code and conversations to improve its products. `engines.muse.bin` points at another binary, and `engines.muse.args` adds arguments to every run.
|
|
841
856
|
|
|
857
|
+
## Local models: Ollama, LM Studio, llama.cpp, MLX
|
|
858
|
+
|
|
859
|
+
An agent can run on a model served on this computer instead of a provider's: no plan, no limits, and nothing leaves the machine. AI Agent Manager finds the model servers running here by asking their usual addresses, and runs the model in a harness you choose, pointed at the local server:
|
|
860
|
+
|
|
861
|
+
| Harness | Engine | Notes |
|
|
862
|
+
|---|---|---|
|
|
863
|
+
| **Codex CLI** (open source; `npm i -g @openai/codex`, no sign-in needed for this) | `local-codex` | The default. A small first message, so it suits small contexts. |
|
|
864
|
+
| **OpenCode** (open source; `npm i -g opencode-ai`) | `local-opencode` | Made for many providers. Runs over ACP, so the app reads less from it (no token counts). |
|
|
865
|
+
| **Claude Code** | `local-claude` | Everything the app does for Claude Code agents, but Anthropic doesn't support Claude Code on other models: expect rough edges. The server has to speak Anthropic's API, which Ollama does. |
|
|
866
|
+
|
|
867
|
+
`--engine local` is the harness set with `agentmgr models --harness codex|opencode|claude`, or else the first of those three that is installed.
|
|
868
|
+
|
|
869
|
+
- **What is found.** Ollama (port 11434), LM Studio (1234), and llama.cpp's `llama-server` or MLX's `mlx_lm.server` (8080), plus any server that speaks the OpenAI API at an address you add: `agentmgr models --add mlx=http://127.0.0.1:8081`. **OS** lists each server's models with their size and whether an agent can use them, as does `agentmgr models`. A model that can't call tools is listed but can't be chosen: an agent needs tools to read and change files. Embedding models are left out.
|
|
870
|
+
- **Starting an agent on one.** Choose **Local · Codex**, **Local · OpenCode** or **Local · Claude Code** as the engine in New agent or Ask Agent (each offered while its harness is installed and a server with a usable model is running) and pick the model, or `agentmgr add --engine local --model ollama/qwen3-coder:30b "…"`. A model is written `<server>/<model>`. `agentmgr models --default <model>` sets the one used when none is given.
|
|
871
|
+
- **Everything else is the harness's own engine**: worktrees and lanes, the brief, the inbox with the harness's approval menus, stuck detection, stop and resume. Summaries and reviews (Explain, Review with AI) stay with your usual engine, no cost is counted, and the Usage window leaves local engines out: there is no plan to show. Claude Code is started without MCP servers, whose tool lists would take much of a local model's context. Not in containers yet.
|
|
872
|
+
- **Context on Ollama.** Ollama starts a model with a few thousand tokens of context whatever the model can take, which is less than a coding agent's first message. So the first time an agent starts on an Ollama model, a copy of it with room for 32,768 tokens is made (`gpt-oss:20b` becomes `gpt-oss-am32k:20b` in `ollama list`; the weights are shared, so it takes no disk space). `agentmgr models --context <tokens>` changes the room, and `--context 0` leaves Ollama's own setting alone. Other servers keep the context they were started with: give LM Studio, llama.cpp or MLX at least 16,000 tokens.
|
|
873
|
+
- **A Codex home of its own.** Local Codex agents run Codex from `~/.agentmanager/codex-local`, not your `~/.codex`: your Codex plugins and MCP servers would fill a local model's context before the task starts. Your `AGENTS.md` is still used, and sessions are kept with your other Codex sessions.
|
|
874
|
+
- **What to expect.** A local model is much weaker than Claude or GPT at work of many steps, and slower. On a Mac with 24 GB of memory, a model of about 20 billion parameters is the practical ceiling, one agent at a time. Small models (under 7 billion parameters) are marked: they answer a question but rarely finish a task.
|
|
875
|
+
|
|
876
|
+
`"localModels": { "enabled": false }` in config.json (or `agentmgr models --off`) stops the lookups. `agentmgr models --remove <name>` stops asking one server.
|
|
877
|
+
|
|
842
878
|
## Agents in containers
|
|
843
879
|
|
|
844
880
|
For isolation, an agent can run in its own Docker container: it sees only its own folder (mounted at the same path), its repository's git data, its brief and its uploads, and nothing else on the computer. Everything else works as usual: sessions, resume, tracking and usage, the inbox, **Open shell** (which opens inside the container), stop and restart.
|
|
@@ -1311,6 +1347,42 @@ Turn it all off with `"decide": { "enabled": false }` in config.json.
|
|
|
1311
1347
|
- **Agent sessions**: each open session with the processor and memory it takes, counting everything it started (Claude Code, the tools and tests it runs). Click a name to open the agent.
|
|
1312
1348
|
- **Busiest processes**: the top of everything running on the computer.
|
|
1313
1349
|
|
|
1350
|
+
### Lanes: each agent's own ports
|
|
1351
|
+
|
|
1352
|
+
Worktrees keep agents' files apart, but two dev servers still want port 3000 and two test runs the same database. So every agent gets a **lane**: a range of ports (ten, from 21000: the first agent has 21000–21009, the next 21010–21019) and a name ending (`_a1`, `_a2`) that no other agent has. A lane is given when an agent's session first starts, stays with the agent across restarts, and is free for a new agent once the agent is deleted.
|
|
1353
|
+
|
|
1354
|
+
- **In its environment**: `AGENT_PORTS` (`21010-21019`), `AGENT_PORT` and `AGENT_PORT_END` (first and last), `AGENT_LANE` (its number), `AGENT_SUFFIX` (`_a2`), and `PORT` set to its first port, which many dev servers listen on by themselves. The shells you open in its folder get the same.
|
|
1355
|
+
- **In its instructions**: to use its own ports for anything it starts that listens, to leave what holds a port outside them alone, and to end the names of things it creates outside its folder (a database, a container, a compose project) with its ending.
|
|
1356
|
+
- **In OS**: the **Ports** column of Agent sessions shows each open session's lane and what it listens on now, read from the system (`lsof`, or `ss` on Linux). Click a port to open it in a browser tab beside the session. A port outside the lane is marked, and so is a port of the lane that something else holds.
|
|
1357
|
+
- **In an agent's detail**: **Lane** under Workspace.
|
|
1358
|
+
|
|
1359
|
+
The switches are under Agent sessions in OS: **A lane of ports for each agent**, and **Set PORT to its first port** (turn it off if your projects use `PORT` for something else). A change reaches a session the next time it starts. From the command line:
|
|
1360
|
+
|
|
1361
|
+
```sh
|
|
1362
|
+
agentmgr lanes # the settings, and every agent's lane
|
|
1363
|
+
agentmgr lanes --off # no lanes (--on brings them back)
|
|
1364
|
+
agentmgr lanes --port off # keep the lanes, leave PORT alone
|
|
1365
|
+
agentmgr lanes --base 30000 --size 20
|
|
1366
|
+
```
|
|
1367
|
+
|
|
1368
|
+
Lanes are a convention the agent is told and given, not a wall: nothing stops a tool that ignores `PORT` from taking 3000. That is what the Ports column is for. Agents in containers get no lane; a container has its own ports.
|
|
1369
|
+
|
|
1370
|
+
## Board
|
|
1371
|
+
|
|
1372
|
+
**Board** in the top bar (or `B`, or `#board`) shows every agent as a card, in the column for where its work stands:
|
|
1373
|
+
|
|
1374
|
+
| Column | An agent is here when |
|
|
1375
|
+
| --- | --- |
|
|
1376
|
+
| Starting | its workspace is being prepared, or it is planning |
|
|
1377
|
+
| Working | it is producing output now |
|
|
1378
|
+
| Needs you | a prompt, an open question, a plan to approve, a usage limit, an error, or it may be stuck. This comes before every other column |
|
|
1379
|
+
| Waiting | its session is open and waits for its next instruction |
|
|
1380
|
+
| In review | it has an open pull request (the card says ready to merge, needs fixes, behind, checks running or draft) |
|
|
1381
|
+
| Done | its pull request merged, or it reported its work done |
|
|
1382
|
+
| Closed | its session is closed and can be resumed |
|
|
1383
|
+
|
|
1384
|
+
Cards are ordered by priority, then the most recently active. A card moves by itself as its agent's work moves; the columns are not something you set. Two drags do something: a card onto **Closed** closes its session (not while it is working), and a card from Closed onto **Waiting** resumes it; the **Close** and **Resume** buttons on the cards do the same. Any other drop says why nothing moved. Click a card to open its agent. With more than one project, a list at the top narrows the board to one.
|
|
1385
|
+
|
|
1314
1386
|
It reads again every 3 seconds while open, with `ps` and the system's own counters; nothing leaves the computer.
|
|
1315
1387
|
|
|
1316
1388
|
Above the agent list, **N running** is a filter: click it to list only the agents whose session is open, and again to list them all.
|
package/bin/local-run.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Starts a harness (the Codex CLI, Claude Code or OpenCode) on a model served on this computer
|
|
3
|
+
// (engines/local.js):
|
|
4
|
+
// local-run.js --harness <codex|claude|opencode> --url <server> --model <name> --context <tokens> -- <command> [arguments]
|
|
5
|
+
// It checks that the server answers and has the model, and tells the harness to talk to it. Ollama
|
|
6
|
+
// starts a model with little context whatever the model can take, so for Ollama it first makes a
|
|
7
|
+
// copy of the model with room for an agent (a few lines in Ollama's list; the weights are shared).
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { variantName } from '../src/localmodels.js';
|
|
10
|
+
|
|
11
|
+
const argv = process.argv.slice(2);
|
|
12
|
+
const split = argv.indexOf('--');
|
|
13
|
+
const opt = {};
|
|
14
|
+
for (let i = 0; i < split; i += 2) opt[argv[i].replace(/^--/, '')] = argv[i + 1];
|
|
15
|
+
const [bin, ...rest] = argv.slice(split + 1);
|
|
16
|
+
const url = String(opt.url ?? '').replace(/\/+$/, '');
|
|
17
|
+
const context = Number(opt.context) || 0;
|
|
18
|
+
|
|
19
|
+
const say = (m) => process.stderr.write(`\x1b[2m[agentmgr] ${m}\x1b[0m\r\n`);
|
|
20
|
+
const stop = (m) => {
|
|
21
|
+
process.stderr.write(`[agentmgr] ${m}\r\n`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
};
|
|
24
|
+
async function call(path, body, timeoutMs = 5000) {
|
|
25
|
+
try {
|
|
26
|
+
const res = await fetch(`${url}${path}`, { signal: AbortSignal.timeout(timeoutMs), ...(body ? { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) } : {}) });
|
|
27
|
+
const text = await res.text();
|
|
28
|
+
let json = null;
|
|
29
|
+
try {
|
|
30
|
+
json = JSON.parse(text);
|
|
31
|
+
} catch {}
|
|
32
|
+
return { ok: res.ok, json, text };
|
|
33
|
+
} catch (err) {
|
|
34
|
+
return { ok: false, json: null, text: err.message };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (split < 0 || !bin || !url || !opt.model) stop('local-run: --url, --model and a command after "--" are needed');
|
|
39
|
+
|
|
40
|
+
let model = opt.model;
|
|
41
|
+
let window = null;
|
|
42
|
+
const tags = await call('/api/tags');
|
|
43
|
+
if (Array.isArray(tags.json?.models)) {
|
|
44
|
+
// Ollama.
|
|
45
|
+
const mine = tags.json.models.find((m) => m.name === model || m.name === `${model}:latest`);
|
|
46
|
+
if (!mine) stop(`Ollama has no model "${model}". Get it with: ollama pull ${model}`);
|
|
47
|
+
if (context > 0) {
|
|
48
|
+
const most = Number(mine.details?.context_length) || context;
|
|
49
|
+
window = Math.min(context, most);
|
|
50
|
+
const copy = variantName(model, window);
|
|
51
|
+
if (!tags.json.models.some((m) => m.name === copy)) {
|
|
52
|
+
say(`Giving ${model} room for ${window} tokens (as ${copy})…`);
|
|
53
|
+
const made = await call('/api/create', { model: copy, from: mine.name, parameters: { num_ctx: window }, stream: false }, 60_000);
|
|
54
|
+
if (!made.ok || made.json?.error) stop(`Ollama couldn't make ${copy}: ${made.json?.error ?? made.text}`);
|
|
55
|
+
}
|
|
56
|
+
model = copy;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
const list = await call('/v1/models');
|
|
60
|
+
if (!Array.isArray(list.json?.data)) stop(`No model server answers at ${url}. Start it, then start this agent again.`);
|
|
61
|
+
// llama.cpp says how much context it was started with.
|
|
62
|
+
window = Number((await call('/props')).json?.default_generation_settings?.n_ctx) || null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const env = { ...process.env };
|
|
66
|
+
let args = rest;
|
|
67
|
+
if (opt.harness === 'claude') {
|
|
68
|
+
// Claude Code, talking to the server's Anthropic-style API; every role it has a model for gets this one
|
|
69
|
+
// (named in its environment: its command may be more than one word, so no argument is added here).
|
|
70
|
+
Object.assign(env, { ANTHROPIC_BASE_URL: url, ANTHROPIC_MODEL: model, ANTHROPIC_AUTH_TOKEN: 'local', ANTHROPIC_API_KEY: '', ANTHROPIC_SMALL_FAST_MODEL: model, ANTHROPIC_DEFAULT_HAIKU_MODEL: model, ANTHROPIC_DEFAULT_SONNET_MODEL: model, ANTHROPIC_DEFAULT_OPUS_MODEL: model, CLAUDE_CODE_SUBAGENT_MODEL: model, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1' });
|
|
71
|
+
delete env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
72
|
+
// It takes the context for a Claude model's 200,000 tokens: summarize before this one's is full.
|
|
73
|
+
if (window) env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE = String(Math.max(1, Math.min(90, Math.floor((window * 0.75 * 100) / 200_000))));
|
|
74
|
+
} else if (opt.harness === 'opencode') {
|
|
75
|
+
// OpenCode, given the server as a provider of its own for this run.
|
|
76
|
+
const limit = window ? { limit: { context: window, output: Math.min(8192, Math.floor(window / 4)) } } : {};
|
|
77
|
+
env.OPENCODE_CONFIG_CONTENT = JSON.stringify({ $schema: 'https://opencode.ai/config.json', provider: { agentmgr: { npm: '@ai-sdk/openai-compatible', name: 'Local', options: { baseURL: `${url}/v1` }, models: { [model]: { name: opt.model, ...limit } } } }, model: `agentmgr/${model}`, small_model: `agentmgr/${model}` });
|
|
78
|
+
} else {
|
|
79
|
+
// Codex, with the server as its model provider. It takes options after `resume`.
|
|
80
|
+
const flags = ['-c', `model_providers.agentmgr={name="Local",base_url="${url}/v1"}`, '-c', 'model_provider="agentmgr"', ...(window ? ['-c', `model_context_window=${window}`] : []), '--model', model];
|
|
81
|
+
args = rest[0] === 'resume' ? ['resume', ...flags, ...rest.slice(1)] : [...flags, ...rest];
|
|
82
|
+
}
|
|
83
|
+
const child = spawn(bin, args, { stdio: 'inherit', env });
|
|
84
|
+
for (const sig of ['SIGHUP', 'SIGINT', 'SIGTERM']) process.on(sig, () => child.kill(sig));
|
|
85
|
+
child.on('error', (err) => stop(`Couldn't start ${bin}: ${err.message}`));
|
|
86
|
+
child.on('exit', (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -44,6 +44,7 @@ import { initSystem } from '/system.js';
|
|
|
44
44
|
import { adviceHtml, initDecide } from '/decide.js';
|
|
45
45
|
import { initUsage } from '/usage.js';
|
|
46
46
|
import { initSkills } from '/skills.js';
|
|
47
|
+
import { initBoard } from '/board.js';
|
|
47
48
|
import { initMcp } from '/mcp.js';
|
|
48
49
|
import { initCodeMap } from '/codemap.js';
|
|
49
50
|
import { initKeys } from '/keys.js';
|
|
@@ -76,19 +77,21 @@ const newsOnLoad = hashId === 'news';
|
|
|
76
77
|
// "#plan" or "#plan/<dates|decisions|debt>".
|
|
77
78
|
const planOnLoad = hashId === 'plan';
|
|
78
79
|
const osOnLoad = hashId === 'os';
|
|
80
|
+
const boardOnLoad = hashId === 'board';
|
|
79
81
|
// "#decide" or "#decide/<waiting|handled|standing|priority|tradeoffs|lookback>".
|
|
80
82
|
const decideOnLoad = hashId === 'decide';
|
|
81
83
|
const reviewsOnLoad = hashId === 'reviews';
|
|
82
84
|
// "#mcp" or "#mcp/<agent>": the MCP window on its own.
|
|
83
85
|
const mcpOnLoad = hashId === 'mcp';
|
|
84
86
|
let watchShown = false;
|
|
85
|
-
let selectedId = (watchOnLoad || standupOnLoad || mapOnLoad || valueOnLoad || newsOnLoad || planOnLoad || osOnLoad || decideOnLoad || reviewsOnLoad || mcpOnLoad ? null : hashId) || null;
|
|
87
|
+
let selectedId = (watchOnLoad || standupOnLoad || mapOnLoad || valueOnLoad || newsOnLoad || planOnLoad || osOnLoad || boardOnLoad || decideOnLoad || reviewsOnLoad || mcpOnLoad ? null : hashId) || null;
|
|
86
88
|
let openTermOnLoad = hashView === 'term' || hashView === 'code' || isShell(hashView) || isBrowser(hashView);
|
|
87
89
|
let filterText = '';
|
|
88
90
|
// Only agents whose session is open (the "running" count above the list, clicked).
|
|
89
91
|
let listRunning = false;
|
|
90
92
|
// Decide: the recommendations shown on inbox cards come from it (set once the page is wired).
|
|
91
93
|
let decideUi = null;
|
|
94
|
+
let boardUi = null;
|
|
92
95
|
// "Only agents created in the last N days": remembered in this browser.
|
|
93
96
|
const recent = (() => {
|
|
94
97
|
try {
|
|
@@ -336,8 +339,11 @@ const planUi = initPlan({
|
|
|
336
339
|
});
|
|
337
340
|
$('#plan-btn').onclick = () => planUi.open();
|
|
338
341
|
// OS: this computer and its load right now.
|
|
339
|
-
const osUi = initSystem({ api, $, esc, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)) });
|
|
342
|
+
const osUi = initSystem({ api, $, esc, toast: (m, ms) => toast(m, ms), openAgent: (id) => (showTab('agents'), select(id)), openPort: (id, port) => openPort(id, port) });
|
|
340
343
|
$('#os-btn').onclick = () => osUi.open();
|
|
344
|
+
// Board: every agent as a card in the column for where its work stands.
|
|
345
|
+
boardUi = initBoard({ api, $, esc, ago, toast: (m, ms) => toast(m, ms), agents: () => agents, openAgent: (id) => (showTab('agents'), select(id)), upsert: (a) => upsert(a) });
|
|
346
|
+
$('#board-btn').onclick = () => boardUi.open();
|
|
341
347
|
// Decide: recommendations on what waits for you, standing decisions, impact, trade-offs, looking back.
|
|
342
348
|
decideUi = initDecide({
|
|
343
349
|
api,
|
|
@@ -413,6 +419,7 @@ function shortcut(act) {
|
|
|
413
419
|
if (act === 'news') return newsUi.open();
|
|
414
420
|
if (act === 'plan') return planUi.open();
|
|
415
421
|
if (act === 'os') return osUi.open();
|
|
422
|
+
if (act === 'board') return boardUi.open();
|
|
416
423
|
if (act === 'decide') return decideUi.open();
|
|
417
424
|
if (act === 'usage') return usageUi.open();
|
|
418
425
|
if (act === 'skills') return skillsUi.open();
|
|
@@ -811,9 +818,9 @@ $('#doc-body').addEventListener('submit', (e) => {
|
|
|
811
818
|
e.preventDefault();
|
|
812
819
|
const id = docView.agentId;
|
|
813
820
|
act(async () => {
|
|
814
|
-
const r = await api('PUT', `/agents/${id}/eval/command`, { command: f.command.value });
|
|
821
|
+
const r = await api('PUT', `/agents/${id}/eval/command`, { command: f.command.value, runs: Number(f.runs.value) || 1 });
|
|
815
822
|
await api('POST', `/agents/${id}/eval/verify`);
|
|
816
|
-
toast(r.testCommand ? `Saved; running ${r.testCommand}` : 'Saved', 4000);
|
|
823
|
+
toast(r.testCommand ? `Saved; running ${r.testCommand}${r.testRuns > 1 ? ` ${r.testRuns} times` : ''}` : 'Saved', 4000);
|
|
817
824
|
});
|
|
818
825
|
});
|
|
819
826
|
|
|
@@ -2181,7 +2188,7 @@ function openRace(id) {
|
|
|
2181
2188
|
|
|
2182
2189
|
const fmtCost = (c) => (c ? `$${c.toFixed(2)}` : '—');
|
|
2183
2190
|
const testCell = (t) =>
|
|
2184
|
-
!t ? '<span class="hint">—</span>' : `<span class="test ${t.status}" title="${esc(t.output ?? '')}">${{ passed: '✓ passed', failed: '✗ failed', running: '… running', queued: 'queued', error: '⚠ error' }[t.status] ?? t.status}${t.seconds != null ? ` <span class="hint">${t.seconds}s</span>` : ''}</span>`;
|
|
2191
|
+
!t ? '<span class="hint">—</span>' : `<span class="test ${t.status}" title="${esc(t.output ?? '')}">${{ passed: t.runs > 1 ? `✓ passed ${t.runs}×` : '✓ passed', failed: t.runs > 1 ? `✗ failed ${t.runs}×` : '✗ failed', flaky: `≈ flaky ${t.passes}/${t.runs}`, running: '… running', queued: 'queued', error: '⚠ error' }[t.status] ?? t.status}${t.seconds != null ? ` <span class="hint">${t.seconds}s</span>` : ''}</span>`;
|
|
2185
2192
|
|
|
2186
2193
|
function renderRace() {
|
|
2187
2194
|
const dlg = $('#race-dialog');
|
|
@@ -2191,7 +2198,7 @@ function renderRace() {
|
|
|
2191
2198
|
$('#race-body').innerHTML = '<p class="hint">Loading…</p>';
|
|
2192
2199
|
return;
|
|
2193
2200
|
}
|
|
2194
|
-
if ($('#race-body').contains(document.activeElement) && document.activeElement.name
|
|
2201
|
+
if ($('#race-body').contains(document.activeElement) && ['testCommand', 'testRuns'].includes(document.activeElement.name)) return;
|
|
2195
2202
|
$('#race-title').textContent = `Race: ${r.intent.split('\n')[0].slice(0, 80)}`;
|
|
2196
2203
|
// Tag a row only when it is strictly the best of several.
|
|
2197
2204
|
const uniqueMin = (vals) => {
|
|
@@ -2204,6 +2211,7 @@ function renderRace() {
|
|
|
2204
2211
|
$('#race-body').innerHTML = `
|
|
2205
2212
|
<form class="race-tests" id="race-tests">
|
|
2206
2213
|
<label>Test command <input name="testCommand" value="${esc(r.testCommand ?? '')}" placeholder="npm test" /></label>
|
|
2214
|
+
<label title="How many times it is run in each attempt. 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="testRuns" type="number" min="1" max="5" value="${r.testRuns ?? 1}" /></label>
|
|
2207
2215
|
<button class="small primary">Run in every attempt</button>
|
|
2208
2216
|
</form>
|
|
2209
2217
|
<div class="race-table-wrap"><table class="race-table">
|
|
@@ -2262,8 +2270,8 @@ $('#race-delete').onclick = () => {
|
|
|
2262
2270
|
};
|
|
2263
2271
|
$('#race-body').addEventListener('submit', (e) => {
|
|
2264
2272
|
e.preventDefault();
|
|
2265
|
-
const
|
|
2266
|
-
act(async () => races.set(openRaceId, await api('POST', `/races/${openRaceId}/tests`, { command })), 'Running tests');
|
|
2273
|
+
const f = new FormData(e.target);
|
|
2274
|
+
act(async () => races.set(openRaceId, await api('POST', `/races/${openRaceId}/tests`, { command: f.get('testCommand'), runs: Number(f.get('testRuns')) || 1 })), 'Running tests');
|
|
2267
2275
|
});
|
|
2268
2276
|
$('#race-body').addEventListener('click', (e) => {
|
|
2269
2277
|
const t = e.target;
|
|
@@ -2455,6 +2463,7 @@ function renderDetail() {
|
|
|
2455
2463
|
<dt>Head</dt><dd>${a.git?.head ? `<code>${esc(a.git.head.sha)}</code> ${esc(a.git.head.subject)}` : '—'}</dd>
|
|
2456
2464
|
${a.baseRef ? `<dt>Branched from</dt><dd><code>${esc(a.baseRef)}</code></dd>` : ''}
|
|
2457
2465
|
${a.worktree ? `<dt>Worktree of</dt><dd><code>${esc(a.sourceDir)}</code></dd>` : ''}
|
|
2466
|
+
${a.laneInfo ? `<dt title="Its own ports and name ending, in its environment and instructions, so what it starts doesn't collide with another agent's. What it listens on now is in OS">Lane</dt><dd>ports <code>${a.laneInfo.first}–${a.laneInfo.last}</code> · names end with <code>${esc(a.laneInfo.suffix)}</code></dd>` : ''}
|
|
2458
2467
|
${noRepo(a) ? '' : `<dt>Repo memory</dt><dd><button class="link" data-act="memory" title="What agents learned working in this repo; every agent here gets it">View and edit</button></dd>`}
|
|
2459
2468
|
</dl>
|
|
2460
2469
|
</div>
|
|
@@ -2566,6 +2575,7 @@ const perf = {
|
|
|
2566
2575
|
on: new URLSearchParams(location.search).has('perf'),
|
|
2567
2576
|
runs: [], // [at, ms, { view: ms }] over the last 5 seconds
|
|
2568
2577
|
draw(views) {
|
|
2578
|
+
boardUi?.refresh();
|
|
2569
2579
|
if (!this.on) {
|
|
2570
2580
|
for (const v of views) VIEWS[v]();
|
|
2571
2581
|
return;
|
|
@@ -3118,6 +3128,16 @@ const browserLabel = (url) => {
|
|
|
3118
3128
|
const u = new URL(url);
|
|
3119
3129
|
return u.host + (u.pathname === '/' ? '' : u.pathname);
|
|
3120
3130
|
};
|
|
3131
|
+
/** What an agent listens on, in a browser tab beside its session. */
|
|
3132
|
+
async function openPort(id, port) {
|
|
3133
|
+
showTab('agents');
|
|
3134
|
+
select(id);
|
|
3135
|
+
await act(async () => {
|
|
3136
|
+
const tab = await api('POST', `/agents/${id}/browsers`, { url: `localhost:${port}`, mode: liveAvailable ? 'live' : 'lite' });
|
|
3137
|
+
upsertBrowsers(id, tab.n, tab.url, tab.mode);
|
|
3138
|
+
term.open(id, `browser:${tab.n}`);
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3121
3141
|
async function openAddress(url) {
|
|
3122
3142
|
const id = term.agentId;
|
|
3123
3143
|
if (!id || !url.trim()) return;
|
|
@@ -4430,6 +4450,7 @@ $('#ask-form').addEventListener('submit', async (e) => {
|
|
|
4430
4450
|
question: String(f.get('question') || '').trim() || undefined,
|
|
4431
4451
|
name: String(f.get('name') || '').trim() || undefined,
|
|
4432
4452
|
engine: f.get('engine') || undefined,
|
|
4453
|
+
model: (String(f.get('engine') || '').startsWith('local-') && String(f.get('model') || '').trim()) || undefined,
|
|
4433
4454
|
attachments: askFiles.paths().length ? askFiles.paths() : undefined,
|
|
4434
4455
|
});
|
|
4435
4456
|
agents.set(a.id, a);
|
|
@@ -4511,6 +4532,11 @@ function handleEvent(msg) {
|
|
|
4511
4532
|
history.replaceState(null, '', '#');
|
|
4512
4533
|
osUi.open();
|
|
4513
4534
|
}
|
|
4535
|
+
if (boardOnLoad && !watchShown) {
|
|
4536
|
+
watchShown = true;
|
|
4537
|
+
history.replaceState(null, '', '#');
|
|
4538
|
+
boardUi.open();
|
|
4539
|
+
}
|
|
4514
4540
|
if (newsOnLoad && !watchShown) {
|
|
4515
4541
|
watchShown = true;
|
|
4516
4542
|
history.replaceState(null, '', '#');
|
|
@@ -5165,10 +5191,37 @@ async function loadEngines() {
|
|
|
5165
5191
|
};
|
|
5166
5192
|
sel.addEventListener('change', show);
|
|
5167
5193
|
show();
|
|
5194
|
+
sel.addEventListener('change', () => syncLocalModel(sel.form));
|
|
5168
5195
|
}
|
|
5169
5196
|
} catch {}
|
|
5170
5197
|
}
|
|
5171
5198
|
|
|
5199
|
+
/**
|
|
5200
|
+
* A local engine (Codex, OpenCode or Claude Code as the harness) takes a model served on this computer ("ollama/qwen3-coder:30b"): the
|
|
5201
|
+
* form's model field then offers the ones found, and starts on the default or the first.
|
|
5202
|
+
*/
|
|
5203
|
+
async function syncLocalModel(form) {
|
|
5204
|
+
const input = form.model;
|
|
5205
|
+
if (!input) return;
|
|
5206
|
+
const local = form.engine.value.startsWith('local-');
|
|
5207
|
+
const field = form.id === 'ask-form' ? $('#ask-model-field') : null;
|
|
5208
|
+
if (field) field.hidden = !local;
|
|
5209
|
+
if (!local) {
|
|
5210
|
+
if (input.dataset.placeholder !== undefined) input.placeholder = input.dataset.placeholder;
|
|
5211
|
+
input.removeAttribute('list');
|
|
5212
|
+
if (input.dataset.local === input.value) input.value = '';
|
|
5213
|
+
return;
|
|
5214
|
+
}
|
|
5215
|
+
input.dataset.placeholder ??= input.placeholder;
|
|
5216
|
+
input.setAttribute('list', 'local-models-list');
|
|
5217
|
+
input.placeholder = '<server>/<model>';
|
|
5218
|
+
const v = await api('GET', '/local-models').catch(() => null);
|
|
5219
|
+
const models = (v?.servers ?? []).flatMap((s) => s.models.filter((m) => m.usable).map((m) => ({ ...m, server: s.label })));
|
|
5220
|
+
$('#local-models-list').replaceChildren(...models.map((m) => Object.assign(document.createElement('option'), { value: m.id, label: [m.server, m.sizeBytes ? `${(m.sizeBytes / 1024 ** 3).toFixed(1)} GB` : '', m.params, ...m.notes].filter(Boolean).join(' · ') })));
|
|
5221
|
+
if (!form.engine.value.startsWith('local-')) return;
|
|
5222
|
+
if (!input.value.includes('/')) input.value = input.dataset.local = (v?.default && models.some((m) => m.id === v.default) ? v.default : models[0]?.id) ?? '';
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5172
5225
|
async function boot() {
|
|
5173
5226
|
if (REMOTE) {
|
|
5174
5227
|
document.body.classList.add('remote');
|
package/public/board.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Board: every agent as a card in the column for where its work stands: starting, working, needs
|
|
2
|
+
// you, waiting for its next instruction, in review (an open pull request), done, closed. An agent
|
|
3
|
+
// moves between columns by itself as its work moves. Dragging a card does the two things a drag
|
|
4
|
+
// can honestly do: onto Closed closes its session, and from Closed onto Waiting resumes it.
|
|
5
|
+
|
|
6
|
+
import { expandButton, expandable } from './expand.js';
|
|
7
|
+
import { morph } from './morph.js';
|
|
8
|
+
import { BOARD_COLUMNS, columnOf, dropAction, needOf, openPrs } from './boardcols.js';
|
|
9
|
+
|
|
10
|
+
const LAND = { ready: 'ready to merge', fix: 'needs fixes', behind: 'behind', waiting: 'checks running', draft: 'draft', merged: 'merged', closed: 'closed' };
|
|
11
|
+
const MANY = 30; // closed and done cards shown before "and N more"
|
|
12
|
+
|
|
13
|
+
export function initBoard({ api, $, esc, ago, toast, agents, openAgent, upsert }) {
|
|
14
|
+
const dialog = $('#board-dialog');
|
|
15
|
+
const body = $('#board-body');
|
|
16
|
+
let project = '';
|
|
17
|
+
let all = false; // every closed and done card, not the latest ones
|
|
18
|
+
let dragging = null;
|
|
19
|
+
let stale = false;
|
|
20
|
+
try {
|
|
21
|
+
project = localStorage.getItem('agentmgr.board.project') ?? '';
|
|
22
|
+
} catch {}
|
|
23
|
+
|
|
24
|
+
const shown = () => [...agents().values()].filter((a) => a.kind !== 'assistant');
|
|
25
|
+
const projects = () => {
|
|
26
|
+
const seen = new Map();
|
|
27
|
+
for (const a of shown()) if (a.projectInfo?.key && !['other', 'general', 'assistant'].includes(a.projectInfo.key)) seen.set(a.projectInfo.key, a.projectInfo.name);
|
|
28
|
+
return [...seen].sort((x, y) => x[1].localeCompare(y[1]));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function card(a, col) {
|
|
32
|
+
const need = col === 'needs' ? needOf(a) : null;
|
|
33
|
+
const pr = col === 'review' ? openPrs(a)[0] : col === 'done' ? (a.prs ?? []).find((p) => p.land === 'merged') : null;
|
|
34
|
+
const rt = a.runtime ?? {};
|
|
35
|
+
const move = col === 'closed' && a.workdir ? `<button class="small" data-board-act="start" data-id="${esc(a.id)}" title="Resume its session in the background">Resume</button>` : col === 'idle' ? `<button class="small ghost" data-board-act="stop" data-id="${esc(a.id)}" title="Close its session; it can be resumed">Close</button>` : '';
|
|
36
|
+
return `<li class="board-card pr${a.priority ?? 2}" draggable="true" data-board-card="${esc(a.id)}" tabindex="0" title="${esc(a.synopsis?.text || a.intent || '')}">
|
|
37
|
+
<div class="board-card-head">${(a.priority ?? 2) === 2 ? '' : `<span class="prio p${a.priority}">P${a.priority}</span>`}<b>${esc(a.name)}</b></div>
|
|
38
|
+
${need ? `<div class="board-need">${esc(need)}</div>` : ''}
|
|
39
|
+
${pr ? `<div class="board-pr ${esc(pr.land)}">#${esc(String(pr.number ?? ''))} ${esc(LAND[pr.land] ?? pr.land)}</div>` : ''}
|
|
40
|
+
${col === 'starting' && a.progress?.phase ? `<div class="hint">${esc(a.progress.phase)}</div>` : ''}
|
|
41
|
+
<div class="board-meta">${a.projectInfo?.name && !project && !['other', 'general', 'assistant'].includes(a.projectInfo.key) ? `<span class="branch">${esc(a.projectInfo.name)}</span>` : ''}${a.kind === 'general' ? '<span class="tag">general</span>' : ''}${a.activeAt ? `<span class="hint">${esc(ago(a.activeAt))}</span>` : ''}${a.brief?.summary?.total ? `<span class="hint${a.brief.summary.failed ? ' fail' : ''}">✓${a.brief.summary.passed}/${a.brief.summary.total}</span>` : ''}${rt.running && col !== 'working' && col !== 'idle' ? '<span class="hint" title="Its session is open">◉</span>' : ''}<span class="spacer"></span>${move}</div>
|
|
42
|
+
</li>`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function draw() {
|
|
46
|
+
const list = shown().filter((a) => !project || a.projectInfo?.key === project);
|
|
47
|
+
const by = new Map(BOARD_COLUMNS.map((c) => [c.id, []]));
|
|
48
|
+
for (const a of list) by.get(columnOf(a)).push(a);
|
|
49
|
+
for (const cards of by.values()) cards.sort((x, y) => (x.priority ?? 2) - (y.priority ?? 2) || String(y.activeAt ?? y.createdAt ?? '').localeCompare(String(x.activeAt ?? x.createdAt ?? '')));
|
|
50
|
+
const ps = projects();
|
|
51
|
+
return `
|
|
52
|
+
<div class="issues-head">
|
|
53
|
+
<h2>Board</h2><span class="hint">${list.length} agent${list.length === 1 ? '' : 's'}</span>
|
|
54
|
+
<span class="spacer"></span>
|
|
55
|
+
${ps.length > 1 ? `<select data-board-project aria-label="Project"><option value="">Every project</option>${ps.map(([k, n]) => `<option value="${esc(k)}" ${k === project ? 'selected' : ''}>${esc(n)}</option>`).join('')}</select>` : ''}
|
|
56
|
+
${expandButton(dialog)}
|
|
57
|
+
<button class="small" data-board="close">Close</button>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="board-cols">
|
|
60
|
+
${BOARD_COLUMNS.map((c) => {
|
|
61
|
+
const cards = by.get(c.id);
|
|
62
|
+
const cut = !all && (c.id === 'closed' || c.id === 'done') && cards.length > MANY ? cards.length - MANY : 0;
|
|
63
|
+
return `<section class="board-col col-${c.id}" data-board-col="${c.id}" aria-label="${esc(c.label)}">
|
|
64
|
+
<h3 title="${esc(c.hint)}">${esc(c.label)} <span class="hint">${cards.length}</span></h3>
|
|
65
|
+
<ul>${(cut ? cards.slice(0, MANY) : cards).map((a) => card(a, c.id)).join('')}</ul>
|
|
66
|
+
${cut ? `<button class="link" data-board="all">and ${cut} more</button>` : ''}
|
|
67
|
+
</section>`;
|
|
68
|
+
}).join('')}
|
|
69
|
+
</div>
|
|
70
|
+
<p class="hint">A card moves by itself as its agent's work moves. Drag one onto Closed to close its session, or from Closed onto Waiting to resume it. Click a card to open its agent.</p>`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const render = () => {
|
|
74
|
+
// A redraw mid-drag would drop the card being dragged: draw when it lands.
|
|
75
|
+
if (dragging) return (stale = true);
|
|
76
|
+
morph(body, draw());
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
async function run(id, what) {
|
|
80
|
+
try {
|
|
81
|
+
upsert(await api('POST', `/agents/${id}/${what}`, {}));
|
|
82
|
+
toast?.(what === 'stop' ? 'Session closed. Resume brings it back' : 'Resumed in the background', 3000);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
toast?.(e.message, 5000);
|
|
85
|
+
}
|
|
86
|
+
render();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
body.addEventListener('click', (e) => {
|
|
90
|
+
if (e.target.closest('[data-board="close"]')) return dialog.close();
|
|
91
|
+
if (e.target.closest('[data-board="all"]')) {
|
|
92
|
+
all = true;
|
|
93
|
+
return render();
|
|
94
|
+
}
|
|
95
|
+
const b = e.target.closest('[data-board-act]');
|
|
96
|
+
if (b) return run(b.dataset.id, b.dataset.boardAct);
|
|
97
|
+
const c = e.target.closest('[data-board-card]');
|
|
98
|
+
if (c) {
|
|
99
|
+
dialog.close();
|
|
100
|
+
openAgent?.(c.dataset.boardCard);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
body.addEventListener('keydown', (e) => {
|
|
104
|
+
const c = e.target.matches?.('[data-board-card]') ? e.target : null;
|
|
105
|
+
if (!c || (e.key !== 'Enter' && e.key !== ' ')) return;
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
dialog.close();
|
|
108
|
+
openAgent?.(c.dataset.boardCard);
|
|
109
|
+
});
|
|
110
|
+
body.addEventListener('change', (e) => {
|
|
111
|
+
if (!e.target.matches('[data-board-project]')) return;
|
|
112
|
+
project = e.target.value;
|
|
113
|
+
try {
|
|
114
|
+
localStorage.setItem('agentmgr.board.project', project);
|
|
115
|
+
} catch {}
|
|
116
|
+
render();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const colAt = (e) => e.target.closest?.('[data-board-col]');
|
|
120
|
+
const clear = () => body.querySelectorAll('.board-col.drop').forEach((x) => x.classList.remove('drop'));
|
|
121
|
+
body.addEventListener('dragstart', (e) => {
|
|
122
|
+
const c = e.target.closest?.('[data-board-card]');
|
|
123
|
+
if (!c) return;
|
|
124
|
+
dragging = c.dataset.boardCard;
|
|
125
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
126
|
+
e.dataTransfer.setData('text/plain', dragging);
|
|
127
|
+
c.classList.add('dragging');
|
|
128
|
+
});
|
|
129
|
+
body.addEventListener('dragover', (e) => {
|
|
130
|
+
const col = colAt(e);
|
|
131
|
+
if (!dragging || !col) return;
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
if (!col.classList.contains('drop')) {
|
|
134
|
+
clear();
|
|
135
|
+
col.classList.add('drop');
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
body.addEventListener('drop', (e) => {
|
|
139
|
+
const col = colAt(e);
|
|
140
|
+
const a = agents().get(dragging);
|
|
141
|
+
if (!col || !a) return;
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
const r = dropAction(a, col.dataset.boardCol);
|
|
144
|
+
if (r.act) run(a.id, r.act);
|
|
145
|
+
else if (r.why) toast?.(r.why, 6000);
|
|
146
|
+
});
|
|
147
|
+
body.addEventListener('dragend', () => {
|
|
148
|
+
dragging = null;
|
|
149
|
+
clear();
|
|
150
|
+
body.querySelector('.board-card.dragging')?.classList.remove('dragging');
|
|
151
|
+
if (stale) {
|
|
152
|
+
stale = false;
|
|
153
|
+
render();
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
let queued = false;
|
|
158
|
+
/** Agents changed: draw again, once a frame at most, while the board is open. */
|
|
159
|
+
function refresh() {
|
|
160
|
+
if (!dialog.open || queued) return;
|
|
161
|
+
queued = true;
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
queued = false;
|
|
164
|
+
if (dialog.open) render();
|
|
165
|
+
}, 200);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function open() {
|
|
169
|
+
if (dialog.open) return dialog.close();
|
|
170
|
+
all = false;
|
|
171
|
+
dialog.showModal();
|
|
172
|
+
render();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
expandable(dialog, render);
|
|
176
|
+
return { open, refresh, isOpen: () => dialog.open };
|
|
177
|
+
}
|