@ouro.bot/cli 0.1.0-alpha.7 → 0.1.0-alpha.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdoptionSpecialist.ouro/agent.json +70 -9
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +147 -205
- package/assets/ouroboros.png +0 -0
- package/changelog.json +387 -0
- package/dist/heart/active-work.js +178 -0
- package/dist/heart/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -0
- package/dist/heart/config.js +68 -23
- package/dist/heart/core.js +282 -92
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/auth-flow.js +409 -0
- package/dist/heart/daemon/daemon-cli.js +1395 -248
- package/dist/heart/daemon/daemon-entry.js +55 -6
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +216 -10
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +7 -82
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/launchd.js +159 -0
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/ouro-bot-entry.js +0 -0
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-entry.js +0 -0
- package/dist/heart/daemon/ouro-path-installer.js +178 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/process-manager.js +14 -1
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +219 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/sense-manager.js +307 -0
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/specialist-orchestrator.js +53 -84
- package/dist/heart/daemon/specialist-prompt.js +64 -5
- package/dist/heart/daemon/specialist-tools.js +213 -58
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +379 -0
- package/dist/heart/daemon/update-checker.js +111 -0
- package/dist/heart/daemon/update-hooks.js +138 -0
- package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/identity.js +126 -21
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/providers/anthropic.js +74 -9
- package/dist/heart/providers/azure.js +86 -7
- package/dist/heart/providers/github-copilot.js +149 -0
- package/dist/heart/providers/minimax.js +4 -0
- package/dist/heart/providers/openai-codex.js +12 -3
- package/dist/heart/safe-workspace.js +228 -0
- package/dist/heart/sense-truth.js +61 -0
- package/dist/heart/session-activity.js +169 -0
- package/dist/heart/session-recall.js +116 -0
- package/dist/heart/streaming.js +100 -22
- package/dist/heart/target-resolution.js +123 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +14 -2
- package/dist/mind/bundle-manifest.js +70 -0
- package/dist/mind/context.js +27 -11
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +35 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/store-file.js +19 -0
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +8 -0
- package/dist/mind/memory.js +27 -26
- package/dist/mind/pending.js +72 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +358 -77
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/coding/feedback.js +134 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +62 -4
- package/dist/repertoire/coding/spawner.js +3 -3
- package/dist/repertoire/coding/tools.js +41 -2
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +279 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +195 -0
- package/dist/repertoire/skills.js +3 -26
- package/dist/repertoire/tasks/board.js +12 -0
- package/dist/repertoire/tasks/index.js +23 -9
- package/dist/repertoire/tasks/transitions.js +1 -2
- package/dist/repertoire/tools-base.js +642 -251
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +93 -52
- package/dist/senses/bluebubbles-client.js +210 -5
- package/dist/senses/bluebubbles-entry.js +2 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +339 -0
- package/dist/senses/bluebubbles-model.js +12 -4
- package/dist/senses/bluebubbles-mutation-log.js +45 -5
- package/dist/senses/bluebubbles-runtime-state.js +109 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +893 -45
- package/dist/senses/cli-layout.js +87 -0
- package/dist/senses/cli.js +348 -144
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +148 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +333 -84
- package/dist/senses/pipeline.js +278 -0
- package/dist/senses/teams.js +573 -129
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +14 -3
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/specialist-session.js +0 -142
- package/dist/heart/daemon/subagent-installer.js +0 -125
- package/dist/inner-worker-entry.js +0 -4
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- 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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/dist/repertoire/tools.js
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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
|
-
|
|
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; } });
|
|
19
29
|
// 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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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));
|
|
30
|
+
const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_bluebubbles_1.bluebubblesToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
|
|
31
|
+
function baseToolsForCapabilities() {
|
|
32
|
+
// Use baseToolDefinitions at call time so dynamically-added tools are included
|
|
33
|
+
return tools_base_1.baseToolDefinitions.map((d) => d.tool);
|
|
27
34
|
}
|
|
28
35
|
// Apply a single tool preference to a tool schema, returning a new object.
|
|
29
36
|
function applyPreference(tool, pref) {
|
|
@@ -35,32 +42,55 @@ function applyPreference(tool, pref) {
|
|
|
35
42
|
},
|
|
36
43
|
};
|
|
37
44
|
}
|
|
45
|
+
// Filter out tools whose requiredCapability is not in the provider's capability set.
|
|
46
|
+
// Uses baseToolDefinitions at call time so dynamically-added tools are included.
|
|
47
|
+
// Only base tools can have requiredCapability (integration tools do not).
|
|
48
|
+
function filterByCapability(toolList, providerCapabilities) {
|
|
49
|
+
return toolList.filter((tool) => {
|
|
50
|
+
const def = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === tool.function.name);
|
|
51
|
+
if (!def?.requiredCapability)
|
|
52
|
+
return true;
|
|
53
|
+
return providerCapabilities?.has(def.requiredCapability) === true;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
38
56
|
// Return the appropriate tools list based on channel capabilities.
|
|
39
57
|
// Base tools (no integration) are always included.
|
|
40
58
|
// Teams/integration tools are included only if their integration is in availableIntegrations.
|
|
41
59
|
// When toolPreferences is provided, matching preferences are appended to tool descriptions.
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
// When providerCapabilities is provided, tools with requiredCapability are filtered.
|
|
61
|
+
function getToolsForChannel(capabilities, toolPreferences, _context, providerCapabilities) {
|
|
62
|
+
const baseTools = baseToolsForCapabilities();
|
|
63
|
+
const bluebubblesTools = capabilities?.channel === "bluebubbles"
|
|
64
|
+
? tools_bluebubbles_1.bluebubblesToolDefinitions.map((d) => d.tool)
|
|
65
|
+
: [];
|
|
66
|
+
let result;
|
|
44
67
|
if (!capabilities || capabilities.availableIntegrations.length === 0) {
|
|
45
|
-
|
|
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)];
|
|
68
|
+
result = [...baseTools, ...bluebubblesTools];
|
|
51
69
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
else {
|
|
71
|
+
const available = new Set(capabilities.availableIntegrations);
|
|
72
|
+
const channelDefs = [...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
|
|
73
|
+
// Include tools whose integration is available, plus channel tools with no integration gate (e.g. teams_send_message)
|
|
74
|
+
const integrationDefs = channelDefs.filter((d) => d.integration ? available.has(d.integration) : capabilities.channel === "teams");
|
|
75
|
+
if (!toolPreferences || Object.keys(toolPreferences).length === 0) {
|
|
76
|
+
result = [...baseTools, ...bluebubblesTools, ...integrationDefs.map((d) => d.tool)];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Build a map of integration -> preference text for fast lookup
|
|
80
|
+
const prefMap = new Map();
|
|
81
|
+
for (const [key, value] of Object.entries(toolPreferences)) {
|
|
82
|
+
prefMap.set(key, value);
|
|
83
|
+
}
|
|
84
|
+
// Apply preferences to matching integration tools (new objects, no mutation)
|
|
85
|
+
// d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
|
|
86
|
+
const enrichedIntegrationTools = integrationDefs.map((d) => {
|
|
87
|
+
const pref = prefMap.get(d.integration);
|
|
88
|
+
return pref ? applyPreference(d.tool, pref) : d.tool;
|
|
89
|
+
});
|
|
90
|
+
result = [...baseTools, ...bluebubblesTools, ...enrichedIntegrationTools];
|
|
91
|
+
}
|
|
56
92
|
}
|
|
57
|
-
|
|
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];
|
|
93
|
+
return filterByCapability(result, providerCapabilities);
|
|
64
94
|
}
|
|
65
95
|
// Check whether a tool requires user confirmation before execution.
|
|
66
96
|
// Reads from ToolDefinition.confirmationRequired instead of a separate Set.
|
|
@@ -87,17 +117,22 @@ async function execTool(name, args, ctx) {
|
|
|
87
117
|
});
|
|
88
118
|
return `unknown: ${name}`;
|
|
89
119
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
120
|
+
// Guardrail check: structural + trust-level
|
|
121
|
+
const guardContext = {
|
|
122
|
+
readPaths: tools_base_1.editFileReadTracker,
|
|
123
|
+
trustLevel: ctx?.context?.friend?.trustLevel,
|
|
124
|
+
agentRoot: safeGetAgentRoot(),
|
|
125
|
+
};
|
|
126
|
+
const guardResult = (0, guardrails_1.guardInvocation)(name, args, guardContext);
|
|
127
|
+
if (!guardResult.allowed) {
|
|
93
128
|
(0, runtime_1.emitNervesEvent)({
|
|
94
129
|
level: "warn",
|
|
95
|
-
event: "tool.
|
|
130
|
+
event: "tool.guardrail_block",
|
|
96
131
|
component: "tools",
|
|
97
|
-
message: "blocked
|
|
98
|
-
meta: { name,
|
|
132
|
+
message: "guardrail blocked tool execution",
|
|
133
|
+
meta: { name, reason: guardResult.reason },
|
|
99
134
|
});
|
|
100
|
-
return
|
|
135
|
+
return guardResult.reason;
|
|
101
136
|
}
|
|
102
137
|
try {
|
|
103
138
|
const result = await def.handler(args, ctx);
|
|
@@ -152,34 +187,30 @@ function summarizeArgs(name, args) {
|
|
|
152
187
|
// Base tools
|
|
153
188
|
if (name === "read_file" || name === "write_file")
|
|
154
189
|
return summarizeKeyValues(args, ["path"]);
|
|
155
|
-
if (name === "
|
|
156
|
-
return summarizeKeyValues(args, ["command"]);
|
|
157
|
-
if (name === "list_directory")
|
|
190
|
+
if (name === "edit_file")
|
|
158
191
|
return summarizeKeyValues(args, ["path"]);
|
|
159
|
-
if (name === "
|
|
160
|
-
return summarizeKeyValues(args, ["
|
|
161
|
-
if (name === "
|
|
192
|
+
if (name === "glob")
|
|
193
|
+
return summarizeKeyValues(args, ["pattern", "cwd"]);
|
|
194
|
+
if (name === "grep")
|
|
195
|
+
return summarizeKeyValues(args, ["pattern", "path", "include"]);
|
|
196
|
+
if (name === "shell")
|
|
162
197
|
return summarizeKeyValues(args, ["command"]);
|
|
163
198
|
if (name === "load_skill")
|
|
164
199
|
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
200
|
if (name === "coding_spawn")
|
|
176
201
|
return summarizeKeyValues(args, ["runner", "workdir", "taskRef"]);
|
|
177
202
|
if (name === "coding_status")
|
|
178
203
|
return summarizeKeyValues(args, ["sessionId"]);
|
|
204
|
+
if (name === "coding_tail")
|
|
205
|
+
return summarizeKeyValues(args, ["sessionId"]);
|
|
179
206
|
if (name === "coding_send_input")
|
|
180
207
|
return summarizeKeyValues(args, ["sessionId", "input"]);
|
|
181
208
|
if (name === "coding_kill")
|
|
182
209
|
return summarizeKeyValues(args, ["sessionId"]);
|
|
210
|
+
if (name === "bluebubbles_set_reply_target")
|
|
211
|
+
return summarizeKeyValues(args, ["target", "threadOriginatorGuid"]);
|
|
212
|
+
if (name === "set_reasoning_effort")
|
|
213
|
+
return summarizeKeyValues(args, ["level"]);
|
|
183
214
|
if (name === "claude")
|
|
184
215
|
return summarizeKeyValues(args, ["prompt"]);
|
|
185
216
|
if (name === "web_search")
|
|
@@ -193,7 +224,17 @@ function summarizeArgs(name, args) {
|
|
|
193
224
|
if (name === "save_friend_note") {
|
|
194
225
|
return summarizeKeyValues(args, ["type", "key", "content"]);
|
|
195
226
|
}
|
|
227
|
+
if (name === "bridge_manage")
|
|
228
|
+
return summarizeKeyValues(args, ["action", "bridgeId", "objective", "friendId", "channel", "key"]);
|
|
196
229
|
if (name === "ado_backlog_list")
|
|
197
230
|
return summarizeKeyValues(args, ["organization", "project"]);
|
|
231
|
+
if (name === "ado_batch_update")
|
|
232
|
+
return summarizeKeyValues(args, ["organization", "project"]);
|
|
233
|
+
if (name === "ado_create_epic" || name === "ado_create_issue")
|
|
234
|
+
return summarizeKeyValues(args, ["organization", "project", "title"]);
|
|
235
|
+
if (name === "ado_move_items")
|
|
236
|
+
return summarizeKeyValues(args, ["organization", "project", "workItemIds"]);
|
|
237
|
+
if (name === "ado_restructure_backlog")
|
|
238
|
+
return summarizeKeyValues(args, ["organization", "project"]);
|
|
198
239
|
return summarizeUnknownArgs(args);
|
|
199
240
|
}
|