@pi-archimedes/subagent 1.7.0 → 1.8.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.
- package/package.json +2 -2
- package/src/index.ts +5 -3
- package/src/spawn.ts +20 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-archimedes/subagent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "./src/index.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@pi-archimedes/core": "1.
|
|
14
|
+
"@pi-archimedes/core": "1.8.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@earendil-works/pi-ai": ">=0.1.0",
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Text, TUI } from "@earendil-works/pi-tui";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
|
-
|
|
4
|
+
// execute.js + agent-manager.js lazy-loaded below to keep subagent tool registration fast
|
|
5
5
|
import { renderSubagentResult } from "./render.js";
|
|
6
6
|
import { discoverAgents, discoverAgentsAll, findAgent } from "./agents.js";
|
|
7
|
-
import { createAgentManager } from "./agent-manager.js";
|
|
8
7
|
import type {
|
|
9
8
|
SubagentDetails,
|
|
10
9
|
SubagentProgress,
|
|
@@ -73,7 +72,8 @@ export function registerSubagent(pi: ExtensionAPI): void {
|
|
|
73
72
|
onUpdate: ((update: SubagentToolResult) => void) | undefined,
|
|
74
73
|
ctx: ExtensionContext,
|
|
75
74
|
): Promise<SubagentToolResult> {
|
|
76
|
-
//
|
|
75
|
+
// Lazy-load executor (spawn/stream/cost) — only when tool is actually invoked
|
|
76
|
+
const { executeSubagent, executeParallel } = await import("./execute.js");
|
|
77
77
|
const agents = discoverAgents(ctx.cwd);
|
|
78
78
|
|
|
79
79
|
// Parallel mode
|
|
@@ -268,6 +268,8 @@ export function registerAgentsCommand(pi: ExtensionAPI): void {
|
|
|
268
268
|
pi.registerCommand("agents", {
|
|
269
269
|
description: "Open the Agents Manager",
|
|
270
270
|
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
271
|
+
// Lazy-load: 1689-line TUI component only needed when /agents is invoked
|
|
272
|
+
const { createAgentManager } = await import("./agent-manager.js");
|
|
271
273
|
const { global: globalAgents, user, project, globalDir, userDir, projectDir } = discoverAgentsAll(ctx.cwd);
|
|
272
274
|
|
|
273
275
|
const availableModels = ctx.modelRegistry.getAvailable().map((m) => ({
|
package/src/spawn.ts
CHANGED
|
@@ -208,14 +208,27 @@ export function spawnSubagent(options: SpawnOptions): ChildProcess {
|
|
|
208
208
|
// The task is the final positional argument
|
|
209
209
|
args.push(options.task);
|
|
210
210
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
// On Windows, spawn `node <resolved-js-path>` instead of the raw binary.
|
|
212
|
+
// The resolved path is a .js file which cannot be spawned directly on Windows.
|
|
213
|
+
// Using process.execPath avoids shell: true (no escaping risks, kill() works).
|
|
214
|
+
const isWindowsResolved = process.platform === "win32" && piBinary !== "pi";
|
|
215
|
+
|
|
216
|
+
const child = spawn(
|
|
217
|
+
isWindowsResolved ? process.execPath : piBinary,
|
|
218
|
+
[
|
|
219
|
+
...(isWindowsResolved ? [piBinary] : []),
|
|
220
|
+
...args,
|
|
221
|
+
],
|
|
222
|
+
{
|
|
223
|
+
cwd: options.cwd || process.cwd(),
|
|
224
|
+
env: {
|
|
225
|
+
...process.env,
|
|
226
|
+
PI_SUBAGENT_SOCKET: socketPath,
|
|
227
|
+
},
|
|
228
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
229
|
+
windowsHide: true,
|
|
216
230
|
},
|
|
217
|
-
|
|
218
|
-
});
|
|
231
|
+
);
|
|
219
232
|
|
|
220
233
|
// Clean up socket server when child exits
|
|
221
234
|
child.on("exit", cleanupSocket);
|