@ryan_nookpi/pi-extension-subagent 0.5.0 → 0.5.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/agents.ts CHANGED
@@ -140,25 +140,30 @@ function loadAgentsFromDir(dir: string, source: "user" | "project", options: Loa
140
140
  continue;
141
141
  }
142
142
 
143
- const { frontmatter, body } = parseFrontmatter<Record<string, string>>(content);
144
- if (!frontmatter.name || !frontmatter.description) continue;
145
-
146
- const tools = normalizeTools(frontmatter.tools, format);
147
- const model = normalizeModel(frontmatter.model, format);
148
- const thinking = normalizeThinkingLevel(frontmatter.thinking);
149
- const runtime: AgentRuntime = frontmatter.runtime === "claude" ? "claude" : "pi";
150
-
151
- agents.push({
152
- name: frontmatter.name,
153
- description: frontmatter.description,
154
- tools,
155
- model,
156
- thinking,
157
- systemPrompt: attachCommonSubagentRule(body, runtime),
158
- source,
159
- filePath,
160
- runtime,
161
- });
143
+ try {
144
+ const { frontmatter, body } = parseFrontmatter<Record<string, unknown>>(content);
145
+ if (typeof frontmatter.name !== "string" || typeof frontmatter.description !== "string") continue;
146
+ if (!frontmatter.name || !frontmatter.description) continue;
147
+
148
+ const tools = normalizeTools(frontmatter.tools, format);
149
+ const model = normalizeModel(typeof frontmatter.model === "string" ? frontmatter.model : undefined, format);
150
+ const thinking = normalizeThinkingLevel(
151
+ typeof frontmatter.thinking === "string" ? frontmatter.thinking : undefined,
152
+ );
153
+ const runtime: AgentRuntime = frontmatter.runtime === "claude" ? "claude" : "pi";
154
+
155
+ agents.push({
156
+ name: frontmatter.name,
157
+ description: frontmatter.description,
158
+ tools,
159
+ model,
160
+ thinking,
161
+ systemPrompt: attachCommonSubagentRule(body, runtime),
162
+ source,
163
+ filePath,
164
+ runtime,
165
+ });
166
+ } catch {}
162
167
  }
163
168
 
164
169
  return agents;
package/commands.ts CHANGED
@@ -1250,6 +1250,8 @@ export function registerAll(pi: ExtensionAPI, store: SubagentStore): SubagentReg
1250
1250
  runState.model = undefined;
1251
1251
  runState.retryCount = 0;
1252
1252
  runState.lastRetryReason = undefined;
1253
+ runState.errorClass = undefined;
1254
+ runState.autoAbortReason = undefined;
1253
1255
  runState.removed = false;
1254
1256
  runState.deliveryMode = deliveryMode;
1255
1257
  runState.turnCount = Math.max(DEFAULT_TURN_COUNT, runState.turnCount || DEFAULT_TURN_COUNT) + 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryan_nookpi/pi-extension-subagent",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Asynchronous subagent delegation for pi with run, batch, chain, and continuation workflows.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/tool-execute.ts CHANGED
@@ -1254,6 +1254,10 @@ export function createSubagentToolExecute(pi: ExtensionAPI, store: SubagentStore
1254
1254
  runState.lastOutput = "";
1255
1255
  runState.usage = undefined;
1256
1256
  runState.model = undefined;
1257
+ runState.retryCount = 0;
1258
+ runState.lastRetryReason = undefined;
1259
+ runState.errorClass = undefined;
1260
+ runState.autoAbortReason = undefined;
1257
1261
  runState.removed = false;
1258
1262
  runState.turnCount = Math.max(DEFAULT_TURN_COUNT, runState.turnCount || DEFAULT_TURN_COUNT) + 1;
1259
1263
  runState.contextMode = runState.contextMode ?? (config.inheritMainContext ? "main" : "sub");
@@ -1979,7 +1983,14 @@ export function createSubagentToolExecute(pi: ExtensionAPI, store: SubagentStore
1979
1983
  pipeline.stepRunIds.push(runState.id);
1980
1984
  chainLaunches.push(toLaunchSummary(runState, "chain"));
1981
1985
 
1982
- const finalized = await launchRunInBackground(runState, taskForAgent);
1986
+ let finalized: FinalizedRun;
1987
+ try {
1988
+ finalized = await launchRunInBackground(runState, taskForAgent);
1989
+ } catch (error: unknown) {
1990
+ finalized = finalizeRunError(runState, error);
1991
+ } finally {
1992
+ clearRunAbortState(runState);
1993
+ }
1983
1994
  if (runState.removed) {
1984
1995
  terminalStatus = finalized.isError ? "error" : "stopped";
1985
1996
  pipeline.stepResults.push({
@@ -88,12 +88,10 @@ export const CLAUDE_MODEL_ALIAS_MAP: Record<string, string> = {
88
88
  * Normalize a comma-separated tool list according to the given format.
89
89
  * For "claude" format, maps Claude tool names to pi equivalents.
90
90
  */
91
- export function normalizeTools(rawTools: string | undefined, format: "pi" | "claude"): string[] | undefined {
92
- if (!rawTools) return undefined;
93
-
94
- const parsed = rawTools
95
- .split(",")
96
- .map((t) => t.trim())
91
+ export function normalizeTools(rawTools: unknown, format: "pi" | "claude"): string[] | undefined {
92
+ const parsed = (Array.isArray(rawTools) ? rawTools : typeof rawTools === "string" ? rawTools.split(",") : [])
93
+ .filter((tool): tool is string => typeof tool === "string")
94
+ .map((tool) => tool.trim())
97
95
  .filter(Boolean);
98
96
 
99
97
  if (parsed.length === 0) return undefined;