@ouro.bot/cli 0.1.0-alpha.1314 → 0.1.0-alpha.1315

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.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1315",
6
+ "changes": [
7
+ "The Shepherd, bundle and Copilot app session tools now carry Ouro AX cards, and their failures return the code a card names."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1314",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1314",
2
+ "runtimeVersion": "0.1.0-alpha.1315",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1314</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1315</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -80,12 +80,43 @@ function because(action, ...detail) {
80
80
  const short = (id) => String(id).slice(0, 8);
81
81
  /** Whether a watch answers the session's replies: `never` does not, `always` keeps watching for a day, `once` (the default) stops at the first reply. */
82
82
  const watchMode = (value) => (value === "never" ? null : value === "always" ? "always" : "once");
83
- function define(name, description, properties, required, risk, body, summaryKeys = []) {
83
+ /** A refusal of this module's own, with the code its card names. */
84
+ class AppSessionsRefusal extends Error {
85
+ code;
86
+ constructor(code, message) {
87
+ super(message);
88
+ this.code = code;
89
+ }
90
+ }
91
+ /** The code a failed call ends with: Shepherd's own, or one of this module's. */
92
+ function codeOf(error) {
93
+ if (error instanceof shepherd_cli_1.ShepherdFailure || error instanceof AppSessionsRefusal)
94
+ return error.code;
95
+ return error instanceof shepherd_cli_1.ShepherdUnavailableError ? "shepherd-not-installed" : "app-sessions-failed";
96
+ }
97
+ /**
98
+ * An app-sessions tool's card: Shepherd missing (unless the tool doesn't run Shepherd), then the tool's own refusal if
99
+ * it has one, then any other failure.
100
+ */
101
+ function card(name, effect, when, fix, extra = {}) {
102
+ const errors = [
103
+ ...(extra.withoutShepherd ? [] : [{ code: "shepherd-not-installed", means: "Shepherd isn't installed on this Mac, so the Copilot app can't be reached.", fix: `Tell the owner ${name} needs Shepherd installed; don't reach the app another way.` }]),
104
+ ...(extra.refusal ? [extra.refusal] : []),
105
+ { code: "app-sessions-failed", means: "The call failed outside Shepherd; the error says why. A Shepherd refusal carries Shepherd's own code and fix instead.", fix },
106
+ { code: "no-agent-runtime", means: "The call ran outside an agent's runtime, so the app can't be reached.", fix: `Don't retry; report that ${name} was called without an agent runtime.` },
107
+ ];
108
+ return {
109
+ id: `tool:${name}`, group: "turn-app-sessions", when, effect, errors,
110
+ ...(extra.idempotent ? { idempotent: true } : {}), ...(extra.destructive ? { destructive: true } : {}),
111
+ };
112
+ }
113
+ function define(name, description, ax, properties, required, risk, body, summaryKeys = []) {
84
114
  return {
85
115
  tool: { type: "function", function: { name, description, parameters: { type: "object", properties, ...(required.length ? { required } : {}), additionalProperties: false } } },
116
+ ax,
86
117
  handler: async (args, ctx) => {
87
118
  if (!ctx?.agentRoot)
88
- return JSON.stringify({ error: "the app-sessions tools need an agent runtime" });
119
+ return JSON.stringify({ error: "the app-sessions tools need an agent runtime", code: "no-agent-runtime" });
89
120
  try {
90
121
  const result = await body(args, ctx.agentRoot, ctx);
91
122
  (0, runtime_1.emitNervesEvent)({ component: "repertoire", event: "repertoire.app_sessions_tool", message: "ran an app-sessions tool", meta: { tool: name } });
@@ -93,7 +124,7 @@ function define(name, description, properties, required, risk, body, summaryKeys
93
124
  }
94
125
  catch (error) {
95
126
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "repertoire.app_sessions_tool_error", message: "app-sessions tool call failed", meta: { tool: name, error: error.message } });
96
- return JSON.stringify({ error: error.message, ...(error instanceof shepherd_cli_1.ShepherdFailure ? { code: error.code } : {}) });
127
+ return JSON.stringify({ error: error.message, code: codeOf(error) });
97
128
  }
98
129
  },
99
130
  summaryKeys,
@@ -102,13 +133,13 @@ function define(name, description, properties, required, risk, body, summaryKeys
102
133
  }
103
134
  const session = { type: "string", description: "A session's id from list_sessions_and_chats; a unique start of it (the first 8 characters) works." };
104
135
  const notifyOnIdle = { type: "string", enum: ["once", "always", "never"], description: "Whether the session's finished replies come back to you as inbound messages: once (default, the next one), always (for a day), or never. The app does not report back to an outside client, so this is how replies reach you." };
105
- exports.listSessionsAndChatsTool = define("list_sessions_and_chats", "Every open coding session and chat in this Mac's GitHub Copilot app: id, app_url, name, project, branch, who created and coordinates it. Read-only.", {}, [], READ, async () => {
136
+ exports.listSessionsAndChatsTool = define("list_sessions_and_chats", "Every open coding session and chat in this Mac's GitHub Copilot app: id, app_url, name, project, branch, who created and coordinates it. Read-only.", card("list_sessions_and_chats", "read", "Pick this to find a session's id or app_url by name, project or branch; get_sessions_status says what each is doing.", "Call list_sessions_and_chats once more; if it fails again, tell the owner the app can't be listed."), {}, [], READ, async () => {
106
137
  const picture = await (0, shepherd_cli_1.shepherd)(["sessions"]);
107
138
  return { total: picture.summary.total, items: picture.sessions.map(row => Object.fromEntries(Object.entries(row).filter(([key]) => !STATUS_KEYS.includes(key)))) };
108
139
  });
109
- exports.getSessionsStatusTool = define("get_sessions_status", "What every session is doing now, with counts: busy, idle, stuck, blocked, and what each blocked one waits on. awaiting_input carries the request_id and the question that answer_session_input or respond_to_session_plan_v2 needs. Read-only.", { state: { type: "string", enum: ["busy", "idle", "waiting", "stuck"], description: "Only sessions in this state." } }, [], READ, args => (0, shepherd_cli_1.shepherd)(["sessions", ...(typeof args.state === "string" ? ["--state", args.state] : [])]), ["state"]);
110
- exports.getSessionTool = define("get_session", "One session's details and what it is doing now, including what it waits on (awaiting_input). Read-only.", { session_id: session }, ["session_id"], READ, args => (0, shepherd_cli_1.shepherd)(["session", sessionId(args)]), ["session_id"]);
111
- exports.sendSessionMessageTool = define("send_session_message", "Send a message to a session as a peer: the session sees it as a cross-session message from Ouroboros (Shepherd's own Ouroboros session is the sender and relays it, so the sender is not this runtime itself), never as the owner's turn. Write as yourself, Ouroboros, not as the owner or the owner's agent; the sender already says who you are. Replies come back to that Ouroboros session (read it with shepherd messages). Waits up to 2 minutes for the app to accept it (a session that is not loaded loads first). immediate (default) is admitted at the session's next turn boundary; enqueue waits behind its work.", { session_id: session, message: { type: "string", description: "What to send." }, delivery_mode: { type: "string", enum: ["immediate", "enqueue"] }, notify_on_idle: notifyOnIdle }, ["session_id", "message"], write("sends a message into another agent session in the owner's Copilot app"), async (args, agentRoot) => {
140
+ exports.getSessionsStatusTool = define("get_sessions_status", "What every session is doing now, with counts: busy, idle, stuck, blocked, and what each blocked one waits on. awaiting_input carries the request_id and the question that answer_session_input or respond_to_session_plan_v2 needs. Read-only.", card("get_sessions_status", "read", "Pick this to see which sessions are busy, stuck or waiting on someone, and on what, across the whole app at once.", "Call get_session for the one you care about, or try get_sessions_status again shortly."), { state: { type: "string", enum: ["busy", "idle", "waiting", "stuck"], description: "Only sessions in this state." } }, [], READ, args => (0, shepherd_cli_1.shepherd)(["sessions", ...(typeof args.state === "string" ? ["--state", args.state] : [])]), ["state"]);
141
+ exports.getSessionTool = define("get_session", "One session's details and what it is doing now, including what it waits on (awaiting_input). Read-only.", card("get_session", "read", "Pick this to check one session's state and the exact question it waits on before you answer or message it.", "Check the id with list_sessions_and_chats and call get_session again."), { session_id: session }, ["session_id"], READ, args => (0, shepherd_cli_1.shepherd)(["session", sessionId(args)]), ["session_id"]);
142
+ exports.sendSessionMessageTool = define("send_session_message", "Send a message to a session as a peer: the session sees it as a cross-session message from Ouroboros (Shepherd's own Ouroboros session is the sender and relays it, so the sender is not this runtime itself), never as the owner's turn. Write as yourself, Ouroboros, not as the owner or the owner's agent; the sender already says who you are. Replies come back to that Ouroboros session (read it with shepherd messages). Waits up to 2 minutes for the app to accept it (a session that is not loaded loads first). immediate (default) is admitted at the session's next turn boundary; enqueue waits behind its work.", card("send_session_message", "write", "Pick this to tell or ask another session something as yourself; answer_session_input fits a question it is blocked on.", "Read the session with get_session; resend only if your message isn't in app_sessions_tail."), { session_id: session, message: { type: "string", description: "What to send." }, delivery_mode: { type: "string", enum: ["immediate", "enqueue"] }, notify_on_idle: notifyOnIdle }, ["session_id", "message"], write("sends a message into another agent session in the owner's Copilot app"), async (args, agentRoot) => {
112
143
  // The session is resolved and the send time taken before the send, so the watch's cursor sits before any reply to it.
113
144
  const row = await (0, shepherd_cli_1.shepherd)(["session", sessionId(args)]);
114
145
  const id = String(row.id);
@@ -119,7 +150,7 @@ exports.sendSessionMessageTool = define("send_session_message", "Send a message
119
150
  (0, store_1.watchSession)(agentRoot, id, String(row.name), sentAt, Date.now(), mode === "once");
120
151
  return { ...sent, watching: mode !== null };
121
152
  }, ["session_id"]);
122
- exports.createSessionTool = define("create_session", "Start a session. With project_id (a project's id or name): a project session in its own worktree (workspace_type branch uses the project's checkout instead), kicked off with kickoff.prompt and allow-all permissions unless kickoff.permission_mode says otherwise. Without it: a standalone chat, which shows to peers as \"General Chat\" and has no repository, so use it only for talk that is not repository work. Any work in a repository (for the harness itself: the ouroboros project) must pass project_id, never a chat. Waits for the session to exist (a worktree takes about two minutes). It has no coordinator: the app does not let an outside client be one. You may archive what you create.", {
153
+ exports.createSessionTool = define("create_session", "Start a session. With project_id (a project's id or name): a project session in its own worktree (workspace_type branch uses the project's checkout instead), kicked off with kickoff.prompt and allow-all permissions unless kickoff.permission_mode says otherwise. Without it: a standalone chat, which shows to peers as \"General Chat\" and has no repository, so use it only for talk that is not repository work. Any work in a repository (for the harness itself: the ouroboros project) must pass project_id, never a chat. Waits for the session to exist (a worktree takes about two minutes). It has no coordinator: the app does not let an outside client be one. You may archive what you create.", card("create_session", "write", "Pick this to start new work in the app: a project session for anything in a repository, a chat only for talk.", "Check list_sessions_and_chats for a half-made session before you create another."), {
123
154
  name: { type: "string", description: "Sidebar title." }, project_id: { type: "string", description: "The project's id or name." }, session_kind: { type: "string", enum: ["chat", "project"] },
124
155
  workspace_type: { type: "string", enum: ["worktree", "branch"] }, branch_name: { type: "string", description: "Branch for a worktree; a fresh ouro-… name by default." },
125
156
  kickoff: {
@@ -140,9 +171,9 @@ exports.createSessionTool = define("create_session", "Start a session. With proj
140
171
  (0, store_1.watchSession)(agentRoot, String(created.session_id), typeof args.name === "string" ? args.name : null, new Date().toISOString(), Date.now(), mode === "once");
141
172
  return prompted ? { ...created, watching: mode !== null } : created;
142
173
  }, ["name"]);
143
- exports.answerSessionInputTool = define("answer_session_input", "Answer the question a session asked with ask_user and is blocked on. get_session shows it (awaiting_input.question, choices). A choice or free text. A question asked while this agent was not connected has no request id and cannot be answered here.", { session_id: session, answer: { type: "string" } }, ["session_id", "answer"], write("answers a question for the person in another agent session"), args => (0, shepherd_cli_1.shepherd)(["answer", sessionId(args)], bodyOf(args, "session_id"), because(`Ouroboros answers the question session ${short(args.session_id)} asked`, args.answer)), ["session_id"]);
144
- exports.respondToSessionPlanTool = define("respond_to_session_plan_v2", "Approve or reject the plan a session paused on (awaiting_plan_approval). feedback is sent to the session as a message after the decision.", { session_id: session, approved: { type: "boolean" }, selected_action: { type: "string", description: "One of awaiting_input.actions; the recommended one by default." }, feedback: { type: "string" } }, ["session_id", "approved"], write("approves or rejects another agent session's plan for the person"), args => (0, shepherd_cli_1.shepherd)(["plan", sessionId(args)], bodyOf(args, "session_id"), because(`Ouroboros ${args.approved === true ? "approves" : "rejects"} the plan of session ${short(args.session_id)}`, args.feedback)), ["session_id"]);
145
- exports.archiveSessionTool = define("archive_session", "Archive a session you created with create_session (a project session's worktree goes with it). A session you did not create is archived only when the owner asked for that session in this conversation (owner_asked: true) or when it is over the size limit and a newer session names it as handed off. Archiving can be undone, and each such archive is logged and shown in the next digest.", { session_id: session, owner_asked: { type: "boolean", description: "True only when the owner asked in this conversation for this session to be archived." } }, ["session_id"], write("archives a session in the owner's Copilot app"), async (args, agentRoot) => {
174
+ exports.answerSessionInputTool = define("answer_session_input", "Answer the question a session asked with ask_user and is blocked on. get_session shows it (awaiting_input.question, choices). A choice or free text. A question asked while this agent was not connected has no request id and cannot be answered here.", card("answer_session_input", "write", "Pick this when a session is blocked on an ask_user question and the person has told you the answer.", "Call get_session to see whether the question is still open and what choices it takes."), { session_id: session, answer: { type: "string" } }, ["session_id", "answer"], write("answers a question for the person in another agent session"), args => (0, shepherd_cli_1.shepherd)(["answer", sessionId(args)], bodyOf(args, "session_id"), because(`Ouroboros answers the question session ${short(args.session_id)} asked`, args.answer)), ["session_id"]);
175
+ exports.respondToSessionPlanTool = define("respond_to_session_plan_v2", "Approve or reject the plan a session paused on (awaiting_plan_approval). feedback is sent to the session as a message after the decision.", card("respond_to_session_plan_v2", "write", "Pick this when a session waits for its plan to be approved or rejected and the person has decided.", "Call get_session to see whether the plan still waits, then respond to what it shows."), { session_id: session, approved: { type: "boolean" }, selected_action: { type: "string", description: "One of awaiting_input.actions; the recommended one by default." }, feedback: { type: "string" } }, ["session_id", "approved"], write("approves or rejects another agent session's plan for the person"), args => (0, shepherd_cli_1.shepherd)(["plan", sessionId(args)], bodyOf(args, "session_id"), because(`Ouroboros ${args.approved === true ? "approves" : "rejects"} the plan of session ${short(args.session_id)}`, args.feedback)), ["session_id"]);
176
+ exports.archiveSessionTool = define("archive_session", "Archive a session you created with create_session (a project session's worktree goes with it). A session you did not create is archived only when the owner asked for that session in this conversation (owner_asked: true) or when it is over the size limit and a newer session names it as handed off. Archiving can be undone, and each such archive is logged and shown in the next digest.", card("archive_session", "write", "Pick this to put away a session you started, or one the owner named for archiving in this conversation.", "Leave the session as it is and tell the owner it couldn't be archived, with the reason.", { destructive: true }), { session_id: session, owner_asked: { type: "boolean", description: "True only when the owner asked in this conversation for this session to be archived." } }, ["session_id"], write("archives a session in the owner's Copilot app"), async (args, agentRoot) => {
146
177
  const ownerAsked = args.owner_asked === true;
147
178
  const row = await (0, shepherd_cli_1.shepherd)(["session", sessionId(args)]);
148
179
  const archived = await (0, shepherd_cli_1.shepherd)(["archive", String(row.id)], ownerAsked ? { owner_asked: true } : undefined, because(ownerAsked ? `The owner asked Ouroboros to archive ${String(row.name)}` : `Ouroboros archives ${String(row.name)}, which it created or which was handed off`));
@@ -151,8 +182,8 @@ exports.archiveSessionTool = define("archive_session", "Archive a session you cr
151
182
  (0, store_1.addArchiveLog)(agentRoot, { id: String(row.id), name: String(row.name), at: new Date().toISOString(), reason: "owner-asked" });
152
183
  return archived;
153
184
  }, ["session_id"]);
154
- exports.navigateToTool = define("navigate_to", "Show a session in the app's window, as following its app_url does.", { id: session }, ["id"], write("changes what the owner's Copilot app shows"), args => (0, shepherd_cli_1.shepherd)(["open", String(args.id)]), ["id"]);
155
- exports.saveSessionAutomationTool = define("save_session_automation", "Create or replace the automation that wakes a session on a schedule, or clear it. interval is once (run_at), minutes (every_minutes), daily or weekly (schedule_hour, schedule_minute, schedule_day), or cron (cron_expression, five fields, local time).", {
185
+ exports.navigateToTool = define("navigate_to", "Show a session in the app's window, as following its app_url does.", card("navigate_to", "write", "Pick this when the owner wants a particular session brought up on screen in the app's window.", "Give the owner the session's app_url from list_sessions_and_chats instead.", { idempotent: true }), { id: session }, ["id"], write("changes what the owner's Copilot app shows"), args => (0, shepherd_cli_1.shepherd)(["open", String(args.id)]), ["id"]);
186
+ exports.saveSessionAutomationTool = define("save_session_automation", "Create or replace the automation that wakes a session on a schedule, or clear it. interval is once (run_at), minutes (every_minutes), daily or weekly (schedule_hour, schedule_minute, schedule_day), or cron (cron_expression, five fields, local time).", card("save_session_automation", "write", "Pick this to schedule a session to wake with a prompt later or on repeat, or to stop that schedule.", "Read the current schedule with get_session_automation before trying again."), {
156
187
  session_id: session, prompt: { type: "string" }, interval: { type: "string", enum: ["once", "minutes", "daily", "weekly", "cron"] }, run_at: { type: "string" }, every_minutes: { type: "number" },
157
188
  schedule_hour: { type: "number" }, schedule_minute: { type: "number" }, schedule_day: { type: "number" }, cron_expression: { type: "string" }, name: { type: "string" },
158
189
  clear: { type: "boolean", description: "Remove the session's automation instead." },
@@ -160,26 +191,26 @@ exports.saveSessionAutomationTool = define("save_session_automation", "Create or
160
191
  const body = bodyOf(args, "session_id");
161
192
  return (0, shepherd_cli_1.shepherd)(["automation", sessionId(args)], body, because(body ? (args.clear === true ? `Ouroboros clears the wake-ups of session ${short(args.session_id)}` : `Ouroboros schedules a wake-up for session ${short(args.session_id)}`) : `Ouroboros reads the wake-ups of session ${short(args.session_id)}`, args.prompt));
162
193
  }, ["session_id"]);
163
- exports.getSessionAutomationTool = define("get_session_automation", "The automation attached to a session. Read-only.", { session_id: session }, ["session_id"], READ, args => (0, shepherd_cli_1.shepherd)(["automation", sessionId(args)], undefined, because(`Ouroboros reads the wake-ups of session ${short(args.session_id)}`)), ["session_id"]);
164
- exports.listWorkflowsTool = define("list_workflows", "The app's automations (workflows), with their ids and schedules. Read-only.", {}, [], READ, () => (0, shepherd_cli_1.shepherd)(["workflows"]));
165
- exports.runWorkflowTool = define("run_workflow", "Run one of the app's automations now, in a new session.", { id: { type: "string", description: "From list_workflows." } }, ["id"], write("starts a session in the owner's Copilot app"), args => (0, shepherd_cli_1.shepherd)(["run-workflow", String(args.id)], undefined, because(`Ouroboros runs workflow ${String(args.id)}`)), ["id"]);
166
- exports.appSessionsTailTool = define("app_sessions_tail", "A session's last visible prompts and replies, oldest first, with its current name and state and how much of the local log was read. Re-read before reporting current progress: older messages are not live status. Read-only.", { session_id: session, count: { type: "number", description: "How many messages, 1-50. Default 6." } }, ["session_id"], READ, async (args, agentRoot) => {
194
+ exports.getSessionAutomationTool = define("get_session_automation", "The automation attached to a session. Read-only.", card("get_session_automation", "read", "Pick this to check whether and when a session is set to wake on its own, before changing that.", "Check the session id with list_sessions_and_chats and read it again."), { session_id: session }, ["session_id"], READ, args => (0, shepherd_cli_1.shepherd)(["automation", sessionId(args)], undefined, because(`Ouroboros reads the wake-ups of session ${short(args.session_id)}`)), ["session_id"]);
195
+ exports.listWorkflowsTool = define("list_workflows", "The app's automations (workflows), with their ids and schedules. Read-only.", card("list_workflows", "read", "Pick this to find the app's saved automations and their ids before running one with run_workflow.", "Call list_workflows again shortly; say the automations can't be listed if it keeps failing."), {}, [], READ, () => (0, shepherd_cli_1.shepherd)(["workflows"]));
196
+ exports.runWorkflowTool = define("run_workflow", "Run one of the app's automations now, in a new session.", card("run_workflow", "write", "Pick this to start one of the app's saved automations right now in a fresh session.", "Check the id with list_workflows, and look for a session it already started before running it again."), { id: { type: "string", description: "From list_workflows." } }, ["id"], write("starts a session in the owner's Copilot app"), args => (0, shepherd_cli_1.shepherd)(["run-workflow", String(args.id)], undefined, because(`Ouroboros runs workflow ${String(args.id)}`)), ["id"]);
197
+ exports.appSessionsTailTool = define("app_sessions_tail", "A session's last visible prompts and replies, oldest first, with its current name and state and how much of the local log was read. Re-read before reporting current progress: older messages are not live status. Read-only.", card("app_sessions_tail", "read", "Pick this to read what a session said and was asked most recently, before reporting its progress.", "Fall back to get_session for its state, and say the latest messages couldn't be read."), { session_id: session, count: { type: "number", description: "How many messages, 1-50. Default 6." } }, ["session_id"], READ, async (args, agentRoot) => {
167
198
  const history = await (0, shepherd_cli_1.shepherd)(["messages", sessionId(args)], { count: Math.min(50, Math.max(1, Math.trunc(Number(args.count) || 6))) });
168
199
  const watchedName = (0, store_1.readWatches)(agentRoot)[String(history.session_id)]?.name;
169
200
  return { ...history, ...(watchedName && watchedName !== history.name ? { renamed_from: watchedName } : {}) };
170
201
  }, ["session_id"]);
171
- exports.appSessionsRestartTool = define("app_sessions_restart", "Restart the Copilot app and lose no session's work, through Housesitter on this Mac (it restarts the app from outside, as a launchd job). status: the restart in progress or the last one: state, step, start time, result, log. enqueue: start one now; every working session is asked to reach a safe point, the app is quit through its Quit menu (it waits while a person is using the Mac), relaunched, and every session that was working gets a resume message and is checked to have taken a turn. Starting one while another runs is refused. Says so plainly when Housesitter is not on this Mac.", { action: { type: "string", enum: ["status", "enqueue"], description: "Default status." }, why: { type: "string", description: "enqueue: the reason; it completes \"restarted at 11:40 for …\" in the resume message each session gets." } }, [], { mutates: "external_side_effect", risk: "high", reason: "restarts the owner's Copilot app" }, async (args, _agentRoot, ctx) => {
202
+ exports.appSessionsRestartTool = define("app_sessions_restart", "Restart the Copilot app and lose no session's work, through Housesitter on this Mac (it restarts the app from outside, as a launchd job). status: the restart in progress or the last one: state, step, start time, result, log. enqueue: start one now; every working session is asked to reach a safe point, the app is quit through its Quit menu (it waits while a person is using the Mac), relaunched, and every session that was working gets a resume message and is checked to have taken a turn. Starting one while another runs is refused. Says so plainly when Housesitter is not on this Mac.", card("app_sessions_restart", "write", "Pick this when the Copilot app itself is hung or needs restarting; it keeps every session's work and resumes them.", "Call app_sessions_restart with action status to see whether a restart is already running.", { withoutShepherd: true, refusal: { code: "why-required", means: "action enqueue came without a reason.", fix: "Call again with why set to what the restart is for; every session sees it in its resume message." } }), { action: { type: "string", enum: ["status", "enqueue"], description: "Default status." }, why: { type: "string", description: "enqueue: the reason; it completes \"restarted at 11:40 for …\" in the resume message each session gets." } }, [], { mutates: "external_side_effect", risk: "high", reason: "restarts the owner's Copilot app" }, async (args, _agentRoot, ctx) => {
172
203
  if (args.action !== "enqueue")
173
204
  return await (0, client_1.restartStatus)(clientOptions);
174
205
  const why = typeof args.why === "string" ? args.why.trim() : "";
175
206
  if (!why)
176
- throw new Error("say why the app needs a restart; every session is told in its resume message");
207
+ throw new AppSessionsRefusal("why-required", "say why the app needs a restart; every session is told in its resume message");
177
208
  return await (0, client_1.restartEnqueue)(why, ctx.agentName ?? "an agent", clientOptions);
178
209
  }, ["action"]);
179
- exports.appSessionsDigestTool = define("app_sessions_digest", "How everything is going, already worked out with no model: what needs the owner, what is broken, each working session with its card's next step, the Mac's health, the drains and what merged today. Read-only.", {}, [], READ, async (_args, agentRoot) => {
210
+ exports.appSessionsDigestTool = define("app_sessions_digest", "How everything is going, already worked out with no model: what needs the owner, what is broken, each working session with its card's next step, the Mac's health, the drains and what merged today. Read-only.", card("app_sessions_digest", "read", "Pick this for one precomputed picture of how all the work is going, what needs the owner, and what broke.", "Build the picture from get_sessions_status instead.", { withoutShepherd: true, refusal: { code: "no-digest-yet", means: "No status digest exists, because agent.json gives the app-sessions sense no digest block.", fix: "Tell the owner the digest isn't set up; answer from get_sessions_status meanwhile." } }), {}, [], READ, async (_args, agentRoot) => {
180
211
  const digest = (0, digest_1.readDigestText)(agentRoot, Date.now());
181
212
  if (!digest)
182
- throw new Error("no status digest yet: it is built when agent.json gives the app-sessions sense a digest block");
213
+ throw new AppSessionsRefusal("no-digest-yet", "no status digest yet: it is built when agent.json gives the app-sessions sense a digest block");
183
214
  return { digest };
184
215
  });
185
216
  exports.appSessionsToolDefinitions = [
@@ -229,7 +229,7 @@ const initGitHandler = (args) => {
229
229
  });
230
230
  return json({
231
231
  ok: false,
232
- error: "bundle already has a .git directory — pass force: true to re-init",
232
+ error: "bundle already has a .git directory — pass force: true to re-init", code: "already-initialized",
233
233
  alreadyInit: true,
234
234
  });
235
235
  }
@@ -250,7 +250,7 @@ const initGitHandler = (args) => {
250
250
  message: "git init failed",
251
251
  meta: { bundleRoot, ok: false },
252
252
  });
253
- return json({ ok: false, error: `git init failed: ${init.stderr}` });
253
+ return json({ ok: false, error: `git init failed: ${init.stderr}`, code: "git-failed" });
254
254
  }
255
255
  /* v8 ignore stop */
256
256
  }
@@ -296,7 +296,7 @@ const addRemoteHandler = (args) => {
296
296
  return json({ ok, ...payload });
297
297
  };
298
298
  if (!isGitRepo(bundleRoot)) {
299
- return finish(false, { error: "bundle is not a git repo — run bundle_init_git first" });
299
+ return finish(false, { error: "bundle is not a git repo — run bundle_init_git first", code: "not-a-repo" });
300
300
  }
301
301
  if (!REMOTE_URL_PATTERN.test(url)) {
302
302
  (0, runtime_1.emitNervesEvent)({
@@ -306,7 +306,7 @@ const addRemoteHandler = (args) => {
306
306
  message: "bundle_add_remote refused: invalid url",
307
307
  meta: { bundleRoot, url },
308
308
  });
309
- return finish(false, { error: `invalid remote url: ${url || "(empty)"}` });
309
+ return finish(false, { error: `invalid remote url: ${url || "(empty)"}`, code: "invalid-remote-url" });
310
310
  }
311
311
  const existing = getRemoteUrl(bundleRoot, name);
312
312
  if (existing && !force) {
@@ -318,7 +318,7 @@ const addRemoteHandler = (args) => {
318
318
  meta: { bundleRoot, name, existing },
319
319
  });
320
320
  return finish(false, {
321
- error: `remote "${name}" already points to ${existing} — pass force: true to overwrite`,
321
+ error: `remote "${name}" already points to ${existing} — pass force: true to overwrite`, code: "remote-exists",
322
322
  previousUrl: existing,
323
323
  });
324
324
  }
@@ -326,14 +326,14 @@ const addRemoteHandler = (args) => {
326
326
  const setUrl = gitExec(bundleRoot, ["remote", "set-url", name, url]);
327
327
  /* v8 ignore next 3 -- git remote set-url failure requires a permissions/git-state edge case @preserve */
328
328
  if (setUrl.code !== 0) {
329
- return finish(false, { error: `git remote set-url failed: ${setUrl.stderr}` });
329
+ return finish(false, { error: `git remote set-url failed: ${setUrl.stderr}`, code: "git-failed" });
330
330
  }
331
331
  }
332
332
  else {
333
333
  const add = gitExec(bundleRoot, ["remote", "add", name, url]);
334
334
  /* v8 ignore next 3 -- git remote add failure requires a permissions/git-state edge case @preserve */
335
335
  if (add.code !== 0) {
336
- return finish(false, { error: `git remote add failed: ${add.stderr}` });
336
+ return finish(false, { error: `git remote add failed: ${add.stderr}`, code: "git-failed" });
337
337
  }
338
338
  }
339
339
  return finish(true, { name, url, previousUrl: existing ?? null });
@@ -356,15 +356,15 @@ const listFirstCommitHandler = () => {
356
356
  return json({ ok, ...payload });
357
357
  };
358
358
  if (!isGitRepo(bundleRoot)) {
359
- return finish(false, { error: "bundle is not a git repo — run bundle_init_git first" });
359
+ return finish(false, { error: "bundle is not a git repo — run bundle_init_git first", code: "not-a-repo" });
360
360
  }
361
361
  if (hasHead(bundleRoot)) {
362
- return finish(false, { error: "bundle already has commits — bundle_list_first_commit only applies before the first commit" });
362
+ return finish(false, { error: "bundle already has commits — bundle_list_first_commit only applies before the first commit", code: "already-committed" });
363
363
  }
364
364
  const ls = gitExec(bundleRoot, ["ls-files", "-o", "--exclude-standard"]);
365
365
  /* v8 ignore next 3 -- git ls-files failure requires a corrupt repo @preserve */
366
366
  if (ls.code !== 0) {
367
- return finish(false, { error: `git ls-files failed: ${ls.stderr}` });
367
+ return finish(false, { error: `git ls-files failed: ${ls.stderr}`, code: "git-failed" });
368
368
  }
369
369
  const files = ls.stdout
370
370
  .split("\n")
@@ -421,16 +421,16 @@ const doFirstCommitHandler = (args) => {
421
421
  return json({ ok, ...payload });
422
422
  };
423
423
  if (!isGitRepo(bundleRoot)) {
424
- return finish(false, { error: "bundle is not a git repo — run bundle_init_git first" });
424
+ return finish(false, { error: "bundle is not a git repo — run bundle_init_git first", code: "not-a-repo" });
425
425
  }
426
426
  if (hasHead(bundleRoot)) {
427
- return finish(false, { error: "bundle already has commits — first commit already exists" });
427
+ return finish(false, { error: "bundle already has commits — first commit already exists", code: "already-committed" });
428
428
  }
429
429
  // Resolve the file list — either explicit or the default set from ls-files.
430
430
  let filesToStage;
431
431
  if (hasExplicitFiles) {
432
432
  if (!Array.isArray(rawFiles)) {
433
- return finish(false, { error: "files must be an array of relative paths" });
433
+ return finish(false, { error: "files must be an array of relative paths", code: "invalid-files" });
434
434
  }
435
435
  if (rawFiles.length === 0) {
436
436
  // Directive A: explicit enumeration required. Empty list is a refusal.
@@ -441,7 +441,7 @@ const doFirstCommitHandler = (args) => {
441
441
  message: "bundle_do_first_commit refused: empty file list",
442
442
  meta: { bundleRoot },
443
443
  });
444
- return finish(false, { error: "refused: files array must be non-empty — pass explicit file paths or omit the argument to stage everything" });
444
+ return finish(false, { error: "refused: files array must be non-empty — pass explicit file paths or omit the argument to stage everything", code: "invalid-files" });
445
445
  }
446
446
  filesToStage = rawFiles;
447
447
  }
@@ -449,7 +449,7 @@ const doFirstCommitHandler = (args) => {
449
449
  const ls = gitExec(bundleRoot, ["ls-files", "-o", "--exclude-standard"]);
450
450
  /* v8 ignore next 3 -- git ls-files failure requires a corrupt repo @preserve */
451
451
  if (ls.code !== 0) {
452
- return finish(false, { error: `git ls-files failed: ${ls.stderr}` });
452
+ return finish(false, { error: `git ls-files failed: ${ls.stderr}`, code: "git-failed" });
453
453
  }
454
454
  filesToStage = ls.stdout
455
455
  .split("\n")
@@ -458,13 +458,13 @@ const doFirstCommitHandler = (args) => {
458
458
  }
459
459
  /* v8 ignore next 3 -- empty filesToStage on default path means ls-files returned zero entries, covered by the empty-bundle test path elsewhere @preserve */
460
460
  if (filesToStage.length === 0) {
461
- return finish(false, { error: "no files to commit" });
461
+ return finish(false, { error: "no files to commit", code: "nothing-to-commit" });
462
462
  }
463
463
  // Security boundary: every file must resolve inside bundleRoot.
464
464
  for (const file of filesToStage) {
465
465
  /* v8 ignore next 3 -- defensive non-string entry check: LLM tool call args are JSON-parsed, a non-string would already fail JSON schema validation upstream @preserve */
466
466
  if (typeof file !== "string" || file.length === 0) {
467
- return finish(false, { error: `invalid file entry: ${JSON.stringify(file)}` });
467
+ return finish(false, { error: `invalid file entry: ${JSON.stringify(file)}`, code: "invalid-files" });
468
468
  }
469
469
  const check = assertInsideBundle(bundleRoot, file);
470
470
  if (!check.ok) {
@@ -475,19 +475,19 @@ const doFirstCommitHandler = (args) => {
475
475
  message: "bundle_do_first_commit refused: path outside bundle root",
476
476
  meta: { bundleRoot, file },
477
477
  });
478
- return finish(false, { error: check.error });
478
+ return finish(false, { error: check.error, code: "outside-bundle" });
479
479
  }
480
480
  }
481
481
  // Stage via `git add -- <file1> <file2> ...` — explicit enumeration.
482
482
  const add = gitExec(bundleRoot, ["add", "--", ...filesToStage]);
483
483
  /* v8 ignore next 3 -- git add failure on a valid file list requires a corrupt repo or race @preserve */
484
484
  if (add.code !== 0) {
485
- return finish(false, { error: `git add failed: ${add.stderr}` });
485
+ return finish(false, { error: `git add failed: ${add.stderr}`, code: "git-failed" });
486
486
  }
487
487
  const commit = gitExec(bundleRoot, ["commit", "-m", message]);
488
488
  /* v8 ignore next 3 -- git commit failure requires a hook-reject or missing user.email, which createTmpBundle pre-configures @preserve */
489
489
  if (commit.code !== 0) {
490
- return finish(false, { error: `git commit failed: ${commit.stderr}` });
490
+ return finish(false, { error: `git commit failed: ${commit.stderr}`, code: "git-failed" });
491
491
  }
492
492
  const rev = gitExec(bundleRoot, ["rev-parse", "HEAD"]);
493
493
  const commitSha = rev.stdout.trim();
@@ -572,17 +572,17 @@ function makeFirstPushReviewHandler(deps = {}) {
572
572
  return json({ ok, ...payload });
573
573
  };
574
574
  if (!isGitRepo(bundleRoot)) {
575
- return finish(false, { error: "bundle is not a git repo — run bundle_init_git first" });
575
+ return finish(false, { error: "bundle is not a git repo — run bundle_init_git first", code: "not-a-repo" });
576
576
  }
577
577
  const remotes = listRemotes(bundleRoot);
578
578
  if (remotes.length === 0) {
579
- return finish(false, { error: "no remote configured — run bundle_add_remote first" });
579
+ return finish(false, { error: "no remote configured — run bundle_add_remote first", code: "no-remote" });
580
580
  }
581
581
  const remoteName = remotes[0];
582
582
  const remoteUrl = getRemoteUrl(bundleRoot, remoteName);
583
583
  /* v8 ignore next 3 -- listRemotes returned a name but get-url failed; only possible under a git race @preserve */
584
584
  if (!remoteUrl) {
585
- return finish(false, { error: "could not resolve remote url" });
585
+ return finish(false, { error: "could not resolve remote url", code: "git-failed" });
586
586
  }
587
587
  // Enumerate PII directory counts
588
588
  const piiCounts = {};
@@ -712,17 +712,17 @@ function makeSyncHandler(toolName, deps = {}) {
712
712
  message,
713
713
  meta: { bundleRoot, tool: toolName },
714
714
  });
715
- return finish(false, { error, kind: "confirmation_required" });
715
+ return finish(false, { error, kind: "confirmation_required", code: "confirmation-required" });
716
716
  };
717
717
  if (!isGitRepo(bundleRoot)) {
718
- return finish(false, { error: "bundle is not a git repo" });
718
+ return finish(false, { error: "bundle is not a git repo", code: "not-a-repo" });
719
719
  }
720
720
  const remotes = listRemotes(bundleRoot);
721
721
  if (!remotes.includes(remote)) {
722
- return finish(false, { error: `remote "${remote}" not configured — run bundle_add_remote first` });
722
+ return finish(false, { error: `remote "${remote}" not configured — run bundle_add_remote first`, code: "no-remote" });
723
723
  }
724
724
  if (!hasHead(bundleRoot)) {
725
- return finish(false, { error: "bundle has no commits — run bundle_do_first_commit first" });
725
+ return finish(false, { error: "bundle has no commits — run bundle_do_first_commit first", code: "no-commits" });
726
726
  }
727
727
  // Directive D: first push to a remote requires the agent to have
728
728
  // previously called bundle_first_push_review and obtained a
@@ -730,7 +730,7 @@ function makeSyncHandler(toolName, deps = {}) {
730
730
  // "bundle built locally" and "bundle contents on the internet".
731
731
  const probe = await probeFirstPush(bundleRoot, remote, config.branch);
732
732
  if (probe.kind === "unreachable") {
733
- return finish(false, { error: `I couldn't reach GitHub to check whether this would be my first push, so I didn't sync: ${probe.error}`, kind: "remote_unreachable" });
733
+ return finish(false, { error: `I couldn't reach GitHub to check whether this would be my first push, so I didn't sync: ${probe.error}`, kind: "remote_unreachable", code: "remote-unreachable" });
734
734
  }
735
735
  const isFirstPush = probe.kind === "first";
736
736
  if (isFirstPush) {
@@ -757,9 +757,9 @@ function makeSyncHandler(toolName, deps = {}) {
757
757
  const result = await (0, sync_1.syncNow)(bundleRoot, config, agentName, BUNDLE_TOOL_SYNC_WAIT_MS, { firstPushApproved: isFirstPush });
758
758
  const where = { remote, branch: config.branch, firstPush: isFirstPush };
759
759
  if (result.paused)
760
- return finish(false, { ...where, paused: true, pausedUntil: result.pausedUntil, error: `sync paused until ${result.pausedUntil}` });
760
+ return finish(false, { ...where, paused: true, pausedUntil: result.pausedUntil, error: `sync paused until ${result.pausedUntil}`, code: "sync-paused" });
761
761
  if (result.busy)
762
- return finish(false, { ...where, busy: true, holderPid: result.holderPid, error: result.error });
762
+ return finish(false, { ...where, busy: true, holderPid: result.holderPid, error: result.error, code: "sync-busy" });
763
763
  // One-shot: the token is spent once sync actually ran, not on a busy or paused refusal.
764
764
  if (confirmationToken !== undefined && isFirstPush)
765
765
  _confirmationTokens.delete(confirmationToken);
@@ -767,7 +767,7 @@ function makeSyncHandler(toolName, deps = {}) {
767
767
  const failure = readPendingFailure(bundleRoot);
768
768
  return finish(false, {
769
769
  ...where,
770
- error: result.error,
770
+ error: result.error, code: "sync-failed",
771
771
  ...(failure?.classification ? { kind: failure.classification } : {}),
772
772
  ...(failure?.conflictFiles && failure.conflictFiles.length > 0 ? { conflictFiles: failure.conflictFiles } : {}),
773
773
  });
@@ -787,6 +787,21 @@ function readPendingFailure(bundleRoot) {
787
787
  const pushHandler = makeSyncHandler("bundle_push");
788
788
  const pullRebaseHandler = makeSyncHandler("bundle_pull_rebase");
789
789
  // ─── registry ──────────────────────────────────────────────────────────
790
+ const notARepo = (tool) => ({ code: "not-a-repo", means: "My bundle has no .git directory yet.", fix: `Call bundle_init_git, then ${tool} again.` });
791
+ const gitFailed = (tool) => ({ code: "git-failed", means: "A git command failed; the error carries git's own words.", fix: `Fix what git names, or call bundle_check_sync_status to see the state, before ${tool} again.` });
792
+ /** The refusals bundle_push and bundle_pull_rebase share, since both run the same sync. */
793
+ function syncErrors(tool) {
794
+ return [
795
+ notARepo(tool),
796
+ { code: "no-remote", means: "The bundle has no remote of that name.", fix: `Call bundle_add_remote with the owner's repository URL, then ${tool} again.` },
797
+ { code: "no-commits", means: "The bundle has no commits to sync.", fix: `Call bundle_list_first_commit and bundle_do_first_commit, then ${tool} again.` },
798
+ { code: "confirmation-required", means: "This would be the first push, and no valid confirmationToken came with it.", fix: `Call bundle_first_push_review, show the human its warning, and on their yes pass its token to ${tool}.` },
799
+ { code: "remote-unreachable", means: "GitHub couldn't be reached to tell whether this is a first push, so nothing synced.", fix: `Call ${tool} again later; it changed nothing.` },
800
+ { code: "sync-busy", means: "Another sync holds the bundle right now.", fix: `Wait a minute and call ${tool} again.` },
801
+ { code: "sync-paused", means: "Syncing is paused by a pause marker; pausedUntil says until when, and nothing synced.", fix: `Tell the human sync is paused until pausedUntil; don't call ${tool} again before then.` },
802
+ { code: "sync-failed", means: "The sync ran and failed; kind and conflictFiles say how.", fix: "Tell the human what kind and conflictFiles name; for conflicts, fix those files and sync again." },
803
+ ];
804
+ }
790
805
  exports.bundleToolDefinitions = [
791
806
  {
792
807
  tool: {
@@ -797,7 +812,13 @@ exports.bundleToolDefinitions = [
797
812
  parameters: { type: "object", properties: {} },
798
813
  },
799
814
  },
815
+ ax: {
816
+ id: "tool:bundle_check_sync_status", group: "turn-bundle", effect: "read",
817
+ when: "Pick this first whenever the turn packet flags a bundleState issue, to see which bundle_ fix comes next.",
818
+ errors: [{ code: "tool-changed", means: "The tools for this turn changed before the check ran, so it read nothing.", fix: "Check the current tool list; call bundle_check_sync_status again only if it is still there." }],
819
+ },
800
820
  handler: checkSyncStatusHandler,
821
+ riskProfile: { mutates: "none", risk: "low" },
801
822
  },
802
823
  {
803
824
  tool: {
@@ -813,6 +834,14 @@ exports.bundleToolDefinitions = [
813
834
  },
814
835
  },
815
836
  },
837
+ ax: {
838
+ id: "tool:bundle_init_git", group: "turn-bundle", effect: "write",
839
+ when: "Pick this when bundle_check_sync_status says my bundle isn't a git repository yet; force only with the human's yes.",
840
+ errors: [
841
+ { code: "already-initialized", means: "The bundle already has a .git directory, so nothing changed.", fix: "Go on with bundle_add_remote; pass force: true only if the human asks to re-run git init." },
842
+ gitFailed("bundle_init_git"),
843
+ ],
844
+ },
816
845
  handler: initGitHandler,
817
846
  riskProfile: { mutates: "durable_state_write", risk: "high", reason: "initializes bundle git state" },
818
847
  },
@@ -833,6 +862,16 @@ exports.bundleToolDefinitions = [
833
862
  },
834
863
  },
835
864
  },
865
+ ax: {
866
+ id: "tool:bundle_add_remote", group: "turn-bundle", effect: "write",
867
+ when: "Pick this once my bundle is a repository and needs the owner's backup repository to sync with.",
868
+ errors: [
869
+ notARepo("bundle_add_remote"),
870
+ { code: "invalid-remote-url", means: "url isn't an https:// or git@ address.", fix: "Ask the human for the repository's https or SSH URL and pass it exactly." },
871
+ { code: "remote-exists", means: "A remote with that name already points somewhere else; previousUrl says where.", fix: "Show the human both URLs; pass force: true only if they say to replace it." },
872
+ gitFailed("bundle_add_remote"),
873
+ ],
874
+ },
836
875
  handler: addRemoteHandler,
837
876
  riskProfile: { mutates: "durable_state_write", risk: "high", reason: "updates bundle git remote configuration" },
838
877
  },
@@ -845,7 +884,17 @@ exports.bundleToolDefinitions = [
845
884
  parameters: { type: "object", properties: {} },
846
885
  },
847
886
  },
887
+ ax: {
888
+ id: "tool:bundle_list_first_commit", group: "turn-bundle", effect: "read",
889
+ when: "Pick this before bundle_do_first_commit, to show the human exactly which files the very first commit would take.",
890
+ errors: [
891
+ notARepo("bundle_list_first_commit"),
892
+ { code: "already-committed", means: "The bundle already has commits, so there is no first commit to plan.", fix: "Call bundle_check_sync_status; ordinary changes sync with bundle_push." },
893
+ gitFailed("bundle_list_first_commit"),
894
+ ],
895
+ },
848
896
  handler: listFirstCommitHandler,
897
+ riskProfile: { mutates: "none", risk: "low" },
849
898
  },
850
899
  {
851
900
  tool: {
@@ -862,6 +911,18 @@ exports.bundleToolDefinitions = [
862
911
  },
863
912
  },
864
913
  },
914
+ ax: {
915
+ id: "tool:bundle_do_first_commit", group: "turn-bundle", effect: "write",
916
+ when: "Pick this after the human has seen bundle_list_first_commit's list and agreed, to record the bundle's very first commit.",
917
+ errors: [
918
+ notARepo("bundle_do_first_commit"),
919
+ { code: "already-committed", means: "The bundle already has a first commit.", fix: "Skip this step; go on with bundle_first_push_review and bundle_push." },
920
+ { code: "invalid-files", means: "files is empty, isn't a list of path strings, or holds a bad entry.", fix: "Pass relative paths from bundle_list_first_commit, or omit files to stage that whole list." },
921
+ { code: "outside-bundle", means: "A path in files leads outside the bundle, so nothing was staged.", fix: "Pass only paths inside the bundle, as bundle_list_first_commit shows them." },
922
+ { code: "nothing-to-commit", means: "There are no files to commit.", fix: "Call bundle_list_first_commit to check; if it is empty, there is nothing to do." },
923
+ gitFailed("bundle_do_first_commit"),
924
+ ],
925
+ },
865
926
  handler: doFirstCommitHandler,
866
927
  riskProfile: { mutates: "durable_state_write", risk: "high", reason: "creates a bundle git commit" },
867
928
  },
@@ -874,6 +935,15 @@ exports.bundleToolDefinitions = [
874
935
  parameters: { type: "object", properties: {} },
875
936
  },
876
937
  },
938
+ ax: {
939
+ id: "tool:bundle_first_push_review", group: "turn-bundle", effect: "write",
940
+ when: "Pick this before the first sync to a new remote: it shows the human what private records would leave this machine.",
941
+ errors: [
942
+ notARepo("bundle_first_push_review"),
943
+ { code: "no-remote", means: "The bundle has no remote yet, so there is nothing to review a push to.", fix: "Call bundle_add_remote with the owner's repository URL, then review again." },
944
+ gitFailed("bundle_first_push_review"),
945
+ ],
946
+ },
877
947
  handler: firstPushReviewHandler,
878
948
  },
879
949
  {
@@ -890,6 +960,11 @@ exports.bundleToolDefinitions = [
890
960
  },
891
961
  },
892
962
  },
963
+ ax: {
964
+ id: "tool:bundle_push", group: "turn-bundle", effect: "write",
965
+ when: "Pick this to send my bundle's new commits to its remote; it runs the same merge-only sync as bundle_pull_rebase.",
966
+ errors: syncErrors("bundle_push"),
967
+ },
893
968
  handler: pushHandler,
894
969
  riskProfile: { mutates: "external_side_effect", risk: "high", reason: "pushes bundle state to a remote" },
895
970
  },
@@ -907,6 +982,11 @@ exports.bundleToolDefinitions = [
907
982
  },
908
983
  },
909
984
  },
985
+ ax: {
986
+ id: "tool:bundle_pull_rebase", group: "turn-bundle", effect: "write",
987
+ when: "Pick this to bring the remote's changes into my bundle; despite its name it merges, the same sync bundle_push runs.",
988
+ errors: syncErrors("bundle_pull_rebase"),
989
+ },
910
990
  handler: pullRebaseHandler,
911
991
  riskProfile: {
912
992
  mutates: ["durable_state_write", "external_side_effect"],
@@ -68,16 +68,26 @@ async function targetFor(ctx, args) {
68
68
  (0, target_binding_1.assertBoundShepherdTarget)(ctx.currentShepherdSurface, found.id, host.name);
69
69
  return { target: live.find(t => t.session === found.id), live };
70
70
  }
71
- function definition(name, description, properties, required, run, mutates = false) {
71
+ /** A guidance tool's card: the family gate every one shares, then its own failure and what to do about it. */
72
+ function card(name, when, failed, mutates = false) {
73
+ const errors = [
74
+ { code: "family-only", means: "The person in this conversation isn't a real family member, so Shepherd's private guidance stays closed.", fix: `Tell them ${name} is only for the family; change nothing.` },
75
+ { code: "no-agent-runtime", means: "The call ran outside an agent's runtime, so there is no guidance store to use.", fix: `Don't retry; report that ${name} was called without an agent runtime.` },
76
+ { code: "guidance-failed", ...failed },
77
+ ];
78
+ return { id: `tool:${name}`, group: "turn-shepherd", when, effect: mutates ? "write" : "read", errors, ...(mutates ? { idempotent: true } : {}) };
79
+ }
80
+ function definition(name, description, ax, properties, required, run, mutates = false) {
72
81
  return {
73
82
  tool: { type: "function", function: { name, description, parameters: { type: "object", properties, required, additionalProperties: false } } },
83
+ ax,
74
84
  handler: async (args, ctx) => {
75
85
  // Same real-family gate as shepherd_send, including rejection of the private runtime's family self.
76
86
  const friend = ctx?.context?.friend;
77
87
  if (!friend || friend.trustLevel !== "family" || !friend.id || friend.id === tools_base_1.SELF_FRIEND_ID)
78
- return json({ error: "Shepherd private guidance is only for a real family member in this conversation" });
88
+ return json({ error: "Shepherd private guidance is only for a real family member in this conversation", code: "family-only" });
79
89
  if (!ctx?.agentRoot || !ctx.agentName)
80
- return json({ error: "Shepherd guidance needs an agent runtime" });
90
+ return json({ error: "Shepherd guidance needs an agent runtime", code: "no-agent-runtime" });
81
91
  try {
82
92
  const boundDefault = name === "shepherd_correct" && !text(args.session) && !text(args.return_id) && ctx.currentShepherdSurface;
83
93
  const request = { actorId: friend.id, requestId: text(args.request_id), requestFingerprint: fingerprint(name, boundDefault ? { ...args, session: boundDefault.id, host: boundDefault.host } : args) };
@@ -96,7 +106,7 @@ function definition(name, description, properties, required, run, mutates = fals
96
106
  catch (error) {
97
107
  const message = (0, redact_1.redactSecrets)(error instanceof Error ? error.message : String(error));
98
108
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "repertoire.shepherd_guidance_tool_error", message: "private Shepherd guidance tool failed", meta: { tool: name, error: "private_guidance_operation_failed" } });
99
- return json({ error: message });
109
+ return json({ error: message, code: "guidance-failed" });
100
110
  }
101
111
  },
102
112
  summaryKeys: [],
@@ -104,7 +114,7 @@ function definition(name, description, properties, required, run, mutates = fals
104
114
  };
105
115
  }
106
116
  exports.shepherdGuidanceToolDefinitions = [
107
- definition("shepherd_history", "Read private Shepherd return history with stable return IDs, actual judgment/reply/outcome and your own ownerNotice receipts when tracked. Historical, not current status; a vanished terminal remains readable. The session filter is a stable ID, not a short ref. Use to understand 'that was wrong because...' before correcting it, or to check whether a notice was sent. Use displayId as the human-facing return label; never invent a shortened ID suffix. Mutations require the exact full id, not displayId. ownerNotice.state sent means transport acceptance, not proof the human read it; pending awaits a safe retry; unknown may already have arrived and must not be blindly replayed. messageId is the activity ID returned by transport. ownerNotice null means no receipt recorded for this recipient, not proof of non-delivery. ownerNoticeError explicitly identifies unavailable receipt evidence. Never types into a terminal.", targetProperties, [], async (args, ctx, request) => {
117
+ definition("shepherd_history", "Read private Shepherd return history with stable return IDs, actual judgment/reply/outcome and your own ownerNotice receipts when tracked. Historical, not current status; a vanished terminal remains readable. The session filter is a stable ID, not a short ref. Use to understand 'that was wrong because...' before correcting it, or to check whether a notice was sent. Use displayId as the human-facing return label; never invent a shortened ID suffix. Mutations require the exact full id, not displayId. ownerNotice.state sent means transport acceptance, not proof the human read it; pending awaits a safe retry; unknown may already have arrived and must not be blindly replayed. messageId is the activity ID returned by transport. ownerNotice null means no receipt recorded for this recipient, not proof of non-delivery. ownerNoticeError explicitly identifies unavailable receipt evidence. Never types into a terminal.", card("shepherd_history", "Pick this to look back at what Shepherd judged and replied in a session, even one that closed, before anyone corrects it.", { means: "The history couldn't be read; the error says why, such as a session not bound to this chat.", fix: "Drop the session filter, or use the stable id from an earlier shepherd_history, and call again." }), targetProperties, [], async (args, ctx, request) => {
108
118
  const session = text(args.session) || ctx.currentShepherdSurface?.id;
109
119
  const host = text(args.host) || ctx.currentShepherdSurface?.host;
110
120
  if (session)
@@ -130,7 +140,7 @@ exports.shepherdGuidanceToolDefinitions = [
130
140
  return { returns, ownerNoticeError: message };
131
141
  }
132
142
  }),
133
- definition("shepherd_correct", "Record the human's post-action correction ('that was wrong because…') or prospective instruction. Optionally learn a principle for 'in future…'. A return_id must name a real history entry; omit it for a prospective instruction, never fabricate one. Session scope is the default; project is the exact recorded folder and optional task; global only when the human deliberately generalizes. Feedback <=2000 characters; principle <=1000; at most 20 active rules. This is not an approval gate and never sends anything. For requested immediate steering use existing shepherd_send.", {
143
+ definition("shepherd_correct", "Record the human's post-action correction ('that was wrong because…') or prospective instruction. Optionally learn a principle for 'in future…'. A return_id must name a real history entry; omit it for a prospective instruction, never fabricate one. Session scope is the default; project is the exact recorded folder and optional task; global only when the human deliberately generalizes. Feedback <=2000 characters; principle <=1000; at most 20 active rules. This is not an approval gate and never sends anything. For requested immediate steering use existing shepherd_send.", card("shepherd_correct", "Pick this when the human says Shepherd got something wrong or tells it how to behave next time; shepherd_send steers now.", { means: "Nothing was recorded; the error says why: an unknown return_id or session, a reused request_id, or text over its limit.", fix: "Fix what the error names (take ids from shepherd_history) and call again with a new request_id." }, true), {
134
144
  ...targetProperties, ...requestProperty,
135
145
  return_id: stringProperty("Real stable return ID from shepherd_history, if correcting an actual judgment."),
136
146
  feedback: stringProperty("The human's explanation or prospective instruction, at most 2000 characters."),
@@ -145,7 +155,7 @@ exports.shepherdGuidanceToolDefinitions = [
145
155
  ...(args.scope !== undefined ? { scope: args.scope } : {}),
146
156
  }, live);
147
157
  }, true),
148
- definition("shepherd_guidance", "Inspect what Shepherd learned ('what did you learn?'). With a session, returns revision, pause and applicable active principles with IDs, scopes and operator provenance. Omit session to inspect all active principles and pauses, including their exact targets. No send.", targetProperties, [], async (args, ctx) => {
158
+ definition("shepherd_guidance", "Inspect what Shepherd learned ('what did you learn?'). With a session, returns revision, pause and applicable active principles with IDs, scopes and operator provenance. Omit session to inspect all active principles and pauses, including their exact targets. No send.", card("shepherd_guidance", "Pick this when the human asks what Shepherd has learned, or before you change or forget one of its preferences.", { means: "The guidance for that target couldn't be read; the error says why, such as an unknown session.", fix: "Call again without session to see every active principle and pause." }), targetProperties, [], async (args, ctx) => {
149
159
  if (args.session === undefined && !ctx.currentShepherdSurface) {
150
160
  const state = (0, guidance_1.readGuidance)(ctx.agentRoot);
151
161
  return { revision: state.revision, principles: state.principles.filter(p => p.active), pauses: state.pauses.filter(p => p.paused) };
@@ -153,18 +163,20 @@ exports.shepherdGuidanceToolDefinitions = [
153
163
  const { target } = await targetFor(ctx, args);
154
164
  return (0, guidance_1.applicableGuidance)((0, guidance_1.readGuidance)(ctx.agentRoot), target);
155
165
  }),
156
- definition("shepherd_update_principle", "Change a learned preference ('change that') by its principle ID. Keeps its existing scope, never silently generalizes it. No send.", {
166
+ definition("shepherd_update_principle", "Change a learned preference ('change that') by its principle ID. Keeps its existing scope, never silently generalizes it. No send.", card("shepherd_update_principle", "Pick this when the human wants a preference Shepherd already holds reworded; for a new one use shepherd_correct.", { means: "The preference wasn't changed; the error says why: an unknown or inactive principle_id, empty or long text, or a reused request_id.", fix: "Take the id from shepherd_guidance, keep text under 1000 characters, and call with a new request_id." }, true), {
157
167
  ...requestProperty, principle_id: stringProperty("Active principle ID from shepherd_guidance."), text: stringProperty("Replacement preference, nonempty and at most 1000 characters."),
158
168
  }, ["request_id", "principle_id", "text"], async (args, ctx, request) => (0, guidance_1.updateShepherdPrinciple)(ctx.agentRoot, {
159
169
  ...request, principleId: text(args.principle_id), text: typeof args.text === "string" ? args.text : "",
160
170
  }), true),
161
- definition("shepherd_forget_principle", "Forget a learned preference ('forget that') by its ID. Removes only that preference from future judgments but retains the private operator trail. Built-in judgment policy, including legitimate outside dependency waits, and all existing guards remain unchanged: forgetting does not make dependency waits premature or delivered done. No send.", {
171
+ definition("shepherd_forget_principle", "Forget a learned preference ('forget that') by its ID. Removes only that preference from future judgments but retains the private operator trail. Built-in judgment policy, including legitimate outside dependency waits, and all existing guards remain unchanged: forgetting does not make dependency waits premature or delivered done. No send.", card("shepherd_forget_principle", "Pick this when the human wants Shepherd to drop a learned preference entirely, keeping the record of who set it.", { means: "Nothing was forgotten; the error says why: an unknown or inactive principle_id, or a reused request_id.", fix: "Take the principle id from shepherd_guidance and call again with a new request_id." }, true), {
162
172
  ...requestProperty, principle_id: stringProperty("Active principle ID from shepherd_guidance."),
163
173
  }, ["request_id", "principle_id"], async (args, ctx, request) => (0, guidance_1.forgetShepherdPrinciple)(ctx.agentRoot, {
164
174
  ...request, principleId: text(args.principle_id),
165
175
  }), true),
166
176
  ...["pause", "resume"].map(action => definition(`shepherd_${action}`, action === "pause" ? "Leave this one alone: pause automatic Shepherd replies for this session only, durably. Independent judgment/owner notices remain. Never interrupts or types into the terminal."
167
- : "Resume automatic Shepherd replies for this paused session. All focus, screen, syntax and loop guards still apply; resume is not an immediate send.", { ...targetProperties, ...requestProperty }, ["session", "request_id"], async (args, ctx, request) => {
177
+ : "Resume automatic Shepherd replies for this paused session. All focus, screen, syntax and loop guards still apply; resume is not an immediate send.", action === "pause"
178
+ ? card("shepherd_pause", "Pick this when the human says to leave one session alone, so Shepherd stops answering it until resumed.", { means: "The session wasn't paused; the error says why, such as an unknown session or a reused request_id.", fix: "Name the session from shepherd_overview or shepherd_history and call with a new request_id." }, true)
179
+ : card("shepherd_resume", "Pick this when the human wants Shepherd answering a session it was told to leave alone again.", { means: "The session wasn't resumed; the error says why, such as an unknown session or a reused request_id.", fix: "Check the paused session's id with shepherd_guidance and call with a new request_id." }, true), { ...targetProperties, ...requestProperty }, ["session", "request_id"], async (args, ctx, request) => {
168
180
  const { target, live } = await targetFor(ctx, args);
169
181
  return (0, guidance_1.setShepherdSessionPause)(ctx.agentRoot, { ...request, target, paused: action === "pause" }, live);
170
182
  }, true)),
@@ -85,10 +85,10 @@ function hostFor(agentName) {
85
85
  }
86
86
  async function withHost(tool, ctx, run) {
87
87
  if (!ctx?.agentName || !ctx.agentRoot)
88
- return JSON.stringify({ error: "the Shepherd tools need an agent runtime" });
88
+ return JSON.stringify({ error: "the Shepherd tools need an agent runtime", code: "no-agent-runtime" });
89
89
  const host = hostFor(ctx.agentName);
90
90
  if (typeof host === "string")
91
- return JSON.stringify({ error: host });
91
+ return JSON.stringify({ error: host, code: "host-unconfigured" });
92
92
  try {
93
93
  if (ctx.currentShepherdSurface) {
94
94
  const bound = ctx.currentShepherdSurface;
@@ -102,9 +102,17 @@ async function withHost(tool, ctx, run) {
102
102
  }
103
103
  catch (error) {
104
104
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "repertoire.shepherd_tool_error", message: "Shepherd tool call failed", meta: { tool, error: error.message } });
105
- return JSON.stringify({ error: error.message });
105
+ return JSON.stringify({ error: error.message, code: "host-failed" });
106
106
  }
107
107
  }
108
+ /** The errors every Shepherd terminal tool can end with, from `withHost`; `tool` is named in each fix. */
109
+ function hostErrors(tool, retry) {
110
+ return [
111
+ { code: "no-agent-runtime", means: "The call ran outside an agent's runtime, so there is no terminal host to ask.", fix: `Don't retry; report that ${tool} was called without an agent runtime.` },
112
+ { code: "host-unconfigured", means: "This machine has no Shepherd terminal host connection set up for the agent.", fix: `Tell the human Shepherd isn't connected here; ${tool} works once it is.` },
113
+ { code: "host-failed", means: "The terminal host refused or failed the call; the error says why (often a session that is gone or not bound to this chat).", fix: retry },
114
+ ];
115
+ }
108
116
  async function currentScreen(host, session, maxChars) {
109
117
  try {
110
118
  const raw = await host.read(session, OVERVIEW_READ_LINES);
@@ -144,6 +152,11 @@ exports.shepherdOverviewToolDefinition = {
144
152
  })),
145
153
  };
146
154
  }),
155
+ ax: {
156
+ id: "tool:shepherd_overview", group: "turn-shepherd", effect: "read",
157
+ when: "Pick this first when asked what the coding agents on this machine are doing; it covers every terminal in one call.",
158
+ errors: hostErrors("shepherd_overview", "Say which part failed, then call shepherd_overview once more; don't guess the missing rows."),
159
+ },
147
160
  summaryKeys: [],
148
161
  riskProfile: { mutates: "none", risk: "low" },
149
162
  };
@@ -171,7 +184,7 @@ exports.shepherdReadToolDefinition = {
171
184
  handler: (args, ctx) => {
172
185
  const session = text(args.session).trim();
173
186
  if (!session)
174
- return Promise.resolve(JSON.stringify({ error: "name a session id or ref from shepherd_overview" }));
187
+ return Promise.resolve(JSON.stringify({ error: "name a session id or ref from shepherd_overview", code: "session-required" }));
175
188
  return withHost("shepherd_read", ctx, async (host) => {
176
189
  (0, target_binding_1.assertBoundShepherdTarget)(ctx?.currentShepherdSurface, session, host.name);
177
190
  const lines = boundedLines(args.lines);
@@ -181,6 +194,14 @@ exports.shepherdReadToolDefinition = {
181
194
  return { session, text: screen.slice(-READ_MAX_CHARS), truncated: screen.length > READ_MAX_CHARS, screen: (0, redact_1.screenFingerprint)(raw) };
182
195
  });
183
196
  },
197
+ ax: {
198
+ id: "tool:shepherd_read", group: "turn-shepherd", effect: "read",
199
+ when: "Pick this to look closely at one terminal after shepherd_overview, and always just before pressing a choosing key with shepherd_send.",
200
+ errors: [
201
+ { code: "session-required", means: "No session id or ref was given.", fix: "Take the session's ref (surface:12) from shepherd_overview and pass it as session." },
202
+ ...hostErrors("shepherd_read", "Call shepherd_overview to see whether that terminal still exists, then read the one it lists."),
203
+ ],
204
+ },
184
205
  summaryKeys: ["session"],
185
206
  riskProfile: { mutates: "none", risk: "low" },
186
207
  };
@@ -208,21 +229,30 @@ exports.shepherdSignalToolDefinition = {
208
229
  const status = text(args.status).trim();
209
230
  const title = text(args.notify_title).trim();
210
231
  if (!session)
211
- return Promise.resolve(JSON.stringify({ error: "name a session id or ref from shepherd_overview" }));
232
+ return Promise.resolve(JSON.stringify({ error: "name a session id or ref from shepherd_overview", code: "session-required" }));
212
233
  if (status.length > STATUS_MAX_CHARS || /[\r\n]/.test(status))
213
- return Promise.resolve(JSON.stringify({ error: `status must be one line of at most ${STATUS_MAX_CHARS} characters` }));
234
+ return Promise.resolve(JSON.stringify({ error: `status must be one line of at most ${STATUS_MAX_CHARS} characters`, code: "status-too-long" }));
214
235
  return withHost("shepherd_signal", ctx, async (host) => {
215
236
  (0, target_binding_1.assertBoundShepherdTarget)(ctx?.currentShepherdSurface, session, host.name);
216
237
  await host.signal(session, status || null, title ? { title, body: text(args.notify_body) } : undefined);
217
238
  return { session, status: status ? "set" : "cleared", notified: !!title };
218
239
  });
219
240
  },
241
+ ax: {
242
+ id: "tool:shepherd_signal", group: "turn-shepherd", effect: "write",
243
+ when: "Pick this to leave the human a status line or desktop alert beside a terminal without typing into it; shepherd_send types.",
244
+ errors: [
245
+ { code: "session-required", means: "No session id or ref was given.", fix: "Pass the ref from shepherd_overview of the terminal the status belongs to." },
246
+ { code: "status-too-long", means: `status is longer than ${STATUS_MAX_CHARS} characters or has a line break.`, fix: `Shorten status to one line of at most ${STATUS_MAX_CHARS} characters; put detail in notify_body.` },
247
+ ...hostErrors("shepherd_signal", "Call shepherd_overview and signal a terminal it still lists."),
248
+ ],
249
+ },
220
250
  summaryKeys: ["session", "status"],
221
251
  riskProfile: { mutates: "external_side_effect", risk: "high", reason: "changes what the terminal host shows the human (a status line or a desktop notification)" },
222
252
  };
223
- function refused(reason, meta) {
253
+ function refused(reason, code, meta) {
224
254
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "repertoire.shepherd_send_refused", message: "refused to type into a terminal", meta: { ...meta, reason } });
225
- return { error: reason };
255
+ return { error: reason, code };
226
256
  }
227
257
  exports.shepherdSendToolDefinition = {
228
258
  tool: {
@@ -250,31 +280,31 @@ exports.shepherdSendToolDefinition = {
250
280
  const seen = text(args.screen).trim();
251
281
  const friend = ctx?.context?.friend;
252
282
  const meta = { session, chars: line.length, key: key || null, friendId: friend?.id ?? null };
253
- const refuse = (reason) => Promise.resolve(JSON.stringify(refused(reason, meta)));
283
+ const refuse = (reason, code) => Promise.resolve(JSON.stringify(refused(reason, code, meta)));
254
284
  // The private runtime talks to itself as a family "friend"; only a real family member's request may type.
255
285
  if (!friend || friend.trustLevel !== "family" || friend.id === tools_base_1.SELF_FRIEND_ID)
256
- return refuse("shepherd_send types only for a family member who asked for it in this conversation");
286
+ return refuse("shepherd_send types only for a family member who asked for it in this conversation", "family-only");
257
287
  if (!session)
258
- return refuse("name a session id or ref from shepherd_overview");
288
+ return refuse("name a session id or ref from shepherd_overview", "session-required");
259
289
  if (!line === !key)
260
- return refuse("give exactly one of text or key");
290
+ return refuse("give exactly one of text or key", "text-or-key");
261
291
  if (key && !exports.SEND_KEYS.includes(key))
262
- return refuse(`key must be one of ${exports.SEND_KEYS.join(", ")}`);
292
+ return refuse(`key must be one of ${exports.SEND_KEYS.join(", ")}`, "text-or-key");
263
293
  if (line.length > exports.SEND_TEXT_MAX_CHARS)
264
- return refuse(`text must be at most ${exports.SEND_TEXT_MAX_CHARS} characters`);
294
+ return refuse(`text must be at most ${exports.SEND_TEXT_MAX_CHARS} characters`, "text-or-key");
265
295
  if (/[\p{Cc}\u2028\u2029]/u.test(line))
266
- return refuse("text must be one line with no control characters; press enter, escape or ctrl-c with key");
296
+ return refuse("text must be one line with no control characters; press enter, escape or ctrl-c with key", "text-or-key");
267
297
  if (CHOOSING_KEYS.has(key) && !seen)
268
- return refuse(`${key} can approve or choose on a prompt, so pass screen from a shepherd_read made just before`);
298
+ return refuse(`${key} can approve or choose on a prompt, so pass screen from a shepherd_read made just before`, "screen-required");
269
299
  return withHost("shepherd_send", ctx, async (host) => {
270
300
  (0, target_binding_1.assertBoundShepherdTarget)(ctx?.currentShepherdSurface, session, host.name);
271
301
  const target = (await host.list()).find((entry) => entry.id === session || entry.ref === session);
272
302
  if (!target)
273
- return refused(`session ${session} is gone; check shepherd_overview`, meta);
303
+ return refused(`session ${session} is gone; check shepherd_overview`, "session-gone", meta);
274
304
  // Read again right before typing, as Shepherd does before its own answers: a gone or changed screen gets nothing.
275
305
  const now = (0, redact_1.screenFingerprint)(await host.read(target.id, redact_1.FINGERPRINT_READ_LINES));
276
306
  if (seen && seen !== now)
277
- return refused("the terminal changed since it was read, so nothing was sent; read it again", meta);
307
+ return refused("the terminal changed since it was read, so nothing was sent; read it again", "screen-changed", meta);
278
308
  const label = `[${(0, agent_presentation_1.readAgentPresentation)(ctx.agentName, ctx.agentRoot).name} for ${friend.name}]`;
279
309
  // The agent sometimes writes the label itself; type it once.
280
310
  const typed = key ? null : `${label} ${line.toLowerCase().startsWith(label.toLowerCase()) ? line.slice(label.length).trimStart() : line}`;
@@ -300,7 +330,7 @@ exports.shepherdSendToolDefinition = {
300
330
  meta: { ...meta, session: target.id, ref: target.ref, instance: target.instance ?? null, attemptId, attemptedAt, error: message },
301
331
  });
302
332
  return {
303
- error: message, session: target.ref, attempted: input,
333
+ error: message, code: "submission-unknown", session: target.ref, attempted: input,
304
334
  submission: { state: "unknown", attemptId, attemptedAt, reportedAt: new Date().toISOString(), target: receiptTarget },
305
335
  verification, retry,
306
336
  };
@@ -319,6 +349,20 @@ exports.shepherdSendToolDefinition = {
319
349
  };
320
350
  });
321
351
  },
352
+ ax: {
353
+ id: "tool:shepherd_send", group: "turn-shepherd", effect: "write",
354
+ when: "Pick this when a family member replies to a Shepherd prompt with a go-ahead, a correction or a stop meant for that coding session.",
355
+ errors: [
356
+ { code: "family-only", means: "The person in this conversation isn't a family member, so nothing is typed for them.", fix: "Tell them you can't type into terminals for them, and send nothing." },
357
+ { code: "text-or-key", means: "The call gave both text and key or neither, a key outside the list, or text that is too long or has control characters.", fix: "Send exactly one: a one-line text, or one key from the list (enter, escape and ctrl-c go as key)." },
358
+ { code: "screen-required", means: "A choosing key (enter, tab, a digit, y or n) came without screen.", fix: "Call shepherd_read on that session and pass its screen value with the key." },
359
+ { code: "screen-changed", means: "The terminal changed since your read, so nothing was typed.", fix: "Call shepherd_read again, check the prompt is still the one the human answered, then send." },
360
+ { code: "submission-unknown", means: "The host failed partway, so the input may or may not have arrived.", fix: "Don't resend; call shepherd_read to see whether it landed, and tell the human it's unverified." },
361
+ { code: "session-required", means: "No session id or ref was given.", fix: "Pass the ref from shepherd_overview of the terminal the human means." },
362
+ { code: "session-gone", means: "That terminal no longer exists, so nothing was typed.", fix: "Call shepherd_overview, and ask the human which listed terminal they meant." },
363
+ ...hostErrors("shepherd_send", "Nothing was typed; call shepherd_overview and shepherd_read before trying again."),
364
+ ],
365
+ },
322
366
  summaryKeys: ["session", "key"],
323
367
  riskProfile: { mutates: "external_side_effect", risk: "high", reason: "types into a coding agent's terminal for the human, which can answer or approve its prompts" },
324
368
  };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1314",
3
+ "version": "0.1.0-alpha.1315",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1314",
9
+ "version": "0.1.0-alpha.1315",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1314",
3
+ "version": "0.1.0-alpha.1315",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },