@oh-my-pi/pi-agent-core 6.0.0 → 6.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-agent-core",
3
- "version": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -13,8 +13,8 @@
13
13
  "test": "vitest --run"
14
14
  },
15
15
  "dependencies": {
16
- "@oh-my-pi/pi-ai": "6.0.0",
17
- "@oh-my-pi/pi-tui": "6.0.0"
16
+ "@oh-my-pi/pi-ai": "6.2.0",
17
+ "@oh-my-pi/pi-tui": "6.2.0"
18
18
  },
19
19
  "keywords": [
20
20
  "ai",
package/src/agent-loop.ts CHANGED
@@ -377,6 +377,8 @@ async function executeToolCalls(
377
377
  const results: ToolResultMessage[] = [];
378
378
  let steeringMessages: AgentMessage[] | undefined;
379
379
  const shouldInterruptImmediately = interruptMode !== "wait";
380
+ const toolCallInfos = toolCalls.map((call) => ({ id: call.id, name: call.name }));
381
+ const batchId = `${assistantMessage.timestamp ?? Date.now()}_${toolCalls[0]?.id ?? "batch"}`;
380
382
 
381
383
  for (let index = 0; index < toolCalls.length; index++) {
382
384
  const toolCall = toolCalls[index];
@@ -397,7 +399,14 @@ async function executeToolCalls(
397
399
 
398
400
  const validatedArgs = validateToolArguments(tool, toolCall);
399
401
 
400
- const toolContext = getToolContext ? getToolContext() : undefined;
402
+ const toolContext = getToolContext
403
+ ? getToolContext({
404
+ batchId,
405
+ index,
406
+ total: toolCalls.length,
407
+ toolCalls: toolCallInfos,
408
+ })
409
+ : undefined;
401
410
  result = await tool.execute(
402
411
  toolCall.id,
403
412
  validatedArgs,
package/src/agent.ts CHANGED
@@ -27,6 +27,7 @@ import type {
27
27
  AgentToolContext,
28
28
  StreamFn,
29
29
  ThinkingLevel,
30
+ ToolCallContext,
30
31
  } from "./types";
31
32
 
32
33
  /**
@@ -94,7 +95,7 @@ export interface AgentOptions {
94
95
  * Provides tool execution context, resolved per tool call.
95
96
  * Use for late-bound UI or session state access.
96
97
  */
97
- getToolContext?: () => AgentToolContext | undefined;
98
+ getToolContext?: (toolCall?: ToolCallContext) => AgentToolContext | undefined;
98
99
 
99
100
  /**
100
101
  * Cursor exec handlers for local tool execution.
@@ -139,7 +140,7 @@ export class Agent {
139
140
  private _sessionId?: string;
140
141
  private _thinkingBudgets?: ThinkingBudgets;
141
142
  public getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
142
- private getToolContext?: () => AgentToolContext | undefined;
143
+ private getToolContext?: (toolCall?: ToolCallContext) => AgentToolContext | undefined;
143
144
  private cursorExecHandlers?: CursorExecHandlers;
144
145
  private cursorOnToolResult?: CursorToolResultHandler;
145
146
  private runningPrompt?: Promise<void>;
package/src/types.ts CHANGED
@@ -109,7 +109,14 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
109
109
  * Provides tool execution context, resolved per tool call.
110
110
  * Use for late-bound UI or session state access.
111
111
  */
112
- getToolContext?: () => AgentToolContext | undefined;
112
+ getToolContext?: (toolCall?: ToolCallContext) => AgentToolContext | undefined;
113
+ }
114
+
115
+ export interface ToolCallContext {
116
+ batchId: string;
117
+ index: number;
118
+ total: number;
119
+ toolCalls: Array<{ id: string; name: string }>;
113
120
  }
114
121
 
115
122
  /**