@ouro.bot/cli 0.1.0-alpha.6 → 0.1.0-alpha.60

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 (117) 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 +325 -0
  7. package/dist/heart/active-work.js +178 -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/config.js +57 -23
  12. package/dist/heart/core.js +236 -90
  13. package/dist/heart/cross-chat-delivery.js +146 -0
  14. package/dist/heart/daemon/agent-discovery.js +81 -0
  15. package/dist/heart/daemon/auth-flow.js +351 -0
  16. package/dist/heart/daemon/daemon-cli.js +1173 -227
  17. package/dist/heart/daemon/daemon-entry.js +55 -6
  18. package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
  19. package/dist/heart/daemon/daemon.js +189 -10
  20. package/dist/heart/daemon/hatch-animation.js +10 -3
  21. package/dist/heart/daemon/hatch-flow.js +4 -82
  22. package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
  23. package/dist/heart/daemon/launchd.js +159 -0
  24. package/dist/heart/daemon/log-tailer.js +4 -3
  25. package/dist/heart/daemon/message-router.js +17 -8
  26. package/dist/heart/daemon/ouro-bot-entry.js +0 -0
  27. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  28. package/dist/heart/daemon/ouro-entry.js +0 -0
  29. package/dist/heart/daemon/ouro-path-installer.js +178 -0
  30. package/dist/heart/daemon/ouro-uti.js +11 -2
  31. package/dist/heart/daemon/process-manager.js +14 -1
  32. package/dist/heart/daemon/run-hooks.js +37 -0
  33. package/dist/heart/daemon/runtime-logging.js +58 -15
  34. package/dist/heart/daemon/runtime-metadata.js +219 -0
  35. package/dist/heart/daemon/runtime-mode.js +67 -0
  36. package/dist/heart/daemon/sense-manager.js +307 -0
  37. package/dist/heart/daemon/socket-client.js +202 -0
  38. package/dist/heart/daemon/specialist-orchestrator.js +53 -84
  39. package/dist/heart/daemon/specialist-prompt.js +64 -5
  40. package/dist/heart/daemon/specialist-tools.js +213 -58
  41. package/dist/heart/daemon/staged-restart.js +114 -0
  42. package/dist/heart/daemon/subagent-installer.js +48 -7
  43. package/dist/heart/daemon/thoughts.js +379 -0
  44. package/dist/heart/daemon/update-checker.js +111 -0
  45. package/dist/heart/daemon/update-hooks.js +138 -0
  46. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  47. package/dist/heart/delegation.js +62 -0
  48. package/dist/heart/identity.js +122 -19
  49. package/dist/heart/kicks.js +1 -19
  50. package/dist/heart/model-capabilities.js +40 -0
  51. package/dist/heart/progress-story.js +42 -0
  52. package/dist/heart/providers/anthropic.js +74 -9
  53. package/dist/heart/providers/azure.js +86 -7
  54. package/dist/heart/providers/minimax.js +4 -0
  55. package/dist/heart/providers/openai-codex.js +12 -3
  56. package/dist/heart/safe-workspace.js +228 -0
  57. package/dist/heart/sense-truth.js +61 -0
  58. package/dist/heart/session-activity.js +169 -0
  59. package/dist/heart/session-recall.js +116 -0
  60. package/dist/heart/streaming.js +100 -22
  61. package/dist/heart/target-resolution.js +123 -0
  62. package/dist/heart/turn-coordinator.js +28 -0
  63. package/dist/mind/associative-recall.js +14 -2
  64. package/dist/mind/bundle-manifest.js +70 -0
  65. package/dist/mind/context.js +27 -11
  66. package/dist/mind/first-impressions.js +16 -2
  67. package/dist/mind/friends/channel.js +35 -0
  68. package/dist/mind/friends/group-context.js +144 -0
  69. package/dist/mind/friends/store-file.js +19 -0
  70. package/dist/mind/friends/trust-explanation.js +74 -0
  71. package/dist/mind/friends/types.js +8 -0
  72. package/dist/mind/memory.js +27 -26
  73. package/dist/mind/pending.js +72 -9
  74. package/dist/mind/phrases.js +1 -0
  75. package/dist/mind/prompt.js +299 -77
  76. package/dist/mind/token-estimate.js +8 -12
  77. package/dist/nerves/cli-logging.js +15 -2
  78. package/dist/nerves/coverage/run-artifacts.js +1 -1
  79. package/dist/repertoire/ado-client.js +4 -2
  80. package/dist/repertoire/coding/feedback.js +134 -0
  81. package/dist/repertoire/coding/index.js +4 -1
  82. package/dist/repertoire/coding/manager.js +62 -4
  83. package/dist/repertoire/coding/spawner.js +3 -3
  84. package/dist/repertoire/coding/tools.js +41 -2
  85. package/dist/repertoire/data/ado-endpoints.json +188 -0
  86. package/dist/repertoire/tasks/board.js +12 -0
  87. package/dist/repertoire/tasks/index.js +23 -9
  88. package/dist/repertoire/tasks/transitions.js +1 -2
  89. package/dist/repertoire/tools-base.js +629 -251
  90. package/dist/repertoire/tools-bluebubbles.js +93 -0
  91. package/dist/repertoire/tools-teams.js +58 -25
  92. package/dist/repertoire/tools.js +92 -48
  93. package/dist/senses/bluebubbles-client.js +210 -5
  94. package/dist/senses/bluebubbles-entry.js +2 -0
  95. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  96. package/dist/senses/bluebubbles-media.js +339 -0
  97. package/dist/senses/bluebubbles-model.js +12 -4
  98. package/dist/senses/bluebubbles-mutation-log.js +45 -5
  99. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  100. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  101. package/dist/senses/bluebubbles.js +890 -45
  102. package/dist/senses/cli-layout.js +87 -0
  103. package/dist/senses/cli.js +345 -144
  104. package/dist/senses/continuity.js +94 -0
  105. package/dist/senses/debug-activity.js +148 -0
  106. package/dist/senses/inner-dialog-worker.js +47 -18
  107. package/dist/senses/inner-dialog.js +330 -84
  108. package/dist/senses/pipeline.js +278 -0
  109. package/dist/senses/teams.js +570 -129
  110. package/dist/senses/trust-gate.js +112 -2
  111. package/package.json +14 -3
  112. package/subagents/README.md +46 -33
  113. package/subagents/work-doer.md +28 -24
  114. package/subagents/work-merger.md +24 -30
  115. package/subagents/work-planner.md +44 -27
  116. package/dist/heart/daemon/specialist-session.js +0 -142
  117. package/dist/inner-worker-entry.js +0 -4
@@ -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,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.teamsTools = exports.finalAnswerTool = exports.tools = void 0;
3
+ exports.REMOTE_BLOCKED_LOCAL_TOOLS = 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");
13
+ const types_1 = require("../mind/friends/types");
14
+ const channel_1 = require("../mind/friends/channel");
12
15
  const runtime_1 = require("../nerves/runtime");
13
16
  // Re-export types and constants used by the rest of the codebase
14
17
  var tools_base_2 = require("./tools-base");
15
18
  Object.defineProperty(exports, "tools", { enumerable: true, get: function () { return tools_base_2.tools; } });
16
19
  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; } });
19
20
  // 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));
21
+ const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_bluebubbles_1.bluebubblesToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
22
+ /** Tool names blocked for untrusted remote contexts. Shared with prompt.ts for restriction messaging. */
23
+ exports.REMOTE_BLOCKED_LOCAL_TOOLS = new Set(["shell", "read_file", "write_file", "edit_file", "glob", "grep"]);
24
+ function isTrustedRemoteContext(context) {
25
+ if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
26
+ return false;
27
+ return (0, types_1.isTrustedLevel)(context.friend.trustLevel);
28
+ }
29
+ function shouldBlockLocalTools(capabilities, context) {
30
+ if (!(0, channel_1.isRemoteChannel)(capabilities))
31
+ return false;
32
+ return !isTrustedRemoteContext(context);
33
+ }
34
+ function blockedLocalToolMessage() {
35
+ return "I can't do that because my trust level with you isn't high enough for local shell/file operations. Ask me for a remote-safe alternative (Graph/ADO/web), or run that operation from CLI.";
36
+ }
37
+ function baseToolsForCapabilities(capabilities, context) {
38
+ // Use baseToolDefinitions at call time so dynamically-added tools are included
39
+ const currentTools = tools_base_1.baseToolDefinitions.map((d) => d.tool);
40
+ if (!shouldBlockLocalTools(capabilities, context))
41
+ return currentTools;
42
+ return currentTools.filter((tool) => !exports.REMOTE_BLOCKED_LOCAL_TOOLS.has(tool.function.name));
27
43
  }
28
44
  // Apply a single tool preference to a tool schema, returning a new object.
29
45
  function applyPreference(tool, pref) {
@@ -35,32 +51,55 @@ function applyPreference(tool, pref) {
35
51
  },
36
52
  };
37
53
  }
54
+ // Filter out tools whose requiredCapability is not in the provider's capability set.
55
+ // Uses baseToolDefinitions at call time so dynamically-added tools are included.
56
+ // Only base tools can have requiredCapability (integration tools do not).
57
+ function filterByCapability(toolList, providerCapabilities) {
58
+ return toolList.filter((tool) => {
59
+ const def = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === tool.function.name);
60
+ if (!def?.requiredCapability)
61
+ return true;
62
+ return providerCapabilities?.has(def.requiredCapability) === true;
63
+ });
64
+ }
38
65
  // Return the appropriate tools list based on channel capabilities.
39
66
  // Base tools (no integration) are always included.
40
67
  // Teams/integration tools are included only if their integration is in availableIntegrations.
41
68
  // When toolPreferences is provided, matching preferences are appended to tool descriptions.
42
- function getToolsForChannel(capabilities, toolPreferences) {
43
- const baseTools = baseToolsForCapabilities(capabilities);
69
+ // When providerCapabilities is provided, tools with requiredCapability are filtered.
70
+ function getToolsForChannel(capabilities, toolPreferences, context, providerCapabilities) {
71
+ const baseTools = baseToolsForCapabilities(capabilities, context);
72
+ const bluebubblesTools = capabilities?.channel === "bluebubbles"
73
+ ? tools_bluebubbles_1.bluebubblesToolDefinitions.map((d) => d.tool)
74
+ : [];
75
+ let result;
44
76
  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)];
77
+ result = [...baseTools, ...bluebubblesTools];
51
78
  }
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);
79
+ else {
80
+ const available = new Set(capabilities.availableIntegrations);
81
+ const channelDefs = [...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
82
+ // Include tools whose integration is available, plus channel tools with no integration gate (e.g. teams_send_message)
83
+ const integrationDefs = channelDefs.filter((d) => d.integration ? available.has(d.integration) : capabilities.channel === "teams");
84
+ if (!toolPreferences || Object.keys(toolPreferences).length === 0) {
85
+ result = [...baseTools, ...bluebubblesTools, ...integrationDefs.map((d) => d.tool)];
86
+ }
87
+ else {
88
+ // Build a map of integration -> preference text for fast lookup
89
+ const prefMap = new Map();
90
+ for (const [key, value] of Object.entries(toolPreferences)) {
91
+ prefMap.set(key, value);
92
+ }
93
+ // Apply preferences to matching integration tools (new objects, no mutation)
94
+ // d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
95
+ const enrichedIntegrationTools = integrationDefs.map((d) => {
96
+ const pref = prefMap.get(d.integration);
97
+ return pref ? applyPreference(d.tool, pref) : d.tool;
98
+ });
99
+ result = [...baseTools, ...bluebubblesTools, ...enrichedIntegrationTools];
100
+ }
56
101
  }
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];
102
+ return filterByCapability(result, providerCapabilities);
64
103
  }
65
104
  // Check whether a tool requires user confirmation before execution.
66
105
  // Reads from ToolDefinition.confirmationRequired instead of a separate Set.
@@ -87,9 +126,8 @@ async function execTool(name, args, ctx) {
87
126
  });
88
127
  return `unknown: ${name}`;
89
128
  }
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.";
129
+ if (shouldBlockLocalTools(ctx?.context?.channel, ctx?.context) && exports.REMOTE_BLOCKED_LOCAL_TOOLS.has(name)) {
130
+ const message = blockedLocalToolMessage();
93
131
  (0, runtime_1.emitNervesEvent)({
94
132
  level: "warn",
95
133
  event: "tool.error",
@@ -152,34 +190,30 @@ function summarizeArgs(name, args) {
152
190
  // Base tools
153
191
  if (name === "read_file" || name === "write_file")
154
192
  return summarizeKeyValues(args, ["path"]);
155
- if (name === "shell")
156
- return summarizeKeyValues(args, ["command"]);
157
- if (name === "list_directory")
193
+ if (name === "edit_file")
158
194
  return summarizeKeyValues(args, ["path"]);
159
- if (name === "git_commit")
160
- return summarizeKeyValues(args, ["message"]);
161
- if (name === "gh_cli")
195
+ if (name === "glob")
196
+ return summarizeKeyValues(args, ["pattern", "cwd"]);
197
+ if (name === "grep")
198
+ return summarizeKeyValues(args, ["pattern", "path", "include"]);
199
+ if (name === "shell")
162
200
  return summarizeKeyValues(args, ["command"]);
163
201
  if (name === "load_skill")
164
202
  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
203
  if (name === "coding_spawn")
176
204
  return summarizeKeyValues(args, ["runner", "workdir", "taskRef"]);
177
205
  if (name === "coding_status")
178
206
  return summarizeKeyValues(args, ["sessionId"]);
207
+ if (name === "coding_tail")
208
+ return summarizeKeyValues(args, ["sessionId"]);
179
209
  if (name === "coding_send_input")
180
210
  return summarizeKeyValues(args, ["sessionId", "input"]);
181
211
  if (name === "coding_kill")
182
212
  return summarizeKeyValues(args, ["sessionId"]);
213
+ if (name === "bluebubbles_set_reply_target")
214
+ return summarizeKeyValues(args, ["target", "threadOriginatorGuid"]);
215
+ if (name === "set_reasoning_effort")
216
+ return summarizeKeyValues(args, ["level"]);
183
217
  if (name === "claude")
184
218
  return summarizeKeyValues(args, ["prompt"]);
185
219
  if (name === "web_search")
@@ -193,7 +227,17 @@ function summarizeArgs(name, args) {
193
227
  if (name === "save_friend_note") {
194
228
  return summarizeKeyValues(args, ["type", "key", "content"]);
195
229
  }
230
+ if (name === "bridge_manage")
231
+ return summarizeKeyValues(args, ["action", "bridgeId", "objective", "friendId", "channel", "key"]);
196
232
  if (name === "ado_backlog_list")
197
233
  return summarizeKeyValues(args, ["organization", "project"]);
234
+ if (name === "ado_batch_update")
235
+ return summarizeKeyValues(args, ["organization", "project"]);
236
+ if (name === "ado_create_epic" || name === "ado_create_issue")
237
+ return summarizeKeyValues(args, ["organization", "project", "title"]);
238
+ if (name === "ado_move_items")
239
+ return summarizeKeyValues(args, ["organization", "project", "workItemIds"]);
240
+ if (name === "ado_restructure_backlog")
241
+ return summarizeKeyValues(args, ["organization", "project"]);
198
242
  return summarizeUnknownArgs(args);
199
243
  }