tryharness 0.7.72 → 0.7.73

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.
Files changed (47) hide show
  1. package/assets/opencode-plugin.js +70 -3
  2. package/lib/asks.mjs +2 -0
  3. package/lib/boardCommands.mjs +9 -1
  4. package/lib/boardProtocol.json +23 -19
  5. package/lib/bridge.mjs +2 -0
  6. package/lib/capabilityCheck.mjs +86 -0
  7. package/lib/computerAddress.mjs +6 -14
  8. package/lib/coordinator.mjs +207 -26
  9. package/lib/daemon.mjs +150 -125
  10. package/lib/dispatchContract.json +1 -31
  11. package/lib/dispatchTools.js +8 -39
  12. package/lib/dispatches.mjs +27 -285
  13. package/lib/goalCommands.mjs +7 -3
  14. package/lib/herdr.mjs +159 -0
  15. package/lib/hookDialects.mjs +36 -2
  16. package/lib/jobAnswers.mjs +3 -0
  17. package/lib/kanban.mjs +256 -0
  18. package/lib/localAgentAsk.mjs +20 -29
  19. package/lib/machineRoutes.mjs +1 -5
  20. package/lib/manager.mjs +254 -0
  21. package/lib/mcp-stdio.mjs +58 -39
  22. package/lib/moves.mjs +365 -0
  23. package/lib/nudge.mjs +13 -3
  24. package/lib/ownMachines.mjs +43 -6
  25. package/lib/places.mjs +29 -2
  26. package/lib/runAuthority.mjs +2 -14
  27. package/lib/runBrief.mjs +14 -1
  28. package/lib/runWorker.mjs +4 -10
  29. package/lib/runner.mjs +1 -49
  30. package/lib/sessionControl.mjs +65 -1
  31. package/lib/steerHook.mjs +124 -0
  32. package/lib/steerQueue.mjs +176 -0
  33. package/lib/store.mjs +9 -23
  34. package/lib/subagentSteering.mjs +363 -0
  35. package/lib/subagents.mjs +138 -29
  36. package/lib/swarm.mjs +13 -3
  37. package/lib/taskCommands.mjs +0 -62
  38. package/lib/threadActions.mjs +4 -2
  39. package/lib/threadBriefs.mjs +9 -3
  40. package/lib/threadRuns.mjs +13 -0
  41. package/npm-shrinkwrap.json +14 -14
  42. package/package.json +4 -4
  43. package/release.json +44 -40
  44. package/lib/comfyExecution.mjs +0 -545
  45. package/lib/promptDecider.mjs +0 -471
  46. package/lib/promptFlow.mjs +0 -597
  47. package/lib/promptScopes.mjs +0 -670
package/lib/herdr.mjs ADDED
@@ -0,0 +1,159 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { spawnSync } from "node:child_process";
5
+ import { hostApp, processTable, tmuxPlace } from "./live.mjs";
6
+
7
+ // A session in a herdr pane (herdr.dev, a terminal workspace for coding agents), opened there. herdr's own server owns
8
+ // its panes, so the process tree of a session in one leads up to that server, not to a terminal app. Every pane carries
9
+ // its ids instead (HERDR_PANE_ID, HERDR_TAB_ID, HERDR_WORKSPACE_ID), the socket of the herdr it belongs to
10
+ // (HERDR_SOCKET_PATH) and herdr's own binary (HERDR_BIN_PATH). herdr's command line, pointed at that socket, focuses a
11
+ // pane, or opens a tab on a folder with a command running in it. Everything a herdr client shows follows the server's
12
+ // focus, so the terminal a client runs in comes forward like any other's.
13
+
14
+ const DEFAULT_SOCKET = path.join(
15
+ os.homedir(),
16
+ ".config",
17
+ "herdr",
18
+ "herdr.sock"
19
+ );
20
+ const isHerdr = (comm) => path.basename(comm || "") === "herdr";
21
+
22
+ /** The herdr to speak to a server with: the one its panes name, one running now, else a usual install. */
23
+ function herdrBinary(place, table) {
24
+ const running = [...table.values()]
25
+ .map((row) => row.comm)
26
+ .filter((comm) => path.isAbsolute(comm) && isHerdr(comm));
27
+ const usual = [
28
+ ...(process.env.PATH || "").split(path.delimiter),
29
+ "/opt/homebrew/bin",
30
+ "/usr/local/bin",
31
+ "/usr/bin",
32
+ path.join(os.homedir(), ".cargo", "bin"),
33
+ path.join(os.homedir(), ".local", "bin"),
34
+ path.join(os.homedir(), "bin"),
35
+ ]
36
+ .filter(Boolean)
37
+ .map((dir) => path.join(dir, "herdr"));
38
+ const named = place?.bin ? [place.bin] : [];
39
+ return (
40
+ [...named, ...running, ...usual].find((file) => fs.existsSync(file)) ?? null
41
+ );
42
+ }
43
+
44
+ /** The socket of the herdr a place belongs to; null when that herdr is not running (its socket is gone). */
45
+ function socketOf(place) {
46
+ const socket = place?.socket || DEFAULT_SOCKET;
47
+ return fs.existsSync(socket) ? socket : null;
48
+ }
49
+
50
+ /** One herdr command against a place's server: its JSON answer, or null when herdr is not there or refused. */
51
+ function herdr(place, args, table) {
52
+ const socket = socketOf(place);
53
+ const binary = socket ? herdrBinary(place, table) : null;
54
+ if (!binary) return null;
55
+ // Not yet measured against a real herdr: the same limit as the other terminals' controls (live.mjs run).
56
+ const ran = spawnSync(binary, args, {
57
+ encoding: "utf8",
58
+ timeout: 3_000,
59
+ env: { ...process.env, HERDR_SOCKET_PATH: socket },
60
+ stdio: ["ignore", "pipe", "pipe"],
61
+ });
62
+ if (ran.status !== 0) return null;
63
+ // Most of herdr's commands answer in JSON; one that prints nothing still did what it was asked.
64
+ if (!ran.stdout.trim()) return {};
65
+ try {
66
+ return JSON.parse(ran.stdout);
67
+ } catch {
68
+ return null;
69
+ }
70
+ }
71
+
72
+ /** Whether a process runs inside one of herdr's panes: a herdr (its server) is among its ancestors. */
73
+ function inPane(table, pid) {
74
+ for (
75
+ let current = table.get(pid)?.ppid, steps = 0;
76
+ current > 1 && steps < 64;
77
+ steps++
78
+ ) {
79
+ const row = table.get(current);
80
+ if (!row) return false;
81
+ if (isHerdr(row.comm)) return true;
82
+ current = row.ppid;
83
+ }
84
+ return false;
85
+ }
86
+
87
+ /**
88
+ * The terminal a herdr client runs in: a herdr process on a terminal device (the server has none) and not in one of
89
+ * herdr's own panes (a command an agent ran there), with the app around it, or tmux's client for a herdr in tmux; the
90
+ * newest when there are several. Null when no client is attached.
91
+ */
92
+ export function herdrClient(table = processTable()) {
93
+ const [pid, row] =
94
+ [...table]
95
+ .filter(
96
+ ([id, entry]) => isHerdr(entry.comm) && entry.tty && !inPane(table, id)
97
+ )
98
+ .sort((a, b) => b[0] - a[0])[0] ?? [];
99
+ if (!row) return null;
100
+ return {
101
+ pid,
102
+ tty: row.tty,
103
+ host:
104
+ hostApp(table, pid) ?? tmuxPlace(table, row.tty)?.client?.host ?? null,
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Brings up the pane a running session is in: by the agent herdr sees there, else its tab. The terminal herdr is attached
110
+ * in ({ pid, tty, host }, to come forward as any terminal does), `{ attach: true }` when herdr runs with no client
111
+ * attached, or null when that herdr does not answer. The process table is read now: a client may have just attached.
112
+ */
113
+ export function showInHerdr(place, table = processTable({ fresh: true })) {
114
+ const shown =
115
+ (place?.pane && herdr(place, ["agent", "focus", place.pane], table)) ||
116
+ (place?.tab && herdr(place, ["tab", "focus", place.tab], table));
117
+ if (!shown) return null;
118
+ return herdrClient(table) ?? { attach: true };
119
+ }
120
+
121
+ /**
122
+ * Runs `command` (a session's resume, or the agent itself) in a new tab on `folder`, in the workspace the place was in
123
+ * (a new workspace on the folder when that one is gone), focused; as showInHerdr.
124
+ */
125
+ export function resumeInHerdr(
126
+ place,
127
+ command,
128
+ folder,
129
+ label,
130
+ table = processTable({ fresh: true })
131
+ ) {
132
+ const where = folder && path.isAbsolute(folder) ? ["--cwd", folder] : [];
133
+ const named = label ? ["--label", label] : [];
134
+ const tab =
135
+ (place?.workspace &&
136
+ herdr(
137
+ place,
138
+ [
139
+ "tab",
140
+ "create",
141
+ "--workspace",
142
+ place.workspace,
143
+ ...where,
144
+ ...named,
145
+ "--focus",
146
+ ],
147
+ table
148
+ )) ||
149
+ herdr(place, ["workspace", "create", ...where, ...named, "--focus"], table);
150
+ const pane = tab?.result?.root_pane?.pane_id;
151
+ if (typeof pane !== "string" || !pane) return null;
152
+ if (!herdr(place, ["pane", "run", pane, command], table)) return null;
153
+ return herdrClient(table) ?? { attach: true };
154
+ }
155
+
156
+ /** Whether herdr is on this computer, for an agent's home there; and whether the place's herdr is running now. */
157
+ export const herdrInstalled = (place, table = processTable()) =>
158
+ Boolean(herdrBinary(place, table));
159
+ export const herdrRunning = (place) => Boolean(socketOf(place));
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { ensureDir, readJson } from "./files.mjs";
5
+ import { steerRoot } from "./steerQueue.mjs";
5
6
 
6
7
  // How each agent runs session hooks: the file it reads them from, that file's shape, and what it does with a hook's
7
8
  // output. Harness hooks three moments, by the names Claude Code gave them: a session starting (its board notice, where it
@@ -10,9 +11,14 @@ import { ensureDir, readJson } from "./files.mjs";
10
11
  // words (hookDialect). Every other setting and hook in a file is kept; setup replaces Harness's entries and uninstall
11
12
  // takes only them out. Read from each agent's own docs and source, October 2026.
12
13
  export const HOOK_EVENTS = ["SessionStart", "UserPromptSubmit", "Stop"];
14
+ // Claude Code alone also runs Harness at each tool call, as each subagent ends and as a permission dialog opens, for what
15
+ // the person tells one of its subagents and what a subagent asks (steerHook.mjs); its hooks name the subagent they fire in.
16
+ export const STEER_EVENTS = ["PreToolUse", "SubagentStop", "PermissionRequest"];
13
17
 
14
18
  const isHarnessHook = (entry) =>
15
- JSON.stringify(entry).includes("/lib/nudge.mjs");
19
+ ["/lib/nudge.mjs", "/lib/steerHook.mjs"].some((file) =>
20
+ JSON.stringify(entry).includes(file)
21
+ );
16
22
  const objectOr = (value) =>
17
23
  value && typeof value === "object" && !Array.isArray(value) ? value : {};
18
24
  const withOurs = (list, ours) => [
@@ -34,12 +40,20 @@ const claudeShape = ({ start = {}, startHook = {} } = {}) => ({
34
40
  : { hooks: [{ ...hook, timeout: 10 }] }
35
41
  );
36
42
  }
43
+ for (const event of STEER_EVENTS) {
44
+ if (commands[event])
45
+ next[event] = withOurs(hooks[event], {
46
+ hooks: [{ type: "command", command: commands[event], timeout: 5 }],
47
+ });
48
+ else if (Array.isArray(hooks[event]))
49
+ next[event] = withOurs(hooks[event]);
50
+ }
37
51
  return { ...settings, hooks: next };
38
52
  },
39
53
  erase: (settings) => {
40
54
  if (!settings.hooks) return settings;
41
55
  const hooks = { ...objectOr(settings.hooks) };
42
- for (const event of HOOK_EVENTS)
56
+ for (const event of [...HOOK_EVENTS, ...STEER_EVENTS])
43
57
  if (Array.isArray(hooks[event])) hooks[event] = withOurs(hooks[event]);
44
58
  return { ...settings, hooks };
45
59
  },
@@ -271,6 +285,7 @@ export function installSessionHooks(
271
285
  // Mid-session: on every prompt, one line only when the queue changed since the session last saw it.
272
286
  UserPromptSubmit: `${nudge} --if-changed`,
273
287
  Stop: `${nudge} --stop`,
288
+ ...(agent === "claude-code" ? steerCommands(runtimeRoot, nodePath) : {}),
274
289
  };
275
290
  const settings = dialect.ownFile ? {} : readJson(file, {});
276
291
  ensureDir(path.dirname(file));
@@ -280,6 +295,25 @@ export function installSessionHooks(
280
295
  );
281
296
  }
282
297
 
298
+ // Claude Code runs these on every tool call of every session, so a shell test of the steer folder goes first: Node
299
+ // starts only when a steer waits somewhere (steerQueue.mjs keeps the folder empty otherwise).
300
+ function steerCommands(runtimeRoot, nodePath) {
301
+ const hook = [
302
+ JSON.stringify(nodePath),
303
+ JSON.stringify(path.join(runtimeRoot, "lib", "steerHook.mjs")),
304
+ ].join(" ");
305
+ const guarded =
306
+ process.platform === "win32"
307
+ ? hook
308
+ : `[ -n "$(ls -A ${JSON.stringify(steerRoot())} 2>/dev/null)" ] && ${hook} || true`;
309
+ // A permission dialog is rare, and a subagent's must reach the person whether or not a steer waits.
310
+ return {
311
+ PreToolUse: guarded,
312
+ SubagentStop: guarded,
313
+ PermissionRequest: `${hook} --ask`,
314
+ };
315
+ }
316
+
283
317
  export function removeSessionHooks(
284
318
  agent,
285
319
  homeDir = os.homedir(),
@@ -27,6 +27,8 @@ export function createJobAnswers({
27
27
  actions,
28
28
  files,
29
29
  notifyBoard,
30
+ // An agent's job ended with its report in the thread (manager.mjs).
31
+ reported = () => {},
30
32
  }) {
31
33
  // What the post says: an answer to an ask follows the ask in the thread, so it stands as said; a job's result names
32
34
  // the job. What Harness made for the task is named under its answer, so every agent reading the thread can get it.
@@ -153,6 +155,7 @@ export function createJobAnswers({
153
155
  // The computer that did the job, so the thread says which Codex answered.
154
156
  machine: task.claimed_machine,
155
157
  });
158
+ if (post?.kind === "result") reported(goal, post);
156
159
  if (root && closesWithTask(goal, task, mentions)) {
157
160
  store.setGoalState(goal.id, {
158
161
  status: task.status,
package/lib/kanban.mjs ADDED
@@ -0,0 +1,256 @@
1
+ // A thread's board: the pieces of work in it as cards in four columns, To do, In progress, Review and Done, so the
2
+ // person can tell at a glance where the work stands and follow one piece without reading the whole thread. Agents keep
3
+ // it: they add a card for each piece they split the work into and move it as the work goes (update_board), and a task
4
+ // posted with a card is linked to it, so claiming that task moves the card to In progress (to Review when the task is a
5
+ // check), a failure marks it blocked and a passed check moves it to Done. Nothing waits on the board: no agent is held
6
+ // for a card, and a card nobody moves only stands still. Cards are kept per thread like its plan, so the buddy and the
7
+ // phone read the same ones (board.swarm.read).
8
+ import { randomUUID } from "node:crypto";
9
+ import { nameOf } from "./members.mjs";
10
+ import { oneLine } from "./oneLine.mjs";
11
+
12
+ export const COLUMNS = ["todo", "doing", "review", "done"];
13
+ const COLUMN_NAMES = {
14
+ todo: "To do",
15
+ doing: "In progress",
16
+ review: "Review",
17
+ done: "Done",
18
+ };
19
+ const MAX_CARDS = 40;
20
+ const TITLE_LIMIT = 120;
21
+ const NOTE_LIMIT = 240;
22
+ const HISTORY_LIMIT = 30;
23
+ // A task at one of these steps reviews the work: while it runs its card is in Review, and when it is done so is the card.
24
+ const REVIEW_STEPS = new Set(["check", "judge"]);
25
+ // A task an agent holds and works on, and one not finished yet.
26
+ const WORKING = new Set(["claimed", "running"]);
27
+ const UNFINISHED = new Set(["open", "claimed", "running", "needs_input"]);
28
+
29
+ const words = (value, limit) => oneLine(String(value ?? "")).slice(0, limit);
30
+ const whoIs = (agent) => (agent === "user" ? "You" : nameOf(agent));
31
+
32
+ export function createKanban({ store, log = () => {}, onChange = () => {} }) {
33
+ const key = (threadId) => `kanban:${threadId}`;
34
+ const cardsOf = (threadId) => {
35
+ try {
36
+ const kept = JSON.parse(store.meta(key(threadId)) || "[]");
37
+ return Array.isArray(kept) ? kept : [];
38
+ } catch {
39
+ return [];
40
+ }
41
+ };
42
+ const save = (threadId, cards) => {
43
+ store.meta(key(threadId), JSON.stringify(cards));
44
+ onChange(threadId);
45
+ };
46
+ const threadOf = (id) => {
47
+ const thread = store.getTask(String(id || ""));
48
+ return thread?.kind === "goal" ? thread : null;
49
+ };
50
+ const remember = (card, by, text) => {
51
+ card.history = [
52
+ ...(card.history ?? []),
53
+ { at: new Date().toISOString(), by, text },
54
+ ].slice(-HISTORY_LIMIT);
55
+ card.at = new Date().toISOString();
56
+ };
57
+ const moveTo = (card, column, by) => {
58
+ if (card.column === column) return false;
59
+ card.column = column;
60
+ remember(card, by, `${whoIs(by)} moved it to ${COLUMN_NAMES[column]}`);
61
+ return true;
62
+ };
63
+
64
+ /** Add a card, or change one: its column, title, note, who has it, and whether it is blocked or waits on the person. */
65
+ const update = (request, agent) => {
66
+ const thread = threadOf(request.id);
67
+ if (!thread) return { ok: false, error: "no thread has that id" };
68
+ const team = thread.goal?.team ?? [];
69
+ if (agent !== "user" && agent !== "harness" && !team.includes(agent))
70
+ return {
71
+ ok: false,
72
+ error: "only the person and the thread's agents keep its board",
73
+ };
74
+ const cards = cardsOf(thread.id);
75
+ const column =
76
+ request.column == null ? null : String(request.column).toLowerCase();
77
+ if (column && !COLUMNS.includes(column))
78
+ return {
79
+ ok: false,
80
+ error: `column is one of ${COLUMNS.join(", ")}`,
81
+ };
82
+ const cardId = request.card ? String(request.card) : null;
83
+ if (!cardId) {
84
+ const title = words(request.title, TITLE_LIMIT);
85
+ if (!title) return { ok: false, error: "a new card needs a title" };
86
+ if (cards.length >= MAX_CARDS)
87
+ return {
88
+ ok: false,
89
+ error: `a thread's board holds ${MAX_CARDS} cards; finish or remove some first`,
90
+ };
91
+ const card = {
92
+ id: randomUUID().slice(0, 8),
93
+ title,
94
+ column: column ?? "todo",
95
+ note: words(request.note, NOTE_LIMIT) || null,
96
+ agent: request.agent ? String(request.agent) : null,
97
+ blocked: words(request.blocked, NOTE_LIMIT) || null,
98
+ needsYou: words(request.needs_you, NOTE_LIMIT) || null,
99
+ tasks: [],
100
+ by: agent,
101
+ at: null,
102
+ history: [],
103
+ };
104
+ remember(card, agent, `${whoIs(agent)} added it`);
105
+ save(thread.id, [...cards, card]);
106
+ return { ok: true, card };
107
+ }
108
+ const card = cards.find((each) => each.id === cardId);
109
+ if (!card)
110
+ return { ok: false, error: "no card on this thread's board has that id" };
111
+ if (request.remove === true) {
112
+ if (agent !== "user" && agent !== card.by)
113
+ return {
114
+ ok: false,
115
+ error: "only the person or the agent that added a card removes it",
116
+ };
117
+ save(
118
+ thread.id,
119
+ cards.filter((each) => each.id !== cardId)
120
+ );
121
+ return { ok: true, removed: cardId };
122
+ }
123
+ if (column) moveTo(card, column, agent);
124
+ if (request.title != null) {
125
+ const title = words(request.title, TITLE_LIMIT);
126
+ if (title) card.title = title;
127
+ }
128
+ if (request.agent !== undefined)
129
+ card.agent = request.agent ? String(request.agent) : null;
130
+ if (request.note !== undefined) {
131
+ card.note = words(request.note, NOTE_LIMIT) || null;
132
+ if (card.note) remember(card, agent, `${whoIs(agent)}: ${card.note}`);
133
+ }
134
+ // false (or empty words) clears each.
135
+ if (request.blocked !== undefined) {
136
+ card.blocked = words(request.blocked || "", NOTE_LIMIT) || null;
137
+ remember(
138
+ card,
139
+ agent,
140
+ card.blocked
141
+ ? `${whoIs(agent)} marked it blocked: ${card.blocked}`
142
+ : `${whoIs(agent)} unblocked it`
143
+ );
144
+ }
145
+ if (request.needs_you !== undefined)
146
+ card.needsYou = words(request.needs_you || "", NOTE_LIMIT) || null;
147
+ card.at = new Date().toISOString();
148
+ save(thread.id, cards);
149
+ return { ok: true, card };
150
+ };
151
+
152
+ /** A task was posted with a card: it is linked, so what happens to the task moves the card. */
153
+ const link = (threadId, cardId, taskId) => {
154
+ const cards = cardsOf(threadId);
155
+ const card = cards.find((each) => each.id === cardId);
156
+ if (!card || card.tasks.includes(taskId)) return Boolean(card);
157
+ card.tasks = [...card.tasks, taskId];
158
+ save(threadId, cards);
159
+ // The task may have been claimed in the same breath as it was posted.
160
+ changed(store.getTask(taskId));
161
+ return true;
162
+ };
163
+
164
+ /** A task changed: the card it is linked to moves with it. */
165
+ const changed = (task) => {
166
+ const threadId = task?.parent_id;
167
+ if (!threadId || !store.meta(key(threadId))) return;
168
+ const cards = cardsOf(threadId);
169
+ const card = cards.find((each) => each.tasks.includes(task.id));
170
+ if (!card) return;
171
+ const reviews = REVIEW_STEPS.has(task.step);
172
+ const holder = task.claimed_by || task.target_agent;
173
+ let moved = false;
174
+ if (WORKING.has(task.status)) {
175
+ moved = moveTo(card, reviews ? "review" : "doing", holder);
176
+ if (card.agent !== holder) {
177
+ card.agent = holder;
178
+ moved = true;
179
+ }
180
+ if (card.blocked) {
181
+ card.blocked = null;
182
+ moved = true;
183
+ }
184
+ } else if (task.status === "failed" || task.status === "unknown") {
185
+ // The agent's own words; task.failure is only which kind of stop it was.
186
+ const why = words(task.result || "it stopped", NOTE_LIMIT);
187
+ if (card.blocked !== why) {
188
+ card.blocked = why;
189
+ remember(card, holder, `${whoIs(holder)} couldn't finish: ${why}`);
190
+ moved = true;
191
+ }
192
+ } else if (task.status === "done") {
193
+ const stillOpen = card.tasks.some(
194
+ (id) => id !== task.id && UNFINISHED.has(store.getTask(id)?.status)
195
+ );
196
+ if (reviews && !stillOpen) moved = moveTo(card, "done", holder);
197
+ else if (!stillOpen && card.column === "doing")
198
+ // The work it stands for is finished; whoever reviews it, or the agent, moves it on.
199
+ moved = moveTo(card, "review", holder);
200
+ }
201
+ if (moved) {
202
+ card.at = new Date().toISOString();
203
+ save(threadId, cards);
204
+ }
205
+ };
206
+
207
+ /** What a run in the thread is told of its board: the cards, and how to keep them. */
208
+ const brief = (threadId) => {
209
+ const cards = cardsOf(threadId);
210
+ const lines = cards.map(
211
+ (card) =>
212
+ `- [${card.id}] ${COLUMN_NAMES[card.column]}: ${card.title}${card.agent ? ` (${whoIs(card.agent)})` : ""}${card.blocked ? `, blocked: ${card.blocked}` : ""}${card.needsYou ? `, waits on the person: ${card.needsYou}` : ""}`
213
+ );
214
+ return [
215
+ "This thread has a board the person follows the work on: a card for each piece of the work, in To do, In progress, Review or Done.",
216
+ lines.length
217
+ ? `Its cards now:\n${lines.join("\n")}`
218
+ : "It has no cards yet. When the work splits into pieces, add a card for each.",
219
+ `Keep it current with update_board (thread ${threadId}): add a card for a piece of work, move yours to In progress when you start it, to Review when it is ready to be checked and to Done when it is finished, mark it blocked with why, or say it waits on the person. Post a task for a card with post_task's card, and its claim and its end move the card for you. Never wait on the board to do your work.`,
220
+ ].join("\n");
221
+ };
222
+
223
+ return {
224
+ of: (threadId) => cardsOf(threadId),
225
+ brief,
226
+ changed: (task) => {
227
+ try {
228
+ changed(task);
229
+ } catch (error) {
230
+ log(`board card move failed for ${task?.id}: ${error.message}`);
231
+ }
232
+ },
233
+ /** After board.post: link the task it made to the card it was posted for. */
234
+ posted(request, answer) {
235
+ const taskId = answer?.task?.id ?? answer?.id;
236
+ if (!request.card || !request.parentId || typeof taskId !== "string")
237
+ return answer;
238
+ const linked = link(
239
+ String(request.parentId),
240
+ String(request.card),
241
+ taskId
242
+ );
243
+ return linked
244
+ ? answer
245
+ : {
246
+ ...answer,
247
+ note: "No card on the thread's board has that id, so the task is not on a card.",
248
+ };
249
+ },
250
+ command(request, agent) {
251
+ if (String(request.command) === "board.kanban.update")
252
+ return update(request, agent);
253
+ return { ok: false, error: `unknown command ${request.command}` };
254
+ },
255
+ };
256
+ }
@@ -8,37 +8,28 @@ export const LOCAL_DECIDERS = ["claude-code", "codex"];
8
8
 
9
9
  /**
10
10
  * One question to `agent`, answered with one JSON object. It runs in the system's temporary folder, away from any
11
- * repository, and has no deadline of its own: it ends when the agent answers or exits. `model` names the agent's own
12
- * model; without it the agent uses its default.
11
+ * repository, and has no deadline of its own: it ends when the agent answers or exits. With `look`, the agent may read
12
+ * this computer to answer but never
13
+ * change it: Codex in its read-only sandbox, Claude Code with only its read, glob and grep tools.
13
14
  */
14
- export function askLocalAgent(
15
- agent,
16
- prompt,
17
- {
18
- executable = null,
19
- isolated = false,
20
- model = null,
21
- onResponse = () => {},
22
- } = {}
23
- ) {
15
+ export function askLocalAgent(agent, prompt, { look = false } = {}) {
24
16
  return new Promise((resolve, reject) => {
25
17
  const invocation =
26
18
  agent === "codex"
27
19
  ? {
28
- command: executable ?? "codex",
20
+ command: "codex",
29
21
  args: [
30
22
  "exec",
31
23
  "--json",
32
24
  "--sandbox",
33
25
  "read-only",
34
26
  "--skip-git-repo-check",
35
- ...(model ? ["--model", model] : []),
36
27
  "-",
37
28
  ],
38
29
  stdin: prompt,
39
30
  }
40
31
  : {
41
- command: executable ?? "claude",
32
+ command: "claude",
42
33
  // Only the model reads: the person's MCP servers, hooks and settings made each reading take ~15 s instead
43
34
  // of ~2 s, and a question with no tools uses none of them.
44
35
  args: [
@@ -46,13 +37,21 @@ export function askLocalAgent(
46
37
  prompt,
47
38
  "--output-format",
48
39
  "json",
49
- "--tools",
50
- "",
40
+ ...(look
41
+ ? [
42
+ "--tools",
43
+ "Read,Glob,Grep",
44
+ "--allowedTools",
45
+ "Read Glob Grep",
46
+ "--add-dir",
47
+ os.homedir(),
48
+ "--permission-mode",
49
+ "dontAsk",
50
+ ]
51
+ : ["--tools", ""]),
51
52
  "--strict-mcp-config",
52
53
  "--setting-sources",
53
54
  "",
54
- ...(isolated ? ["--bare", "--restricted"] : []),
55
- ...(model ? ["--model", model] : []),
56
55
  ],
57
56
  };
58
57
  let child;
@@ -66,21 +65,13 @@ export function askLocalAgent(
66
65
  child.stdin.on("error", () => {});
67
66
  child.stdin.end(invocation.stdin ?? "");
68
67
  let out = "";
69
- let errors = "";
70
68
  child.stdout.on("data", (chunk) => {
71
69
  out += chunk;
72
70
  });
73
- child.stderr.on("data", (chunk) => {
74
- errors += chunk;
75
- });
71
+ // Read and dropped, so a talkative agent never fills the pipe and stalls.
72
+ child.stderr.resume();
76
73
  child.on("error", reject);
77
74
  child.on("close", (code) => {
78
- try {
79
- onResponse({ code, stdout: out, stderr: errors });
80
- } catch (error) {
81
- reject(error);
82
- return;
83
- }
84
75
  if (code !== 0) {
85
76
  reject(new Error(`${agent} exited with code ${code}`));
86
77
  return;
@@ -46,7 +46,6 @@ const QUEUEABLE = new Set([
46
46
  "board.thread.post",
47
47
  "board.context.add",
48
48
  "board.machine.finish",
49
- "board.prompt.receipt",
50
49
  ]);
51
50
  export const queueable = (command) => QUEUEABLE.has(String(command));
52
51
 
@@ -149,7 +148,6 @@ export function withComputer(post, computerOf) {
149
148
  // A worker's own upkeep with home, whoever it names: telling home its folders, taking and reporting the runs home keeps
150
149
  // for its agents, the environment grants home's vault lends a run there (vault.mjs checks those itself).
151
150
  const UPKEEP = new Set([
152
- "board.prompt.receipt",
153
151
  "board.machine.info",
154
152
  "board.machine.runnable",
155
153
  "board.machine.take",
@@ -208,6 +206,7 @@ const AGENT_WORK = new Set([
208
206
  "board.template.list",
209
207
  "board.template.get",
210
208
  "board.template.use",
209
+ "board.kanban.update",
211
210
  "board.project.plan",
212
211
  "board.project.propose",
213
212
  "board.desk.book",
@@ -224,9 +223,6 @@ const AGENT_WORK = new Set([
224
223
  // threads. How the swarm is set up (standing permission, spend ceilings, connectors' grants, the vault, the relay
225
224
  // network, the desk's book, partners on projects, offices) is changed only on home itself or a phone paired with it.
226
225
  const PERSON_WORK = new Set([
227
- "board.prompt.start",
228
- "board.prompt.status",
229
- "board.prompt.cancel",
230
226
  ...AGENT_WORK,
231
227
  "board.run",
232
228
  "board.remove",