@ouro.bot/cli 0.1.0-alpha.1349 → 0.1.0-alpha.1350

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 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.1350",
6
+ "changes": [
7
+ "Anthropic requests can defer tools with defer_loading and load them through tool_reference blocks from a find_tools reply, keeping the cached prompt; the engine doesn't defer any tools yet, so requests are unchanged."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1349",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1349",
2
+ "runtimeVersion": "0.1.0-alpha.1350",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.1349</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1350</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -48,6 +48,7 @@ const runtime_1 = require("../../nerves/runtime");
48
48
  const streaming_1 = require("../streaming");
49
49
  const model_capabilities_1 = require("../model-capabilities");
50
50
  const error_classification_1 = require("./error-classification");
51
+ const tool_catalog_1 = require("../../repertoire/tool-catalog");
51
52
  const ANTHROPIC_SETUP_TOKEN_PREFIX = "sk-ant-oat01-";
52
53
  const ANTHROPIC_SETUP_TOKEN_MIN_LENGTH = 80;
53
54
  const ANTHROPIC_OAUTH_BETA_HEADER = "claude-code-20250219,oauth-2025-04-20,fine-grained-tool-streaming-2025-05-14,interleaved-thinking-2025-05-14";
@@ -130,9 +131,10 @@ function parseToolCallInput(argumentsJson) {
130
131
  return {};
131
132
  }
132
133
  }
133
- function toAnthropicMessages(messages) {
134
+ function toAnthropicMessages(messages, options = {}) {
134
135
  const systemParts = [];
135
136
  const converted = [];
137
+ const findToolsCallIds = new Set();
136
138
  for (const msg of messages) {
137
139
  if (msg.role === "system") {
138
140
  const text = toAnthropicTextContent(msg.content).trim();
@@ -172,6 +174,8 @@ function toAnthropicMessages(messages) {
172
174
  /* v8 ignore next -- type narrowing: OpenAI SDK only emits function tool_calls @preserve */
173
175
  if (toolCall.type !== "function")
174
176
  continue;
177
+ if (toolCall.function.name === tool_catalog_1.FIND_TOOLS_NAME)
178
+ findToolsCallIds.add(toolCall.id);
175
179
  blocks.push({
176
180
  type: "tool_use",
177
181
  id: toolCall.id,
@@ -188,13 +192,17 @@ function toAnthropicMessages(messages) {
188
192
  }
189
193
  if (msg.role === "tool") {
190
194
  const tool = msg;
195
+ const text = toAnthropicTextContent(tool.content);
196
+ const references = options.toolReferences && findToolsCallIds.has(tool.tool_call_id)
197
+ ? (0, tool_catalog_1.loadedDoorNames)(text).filter((name) => options.toolReferences.has(name))
198
+ : [];
191
199
  converted.push({
192
200
  role: "user",
193
201
  content: [
194
202
  {
195
203
  type: "tool_result",
196
204
  tool_use_id: tool.tool_call_id,
197
- content: toAnthropicTextContent(tool.content),
205
+ content: references.length > 0 ? references.map((name) => ({ type: "tool_reference", tool_name: name })) : text,
198
206
  },
199
207
  ],
200
208
  });
@@ -205,13 +213,17 @@ function toAnthropicMessages(messages) {
205
213
  // The Anthropic API rejects the whole request when any tool's input_schema has
206
214
  // oneOf, allOf or anyOf at the top level, so those keys are dropped here. Each
207
215
  // tool's handler still enforces its own either/or rules.
208
- function toAnthropicTools(tools) {
216
+ // A deferred door is sent with `defer_loading: true`: the API keeps it out of context until find_tools loads it. The
217
+ // API refuses a request where every tool is deferred, so a list with nothing left loaded is sent whole.
218
+ function toAnthropicTools(tools, deferred = new Set()) {
219
+ const defer = tools.some((tool) => !deferred.has(tool.function.name));
209
220
  return tools.map((tool) => {
210
221
  const { oneOf: _oneOf, allOf: _allOf, anyOf: _anyOf, ...schema } = tool.function.parameters ?? { type: "object", properties: {} };
211
222
  return {
212
223
  name: tool.function.name,
213
224
  description: tool.function.description ?? "",
214
225
  input_schema: schema,
226
+ ...(defer && deferred.has(tool.function.name) ? { defer_loading: true } : {}),
215
227
  };
216
228
  });
217
229
  }
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TURN_TOOL_NAMES = void 0;
3
+ exports.TURN_TOOL_NAMES = exports.FIND_TOOLS_NAME = void 0;
4
4
  exports.catalogDoor = catalogDoor;
5
5
  exports.buildToolCatalog = buildToolCatalog;
6
6
  exports.searchCatalog = searchCatalog;
7
+ exports.formatLoadedDoors = formatLoadedDoors;
8
+ exports.loadedDoorNames = loadedDoorNames;
7
9
  const runtime_1 = require("../nerves/runtime");
10
+ /** The door that loads deferred doors on every provider. */
11
+ exports.FIND_TOOLS_NAME = "find_tools";
8
12
  /** The engine's turn tools: a turn can't end, think or reply without them, so they are never deferred. */
9
13
  exports.TURN_TOOL_NAMES = new Set(["settle", "ponder", "observe", "rest", "speak", "surface"]);
10
14
  const MAX_WHEN = 200;
@@ -88,3 +92,21 @@ function searchCatalog(catalog, candidates, query) {
88
92
  const floor = scored.length > 0 ? Math.ceil(scored[0].score / 3) : 0;
89
93
  return scored.filter((entry) => entry.score >= floor).slice(0, MAX_RESULTS).map((entry) => entry.name);
90
94
  }
95
+ const LOADED_HEADER = "loaded; callable on your next step:";
96
+ function signature(tool) {
97
+ const parameters = tool.function.parameters;
98
+ const required = new Set(parameters?.required ?? []);
99
+ return Object.keys(parameters?.properties ?? {}).map((key) => (required.has(key) ? key : `${key}?`)).join(", ");
100
+ }
101
+ /** `find_tools`'s reply: the doors it loaded, one per line, or how to try again. */
102
+ function formatLoadedDoors(loaded) {
103
+ if (loaded.length === 0)
104
+ return "no matching tools. try different words, or select:name1,name2 using a name from the list in find_tools.";
105
+ return `${LOADED_HEADER}\n${loaded.map((tool) => `- ${tool.function.name}(${signature(tool)}): ${tool.function.description ?? ""}`).join("\n")}`;
106
+ }
107
+ /** The door names a `find_tools` reply loaded, read back from its text so the reply itself stays the record. */
108
+ function loadedDoorNames(reply) {
109
+ if (!reply.startsWith(LOADED_HEADER))
110
+ return [];
111
+ return reply.split("\n").slice(1).flatMap((line) => /^- ([A-Za-z0-9_-]+)\(/.exec(line)?.[1] ?? []);
112
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1349",
3
+ "version": "0.1.0-alpha.1350",
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.1349",
9
+ "version": "0.1.0-alpha.1350",
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.1349",
3
+ "version": "0.1.0-alpha.1350",
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": {