@arhen/pi-core-subagent 1.1.2 → 1.1.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +7 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arhen/pi-core-subagent",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "pi extension: fast in-process subagents with single/parallel/chain, background runs, intercom and agent-to-agent mailbox. Leader defines agents inline.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -59,6 +59,7 @@ interface TaskInput {
59
59
  tools?: string[];
60
60
  model?: string;
61
61
  thinking?: string;
62
+ cwd?: string;
62
63
  maxRuntimeMs?: number;
63
64
  }
64
65
 
@@ -814,7 +815,7 @@ class SubagentManager {
814
815
 
815
816
  const mode: RunMode = hasChain ? "chain" : hasTasks ? "parallel" : "single";
816
817
  const inputs: TaskInput[] = hasSingle
817
- ? [{ agent: params.agent as string, task: params.task as string, prompt: params.prompt, write: params.write, model: params.model, thinking: params.thinking, tools: params.tools, maxRuntimeMs: params.maxRuntimeMs }]
818
+ ? [{ agent: params.agent as string, task: params.task as string, prompt: params.prompt, write: params.write, model: params.model, thinking: params.thinking, cwd: params.cwd, tools: params.tools, maxRuntimeMs: params.maxRuntimeMs }]
818
819
  : hasTasks
819
820
  ? params.tasks!
820
821
  : params.chain!;
@@ -834,7 +835,7 @@ class SubagentManager {
834
835
  runId: "",
835
836
  agent: input.agent,
836
837
  task: input.task,
837
- cwd: ctx.cwd,
838
+ cwd: input.cwd ?? ctx.cwd,
838
839
  status: "queued" as TaskStatus,
839
840
  model: input.model,
840
841
  thinking: input.thinking,
@@ -1013,6 +1014,7 @@ const TaskItem = Type.Object({
1013
1014
  write: Type.Optional(Type.Boolean({ description: "true = write toolset (read, bash, edit, write); default false = read-only (read, grep, find, ls)" })),
1014
1015
  model: Type.Optional(Type.String({ description: "Model override (provider/model-id)" })),
1015
1016
  thinking: Type.Optional(StringEnum(THINKING_LEVELS, { description: "Thinking level override" })),
1017
+ cwd: Type.Optional(Type.String({ description: "Working directory for this task. Default: current project." })),
1016
1018
  tools: Type.Optional(Type.Array(Type.String(), { description: "Explicit tool allowlist (overrides the toolset)" })),
1017
1019
  maxRuntimeMs: Type.Optional(Type.Number({ description: "Per-task timeout (ms)" })),
1018
1020
  });
@@ -1026,6 +1028,7 @@ type SubagentParamsShape = {
1026
1028
  chain?: TaskInput[];
1027
1029
  model?: string;
1028
1030
  thinking?: string;
1031
+ cwd?: string;
1029
1032
  tools?: string[];
1030
1033
  concurrency?: number;
1031
1034
  maxRuntimeMs?: number;
@@ -1043,6 +1046,7 @@ const SubagentParams = Type.Object({
1043
1046
  chain: Type.Optional(Type.Array(TaskItem, { description: "Sequential tasks; {previous} = prior output" })),
1044
1047
  model: Type.Optional(Type.String({ description: "Model override (single mode)" })),
1045
1048
  thinking: Type.Optional(StringEnum(THINKING_LEVELS, { description: "Thinking level override (single mode)" })),
1049
+ cwd: Type.Optional(Type.String({ description: "Working directory (single mode). Default: current project." })),
1046
1050
  concurrency: Type.Optional(Type.Number({ description: `Parallel concurrency (default ${DEFAULT_CONCURRENCY}, max ${MAX_CONCURRENCY})` })),
1047
1051
  maxRuntimeMs: Type.Optional(Type.Number({ description: `Per-task timeout, ms (default ${DEFAULT_RUNTIME_MS / 60000} min)` })),
1048
1052
  background: Type.Optional(Type.Boolean({ description: "Fire-and-forget: return immediately with a runId; you'll be notified on completion" })),
@@ -1117,7 +1121,7 @@ export default function (pi: ExtensionAPI) {
1117
1121
  "Use allowIntercom:true only when a child may need to ask you something; keep children autonomous otherwise.",
1118
1122
  ],
1119
1123
  parameters: SubagentParams,
1120
- executionMode: "sequential",
1124
+ executionMode: "parallel", // sibling subagent calls run concurrently, not serialized
1121
1125
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
1122
1126
  const typed = params as unknown as SubagentParamsShape;
1123
1127
  if (typed.background) {
@@ -1140,7 +1144,6 @@ export default function (pi: ExtensionAPI) {
1140
1144
  if (args.model) parts.push(args.model);
1141
1145
  if (args.thinking) parts.push(args.thinking);
1142
1146
  if (args.write) parts.push("write");
1143
- else if (writeCount === 0) parts.push("read-only");
1144
1147
  if (writeCount > 0) parts.push(`${writeCount} write`);
1145
1148
  if (args.concurrency) parts.push(`c${args.concurrency}`);
1146
1149
  if (args.maxRuntimeMs) parts.push(`${Math.round(args.maxRuntimeMs / 60000)}m`);