@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 +24 -19
- package/commands.ts +2 -0
- package/package.json +1 -1
- package/tool-execute.ts +12 -1
- package/utils/agent-utils.ts +4 -6
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
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
|
-
|
|
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({
|
package/utils/agent-utils.ts
CHANGED
|
@@ -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:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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;
|