@piotr-oles/pi-subagents 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -92,10 +92,10 @@ Opens an interactive menu listing all loaded agent templates with their source (
92
92
  ## Development
93
93
 
94
94
  ```bash
95
- pnpm install
96
- pnpm test
97
- pnpm typecheck
98
- pnpm check
95
+ npm install
96
+ npm test
97
+ npm run typecheck
98
+ npm run check
99
99
  ```
100
100
 
101
101
  To test changes manually, pass the source entry point directly to pi:
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@piotr-oles/pi-subagents",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Pi Agent extension: spawn specialized subagents with isolated sessions",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/piotr-oles/pi-extensions.git",
7
+ "url": "git+https://github.com/piotr-oles/pi-extensions.git",
8
8
  "directory": "packages/pi-subagents"
9
9
  },
10
10
  "keywords": [
@@ -30,17 +30,17 @@
30
30
  "typecheck": "tsc --noEmit",
31
31
  "check": "biome ci src/",
32
32
  "fix": "biome check --write src/",
33
- "release": "semantic-release -e semantic-release-monorepo"
33
+ "release": "semantic-release -e semantic-release-monorepo -e ../../.releaserc.json"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@earendil-works/pi-agent-core": "*",
37
37
  "@earendil-works/pi-coding-agent": "*"
38
38
  },
39
39
  "devDependencies": {
40
- "@earendil-works/pi-agent-core": "^0.75.5",
41
- "@earendil-works/pi-ai": "^0.75.5",
42
- "@earendil-works/pi-coding-agent": "^0.75.5",
43
- "@earendil-works/pi-tui": "^0.75.5",
40
+ "@earendil-works/pi-agent-core": "0.80.10",
41
+ "@earendil-works/pi-ai": "0.80.10",
42
+ "@earendil-works/pi-coding-agent": "0.80.10",
43
+ "@earendil-works/pi-tui": "0.80.10",
44
44
  "@marcfargas/pi-test-harness": "^0.6.1",
45
45
  "strip-ansi": "^7.2.0",
46
46
  "typebox": "^1.1.38",
@@ -13,6 +13,7 @@ const THINKING_LEVEL_COLORS = {
13
13
  medium: "thinkingMedium",
14
14
  high: "thinkingHigh",
15
15
  xhigh: "thinkingXhigh",
16
+ max: "thinkingMax",
16
17
  } as const;
17
18
 
18
19
  export class SubagentTemplateDetailsComponent implements Component {
@@ -160,7 +160,10 @@ export class RunningSubagent {
160
160
  if (event.message.role === "assistant") {
161
161
  this.state.lastMessage = event.message;
162
162
  }
163
- if (this.config.maxTurns) {
163
+ if (
164
+ this.config.maxTurns &&
165
+ (event.message.role !== "assistant" || event.message.stopReason !== "error")
166
+ ) {
164
167
  if (
165
168
  !this.state.steered &&
166
169
  this.config.graceTurns > 0 &&
@@ -201,6 +204,13 @@ export class RunningSubagent {
201
204
  onDone(this.done({ status: "exceeded_limit", limit: this.state.exceededLimit }));
202
205
  } else if (this.state.aborted) {
203
206
  onDone(this.done({ status: "aborted" }));
207
+ } else if (this.state.lastMessage?.stopReason === "error") {
208
+ onDone(
209
+ this.done({
210
+ status: "error",
211
+ error: this.state.lastMessage.errorMessage ?? "Unknown provider error",
212
+ }),
213
+ );
204
214
  } else {
205
215
  onDone(
206
216
  this.done({
@@ -161,6 +161,7 @@ const THINKING_LEVELS: ReadonlySet<ThinkingLevel> = new Set([
161
161
  "medium",
162
162
  "high",
163
163
  "xhigh",
164
+ "max",
164
165
  ]);
165
166
 
166
167
  function isThinkingLevel(value: string): value is ThinkingLevel {
@@ -43,6 +43,11 @@ export class ScriptedSessionBuilder {
43
43
  return this;
44
44
  }
45
45
 
46
+ providerError(message: string): this {
47
+ this.completion = { kind: "provider-error", message };
48
+ return this;
49
+ }
50
+
46
51
  fail(message: string): this {
47
52
  this.completion = { kind: "error", message };
48
53
  return this;
@@ -18,6 +18,7 @@ export type Step = TurnStep | EventStep | SideEffectStep;
18
18
 
19
19
  export type Completion =
20
20
  | { readonly kind: "complete"; readonly text: string }
21
+ | { readonly kind: "provider-error"; readonly message: string }
21
22
  | { readonly kind: "error"; readonly message: string };
22
23
 
23
24
  /**
@@ -72,7 +73,18 @@ export class ScriptedSession {
72
73
  return;
73
74
  }
74
75
 
75
- if (this.completion.kind === "error") {
76
+ if (this.completion.kind === "provider-error") {
77
+ await this.handler?.({
78
+ type: "turn_end",
79
+ message: {
80
+ role: "assistant",
81
+ content: [],
82
+ stopReason: "error",
83
+ errorMessage: this.completion.message,
84
+ },
85
+ toolResults: [],
86
+ } as unknown as AgentSessionEvent);
87
+ } else if (this.completion.kind === "error") {
76
88
  throw new Error(this.completion.message);
77
89
  }
78
90
  }
@@ -51,6 +51,7 @@ const FG_COLORS: Record<ThemeColor, string> = {
51
51
  thinkingMedium: "",
52
52
  thinkingHigh: "",
53
53
  thinkingXhigh: "",
54
+ thinkingMax: "",
54
55
  bashMode: "",
55
56
  };
56
57
 
@@ -56,6 +56,10 @@ export class SubagentToolResultComponent implements Component {
56
56
  this.summary.invalidate();
57
57
  this.details.invalidate();
58
58
  }
59
+
60
+ dispose(): void {
61
+ this.summary.dispose();
62
+ }
59
63
  }
60
64
 
61
65
  class SubagentSummaryComponent implements Component {
@@ -84,6 +88,10 @@ class SubagentSummaryComponent implements Component {
84
88
  invalidate() {
85
89
  this.container.invalidate();
86
90
  }
91
+
92
+ dispose(): void {
93
+ this.icon.dispose();
94
+ }
87
95
  }
88
96
 
89
97
  class SubagentDetailsComponent implements Component {
@@ -311,6 +319,10 @@ class SubagentIconComponent implements Component {
311
319
 
312
320
  invalidate() {}
313
321
 
322
+ dispose(): void {
323
+ this.stopAnimation();
324
+ }
325
+
314
326
  private syncAnimation(): void {
315
327
  if (this.entry.status === "running") {
316
328
  this.startAnimation();
@@ -1,6 +1,6 @@
1
1
  import type { TextContent } from "@earendil-works/pi-ai";
2
2
  import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
- import type { Component } from "@earendil-works/pi-tui";
3
+ import { type Component, Text } from "@earendil-works/pi-tui";
4
4
  import type { DoneSubagent } from "../domain/instance/done-subagent.js";
5
5
  import type { SubagentInstancesManager } from "../domain/subagent-instances-manager.js";
6
6
  import type { SubagentTemplatesManager } from "../domain/subagent-templates-manager.js";
@@ -76,11 +76,18 @@ export function createSubagentTool(deps: SubagentToolDeps) {
76
76
  ctx.ui.setWorkingIndicator({ frames: [ctx.ui.theme.fg("dim", "●")] });
77
77
  ctx.ui.setWorkingMessage("Waiting for subagents");
78
78
 
79
- const done = await promise;
79
+ let done: DoneSubagent;
80
+ try {
81
+ done = await promise;
82
+ } finally {
83
+ if (!instanceManager.isRunning()) {
84
+ ctx.ui.setWorkingIndicator();
85
+ ctx.ui.setWorkingMessage();
86
+ }
87
+ }
80
88
 
81
- if (!instanceManager.isRunning()) {
82
- ctx.ui.setWorkingIndicator();
83
- ctx.ui.setWorkingMessage();
89
+ if (done.result.status === "error") {
90
+ throw new Error(done.result.error);
84
91
  }
85
92
 
86
93
  return {
@@ -102,6 +109,13 @@ export function createSubagentTool(deps: SubagentToolDeps) {
102
109
  },
103
110
  /** Custom rendering for tool result display */
104
111
  renderResult(result, _options, theme, context): Component {
112
+ if (context.isError) {
113
+ if (context.lastComponent instanceof SubagentToolResultComponent) {
114
+ context.lastComponent.dispose();
115
+ }
116
+ const error = result.content[0];
117
+ return new Text(error.type === "text" ? error.text : "", 0, 0);
118
+ }
105
119
  if (!(context.lastComponent instanceof SubagentToolResultComponent)) {
106
120
  return new SubagentToolResultComponent(
107
121
  result.details,