@ouro.bot/cli 0.1.0-alpha.1313 → 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,18 @@
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
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1314",
12
+ "changes": [
13
+ "The Sanctuary tools now carry Ouro AX cards, and their failures end with the code a card names."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1313",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1313",
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.1313</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"],