@ouro.bot/cli 0.1.0-alpha.9 → 0.1.0-alpha.91
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 +536 -0
- package/dist/heart/active-work.js +251 -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/commitments.js +109 -0
- package/dist/heart/config.js +68 -23
- package/dist/heart/core.js +452 -93
- 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 +430 -0
- package/dist/heart/daemon/daemon-cli.js +1738 -269
- 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 +260 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- 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 +63 -11
- package/dist/heart/daemon/specialist-tools.js +211 -60
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +507 -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/obligations.js +191 -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 +362 -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 +57 -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/obligation-steering.js +31 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +467 -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/nerves/index.js +12 -0
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/coding/feedback.js +180 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +69 -4
- package/dist/repertoire/coding/spawner.js +21 -3
- package/dist/repertoire/coding/tools.js +105 -2
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +290 -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 +714 -249
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +106 -53
- 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 +894 -45
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +400 -164
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +154 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +377 -83
- package/dist/senses/pipeline.js +307 -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,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
+
const safe_workspace_1 = require("../heart/safe-workspace");
|
|
17
|
+
function safeGetAgentRoot() {
|
|
18
|
+
try {
|
|
19
|
+
return (0, identity_1.getAgentRoot)();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
13
25
|
// Re-export types and constants used by the rest of the codebase
|
|
14
26
|
var tools_base_2 = require("./tools-base");
|
|
15
27
|
Object.defineProperty(exports, "tools", { enumerable: true, get: function () { return tools_base_2.tools; } });
|
|
16
28
|
Object.defineProperty(exports, "finalAnswerTool", { enumerable: true, get: function () { return tools_base_2.finalAnswerTool; } });
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "
|
|
29
|
+
Object.defineProperty(exports, "noResponseTool", { enumerable: true, get: function () { return tools_base_2.noResponseTool; } });
|
|
30
|
+
Object.defineProperty(exports, "goInwardTool", { enumerable: true, get: function () { return tools_base_2.goInwardTool; } });
|
|
19
31
|
// 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));
|
|
32
|
+
const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_bluebubbles_1.bluebubblesToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
|
|
33
|
+
function baseToolsForCapabilities() {
|
|
34
|
+
// Use baseToolDefinitions at call time so dynamically-added tools are included
|
|
35
|
+
return tools_base_1.baseToolDefinitions.map((d) => d.tool);
|
|
27
36
|
}
|
|
28
37
|
// Apply a single tool preference to a tool schema, returning a new object.
|
|
29
38
|
function applyPreference(tool, pref) {
|
|
@@ -35,32 +44,55 @@ function applyPreference(tool, pref) {
|
|
|
35
44
|
},
|
|
36
45
|
};
|
|
37
46
|
}
|
|
47
|
+
// Filter out tools whose requiredCapability is not in the provider's capability set.
|
|
48
|
+
// Uses baseToolDefinitions at call time so dynamically-added tools are included.
|
|
49
|
+
// Only base tools can have requiredCapability (integration tools do not).
|
|
50
|
+
function filterByCapability(toolList, providerCapabilities) {
|
|
51
|
+
return toolList.filter((tool) => {
|
|
52
|
+
const def = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === tool.function.name);
|
|
53
|
+
if (!def?.requiredCapability)
|
|
54
|
+
return true;
|
|
55
|
+
return providerCapabilities?.has(def.requiredCapability) === true;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
38
58
|
// Return the appropriate tools list based on channel capabilities.
|
|
39
59
|
// Base tools (no integration) are always included.
|
|
40
60
|
// Teams/integration tools are included only if their integration is in availableIntegrations.
|
|
41
61
|
// When toolPreferences is provided, matching preferences are appended to tool descriptions.
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
// When providerCapabilities is provided, tools with requiredCapability are filtered.
|
|
63
|
+
function getToolsForChannel(capabilities, toolPreferences, _context, providerCapabilities) {
|
|
64
|
+
const baseTools = baseToolsForCapabilities();
|
|
65
|
+
const bluebubblesTools = capabilities?.channel === "bluebubbles"
|
|
66
|
+
? tools_bluebubbles_1.bluebubblesToolDefinitions.map((d) => d.tool)
|
|
67
|
+
: [];
|
|
68
|
+
let result;
|
|
44
69
|
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)];
|
|
70
|
+
result = [...baseTools, ...bluebubblesTools];
|
|
51
71
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
else {
|
|
73
|
+
const available = new Set(capabilities.availableIntegrations);
|
|
74
|
+
const channelDefs = [...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
|
|
75
|
+
// Include tools whose integration is available, plus channel tools with no integration gate (e.g. teams_send_message)
|
|
76
|
+
const integrationDefs = channelDefs.filter((d) => d.integration ? available.has(d.integration) : capabilities.channel === "teams");
|
|
77
|
+
if (!toolPreferences || Object.keys(toolPreferences).length === 0) {
|
|
78
|
+
result = [...baseTools, ...bluebubblesTools, ...integrationDefs.map((d) => d.tool)];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Build a map of integration -> preference text for fast lookup
|
|
82
|
+
const prefMap = new Map();
|
|
83
|
+
for (const [key, value] of Object.entries(toolPreferences)) {
|
|
84
|
+
prefMap.set(key, value);
|
|
85
|
+
}
|
|
86
|
+
// Apply preferences to matching integration tools (new objects, no mutation)
|
|
87
|
+
// d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
|
|
88
|
+
const enrichedIntegrationTools = integrationDefs.map((d) => {
|
|
89
|
+
const pref = prefMap.get(d.integration);
|
|
90
|
+
return pref ? applyPreference(d.tool, pref) : d.tool;
|
|
91
|
+
});
|
|
92
|
+
result = [...baseTools, ...bluebubblesTools, ...enrichedIntegrationTools];
|
|
93
|
+
}
|
|
56
94
|
}
|
|
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];
|
|
95
|
+
return filterByCapability(result, providerCapabilities);
|
|
64
96
|
}
|
|
65
97
|
// Check whether a tool requires user confirmation before execution.
|
|
66
98
|
// Reads from ToolDefinition.confirmationRequired instead of a separate Set.
|
|
@@ -68,12 +100,21 @@ function isConfirmationRequired(toolName) {
|
|
|
68
100
|
const def = allDefinitions.find((d) => d.tool.function.name === toolName);
|
|
69
101
|
return def?.confirmationRequired === true;
|
|
70
102
|
}
|
|
103
|
+
function normalizeGuardArgs(name, args) {
|
|
104
|
+
if ((name === "read_file" || name === "write_file" || name === "edit_file") && args.path) {
|
|
105
|
+
return {
|
|
106
|
+
...args,
|
|
107
|
+
path: (0, safe_workspace_1.resolveSafeRepoPath)({ requestedPath: args.path }).resolvedPath,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return args;
|
|
111
|
+
}
|
|
71
112
|
async function execTool(name, args, ctx) {
|
|
72
113
|
(0, runtime_1.emitNervesEvent)({
|
|
73
114
|
event: "tool.start",
|
|
74
115
|
component: "tools",
|
|
75
116
|
message: "tool execution started",
|
|
76
|
-
meta: { name },
|
|
117
|
+
meta: { name, ...(name === "shell" && args.command ? { command: args.command } : {}) },
|
|
77
118
|
});
|
|
78
119
|
// Look up from combined registry
|
|
79
120
|
const def = allDefinitions.find((d) => d.tool.function.name === name);
|
|
@@ -87,17 +128,23 @@ async function execTool(name, args, ctx) {
|
|
|
87
128
|
});
|
|
88
129
|
return `unknown: ${name}`;
|
|
89
130
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
131
|
+
// Guardrail check: structural + trust-level
|
|
132
|
+
const guardContext = {
|
|
133
|
+
readPaths: tools_base_1.editFileReadTracker,
|
|
134
|
+
trustLevel: ctx?.context?.friend?.trustLevel,
|
|
135
|
+
agentRoot: safeGetAgentRoot(),
|
|
136
|
+
};
|
|
137
|
+
const guardArgs = normalizeGuardArgs(name, args);
|
|
138
|
+
const guardResult = (0, guardrails_1.guardInvocation)(name, guardArgs, guardContext);
|
|
139
|
+
if (!guardResult.allowed) {
|
|
93
140
|
(0, runtime_1.emitNervesEvent)({
|
|
94
141
|
level: "warn",
|
|
95
|
-
event: "tool.
|
|
142
|
+
event: "tool.guardrail_block",
|
|
96
143
|
component: "tools",
|
|
97
|
-
message: "blocked
|
|
98
|
-
meta: { name,
|
|
144
|
+
message: "guardrail blocked tool execution",
|
|
145
|
+
meta: { name, reason: guardResult.reason },
|
|
99
146
|
});
|
|
100
|
-
return
|
|
147
|
+
return guardResult.reason;
|
|
101
148
|
}
|
|
102
149
|
try {
|
|
103
150
|
const result = await def.handler(args, ctx);
|
|
@@ -152,34 +199,30 @@ function summarizeArgs(name, args) {
|
|
|
152
199
|
// Base tools
|
|
153
200
|
if (name === "read_file" || name === "write_file")
|
|
154
201
|
return summarizeKeyValues(args, ["path"]);
|
|
155
|
-
if (name === "
|
|
156
|
-
return summarizeKeyValues(args, ["command"]);
|
|
157
|
-
if (name === "list_directory")
|
|
202
|
+
if (name === "edit_file")
|
|
158
203
|
return summarizeKeyValues(args, ["path"]);
|
|
159
|
-
if (name === "
|
|
160
|
-
return summarizeKeyValues(args, ["
|
|
161
|
-
if (name === "
|
|
204
|
+
if (name === "glob")
|
|
205
|
+
return summarizeKeyValues(args, ["pattern", "cwd"]);
|
|
206
|
+
if (name === "grep")
|
|
207
|
+
return summarizeKeyValues(args, ["pattern", "path", "include"]);
|
|
208
|
+
if (name === "shell")
|
|
162
209
|
return summarizeKeyValues(args, ["command"]);
|
|
163
210
|
if (name === "load_skill")
|
|
164
211
|
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
212
|
if (name === "coding_spawn")
|
|
176
213
|
return summarizeKeyValues(args, ["runner", "workdir", "taskRef"]);
|
|
177
214
|
if (name === "coding_status")
|
|
178
215
|
return summarizeKeyValues(args, ["sessionId"]);
|
|
216
|
+
if (name === "coding_tail")
|
|
217
|
+
return summarizeKeyValues(args, ["sessionId"]);
|
|
179
218
|
if (name === "coding_send_input")
|
|
180
219
|
return summarizeKeyValues(args, ["sessionId", "input"]);
|
|
181
220
|
if (name === "coding_kill")
|
|
182
221
|
return summarizeKeyValues(args, ["sessionId"]);
|
|
222
|
+
if (name === "bluebubbles_set_reply_target")
|
|
223
|
+
return summarizeKeyValues(args, ["target", "threadOriginatorGuid"]);
|
|
224
|
+
if (name === "set_reasoning_effort")
|
|
225
|
+
return summarizeKeyValues(args, ["level"]);
|
|
183
226
|
if (name === "claude")
|
|
184
227
|
return summarizeKeyValues(args, ["prompt"]);
|
|
185
228
|
if (name === "web_search")
|
|
@@ -193,7 +236,17 @@ function summarizeArgs(name, args) {
|
|
|
193
236
|
if (name === "save_friend_note") {
|
|
194
237
|
return summarizeKeyValues(args, ["type", "key", "content"]);
|
|
195
238
|
}
|
|
239
|
+
if (name === "bridge_manage")
|
|
240
|
+
return summarizeKeyValues(args, ["action", "bridgeId", "objective", "friendId", "channel", "key"]);
|
|
196
241
|
if (name === "ado_backlog_list")
|
|
197
242
|
return summarizeKeyValues(args, ["organization", "project"]);
|
|
243
|
+
if (name === "ado_batch_update")
|
|
244
|
+
return summarizeKeyValues(args, ["organization", "project"]);
|
|
245
|
+
if (name === "ado_create_epic" || name === "ado_create_issue")
|
|
246
|
+
return summarizeKeyValues(args, ["organization", "project", "title"]);
|
|
247
|
+
if (name === "ado_move_items")
|
|
248
|
+
return summarizeKeyValues(args, ["organization", "project", "workItemIds"]);
|
|
249
|
+
if (name === "ado_restructure_backlog")
|
|
250
|
+
return summarizeKeyValues(args, ["organization", "project"]);
|
|
198
251
|
return summarizeUnknownArgs(args);
|
|
199
252
|
}
|