@oh-my-pi/pi-agent-core 12.1.0 → 12.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.
Files changed (2) hide show
  1. package/package.json +17 -12
  2. package/src/agent.ts +28 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-agent-core",
3
- "version": "12.1.0",
3
+ "version": "12.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",
@@ -24,9 +24,9 @@
24
24
  "test": "bun test"
25
25
  },
26
26
  "dependencies": {
27
- "@oh-my-pi/pi-ai": "12.1.0",
28
- "@oh-my-pi/pi-tui": "12.1.0",
29
- "@oh-my-pi/pi-utils": "12.1.0"
27
+ "@oh-my-pi/pi-ai": "12.2.0",
28
+ "@oh-my-pi/pi-tui": "12.2.0",
29
+ "@oh-my-pi/pi-utils": "12.2.0"
30
30
  },
31
31
  "keywords": [
32
32
  "ai",
@@ -35,18 +35,23 @@
35
35
  "transport",
36
36
  "state-management"
37
37
  ],
38
- "author": "Mario Zechner",
38
+ "author": "Can Bölük",
39
+ "contributors": ["Mario Zechner"],
39
40
  "license": "MIT",
40
41
  "repository": {
41
42
  "type": "git",
42
43
  "url": "git+https://github.com/can1357/oh-my-pi.git",
43
44
  "directory": "packages/agent"
44
45
  },
45
- "engines": {
46
- "bun": ">=1.3.7"
47
- },
48
- "devDependencies": {
49
- "@sinclair/typebox": "^0.34.48",
50
- "@types/bun": "^1.3.9"
51
- }
46
+ "homepage": "https://github.com/can1357/oh-my-pi",
47
+ "bugs": {
48
+ "url": "https://github.com/can1357/oh-my-pi/issues"
49
+ },
50
+ "engines": {
51
+ "bun": ">=1.3.7"
52
+ },
53
+ "devDependencies": {
54
+ "@sinclair/typebox": "^0.34.48",
55
+ "@types/bun": "^1.3.9"
56
+ }
52
57
  }
package/src/agent.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  type ImageContent,
11
11
  type Message,
12
12
  type Model,
13
+ type ProviderSessionState,
13
14
  streamSimple,
14
15
  type TextContent,
15
16
  type ThinkingBudgets,
@@ -74,6 +75,9 @@ export interface AgentOptions {
74
75
  */
75
76
  kimiApiFormat?: "openai" | "anthropic";
76
77
 
78
+ /** Hint that websocket transport should be preferred when supported by the provider implementation. */
79
+ preferWebsockets?: boolean;
80
+
77
81
  /**
78
82
  * Custom stream function (for proxy backends, etc.). Default uses streamSimple.
79
83
  */
@@ -84,6 +88,10 @@ export interface AgentOptions {
84
88
  * Used by providers that support session-based caching (e.g., OpenAI Codex).
85
89
  */
86
90
  sessionId?: string;
91
+ /**
92
+ * Shared provider state map for session-scoped transport/session caches.
93
+ */
94
+ providerSessionState?: Map<string, ProviderSessionState>;
87
95
 
88
96
  /**
89
97
  * Resolves an API key dynamically for each LLM call.
@@ -159,6 +167,7 @@ export class Agent {
159
167
  #followUpMode: "all" | "one-at-a-time";
160
168
  #interruptMode: "immediate" | "wait";
161
169
  #sessionId?: string;
170
+ #providerSessionState?: Map<string, ProviderSessionState>;
162
171
  #thinkingBudgets?: ThinkingBudgets;
163
172
  #temperature?: number;
164
173
  #maxRetryDelayMs?: number;
@@ -168,6 +177,7 @@ export class Agent {
168
177
  #runningPrompt?: Promise<void>;
169
178
  #resolveRunningPrompt?: () => void;
170
179
  #kimiApiFormat?: "openai" | "anthropic";
180
+ #preferWebsockets?: boolean;
171
181
 
172
182
  /** Buffered Cursor tool results with text length at time of call (for correct ordering) */
173
183
  #cursorToolResultBuffer: CursorToolResultEntry[] = [];
@@ -184,6 +194,7 @@ export class Agent {
184
194
  this.#interruptMode = opts.interruptMode || "immediate";
185
195
  this.streamFn = opts.streamFn || streamSimple;
186
196
  this.#sessionId = opts.sessionId;
197
+ this.#providerSessionState = opts.providerSessionState;
187
198
  this.#thinkingBudgets = opts.thinkingBudgets;
188
199
  this.#temperature = opts.temperature;
189
200
  this.#maxRetryDelayMs = opts.maxRetryDelayMs;
@@ -192,6 +203,7 @@ export class Agent {
192
203
  this.#cursorExecHandlers = opts.cursorExecHandlers;
193
204
  this.#cursorOnToolResult = opts.cursorOnToolResult;
194
205
  this.#kimiApiFormat = opts.kimiApiFormat;
206
+ this.#preferWebsockets = opts.preferWebsockets;
195
207
  }
196
208
 
197
209
  /**
@@ -209,6 +221,20 @@ export class Agent {
209
221
  this.#sessionId = value;
210
222
  }
211
223
 
224
+ /**
225
+ * Get provider-scoped mutable session state store.
226
+ */
227
+ get providerSessionState(): Map<string, ProviderSessionState> | undefined {
228
+ return this.#providerSessionState;
229
+ }
230
+
231
+ /**
232
+ * Set provider-scoped mutable session state store.
233
+ */
234
+ set providerSessionState(value: Map<string, ProviderSessionState> | undefined) {
235
+ this.#providerSessionState = value;
236
+ }
237
+
212
238
  /**
213
239
  * Get the current thinking budgets.
214
240
  */
@@ -588,9 +614,11 @@ export class Agent {
588
614
  temperature: this.#temperature,
589
615
  interruptMode: this.#interruptMode,
590
616
  sessionId: this.#sessionId,
617
+ providerSessionState: this.#providerSessionState,
591
618
  thinkingBudgets: this.#thinkingBudgets,
592
619
  maxRetryDelayMs: this.#maxRetryDelayMs,
593
620
  kimiApiFormat: this.#kimiApiFormat,
621
+ preferWebsockets: this.#preferWebsockets,
594
622
  toolChoice: options?.toolChoice,
595
623
  convertToLlm: this.#convertToLlm,
596
624
  transformContext: this.#transformContext,