@oh-my-pi/pi-agent-core 17.1.1 → 17.1.3

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.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [17.1.2] - 2026-07-24
6
+
7
+ ### Added
8
+
9
+ - Added `resolveFallbackTool` option to allow routing unadvertised tool calls to host-side transports (e.g., device mounts)
10
+
5
11
  ## [17.1.1] - 2026-07-24
6
12
 
7
13
  ### Added
@@ -134,6 +134,12 @@ export interface AgentOptions {
134
134
  * Use for deobfuscating secrets or rewriting arguments.
135
135
  */
136
136
  transformToolCallArguments?: (args: Record<string, unknown>, toolName: string) => Record<string, unknown>;
137
+ /**
138
+ * Resolve a tool call whose name matched no advertised tool. Lets hosts
139
+ * route calls to tools exposed through side transports (e.g. `xd://`
140
+ * device mounts) instead of failing with "Tool not found".
141
+ */
142
+ resolveFallbackTool?: (name: string) => AgentTool<any> | undefined;
137
143
  /** Enable intent tracing schema injection/stripping in the harness. */
138
144
  intentTracing?: boolean;
139
145
  /**
@@ -230,6 +230,13 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
230
230
  * Use for deobfuscating secrets or rewriting arguments.
231
231
  */
232
232
  transformToolCallArguments?: (args: Record<string, unknown>, toolName: string) => Record<string, unknown>;
233
+ /**
234
+ * Resolve a tool call whose name matched no advertised tool (including
235
+ * `customWireName` aliases). Lets hosts route calls to tools they expose
236
+ * through side transports (e.g. `xd://` device mounts) instead of failing
237
+ * with "Tool not found". Returning `undefined` keeps the failure.
238
+ */
239
+ resolveFallbackTool?: (name: string) => AgentTool<any> | undefined;
233
240
  /**
234
241
  * Enable intent tracing for tool calls.
235
242
  * When enabled, the harness injects a `string` field into tool schemas sent to the model,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-agent-core",
4
- "version": "17.1.1",
4
+ "version": "17.1.3",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -35,12 +35,12 @@
35
35
  "fmt": "biome format --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@oh-my-pi/pi-ai": "17.1.1",
39
- "@oh-my-pi/pi-catalog": "17.1.1",
40
- "@oh-my-pi/pi-natives": "17.1.1",
41
- "@oh-my-pi/pi-utils": "17.1.1",
42
- "@oh-my-pi/pi-wire": "17.1.1",
43
- "@oh-my-pi/snapcompact": "17.1.1",
38
+ "@oh-my-pi/pi-ai": "17.1.3",
39
+ "@oh-my-pi/pi-catalog": "17.1.3",
40
+ "@oh-my-pi/pi-natives": "17.1.3",
41
+ "@oh-my-pi/pi-utils": "17.1.3",
42
+ "@oh-my-pi/pi-wire": "17.1.3",
43
+ "@oh-my-pi/snapcompact": "17.1.3",
44
44
  "@opentelemetry/api": "^1.9.1"
45
45
  },
46
46
  "devDependencies": {
package/src/agent-loop.ts CHANGED
@@ -348,6 +348,8 @@ function snapshotAssistantContentBlock(block: AssistantContentBlock): AssistantC
348
348
  return { ...block };
349
349
  case "redactedThinking":
350
350
  return { ...block };
351
+ case "anthropicServerTool":
352
+ return { ...block, block: structuredCloneJSON(block.block) };
351
353
  case "fallback":
352
354
  return { ...block, from: { ...block.from }, to: { ...block.to } };
353
355
  case "toolCall":
@@ -1973,6 +1975,7 @@ async function executeToolCalls(
1973
1975
  interruptMode = "immediate",
1974
1976
  getToolContext,
1975
1977
  transformToolCallArguments,
1978
+ resolveFallbackTool,
1976
1979
  intentTracing,
1977
1980
  beforeToolCall,
1978
1981
  afterToolCall,
@@ -2015,7 +2018,10 @@ async function executeToolCalls(
2015
2018
  // determinism if both somehow collide.
2016
2019
  const tool =
2017
2020
  tools?.find(t => t.name === toolCall.name) ??
2018
- tools?.find(t => t.customWireName !== undefined && t.customWireName === toolCall.name);
2021
+ tools?.find(t => t.customWireName !== undefined && t.customWireName === toolCall.name) ??
2022
+ // Not in the advertised set: let the host route side-transport tools
2023
+ // (e.g. xd:// device mounts) called by their top-level name.
2024
+ resolveFallbackTool?.(toolCall.name);
2019
2025
  const args = toolCall.arguments as Record<string, unknown>;
2020
2026
  const interruptibleMode = tool?.interruptible;
2021
2027
  let interruptible = false;
package/src/agent.ts CHANGED
@@ -241,6 +241,13 @@ export interface AgentOptions {
241
241
  */
242
242
  transformToolCallArguments?: (args: Record<string, unknown>, toolName: string) => Record<string, unknown>;
243
243
 
244
+ /**
245
+ * Resolve a tool call whose name matched no advertised tool. Lets hosts
246
+ * route calls to tools exposed through side transports (e.g. `xd://`
247
+ * device mounts) instead of failing with "Tool not found".
248
+ */
249
+ resolveFallbackTool?: (name: string) => AgentTool<any> | undefined;
250
+
244
251
  /** Enable intent tracing schema injection/stripping in the harness. */
245
252
  intentTracing?: boolean;
246
253
  /**
@@ -378,6 +385,7 @@ export class Agent {
378
385
  #kimiApiFormat?: "openai" | "anthropic";
379
386
  #preferWebsockets?: boolean;
380
387
  #transformToolCallArguments?: (args: Record<string, unknown>, toolName: string) => Record<string, unknown>;
388
+ #resolveFallbackTool?: (name: string) => AgentTool<any> | undefined;
381
389
  #intentTracing: boolean;
382
390
  #pruneToolDescriptions: boolean;
383
391
  #dialect?: Dialect;
@@ -458,6 +466,7 @@ export class Agent {
458
466
  this.#kimiApiFormat = opts.kimiApiFormat;
459
467
  this.#preferWebsockets = opts.preferWebsockets;
460
468
  this.#transformToolCallArguments = opts.transformToolCallArguments;
469
+ this.#resolveFallbackTool = opts.resolveFallbackTool;
461
470
  this.#intentTracing = opts.intentTracing === true;
462
471
  this.#pruneToolDescriptions = opts.pruneToolDescriptions === true;
463
472
  this.#dialect = opts.dialect;
@@ -1193,6 +1202,7 @@ export class Agent {
1193
1202
  cwd: this.#cwd,
1194
1203
  getCwd: this.#cwdResolver,
1195
1204
  transformToolCallArguments: this.#transformToolCallArguments,
1205
+ resolveFallbackTool: this.#resolveFallbackTool,
1196
1206
  intentTracing: this.#intentTracing,
1197
1207
  pruneToolDescriptions: this.#pruneToolDescriptions,
1198
1208
  dialect: this.#dialect,
@@ -427,6 +427,14 @@ function computeMessageTokens(message: AgentMessage, options?: { excludeEncrypte
427
427
  // Encrypted reasoning blob the provider still bills for on replay;
428
428
  // excluded from the compaction floor for the same reason as above.
429
429
  if (!options?.excludeEncryptedReasoning) fragments.push(block.data);
430
+ } else if (block.type === "anthropicServerTool") {
431
+ // Native Anthropic server-tool call/result replayed verbatim on the
432
+ // wire (server_tool_use input, web_search_tool_result
433
+ // encrypted_content). Opaque provider-replay state the provider still
434
+ // bills for on same-provider replay; excluded from the compaction
435
+ // floor like other encrypted reasoning because its local byte size
436
+ // diverges from provider billing.
437
+ if (!options?.excludeEncryptedReasoning) fragments.push(stringifyJson(block.block) ?? "null");
430
438
  }
431
439
  }
432
440
  break;
package/src/types.ts CHANGED
@@ -276,6 +276,13 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
276
276
  * Use for deobfuscating secrets or rewriting arguments.
277
277
  */
278
278
  transformToolCallArguments?: (args: Record<string, unknown>, toolName: string) => Record<string, unknown>;
279
+ /**
280
+ * Resolve a tool call whose name matched no advertised tool (including
281
+ * `customWireName` aliases). Lets hosts route calls to tools they expose
282
+ * through side transports (e.g. `xd://` device mounts) instead of failing
283
+ * with "Tool not found". Returning `undefined` keeps the failure.
284
+ */
285
+ resolveFallbackTool?: (name: string) => AgentTool<any> | undefined;
279
286
 
280
287
  /**
281
288
  * Enable intent tracing for tool calls.