@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
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bluebubblesToolDefinitions = void 0;
4
+ const runtime_1 = require("../nerves/runtime");
5
+ exports.bluebubblesToolDefinitions = [
6
+ {
7
+ tool: {
8
+ type: "function",
9
+ function: {
10
+ name: "bluebubbles_set_reply_target",
11
+ description: "choose where the current iMessage turn should land. use this when you want to widen back to top-level or route your update into a specific active thread in the same chat.",
12
+ parameters: {
13
+ type: "object",
14
+ properties: {
15
+ target: {
16
+ type: "string",
17
+ enum: ["current_lane", "top_level", "thread"],
18
+ description: "current_lane mirrors the current inbound lane, top_level answers in the main chat, and thread targets a specific active thread.",
19
+ },
20
+ threadOriginatorGuid: {
21
+ type: "string",
22
+ description: "required when target=thread; use one of the thread ids surfaced in the inbound iMessage context.",
23
+ },
24
+ },
25
+ required: ["target"],
26
+ },
27
+ },
28
+ },
29
+ handler: (args, ctx) => {
30
+ const target = typeof args.target === "string" ? args.target.trim() : "";
31
+ const controller = ctx?.bluebubblesReplyTarget;
32
+ if (!controller) {
33
+ (0, runtime_1.emitNervesEvent)({
34
+ level: "warn",
35
+ component: "tools",
36
+ event: "tool.error",
37
+ message: "bluebubbles reply target missing controller",
38
+ meta: { target },
39
+ });
40
+ return "bluebubbles reply targeting is not available in this context.";
41
+ }
42
+ if (target === "current_lane") {
43
+ const result = controller.setSelection({ target: "current_lane" });
44
+ (0, runtime_1.emitNervesEvent)({
45
+ component: "tools",
46
+ event: "tool.end",
47
+ message: "bluebubbles reply target updated",
48
+ meta: { target: "current_lane", success: true },
49
+ });
50
+ return result;
51
+ }
52
+ if (target === "top_level") {
53
+ const result = controller.setSelection({ target: "top_level" });
54
+ (0, runtime_1.emitNervesEvent)({
55
+ component: "tools",
56
+ event: "tool.end",
57
+ message: "bluebubbles reply target updated",
58
+ meta: { target: "top_level", success: true },
59
+ });
60
+ return result;
61
+ }
62
+ if (target === "thread") {
63
+ const threadOriginatorGuid = typeof args.threadOriginatorGuid === "string" ? args.threadOriginatorGuid.trim() : "";
64
+ if (!threadOriginatorGuid) {
65
+ (0, runtime_1.emitNervesEvent)({
66
+ level: "warn",
67
+ component: "tools",
68
+ event: "tool.error",
69
+ message: "bluebubbles reply target missing thread id",
70
+ meta: { target: "thread" },
71
+ });
72
+ return "threadOriginatorGuid is required when target=thread.";
73
+ }
74
+ const result = controller.setSelection({ target: "thread", threadOriginatorGuid });
75
+ (0, runtime_1.emitNervesEvent)({
76
+ component: "tools",
77
+ event: "tool.end",
78
+ message: "bluebubbles reply target updated",
79
+ meta: { target: "thread", success: true },
80
+ });
81
+ return result;
82
+ }
83
+ (0, runtime_1.emitNervesEvent)({
84
+ level: "warn",
85
+ component: "tools",
86
+ event: "tool.error",
87
+ message: "bluebubbles reply target invalid target",
88
+ meta: { target },
89
+ });
90
+ return "target must be one of: current_lane, top_level, thread.";
91
+ },
92
+ },
93
+ ];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.teamsToolHandlers = exports.teamsTools = exports.teamsToolDefinitions = void 0;
6
+ exports.teamsToolDefinitions = void 0;
7
7
  exports.summarizeTeamsArgs = summarizeTeamsArgs;
8
8
  const graph_client_1 = require("./graph-client");
9
9
  const ado_client_1 = require("./ado-client");
@@ -11,16 +11,6 @@ const graph_endpoints_json_1 = __importDefault(require("./data/graph-endpoints.j
11
11
  const ado_endpoints_json_1 = __importDefault(require("./data/ado-endpoints.json"));
12
12
  const runtime_1 = require("../nerves/runtime");
13
13
  const MUTATE_METHODS = ["POST", "PATCH", "DELETE"];
14
- // Map HTTP method to authority action name for canWrite() checks
15
- const METHOD_TO_ACTION = {
16
- POST: "createWorkItem",
17
- PATCH: "updateWorkItem",
18
- DELETE: "deleteWorkItem",
19
- };
20
- // Check if a tool response indicates a 403 PERMISSION_DENIED (authority checker removed; this is now a no-op kept for call-site stability)
21
- function checkAndRecord403(_result, _integration, _scope, _action, _ctx) {
22
- // No-op: AuthorityChecker eliminated. 403 recording removed.
23
- }
24
14
  const DEFAULT_ADO_QUERY = "SELECT [System.Id], [System.Title], [System.State], [System.AssignedTo] FROM WorkItems WHERE [System.AssignedTo] = @Me AND [System.State] <> 'Closed' ORDER BY [System.ChangedDate] DESC";
25
15
  exports.teamsToolDefinitions = [
26
16
  // -- Generic Graph tools --
@@ -82,7 +72,7 @@ exports.teamsToolDefinitions = [
82
72
  type: "function",
83
73
  function: {
84
74
  name: "ado_query",
85
- description: "GET or POST (for WIQL read queries) any Azure DevOps API endpoint. Use ado_docs first to look up the correct path.",
75
+ description: "GET or POST (for WIQL read queries) any Azure DevOps API endpoint. Use ado_docs first to look up the correct path and host.",
86
76
  parameters: {
87
77
  type: "object",
88
78
  properties: {
@@ -90,6 +80,7 @@ exports.teamsToolDefinitions = [
90
80
  path: { type: "string", description: "ADO API path after /{org}, e.g. /_apis/wit/wiql" },
91
81
  method: { type: "string", enum: ["GET", "POST"], description: "HTTP method (defaults to GET)" },
92
82
  body: { type: "string", description: "JSON request body (optional, used with POST for WIQL)" },
83
+ host: { type: "string", description: "API host override for non-standard APIs (e.g. 'vsapm.dev.azure.com' for entitlements, 'vssps.dev.azure.com' for users). Omit for standard dev.azure.com." },
93
84
  },
94
85
  required: ["organization", "path"],
95
86
  },
@@ -100,9 +91,7 @@ exports.teamsToolDefinitions = [
100
91
  return "AUTH_REQUIRED:ado -- I need access to Azure DevOps. Please sign in when prompted.";
101
92
  }
102
93
  const method = args.method || "GET";
103
- const result = await (0, ado_client_1.adoRequest)(ctx.adoToken, method, args.organization, args.path, args.body);
104
- checkAndRecord403(result, "ado", args.organization, method, ctx);
105
- return result;
94
+ return (0, ado_client_1.adoRequest)(ctx.adoToken, method, args.organization, args.path, args.body, args.host);
106
95
  },
107
96
  integration: "ado",
108
97
  },
@@ -111,7 +100,7 @@ exports.teamsToolDefinitions = [
111
100
  type: "function",
112
101
  function: {
113
102
  name: "ado_mutate",
114
- description: "POST/PATCH/DELETE any Azure DevOps API endpoint for actual mutations. Use ado_docs first to look up the correct path.",
103
+ description: "POST/PATCH/DELETE any Azure DevOps API endpoint for actual mutations. Use ado_docs first to look up the correct path and host.",
115
104
  parameters: {
116
105
  type: "object",
117
106
  properties: {
@@ -119,6 +108,7 @@ exports.teamsToolDefinitions = [
119
108
  organization: { type: "string", description: "Azure DevOps organization name" },
120
109
  path: { type: "string", description: "ADO API path after /{org}" },
121
110
  body: { type: "string", description: "JSON request body (optional)" },
111
+ host: { type: "string", description: "API host override for non-standard APIs (e.g. 'vsapm.dev.azure.com' for entitlements, 'vssps.dev.azure.com' for users). Omit for standard dev.azure.com." },
122
112
  },
123
113
  required: ["method", "organization", "path"],
124
114
  },
@@ -131,11 +121,7 @@ exports.teamsToolDefinitions = [
131
121
  if (!MUTATE_METHODS.includes(args.method)) {
132
122
  return `Invalid method "${args.method}". Must be one of: ${MUTATE_METHODS.join(", ")}`;
133
123
  }
134
- /* v8 ignore next -- fallback unreachable: method is validated against MUTATE_METHODS above @preserve */
135
- const action = METHOD_TO_ACTION[args.method] || args.method;
136
- const result = await (0, ado_client_1.adoRequest)(ctx.adoToken, args.method, args.organization, args.path, args.body);
137
- checkAndRecord403(result, "ado", args.organization, action, ctx);
138
- return result;
124
+ return (0, ado_client_1.adoRequest)(ctx.adoToken, args.method, args.organization, args.path, args.body, args.host);
139
125
  },
140
126
  integration: "ado",
141
127
  confirmationRequired: true,
@@ -201,6 +187,53 @@ exports.teamsToolDefinitions = [
201
187
  },
202
188
  integration: "ado",
203
189
  },
190
+ // -- Proactive messaging --
191
+ {
192
+ tool: {
193
+ type: "function",
194
+ function: {
195
+ name: "teams_send_message",
196
+ description: "send a proactive 1:1 Teams message to a user. requires their AAD object ID (use graph_query /users to find it). the message appears as coming from the bot.",
197
+ parameters: {
198
+ type: "object",
199
+ properties: {
200
+ user_id: { type: "string", description: "AAD object ID of the user to message" },
201
+ user_name: { type: "string", description: "display name of the user (for logging)" },
202
+ message: { type: "string", description: "message text to send" },
203
+ tenant_id: { type: "string", description: "tenant ID (optional, defaults to current conversation tenant)" },
204
+ },
205
+ required: ["user_id", "message"],
206
+ },
207
+ },
208
+ },
209
+ /* v8 ignore start -- proactive messaging requires live Teams SDK conversation client @preserve */
210
+ handler: async (args, ctx) => {
211
+ if (!ctx?.botApi) {
212
+ return "proactive messaging is not available -- no bot API context (this tool only works in the Teams channel)";
213
+ }
214
+ try {
215
+ const tenantId = args.tenant_id || ctx.tenantId;
216
+ // Cast to the SDK's ConversationClient shape (kept as `unknown` in ToolContext to avoid type coupling)
217
+ const conversations = ctx.botApi.conversations;
218
+ const conversation = await conversations.create({
219
+ bot: { id: ctx.botApi.id },
220
+ members: [{ id: args.user_id, role: "user", name: args.user_name || args.user_id }],
221
+ tenantId,
222
+ isGroup: false,
223
+ });
224
+ await conversations.activities(conversation.id).create({
225
+ type: "message",
226
+ text: args.message,
227
+ });
228
+ return `message sent to ${args.user_name || args.user_id}`;
229
+ }
230
+ catch (e) {
231
+ return `failed to send proactive message: ${e instanceof Error ? e.message : String(e)}`;
232
+ }
233
+ },
234
+ /* v8 ignore stop */
235
+ confirmationRequired: true,
236
+ },
204
237
  // -- Documentation tools --
205
238
  {
206
239
  tool: {
@@ -243,10 +276,6 @@ exports.teamsToolDefinitions = [
243
276
  integration: "ado",
244
277
  },
245
278
  ];
246
- // Backward-compat: extract just the OpenAI tool schemas
247
- exports.teamsTools = exports.teamsToolDefinitions.map((d) => d.tool);
248
- // Backward-compat: extract just the handlers by name
249
- exports.teamsToolHandlers = Object.fromEntries(exports.teamsToolDefinitions.map((d) => [d.tool.function.name, d.handler]));
250
279
  function searchEndpoints(entries, query) {
251
280
  (0, runtime_1.emitNervesEvent)({
252
281
  component: "repertoire",
@@ -268,6 +297,8 @@ function searchEndpoints(entries, query) {
268
297
  ` ${e.description}`,
269
298
  ` Params: ${e.params || "none"}`,
270
299
  ];
300
+ if (e.host)
301
+ lines.push(` Host: ${e.host}`);
271
302
  if (e.scopes)
272
303
  lines.push(` Scopes: ${e.scopes}`);
273
304
  return lines.join("\n");
@@ -304,5 +335,7 @@ function summarizeTeamsArgs(name, args) {
304
335
  return summarizeKeyValues(["query"]);
305
336
  if (name === "ado_docs")
306
337
  return summarizeKeyValues(["query"]);
338
+ if (name === "teams_send_message")
339
+ return summarizeKeyValues(["user_name", "user_id"]);
307
340
  return undefined;
308
341
  }
@@ -1,29 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.teamsTools = exports.finalAnswerTool = exports.tools = void 0;
3
+ exports.goInwardTool = exports.noResponseTool = exports.finalAnswerTool = exports.tools = void 0;
4
4
  exports.getToolsForChannel = getToolsForChannel;
5
5
  exports.isConfirmationRequired = isConfirmationRequired;
6
6
  exports.execTool = execTool;
7
7
  exports.summarizeArgs = summarizeArgs;
8
8
  const tools_base_1 = require("./tools-base");
9
9
  const tools_teams_1 = require("./tools-teams");
10
+ const tools_bluebubbles_1 = require("./tools-bluebubbles");
10
11
  const ado_semantic_1 = require("./ado-semantic");
11
12
  const tools_github_1 = require("./tools-github");
12
13
  const runtime_1 = require("../nerves/runtime");
14
+ const guardrails_1 = require("./guardrails");
15
+ const identity_1 = require("../heart/identity");
16
+ function safeGetAgentRoot() {
17
+ try {
18
+ return (0, identity_1.getAgentRoot)();
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
13
24
  // Re-export types and constants used by the rest of the codebase
14
25
  var tools_base_2 = require("./tools-base");
15
26
  Object.defineProperty(exports, "tools", { enumerable: true, get: function () { return tools_base_2.tools; } });
16
27
  Object.defineProperty(exports, "finalAnswerTool", { enumerable: true, get: function () { return tools_base_2.finalAnswerTool; } });
17
- var tools_teams_2 = require("./tools-teams");
18
- Object.defineProperty(exports, "teamsTools", { enumerable: true, get: function () { return tools_teams_2.teamsTools; } });
28
+ Object.defineProperty(exports, "noResponseTool", { enumerable: true, get: function () { return tools_base_2.noResponseTool; } });
29
+ Object.defineProperty(exports, "goInwardTool", { enumerable: true, get: function () { return tools_base_2.goInwardTool; } });
19
30
  // All tool definitions in a single registry
20
- const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
21
- const REMOTE_BLOCKED_LOCAL_TOOLS = new Set(["shell", "read_file", "write_file", "git_commit", "gh_cli"]);
22
- function baseToolsForCapabilities(capabilities) {
23
- const isRemoteChannel = capabilities?.channel === "teams" || capabilities?.channel === "bluebubbles";
24
- if (!isRemoteChannel)
25
- return tools_base_1.tools;
26
- return tools_base_1.tools.filter((tool) => !REMOTE_BLOCKED_LOCAL_TOOLS.has(tool.function.name));
31
+ const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_bluebubbles_1.bluebubblesToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
32
+ function baseToolsForCapabilities() {
33
+ // Use baseToolDefinitions at call time so dynamically-added tools are included
34
+ return tools_base_1.baseToolDefinitions.map((d) => d.tool);
27
35
  }
28
36
  // Apply a single tool preference to a tool schema, returning a new object.
29
37
  function applyPreference(tool, pref) {
@@ -35,32 +43,55 @@ function applyPreference(tool, pref) {
35
43
  },
36
44
  };
37
45
  }
46
+ // Filter out tools whose requiredCapability is not in the provider's capability set.
47
+ // Uses baseToolDefinitions at call time so dynamically-added tools are included.
48
+ // Only base tools can have requiredCapability (integration tools do not).
49
+ function filterByCapability(toolList, providerCapabilities) {
50
+ return toolList.filter((tool) => {
51
+ const def = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === tool.function.name);
52
+ if (!def?.requiredCapability)
53
+ return true;
54
+ return providerCapabilities?.has(def.requiredCapability) === true;
55
+ });
56
+ }
38
57
  // Return the appropriate tools list based on channel capabilities.
39
58
  // Base tools (no integration) are always included.
40
59
  // Teams/integration tools are included only if their integration is in availableIntegrations.
41
60
  // When toolPreferences is provided, matching preferences are appended to tool descriptions.
42
- function getToolsForChannel(capabilities, toolPreferences) {
43
- const baseTools = baseToolsForCapabilities(capabilities);
61
+ // When providerCapabilities is provided, tools with requiredCapability are filtered.
62
+ function getToolsForChannel(capabilities, toolPreferences, _context, providerCapabilities) {
63
+ const baseTools = baseToolsForCapabilities();
64
+ const bluebubblesTools = capabilities?.channel === "bluebubbles"
65
+ ? tools_bluebubbles_1.bluebubblesToolDefinitions.map((d) => d.tool)
66
+ : [];
67
+ let result;
44
68
  if (!capabilities || capabilities.availableIntegrations.length === 0) {
45
- return baseTools;
46
- }
47
- const available = new Set(capabilities.availableIntegrations);
48
- const integrationDefs = [...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions].filter((d) => d.integration && available.has(d.integration));
49
- if (!toolPreferences || Object.keys(toolPreferences).length === 0) {
50
- return [...baseTools, ...integrationDefs.map((d) => d.tool)];
69
+ result = [...baseTools, ...bluebubblesTools];
51
70
  }
52
- // Build a map of integration -> preference text for fast lookup
53
- const prefMap = new Map();
54
- for (const [key, value] of Object.entries(toolPreferences)) {
55
- prefMap.set(key, value);
71
+ else {
72
+ const available = new Set(capabilities.availableIntegrations);
73
+ const channelDefs = [...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
74
+ // Include tools whose integration is available, plus channel tools with no integration gate (e.g. teams_send_message)
75
+ const integrationDefs = channelDefs.filter((d) => d.integration ? available.has(d.integration) : capabilities.channel === "teams");
76
+ if (!toolPreferences || Object.keys(toolPreferences).length === 0) {
77
+ result = [...baseTools, ...bluebubblesTools, ...integrationDefs.map((d) => d.tool)];
78
+ }
79
+ else {
80
+ // Build a map of integration -> preference text for fast lookup
81
+ const prefMap = new Map();
82
+ for (const [key, value] of Object.entries(toolPreferences)) {
83
+ prefMap.set(key, value);
84
+ }
85
+ // Apply preferences to matching integration tools (new objects, no mutation)
86
+ // d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
87
+ const enrichedIntegrationTools = integrationDefs.map((d) => {
88
+ const pref = prefMap.get(d.integration);
89
+ return pref ? applyPreference(d.tool, pref) : d.tool;
90
+ });
91
+ result = [...baseTools, ...bluebubblesTools, ...enrichedIntegrationTools];
92
+ }
56
93
  }
57
- // Apply preferences to matching integration tools (new objects, no mutation)
58
- // d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
59
- const enrichedIntegrationTools = integrationDefs.map((d) => {
60
- const pref = prefMap.get(d.integration);
61
- return pref ? applyPreference(d.tool, pref) : d.tool;
62
- });
63
- return [...baseTools, ...enrichedIntegrationTools];
94
+ return filterByCapability(result, providerCapabilities);
64
95
  }
65
96
  // Check whether a tool requires user confirmation before execution.
66
97
  // Reads from ToolDefinition.confirmationRequired instead of a separate Set.
@@ -73,7 +104,7 @@ async function execTool(name, args, ctx) {
73
104
  event: "tool.start",
74
105
  component: "tools",
75
106
  message: "tool execution started",
76
- meta: { name },
107
+ meta: { name, ...(name === "shell" && args.command ? { command: args.command } : {}) },
77
108
  });
78
109
  // Look up from combined registry
79
110
  const def = allDefinitions.find((d) => d.tool.function.name === name);
@@ -87,17 +118,22 @@ async function execTool(name, args, ctx) {
87
118
  });
88
119
  return `unknown: ${name}`;
89
120
  }
90
- const isRemoteChannel = ctx?.context?.channel?.channel === "teams" || ctx?.context?.channel?.channel === "bluebubbles";
91
- if (isRemoteChannel && REMOTE_BLOCKED_LOCAL_TOOLS.has(name)) {
92
- const message = "I can't do that from here because I'm talking to multiple people in a shared remote channel, and local shell/file/git/gh operations could let conversations interfere with each other. Ask me for a remote-safe alternative (Graph/ADO/web), or run that operation from CLI.";
121
+ // Guardrail check: structural + trust-level
122
+ const guardContext = {
123
+ readPaths: tools_base_1.editFileReadTracker,
124
+ trustLevel: ctx?.context?.friend?.trustLevel,
125
+ agentRoot: safeGetAgentRoot(),
126
+ };
127
+ const guardResult = (0, guardrails_1.guardInvocation)(name, args, guardContext);
128
+ if (!guardResult.allowed) {
93
129
  (0, runtime_1.emitNervesEvent)({
94
130
  level: "warn",
95
- event: "tool.error",
131
+ event: "tool.guardrail_block",
96
132
  component: "tools",
97
- message: "blocked local tool in remote channel",
98
- meta: { name, channel: ctx?.context?.channel?.channel },
133
+ message: "guardrail blocked tool execution",
134
+ meta: { name, reason: guardResult.reason },
99
135
  });
100
- return message;
136
+ return guardResult.reason;
101
137
  }
102
138
  try {
103
139
  const result = await def.handler(args, ctx);
@@ -152,34 +188,30 @@ function summarizeArgs(name, args) {
152
188
  // Base tools
153
189
  if (name === "read_file" || name === "write_file")
154
190
  return summarizeKeyValues(args, ["path"]);
155
- if (name === "shell")
156
- return summarizeKeyValues(args, ["command"]);
157
- if (name === "list_directory")
191
+ if (name === "edit_file")
158
192
  return summarizeKeyValues(args, ["path"]);
159
- if (name === "git_commit")
160
- return summarizeKeyValues(args, ["message"]);
161
- if (name === "gh_cli")
193
+ if (name === "glob")
194
+ return summarizeKeyValues(args, ["pattern", "cwd"]);
195
+ if (name === "grep")
196
+ return summarizeKeyValues(args, ["pattern", "path", "include"]);
197
+ if (name === "shell")
162
198
  return summarizeKeyValues(args, ["command"]);
163
199
  if (name === "load_skill")
164
200
  return summarizeKeyValues(args, ["name"]);
165
- if (name === "task_create")
166
- return summarizeKeyValues(args, ["title", "type", "category"]);
167
- if (name === "task_update_status")
168
- return summarizeKeyValues(args, ["name", "status"]);
169
- if (name === "task_board_status")
170
- return summarizeKeyValues(args, ["status"]);
171
- if (name === "task_board_action")
172
- return summarizeKeyValues(args, ["scope"]);
173
- if (name === "task_board" || name === "task_board_deps" || name === "task_board_sessions")
174
- return "";
175
201
  if (name === "coding_spawn")
176
202
  return summarizeKeyValues(args, ["runner", "workdir", "taskRef"]);
177
203
  if (name === "coding_status")
178
204
  return summarizeKeyValues(args, ["sessionId"]);
205
+ if (name === "coding_tail")
206
+ return summarizeKeyValues(args, ["sessionId"]);
179
207
  if (name === "coding_send_input")
180
208
  return summarizeKeyValues(args, ["sessionId", "input"]);
181
209
  if (name === "coding_kill")
182
210
  return summarizeKeyValues(args, ["sessionId"]);
211
+ if (name === "bluebubbles_set_reply_target")
212
+ return summarizeKeyValues(args, ["target", "threadOriginatorGuid"]);
213
+ if (name === "set_reasoning_effort")
214
+ return summarizeKeyValues(args, ["level"]);
183
215
  if (name === "claude")
184
216
  return summarizeKeyValues(args, ["prompt"]);
185
217
  if (name === "web_search")
@@ -193,7 +225,17 @@ function summarizeArgs(name, args) {
193
225
  if (name === "save_friend_note") {
194
226
  return summarizeKeyValues(args, ["type", "key", "content"]);
195
227
  }
228
+ if (name === "bridge_manage")
229
+ return summarizeKeyValues(args, ["action", "bridgeId", "objective", "friendId", "channel", "key"]);
196
230
  if (name === "ado_backlog_list")
197
231
  return summarizeKeyValues(args, ["organization", "project"]);
232
+ if (name === "ado_batch_update")
233
+ return summarizeKeyValues(args, ["organization", "project"]);
234
+ if (name === "ado_create_epic" || name === "ado_create_issue")
235
+ return summarizeKeyValues(args, ["organization", "project", "title"]);
236
+ if (name === "ado_move_items")
237
+ return summarizeKeyValues(args, ["organization", "project", "workItemIds"]);
238
+ if (name === "ado_restructure_backlog")
239
+ return summarizeKeyValues(args, ["organization", "project"]);
198
240
  return summarizeUnknownArgs(args);
199
241
  }