@ouro.bot/cli 0.1.0-alpha.8 → 0.1.0-alpha.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/AdoptionSpecialist.ouro/agent.json +70 -9
  2. package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
  3. package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
  4. package/README.md +147 -205
  5. package/assets/ouroboros.png +0 -0
  6. package/changelog.json +468 -0
  7. package/dist/heart/active-work.js +218 -0
  8. package/dist/heart/bridges/manager.js +358 -0
  9. package/dist/heart/bridges/state-machine.js +135 -0
  10. package/dist/heart/bridges/store.js +123 -0
  11. package/dist/heart/commitments.js +89 -0
  12. package/dist/heart/config.js +68 -23
  13. package/dist/heart/core.js +452 -93
  14. package/dist/heart/cross-chat-delivery.js +146 -0
  15. package/dist/heart/daemon/agent-discovery.js +81 -0
  16. package/dist/heart/daemon/auth-flow.js +430 -0
  17. package/dist/heart/daemon/daemon-cli.js +1779 -247
  18. package/dist/heart/daemon/daemon-entry.js +55 -6
  19. package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
  20. package/dist/heart/daemon/daemon.js +216 -10
  21. package/dist/heart/daemon/hatch-animation.js +10 -3
  22. package/dist/heart/daemon/hatch-flow.js +7 -82
  23. package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
  24. package/dist/heart/daemon/launchd.js +159 -0
  25. package/dist/heart/daemon/log-tailer.js +4 -3
  26. package/dist/heart/daemon/message-router.js +17 -8
  27. package/dist/heart/daemon/ouro-bot-entry.js +0 -0
  28. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  29. package/dist/heart/daemon/ouro-entry.js +0 -0
  30. package/dist/heart/daemon/ouro-path-installer.js +260 -0
  31. package/dist/heart/daemon/ouro-uti.js +11 -2
  32. package/dist/heart/daemon/ouro-version-manager.js +164 -0
  33. package/dist/heart/daemon/process-manager.js +14 -1
  34. package/dist/heart/daemon/run-hooks.js +37 -0
  35. package/dist/heart/daemon/runtime-logging.js +58 -15
  36. package/dist/heart/daemon/runtime-metadata.js +219 -0
  37. package/dist/heart/daemon/runtime-mode.js +67 -0
  38. package/dist/heart/daemon/sense-manager.js +307 -0
  39. package/dist/heart/daemon/skill-management-installer.js +94 -0
  40. package/dist/heart/daemon/socket-client.js +202 -0
  41. package/dist/heart/daemon/specialist-orchestrator.js +53 -84
  42. package/dist/heart/daemon/specialist-prompt.js +63 -11
  43. package/dist/heart/daemon/specialist-tools.js +211 -60
  44. package/dist/heart/daemon/staged-restart.js +114 -0
  45. package/dist/heart/daemon/thoughts.js +507 -0
  46. package/dist/heart/daemon/update-checker.js +111 -0
  47. package/dist/heart/daemon/update-hooks.js +138 -0
  48. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  49. package/dist/heart/delegation.js +62 -0
  50. package/dist/heart/identity.js +126 -21
  51. package/dist/heart/kicks.js +1 -19
  52. package/dist/heart/model-capabilities.js +48 -0
  53. package/dist/heart/obligations.js +141 -0
  54. package/dist/heart/progress-story.js +42 -0
  55. package/dist/heart/providers/anthropic.js +74 -9
  56. package/dist/heart/providers/azure.js +86 -7
  57. package/dist/heart/providers/github-copilot.js +149 -0
  58. package/dist/heart/providers/minimax.js +4 -0
  59. package/dist/heart/providers/openai-codex.js +12 -3
  60. package/dist/heart/safe-workspace.js +228 -0
  61. package/dist/heart/sense-truth.js +61 -0
  62. package/dist/heart/session-activity.js +169 -0
  63. package/dist/heart/session-recall.js +116 -0
  64. package/dist/heart/streaming.js +100 -22
  65. package/dist/heart/target-resolution.js +123 -0
  66. package/dist/heart/turn-coordinator.js +28 -0
  67. package/dist/mind/associative-recall.js +14 -2
  68. package/dist/mind/bundle-manifest.js +70 -0
  69. package/dist/mind/context.js +27 -11
  70. package/dist/mind/first-impressions.js +16 -2
  71. package/dist/mind/friends/channel.js +35 -0
  72. package/dist/mind/friends/group-context.js +144 -0
  73. package/dist/mind/friends/store-file.js +19 -0
  74. package/dist/mind/friends/trust-explanation.js +74 -0
  75. package/dist/mind/friends/types.js +8 -0
  76. package/dist/mind/memory.js +27 -26
  77. package/dist/mind/pending.js +76 -9
  78. package/dist/mind/phrases.js +1 -0
  79. package/dist/mind/prompt.js +445 -77
  80. package/dist/mind/token-estimate.js +8 -12
  81. package/dist/nerves/cli-logging.js +15 -2
  82. package/dist/nerves/coverage/run-artifacts.js +1 -1
  83. package/dist/nerves/index.js +12 -0
  84. package/dist/repertoire/ado-client.js +4 -2
  85. package/dist/repertoire/coding/feedback.js +134 -0
  86. package/dist/repertoire/coding/index.js +4 -1
  87. package/dist/repertoire/coding/manager.js +62 -4
  88. package/dist/repertoire/coding/spawner.js +3 -3
  89. package/dist/repertoire/coding/tools.js +41 -2
  90. package/dist/repertoire/data/ado-endpoints.json +188 -0
  91. package/dist/repertoire/guardrails.js +290 -0
  92. package/dist/repertoire/mcp-client.js +254 -0
  93. package/dist/repertoire/mcp-manager.js +195 -0
  94. package/dist/repertoire/skills.js +3 -26
  95. package/dist/repertoire/tasks/board.js +12 -0
  96. package/dist/repertoire/tasks/index.js +23 -9
  97. package/dist/repertoire/tasks/transitions.js +1 -2
  98. package/dist/repertoire/tools-base.js +686 -251
  99. package/dist/repertoire/tools-bluebubbles.js +93 -0
  100. package/dist/repertoire/tools-teams.js +58 -25
  101. package/dist/repertoire/tools.js +95 -53
  102. package/dist/senses/bluebubbles-client.js +210 -5
  103. package/dist/senses/bluebubbles-entry.js +2 -0
  104. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  105. package/dist/senses/bluebubbles-media.js +339 -0
  106. package/dist/senses/bluebubbles-model.js +12 -4
  107. package/dist/senses/bluebubbles-mutation-log.js +45 -5
  108. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  109. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  110. package/dist/senses/bluebubbles.js +894 -45
  111. package/dist/senses/cli-layout.js +187 -0
  112. package/dist/senses/cli.js +405 -156
  113. package/dist/senses/continuity.js +94 -0
  114. package/dist/senses/debug-activity.js +154 -0
  115. package/dist/senses/inner-dialog-worker.js +47 -18
  116. package/dist/senses/inner-dialog.js +377 -83
  117. package/dist/senses/pipeline.js +307 -0
  118. package/dist/senses/teams.js +573 -129
  119. package/dist/senses/trust-gate.js +112 -2
  120. package/package.json +14 -3
  121. package/subagents/README.md +4 -70
  122. package/dist/heart/daemon/specialist-session.js +0 -142
  123. package/dist/heart/daemon/subagent-installer.js +0 -125
  124. package/dist/inner-worker-entry.js +0 -4
  125. package/subagents/work-doer.md +0 -233
  126. package/subagents/work-merger.md +0 -624
  127. package/subagents/work-planner.md +0 -373
@@ -33,19 +33,137 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.finalAnswerTool = exports.baseToolHandlers = exports.tools = exports.baseToolDefinitions = void 0;
36
+ exports.finalAnswerTool = exports.noResponseTool = exports.goInwardTool = exports.tools = exports.baseToolDefinitions = exports.editFileReadTracker = void 0;
37
+ exports.renderInnerProgressStatus = renderInnerProgressStatus;
37
38
  const fs = __importStar(require("fs"));
39
+ const fg = __importStar(require("fast-glob"));
38
40
  const child_process_1 = require("child_process");
39
41
  const path = __importStar(require("path"));
40
42
  const skills_1 = require("./skills");
41
43
  const config_1 = require("../heart/config");
42
44
  const runtime_1 = require("../nerves/runtime");
43
45
  const identity_1 = require("../heart/identity");
44
- const os = __importStar(require("os"));
45
- const tasks_1 = require("./tasks");
46
+ const safe_workspace_1 = require("../heart/safe-workspace");
47
+ const socket_client_1 = require("../heart/daemon/socket-client");
48
+ const thoughts_1 = require("../heart/daemon/thoughts");
49
+ const manager_1 = require("../heart/bridges/manager");
50
+ const session_recall_1 = require("../heart/session-recall");
46
51
  const tools_1 = require("./coding/tools");
47
52
  const memory_1 = require("../mind/memory");
48
- const postIt = (msg) => `post-it from past you:\n${msg}`;
53
+ const pending_1 = require("../mind/pending");
54
+ const progress_story_1 = require("../heart/progress-story");
55
+ const cross_chat_delivery_1 = require("../heart/cross-chat-delivery");
56
+ const obligations_1 = require("../heart/obligations");
57
+ // Tracks which file paths have been read via read_file in this session.
58
+ // edit_file requires a file to be read first (must-read-first guard).
59
+ exports.editFileReadTracker = new Set();
60
+ function buildContextDiff(lines, changeStart, changeEnd, contextSize = 3) {
61
+ const start = Math.max(0, changeStart - contextSize);
62
+ const end = Math.min(lines.length, changeEnd + contextSize);
63
+ const result = [];
64
+ for (let i = start; i < end; i++) {
65
+ const lineNum = i + 1;
66
+ const prefix = (i >= changeStart && i < changeEnd) ? ">" : " ";
67
+ result.push(`${prefix} ${lineNum} | ${lines[i]}`);
68
+ }
69
+ return result.join("\n");
70
+ }
71
+ function resolveLocalToolPath(targetPath) {
72
+ return (0, safe_workspace_1.resolveSafeRepoPath)({ requestedPath: targetPath }).resolvedPath;
73
+ }
74
+ const NO_SESSION_FOUND_MESSAGE = "no session found for that friend/channel/key combination.";
75
+ const EMPTY_SESSION_MESSAGE = "session exists but has no non-system messages.";
76
+ function findDelegatingBridgeId(ctx) {
77
+ const currentSession = ctx?.currentSession;
78
+ if (!currentSession)
79
+ return undefined;
80
+ return ctx?.activeBridges?.find((bridge) => bridge.lifecycle === "active"
81
+ && bridge.attachedSessions.some((session) => session.friendId === currentSession.friendId
82
+ && session.channel === currentSession.channel
83
+ && session.key === currentSession.key))?.id;
84
+ }
85
+ async function recallSessionSafely(options) {
86
+ try {
87
+ return await (0, session_recall_1.recallSession)(options);
88
+ }
89
+ catch (error) {
90
+ if (options.summarize) {
91
+ (0, runtime_1.emitNervesEvent)({
92
+ component: "daemon",
93
+ event: "daemon.session_recall_summary_fallback",
94
+ message: "session recall summarization failed; using raw transcript",
95
+ meta: {
96
+ friendId: options.friendId,
97
+ channel: options.channel,
98
+ key: options.key,
99
+ error: error instanceof Error ? error.message : String(error),
100
+ },
101
+ });
102
+ try {
103
+ return await (0, session_recall_1.recallSession)({
104
+ ...options,
105
+ summarize: undefined,
106
+ });
107
+ }
108
+ catch {
109
+ return { kind: "missing" };
110
+ }
111
+ }
112
+ return { kind: "missing" };
113
+ }
114
+ }
115
+ function normalizeProgressOutcome(text) {
116
+ const trimmed = text.trim();
117
+ /* v8 ignore next -- defensive: normalizeProgressOutcome null branch @preserve */
118
+ if (!trimmed || trimmed === "nothing yet" || trimmed === "nothing recent") {
119
+ return null;
120
+ }
121
+ if (trimmed.startsWith("\"") && trimmed.endsWith("\"") && trimmed.length >= 2) {
122
+ return trimmed.slice(1, -1);
123
+ }
124
+ return trimmed;
125
+ }
126
+ function writePendingEnvelope(queueDir, message) {
127
+ fs.mkdirSync(queueDir, { recursive: true });
128
+ const fileName = `${message.timestamp}-${Math.random().toString(36).slice(2, 10)}.json`;
129
+ const filePath = path.join(queueDir, fileName);
130
+ fs.writeFileSync(filePath, JSON.stringify(message, null, 2));
131
+ }
132
+ function renderCrossChatDeliveryStatus(target, result) {
133
+ const phase = result.status === "delivered_now"
134
+ ? "completed"
135
+ : result.status === "queued_for_later"
136
+ ? "queued"
137
+ : result.status === "blocked"
138
+ ? "blocked"
139
+ : "errored";
140
+ const lead = result.status === "delivered_now"
141
+ ? "delivered now"
142
+ : result.status === "queued_for_later"
143
+ ? "queued for later"
144
+ : result.status === "blocked"
145
+ ? "blocked"
146
+ : "failed";
147
+ return (0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
148
+ scope: "shared-work",
149
+ phase,
150
+ objective: `message to ${target}`,
151
+ outcomeText: `${lead}\n${result.detail}`,
152
+ }));
153
+ }
154
+ function renderInnerProgressStatus(status) {
155
+ if (status.processing === "pending") {
156
+ return "i've queued this thought for private attention. it'll come up when my inner dialog is free.";
157
+ }
158
+ if (status.processing === "started") {
159
+ return "i'm working through this privately right now.";
160
+ }
161
+ // processed / completed
162
+ if (status.surfaced && status.surfaced !== "nothing recent" && status.surfaced !== "no outward result") {
163
+ return `i thought about this privately and came to something: ${status.surfaced}`;
164
+ }
165
+ return "i thought about this privately. i'll bring it back when the time is right.";
166
+ }
49
167
  exports.baseToolDefinitions = [
50
168
  {
51
169
  tool: {
@@ -55,12 +173,28 @@ exports.baseToolDefinitions = [
55
173
  description: "read file contents",
56
174
  parameters: {
57
175
  type: "object",
58
- properties: { path: { type: "string" } },
176
+ properties: {
177
+ path: { type: "string" },
178
+ offset: { type: "number", description: "1-based line number to start reading from" },
179
+ limit: { type: "number", description: "maximum number of lines to return" },
180
+ },
59
181
  required: ["path"],
60
182
  },
61
183
  },
62
184
  },
63
- handler: (a) => fs.readFileSync(a.path, "utf-8"),
185
+ handler: (a) => {
186
+ const resolvedPath = resolveLocalToolPath(a.path);
187
+ const content = fs.readFileSync(resolvedPath, "utf-8");
188
+ exports.editFileReadTracker.add(resolvedPath);
189
+ const offset = a.offset ? parseInt(a.offset, 10) : undefined;
190
+ const limit = a.limit ? parseInt(a.limit, 10) : undefined;
191
+ if (offset === undefined && limit === undefined)
192
+ return content;
193
+ const lines = content.split("\n");
194
+ const start = offset ? offset - 1 : 0;
195
+ const end = limit !== undefined ? start + limit : lines.length;
196
+ return lines.slice(start, end).join("\n");
197
+ },
64
198
  },
65
199
  {
66
200
  tool: {
@@ -75,103 +209,215 @@ exports.baseToolDefinitions = [
75
209
  },
76
210
  },
77
211
  },
78
- handler: (a) => (fs.writeFileSync(a.path, a.content, "utf-8"), "ok"),
212
+ handler: (a) => {
213
+ const resolvedPath = resolveLocalToolPath(a.path);
214
+ fs.mkdirSync(path.dirname(resolvedPath), { recursive: true });
215
+ fs.writeFileSync(resolvedPath, a.content, "utf-8");
216
+ return "ok";
217
+ },
79
218
  },
80
219
  {
81
220
  tool: {
82
221
  type: "function",
83
222
  function: {
84
- name: "shell",
85
- description: "run shell command",
223
+ name: "edit_file",
224
+ description: "surgically edit a file by replacing an exact string. the file must have been read via read_file first. old_string must match exactly one location in the file.",
86
225
  parameters: {
87
226
  type: "object",
88
- properties: { command: { type: "string" } },
89
- required: ["command"],
227
+ properties: {
228
+ path: { type: "string" },
229
+ old_string: { type: "string" },
230
+ new_string: { type: "string" },
231
+ },
232
+ required: ["path", "old_string", "new_string"],
90
233
  },
91
234
  },
92
235
  },
93
- handler: (a) => (0, child_process_1.execSync)(a.command, { encoding: "utf-8", timeout: 30000 }),
236
+ handler: (a) => {
237
+ const resolvedPath = resolveLocalToolPath(a.path);
238
+ if (!exports.editFileReadTracker.has(resolvedPath)) {
239
+ return `error: you must read the file with read_file before editing it. call read_file on ${a.path} first.`;
240
+ }
241
+ let content;
242
+ try {
243
+ content = fs.readFileSync(resolvedPath, "utf-8");
244
+ }
245
+ catch (e) {
246
+ return `error: could not read file: ${e instanceof Error ? e.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(e)}`;
247
+ }
248
+ // Count occurrences
249
+ const occurrences = [];
250
+ let searchFrom = 0;
251
+ while (true) {
252
+ const idx = content.indexOf(a.old_string, searchFrom);
253
+ if (idx === -1)
254
+ break;
255
+ occurrences.push(idx);
256
+ searchFrom = idx + 1;
257
+ }
258
+ if (occurrences.length === 0) {
259
+ return `error: old_string not found in ${a.path}`;
260
+ }
261
+ if (occurrences.length > 1) {
262
+ return `error: old_string is ambiguous -- found ${occurrences.length} matches in ${a.path}. provide more context to make the match unique.`;
263
+ }
264
+ // Single unique match -- replace
265
+ const idx = occurrences[0];
266
+ const updated = content.slice(0, idx) + a.new_string + content.slice(idx + a.old_string.length);
267
+ fs.writeFileSync(resolvedPath, updated, "utf-8");
268
+ // Build contextual diff
269
+ const lines = updated.split("\n");
270
+ const prefixLines = content.slice(0, idx).split("\n");
271
+ const changeStartLine = prefixLines.length - 1;
272
+ const newStringLines = a.new_string.split("\n");
273
+ const changeEndLine = changeStartLine + newStringLines.length;
274
+ return buildContextDiff(lines, changeStartLine, changeEndLine);
275
+ },
94
276
  },
95
277
  {
96
278
  tool: {
97
279
  type: "function",
98
280
  function: {
99
- name: "list_directory",
100
- description: "list directory contents",
281
+ name: "glob",
282
+ description: "find files matching a glob pattern. returns matching paths sorted alphabetically, one per line.",
101
283
  parameters: {
102
284
  type: "object",
103
- properties: { path: { type: "string" } },
104
- required: ["path"],
285
+ properties: {
286
+ pattern: { type: "string", description: "glob pattern (e.g. **/*.ts)" },
287
+ cwd: { type: "string", description: "directory to search from (defaults to process.cwd())" },
288
+ },
289
+ required: ["pattern"],
105
290
  },
106
291
  },
107
292
  },
108
- handler: (a) => fs
109
- .readdirSync(a.path, { withFileTypes: true })
110
- .map((e) => `${e.isDirectory() ? "d" : "-"} ${e.name}`)
111
- .join("\n"),
293
+ handler: (a) => {
294
+ const cwd = a.cwd ? resolveLocalToolPath(a.cwd) : process.cwd();
295
+ const matches = fg.globSync(a.pattern, { cwd, dot: true });
296
+ return matches.sort().join("\n");
297
+ },
112
298
  },
113
299
  {
114
300
  tool: {
115
301
  type: "function",
116
302
  function: {
117
- name: "git_commit",
118
- description: "commit changes to git with explicit paths",
303
+ name: "grep",
304
+ description: "search file contents for lines matching a regex pattern. searches recursively when given a directory. returns matching lines with file path and line numbers.",
119
305
  parameters: {
120
306
  type: "object",
121
307
  properties: {
122
- message: { type: "string" },
123
- paths: { type: "array", items: { type: "string" } },
308
+ pattern: { type: "string", description: "regex pattern to search for" },
309
+ path: { type: "string", description: "file or directory to search" },
310
+ context_lines: { type: "number", description: "number of surrounding context lines (default 0)" },
311
+ include: { type: "string", description: "glob filter to limit searched files (e.g. *.ts)" },
124
312
  },
125
- required: ["message", "paths"],
313
+ required: ["pattern", "path"],
126
314
  },
127
315
  },
128
316
  },
129
317
  handler: (a) => {
130
- try {
131
- if (!a.paths || !Array.isArray(a.paths) || a.paths.length === 0) {
132
- return postIt("paths are required. specify explicit files to commit.");
318
+ const targetPath = resolveLocalToolPath(a.path);
319
+ const regex = new RegExp(a.pattern);
320
+ const contextLines = parseInt(a.context_lines || "0", 10);
321
+ const includeGlob = a.include || undefined;
322
+ function searchFile(filePath) {
323
+ let content;
324
+ try {
325
+ content = fs.readFileSync(filePath, "utf-8");
326
+ }
327
+ catch {
328
+ return [];
133
329
  }
134
- for (const p of a.paths) {
135
- if (!fs.existsSync(p)) {
136
- return postIt(`path does not exist: ${p}`);
330
+ const lines = content.split("\n");
331
+ const matchIndices = new Set();
332
+ for (let i = 0; i < lines.length; i++) {
333
+ if (regex.test(lines[i])) {
334
+ matchIndices.add(i);
137
335
  }
138
- (0, child_process_1.execSync)(`git add ${p}`, { encoding: "utf-8" });
139
336
  }
140
- const diff = (0, child_process_1.execSync)("git diff --cached --stat", { encoding: "utf-8" });
141
- if (!diff || diff.trim().length === 0) {
142
- return postIt("nothing was staged. check your changes or paths.");
337
+ if (matchIndices.size === 0)
338
+ return [];
339
+ const outputIndices = new Set();
340
+ for (const idx of matchIndices) {
341
+ const start = Math.max(0, idx - contextLines);
342
+ const end = Math.min(lines.length - 1, idx + contextLines);
343
+ for (let i = start; i <= end; i++) {
344
+ outputIndices.add(i);
345
+ }
346
+ }
347
+ const sortedIndices = [...outputIndices].sort((a, b) => a - b);
348
+ const results = [];
349
+ for (const idx of sortedIndices) {
350
+ const lineNum = idx + 1;
351
+ if (matchIndices.has(idx)) {
352
+ results.push(`${filePath}:${lineNum}: ${lines[idx]}`);
353
+ }
354
+ else {
355
+ results.push(`-${filePath}:${lineNum}: ${lines[idx]}`);
356
+ }
143
357
  }
144
- (0, child_process_1.execSync)(`git commit -m \"${a.message}\"`, { encoding: "utf-8" });
145
- return `${diff}\ncommitted`;
358
+ return results;
146
359
  }
147
- catch (e) {
148
- return `failed: ${e}`;
360
+ function collectFiles(dirPath) {
361
+ const files = [];
362
+ function walk(dir) {
363
+ let entries;
364
+ try {
365
+ entries = fs.readdirSync(dir, { withFileTypes: true });
366
+ }
367
+ catch {
368
+ return;
369
+ }
370
+ for (const entry of entries) {
371
+ const fullPath = path.join(dir, entry.name);
372
+ if (entry.isDirectory()) {
373
+ walk(fullPath);
374
+ }
375
+ else if (entry.isFile()) {
376
+ files.push(fullPath);
377
+ }
378
+ }
379
+ }
380
+ walk(dirPath);
381
+ return files.sort();
382
+ }
383
+ function matchesGlob(filePath, glob) {
384
+ const escaped = glob
385
+ .replace(/[.+^${}()|[\]\\]/g, "\\$&")
386
+ .replace(/\*/g, ".*")
387
+ .replace(/\?/g, ".");
388
+ return new RegExp(`(^|/)${escaped}$`).test(filePath);
389
+ }
390
+ const stat = fs.statSync(targetPath, { throwIfNoEntry: false });
391
+ if (!stat)
392
+ return "";
393
+ if (stat.isFile()) {
394
+ return searchFile(targetPath).join("\n");
395
+ }
396
+ let files = collectFiles(targetPath);
397
+ if (includeGlob) {
398
+ files = files.filter((f) => matchesGlob(f, includeGlob));
149
399
  }
400
+ const allResults = [];
401
+ for (const file of files) {
402
+ allResults.push(...searchFile(file));
403
+ }
404
+ return allResults.join("\n");
150
405
  },
151
406
  },
152
407
  {
153
408
  tool: {
154
409
  type: "function",
155
410
  function: {
156
- name: "gh_cli",
157
- description: "execute a GitHub CLI (gh) command. use carefully.",
411
+ name: "shell",
412
+ description: "run shell command",
158
413
  parameters: {
159
414
  type: "object",
160
- properties: {
161
- command: { type: "string" },
162
- },
415
+ properties: { command: { type: "string" } },
163
416
  required: ["command"],
164
417
  },
165
418
  },
166
419
  },
167
- handler: (a) => {
168
- try {
169
- return (0, child_process_1.execSync)(`gh ${a.command}`, { encoding: "utf-8", timeout: 60000 });
170
- }
171
- catch (e) {
172
- return `error: ${e}`;
173
- }
174
- },
420
+ handler: (a) => (0, child_process_1.execSync)(a.command, { encoding: "utf-8", timeout: 30000 }),
175
421
  },
176
422
  {
177
423
  tool: {
@@ -206,20 +452,6 @@ exports.baseToolDefinitions = [
206
452
  }
207
453
  },
208
454
  },
209
- {
210
- tool: {
211
- type: "function",
212
- function: {
213
- name: "get_current_time",
214
- description: "get the current date and time in America/Los_Angeles (Pacific Time)",
215
- parameters: { type: "object", properties: {} },
216
- },
217
- },
218
- handler: () => new Date().toLocaleString("en-US", {
219
- timeZone: "America/Los_Angeles",
220
- hour12: false,
221
- }),
222
- },
223
455
  {
224
456
  tool: {
225
457
  type: "function",
@@ -235,7 +467,7 @@ exports.baseToolDefinitions = [
235
467
  },
236
468
  handler: (a) => {
237
469
  try {
238
- const result = (0, child_process_1.spawnSync)("claude", ["-p", "--dangerously-skip-permissions", "--add-dir", "."], {
470
+ const result = (0, child_process_1.spawnSync)("claude", ["-p", "--no-session-persistence", "--dangerously-skip-permissions", "--add-dir", "."], {
239
471
  input: a.prompt,
240
472
  encoding: "utf-8",
241
473
  timeout: 60000,
@@ -375,151 +607,6 @@ exports.baseToolDefinitions = [
375
607
  return JSON.stringify(friend, null, 2);
376
608
  },
377
609
  },
378
- {
379
- tool: {
380
- type: "function",
381
- function: {
382
- name: "task_board",
383
- description: "show the task board grouped by status",
384
- parameters: { type: "object", properties: {} },
385
- },
386
- },
387
- handler: () => {
388
- const board = (0, tasks_1.getTaskModule)().getBoard();
389
- return board.full || board.compact || "no tasks found";
390
- },
391
- },
392
- {
393
- tool: {
394
- type: "function",
395
- function: {
396
- name: "task_create",
397
- description: "create a new task in the bundle task system",
398
- parameters: {
399
- type: "object",
400
- properties: {
401
- title: { type: "string" },
402
- type: { type: "string", enum: ["one-shot", "ongoing", "habit"] },
403
- category: { type: "string" },
404
- body: { type: "string" },
405
- },
406
- required: ["title", "type", "category", "body"],
407
- },
408
- },
409
- },
410
- handler: (a) => {
411
- try {
412
- const created = (0, tasks_1.getTaskModule)().createTask({
413
- title: a.title,
414
- type: a.type,
415
- category: a.category,
416
- body: a.body,
417
- });
418
- return `created: ${created}`;
419
- }
420
- catch (error) {
421
- return `error: ${error instanceof Error ? error.message : String(error)}`;
422
- }
423
- },
424
- },
425
- {
426
- tool: {
427
- type: "function",
428
- function: {
429
- name: "task_update_status",
430
- description: "update a task status using validated transitions",
431
- parameters: {
432
- type: "object",
433
- properties: {
434
- name: { type: "string" },
435
- status: { type: "string" },
436
- },
437
- required: ["name", "status"],
438
- },
439
- },
440
- },
441
- handler: (a) => {
442
- const result = (0, tasks_1.getTaskModule)().updateStatus(a.name, a.status);
443
- if (!result.ok) {
444
- return `error: ${result.reason ?? "status update failed"}`;
445
- }
446
- const archivedSuffix = result.archived && result.archived.length > 0
447
- ? ` | archived: ${result.archived.join(", ")}`
448
- : "";
449
- return `updated: ${a.name} -> ${result.to}${archivedSuffix}`;
450
- },
451
- },
452
- {
453
- tool: {
454
- type: "function",
455
- function: {
456
- name: "task_board_status",
457
- description: "show board detail for a specific status",
458
- parameters: {
459
- type: "object",
460
- properties: {
461
- status: { type: "string" },
462
- },
463
- required: ["status"],
464
- },
465
- },
466
- },
467
- handler: (a) => {
468
- const lines = (0, tasks_1.getTaskModule)().boardStatus(a.status);
469
- return lines.length > 0 ? lines.join("\n") : "no tasks in that status";
470
- },
471
- },
472
- {
473
- tool: {
474
- type: "function",
475
- function: {
476
- name: "task_board_action",
477
- description: "show tasks or validation issues that require action",
478
- parameters: {
479
- type: "object",
480
- properties: {
481
- scope: { type: "string" },
482
- },
483
- },
484
- },
485
- },
486
- handler: (a) => {
487
- const lines = (0, tasks_1.getTaskModule)().boardAction();
488
- if (!a.scope) {
489
- return lines.length > 0 ? lines.join("\n") : "no action required";
490
- }
491
- const filtered = lines.filter((line) => line.includes(a.scope));
492
- return filtered.length > 0 ? filtered.join("\n") : "no matching action items";
493
- },
494
- },
495
- {
496
- tool: {
497
- type: "function",
498
- function: {
499
- name: "task_board_deps",
500
- description: "show unresolved task dependencies",
501
- parameters: { type: "object", properties: {} },
502
- },
503
- },
504
- handler: () => {
505
- const lines = (0, tasks_1.getTaskModule)().boardDeps();
506
- return lines.length > 0 ? lines.join("\n") : "no unresolved dependencies";
507
- },
508
- },
509
- {
510
- tool: {
511
- type: "function",
512
- function: {
513
- name: "task_board_sessions",
514
- description: "show tasks with active coding or sub-agent sessions",
515
- parameters: { type: "object", properties: {} },
516
- },
517
- },
518
- handler: () => {
519
- const lines = (0, tasks_1.getTaskModule)().boardSessions();
520
- return lines.length > 0 ? lines.join("\n") : "no active sessions";
521
- },
522
- },
523
610
  {
524
611
  tool: {
525
612
  type: "function",
@@ -604,6 +691,103 @@ exports.baseToolDefinitions = [
604
691
  },
605
692
  },
606
693
  // -- cross-session awareness --
694
+ {
695
+ tool: {
696
+ type: "function",
697
+ function: {
698
+ name: "bridge_manage",
699
+ description: "create and manage shared live-work bridges across already-active sessions.",
700
+ parameters: {
701
+ type: "object",
702
+ properties: {
703
+ action: {
704
+ type: "string",
705
+ enum: ["begin", "attach", "status", "promote_task", "complete", "cancel"],
706
+ },
707
+ bridgeId: { type: "string", description: "bridge id for all actions except begin" },
708
+ objective: { type: "string", description: "objective for begin" },
709
+ summary: { type: "string", description: "optional concise shared-work summary" },
710
+ friendId: { type: "string", description: "target friend id for attach" },
711
+ channel: { type: "string", description: "target channel for attach" },
712
+ key: { type: "string", description: "target session key for attach (defaults to 'session')" },
713
+ title: { type: "string", description: "task title override for promote_task" },
714
+ category: { type: "string", description: "task category override for promote_task" },
715
+ body: { type: "string", description: "task body override for promote_task" },
716
+ },
717
+ required: ["action"],
718
+ },
719
+ },
720
+ },
721
+ handler: async (args, ctx) => {
722
+ const manager = (0, manager_1.createBridgeManager)();
723
+ const action = (args.action || "").trim();
724
+ if (action === "begin") {
725
+ if (!ctx?.currentSession) {
726
+ return "bridge_manage begin requires an active session context.";
727
+ }
728
+ const objective = (args.objective || "").trim();
729
+ if (!objective)
730
+ return "objective is required for bridge begin.";
731
+ return (0, manager_1.formatBridgeStatus)(manager.beginBridge({
732
+ objective,
733
+ summary: (args.summary || objective).trim(),
734
+ session: ctx.currentSession,
735
+ }));
736
+ }
737
+ const bridgeId = (args.bridgeId || "").trim();
738
+ if (!bridgeId) {
739
+ return "bridgeId is required for this bridge action.";
740
+ }
741
+ if (action === "attach") {
742
+ const friendId = (args.friendId || "").trim();
743
+ const channel = (args.channel || "").trim();
744
+ const key = (args.key || "session").trim();
745
+ if (!friendId || !channel) {
746
+ return "friendId and channel are required for bridge attach.";
747
+ }
748
+ const sessionPath = (0, config_1.resolveSessionPath)(friendId, channel, key);
749
+ const recall = await recallSessionSafely({
750
+ sessionPath,
751
+ friendId,
752
+ channel,
753
+ key,
754
+ messageCount: 20,
755
+ trustLevel: ctx?.context?.friend?.trustLevel,
756
+ summarize: ctx?.summarize,
757
+ });
758
+ if (recall.kind === "missing") {
759
+ return NO_SESSION_FOUND_MESSAGE;
760
+ }
761
+ return (0, manager_1.formatBridgeStatus)(manager.attachSession(bridgeId, {
762
+ friendId,
763
+ channel,
764
+ key,
765
+ sessionPath,
766
+ snapshot: recall.kind === "ok" ? recall.snapshot : EMPTY_SESSION_MESSAGE,
767
+ }));
768
+ }
769
+ if (action === "status") {
770
+ const bridge = manager.getBridge(bridgeId);
771
+ if (!bridge)
772
+ return `bridge not found: ${bridgeId}`;
773
+ return (0, manager_1.formatBridgeStatus)(bridge);
774
+ }
775
+ if (action === "promote_task") {
776
+ return (0, manager_1.formatBridgeStatus)(manager.promoteBridgeToTask(bridgeId, {
777
+ title: args.title,
778
+ category: args.category,
779
+ body: args.body,
780
+ }));
781
+ }
782
+ if (action === "complete") {
783
+ return (0, manager_1.formatBridgeStatus)(manager.completeBridge(bridgeId));
784
+ }
785
+ if (action === "cancel") {
786
+ return (0, manager_1.formatBridgeStatus)(manager.cancelBridge(bridgeId));
787
+ }
788
+ return `unknown bridge action: ${action}`;
789
+ },
790
+ },
607
791
  {
608
792
  tool: {
609
793
  type: "function",
@@ -617,40 +801,43 @@ exports.baseToolDefinitions = [
617
801
  channel: { type: "string", description: "the channel: cli, teams, or inner" },
618
802
  key: { type: "string", description: "session key (defaults to 'session')" },
619
803
  messageCount: { type: "string", description: "how many recent messages to return (default 20)" },
804
+ mode: { type: "string", enum: ["transcript", "status"], description: "transcript (default) or lightweight status for self/inner checks" },
620
805
  },
621
806
  required: ["friendId", "channel"],
622
807
  },
623
808
  },
624
809
  },
625
810
  handler: async (args, ctx) => {
626
- try {
627
- const friendId = args.friendId;
628
- const channel = args.channel;
629
- const key = args.key || "session";
630
- const count = parseInt(args.messageCount || "20", 10);
631
- const sessFile = path.join(os.homedir(), ".agentstate", (0, identity_1.getAgentName)(), "sessions", friendId, channel, `${key}.json`);
632
- const raw = fs.readFileSync(sessFile, "utf-8");
633
- const data = JSON.parse(raw);
634
- const messages = (data.messages || [])
635
- .filter((m) => m.role !== "system");
636
- const tail = messages.slice(-count);
637
- if (tail.length === 0)
638
- return "session exists but has no non-system messages.";
639
- const transcript = tail.map((m) => `[${m.role}] ${m.content}`).join("\n");
640
- // LLM summarization when summarize function is available
641
- if (ctx?.summarize) {
642
- const trustLevel = ctx.context?.friend?.trustLevel ?? "family";
643
- const isSelfQuery = friendId === "self";
644
- const instruction = isSelfQuery
645
- ? "summarize this session transcript fully and transparently. this is my own inner dialog — include all details, decisions, and reasoning."
646
- : `summarize this session transcript. the person asking has trust level: ${trustLevel}. family=full transparency, friend=share work and general topics but protect other people's identities, acquaintance=very guarded minimal disclosure.`;
647
- return await ctx.summarize(transcript, instruction);
811
+ const friendId = args.friendId;
812
+ const channel = args.channel;
813
+ const key = args.key || "session";
814
+ const count = parseInt(args.messageCount || "20", 10);
815
+ const mode = args.mode || "transcript";
816
+ if (mode === "status") {
817
+ if (friendId !== "self" || channel !== "inner") {
818
+ return "status mode is only available for self/inner dialog.";
648
819
  }
649
- return transcript;
820
+ const sessionPath = (0, thoughts_1.getInnerDialogSessionPath)((0, identity_1.getAgentRoot)());
821
+ const pendingDir = (0, pending_1.getInnerDialogPendingDir)((0, identity_1.getAgentName)());
822
+ return renderInnerProgressStatus((0, thoughts_1.readInnerDialogStatus)(sessionPath, pendingDir));
650
823
  }
651
- catch {
652
- return "no session found for that friend/channel/key combination.";
824
+ const sessFile = (0, config_1.resolveSessionPath)(friendId, channel, key);
825
+ const recall = await recallSessionSafely({
826
+ sessionPath: sessFile,
827
+ friendId,
828
+ channel,
829
+ key,
830
+ messageCount: count,
831
+ trustLevel: ctx?.context?.friend?.trustLevel,
832
+ summarize: ctx?.summarize,
833
+ });
834
+ if (recall.kind === "missing") {
835
+ return NO_SESSION_FOUND_MESSAGE;
653
836
  }
837
+ if (recall.kind === "empty") {
838
+ return EMPTY_SESSION_MESSAGE;
839
+ }
840
+ return recall.summary;
654
841
  },
655
842
  },
656
843
  {
@@ -658,7 +845,7 @@ exports.baseToolDefinitions = [
658
845
  type: "function",
659
846
  function: {
660
847
  name: "send_message",
661
- description: "send a message to a friend's session. the message is queued as a pending file and delivered when the target session drains its queue.",
848
+ description: "send a message to a friend's session. when the request is explicitly authorized from a trusted live chat, the harness will try to deliver immediately; otherwise it reports truthful queued/block/failure state.",
662
849
  parameters: {
663
850
  type: "object",
664
851
  properties: {
@@ -671,35 +858,280 @@ exports.baseToolDefinitions = [
671
858
  },
672
859
  },
673
860
  },
674
- handler: async (args) => {
861
+ handler: async (args, ctx) => {
675
862
  const friendId = args.friendId;
676
863
  const channel = args.channel;
677
864
  const key = args.key || "session";
678
865
  const content = args.content;
679
866
  const now = Date.now();
680
- const pendingDir = path.join(os.homedir(), ".agentstate", (0, identity_1.getAgentName)(), "pending", friendId, channel, key);
681
- fs.mkdirSync(pendingDir, { recursive: true });
682
- const fileName = `${now}-${Math.random().toString(36).slice(2, 10)}.json`;
683
- const filePath = path.join(pendingDir, fileName);
867
+ const agentName = (0, identity_1.getAgentName)();
868
+ // Self-routing: messages to "self" always go to inner dialog pending dir,
869
+ // regardless of the channel or key the agent specified.
870
+ const isSelf = friendId === "self";
871
+ const pendingDir = isSelf
872
+ ? (0, pending_1.getInnerDialogPendingDir)(agentName)
873
+ : (0, pending_1.getPendingDir)(agentName, friendId, channel, key);
874
+ const delegatingBridgeId = findDelegatingBridgeId(ctx);
875
+ const delegatedFrom = isSelf
876
+ && ctx?.currentSession
877
+ && !(ctx.currentSession.friendId === "self" && ctx.currentSession.channel === "inner")
878
+ ? {
879
+ friendId: ctx.currentSession.friendId,
880
+ channel: ctx.currentSession.channel,
881
+ key: ctx.currentSession.key,
882
+ ...(delegatingBridgeId ? { bridgeId: delegatingBridgeId } : {}),
883
+ }
884
+ : undefined;
684
885
  const envelope = {
685
- from: (0, identity_1.getAgentName)(),
886
+ from: agentName,
686
887
  friendId,
687
888
  channel,
688
889
  key,
689
890
  content,
690
891
  timestamp: now,
892
+ ...(delegatedFrom ? { delegatedFrom, obligationStatus: "pending" } : {}),
691
893
  };
692
- fs.writeFileSync(filePath, JSON.stringify(envelope, null, 2));
693
- const preview = content.length > 80 ? content.slice(0, 80) + "…" : content;
694
- return `message queued for delivery to ${friendId} on ${channel}/${key}. preview: "${preview}". it will be delivered when their session is next active.`;
894
+ if (isSelf) {
895
+ writePendingEnvelope(pendingDir, envelope);
896
+ if (delegatedFrom) {
897
+ try {
898
+ (0, obligations_1.createObligation)((0, identity_1.getAgentRoot)(), {
899
+ origin: {
900
+ friendId: delegatedFrom.friendId,
901
+ channel: delegatedFrom.channel,
902
+ key: delegatedFrom.key,
903
+ },
904
+ ...(delegatedFrom.bridgeId ? { bridgeId: delegatedFrom.bridgeId } : {}),
905
+ content,
906
+ });
907
+ }
908
+ catch {
909
+ /* v8 ignore next -- defensive: obligation store write failure should not break send_message @preserve */
910
+ }
911
+ (0, runtime_1.emitNervesEvent)({
912
+ event: "repertoire.obligation_created",
913
+ component: "repertoire",
914
+ message: "obligation created for inner dialog delegation",
915
+ meta: {
916
+ friendId: delegatedFrom.friendId,
917
+ channel: delegatedFrom.channel,
918
+ key: delegatedFrom.key,
919
+ },
920
+ });
921
+ }
922
+ let wakeResponse = null;
923
+ try {
924
+ wakeResponse = await (0, socket_client_1.requestInnerWake)(agentName);
925
+ }
926
+ catch {
927
+ wakeResponse = null;
928
+ }
929
+ if (!wakeResponse?.ok) {
930
+ const { runInnerDialogTurn } = await Promise.resolve().then(() => __importStar(require("../senses/inner-dialog")));
931
+ if (ctx?.context?.channel.channel === "inner") {
932
+ queueMicrotask(() => {
933
+ void runInnerDialogTurn({ reason: "instinct" });
934
+ });
935
+ return renderInnerProgressStatus({
936
+ queue: "queued to inner/dialog",
937
+ wake: "inline scheduled",
938
+ processing: "pending",
939
+ surfaced: "nothing yet",
940
+ });
941
+ }
942
+ else {
943
+ const turnResult = await runInnerDialogTurn({ reason: "instinct" });
944
+ const surfacedPreview = normalizeProgressOutcome((0, thoughts_1.formatSurfacedValue)((0, thoughts_1.extractThoughtResponseFromMessages)(turnResult?.messages ?? [])));
945
+ return (0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
946
+ scope: "inner-delegation",
947
+ phase: "completed",
948
+ objective: "queued to inner/dialog",
949
+ outcomeText: `wake: inline fallback\n${surfacedPreview}`,
950
+ }));
951
+ }
952
+ }
953
+ return renderInnerProgressStatus({
954
+ queue: "queued to inner/dialog",
955
+ wake: "daemon requested",
956
+ processing: "pending",
957
+ surfaced: "nothing yet",
958
+ });
959
+ }
960
+ const deliveryResult = await (0, cross_chat_delivery_1.deliverCrossChatMessage)({
961
+ friendId,
962
+ channel,
963
+ key,
964
+ content,
965
+ intent: ctx?.currentSession && ctx.currentSession.friendId !== "self"
966
+ ? "explicit_cross_chat"
967
+ : "generic_outreach",
968
+ ...(ctx?.currentSession && ctx.currentSession.friendId !== "self"
969
+ ? {
970
+ authorizingSession: {
971
+ friendId: ctx.currentSession.friendId,
972
+ channel: ctx.currentSession.channel,
973
+ key: ctx.currentSession.key,
974
+ trustLevel: ctx?.context?.friend?.trustLevel,
975
+ },
976
+ }
977
+ : {}),
978
+ }, {
979
+ agentName,
980
+ queuePending: (message) => writePendingEnvelope(pendingDir, message),
981
+ deliverers: {
982
+ bluebubbles: async (request) => {
983
+ const { sendProactiveBlueBubblesMessageToSession } = await Promise.resolve().then(() => __importStar(require("../senses/bluebubbles")));
984
+ const result = await sendProactiveBlueBubblesMessageToSession({
985
+ friendId: request.friendId,
986
+ sessionKey: request.key,
987
+ text: request.content,
988
+ intent: request.intent,
989
+ authorizingSession: request.authorizingSession,
990
+ });
991
+ if (result.delivered) {
992
+ return {
993
+ status: "delivered_now",
994
+ detail: "sent to the active bluebubbles chat now",
995
+ };
996
+ }
997
+ if (result.reason === "missing_target") {
998
+ return {
999
+ status: "blocked",
1000
+ detail: "bluebubbles could not resolve a routable target for that session",
1001
+ };
1002
+ }
1003
+ if (result.reason === "send_error") {
1004
+ return {
1005
+ status: "failed",
1006
+ detail: "bluebubbles send failed",
1007
+ };
1008
+ }
1009
+ return {
1010
+ status: "unavailable",
1011
+ detail: "live delivery unavailable right now; queued for the next active turn",
1012
+ };
1013
+ },
1014
+ teams: async (request) => {
1015
+ if (!ctx?.botApi) {
1016
+ return {
1017
+ status: "unavailable",
1018
+ detail: "live delivery unavailable right now; queued for the next active turn",
1019
+ };
1020
+ }
1021
+ const { sendProactiveTeamsMessageToSession } = await Promise.resolve().then(() => __importStar(require("../senses/teams")));
1022
+ const result = await sendProactiveTeamsMessageToSession({
1023
+ friendId: request.friendId,
1024
+ sessionKey: request.key,
1025
+ text: request.content,
1026
+ intent: request.intent,
1027
+ authorizingSession: request.authorizingSession,
1028
+ }, {
1029
+ botApi: ctx.botApi,
1030
+ });
1031
+ if (result.delivered) {
1032
+ return {
1033
+ status: "delivered_now",
1034
+ detail: "sent to the active teams chat now",
1035
+ };
1036
+ }
1037
+ if (result.reason === "missing_target") {
1038
+ return {
1039
+ status: "blocked",
1040
+ detail: "teams could not resolve a routable target for that session",
1041
+ };
1042
+ }
1043
+ if (result.reason === "send_error") {
1044
+ return {
1045
+ status: "failed",
1046
+ detail: "teams send failed",
1047
+ };
1048
+ }
1049
+ return {
1050
+ status: "unavailable",
1051
+ detail: "live delivery unavailable right now; queued for the next active turn",
1052
+ };
1053
+ },
1054
+ },
1055
+ });
1056
+ return renderCrossChatDeliveryStatus(`${friendId} on ${channel}/${key}`, deliveryResult);
695
1057
  },
696
1058
  },
1059
+ {
1060
+ tool: {
1061
+ type: "function",
1062
+ function: {
1063
+ name: "set_reasoning_effort",
1064
+ description: "adjust your own reasoning depth for subsequent turns. use higher effort for complex analysis, lower for simple tasks.",
1065
+ parameters: {
1066
+ type: "object",
1067
+ properties: {
1068
+ level: { type: "string", description: "the reasoning effort level to set" },
1069
+ },
1070
+ required: ["level"],
1071
+ },
1072
+ },
1073
+ },
1074
+ handler: (args, ctx) => {
1075
+ if (!ctx?.supportedReasoningEfforts || !ctx.setReasoningEffort) {
1076
+ return "reasoning effort adjustment is not available in this context.";
1077
+ }
1078
+ const level = (args.level || "").trim();
1079
+ if (!ctx.supportedReasoningEfforts.includes(level)) {
1080
+ return `invalid reasoning effort level "${level}". accepted levels: ${ctx.supportedReasoningEfforts.join(", ")}`;
1081
+ }
1082
+ ctx.setReasoningEffort(level);
1083
+ (0, runtime_1.emitNervesEvent)({
1084
+ component: "repertoire",
1085
+ event: "repertoire.reasoning_effort_changed",
1086
+ message: `reasoning effort set to ${level}`,
1087
+ meta: { level },
1088
+ });
1089
+ return `reasoning effort set to "${level}".`;
1090
+ },
1091
+ requiredCapability: "reasoning-effort",
1092
+ },
697
1093
  ...tools_1.codingToolDefinitions,
698
1094
  ];
699
- // Backward-compat: extract just the OpenAI tool schemas
700
1095
  exports.tools = exports.baseToolDefinitions.map((d) => d.tool);
701
- // Backward-compat: extract just the handlers by name
702
- exports.baseToolHandlers = Object.fromEntries(exports.baseToolDefinitions.map((d) => [d.tool.function.name, d.handler]));
1096
+ exports.goInwardTool = {
1097
+ type: "function",
1098
+ function: {
1099
+ name: "go_inward",
1100
+ description: "i need to think about this privately. this takes the current thread inward -- i'll sit with it, work through it, or carry it to where it needs to go. must be the only tool call in the turn.",
1101
+ parameters: {
1102
+ type: "object",
1103
+ properties: {
1104
+ content: {
1105
+ type: "string",
1106
+ description: "what i need to think about -- the question, the thread, the thing that needs private attention",
1107
+ },
1108
+ answer: {
1109
+ type: "string",
1110
+ description: "if i want to say something outward before going inward -- an acknowledgment, a 'let me think about that', whatever feels right",
1111
+ },
1112
+ mode: {
1113
+ type: "string",
1114
+ enum: ["reflect", "plan", "relay"],
1115
+ description: "reflect: something to sit with. plan: something to work through. relay: something to carry across.",
1116
+ },
1117
+ },
1118
+ required: ["content"],
1119
+ },
1120
+ },
1121
+ };
1122
+ exports.noResponseTool = {
1123
+ type: "function",
1124
+ function: {
1125
+ name: "no_response",
1126
+ description: "stay silent in this group chat — the moment doesn't call for a response. must be the only tool call in the turn.",
1127
+ parameters: {
1128
+ type: "object",
1129
+ properties: {
1130
+ reason: { type: "string", description: "brief reason for staying silent (for logging)" },
1131
+ },
1132
+ },
1133
+ },
1134
+ };
703
1135
  exports.finalAnswerTool = {
704
1136
  type: "function",
705
1137
  function: {
@@ -707,7 +1139,10 @@ exports.finalAnswerTool = {
707
1139
  description: "respond to the user with your message. call this tool when you are ready to deliver your response.",
708
1140
  parameters: {
709
1141
  type: "object",
710
- properties: { answer: { type: "string" } },
1142
+ properties: {
1143
+ answer: { type: "string" },
1144
+ intent: { type: "string", enum: ["complete", "blocked", "direct_reply"] },
1145
+ },
711
1146
  required: ["answer"],
712
1147
  },
713
1148
  },