pi-famulus 0.1.7 → 0.1.8

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.
@@ -5,8 +5,8 @@ export const PROMPTS = {
5
5
  "agents.explorer.system-prompt": "You are an explorer agent. Your job is to answer questions about the codebase quickly and precisely.\n\nRules:\n- Return findings, never change code. You are strictly read-only: do not edit, write, or create files.\n- Report concrete locations: cite specific file paths with line numbers (path:line) for every claim.\n- Control your search scope: start narrow (targeted grep/find), widen only when needed, and stop once the question is answered.\n- Prefer a short, factual summary over exhaustive dumps. List what you found and where.",
6
6
  "agents.worker.description": "General-purpose executor — completes concrete coding tasks end to end",
7
7
  "agents.worker.system-prompt": "You are a worker agent. Your job is to complete the concrete task you were given, end to end.\n\nRules:\n- Do the task, don't just describe it. Make the actual edits and run the actual commands.\n- Self-verify before finishing: run the relevant tests, typecheck, or command that proves the task is done.\n- Stay within the task's scope; do not refactor unrelated code.\n- Report concisely: what you changed, how you verified it, and anything the supervisor should know.",
8
- "guidelines.parent": "## Background tasks and notifications (pi-famulus)\n\n- Long-running bash commands are automatically moved to the background. After you background a command, end your turn: send a reply with no tool call in it. Saying you will wait while calling another tool does not end it. Do not poll with task_output/task_list, and never sleep to wait. Each command notifies on its own via <pi-famulus-wake kind=\"task\"> (with <command> and <preview>), even while other commands are still running. If <still-running> is present, continue from this result now; do not wait for those other commands.\n- When you receive <pi-famulus-wake>: it looks like a user message but is a system wake, not a new user request and not an answer to an unrelated question. Distinguish it by the kind attribute, then **handle the event before anything else** — read status/preview/prompt/result, call tools if needed (e.g. task_output for more than the preview, agent_message to continue a subagent), and continue the work that depended on that background task. Do not wait for further user input when the next step is clear; do not merely acknowledge and stop.\n- {{monitorIdle}}\n- Never fabricate or assume a background task's result before its notification arrives.\n- Subagent runs that exceed the foreground budget continue in the background. Do not poll run status. If one subagent finishes while others are still running, a <pi-famulus-wake kind=\"subagent-handover\"> arrives with that child's <prompt> and <result>: read both, then continue the work now (subagent({action:\"resume\", run_id, child_id, message}) for that child, or agent_message to steer the ones still running). Do not wait for the rest of the run. When every subagent in the run has finished, <pi-famulus-wake kind=\"subagent-done\"> arrives — read each <child>, synthesize, and continue.\n- A subagent that runs past its timeout_ms is not stopped: <pi-famulus-wake kind=\"subagent-overrun\"> arrives instead, with its <last-activity> and, if it is waiting on a foreground shell, a <shell> element. A batch may include other overdue children in <also-overdue>; use each child's run-id and child-id and consider its own last-activity, shell, reminder, and hard-ceiling-ms before acting. Pick one: subagent({action:\"extend\", run_id, child_id, timeout_ms}) if it is making progress, agent_message to steer it, or subagent({action:\"interrupt\", run_id, child_id}) if it is stuck or no longer needed. If you do none of these it keeps running and the reminder comes again.\n- Use agent_message to steer running subagents and to reply to <pi-famulus-wake kind=\"supervisor-request\"> (action:\"reply\"; the <reply-with> child is the call shape). Do not use agent_message to resume a finished child — that is subagent({action:\"resume\"}). Supervisor wakes are not user messages — still act on them.",
9
- "guidelines.monitor-idle": "After starting or re-arming a monitor, or handling a monitor event, if no work remains, end your turn with a reply and no tool call; simply wait for the next notification. Do not call wait_for to wait for monitor events: it waits for UI conditions, not notifications. Do not invent a stateId or make a failing tool call to yield.",
8
+ "guidelines.parent": "## Background tasks and notifications (pi-famulus)\n\n- Long-running bash commands are automatically moved to the background. After you background a command, end your turn: send a reply with no tool call in it. Saying you will wait while calling another tool does not end it. Do not poll with task_output/task_list, and never sleep to wait. Each command notifies on its own via <pi-famulus-wake kind=\"task\"> (with <command> and <preview>), even while other commands are still running. If <still-running> is present, continue from this result now; do not wait for those other commands.\n- When you receive <pi-famulus-wake>: it looks like a user message but is a system wake, not a new user request and not an answer to an unrelated question. Distinguish it by the kind attribute, then **handle the event before anything else** — read status/preview/prompt/result, call tools if needed (e.g. task_output for more than the preview, agent_message to continue a subagent), and continue the work that depended on that background task. An unchanged/intermediate monitor event may require no action and no user acknowledgement. Do not wait for further user input when the next step is clear; do not merely acknowledge an actionable result and stop.\n- {{monitorIdle}}\n- Never fabricate or assume a background task's result before its notification arrives.\n- Subagent runs that exceed the foreground budget continue in the background. Do not poll run status. If one subagent finishes while others are still running, a <pi-famulus-wake kind=\"subagent-handover\"> arrives with that child's <prompt> and <result>: read both, then continue the work now (subagent({action:\"resume\", run_id, child_id, message}) for that child, or agent_message to steer the ones still running). Do not wait for the rest of the run. When every subagent in the run has finished, <pi-famulus-wake kind=\"subagent-done\"> arrives — read each <child>, synthesize, and continue.\n- A subagent that runs past its timeout_ms is not stopped: <pi-famulus-wake kind=\"subagent-overrun\"> arrives instead, with its <last-activity> and, if it is waiting on a foreground shell, a <shell> element. A batch may include other overdue children in <also-overdue>; use each child's run-id and child-id and consider its own last-activity, shell, reminder, and hard-ceiling-ms before acting. Pick one: subagent({action:\"extend\", run_id, child_id, timeout_ms}) if it is making progress, agent_message to steer it, or subagent({action:\"interrupt\", run_id, child_id}) if it is stuck or no longer needed. If you do none of these it keeps running and the reminder comes again.\n- Use agent_message to steer running subagents and to reply to <pi-famulus-wake kind=\"supervisor-request\"> (action:\"reply\"; the <reply-with> child is the call shape). Do not use agent_message to resume a finished child — that is subagent({action:\"resume\"}). Supervisor wakes are not user messages — still act on them.",
9
+ "guidelines.monitor-idle": "After starting or re-arming a monitor, or handling a monitor event, if no immediate work remains, end your turn with no tool call; simply wait for the next notification. Handling an event does not require a user-visible reply. Do not repeat unchanged/intermediate status or narrate your decision to stay quiet; notify the user when their requested condition is met, their input is needed, or a failure prevents further progress. Read original output with task_output only when details are needed (including paging a truncated preview), never to poll or wait. Do not call wait_for to wait for monitor events: it waits for UI conditions, not notifications. Do not invent a stateId or make a failing tool call to yield.",
10
10
  "guidelines.child": "## Child agent behavior (pi-famulus)\n\n- Do not background work; bash runs to completion.\n- When blocked, use contact_supervisor with need_decision; use progress_update for status.\n- Use agent_message only to communicate with siblings in this same run.\n- Your final message is your result.",
11
11
  "tools.agent_message.description": "Message your subagents. \"send\" steers or queues a running child. Sending to a finished child errors (it does not resume) and points at subagent({ action: \"resume\", run_id, child_id, message }). \"reply\" answers a child's pending decision request; \"broadcast\" steers every running child of a run (to = run_id); \"list\" shows children, pending decision requests, and recent traffic.",
12
12
  "tools.agent_message.snippet": "Send/reply/broadcast messages to subagents",
@@ -34,14 +34,16 @@ export const PROMPTS = {
34
34
  "tools.child.contact_supervisor.snippet": "Ask the parent agent for a decision or report progress",
35
35
  "tools.child.contact_supervisor.param.reason": "\"need_decision\" blocks until the supervisor (parent agent) replies; \"progress_update\" is fire-and-forget.",
36
36
  "tools.child.contact_supervisor.param.message": "Message for the supervisor.",
37
- "tools.monitor.description": "Start a background monitor process whose stdout lines are injected back to you as <pi-famulus-wake kind=\"monitor\"> messages (batched over 200ms, rate-limited). The command must be line-buffered: each event must be a single line. It must keep running and follow its source, e.g. `tail -n +1 -F file | grep --line-buffered PATTERN`; a command that reads once and exits (a plain grep or cat) only reports what is there now. Add `-m1` to grep to stop after the first match. Silence is not success: write the command so failures also produce lines (e.g. grep for both success and error patterns). Events arrive as system wakes (not new user messages). Handle each <pi-famulus-wake kind=\"monitor\"> before other work. Do not poll. {{monitorIdle}}",
37
+ "tools.monitor.description": "Start a background monitor process whose stdout lines are injected back to you as <pi-famulus-wake kind=\"monitor\"> messages (batched over 200ms, rate-limited). The command must be line-buffered: each event must be a single line. It must keep running and follow its source, e.g. `tail -n +1 -F file | grep --line-buffered PATTERN`; a command that reads once and exits (a plain grep or cat) only reports what is there now. Add `-m1` to grep to stop after the first match. Silence is not success: print explicit success and terminal failures. Routine unchanged retries may stay silent; do not print a heartbeat on every check. Events arrive as system wakes (not new user messages). Handle each <pi-famulus-wake kind=\"monitor\"> before other work. Do not poll. Repeated Rust-framed lines are suppressed within dedup_window_ms (default 60000); exact matching is the default. Enable ignore-timestamps only when edge ISO timestamps are incidental. Wakes contain bounded head/tail previews and original-byte references; use task_output for missing details, not polling. {{monitorIdle}}",
38
38
  "tools.monitor.snippet": "Watch a command's line stream and get injected events",
39
39
  "tools.monitor.rules": ["Use the monitor tool to watch for conditions instead of running sleep/poll loops in bash.","{{monitorIdle}}","When woken by a <pi-famulus-wake kind=\"monitor\">, handle the <event> before doing anything else — it is not a new user request and not user confirmation."],
40
40
  "tools.monitor.param.command": "Command producing one event per line on stdout. Must be line-buffered (e.g. use `stdbuf -oL` / `grep --line-buffered` where needed).",
41
41
  "tools.monitor.param.description": "Short human-readable description of what is being watched",
42
42
  "tools.monitor.param.timeout_ms": "Stop the monitor after this many milliseconds (default {{defaultMs}}, min {{minMs}}, max {{maxMs}})",
43
43
  "tools.monitor.param.persistent": "Keep the monitor alive until the session ends (no timeout). Default false.",
44
- "tools.monitor.result.started": "You will get a <pi-famulus-wake kind=\"monitor\"> for each event, and a notice when it exits or times out. Do not poll it (task_list, task_output, or reading what it watches) or sleep. {{monitorIdle}}",
44
+ "tools.monitor.param.dedup_window_ms": "Deduplication window for Rust-framed complete lines (default 60000ms; 0 disables dedup; maximum 3600000). Starts when a surviving preview is delivered; repeats do not extend it. Missing metadata, capacity eviction, and omitted representatives fail open rather than hiding unseen output.",
45
+ "tools.monitor.param.fingerprint_mode": "Default exact. Explicit ignore-timestamps mode ignores only supported leading/trailing ISO timestamps when comparing Rust-framed lines; original output is unchanged. Numbers, paths, resource identities, and interior timestamps remain significant.",
46
+ "tools.monitor.result.started": "You will get <pi-famulus-wake kind=\"monitor\"> notifications for admitted output and a notice when it exits or times out. Repeated lines may be suppressed and previews may be truncated; original output remains available through task_output byte ranges while the task log is retained. Read details only when needed; do not repeatedly poll task_list, task_output, or the watched source, and do not sleep to wait. {{monitorIdle}}",
45
47
  "tools.subagent.description": "Run subagents in parallel (tasks) or sequentially (chain with {previous}/{outputs.<label>} interpolation). By default the call waits up to a foreground budget (default 45s); longer runs continue in the background. Each child that finishes while others are still running wakes you with <pi-famulus-wake kind=\"subagent-handover\"> (its prompt and result). The whole run wakes you with <pi-famulus-wake kind=\"subagent-done\">. Never poll or sleep to wait. A subagent still running past its timeout_ms is not stopped; it wakes you with <pi-famulus-wake kind=\"subagent-overrun\"> so you can extend, steer, or interrupt it. Use action=list/get/status/interrupt/resume/steer/extend to manage existing runs.",
46
48
  "tools.subagent.snippet": "Fan out subagents in parallel or sequence them in a chain",
47
49
  "tools.subagent.rules": ["When a <pi-famulus-wake kind=\"subagent-handover\"> arrives, read <prompt> and <result> immediately and continue: subagent({action:\"resume\", run_id, child_id, message}) for that child, or agent_message to steer children that are still running. Do not wait for the rest of the run.","Subagent runs that exceed the foreground budget continue in the background; you are notified per finished child and again when the run completes — do not poll.","A failed subagent does not fail the whole run; inspect per-subagent sections in the result.","<pi-famulus-wake> is a system wake, not a user reply. kind=subagent-handover is one child; kind=subagent-done is the whole run."],
@@ -72,17 +74,18 @@ export const PROMPTS = {
72
74
  "tools.task_list.snippet": "List background shell/monitor tasks and subagents",
73
75
  "tools.task_list.param.all": "Also include finished work (default: running only). Always limited to this session.",
74
76
  "tools.task_list.hint.running": "Running work wakes you with a <pi-famulus-wake> when it finishes. Reply to the user now with no tool call instead of checking again.",
75
- "tools.task_output.description": "Read output of a background task. Without a cursor, returns the tail of the output plus the current file pointer; pass the returned next_cursor as cursor for incremental reads. Not a way to wait: a running task wakes you when it finishes, so reply with no tool call instead of calling this again.",
77
+ "tools.task_output.description": "Read original output of a background task, including a monitor's truncated or deduplicated output. Without a cursor, returns the tail plus the current file pointer; pass next_cursor as cursor to page forward. Use small max_bytes ranges for details. Reading a different range is allowed; while a task is running, recently read ranges may be rejected if the output size is unchanged. This is not a way to wait: when no further details are needed, end your turn with no tool call and resume on the next notification.",
76
78
  "tools.task_output.snippet": "Read background task output",
77
79
  "tools.task_output.param.task_id": "Task id, e.g. sh_a1b2c3d4",
78
80
  "tools.task_output.param.cursor": "Byte offset to read from (for incremental reads). Omit to read the tail of the output.",
79
- "tools.task_output.param.max_bytes": "Maximum bytes to return (default 65536)",
80
- "tools.task_output.hint.still-running": "The task is still running. Reply to the user now with no tool call; a <pi-famulus-wake> arrives when it finishes.",
81
+ "tools.task_output.param.max_bytes": "Maximum bytes to return (default 65536, capped at 1048576); use a smaller range to avoid flooding context. Zero selects the default.",
82
+ "tools.task_output.hint.still-running": "The task is still running. Read another byte range only if details are needed; otherwise end your turn with no tool call. Do not repeatedly check for progress; a <pi-famulus-wake> arrives when it finishes.",
81
83
  "tools.task_output.error.no-new-output": "No new output from {{taskId}} since your last read. {{hint}}",
82
84
  "tools.task_stop.description": "Stop a running background task (SIGTERM to the process group, SIGKILL after a 2s grace).",
83
85
  "tools.task_stop.snippet": "Stop a background task",
84
86
  "tools.task_stop.param.task_id": "Task id to stop, e.g. sh_a1b2c3d4",
85
87
  "wakes.lead-in": "System wake — not a new user message. Handle this <pi-famulus-wake> before other work.",
88
+ "wakes.monitor.output-hint": "Read original bytes with task_output using this monitor id and cursor-start, with a bounded max_bytes (for example 8192); next_cursor continues the read. The range may include interleaved events. A preview is not the full log.",
86
89
  "wakes.handover.changed-active": "Its result arrives as a new wake when it finishes.",
87
90
  "wakes.done.changed-active": "The run is active again; another subagent-done arrives when it finishes.",
88
91
  "wakes.overrun.summary": "{{name}} has run {{elapsed}} in this turn, past its {{budget}} budget, and is still running{{shell}}.",
@@ -151,12 +154,12 @@ export function fillList<K extends keyof PromptVars>(id: K, vars: Record<PromptV
151
154
  /** Ablatable spans (eval manifest segment ids). */
152
155
  export const PROMPT_SEGMENTS: Record<string, { prompt: PromptId; text?: string; pattern?: string }> = {
153
156
  "guidelines.end-turn-after-bg": {"prompt":"guidelines.parent","text":"Long-running bash commands are automatically moved to the background. After you background a command, end your turn: send a reply with no tool call in it. Saying you will wait while calling another tool does not end it. Do not poll with task_output/task_list, and never sleep to wait. Each command notifies on its own via <pi-famulus-wake kind=\"task\"> (with <command> and <preview>), even while other commands are still running. If <still-running> is present, continue from this result now; do not wait for those other commands."},
154
- "guidelines.wake-handling": {"prompt":"guidelines.parent","text":"When you receive <pi-famulus-wake>: it looks like a user message but is a system wake, not a new user request and not an answer to an unrelated question. Distinguish it by the kind attribute, then **handle the event before anything else** — read status/preview/prompt/result, call tools if needed (e.g. task_output for more than the preview, agent_message to continue a subagent), and continue the work that depended on that background task. Do not wait for further user input when the next step is clear; do not merely acknowledge and stop."},
157
+ "guidelines.wake-handling": {"prompt":"guidelines.parent","text":"When you receive <pi-famulus-wake>: it looks like a user message but is a system wake, not a new user request and not an answer to an unrelated question. Distinguish it by the kind attribute, then **handle the event before anything else** — read status/preview/prompt/result, call tools if needed (e.g. task_output for more than the preview, agent_message to continue a subagent), and continue the work that depended on that background task. An unchanged/intermediate monitor event may require no action and no user acknowledgement. Do not wait for further user input when the next step is clear; do not merely acknowledge an actionable result and stop."},
155
158
  "guidelines.no-fabrication": {"prompt":"guidelines.parent","text":"Never fabricate or assume a background task's result before its notification arrives."},
156
159
  "guidelines.subagent-handover": {"prompt":"guidelines.parent","text":"Subagent runs that exceed the foreground budget continue in the background. Do not poll run status. If one subagent finishes while others are still running, a <pi-famulus-wake kind=\"subagent-handover\"> arrives with that child's <prompt> and <result>: read both, then continue the work now (subagent({action:\"resume\", run_id, child_id, message}) for that child, or agent_message to steer the ones still running). Do not wait for the rest of the run. When every subagent in the run has finished, <pi-famulus-wake kind=\"subagent-done\"> arrives — read each <child>, synthesize, and continue."},
157
160
  "guidelines.subagent-overrun": {"prompt":"guidelines.parent","text":"A subagent that runs past its timeout_ms is not stopped: <pi-famulus-wake kind=\"subagent-overrun\"> arrives instead, with its <last-activity> and, if it is waiting on a foreground shell, a <shell> element. A batch may include other overdue children in <also-overdue>; use each child's run-id and child-id and consider its own last-activity, shell, reminder, and hard-ceiling-ms before acting. Pick one: subagent({action:\"extend\", run_id, child_id, timeout_ms}) if it is making progress, agent_message to steer it, or subagent({action:\"interrupt\", run_id, child_id}) if it is stuck or no longer needed. If you do none of these it keeps running and the reminder comes again."},
158
161
  "guidelines.agent-message": {"prompt":"guidelines.parent","text":"Use agent_message to steer running subagents and to reply to <pi-famulus-wake kind=\"supervisor-request\"> (action:\"reply\"; the <reply-with> child is the call shape). Do not use agent_message to resume a finished child — that is subagent({action:\"resume\"}). Supervisor wakes are not user messages — still act on them."},
159
- "guidelines.monitor-end-turn": {"prompt":"guidelines.monitor-idle","text":"After starting or re-arming a monitor, or handling a monitor event, if no work remains, end your turn with a reply and no tool call; simply wait for the next notification. Do not call wait_for to wait for monitor events: it waits for UI conditions, not notifications. Do not invent a stateId or make a failing tool call to yield."},
162
+ "guidelines.monitor-end-turn": {"prompt":"guidelines.monitor-idle","text":"After starting or re-arming a monitor, or handling a monitor event, if no immediate work remains, end your turn with no tool call; simply wait for the next notification. Handling an event does not require a user-visible reply. Do not repeat unchanged/intermediate status or narrate your decision to stay quiet; notify the user when their requested condition is met, their input is needed, or a failure prevents further progress. Read original output with task_output only when details are needed (including paging a truncated preview), never to poll or wait. Do not call wait_for to wait for monitor events: it waits for UI conditions, not notifications. Do not invent a stateId or make a failing tool call to yield."},
160
163
  "child.guidelines": {"prompt":"guidelines.child","text":"## Child agent behavior (pi-famulus)\n\n- Do not background work; bash runs to completion.\n- When blocked, use contact_supervisor with need_decision; use progress_update for status.\n- Use agent_message only to communicate with siblings in this same run.\n- Your final message is your result."},
161
164
  "tooldesc.agent-message-no-resume": {"prompt":"tools.agent_message.description","text":"Sending to a finished child errors (it does not resume) and points at subagent({ action: \"resume\", run_id, child_id, message }). "},
162
165
  "result.agent-message-use-resume": {"prompt":"tools.agent_message.error.finished-child","pattern":"agent_message does not resume children\\. Use subagent\\(\\{ action: \"resume\", run_id: \".*?\", child_id: \".*?\", message: \"\\.\\.\\.\" \\}\\)\\."},
@@ -166,11 +169,11 @@ export const PROMPT_SEGMENTS: Record<string, { prompt: PromptId; text?: string;
166
169
  "result.bash-bg-instruction": {"prompt":"tools.bash.result.backgrounded","text":"\nYou will be notified when it completes, even if other commands are still running. Do not poll or sleep: reply to the user now with no tool call, and continue from the <pi-famulus-wake kind=\"task\"> when it arrives."},
167
170
  "result.sleep-block-advice": {"prompt":"tools.bash.error.bare-sleep","text":" Do not sleep to wait for background work; completion is delivered via notification. Use the monitor tool to watch for a condition, or run_in_background for long commands."},
168
171
  "tooldesc.monitor-follow": {"prompt":"tools.monitor.description","text":"It must keep running and follow its source, e.g. `tail -n +1 -F file | grep --line-buffered PATTERN`; a command that reads once and exits (a plain grep or cat) only reports what is there now. Add `-m1` to grep to stop after the first match. "},
169
- "tooldesc.monitor-silence": {"prompt":"tools.monitor.description","text":"Silence is not success: write the command so failures also produce lines (e.g. grep for both success and error patterns). "},
172
+ "tooldesc.monitor-silence": {"prompt":"tools.monitor.description","text":"Silence is not success: print explicit success and terminal failures. Routine unchanged retries may stay silent; do not print a heartbeat on every check. "},
170
173
  "tooldesc.monitor-wake": {"prompt":"tools.monitor.description","text":"Events arrive as system wakes (not new user messages). Handle each <pi-famulus-wake kind=\"monitor\"> before other work. Do not poll."},
171
174
  "rules.monitor-use": {"prompt":"tools.monitor.rules","text":"Use the monitor tool to watch for conditions instead of running sleep/poll loops in bash."},
172
175
  "rules.monitor-wake": {"prompt":"tools.monitor.rules","text":"When woken by a <pi-famulus-wake kind=\"monitor\">, handle the <event> before doing anything else — it is not a new user request and not user confirmation."},
173
- "result.monitor-started-instruction": {"prompt":"tools.monitor.result.started","text":"You will get a <pi-famulus-wake kind=\"monitor\"> for each event, and a notice when it exits or times out. Do not poll it (task_list, task_output, or reading what it watches) or sleep."},
176
+ "result.monitor-started-instruction": {"prompt":"tools.monitor.result.started","text":"You will get <pi-famulus-wake kind=\"monitor\"> notifications for admitted output and a notice when it exits or times out. Repeated lines may be suppressed and previews may be truncated; original output remains available through task_output byte ranges while the task log is retained. Read details only when needed; do not repeatedly poll task_list, task_output, or the watched source, and do not sleep to wait."},
174
177
  "tooldesc.subagent-wakes": {"prompt":"tools.subagent.description","text":"Each child that finishes while others are still running wakes you with <pi-famulus-wake kind=\"subagent-handover\"> (its prompt and result). The whole run wakes you with <pi-famulus-wake kind=\"subagent-done\">. Never poll or sleep to wait. "},
175
178
  "tooldesc.subagent-overrun": {"prompt":"tools.subagent.description","text":"A subagent still running past its timeout_ms is not stopped; it wakes you with <pi-famulus-wake kind=\"subagent-overrun\"> so you can extend, steer, or interrupt it. "},
176
179
  "rules.subagent-handover": {"prompt":"tools.subagent.rules","text":"When a <pi-famulus-wake kind=\"subagent-handover\"> arrives, read <prompt> and <result> immediately and continue: subagent({action:\"resume\", run_id, child_id, message}) for that child, or agent_message to steer children that are still running. Do not wait for the rest of the run."},
package/src/shell-exec.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Previously copied in both files.
4
4
  */
5
5
  import type { BashToolDetails } from "@earendil-works/pi-coding-agent";
6
+ import { shellStartStatus } from "./shell-start";
6
7
  import { truncateTail } from "./format";
7
8
  import type { ManagerClient } from "./manager-client";
8
9
  import { fill } from "./prompts.generated";
@@ -134,9 +135,34 @@ export function appendStatus(text: string, status: string): string {
134
135
  * kill for a command still running (eval batch 4).
135
136
  */
136
137
  export async function killedStatus(client: ManagerClient, taskId: string, timeoutSeconds: number | undefined): Promise<string> {
137
- const record = (await client.list(true).catch(() => [])).find((t) => t.task_id === taskId);
138
+ const record = await taskRecord(client, taskId);
138
139
  if (record?.end_reason === "timeout" && timeoutSeconds !== undefined) return timedOutStatus(timeoutSeconds);
139
- return killedBy(record?.signal);
140
+ return shellStartStatus(record?.end_reason) ?? killedBy(record?.signal);
141
+ }
142
+
143
+ /**
144
+ * Status line for a non-zero exit. On Windows the manager marks a Git Bash
145
+ * that crashed while starting (shell-start-failed); elsewhere that cannot
146
+ * happen, so skip the record lookup.
147
+ */
148
+ export async function exitedStatus(
149
+ client: ManagerClient,
150
+ taskId: string,
151
+ exitCode: number,
152
+ platform: NodeJS.Platform = process.platform,
153
+ ): Promise<string> {
154
+ const plain = `Command exited with code ${exitCode}`;
155
+ if (platform !== "win32") return plain;
156
+ const hint = shellStartStatus((await taskRecord(client, taskId))?.end_reason);
157
+ return hint ? `${hint} (exit code ${exitCode})` : plain;
158
+ }
159
+
160
+ async function taskRecord(client: ManagerClient, taskId: string) {
161
+ try {
162
+ return (await client.list(true)).find((t) => t.task_id === taskId);
163
+ } catch {
164
+ return undefined;
165
+ }
140
166
  }
141
167
 
142
168
  /** The one wording of a timeout kill, on every bash path. */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Windows Git Bash start-up failures (manager end_reasons, see
3
+ * manager/src/shellstart.rs). Concurrent MSYS cold starts race while building
4
+ * the shared mount table (git-for-windows/git#6368). These reasons are
5
+ * inferred: a nested shell can print the same fatal text after the command
6
+ * has already had side effects, and a silent builtin-only command looks like
7
+ * a hung start. Say that, and do not tell the model the command did not run.
8
+ */
9
+ export const SHELL_START_FAILED = "shell-start-failed";
10
+ export const SHELL_START_HUNG = "shell-start-hung";
11
+
12
+ /** The status line for a shell start-up failure, or undefined. */
13
+ export function shellStartStatus(endReason: string | undefined): string | undefined {
14
+ if (endReason === SHELL_START_FAILED) {
15
+ return "Git Bash reported a Windows runtime startup failure; the command may have partially run. Check for side effects before retrying.";
16
+ }
17
+ if (endReason === SHELL_START_HUNG) {
18
+ return (
19
+ "Git Bash showed no output and only the shell process for 20s, so it was killed. " +
20
+ "This is usually a hung start, but a silent builtin-only command looks the same and may have been running. " +
21
+ "Check for side effects before retrying."
22
+ );
23
+ }
24
+ return undefined;
25
+ }
@@ -32,6 +32,7 @@ import {
32
32
  bareSleepError,
33
33
  collectOutput,
34
34
  formatFinishedOutput,
35
+ exitedStatus,
35
36
  killedStatus,
36
37
  timedOutStatus,
37
38
  SHELL_MAX_BYTES,
@@ -172,7 +173,7 @@ export function createChildBashTool(
172
173
  const { text, details } = formatFinishedOutput(collected, outputPath);
173
174
  const exitCode = waitResult.exit_code ?? null;
174
175
  if (exitCode !== 0 && exitCode !== null) {
175
- throw new Error(appendStatus(text, `Command exited with code ${exitCode}`));
176
+ throw new Error(appendStatus(text, await exitedStatus(client, start.task_id, exitCode)));
176
177
  }
177
178
  // No exit code: killed (timeout, stop, crash), unless the manager
178
179
  // finished it as completed with its runner status unobservable.
@@ -7,6 +7,7 @@ import type { ConversationTurn } from "./types";
7
7
  interface LooseBlock {
8
8
  type?: string;
9
9
  text?: string;
10
+ thinking?: string;
10
11
  name?: string;
11
12
  arguments?: unknown;
12
13
  }
@@ -21,7 +22,8 @@ interface LooseMessage {
21
22
  }
22
23
 
23
24
  function blockText(block: LooseBlock): string {
24
- if (block.type === "text" || block.type === "thinking") return block.text ?? "";
25
+ if (block.type === "thinking") return block.thinking ?? block.text ?? "";
26
+ if (block.type === "text") return block.text ?? "";
25
27
  if (block.type === "toolCall") {
26
28
  const args = block.arguments === undefined ? "" : ` ${JSON.stringify(block.arguments)}`;
27
29
  return `tool ${block.name ?? "?"}${args}`;
@@ -45,32 +47,75 @@ function contentText(content: unknown): string {
45
47
  .join("\n");
46
48
  }
47
49
 
50
+ function emitAssistantBlocks(message: LooseMessage, turns: ConversationTurn[]): void {
51
+ if (!Array.isArray(message.content)) {
52
+ const text = contentText(message.content);
53
+ if (text) turns.push({ role: message.role ?? "message", text });
54
+ return;
55
+ }
56
+ let thinking = "";
57
+ let text = "";
58
+ const flushThinking = () => {
59
+ const t = thinking.trim();
60
+ if (t) turns.push({ role: "thinking", text: t });
61
+ thinking = "";
62
+ };
63
+ const flushText = () => {
64
+ const t = text.trim();
65
+ if (t) turns.push({ role: message.role ?? "assistant", text: t });
66
+ text = "";
67
+ };
68
+ for (const raw of message.content) {
69
+ const block = raw && typeof raw === "object" ? (raw as LooseBlock) : null;
70
+ if (!block?.type) continue;
71
+ if (block.type === "thinking") {
72
+ flushText();
73
+ const part = (block.thinking ?? block.text ?? "").trim();
74
+ if (part) thinking = thinking ? `${thinking}\n\n${part}` : part;
75
+ continue;
76
+ }
77
+ if (block.type === "toolCall") {
78
+ flushThinking();
79
+ flushText();
80
+ const part = blockText(block);
81
+ if (part) turns.push({ role: message.role ?? "assistant", text: part });
82
+ continue;
83
+ }
84
+ if (block.type === "text") {
85
+ flushThinking();
86
+ const part = block.text ?? "";
87
+ if (part) text = text ? `${text}\n${part}` : part;
88
+ }
89
+ }
90
+ flushThinking();
91
+ flushText();
92
+ }
93
+
48
94
  export function turnsFromMessages(messages: readonly LooseMessage[]): ConversationTurn[] {
49
95
  const turns: ConversationTurn[] = [];
50
96
  let firstUserTurn = true;
51
97
  for (const message of messages) {
52
98
  if (message.role === "system") continue;
53
- const rawText = contentText(message.content);
54
- const text = message.role === "user" && firstUserTurn ? visibleUserText(rawText) : rawText;
55
- if (message.role === "user") firstUserTurn = false;
56
99
  if (message.role === "assistant" && (message.stopReason === "error" || message.stopReason === "aborted")) {
57
100
  // A failed model call often has no text; its error is the only record of what happened.
101
+ const text = contentText(message.content);
58
102
  if (text) turns.push({ role: "assistant", text });
59
103
  turns.push({ role: "assistant error", text: message.errorMessage?.trim() || `model stopped: ${message.stopReason}` });
60
104
  continue;
61
105
  }
62
- if (!text) continue;
63
106
  if (message.role === "toolResult") {
64
107
  const name = message.toolName ?? "tool";
65
- turns.push({ role: message.isError ? `tool ${name} error` : `tool ${name}`, text });
108
+ turns.push({ role: message.isError ? `tool ${name} error` : `tool ${name}`, text: contentText(message.content) });
109
+ continue;
110
+ }
111
+ if (message.role === "user") {
112
+ const rawText = contentText(message.content);
113
+ const text = firstUserTurn ? visibleUserText(rawText) : rawText;
114
+ firstUserTurn = false;
115
+ if (text) turns.push({ role: "user", text });
66
116
  continue;
67
117
  }
68
- turns.push({ role: message.role ?? "message", text });
118
+ emitAssistantBlocks(message, turns);
69
119
  }
70
120
  return turns;
71
121
  }
72
-
73
- export function formatConversation(turns: readonly ConversationTurn[]): string {
74
- if (turns.length === 0) return "(no messages yet)";
75
- return turns.map((turn) => `── ${turn.role} ──\n${turn.text}`).join("\n\n");
76
- }
@@ -1,16 +1,17 @@
1
1
  /**
2
- * Passive fleet summary below the editor — counts only, no keyboard hooks.
2
+ * Passive fleet line below the editor — live work only, no keyboard hooks.
3
3
  *
4
- * Format: `2 workers · 1 subagent · 1 monitor`
5
- * workers = backgrounded shell tasks (not sync-waited)
6
- * subagents = in-process subagent children
7
- * monitors = active monitors
4
+ * Format: `● 2 shells · 1 monitor · scout 12s /tasks`
5
+ * shells = backgrounded shell tasks (not sync-waited)
6
+ * monitors = active monitors
7
+ * then each running subagent by name with its age
8
8
  *
9
9
  * Driven by WorkIndex changes. Does not poll the manager.
10
10
  */
11
11
  import { realClock, type Clock, type ClockTimer } from "../clock";
12
12
  import { formatAge, nextAgeBoundary, type WorkIndex, type WorkItem } from "../work-index";
13
13
  import { truncateToWidth } from "../tui/pi-tui-load";
14
+ import { statusGlyph } from "../tui/tool-component";
14
15
 
15
16
  export const FLEET_WIDGET_KEY = "pi-famulus-fleet";
16
17
 
@@ -207,10 +208,9 @@ export class FleetWidget {
207
208
  parts.push(`${name} ${theme.fg("dim", formatAge(item.startedAt, item.endedAt, now))}`);
208
209
  }
209
210
  if (parts.length === 0) return [];
210
- const line = ` ${theme.fg("accent", "●")} ${parts.join(theme.fg("dim", " · "))} ${theme.fg("dim", "/tasks")}`;
211
+ const live = statusGlyph("running");
212
+ const line = ` ${theme.fg(live.color, live.glyph)} ${parts.join(theme.fg("dim", " · "))} ${theme.fg("dim", "/tasks")}`;
211
213
  return [truncateToWidth(line, Math.max(1, width), "…")];
212
214
  }
213
215
  }
214
216
 
215
- /** @deprecated Use FleetWidget — kept as alias for older imports. */
216
- export { FleetWidget as FleetStatus };
@@ -16,7 +16,7 @@
16
16
  * the next one. See design.md §4.6 "Child lifecycle".
17
17
  * - `hardTimeoutMs` (opt-in, default off) is the abort ceiling per turn:
18
18
  * abort -> result {status:"interrupted", error:"timeout"};
19
- * - a stall watchdog aborts the child after `stallMs` (default 10min) without
19
+ * - a stall watchdog aborts the child after `stallMs` (default 5min) without
20
20
  * any session event. A stall is treated as transient (a silently dropped
21
21
  * provider stream): the child is aborted and auto-resumed on the SAME
22
22
  * session with a continuation prompt, up to `stallRetries` times
@@ -79,7 +79,7 @@ export interface AdmissionTicket {
79
79
 
80
80
  export interface InProcessRunnerOptions {
81
81
  createSession: CreateSessionFn;
82
- /** Stall watchdog timeout (ms). Default 10 minutes. */
82
+ /** Stall watchdog timeout (ms). Default 5 minutes. */
83
83
  stallMs?: number;
84
84
  /** Auto-resume attempts after a stall. Default 1; 0 settles stalled at once. */
85
85
  stallRetries?: number;
@@ -21,6 +21,7 @@ import { realClock, type Clock, type ClockTimer } from "../clock";
21
21
 
22
22
  import type { NotifyCenter } from "../notify";
23
23
  import { statusGlyph, toolComponent } from "../tui/tool-component";
24
+ import { scrubTty } from "../tui/conversation-view";
24
25
  import type { WorkIndex } from "../work-index";
25
26
  import { fill, PROMPTS } from "../prompts.generated";
26
27
  import { runChain, runTasks, validateChainSteps } from "./pool";
@@ -706,7 +707,7 @@ export function createSubagentTool(
706
707
  .filter((c): c is { type: "text"; text: string } => c.type === "text")
707
708
  .map((c) => c.text)
708
709
  .join("\n");
709
- const all = text.split("\n");
710
+ const all = scrubTty(text).split("\n");
710
711
  const shown = expanded ? all : all.slice(0, 10);
711
712
  const out = shown.map((l) => theme.fg("toolOutput", l));
712
713
  if (shown.length < all.length) out.push(theme.fg("muted", `... (${all.length - shown.length} more lines, ctrl+o to expand)`));
package/src/task-tools.ts CHANGED
@@ -5,6 +5,7 @@ import { Type } from "typebox";
5
5
  import { realClock, type Clock } from "./clock";
6
6
  import type { ExtensionContext, ToolDefinition } from "@earendil-works/pi-coding-agent";
7
7
  import type { ManagerClient, TaskRecord } from "./manager-client";
8
+ import { fnv1a64 } from "./config";
8
9
  import { fill, PROMPTS } from "./prompts.generated";
9
10
  import {
10
11
  formatAgentCommand,
@@ -196,19 +197,32 @@ export interface TaskOutputDetails {
196
197
  }
197
198
 
198
199
  const DEFAULT_OUTPUT_BYTES = 65536;
200
+ // manager/src/daemon.rs MAX_OUTPUT_READ: clamp before selecting a tail window.
201
+ const MAX_OUTPUT_BYTES = 1024 * 1024;
199
202
 
200
203
  export function createTaskOutputTool(
201
204
  deps: TaskToolsDeps,
202
205
  ): ToolDefinition<typeof taskOutputParameters, TaskOutputDetails> {
203
- // total_size at the last read of each running task. A repeat read that finds
204
- // the same size is polling: the prompt forbids it, but models still loop.
205
- const lastRunningSize = new Map<string, number>();
206
- const guardPoll = (id: string, running: boolean, size: number) => {
207
- if (running && lastRunningSize.get(id) === size) {
206
+ // Reading another page is retrieval, not polling. Remember actual returned
207
+ // ranges so tail/explicit reads (or different limits hitting EOF) agree.
208
+ // Bound both task and range histories for long-lived extension sessions.
209
+ const runningReads = new Map<string, { size: number; ranges: Set<string> }>();
210
+ const guardPoll = (id: string, running: boolean, size: number, start: number, end: number, identity = "") => {
211
+ if (!running) {
212
+ runningReads.delete(id);
213
+ return;
214
+ }
215
+ const previous = runningReads.get(id);
216
+ const entry = previous?.size === size ? previous : { size, ranges: new Set<string>() };
217
+ const range = `${start === end ? "empty" : `${start}:${end}`}:${identity}`;
218
+ if (entry.ranges.has(range)) {
208
219
  throw new Error(fill("tools.task_output.error.no-new-output", { taskId: id, hint: END_TURN_HINT }));
209
220
  }
210
- if (running) lastRunningSize.set(id, size);
211
- else lastRunningSize.delete(id);
221
+ entry.ranges.add(range);
222
+ if (entry.ranges.size > 256) entry.ranges.delete(entry.ranges.values().next().value!);
223
+ runningReads.delete(id);
224
+ runningReads.set(id, entry);
225
+ if (runningReads.size > 128) runningReads.delete(runningReads.keys().next().value!);
212
226
  };
213
227
  return {
214
228
  name: "task_output",
@@ -217,11 +231,19 @@ export function createTaskOutputTool(
217
231
  promptSnippet: PROMPTS["tools.task_output.snippet"],
218
232
  parameters: taskOutputParameters,
219
233
  async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
234
+ for (const field of ["cursor", "max_bytes"] as const) {
235
+ const value = params[field];
236
+ if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {
237
+ throw new TypeError(`${field} must be a nonnegative safe integer`);
238
+ }
239
+ }
220
240
  const agentText = agentTextFor(deps, params.task_id);
221
241
  if (agentText !== undefined) {
222
242
  const status = deps.getIndex?.()?.get(params.task_id)?.status ?? "unknown";
223
243
  const running = status === "pending" || status === "running";
224
- guardPoll(params.task_id, running, agentText.length);
244
+ // Length alone hides a same-length conversation rewrite. Hash the
245
+ // snapshot so a changed child transcript is a new range.
246
+ guardPoll(params.task_id, running, agentText.length, 0, agentText.length, fnv1a64(agentText));
225
247
  const body = (agentText || "(no output yet)") + (running ? `\n\n${END_TURN_HINT}` : "");
226
248
  return {
227
249
  content: [{ type: "text", text: body }],
@@ -236,10 +258,7 @@ export function createTaskOutputTool(
236
258
  };
237
259
  }
238
260
  const client = await requireClient(deps);
239
- const maxBytes =
240
- params.max_bytes !== undefined && params.max_bytes > 0
241
- ? Math.floor(params.max_bytes)
242
- : DEFAULT_OUTPUT_BYTES;
261
+ const maxBytes = Math.min(params.max_bytes || DEFAULT_OUTPUT_BYTES, MAX_OUTPUT_BYTES);
243
262
 
244
263
  let cursor = params.cursor;
245
264
  if (cursor === undefined) {
@@ -250,7 +269,7 @@ export function createTaskOutputTool(
250
269
 
251
270
  const res = await client.output(params.task_id, cursor, maxBytes);
252
271
  const running = res.status === "running";
253
- guardPoll(params.task_id, running, res.total_size);
272
+ guardPoll(params.task_id, running, res.total_size, cursor, res.next_cursor);
254
273
  const details: TaskOutputDetails = {
255
274
  task_id: params.task_id,
256
275
  status: res.status,