@oh-my-pi/pi-agent-core 12.10.1 → 12.11.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.
- package/package.json +4 -4
- package/src/agent.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-agent-core",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.11.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",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"test": "bun test"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@oh-my-pi/pi-ai": "12.
|
|
28
|
-
"@oh-my-pi/pi-tui": "12.
|
|
29
|
-
"@oh-my-pi/pi-utils": "12.
|
|
27
|
+
"@oh-my-pi/pi-ai": "12.11.1",
|
|
28
|
+
"@oh-my-pi/pi-tui": "12.11.1",
|
|
29
|
+
"@oh-my-pi/pi-utils": "12.11.1"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|
|
32
32
|
"ai",
|
package/src/agent.ts
CHANGED
|
@@ -38,6 +38,14 @@ function defaultConvertToLlm(messages: AgentMessage[]): Message[] {
|
|
|
38
38
|
return messages.filter(m => m.role === "user" || m.role === "assistant" || m.role === "toolResult");
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export class AgentBusyError extends Error {
|
|
42
|
+
constructor(
|
|
43
|
+
message: string = "Agent is already processing. Use steer() or followUp() to queue messages, or wait for completion.",
|
|
44
|
+
) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "AgentBusyError";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
41
49
|
export interface AgentOptions {
|
|
42
50
|
initialState?: Partial<AgentState>;
|
|
43
51
|
|
|
@@ -491,9 +499,7 @@ export class Agent {
|
|
|
491
499
|
options?: AgentPromptOptions,
|
|
492
500
|
) {
|
|
493
501
|
if (this.#state.isStreaming) {
|
|
494
|
-
throw new
|
|
495
|
-
"Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.",
|
|
496
|
-
);
|
|
502
|
+
throw new AgentBusyError();
|
|
497
503
|
}
|
|
498
504
|
|
|
499
505
|
const model = this.#state.model;
|
|
@@ -537,7 +543,7 @@ export class Agent {
|
|
|
537
543
|
*/
|
|
538
544
|
async continue() {
|
|
539
545
|
if (this.#state.isStreaming) {
|
|
540
|
-
throw new
|
|
546
|
+
throw new AgentBusyError();
|
|
541
547
|
}
|
|
542
548
|
|
|
543
549
|
const messages = this.#state.messages;
|