@ouro.bot/cli 0.1.0-alpha.1382 → 0.1.0-alpha.1383
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/changelog.json +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/repertoire/mcp-declared-tools.js +156 -0
- package/dist/repertoire/mcp-manager.js +12 -5
- package/dist/repertoire/mcp-tools.js +104 -77
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1383",
|
|
6
|
+
"changes": [
|
|
7
|
+
"A bundle can declare its own MCP server's tools in a tools.json from Ouro UI core's ouro-actions-tools (agent.json mcpServers.<name>.tools); the harness then gives those tools the declared description, parameters and Ouro AX card, with risk from the card's effect."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1382",
|
|
6
12
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1383</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parseDeclaredTools = parseDeclaredTools;
|
|
37
|
+
exports.loadDeclaredTools = loadDeclaredTools;
|
|
38
|
+
exports.declaredRiskProfile = declaredRiskProfile;
|
|
39
|
+
/**
|
|
40
|
+
* A bundle's declared tools: the `tools.json` an agent bundle ships for one of its own MCP servers (agent.json
|
|
41
|
+
* `mcpServers.<name>.tools`), written by Ouro UI core's ouro-actions-tools projection from the bundle's action
|
|
42
|
+
* declarations (ourostack/ouro-ui-core `src/actions-tools.mts`, release v1.11.0). Each entry is an OpenAI function tool
|
|
43
|
+
* with its Ouro AX card (`ax`, the census's DoorCard). The harness surfaces that server's tools with the declared
|
|
44
|
+
* description, parameters and card, so a bundle's tool schemas and its Ouro AX cards come from one declaration.
|
|
45
|
+
*
|
|
46
|
+
* An entry that isn't a whole declaration (no effect, no `when`, a consequential one with no confirm question) is left
|
|
47
|
+
* out, and its tool stays undeclared: it's handled as any MCP tool is, from what its server says, never from the broken entry.
|
|
48
|
+
*/
|
|
49
|
+
const fs = __importStar(require("node:fs"));
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const runtime_1 = require("../nerves/runtime");
|
|
52
|
+
const EFFECTS = new Set(["read", "write", "consequential", "person-only"]);
|
|
53
|
+
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
54
|
+
const isLine = (v) => typeof v === "string" && v.trim() !== "" && !/[\r\n]/.test(v);
|
|
55
|
+
function errorCards(v) {
|
|
56
|
+
if (!Array.isArray(v))
|
|
57
|
+
return null;
|
|
58
|
+
const cards = [];
|
|
59
|
+
for (const e of v) {
|
|
60
|
+
if (!isObject(e) || !isLine(e.code) || !isLine(e.means) || !isLine(e.fix))
|
|
61
|
+
return null;
|
|
62
|
+
cards.push({ code: e.code, means: e.means, fix: e.fix });
|
|
63
|
+
}
|
|
64
|
+
return cards;
|
|
65
|
+
}
|
|
66
|
+
/** Why one entry isn't a whole declaration, or its declaration. */
|
|
67
|
+
function declaredTool(entry) {
|
|
68
|
+
if (!isObject(entry) || entry.type !== "function" || !isObject(entry.function) || typeof entry.function.name !== "string" || entry.function.name === "") {
|
|
69
|
+
return { problem: "an entry is not a function tool with a name" };
|
|
70
|
+
}
|
|
71
|
+
const name = entry.function.name;
|
|
72
|
+
const { description, parameters } = entry.function;
|
|
73
|
+
if (!isLine(description))
|
|
74
|
+
return { problem: `${name}: no one-line description` };
|
|
75
|
+
if (!isObject(parameters) || parameters.type !== "object")
|
|
76
|
+
return { problem: `${name}: parameters is not an object schema` };
|
|
77
|
+
const ax = entry.ax;
|
|
78
|
+
if (!isObject(ax))
|
|
79
|
+
return { problem: `${name}: no ax card` };
|
|
80
|
+
if (typeof ax.effect !== "string" || !EFFECTS.has(ax.effect))
|
|
81
|
+
return { problem: `${name}: the card has no effect` };
|
|
82
|
+
if (!isLine(ax.when))
|
|
83
|
+
return { problem: `${name}: the card has no when line` };
|
|
84
|
+
if (!isLine(ax.group))
|
|
85
|
+
return { problem: `${name}: the card has no group` };
|
|
86
|
+
const errors = errorCards(ax.errors);
|
|
87
|
+
if (errors === null)
|
|
88
|
+
return { problem: `${name}: the card's errors are not { code, means, fix } lines` };
|
|
89
|
+
if (ax.effect === "consequential" && !isLine(ax.confirm))
|
|
90
|
+
return { problem: `${name}: a consequential card has no confirm question` };
|
|
91
|
+
const card = {
|
|
92
|
+
id: `tool:${name}`, group: ax.group, when: ax.when, effect: ax.effect, errors,
|
|
93
|
+
...(ax.destructive === true ? { destructive: true } : {}),
|
|
94
|
+
...(ax.idempotent === true ? { idempotent: true } : {}),
|
|
95
|
+
...(isLine(ax.confirm) ? { confirm: ax.confirm } : {}),
|
|
96
|
+
};
|
|
97
|
+
return { name, tool: { description, parameters, ax: card } };
|
|
98
|
+
}
|
|
99
|
+
/** The declared tools in a tools.json's content, and why any entry was left out. */
|
|
100
|
+
function parseDeclaredTools(json) {
|
|
101
|
+
const tools = new Map();
|
|
102
|
+
const problems = [];
|
|
103
|
+
if (!isObject(json) || !Array.isArray(json.tools))
|
|
104
|
+
return { tools, problems: ["it has no tools list"] };
|
|
105
|
+
for (const entry of json.tools) {
|
|
106
|
+
const result = declaredTool(entry);
|
|
107
|
+
if ("problem" in result)
|
|
108
|
+
problems.push(result.problem);
|
|
109
|
+
else if (tools.has(result.name))
|
|
110
|
+
problems.push(`${result.name}: declared twice`);
|
|
111
|
+
else
|
|
112
|
+
tools.set(result.name, result.tool);
|
|
113
|
+
}
|
|
114
|
+
return { tools, problems };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Reads a server's tools.json, a path inside the agent's bundle (relative to it, or absolute). Null, with a warning,
|
|
118
|
+
* when the path leaves the bundle or the file can't be read as JSON; the server's tools then stay undeclared.
|
|
119
|
+
*/
|
|
120
|
+
function loadDeclaredTools(agentRoot, file, server) {
|
|
121
|
+
const root = path.resolve(agentRoot);
|
|
122
|
+
const target = path.resolve(root, file);
|
|
123
|
+
const warn = (reason) => {
|
|
124
|
+
(0, runtime_1.emitNervesEvent)({
|
|
125
|
+
level: "warn", event: "mcp.declared_tools_unreadable", component: "repertoire",
|
|
126
|
+
message: `the declared tools for MCP server ${server} can't be used`, meta: { server, reason },
|
|
127
|
+
});
|
|
128
|
+
return null;
|
|
129
|
+
};
|
|
130
|
+
if (target !== root && !target.startsWith(root + path.sep))
|
|
131
|
+
return warn("the tools path is outside the agent bundle");
|
|
132
|
+
let json;
|
|
133
|
+
try {
|
|
134
|
+
json = JSON.parse(fs.readFileSync(target, "utf8"));
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
// readFileSync and JSON.parse throw only Errors.
|
|
138
|
+
return warn(error.message);
|
|
139
|
+
}
|
|
140
|
+
const { tools, problems } = parseDeclaredTools(json);
|
|
141
|
+
if (problems.length > 0) {
|
|
142
|
+
(0, runtime_1.emitNervesEvent)({
|
|
143
|
+
level: "warn", event: "mcp.declared_tools_incomplete", component: "repertoire",
|
|
144
|
+
message: `some declared tools for MCP server ${server} were left out`, meta: { server, problems },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return tools;
|
|
148
|
+
}
|
|
149
|
+
/** The risk the harness gives a declared tool, from its card's effect. */
|
|
150
|
+
function declaredRiskProfile(effect) {
|
|
151
|
+
if (effect === "read")
|
|
152
|
+
return { mutates: "none", risk: "low", reason: "declared read in the agent bundle's tools.json" };
|
|
153
|
+
if (effect === "write")
|
|
154
|
+
return { mutates: "durable_state_write", risk: "high", reason: "declared write in the agent bundle's tools.json" };
|
|
155
|
+
return { mutates: "external_side_effect", risk: "high", reason: `declared ${effect} in the agent bundle's tools.json` };
|
|
156
|
+
}
|
|
@@ -46,6 +46,7 @@ const credential_access_1 = require("./credential-access");
|
|
|
46
46
|
const plugin_mcp_1 = require("./plugin-mcp");
|
|
47
47
|
const tool_arguments_1 = require("./tool-arguments");
|
|
48
48
|
const mcp_tools_1 = require("./mcp-tools");
|
|
49
|
+
const mcp_declared_tools_1 = require("./mcp-declared-tools");
|
|
49
50
|
const MAX_RESTART_RETRIES = 5;
|
|
50
51
|
const RESTART_DELAY_MS = 1000;
|
|
51
52
|
function isOwner(value) {
|
|
@@ -266,11 +267,17 @@ class McpManager {
|
|
|
266
267
|
&& this.desiredGenerations.get(key) === entry.generation;
|
|
267
268
|
}
|
|
268
269
|
freezeView(owner) {
|
|
269
|
-
const entries = this.ownedEntries(owner).filter((entry) => this.isCurrentEntry(entry)).map((entry) =>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
const entries = this.ownedEntries(owner).filter((entry) => this.isCurrentEntry(entry)).map((entry) => {
|
|
271
|
+
const declared = entry.source === "builtin" && typeof entry.config.tools === "string"
|
|
272
|
+
? (0, mcp_declared_tools_1.loadDeclaredTools)(owner.agentRoot, entry.config.tools, entry.name)
|
|
273
|
+
: null;
|
|
274
|
+
return Object.freeze({
|
|
275
|
+
server: entry.name, source: entry.source, pluginId: entry.pluginId,
|
|
276
|
+
configDigest: entry.configDigest, generation: entry.generation,
|
|
277
|
+
tools: (0, tool_arguments_1.freezeToolValue)(structuredClone(entry.cachedTools)),
|
|
278
|
+
...(declared ? { declared } : {}),
|
|
279
|
+
});
|
|
280
|
+
});
|
|
274
281
|
return Object.freeze({ manager: this, owner, entries: Object.freeze(entries) });
|
|
275
282
|
}
|
|
276
283
|
matchesBinding(entry, binding, owner) {
|
|
@@ -11,6 +11,7 @@ exports.mcpToolsAsDefinitions = mcpToolsAsDefinitions;
|
|
|
11
11
|
const runtime_1 = require("../nerves/runtime");
|
|
12
12
|
const tool_arguments_1 = require("./tool-arguments");
|
|
13
13
|
const mcp_write_guard_1 = require("./mcp-write-guard");
|
|
14
|
+
const mcp_declared_tools_1 = require("./mcp-declared-tools");
|
|
14
15
|
class McpCallRejectedError extends Error {
|
|
15
16
|
constructor(message) {
|
|
16
17
|
super(message);
|
|
@@ -52,6 +53,10 @@ function mcpToolSchema(entry, tool) {
|
|
|
52
53
|
},
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
/** The served schema with the bundle's declared description and parameters; its name stays the served one. */
|
|
57
|
+
function withDeclaration(served, declared) {
|
|
58
|
+
return { ...served, function: { ...served.function, description: declared.description, parameters: declared.parameters } };
|
|
59
|
+
}
|
|
55
60
|
/**
|
|
56
61
|
* An MCP tool's Ouro AX card, made from what its server says: the tool's first description sentence as its `when`
|
|
57
62
|
* line, and a read effect only when the read-only hint is trusted (the agent's own servers), else a write.
|
|
@@ -83,82 +88,104 @@ function mcpToolCard(server, tool, surfacedName, readOnly) {
|
|
|
83
88
|
function mcpToolsAsDefinitions(view) {
|
|
84
89
|
if (!view)
|
|
85
90
|
return [];
|
|
86
|
-
return view.entries.flatMap((entry) =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
return view.entries.flatMap((entry) => {
|
|
92
|
+
if (entry.declared)
|
|
93
|
+
warnUnservedDeclarations(entry);
|
|
94
|
+
return entry.tools.flatMap((tool) => {
|
|
95
|
+
const served = mcpToolSchema(entry, tool);
|
|
96
|
+
// The bundle's own declaration, when it has one: the model sees the declared description, parameters and card.
|
|
97
|
+
const declared = entry.declared?.get(tool.name);
|
|
98
|
+
// A person-only action is never an agent's to call, so a declared one is not surfaced.
|
|
99
|
+
if (declared?.ax.effect === "person-only")
|
|
100
|
+
return [];
|
|
101
|
+
const schema = declared ? withDeclaration(served, declared) : served;
|
|
102
|
+
const binding = Object.freeze({
|
|
103
|
+
manager: view.manager, ...view.owner, server: entry.server,
|
|
104
|
+
rawName: tool.name, surfacedName: served.function.name,
|
|
105
|
+
source: entry.source, pluginId: entry.pluginId,
|
|
106
|
+
configDigest: entry.configDigest, generation: entry.generation,
|
|
107
|
+
// The served schema, which the manager checks the binding against; the declaration changes only what the model reads.
|
|
108
|
+
schemaDigest: (0, tool_arguments_1.digestJson)(served),
|
|
109
|
+
});
|
|
110
|
+
// A read-only hint is trusted only from the agent's own bundle (agent.json mcpServers),
|
|
111
|
+
// so an orientation hold still lets the agent inspect through those tools.
|
|
112
|
+
const trustedReadOnly = entry.source === "builtin" && tool.annotations?.readOnlyHint === true;
|
|
113
|
+
return [{
|
|
114
|
+
tool: schema,
|
|
115
|
+
ax: declared ? { ...declared.ax, id: `tool:${served.function.name}` } : mcpToolCard(entry.server, tool, served.function.name, trustedReadOnly),
|
|
116
|
+
riskProfile: declared ? (0, mcp_declared_tools_1.declaredRiskProfile)(declared.ax.effect) : trustedReadOnly
|
|
117
|
+
? { mutates: "none", risk: "low", reason: "read-only tool from the agent's own MCP server" }
|
|
118
|
+
: {
|
|
119
|
+
mutates: "external_side_effect",
|
|
120
|
+
risk: "high",
|
|
121
|
+
reason: "MCP tools may mutate external systems",
|
|
122
|
+
},
|
|
123
|
+
handler: async (args, ctx) => {
|
|
124
|
+
if (ctx?.agentName !== binding.agentName || ctx.agentRoot !== binding.agentRoot) {
|
|
125
|
+
(0, runtime_1.emitNervesEvent)({
|
|
126
|
+
level: "warn", event: "mcp.tool_rejected", component: "repertoire",
|
|
127
|
+
message: "MCP tool owner does not match its caller", meta: { reason: "owner mismatch" },
|
|
128
|
+
});
|
|
129
|
+
throw new McpCallRejectedError("MCP tool owner does not match its caller");
|
|
130
|
+
}
|
|
131
|
+
(0, runtime_1.emitNervesEvent)({
|
|
132
|
+
event: "mcp.tool_start",
|
|
133
|
+
component: "repertoire",
|
|
134
|
+
message: `calling MCP tool ${entry.server}/${tool.name}`,
|
|
135
|
+
meta: { server: entry.server, tool: tool.name },
|
|
136
|
+
});
|
|
137
|
+
const guarded = (0, mcp_write_guard_1.guardMcpArgs)({ toolName: tool.name, declaresDryRun: Object.hasOwn((tool.inputSchema?.properties ?? {}), "dry_run"), args, ctx });
|
|
138
|
+
if (guarded.rejected !== undefined)
|
|
139
|
+
throw new McpCallRejectedError(guarded.rejected);
|
|
140
|
+
try {
|
|
141
|
+
const result = await view.manager.callTool(binding, guarded.args, { agentName: ctx.agentName, agentRoot: ctx.agentRoot });
|
|
142
|
+
const { text, images } = splitMcpContent(result.content);
|
|
143
|
+
if (result.isError === true) {
|
|
144
|
+
throw new McpToolExecutionError("handler_failed", `[mcp error] ${entry.server}/${tool.name}: ${text}`);
|
|
145
|
+
}
|
|
146
|
+
let output = text;
|
|
147
|
+
if (images.length > 0) {
|
|
148
|
+
if (ctx.attachToolImages)
|
|
149
|
+
ctx.attachToolImages(images);
|
|
150
|
+
else
|
|
151
|
+
output = `${text}${text ? "\n\n" : ""}[${images.length} image(s) returned, but this caller can't receive images]`;
|
|
152
|
+
}
|
|
153
|
+
(0, runtime_1.emitNervesEvent)({
|
|
154
|
+
event: "mcp.tool_end",
|
|
155
|
+
component: "repertoire",
|
|
156
|
+
message: `MCP tool ${entry.server}/${tool.name} completed`,
|
|
157
|
+
meta: { server: entry.server, tool: tool.name },
|
|
158
|
+
});
|
|
159
|
+
return output;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
163
|
+
(0, runtime_1.emitNervesEvent)({
|
|
164
|
+
level: "error",
|
|
165
|
+
event: "mcp.tool_error",
|
|
166
|
+
component: "repertoire",
|
|
167
|
+
message: `MCP tool ${entry.server}/${tool.name} failed: ${reason}`,
|
|
168
|
+
meta: { server: entry.server, tool: tool.name, reason },
|
|
169
|
+
});
|
|
170
|
+
if (error instanceof McpCallRejectedError || error instanceof McpToolExecutionError)
|
|
171
|
+
throw error;
|
|
172
|
+
throw new McpToolExecutionError("handler_indeterminate", `[mcp error] ${entry.server}/${tool.name}: ${reason}`);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
mcpServer: entry.server,
|
|
176
|
+
mcpBinding: binding,
|
|
177
|
+
}];
|
|
94
178
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
handler: async (args, ctx) => {
|
|
109
|
-
if (ctx?.agentName !== binding.agentName || ctx.agentRoot !== binding.agentRoot) {
|
|
110
|
-
(0, runtime_1.emitNervesEvent)({
|
|
111
|
-
level: "warn", event: "mcp.tool_rejected", component: "repertoire",
|
|
112
|
-
message: "MCP tool owner does not match its caller", meta: { reason: "owner mismatch" },
|
|
113
|
-
});
|
|
114
|
-
throw new McpCallRejectedError("MCP tool owner does not match its caller");
|
|
115
|
-
}
|
|
116
|
-
(0, runtime_1.emitNervesEvent)({
|
|
117
|
-
event: "mcp.tool_start",
|
|
118
|
-
component: "repertoire",
|
|
119
|
-
message: `calling MCP tool ${entry.server}/${tool.name}`,
|
|
120
|
-
meta: { server: entry.server, tool: tool.name },
|
|
121
|
-
});
|
|
122
|
-
const guarded = (0, mcp_write_guard_1.guardMcpArgs)({ toolName: tool.name, declaresDryRun: Object.hasOwn((tool.inputSchema?.properties ?? {}), "dry_run"), args, ctx });
|
|
123
|
-
if (guarded.rejected !== undefined)
|
|
124
|
-
throw new McpCallRejectedError(guarded.rejected);
|
|
125
|
-
try {
|
|
126
|
-
const result = await view.manager.callTool(binding, guarded.args, { agentName: ctx.agentName, agentRoot: ctx.agentRoot });
|
|
127
|
-
const { text, images } = splitMcpContent(result.content);
|
|
128
|
-
if (result.isError === true) {
|
|
129
|
-
throw new McpToolExecutionError("handler_failed", `[mcp error] ${entry.server}/${tool.name}: ${text}`);
|
|
130
|
-
}
|
|
131
|
-
let output = text;
|
|
132
|
-
if (images.length > 0) {
|
|
133
|
-
if (ctx.attachToolImages)
|
|
134
|
-
ctx.attachToolImages(images);
|
|
135
|
-
else
|
|
136
|
-
output = `${text}${text ? "\n\n" : ""}[${images.length} image(s) returned, but this caller can't receive images]`;
|
|
137
|
-
}
|
|
138
|
-
(0, runtime_1.emitNervesEvent)({
|
|
139
|
-
event: "mcp.tool_end",
|
|
140
|
-
component: "repertoire",
|
|
141
|
-
message: `MCP tool ${entry.server}/${tool.name} completed`,
|
|
142
|
-
meta: { server: entry.server, tool: tool.name },
|
|
143
|
-
});
|
|
144
|
-
return output;
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
148
|
-
(0, runtime_1.emitNervesEvent)({
|
|
149
|
-
level: "error",
|
|
150
|
-
event: "mcp.tool_error",
|
|
151
|
-
component: "repertoire",
|
|
152
|
-
message: `MCP tool ${entry.server}/${tool.name} failed: ${reason}`,
|
|
153
|
-
meta: { server: entry.server, tool: tool.name, reason },
|
|
154
|
-
});
|
|
155
|
-
if (error instanceof McpCallRejectedError || error instanceof McpToolExecutionError)
|
|
156
|
-
throw error;
|
|
157
|
-
throw new McpToolExecutionError("handler_indeterminate", `[mcp error] ${entry.server}/${tool.name}: ${reason}`);
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
mcpServer: entry.server,
|
|
161
|
-
mcpBinding: binding,
|
|
162
|
-
};
|
|
163
|
-
}));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/** A declared tool the server doesn't serve is not surfaced; say so, since the bundle promised it. */
|
|
182
|
+
function warnUnservedDeclarations(entry) {
|
|
183
|
+
const served = new Set(entry.tools.map((tool) => tool.name));
|
|
184
|
+
const missing = [...entry.declared.keys()].filter((name) => !served.has(name));
|
|
185
|
+
if (missing.length === 0)
|
|
186
|
+
return;
|
|
187
|
+
(0, runtime_1.emitNervesEvent)({
|
|
188
|
+
level: "warn", event: "mcp.declared_tool_unserved", component: "repertoire",
|
|
189
|
+
message: `MCP server ${entry.server} doesn't serve tools its bundle declares`, meta: { server: entry.server, missing },
|
|
190
|
+
});
|
|
164
191
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1383",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1383",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1383",
|
|
4
4
|
"description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
|
|
5
5
|
"homepage": "https://ouroboros.bot/",
|
|
6
6
|
"engines": {
|