@ouro.bot/cli 0.1.0-alpha.1144 → 0.1.0-alpha.1146

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.1146",
6
+ "changes": [
7
+ "The app-sessions tools are now the GitHub Copilot app's own client tools (list_sessions_and_chats, get_sessions_status, get_session, send_session_message, create_session, answer_session_input, respond_to_session_plan_v2, archive_session, navigate_to, save_session_automation, get_session_automation, list_workflows, run_workflow), sent over the app's local WebSocket as the app's sessions do, so Ouroboros coordinates sessions the way a coordinating session does. The shepherd's Copilot-app host, the app's database and repository-trust reads, and the old app_sessions_list/send/new/resume/archive/watch tools are gone."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1145",
12
+ "changes": [
13
+ "The app-sessions sense now flags any Copilot app session whose history passes 500 MB, because the app loads a whole history into memory whenever it resumes that session, and several multi-GB ones froze a Mac. It asks the session's coordinator (or the session itself) once, with no model turn, to hand off to a fresh successor and to keep images out of chat, and records the session as never-resume."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1144",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1144",
2
+ "runtimeVersion": "0.1.0-alpha.1146",
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.1144</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1146</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -89,7 +89,7 @@ function parseShepherdOperation(args) {
89
89
  const common = { agent, ...(values.has("json") ? { json: true } : {}) };
90
90
  const host = () => {
91
91
  const value = required("host");
92
- return value === "cmux" || value === "herdr" || value === "copilot-app" ? value : fail();
92
+ return value === "cmux" || value === "herdr" ? value : fail();
93
93
  };
94
94
  if (operation === "status")
95
95
  return { kind: "shepherd.status", ...common };
@@ -37,7 +37,6 @@ exports.shepherdRepairHint = shepherdRepairHint;
37
37
  exports.shepherdConfigFacts = shepherdConfigFacts;
38
38
  exports.shepherdSenseStatus = shepherdSenseStatus;
39
39
  exports.defaultHerdrSocketPath = defaultHerdrSocketPath;
40
- exports.defaultCopilotAppStateDir = defaultCopilotAppStateDir;
41
40
  exports.defaultCmuxSocketPath = defaultCmuxSocketPath;
42
41
  exports.resolveShepherdConnection = resolveShepherdConnection;
43
42
  const fs = __importStar(require("node:fs"));
@@ -45,7 +44,7 @@ const os = __importStar(require("node:os"));
45
44
  const path = __importStar(require("node:path"));
46
45
  const runtime_1 = require("../nerves/runtime");
47
46
  function shepherdRepairHint(agent) {
48
- return `human-required: for the GitHub Copilot app run 'ouro vault config set --agent ${agent} --scope machine --key copilotApp.stateDir --value "$HOME/.copilot"', then 'ouro up'. Or in a cmux terminal run 'ouro vault config set --agent ${agent} --scope machine --key cmux.socketCapability --value "$CMUX_SOCKET_CAPABILITY"' (or set cmux.socketPassword when cmux is in password mode), then 'ouro up'. On Herdr instead: 'ouro vault config set --agent ${agent} --scope machine --key herdr.socketPath --value "$HOME/.config/herdr/herdr.sock"', then 'ouro up'.`;
47
+ return `human-required: in a cmux terminal run 'ouro vault config set --agent ${agent} --scope machine --key cmux.socketCapability --value "$CMUX_SOCKET_CAPABILITY"' (or set cmux.socketPassword when cmux is in password mode), then 'ouro up'. On Herdr instead: 'ouro vault config set --agent ${agent} --scope machine --key herdr.socketPath --value "$HOME/.config/herdr/herdr.sock"', then 'ouro up'.`;
49
48
  }
50
49
  function text(record, key) {
51
50
  const value = record?.[key];
@@ -67,8 +66,6 @@ function cmuxAuth(cmux) {
67
66
  return null;
68
67
  }
69
68
  function shepherdConfigFacts(machinePayload) {
70
- if (hostRecord(machinePayload, "copilotApp"))
71
- return { configured: true, detail: "GitHub Copilot app" };
72
69
  const cmux = hostRecord(machinePayload, "cmux");
73
70
  const auth = cmuxAuth(cmux);
74
71
  if (!auth && hostRecord(machinePayload, "herdr"))
@@ -90,10 +87,6 @@ function shepherdSenseStatus(enabled, machinePayload) {
90
87
  function defaultHerdrSocketPath(homeDir = os.homedir()) {
91
88
  return path.join(homeDir, ".config", "herdr", "herdr.sock");
92
89
  }
93
- /** The Copilot app's state directory, where it writes `run/ws.port` and `run/ws.token`. */
94
- function defaultCopilotAppStateDir(homeDir = os.homedir()) {
95
- return path.join(homeDir, ".copilot");
96
- }
97
90
  /** cmux's own default: `~/.local/state/cmux/cmux-<uid>.sock`, then the older unscoped `cmux.sock`. */
98
91
  function defaultCmuxSocketPath(homeDir = os.homedir(), uid = process.getuid?.() ?? 0, exists = fs.existsSync) {
99
92
  const dir = path.join(homeDir, ".local", "state", "cmux");
@@ -104,17 +97,14 @@ function defaultCmuxSocketPath(homeDir = os.homedir(), uid = process.getuid?.()
104
97
  function resolveShepherdConnection(agent, machinePayload, defaultSocketPath = defaultCmuxSocketPath) {
105
98
  const cmux = hostRecord(machinePayload, "cmux");
106
99
  const herdr = hostRecord(machinePayload, "herdr");
107
- const copilotApp = hostRecord(machinePayload, "copilotApp");
108
100
  const auth = cmuxAuth(cmux);
109
- const host = copilotApp ? "copilot-app" : auth ? "cmux" : herdr ? "herdr" : "none";
101
+ const host = auth ? "cmux" : herdr ? "herdr" : "none";
110
102
  (0, runtime_1.emitNervesEvent)({
111
103
  component: "senses",
112
104
  event: "senses.shepherd_connection_resolved",
113
105
  message: "resolved Shepherd terminal host connection settings",
114
- meta: { agent, host, auth: host === "copilot-app" ? "app-token-file" : auth?.kind ?? "missing" },
106
+ meta: { agent, host, auth: auth?.kind ?? "missing" },
115
107
  });
116
- if (copilotApp)
117
- return { ok: true, connection: { host: "copilot-app", stateDir: text(copilotApp, "stateDir") || defaultCopilotAppStateDir() } };
118
108
  if (auth)
119
109
  return { ok: true, connection: { host: "cmux", socketPath: text(cmux, "socketPath") || defaultSocketPath(), auth } };
120
110
  if (herdr)
@@ -424,7 +424,10 @@ const COMMERCE_AUTHORITY_TOOLS = new Set(["stripe_create_card", "flight_hold", "
424
424
  // A call with no known trust level fails closed.
425
425
  const SHEPHERD_FAMILY_TOOLS = new Set(["shepherd_overview", "shepherd_read", "shepherd_signal", "shepherd_send"]);
426
426
  // The app-sessions tools read and write the owner's Copilot app sessions on this machine: family only, as Shepherd's.
427
- const APP_SESSIONS_FAMILY_TOOLS = new Set(["app_sessions_list", "app_sessions_tail", "app_sessions_send", "app_sessions_resume", "app_sessions_new", "app_sessions_archive", "app_sessions_restart", "app_sessions_watch", "app_sessions_digest"]);
427
+ const APP_SESSIONS_FAMILY_TOOLS = new Set([
428
+ "list_sessions_and_chats", "get_sessions_status", "get_session", "send_session_message", "create_session", "answer_session_input", "respond_to_session_plan_v2", "archive_session",
429
+ "navigate_to", "save_session_automation", "get_session_automation", "list_workflows", "run_workflow", "app_sessions_tail", "app_sessions_restart", "app_sessions_digest",
430
+ ]);
428
431
  const MAIL_FAMILY_TOOLS = new Set(["mail_screener", "mail_decide", "mail_access_log", "mail_send", "mail_index_refresh"]);
429
432
  const MAIL_DELEGATED_READ_TOOLS = new Set(["mail_recent", "mail_search"]);
430
433
  function opaqueAnsiShellAtoms(command) {
@@ -33,32 +33,24 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.appSessionsToolDefinitions = exports.appSessionsWatchTool = exports.appSessionsDigestTool = exports.appSessionsRestartTool = exports.appSessionsArchiveTool = exports.appSessionsNewTool = exports.appSessionsResumeTool = exports.appSessionsSendTool = exports.appSessionsTailTool = exports.appSessionsListTool = void 0;
36
+ exports.appSessionsToolDefinitions = exports.appSessionsDigestTool = exports.appSessionsRestartTool = exports.appSessionsTailTool = exports.runWorkflowTool = exports.listWorkflowsTool = exports.getSessionAutomationTool = exports.saveSessionAutomationTool = exports.navigateToTool = exports.archiveSessionTool = exports.respondToSessionPlanTool = exports.answerSessionInputTool = exports.createSessionTool = exports.sendSessionMessageTool = exports.getSessionTool = exports.getSessionsStatusTool = exports.listSessionsAndChatsTool = void 0;
37
37
  exports.appSessionsToolsEnabled = appSessionsToolsEnabled;
38
38
  const fs = __importStar(require("node:fs"));
39
39
  const path = __importStar(require("node:path"));
40
40
  const runtime_1 = require("../nerves/runtime");
41
- const client_1 = require("../senses/app-sessions/client");
41
+ const app_interface_1 = require("../senses/app-sessions/app-interface");
42
42
  const digest_1 = require("../senses/app-sessions/digest");
43
+ const client_1 = require("../senses/app-sessions/client");
43
44
  const store_1 = require("../senses/app-sessions/store");
44
45
  /**
45
- * The app-sessions tools: read and write this machine's GitHub Copilot app sessions. Every write is logged as a
46
- * nerves event; none is gated. A session the agent writes to is watched, so its next finished reply comes back to the
47
- * agent through the app-sessions sense.
46
+ * The app-sessions tools: what a coordinating session of the GitHub Copilot app can do with its client tools, under the
47
+ * app's own names and in its shapes (see `senses/app-sessions/app-interface.ts` for how each reaches the app, and which
48
+ * parts of the app are not reachable from outside it). Beside them, `app_sessions_tail` reads a session's transcript and
49
+ * `app_sessions_restart` restarts the app through Housesitter, which the app's own tools do not do. Every write is
50
+ * logged as a nerves event; none is gated beyond the harness's trust rule (family only).
48
51
  */
49
- const STATES = ["working", "waiting", "stuck", "idle"];
50
52
  /** This Mac's app, in `~/.copilot`. */
51
53
  const clientOptions = {};
52
- function text(value) {
53
- return typeof value === "string" ? value.trim() : "";
54
- }
55
- function flag(value, fallback) {
56
- if (value === true || value === "true")
57
- return true;
58
- if (value === false || value === "false")
59
- return false;
60
- return fallback;
61
- }
62
54
  function appSessionsToolsEnabled(agentRoot) {
63
55
  if (!agentRoot)
64
56
  return false;
@@ -70,307 +62,82 @@ function appSessionsToolsEnabled(agentRoot) {
70
62
  return false;
71
63
  }
72
64
  }
73
- async function run(tool, ctx, body) {
74
- if (!ctx?.agentRoot)
75
- return JSON.stringify({ error: "the app-sessions tools need an agent runtime" });
76
- try {
77
- const result = await body(ctx.agentRoot);
78
- (0, runtime_1.emitNervesEvent)({ component: "repertoire", event: "repertoire.app_sessions_tool", message: "ran an app-sessions tool", meta: { tool } });
79
- return JSON.stringify(result);
80
- }
81
- catch (error) {
82
- (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "repertoire.app_sessions_tool_error", message: "app-sessions tool call failed", meta: { tool, error: error.message } });
83
- return JSON.stringify({ error: error.message });
84
- }
85
- }
86
- /** A full session id, or a unique prefix of one (the first 8 characters are enough). */
87
- function resolveSession(value) {
88
- const wanted = text(value);
89
- if (!wanted)
90
- throw new Error("name a session: its id, or the start of it, from app_sessions_list");
91
- const rows = (0, client_1.listAppSessions)(clientOptions);
92
- const exact = rows.find(row => row.id === wanted);
93
- if (exact)
94
- return exact;
95
- const matches = rows.filter(row => row.id.startsWith(wanted));
96
- if (matches.length === 1)
97
- return matches[0];
98
- if (matches.length > 1)
99
- throw new Error(`'${wanted}' matches ${matches.length} sessions; give more of the id`);
100
- throw new Error(`no session '${wanted}' in this Mac's Copilot app sidebar (app_sessions_list shows them)`);
101
- }
102
- function watch(agentRoot, id, name, offset) {
103
- (0, store_1.watchSession)(agentRoot, id, name, offset, Date.now());
104
- }
105
- const sessionParam = { type: "string", description: "Session id from app_sessions_list (a unique prefix such as the first 8 characters works)." };
106
- exports.appSessionsListTool = {
107
- tool: {
108
- type: "function",
109
- function: {
110
- name: "app_sessions_list",
111
- description: "Every session in this Mac's GitHub Copilot app sidebar: id, name, state, why, last activity, actual kind/workspaceId/projectId and known creator/parent ids. Project association is not sidebar nesting; sidebarPlacement is unknown when the local schema cannot prove it. Refresh before reporting where work lives. Read-only.",
112
- parameters: {
113
- type: "object",
114
- properties: { state: { type: "string", enum: [...STATES], description: "Only sessions in this state." } },
115
- additionalProperties: false,
116
- },
117
- },
118
- },
119
- handler: (args, ctx) => run("app_sessions_list", ctx, () => {
120
- const state = text(args.state);
121
- const rows = (0, client_1.listAppSessions)(clientOptions);
122
- const picture = (0, client_1.snapshot)(clientOptions, rows);
123
- return {
124
- observedAt: picture.at,
125
- appRunning: picture.appRunning,
126
- counts: picture.counts,
127
- sessions: rows.filter(row => !state || row.state === state).map(row => ({
128
- id: row.id, name: row.name, state: row.state, why: row.detail, kind: row.kind, workspaceId: row.workspaceId,
129
- project: row.project, projectId: row.projectId, sidebarPlacement: row.sidebarPlacement,
130
- ...(row.parentSessionId !== undefined ? { parentSessionId: row.parentSessionId } : {}),
131
- ...(row.creatorSessionId !== undefined ? { creatorSessionId: row.creatorSessionId } : {}),
132
- ...(row.coordinatingCreatorSessionId !== undefined ? { coordinatingCreatorSessionId: row.coordinatingCreatorSessionId } : {}),
133
- lastActivity: row.lastActivity, ...(row.remote ? { remote: true } : {}),
134
- })),
135
- };
136
- }),
137
- summaryKeys: ["state"],
138
- riskProfile: { mutates: "none", risk: "low" },
139
- };
140
- exports.appSessionsTailTool = {
141
- tool: {
142
- type: "function",
143
- function: {
144
- name: "app_sessions_tail",
145
- description: "A Copilot app session's last visible prompts and replies, oldest first, with current name/state, observation time and local-log coverage. Re-read before reporting current progress: older messages and watched names are not live status. Remote history is only what this Mac has received. Read-only.",
146
- parameters: {
147
- type: "object",
148
- properties: { session: sessionParam, count: { type: "number", description: "How many messages, 1-50. Default 6." } },
149
- required: ["session"],
150
- additionalProperties: false,
151
- },
152
- },
153
- },
154
- handler: (args, ctx) => run("app_sessions_tail", ctx, (agentRoot) => {
155
- const session = resolveSession(args.session);
156
- const count = Math.min(50, Math.max(1, Math.trunc(Number(args.count) || 6)));
157
- const history = (0, client_1.readAppSessionHistory)(session.id, count, clientOptions);
158
- const watchedName = (0, store_1.readWatches)(agentRoot)[session.id]?.name;
159
- return {
160
- session: session.id, name: session.name, state: session.state, lastActivity: session.lastActivity,
161
- kind: session.kind, workspaceId: session.workspaceId, projectId: session.projectId, sidebarPlacement: session.sidebarPlacement,
162
- ...(session.parentSessionId !== undefined ? { parentSessionId: session.parentSessionId } : {}),
163
- ...(session.creatorSessionId !== undefined ? { creatorSessionId: session.creatorSessionId } : {}),
164
- ...(session.coordinatingCreatorSessionId !== undefined ? { coordinatingCreatorSessionId: session.coordinatingCreatorSessionId } : {}),
165
- ...history,
166
- ...(watchedName && watchedName !== session.name ? { renamedFrom: watchedName } : {}),
167
- coverage: history.missing ? "missing" : history.skippedEvents ? "incomplete" : session.remote ? "local-only" : "local",
168
- freshness: "point-in-time; re-read before reporting current progress",
169
- };
170
- }),
171
- summaryKeys: ["session"],
172
- riskProfile: { mutates: "none", risk: "low" },
173
- };
174
- exports.appSessionsSendTool = {
175
- tool: {
176
- type: "function",
177
- function: {
178
- name: "app_sessions_send",
179
- description: "Deliver a message into a Copilot app session, the same request the app's own message box sends. Waits (up to 2 minutes) for the app to accept it: a session that is not loaded loads first. Its next finished reply comes back to you as an inbound message unless watch is false.",
180
- parameters: {
181
- type: "object",
182
- properties: {
183
- session: sessionParam,
184
- message: { type: "string", description: "What to send." },
185
- delivery: { type: "string", enum: ["immediate", "enqueue"], description: "immediate (default) steers the session now; enqueue waits behind its current work." },
186
- watch: { type: "boolean", description: "Bring the session's next reply back to you. Default true." },
187
- },
188
- required: ["session", "message"],
189
- additionalProperties: false,
190
- },
191
- },
192
- },
193
- handler: (args, ctx) => run("app_sessions_send", ctx, async (agentRoot) => {
194
- const session = resolveSession(args.session);
195
- const message = typeof args.message === "string" ? args.message : "";
196
- if (!message.trim())
197
- throw new Error("say what to send");
198
- const offset = (0, client_1.eventLogSize)(session.id, clientOptions);
199
- const delivery = text(args.delivery) === "enqueue" ? "enqueue" : "immediate";
200
- const result = await (0, client_1.sendToAppSession)(session.id, message, { ...clientOptions, delivery });
201
- const watching = result.ok && flag(args.watch, true);
202
- if (watching)
203
- watch(agentRoot, session.id, session.name, offset);
204
- return { session: session.id, name: session.name, ...result, watching };
205
- }),
206
- summaryKeys: ["session"],
207
- riskProfile: { mutates: "external_side_effect", risk: "high", reason: "sends a message into another agent session in the owner's Copilot app" },
208
- };
209
- exports.appSessionsResumeTool = {
210
- tool: {
211
- type: "function",
212
- function: {
213
- name: "app_sessions_resume",
214
- description: "Nudge a stuck or stopped Copilot app session to continue where it left off (the resume message Housesitter sends after a restart), with an optional note. Its next reply comes back to you.",
215
- parameters: {
216
- type: "object",
217
- properties: { session: sessionParam, note: { type: "string", description: "Anything to add to the resume message." } },
218
- required: ["session"],
219
- additionalProperties: false,
220
- },
221
- },
222
- },
223
- handler: (args, ctx) => run("app_sessions_resume", ctx, async (agentRoot) => {
224
- const session = resolveSession(args.session);
225
- const offset = (0, client_1.eventLogSize)(session.id, clientOptions);
226
- const result = await (0, client_1.resumeAppSession)(session.id, text(args.note) || undefined, clientOptions);
227
- if (result.ok)
228
- watch(agentRoot, session.id, session.name, offset);
229
- return { session: session.id, name: session.name, ...result, watching: result.ok };
230
- }),
231
- summaryKeys: ["session"],
232
- riskProfile: { mutates: "external_side_effect", risk: "high", reason: "tells another agent session in the owner's Copilot app to continue" },
233
- };
234
- exports.appSessionsNewTool = {
235
- tool: {
236
- type: "function",
237
- function: {
238
- name: "app_sessions_new",
239
- description: "Create a standalone general chat, NOT a project/workspace session and NOT a child under an existing workspace. cwd and prompt text do not choose sidebar placement. Workspace/project/parent targets are unsupported and refused without creating anything. Returns actual kind/association and verified or unknown placement; do not claim workspace placement from a project id or delegated child. Initial message acceptance is separate from creation. You may archive any session this tool created.",
240
- parameters: {
241
- type: "object",
242
- properties: {
243
- name: { type: "string", description: "Sidebar title." },
244
- prompt: { type: "string", description: "First message." },
245
- cwd: { type: "string", description: "Working folder. Default: the home folder." },
246
- agent: { type: "string", description: "Custom agent to run as, for example desk:worker." },
247
- model: { type: "string", description: "Model id." },
248
- target: { type: "string", enum: ["chat", "workspace"], description: "Default chat. workspace is unsupported and refused; use the app's native project-session creation instead." },
249
- project: { type: "string", description: "Project placement is unsupported by this tool and refused." },
250
- workspace: { type: "string", description: "Workspace placement is unsupported by this tool and refused." },
251
- parent_session: { type: "string", description: "Parent/child placement is unsupported by this tool and refused." },
252
- },
253
- additionalProperties: false,
254
- },
255
- },
256
- },
257
- handler: (args, ctx) => run("app_sessions_new", ctx, async (agentRoot) => {
258
- if ((text(args.target) && text(args.target) !== "chat") || args.project !== undefined || args.workspace !== undefined || args.parent_session !== undefined) {
259
- throw new Error("app_sessions_new supports only a standalone chat; workspace/project/parent placement is unsupported. Nothing was created. Use the Copilot app's native project-session creation and verify its actual sidebar placement.");
260
- }
261
- const name = text(args.name);
262
- const prompt = typeof args.prompt === "string" && args.prompt.trim() ? args.prompt : undefined;
263
- const opened = await (0, client_1.openAppChat)({
264
- ...(name ? { name } : {}), ...(prompt ? { prompt } : {}),
265
- ...(text(args.cwd) ? { cwd: text(args.cwd) } : {}), ...(text(args.agent) ? { agent: text(args.agent) } : {}), ...(text(args.model) ? { model: text(args.model) } : {}),
266
- }, clientOptions);
267
- if (!opened.sessionId)
268
- return { ...opened };
269
- (0, store_1.addProbe)(agentRoot, opened.sessionId, opened.placement?.name ?? (name || null), Date.now());
270
- const watching = !!prompt && opened.sent?.ok === true;
271
- if (watching)
272
- watch(agentRoot, opened.sessionId, opened.placement?.name ?? (name || null), 0);
273
- return { ...opened, watching };
274
- }),
275
- summaryKeys: ["name"],
276
- riskProfile: { mutates: "external_side_effect", risk: "high", reason: "opens a new agent session in the owner's Copilot app" },
277
- };
278
- exports.appSessionsArchiveTool = {
279
- tool: {
280
- type: "function",
281
- function: {
282
- name: "app_sessions_archive",
283
- description: "Archive a Copilot app session that you opened with app_sessions_new (its workspace goes too).",
284
- parameters: { type: "object", properties: { session: sessionParam }, required: ["session"], additionalProperties: false },
285
- },
286
- },
287
- handler: (args, ctx) => run("app_sessions_archive", ctx, async (agentRoot) => {
288
- const id = text(args.session);
289
- const probes = (0, store_1.readProbes)(agentRoot);
290
- const match = Object.keys(probes).filter(probe => probe === id || (id.length > 0 && probe.startsWith(id)));
291
- if (match.length !== 1)
292
- throw new Error(`'${id}' is not one session you opened with app_sessions_new (yours: ${Object.keys(probes).join(", ") || "none"})`);
293
- const result = await (0, client_1.archiveAppSession)(match[0], clientOptions);
294
- if (result.ok) {
295
- (0, store_1.removeProbe)(agentRoot, match[0]);
296
- (0, store_1.unwatchSession)(agentRoot, match[0]);
297
- }
298
- return { session: match[0], name: probes[match[0]].name, ...result };
299
- }),
300
- summaryKeys: ["session"],
301
- riskProfile: { mutates: "external_side_effect", risk: "high", reason: "archives a session in the owner's Copilot app" },
302
- };
303
- exports.appSessionsRestartTool = {
304
- tool: {
305
- type: "function",
306
- function: {
307
- name: "app_sessions_restart",
308
- description: "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.",
309
- parameters: {
310
- type: "object",
311
- properties: {
312
- action: { type: "string", enum: ["status", "enqueue"], description: "Default status." },
313
- why: { type: "string", description: "enqueue: the reason; it completes \"restarted at 11:40 for …\" in the resume message each session gets." },
314
- },
315
- additionalProperties: false,
316
- },
317
- },
318
- },
319
- handler: (args, ctx) => run("app_sessions_restart", ctx, async () => {
320
- if (text(args.action) !== "enqueue")
321
- return await (0, client_1.restartStatus)(clientOptions);
322
- const why = text(args.why);
323
- if (!why)
324
- throw new Error("say why the app needs a restart; every session is told in its resume message");
325
- return await (0, client_1.restartEnqueue)(why, ctx?.agentName ?? "an agent", clientOptions);
326
- }),
327
- summaryKeys: ["action"],
328
- riskProfile: (args) => text(args.action) === "enqueue"
329
- ? { mutates: "external_side_effect", risk: "high", reason: "restarts the owner's Copilot app" }
330
- : { mutates: "none", risk: "low" },
331
- };
332
- exports.appSessionsDigestTool = {
333
- tool: {
334
- type: "function",
335
- function: {
336
- name: "app_sessions_digest",
337
- description: "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. Answer \"how's it going?\" from it in a few lines of your own, leading with what needs the owner; never add facts it does not carry. It is at most a few minutes old and says so when older.",
338
- parameters: { type: "object", properties: {}, additionalProperties: false },
65
+ const READ = { mutates: "none", risk: "low" };
66
+ const write = (reason) => ({ mutates: "external_side_effect", risk: "high", reason });
67
+ function define(name, description, properties, required, risk, body, summaryKeys = []) {
68
+ return {
69
+ tool: { type: "function", function: { name, description, parameters: { type: "object", properties, ...(required.length ? { required } : {}), additionalProperties: false } } },
70
+ handler: async (args, ctx) => {
71
+ if (!ctx?.agentRoot)
72
+ return JSON.stringify({ error: "the app-sessions tools need an agent runtime" });
73
+ try {
74
+ const result = await body(args, ctx.agentRoot, ctx);
75
+ (0, runtime_1.emitNervesEvent)({ component: "repertoire", event: "repertoire.app_sessions_tool", message: "ran an app-sessions tool", meta: { tool: name } });
76
+ return JSON.stringify(result);
77
+ }
78
+ catch (error) {
79
+ (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 } });
80
+ return JSON.stringify({ error: error.message });
81
+ }
339
82
  },
340
- },
341
- handler: (_args, ctx) => run("app_sessions_digest", ctx, (agentRoot) => {
342
- const digest = (0, digest_1.readDigestText)(agentRoot, Date.now());
343
- if (!digest)
344
- throw new Error("no status digest yet: it is built when agent.json gives the app-sessions sense a digest block");
345
- return { digest };
346
- }),
347
- summaryKeys: [],
348
- riskProfile: () => ({ mutates: "none", risk: "low" }),
349
- };
350
- exports.appSessionsWatchTool = {
351
- tool: {
352
- type: "function",
353
- function: {
354
- name: "app_sessions_watch",
355
- description: "Start or stop bringing a Copilot app session's finished replies back to you as inbound messages (sending to a session starts it; it lasts a day after your last message).",
356
- parameters: {
357
- type: "object",
358
- properties: { session: sessionParam, watch: { type: "boolean", description: "true to start (default), false to stop." } },
359
- required: ["session"],
360
- additionalProperties: false,
361
- },
83
+ summaryKeys,
84
+ riskProfile: risk,
85
+ };
86
+ }
87
+ const session = { type: "string", description: "A session's id from list_sessions_and_chats; a unique start of it (the first 8 characters) works." };
88
+ 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." };
89
+ 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, () => (0, app_interface_1.listSessionsAndChats)(clientOptions));
90
+ 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, agentRoot) => (0, app_interface_1.getSessionsStatus)(agentRoot, typeof args.state === "string" ? args.state : undefined, clientOptions), ["state"]);
91
+ 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, agentRoot) => (0, app_interface_1.getSession)(agentRoot, args.session_id, clientOptions), ["session_id"]);
92
+ exports.sendSessionMessageTool = define("send_session_message", "Send a message into a session, as its message box does; waits up to 2 minutes for the app to accept it (a session that is not loaded loads first). The app takes it for the person's, so say who you are in it. 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"), (args, agentRoot) => (0, app_interface_1.sendSessionMessage)(agentRoot, args, clientOptions), ["session_id"]);
93
+ 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. 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.", {
94
+ name: { type: "string", description: "Sidebar title." }, project_id: { type: "string", description: "The project's id or name." }, session_kind: { type: "string", enum: ["chat", "project"] },
95
+ workspace_type: { type: "string", enum: ["worktree", "branch"] }, branch_name: { type: "string", description: "Branch for a worktree; a fresh ouro-… name by default." },
96
+ kickoff: {
97
+ type: "object", description: "The first work.", additionalProperties: false,
98
+ properties: {
99
+ prompt: { type: "string" }, mode: { type: "string", enum: ["interactive", "plan", "autopilot"] }, model: { type: "string" }, agent: { type: "string", description: "Custom agent, for example desk:worker." },
100
+ reasoning_effort: { type: "string" }, permission_mode: { type: "string", description: "allow-all (default) or manual." },
362
101
  },
363
102
  },
364
- handler: (args, ctx) => run("app_sessions_watch", ctx, (agentRoot) => {
365
- const session = resolveSession(args.session);
366
- if (!flag(args.watch, true))
367
- return { session: session.id, watching: false, wasWatching: (0, store_1.unwatchSession)(agentRoot, session.id) };
368
- watch(agentRoot, session.id, session.name, (0, client_1.eventLogSize)(session.id, clientOptions));
369
- return { session: session.id, name: session.name, watching: true };
370
- }),
371
- summaryKeys: ["session"],
372
- riskProfile: { mutates: "durable_state_write", risk: "high", reason: "changes which app sessions' replies wake the agent" },
373
- };
103
+ notify_on_idle: notifyOnIdle,
104
+ }, [], write("opens a new agent session in the owner's Copilot app"), (args, agentRoot) => (0, app_interface_1.createSession)(agentRoot, args, clientOptions), ["name"]);
105
+ 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, agentRoot) => (0, app_interface_1.answerSessionInput)(agentRoot, args, clientOptions), ["session_id"]);
106
+ 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, agentRoot) => (0, app_interface_1.respondToSessionPlan)(agentRoot, args, clientOptions), ["session_id"]);
107
+ exports.archiveSessionTool = define("archive_session", "Archive a session you created with create_session (a project session's worktree goes with it).", { session_id: session }, ["session_id"], write("archives a session in the owner's Copilot app"), (args, agentRoot) => (0, app_interface_1.archiveSession)(agentRoot, args.session_id, clientOptions), ["session_id"]);
108
+ 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, app_interface_1.navigateTo)(args.id, clientOptions), ["id"]);
109
+ 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).", {
110
+ session_id: session, prompt: { type: "string" }, interval: { type: "string", enum: ["once", "minutes", "daily", "weekly", "cron"] }, run_at: { type: "string" }, every_minutes: { type: "number" },
111
+ schedule_hour: { type: "number" }, schedule_minute: { type: "number" }, schedule_day: { type: "number" }, cron_expression: { type: "string" }, name: { type: "string" },
112
+ clear: { type: "boolean", description: "Remove the session's automation instead." },
113
+ }, ["session_id"], write("schedules wake-ups for an agent session in the owner's Copilot app"), args => (0, app_interface_1.saveSessionAutomation)(args, clientOptions), ["session_id"]);
114
+ exports.getSessionAutomationTool = define("get_session_automation", "The automation attached to a session. Read-only.", { session_id: session }, ["session_id"], READ, args => (0, app_interface_1.getSessionAutomation)(args.session_id, clientOptions), ["session_id"]);
115
+ exports.listWorkflowsTool = define("list_workflows", "The app's automations (workflows), with their ids and schedules. Read-only.", {}, [], READ, () => (0, app_interface_1.listWorkflows)(clientOptions));
116
+ 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, app_interface_1.runWorkflow)(args.id, clientOptions), ["id"]);
117
+ 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) => {
118
+ const row = (0, app_interface_1.findSession)(await (0, client_1.listAppSessions)(clientOptions), args.session_id);
119
+ const history = (0, client_1.readAppSessionHistory)(row.id, Math.min(50, Math.max(1, Math.trunc(Number(args.count) || 6))), clientOptions);
120
+ const watchedName = (0, store_1.readWatches)(agentRoot)[row.id]?.name;
121
+ return {
122
+ session_id: row.id, name: row.name, state: row.state, last_activity: row.lastActivity, ...history, ...(watchedName && watchedName !== row.name ? { renamed_from: watchedName } : {}),
123
+ coverage: history.missing ? "missing" : history.skippedEvents ? "incomplete" : row.remote ? "local-only" : "local", freshness: "point-in-time; re-read before reporting current progress",
124
+ };
125
+ }, ["session_id"]);
126
+ 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) => {
127
+ if (args.action !== "enqueue")
128
+ return await (0, client_1.restartStatus)(clientOptions);
129
+ const why = typeof args.why === "string" ? args.why.trim() : "";
130
+ if (!why)
131
+ throw new Error("say why the app needs a restart; every session is told in its resume message");
132
+ return await (0, client_1.restartEnqueue)(why, ctx.agentName ?? "an agent", clientOptions);
133
+ }, ["action"]);
134
+ 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) => {
135
+ const digest = (0, digest_1.readDigestText)(agentRoot, Date.now());
136
+ if (!digest)
137
+ throw new Error("no status digest yet: it is built when agent.json gives the app-sessions sense a digest block");
138
+ return { digest };
139
+ });
374
140
  exports.appSessionsToolDefinitions = [
375
- exports.appSessionsListTool, exports.appSessionsTailTool, exports.appSessionsSendTool, exports.appSessionsResumeTool, exports.appSessionsNewTool, exports.appSessionsArchiveTool, exports.appSessionsRestartTool, exports.appSessionsWatchTool, exports.appSessionsDigestTool,
141
+ exports.listSessionsAndChatsTool, exports.getSessionsStatusTool, exports.getSessionTool, exports.sendSessionMessageTool, exports.createSessionTool, exports.answerSessionInputTool, exports.respondToSessionPlanTool, exports.archiveSessionTool,
142
+ exports.navigateToTool, exports.saveSessionAutomationTool, exports.getSessionAutomationTool, exports.listWorkflowsTool, exports.runWorkflowTool, exports.appSessionsTailTool, exports.appSessionsRestartTool, exports.appSessionsDigestTool,
376
143
  ];