@ouro.bot/cli 0.1.0-alpha.1378 → 0.1.0-alpha.1379
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/heart/mcp/mcp-server.js +2 -47
- package/dist/nerves/coverage/file-completeness.js +1 -0
- package/dist/repertoire/in-turn-tools-door.js +54 -0
- package/dist/repertoire/mcp-tools.js +19 -3
- package/dist/repertoire/tool-candidates.js +50 -0
- package/dist/repertoire/tool-error-code.js +16 -0
- package/dist/repertoire/tools-surface.js +13 -6
- package/dist/repertoire/tools.js +18 -1
- 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.1379",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Every in-turn tool carries an Ouro AX card, a call's outcome is typed, and an unknown tool names the real tools it could mean; the Ouro AX X-ray now checks the in-turn tools in CI."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1378",
|
|
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.1379</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -39,7 +39,6 @@ exports._setSenseTurnCommandTimeoutMs = _setSenseTurnCommandTimeoutMs;
|
|
|
39
39
|
exports.mcpAnnotationsOf = mcpAnnotationsOf;
|
|
40
40
|
exports.toListedTool = toListedTool;
|
|
41
41
|
exports.listTools = listTools;
|
|
42
|
-
exports.toolCandidates = toolCandidates;
|
|
43
42
|
exports.createMcpServer = createMcpServer;
|
|
44
43
|
exports.getToolSchemas = getToolSchemas;
|
|
45
44
|
const fs = __importStar(require("fs"));
|
|
@@ -52,6 +51,7 @@ const session_id_resolver_1 = require("../daemon/session-id-resolver");
|
|
|
52
51
|
const pending_1 = require("../../mind/pending");
|
|
53
52
|
const feedback_source_1 = require("../../senses/shepherd/feedback-source");
|
|
54
53
|
const redact_1 = require("../../senses/shepherd/redact");
|
|
54
|
+
const tool_candidates_1 = require("../../repertoire/tool-candidates");
|
|
55
55
|
exports.SENSE_TURN_MAX_RETRIES = 3;
|
|
56
56
|
exports.SENSE_TURN_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
57
57
|
exports.SENSE_TURN_COMMAND_TIMEOUT_MS = 10 * 60 * 1000;
|
|
@@ -148,51 +148,6 @@ function listTools() {
|
|
|
148
148
|
exports.serverErrors = [
|
|
149
149
|
{ code: "unknown-door", means: "This server has no tool by that name.", fix: "If a suggested tool is the one you meant, call it; otherwise call tools/list and pick by description." },
|
|
150
150
|
];
|
|
151
|
-
/** A name as compared: a host's `mcp__<server>__` prefix dropped, lowercase, letters and digits only. */
|
|
152
|
-
function comparable(name) {
|
|
153
|
-
const bare = name.includes("__") ? name.slice(name.lastIndexOf("__") + 2) : name;
|
|
154
|
-
return bare.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
155
|
-
}
|
|
156
|
-
/** Edit distance between two comparable names. */
|
|
157
|
-
function nameDistance(x, y) {
|
|
158
|
-
let previous = Array.from({ length: y.length + 1 }, (_, j) => j);
|
|
159
|
-
for (let i = 1; i <= x.length; i++) {
|
|
160
|
-
const current = [i];
|
|
161
|
-
for (let j = 1; j <= y.length; j++) {
|
|
162
|
-
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (x[i - 1] === y[j - 1] ? 0 : 1));
|
|
163
|
-
}
|
|
164
|
-
previous = current;
|
|
165
|
-
}
|
|
166
|
-
return previous[y.length];
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The real tools a mistyped name could mean: the ones whose name contains it or that it contains (`report` gives the
|
|
170
|
-
* three report tools), else the one within a few edits of it, else none. Never a guess: a wrong suggestion would send
|
|
171
|
-
* the agent to a tool that does something else.
|
|
172
|
-
*/
|
|
173
|
-
function toolCandidates(name, names) {
|
|
174
|
-
const wanted = comparable(name);
|
|
175
|
-
const exact = names.filter((candidate) => comparable(candidate) === wanted);
|
|
176
|
-
if (exact.length > 0)
|
|
177
|
-
return exact;
|
|
178
|
-
if (wanted.length >= 3) {
|
|
179
|
-
const containing = names.filter((candidate) => comparable(candidate).includes(wanted));
|
|
180
|
-
if (containing.length > 0)
|
|
181
|
-
return containing;
|
|
182
|
-
}
|
|
183
|
-
const limit = Math.max(1, Math.floor(wanted.length / 3));
|
|
184
|
-
const near = names.map((candidate) => ({ candidate, distance: nameDistance(wanted, comparable(candidate)) })).filter((n) => n.distance <= limit);
|
|
185
|
-
if (near.length > 0) {
|
|
186
|
-
const best = Math.min(...near.map((n) => n.distance));
|
|
187
|
-
return near.filter((n) => n.distance === best).map((n) => n.candidate);
|
|
188
|
-
}
|
|
189
|
-
// A longer name that holds a tool's whole name, such as `send_message_now`: the longest such tool.
|
|
190
|
-
const inside = names.filter((candidate) => comparable(candidate).length >= 4 && wanted.includes(comparable(candidate)));
|
|
191
|
-
if (inside.length === 0)
|
|
192
|
-
return [];
|
|
193
|
-
const longest = Math.max(...inside.map((candidate) => comparable(candidate).length));
|
|
194
|
-
return inside.filter((candidate) => comparable(candidate).length === longest);
|
|
195
|
-
}
|
|
196
151
|
/** The required text argument each tool refuses to run without, and the error code it answers. */
|
|
197
152
|
const REQUIRED_TEXT = {
|
|
198
153
|
send_message: { arg: "message", code: "missing-message" },
|
|
@@ -523,7 +478,7 @@ function createMcpServer(options) {
|
|
|
523
478
|
if (typeof toolName !== "string" || !names.includes(toolName)) {
|
|
524
479
|
const unknown = exports.serverErrors.find((card) => card.code === "unknown-door");
|
|
525
480
|
const named = typeof toolName === "string" && toolName.length > 0;
|
|
526
|
-
const candidates = named ? toolCandidates(toolName, names) : [];
|
|
481
|
+
const candidates = named ? (0, tool_candidates_1.toolCandidates)(toolName, names) : [];
|
|
527
482
|
const nearest = candidates.length === 1 ? candidates[0] : null;
|
|
528
483
|
const quoted = candidates.map((candidate) => `"${candidate}"`).join(", ");
|
|
529
484
|
const message = !named
|
|
@@ -75,6 +75,7 @@ const DISPATCH_EXEMPT_PATTERNS = [
|
|
|
75
75
|
"repertoire/github-client",
|
|
76
76
|
// The suffix that ends a tool's coded error; each tool module that uses it owns its own observability.
|
|
77
77
|
"repertoire/tool-error-code",
|
|
78
|
+
"repertoire/tool-candidates",
|
|
78
79
|
"mind/embedding-provider",
|
|
79
80
|
// Commerce utility module: error classes and pure helpers (no independent side effects).
|
|
80
81
|
"repertoire/commerce-errors",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DISPATCH_ERRORS = void 0;
|
|
4
|
+
exports.neverSignIn = neverSignIn;
|
|
5
|
+
exports.listInTurnTools = listInTurnTools;
|
|
6
|
+
exports.callInTurnTool = callInTurnTool;
|
|
7
|
+
const runtime_1 = require("../nerves/runtime");
|
|
8
|
+
const tools_1 = require("./tools");
|
|
9
|
+
const tools_flow_1 = require("./tools-flow");
|
|
10
|
+
const tool_error_code_1 = require("./tool-error-code");
|
|
11
|
+
const tool_catalog_1 = require("./tool-catalog");
|
|
12
|
+
const specialist_tools_1 = require("../heart/hatch/specialist-tools");
|
|
13
|
+
/** The dispatcher's own codes, which any tool can answer before its handler runs. */
|
|
14
|
+
exports.DISPATCH_ERRORS = [
|
|
15
|
+
{ code: "unknown-tool", means: "No tool has that name in this turn.", fix: "Call one the text suggests, or pick one from this turn's tool list." },
|
|
16
|
+
{ code: "invalid-arguments", means: "The arguments don't match the tool's parameters, so it didn't run.", fix: "Call it again with the arguments the text names." },
|
|
17
|
+
{ code: "not-allowed", means: "The person this turn is for may not use this tool.", fix: "Use a tool this turn offers, or ask the person to do it." },
|
|
18
|
+
{ code: "tool-changed", means: "The tool changed or left this turn's tools after it was offered.", fix: "Pick again from the current tool list." },
|
|
19
|
+
{ code: "orientation-hold", means: "A correction hold blocks tools that change things until it clears.", fix: "Answer the correction first; read-only tools still work." },
|
|
20
|
+
{ code: "guardrail-blocked", means: "A guardrail refused this call; the text says which.", fix: "Do what the text says, such as reading the file before editing it." },
|
|
21
|
+
{ code: "commerce-authority-required", means: "A purchase needs a commerce authority token from the person.", fix: "Ask the person to approve the purchase, then call it with the token." },
|
|
22
|
+
{ code: "not-run", means: "This X-ray door checked the call but runs no tool.", fix: "Nothing to fix: in a real turn the tool runs." },
|
|
23
|
+
];
|
|
24
|
+
/** The door's sign-in: it never starts one, since no tool it answers runs. */
|
|
25
|
+
async function neverSignIn() {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const FLOW_TOOLS = [tools_flow_1.settleTool, tools_flow_1.speakTool, tools_flow_1.observeTool, tools_flow_1.restTool, tools_flow_1.ponderTool];
|
|
29
|
+
/** Tools a runner other than the dispatcher runs, which declare their cards beside their schemas. */
|
|
30
|
+
const DECLARED = [tool_catalog_1.findToolsDefinition, ...specialist_tools_1.specialistToolDefinitions];
|
|
31
|
+
const ENGINE_TOOLS = [...FLOW_TOOLS, ...DECLARED.map((d) => d.tool)];
|
|
32
|
+
function card(id) {
|
|
33
|
+
return tools_flow_1.toolCards.find((c) => c.id === id);
|
|
34
|
+
}
|
|
35
|
+
/** Every in-turn tool the harness registers, with its card: the dispatched definitions, the engine's flow tools, then find_tools and the hatch specialist's own. */
|
|
36
|
+
function listInTurnTools() {
|
|
37
|
+
const tools = [
|
|
38
|
+
...(0, tools_1.registeredToolDefinitions)().map((def) => ({ ...def.tool, ax: def.ax })),
|
|
39
|
+
...FLOW_TOOLS.map((tool) => ({ ...tool, ax: card(`tool:${tool.function.name}`) })),
|
|
40
|
+
...DECLARED.map((d) => ({ ...d.tool, ax: d.ax })),
|
|
41
|
+
];
|
|
42
|
+
(0, runtime_1.emitNervesEvent)({ component: "tools", event: "tool.door_listed", message: "in-turn tools listed for the X-ray", meta: { count: tools.length } });
|
|
43
|
+
return tools;
|
|
44
|
+
}
|
|
45
|
+
/** A call answered by the dispatcher's checks over every registered tool; one that passes them is not run. */
|
|
46
|
+
async function callInTurnTool(name, args) {
|
|
47
|
+
const selection = { ordinary: (0, tools_1.registeredToolDefinitions)(), engine: ENGINE_TOOLS };
|
|
48
|
+
const prepared = await (0, tools_1.preflightToolCall)(name, args, { toolSelection: selection, signin: neverSignIn });
|
|
49
|
+
const outcome = prepared.kind === "ready"
|
|
50
|
+
? { state: "refused", text: `${name} passed the dispatcher's checks; this X-ray door runs no tool (code: not-run)`, code: "not-run" }
|
|
51
|
+
: (0, tool_error_code_1.typedOutcome)(prepared);
|
|
52
|
+
(0, runtime_1.emitNervesEvent)({ component: "tools", event: "tool.door_called", message: "in-turn tool call answered for the X-ray", meta: { name, state: outcome.state } });
|
|
53
|
+
return outcome;
|
|
54
|
+
}
|
|
@@ -52,6 +52,20 @@ function mcpToolSchema(entry, tool) {
|
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* An MCP tool's Ouro AX card, made from what its server says: the tool's first description sentence as its `when`
|
|
57
|
+
* line, and a read effect only when the read-only hint is trusted (the agent's own servers), else a write.
|
|
58
|
+
*/
|
|
59
|
+
function mcpToolCard(server, tool, surfacedName, readOnly) {
|
|
60
|
+
const first = tool.description?.trim().split(/(?<=[.!?])\s/)[0]?.replace(/[.!?]$/, "");
|
|
61
|
+
return {
|
|
62
|
+
id: `tool:${surfacedName}`,
|
|
63
|
+
group: `mcp:${server}`,
|
|
64
|
+
when: `Pick this to use ${server}'s ${tool.name} tool${first ? `: ${first}` : ""}.`,
|
|
65
|
+
effect: readOnly ? "read" : "write",
|
|
66
|
+
errors: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
55
69
|
/**
|
|
56
70
|
* Convert an owned frozen MCP view into ToolDefinition objects.
|
|
57
71
|
*
|
|
@@ -78,11 +92,13 @@ function mcpToolsAsDefinitions(view) {
|
|
|
78
92
|
configDigest: entry.configDigest, generation: entry.generation,
|
|
79
93
|
schemaDigest: (0, tool_arguments_1.digestJson)(schema),
|
|
80
94
|
});
|
|
95
|
+
// A read-only hint is trusted only from the agent's own bundle (agent.json mcpServers),
|
|
96
|
+
// so an orientation hold still lets the agent inspect through those tools.
|
|
97
|
+
const trustedReadOnly = entry.source === "builtin" && tool.annotations?.readOnlyHint === true;
|
|
81
98
|
return {
|
|
82
99
|
tool: schema,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
riskProfile: entry.source === "builtin" && tool.annotations?.readOnlyHint === true
|
|
100
|
+
ax: mcpToolCard(entry.server, tool, schema.function.name, trustedReadOnly),
|
|
101
|
+
riskProfile: trustedReadOnly
|
|
86
102
|
? { mutates: "none", risk: "low", reason: "read-only tool from the agent's own MCP server" }
|
|
87
103
|
: {
|
|
88
104
|
mutates: "external_side_effect",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The real tools a mistyped tool name could mean. The MCP server and the in-turn dispatcher both answer an unknown tool
|
|
3
|
+
// with these, so a model is sent to a real tool by the same rule wherever it calls one.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.toolCandidates = toolCandidates;
|
|
6
|
+
/** A name as compared: a host's `mcp__<server>__` prefix dropped, lowercase, letters and digits only. */
|
|
7
|
+
function comparable(name) {
|
|
8
|
+
const bare = name.includes("__") ? name.slice(name.lastIndexOf("__") + 2) : name;
|
|
9
|
+
return bare.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
10
|
+
}
|
|
11
|
+
/** Edit distance between two comparable names. */
|
|
12
|
+
function nameDistance(x, y) {
|
|
13
|
+
let previous = Array.from({ length: y.length + 1 }, (_, j) => j);
|
|
14
|
+
for (let i = 1; i <= x.length; i++) {
|
|
15
|
+
const current = [i];
|
|
16
|
+
for (let j = 1; j <= y.length; j++) {
|
|
17
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (x[i - 1] === y[j - 1] ? 0 : 1));
|
|
18
|
+
}
|
|
19
|
+
previous = current;
|
|
20
|
+
}
|
|
21
|
+
return previous[y.length];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The real tools a mistyped name could mean: the ones whose name contains it or that it contains (`report` gives the
|
|
25
|
+
* three report tools), else the one within a few edits of it, else none. Never a guess: a wrong suggestion would send
|
|
26
|
+
* the agent to a tool that does something else.
|
|
27
|
+
*/
|
|
28
|
+
function toolCandidates(name, names) {
|
|
29
|
+
const wanted = comparable(name);
|
|
30
|
+
const exact = names.filter((candidate) => comparable(candidate) === wanted);
|
|
31
|
+
if (exact.length > 0)
|
|
32
|
+
return exact;
|
|
33
|
+
if (wanted.length >= 3) {
|
|
34
|
+
const containing = names.filter((candidate) => comparable(candidate).includes(wanted));
|
|
35
|
+
if (containing.length > 0)
|
|
36
|
+
return containing;
|
|
37
|
+
}
|
|
38
|
+
const limit = Math.max(1, Math.floor(wanted.length / 3));
|
|
39
|
+
const near = names.map((candidate) => ({ candidate, distance: nameDistance(wanted, comparable(candidate)) })).filter((n) => n.distance <= limit);
|
|
40
|
+
if (near.length > 0) {
|
|
41
|
+
const best = Math.min(...near.map((n) => n.distance));
|
|
42
|
+
return near.filter((n) => n.distance === best).map((n) => n.candidate);
|
|
43
|
+
}
|
|
44
|
+
// A longer name that holds a tool's whole name, such as `send_message_now`: the longest such tool.
|
|
45
|
+
const inside = names.filter((candidate) => comparable(candidate).length >= 4 && wanted.includes(comparable(candidate)));
|
|
46
|
+
if (inside.length === 0)
|
|
47
|
+
return [];
|
|
48
|
+
const longest = Math.max(...inside.map((candidate) => comparable(candidate).length));
|
|
49
|
+
return inside.filter((candidate) => comparable(candidate).length === longest);
|
|
50
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withCode = withCode;
|
|
4
|
+
exports.typedOutcome = typedOutcome;
|
|
4
5
|
/**
|
|
5
6
|
* An error text a tool or the dispatcher returns, ending with the code its Ouro AX card names, so a model can look up
|
|
6
7
|
* the card's fix. The message stays first and unchanged; the code is a suffix. Pass the code as a literal: the AX
|
|
@@ -12,3 +13,18 @@ exports.withCode = withCode;
|
|
|
12
13
|
function withCode(message, code) {
|
|
13
14
|
return `${message} (code: ${code})`;
|
|
14
15
|
}
|
|
16
|
+
const STATE_OF = {
|
|
17
|
+
handler_succeeded: "done",
|
|
18
|
+
rejected_before_handler: "refused",
|
|
19
|
+
handler_failed: "failed",
|
|
20
|
+
handler_indeterminate: "uncertain",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The dispatcher's outcome as a typed one: refused before the handler ran, failed, or uncertain when a high-risk call
|
|
24
|
+
* failed partway and nobody can say what it did. The code is the one `withCode` put at the end of the text.
|
|
25
|
+
*/
|
|
26
|
+
function typedOutcome(outcome) {
|
|
27
|
+
const state = STATE_OF[outcome.kind];
|
|
28
|
+
const code = state === "done" ? undefined : /\(code: ([a-z0-9-]+)\)$/.exec(outcome.text)?.[1];
|
|
29
|
+
return code ? { state, text: outcome.text, code } : { state, text: outcome.text };
|
|
30
|
+
}
|
|
@@ -293,9 +293,21 @@ async function routeSurfaceToFriend(agentName, friendId, content, queueItem, hin
|
|
|
293
293
|
}
|
|
294
294
|
/* v8 ignore stop */
|
|
295
295
|
}
|
|
296
|
+
/** surface's Ouro AX card, which its definition carries and `toolCards` lists for the census. */
|
|
297
|
+
const surfaceCard = {
|
|
298
|
+
id: "tool:surface",
|
|
299
|
+
group: "turn-sessions",
|
|
300
|
+
when: "Pick this to hand a finished thought back to whoever is waiting on it, by delegationId, or to reach out to a friend unprompted.",
|
|
301
|
+
effect: "write",
|
|
302
|
+
errors: [
|
|
303
|
+
{ code: "delivery-blocked", means: "The content carries internal meta markers, so nothing was delivered.", fix: "Rewrite the content as plain words for the person and surface it again." },
|
|
304
|
+
{ code: "orientation-hold", means: "This turn is on a correction hold, so surfacing waits.", fix: "Call orientation_get, settle what the person meant, then surface the thought if it still answers them." },
|
|
305
|
+
],
|
|
306
|
+
};
|
|
296
307
|
/* v8 ignore start -- surface handler wiring: core logic tested via surface-tool.test.ts; this wires identity/routing deps @preserve */
|
|
297
308
|
exports.surfaceToolDefinition = {
|
|
298
309
|
tool: exports.surfaceToolDef,
|
|
310
|
+
ax: surfaceCard,
|
|
299
311
|
handler: async (args, ctx) => {
|
|
300
312
|
const rawContent = args.content ?? "";
|
|
301
313
|
const deliveryHint = {
|
|
@@ -397,10 +409,5 @@ exports.surfaceToolDefinition = {
|
|
|
397
409
|
},
|
|
398
410
|
};
|
|
399
411
|
/** surface's Ouro AX card. The bare schema above is exported first, so the census reads the card from this list. */
|
|
400
|
-
exports.toolCards = [
|
|
401
|
-
{ id: "tool:surface", group: "turn-sessions", when: "Pick this to hand a finished thought back to whoever is waiting on it, by delegationId, or to reach out to a friend unprompted.", effect: "write", errors: [
|
|
402
|
-
{ code: "delivery-blocked", means: "The content carries internal meta markers, so nothing was delivered.", fix: "Rewrite the content as plain words for the person and surface it again." },
|
|
403
|
-
{ code: "orientation-hold", means: "This turn is on a correction hold, so surfacing waits.", fix: "Call orientation_get, settle what the person meant, then surface the thought if it still answers them." },
|
|
404
|
-
] },
|
|
405
|
-
];
|
|
412
|
+
exports.toolCards = [surfaceCard];
|
|
406
413
|
/* v8 ignore stop */
|
package/dist/repertoire/tools.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.selectToolsForChannel = selectToolsForChannel;
|
|
|
6
6
|
exports.getToolsForChannel = getToolsForChannel;
|
|
7
7
|
exports.reduceToolSelection = reduceToolSelection;
|
|
8
8
|
exports.resolveToolDefinition = resolveToolDefinition;
|
|
9
|
+
exports.registeredToolDefinitions = registeredToolDefinitions;
|
|
9
10
|
exports.approvalPolicyForToolName = approvalPolicyForToolName;
|
|
10
11
|
exports.classifyApprovalForInvocation = classifyApprovalForInvocation;
|
|
11
12
|
exports.approvalPolicyForInvocation = approvalPolicyForInvocation;
|
|
@@ -19,6 +20,8 @@ exports.execTool = execTool;
|
|
|
19
20
|
exports.summarizeArgs = summarizeArgs;
|
|
20
21
|
exports.buildToolResultSummary = buildToolResultSummary;
|
|
21
22
|
const node_util_1 = require("node:util");
|
|
23
|
+
const tool_candidates_1 = require("./tool-candidates");
|
|
24
|
+
const tool_catalog_1 = require("./tool-catalog");
|
|
22
25
|
const tools_base_1 = require("./tools-base");
|
|
23
26
|
const tools_teams_1 = require("./tools-teams");
|
|
24
27
|
const tools_chat_1 = require("./tools-chat");
|
|
@@ -259,6 +262,20 @@ function reduceToolSelection(selection, requested) {
|
|
|
259
262
|
function resolveToolDefinition(toolName, selection) {
|
|
260
263
|
return (selection?.ordinary ?? [...tools_base_1.baseToolDefinitions, ...additionalDefinitions]).find((definition) => definition.tool.function.name === toolName);
|
|
261
264
|
}
|
|
265
|
+
/** Every in-turn tool definition the harness registers, before any channel or relationship narrows it. */
|
|
266
|
+
function registeredToolDefinitions() {
|
|
267
|
+
return [...tools_base_1.baseToolDefinitions, ...additionalDefinitions, tools_sanctuary_host_1.rootHostToolDefinition, tools_voice_local_1.voiceLocalAudioToolDefinition];
|
|
268
|
+
}
|
|
269
|
+
/** What an unknown tool answers: the real tools its name could mean, else where the real ones are. */
|
|
270
|
+
function unknownToolText(name, selection) {
|
|
271
|
+
const names = (selection ? toolSelectionSchemas(selection) : registeredToolDefinitions().map((d) => d.tool)).map((tool) => tool.function.name);
|
|
272
|
+
const candidates = (0, tool_candidates_1.toolCandidates)(name, names);
|
|
273
|
+
return candidates.length > 0
|
|
274
|
+
? `unknown: ${name}; did you mean ${candidates.map((candidate) => `"${candidate}"`).join(" or ")}?`
|
|
275
|
+
: names.includes(tool_catalog_1.FIND_TOOLS_NAME)
|
|
276
|
+
? `unknown: ${name}; no tool has a name close to it, so pick one from this turn's tool list, or call ${tool_catalog_1.FIND_TOOLS_NAME} to search the tools held back from it`
|
|
277
|
+
: `unknown: ${name}; no tool has a name close to it, so pick one from this turn's tool list`;
|
|
278
|
+
}
|
|
262
279
|
function approvalPolicyForToolName(name, args, selection) {
|
|
263
280
|
return resolveToolDefinition(name, selection)?.approvalPolicy?.(args) ?? { kind: "not_required" };
|
|
264
281
|
}
|
|
@@ -407,7 +424,7 @@ async function preflightToolCall(name, args, ctx) {
|
|
|
407
424
|
const schema = def?.tool ?? selection?.engine.find((tool) => tool.function.name === name);
|
|
408
425
|
if (!schema) {
|
|
409
426
|
(0, runtime_1.emitNervesEvent)({ level: "error", event: "tool.error", component: "tools", message: "unknown or unselected tool requested", meta: { name } });
|
|
410
|
-
return { kind: "rejected_before_handler", text: (0, tools_base_1.withCode)(
|
|
427
|
+
return { kind: "rejected_before_handler", text: (0, tools_base_1.withCode)(unknownToolText(name, selection), "unknown-tool") };
|
|
411
428
|
}
|
|
412
429
|
if (name === tools_sanctuary_host_1.rootHostToolDefinition.tool.function.name)
|
|
413
430
|
await (0, tools_sanctuary_host_1.authorizeRootHostToolInvocation)(ctx, def, args);
|
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.1379",
|
|
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.1379",
|
|
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.1379",
|
|
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": {
|