pi-subagent-manager 1.3.1 → 1.4.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 +1 -1
- package/src/orch/extensions.ts +12 -0
- package/src/orch/manager.ts +7 -0
- package/src/orch/prompt.ts +7 -0
- package/src/orch/runtime.ts +5 -1
- package/src/types.ts +2 -0
- package/src/ui/settings-ui.ts +2 -3
package/package.json
CHANGED
package/src/orch/extensions.ts
CHANGED
|
@@ -5,6 +5,18 @@ import { DefaultPackageManager, SettingsManager } from "@earendil-works/pi-codin
|
|
|
5
5
|
|
|
6
6
|
const MANAGER_ENTRY = fileURLToPath(new URL("../index.ts", import.meta.url));
|
|
7
7
|
|
|
8
|
+
/** Installed extensions use their npm package name, not a generic entry-point filename. */
|
|
9
|
+
export function extensionDisplayName(file: string): string {
|
|
10
|
+
const packagePath = file.split(`${path.sep}node_modules${path.sep}`).slice(1).at(-1);
|
|
11
|
+
if (packagePath) {
|
|
12
|
+
const [name, scopedName] = packagePath.split(path.sep);
|
|
13
|
+
return name.startsWith("@") ? `${name}/${scopedName}` : name;
|
|
14
|
+
}
|
|
15
|
+
return /^index\.[cm]?[jt]s$/.test(path.basename(file))
|
|
16
|
+
? path.basename(path.dirname(file))
|
|
17
|
+
: path.basename(file);
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
async function canonical(file: string): Promise<string> {
|
|
9
21
|
return realpath(file).catch(() => path.resolve(file));
|
|
10
22
|
}
|
package/src/orch/manager.ts
CHANGED
|
@@ -719,8 +719,15 @@ export class ThreadManager {
|
|
|
719
719
|
if (!parentRecord.driver) await this.ensureDriver(parentRecord, readOnly);
|
|
720
720
|
}
|
|
721
721
|
const parentSessionFile = this.lexicalParentSessionFile(record);
|
|
722
|
+
const segments = record.view.path.slice(1).split("/");
|
|
723
|
+
const level = segments.length + (segments[0] === "root" ? 0 : 1);
|
|
724
|
+
const canSpawnChildren =
|
|
725
|
+
this.options.maxLevels === undefined && this.options.maxDepth !== undefined
|
|
726
|
+
? segments.length - 1 < this.options.maxDepth
|
|
727
|
+
: level < (this.options.maxLevels ?? DEFAULT_MANAGER_SETTINGS.maxLevels);
|
|
722
728
|
const options: DriverOptions = {
|
|
723
729
|
path: record.view.path,
|
|
730
|
+
canSpawnChildren,
|
|
724
731
|
type: record.definition,
|
|
725
732
|
inherited: record.inherited,
|
|
726
733
|
tools: this.options.toolsFor(record.view.path),
|
package/src/orch/prompt.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ManagerSettings } from "../prefs/settings.ts";
|
|
2
2
|
import { checklistGuidance } from "./checklist-integration.ts";
|
|
3
3
|
|
|
4
|
+
export function delegationGuidance(canSpawnChildren: boolean): string {
|
|
5
|
+
return canSpawnChildren
|
|
6
|
+
? "You may spawn subagents of your own if useful, subject to your tools, assigned scope, and shared concurrency limits."
|
|
7
|
+
: "You are at the maximum agent depth and cannot spawn any more subagents. Complete your assigned work yourself.";
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
/** Root-only guidance: child SDK sessions use their own worker prompt. */
|
|
5
11
|
export function subagentPrompt(
|
|
6
12
|
settings: ManagerSettings,
|
|
@@ -25,6 +31,7 @@ export function subagentPrompt(
|
|
|
25
31
|
'Use agent_status to inspect and agent_output for full results. Completion, failure or stop of a wait:false agent is delivered to you as a message event that starts a new turn when you are idle (with Final Recap on, once after all outstanding async agents have finished). Pass timeoutMs to agent_spawn to get a status event if a child runs long; the child is not killed. Valid range 30000–300000 ms; omit for no timeout. To extend a running background agent\'s reporting timer, before or after a timeout event, call agent_steer({path: "/root/task", timeoutMs: 120000}) with message omitted entirely. This resets the timer from now (replacing any pending timer), without sending input, interrupting or resuming the agent; it requires the agent to still be running. After re-arming, end your turn to remain available while it works. For other timeout responses, follow the waiting policy above, send steering input or stop the agent.',
|
|
26
32
|
"Use agent_steer to send input or resume retained sessions. Paused agents have no final answer; completed agents hand back results. Both retain their session.",
|
|
27
33
|
`Maximum depth: ${settings.maxLevels} levels including L1. Shared concurrency: ${settings.maxConcurrent} active threads; waiting parents count.`,
|
|
34
|
+
delegationGuidance(settings.maxLevels > 1),
|
|
28
35
|
...(settings.checklistIntegration && checklistEligible
|
|
29
36
|
? [checklistGuidance(settings.subagentMode)]
|
|
30
37
|
: []),
|
package/src/orch/runtime.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from "./mailbox.ts";
|
|
29
29
|
import { selectTools } from "../prefs/config.ts";
|
|
30
30
|
import { TranscriptChannel } from "./transcript.ts";
|
|
31
|
+
import { delegationGuidance } from "./prompt.ts";
|
|
31
32
|
import { discoverSubagentExtensions, selectSubagentExtensions } from "./extensions.ts";
|
|
32
33
|
import type { InheritedToolSource } from "./inherited-tools.ts";
|
|
33
34
|
import type {
|
|
@@ -545,7 +546,10 @@ export function createDriverFactory(
|
|
|
545
546
|
? `Your lexical parent is ${options.parentPath}; inherited conversation comes only from that parent.`
|
|
546
547
|
: "You are an independent root thread with no inherited history.",
|
|
547
548
|
"When finished, give your final answer normally so it can be handed back. To retain unfinished work without a final answer, call agent_pause (if available), then stop; resume only when instructed.",
|
|
548
|
-
|
|
549
|
+
delegationGuidance(options.canSpawnChildren !== false),
|
|
550
|
+
...(options.canSpawnChildren !== false &&
|
|
551
|
+
allowed.has("agent_spawn") &&
|
|
552
|
+
allowed.has("agent_wait")
|
|
549
553
|
? [
|
|
550
554
|
"Name child paths with concise task-based kebab-case slugs (e.g. /root/controller-security-research), independent of type.",
|
|
551
555
|
"For independent parallel work, launch all siblings with agent_spawn wait:false before calling agent_wait. Children share the main conversation's depth and concurrency limits; waiting parents count as active. Do not delegate work beyond your assigned scope.",
|
package/src/types.ts
CHANGED
|
@@ -154,6 +154,8 @@ export interface AgentDriver {
|
|
|
154
154
|
}
|
|
155
155
|
export interface DriverOptions {
|
|
156
156
|
path: string;
|
|
157
|
+
/** Whether the configured depth limit permits another level of children. */
|
|
158
|
+
canSpawnChildren?: boolean;
|
|
157
159
|
type: AgentType;
|
|
158
160
|
inherited: AgentMessage[];
|
|
159
161
|
tools: ToolDefinition[];
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExtensionCommandContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
3
|
-
import { discoverSubagentExtensions } from "../orch/extensions.ts";
|
|
2
|
+
import { discoverSubagentExtensions, extensionDisplayName } from "../orch/extensions.ts";
|
|
4
3
|
import type { ConfigStore } from "../prefs/config.ts";
|
|
5
4
|
import {
|
|
6
5
|
canOpenDialog,
|
|
@@ -226,7 +225,7 @@ async function configureSubagentExtensions(
|
|
|
226
225
|
[
|
|
227
226
|
...files.map((file) => ({
|
|
228
227
|
id: file,
|
|
229
|
-
label: `${selected.has(file) ? "[x]" : "[ ]"} ${
|
|
228
|
+
label: `${selected.has(file) ? "[x]" : "[ ]"} ${extensionDisplayName(file)}`,
|
|
230
229
|
value: available.includes(file) ? (selected.has(file) ? "On" : "Off") : "Unavailable",
|
|
231
230
|
help: `${file}\n${available.includes(file) ? "Reload this extension in newly opened subagent sessions." : "Not currently discoverable/trusted; will not load. Toggle Off to remove the saved selection."}\nSpace/Enter toggles. Changes are saved only with outer Save and apply.`,
|
|
232
231
|
})),
|