@oh-my-pi/pi-agent-core 17.1.1 → 17.1.2
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 +6 -0
- package/dist/types/agent.d.ts +6 -0
- package/dist/types/types.d.ts +7 -0
- package/package.json +7 -7
- package/src/agent-loop.ts +7 -1
- package/src/agent.ts +10 -0
- package/src/compaction/compaction.ts +8 -0
- package/src/types.ts +7 -0
package/CHANGELOG.md
CHANGED
package/dist/types/agent.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/types/types.d.ts
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "17.1.2",
|
|
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.
|
|
39
|
-
"@oh-my-pi/pi-catalog": "17.1.
|
|
40
|
-
"@oh-my-pi/pi-natives": "17.1.
|
|
41
|
-
"@oh-my-pi/pi-utils": "17.1.
|
|
42
|
-
"@oh-my-pi/pi-wire": "17.1.
|
|
43
|
-
"@oh-my-pi/snapcompact": "17.1.
|
|
38
|
+
"@oh-my-pi/pi-ai": "17.1.2",
|
|
39
|
+
"@oh-my-pi/pi-catalog": "17.1.2",
|
|
40
|
+
"@oh-my-pi/pi-natives": "17.1.2",
|
|
41
|
+
"@oh-my-pi/pi-utils": "17.1.2",
|
|
42
|
+
"@oh-my-pi/pi-wire": "17.1.2",
|
|
43
|
+
"@oh-my-pi/snapcompact": "17.1.2",
|
|
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.
|