@oh-my-pi/pi-agent-core 3.37.1 → 4.0.1

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/agent.ts +47 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-agent-core",
3
- "version": "3.37.1",
3
+ "version": "4.0.1",
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": "3.37.1",
17
- "@oh-my-pi/pi-tui": "3.37.1"
16
+ "@oh-my-pi/pi-ai": "4.0.1",
17
+ "@oh-my-pi/pi-tui": "4.0.1"
18
18
  },
19
19
  "keywords": [
20
20
  "ai",
package/src/agent.ts CHANGED
@@ -3,7 +3,15 @@
3
3
  * No transport abstraction - calls streamSimple via the loop.
4
4
  */
5
5
 
6
- import { getModel, type ImageContent, type Message, type Model, streamSimple, type TextContent } from "@oh-my-pi/pi-ai";
6
+ import {
7
+ getModel,
8
+ type ImageContent,
9
+ type Message,
10
+ type Model,
11
+ streamSimple,
12
+ type TextContent,
13
+ type ThinkingBudgets,
14
+ } from "@oh-my-pi/pi-ai";
7
15
  import { agentLoop, agentLoopContinue } from "./agent-loop";
8
16
  import type {
9
17
  AgentContext,
@@ -73,6 +81,11 @@ export interface AgentOptions {
73
81
  */
74
82
  getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
75
83
 
84
+ /**
85
+ * Custom token budgets for thinking levels (token-based providers only).
86
+ */
87
+ thinkingBudgets?: ThinkingBudgets;
88
+
76
89
  /**
77
90
  * Provides tool execution context, resolved per tool call.
78
91
  * Use for late-bound UI or session state access.
@@ -104,6 +117,7 @@ export class Agent {
104
117
  private interruptMode: "immediate" | "wait";
105
118
  public streamFn: StreamFn;
106
119
  private _sessionId?: string;
120
+ private _thinkingBudgets?: ThinkingBudgets;
107
121
  public getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
108
122
  private getToolContext?: () => AgentToolContext | undefined;
109
123
  private runningPrompt?: Promise<void>;
@@ -118,6 +132,7 @@ export class Agent {
118
132
  this.interruptMode = opts.interruptMode || "immediate";
119
133
  this.streamFn = opts.streamFn || streamSimple;
120
134
  this._sessionId = opts.sessionId;
135
+ this._thinkingBudgets = opts.thinkingBudgets;
121
136
  this.getApiKey = opts.getApiKey;
122
137
  this.getToolContext = opts.getToolContext;
123
138
  }
@@ -137,6 +152,20 @@ export class Agent {
137
152
  this._sessionId = value;
138
153
  }
139
154
 
155
+ /**
156
+ * Get the current thinking budgets.
157
+ */
158
+ get thinkingBudgets(): ThinkingBudgets | undefined {
159
+ return this._thinkingBudgets;
160
+ }
161
+
162
+ /**
163
+ * Set custom thinking budgets for token-based providers.
164
+ */
165
+ set thinkingBudgets(value: ThinkingBudgets | undefined) {
166
+ this._thinkingBudgets = value;
167
+ }
168
+
140
169
  get state(): AgentState {
141
170
  return this._state;
142
171
  }
@@ -236,6 +265,22 @@ export class Agent {
236
265
  this.followUpQueue = [];
237
266
  }
238
267
 
268
+ /**
269
+ * Remove and return the last steering message from the queue (LIFO).
270
+ * Used by dequeue keybinding.
271
+ */
272
+ popLastSteer(): AgentMessage | undefined {
273
+ return this.steeringQueue.pop();
274
+ }
275
+
276
+ /**
277
+ * Remove and return the last follow-up message from the queue (LIFO).
278
+ * Used by dequeue keybinding.
279
+ */
280
+ popLastFollowUp(): AgentMessage | undefined {
281
+ return this.followUpQueue.pop();
282
+ }
283
+
239
284
  clearMessages() {
240
285
  this._state.messages = [];
241
286
  }
@@ -342,6 +387,7 @@ export class Agent {
342
387
  reasoning,
343
388
  interruptMode: this.interruptMode,
344
389
  sessionId: this._sessionId,
390
+ thinkingBudgets: this._thinkingBudgets,
345
391
  convertToLlm: this.convertToLlm,
346
392
  transformContext: this.transformContext,
347
393
  getApiKey: this.getApiKey,