@zachwill/pi-orchestrate 0.3.0 → 0.4.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pi Orchestrate
2
2
 
3
- [`@zachwill/pi-orchestrate`](https://www.npmjs.com/package/@zachwill/pi-orchestrate) adds concurrent worker orchestration to [Pi](https://pi.dev). It helps a parent agent delegate bounded work, message independent workers concurrently, and synthesize each response as it arrives.
3
+ [`@zachwill/pi-orchestrate`](https://www.npmjs.com/package/@zachwill/pi-orchestrate) adds concurrent worker orchestration to [Pi](https://pi.dev). A parent agent can delegate bounded work to isolated child sessions, run independent tasks concurrently, and synthesize the results.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,60 +8,86 @@
8
8
  pi install npm:@zachwill/pi-orchestrate
9
9
  ```
10
10
 
11
- Pi packages execute with your system permissions. Review the package and worker definitions before trusting them.
11
+ Pi packages run with your system permissions. Review this package and every worker definition you trust.
12
12
 
13
- ## Public tools
13
+ ## Tools
14
14
 
15
15
  Pi Orchestrate adds exactly five tools:
16
16
 
17
- - `orchestrate` dispatches one task with `orchestrate({ worker, title, instructions })`. Send independent tasks as sibling `orchestrate` calls in the same assistant message.
18
- - `orchestration_status` inspects the trusted catalog, catalog diagnostics, runs, and worker states without exposing full task instructions.
19
- - `worker_send` sends follow-up instructions to an owned reusable worker in the `ready` state.
20
- - `worker_abort` stops owned active work that is no longer needed.
21
- - `worker_close` closes an owned reusable worker in the `ready` state.
17
+ | Tool | Call | Purpose |
18
+ | --- | --- | --- |
19
+ | `orchestrate` | `orchestrate({ worker, title, instructions })` | Start one worker task |
20
+ | `orchestration_status` | `orchestration_status({})` | Inspect the trusted catalog, diagnostics, runs, and worker states |
21
+ | `worker_send` | `worker_send({ worker_id, instructions })` | Send a follow-up to a ready reusable worker |
22
+ | `worker_abort` | `worker_abort({ worker_ids })` or `worker_abort({ all: true })` | Stop active owned work |
23
+ | `worker_close` | `worker_close({ worker_id })` | Close a ready reusable worker |
22
24
 
23
- Each `orchestrate` call first performs atomic input, catalog, and model preflight before its worker starts. Sibling calls are admitted independently: one rejected call does not prevent valid siblings from starting. After acceptance, a resource startup failure becomes that worker's `failed` result and does not roll back or stop sibling calls.
25
+ `title` is a label. `instructions` is the complete worker brief. Collapsed tool calls preview those instructions; expanded calls show them in full.
24
26
 
25
- Pi executes sibling tool calls concurrently, so independent `orchestrate` calls start concurrently without an extension-level group limit or hidden throttle. Exact unchanged worker instructions remain visible in each tool call: collapsed calls preview the message, and expanded calls show the full brief. Titles are labels, never replacements for instructions.
27
+ ## Dispatch
26
28
 
27
- A sole `orchestrate` call or a pure group of sibling `orchestrate` calls runs asynchronously. Pi accepts a pure group concurrently and yields the parent turn. Mixing `orchestrate` with another tool makes it inline and blocking. `worker_send` is asynchronous only as the sole tool call in its assistant message. Inline work receives the parent turn's cancellation signal. Accepted async work does not retain that signal and continues independently.
29
+ Each `orchestrate` call validates its input, worker definition, and model before allocating IDs or starting a session. Calls are admitted independently: a rejected sibling does not block valid siblings. After admission, a startup or prompt failure settles only that worker as `failed`.
28
30
 
29
- Async worker responses enter the transcript individually as workers finish. An ungrouped response starts the parent's synthesis turn. Responses from sibling calls share one final synthesis turn. The bottom widget is ephemeral and shows active work only; completed, failed, aborted, and reusable ready workers disappear immediately. An inline call shows its single current response in the live tool output while it blocks.
31
+ Pi executes sibling tool calls concurrently, with no extension-level group limit or hidden throttle. Send every known independent task as sibling `orchestrate` calls in one assistant message.
30
32
 
31
- `orchestration_status` is for diagnostics and recovery, never a normal completion mechanism. Do not poll it for completion. If the owning session becomes inactive, its workers continue and completed results remain queued. Those results become available only when that exact owning session resumes; they are never delivered to another session.
33
+ Execution mode depends on the complete tool-call group:
32
34
 
33
- Each run owns exactly one worker generation. Worker IDs identify live worker sessions. A reusable worker keeps the same worker ID across `worker_send` follow-ups, with each follow-up result belonging to a new run. One-shot workers finish as `completed`. Reusable workers deliver as `ready`, remain available for follow-up, and wait for `worker_send` or `worker_close`. Use `worker_abort` only for active work by `worker_ids` or `all`, not to close a ready worker.
35
+ - One `orchestrate` call is asynchronous.
36
+ - A pure group of sibling `orchestrate` calls is asynchronous and concurrent.
37
+ - Mixing `orchestrate` with any other tool makes the orchestration calls inline and blocking.
38
+ - `worker_send` is asynchronous only when it is the sole tool call in the message.
34
39
 
35
- ## Parent orchestration contract
40
+ Inline work follows the parent turn's cancellation signal. Accepted asynchronous work detaches from that signal and continues independently.
36
41
 
37
- Pi Orchestrate automatically injects the authoritative orchestration contract and trusted worker catalog into the parent system prompt. In summary, the parent owns the task end to end:
42
+ ## Results and ownership
38
43
 
39
- 1. Keep trivial or tightly coupled work in the parent session.
40
- 2. Give every delegated task a full brief: objective, paths and scope, forbidden actions, context, constraints, observable success, checks, and expected output.
41
- 3. Dispatch every known independent task with a sibling `orchestrate` call in the same assistant message.
42
- 4. Keep an async `orchestrate` call or pure sibling group separate from other tools, then yield after acceptance. Make `worker_send` the sole tool call when it should run asynchronously.
43
- 5. Review delivered evidence and changes, resolve conflicts, integrate deliberately, and run the relevant verification.
44
- 6. Deliver the final answer from the parent session.
44
+ Asynchronous worker results enter the transcript individually. An ungrouped result starts a parent synthesis turn. Results from a sibling orchestration group share one final synthesis turn after every admitted member settles.
45
+
46
+ All state and delivery are owner-scoped. If an owning session is busy or inactive, completed results queue until that exact session is active and idle again. They are never delivered to another session.
47
+
48
+ `orchestration_status` is for diagnostics and recovery, not completion polling. It exposes bounded owner-scoped state without full task instructions or worker prompts.
49
+
50
+ The bottom widget shows active work only. Completed, failed, aborted, and reusable ready workers disappear immediately. Inline work shows its current response in the live tool output while it blocks.
51
+
52
+ ## Lifecycle
53
+
54
+ A run represents one worker generation. A worker ID identifies the live worker session.
45
55
 
46
- Workers provide evidence or bounded changes. They do not replace parent judgment.
56
+ - A **one-shot** worker succeeds as `completed` and terminates.
57
+ - A **reusable** worker succeeds as `ready` and keeps the same worker ID.
58
+ - `worker_send` starts a new run on that ready reusable worker.
59
+ - `worker_close` closes a ready reusable worker.
60
+ - `worker_abort` stops active work only; `{ all: true }` does not close ready workers.
61
+
62
+ Workers, runs, and queued delivery survive extension reloads and session switches within the same Pi process. Reusable workers do not survive process exit, so close them when continuity is no longer needed.
63
+
64
+ ## Parent contract
65
+
66
+ Pi Orchestrate injects the authoritative orchestration contract and trusted catalog into the parent system prompt. The parent remains responsible for the task end to end:
67
+
68
+ 1. Keep trivial or tightly coupled work in the parent session.
69
+ 2. Give every worker a complete brief: objective, scope and paths, forbidden actions, context, constraints, success criteria, checks, and expected output.
70
+ 3. Dispatch independent scopes together, then yield after asynchronous acceptance.
71
+ 4. Review evidence and changes, resolve conflicts, integrate deliberately, and verify the result.
72
+ 5. Produce the final answer from the parent session.
47
73
 
48
- ## Trusted worker catalog
74
+ Workers provide bounded evidence or changes. They do not replace parent judgment.
49
75
 
50
- Definitions are loaded by name with this precedence:
76
+ ## Worker catalog
51
77
 
52
- 1. Package workers in [`examples/workers/`](examples/workers/) are active fallbacks automatically.
53
- 2. User definitions in `~/.pi/agent/pi-orchestrate/workers/*.md` override package fallbacks by name.
54
- 3. Project definitions in `<project>/.pi/pi-orchestrate/workers/*.md` override user and package definitions by name, but only after Pi trusts the project.
78
+ Definitions are loaded by name in this precedence order, from lowest to highest:
55
79
 
56
- An untrusted project contributes no worker definitions. Review project definitions as part of Pi's normal project-trust flow before enabling them.
80
+ 1. Package fallbacks in [`examples/workers/`](examples/workers/)
81
+ 2. User definitions in `~/.pi/agent/pi-orchestrate/workers/*.md`
82
+ 3. Project definitions in `<project>/.pi/pi-orchestrate/workers/*.md`, only after Pi trusts the project
57
83
 
58
- All three package fallbacks intentionally omit `model`, so they portably inherit the parent model active at dispatch. User and trusted project overrides are the model-specialization points: add `model` to an override only when that worker needs a specific provider/model.
84
+ A higher-precedence definition replaces a lower one with the same `name`. Pi performs no project-worker discovery for an untrusted project.
59
85
 
60
- To customize a fallback, create a Markdown definition manually at the user or project path with the same filename and `name`. The linked package fallbacks are templates. This instruction does not assume your shell is inside a source checkout or that an npm-installed package has a particular current working directory.
86
+ The package includes `scout`, `investigator`, `web`, and `worker` fallbacks. `scout`, `investigator`, and `worker` omit `model`, so they inherit the parent's active model at dispatch. `web` uses an installed, authenticated Codex CLI for public-web research and pins its Pi session and searches to `gpt-5.6-sol`. To customize one, copy its definition to the user or project directory and keep the same filename and `name`. Add an explicit model only when that worker needs one.
61
87
 
62
88
  ## Worker definitions
63
89
 
64
- A worker is a strict Markdown system prompt. Its basename must equal its `name`:
90
+ A worker is a regular Markdown file whose basename matches its `name`:
65
91
 
66
92
  ```md
67
93
  ---
@@ -71,29 +97,32 @@ tools: read, grep, find, ls, bash
71
97
  lifecycle: reusable
72
98
  ---
73
99
 
74
- You are a review worker. Inspect only the assigned scope and return concise findings with file paths.
100
+ Inspect the assigned scope and return concise findings with file paths.
75
101
  ```
76
102
 
77
- Frontmatter supports these fields:
103
+ | Field | Rule |
104
+ | --- | --- |
105
+ | `name` | Required; must match the filename |
106
+ | `description` | Required; used by the parent to choose a worker |
107
+ | `tools` | Required, nonempty list using `read`, `bash`, `edit`, `write`, `grep`, `find`, or `ls` |
108
+ | `lifecycle` | Required; exactly `one-shot` or `reusable` |
109
+ | `model` | Optional `provider/model`; omitted inherits the parent model |
110
+ | `thinking` | Optional Pi thinking level |
111
+ | `skills` | Optional; omitted uses normal discovery, a list is an exact allowlist, and `[]` disables skills |
112
+ | `compaction` | Optional worker compaction settings |
78
113
 
79
- - `name` and `description` are required.
80
- - `tools` and `lifecycle` are required. Grant the smallest useful tool set.
81
- - `model` is optional. When omitted, the worker inherits the parent model active when dispatched.
82
- - `thinking`, `skills`, and `compaction` are optional.
83
- - Omitted `skills` uses Pi's normal discovered skills. A nonempty `skills` list is an exact name allowlist, and `skills: []` disables skills.
84
- - `lifecycle` must be exactly `one-shot` or `reusable`.
85
- - The Markdown body must be nonempty.
114
+ The Markdown body is the worker system prompt and must be nonempty. Unknown fields, invalid values, symlinks, and filename/name mismatches invalidate a definition.
86
115
 
87
- Unknown fields, invalid values, filename/name mismatches, and empty bodies invalidate a definition. A read-only prompt is not enforcement when its tools can write.
116
+ Grant the smallest useful tool set. A read-only prompt is not enforcement when the worker has tools that can write.
88
117
 
89
- ## Lifecycle and process limits
118
+ ## Trust and isolation
90
119
 
91
- Use one-shot workers for bounded investigation, review, and implementation. Use reusable workers only when follow-up continuity matters. Reusable workers remain live in memory while the Pi process is running; they do not survive process exit. Close ready reusable workers when the conversation is complete.
120
+ Workers receive fresh durable Pi session lineage without the parent's conversation. They still run in the parent process and are not security sandboxes: they share your filesystem and environment permissions.
92
121
 
93
- ## Isolation, trust, and writes
122
+ Workers use normal global Pi settings, authentication, packages, extensions, skills, and context. A trusted project may also contribute project-scoped definitions, settings, extensions, skills, and context. An untrusted project contributes none of those project-scoped resources; global resources remain available.
94
123
 
95
- Worker sessions are isolated from the parent's conversational context, but they run in-process and are not sandboxes. They share the parent process's filesystem and environment permissions. Treat worker prompts, optional skills, models, and tool grants as trusted code.
124
+ Other configured extensions, including provider integrations such as `@benvargas/pi-claude-code-use`, load normally in worker sessions. Pi Orchestrate excludes itself, so workers remain direct Pi children. The injected boundary forbids recursive Pi Orchestrate delegation and descendant Pi worker sessions.
96
125
 
97
- Workers use regular persisted Pi global settings, authentication, packages, extensions, skills, and context. Trusted projects also contribute their project settings and resources; untrusted projects do not. Extensions are active in print mode for the complete worker lifecycle, including resource discovery and provider request hooks. Pi Orchestrate excludes its own package before child extension factories execute, so workers remain direct children while other configured extensions—including provider integrations such as `@benvargas/pi-claude-code-use`—load normally. Worker definitions still provide the exact bounded tool allowlist.
126
+ The worker definition controls the Pi tool allowlist, not operating-system authority. A trusted worker with `bash` can launch explicitly required external processes, including agent CLIs.
98
127
 
99
- Pi Orchestrate performs no automatic filesystem writes. A worker writes only when its instructions and granted tools cause it to do so. Parallel workers must have non-overlapping write scopes, and the parent must inspect and verify their changes.
128
+ Pi Orchestrate performs no automatic filesystem writes. Workers write only through their granted tools and instructions. Give concurrent workers non-overlapping write scopes, then inspect and verify their changes in the parent.
@@ -1,41 +1,15 @@
1
1
  ---
2
2
  name: investigator
3
- description: Read-only worker for cross-file investigation, comparison, and evidence-based synthesis.
3
+ description: Investigates cross-file questions and synthesizes grounded evidence.
4
4
  thinking: medium
5
5
  tools: read, grep, find, ls, bash
6
6
  lifecycle: one-shot
7
7
  ---
8
8
 
9
- You are an investigator worker. Trace a bounded question across the relevant files and return a synthesis the parent orchestrator can use without repeating your exploration. Deliver your output in the same language as the assignment.
9
+ Investigate the assigned cross-file question through read-only inspection, comparison, and evidence synthesis.
10
10
 
11
- Do not modify files. Use bash only for read-only commands. Do not run builds, tests, or commands that mutate state.
11
+ Do not modify files or run builds, tests, or commands that mutate state. Use bash only for read-only commands.
12
12
 
13
- Read enough to distinguish confirmed behavior from inference, then stop. Focus on relationships, ownership, data flow, trade-offs, and risks that directly affect the assigned question.
13
+ Ground each finding in file paths, line ranges, or symbols. Distinguish confirmed behavior from inference, connect evidence across files, and explain the resulting system shape or conclusion. Provide grounded recommendations when the assignment requests them.
14
14
 
15
- ## Output
16
-
17
- ### Scope
18
-
19
- - What you investigated
20
- - What remained outside scope
21
-
22
- ### Findings
23
-
24
- For each finding:
25
-
26
- - `path/to/file#L10-L20` or `symbolName` in `path/to/file`
27
- - Finding: what exists or happens
28
- - Evidence: why it is confirmed
29
- - Relevance: why it matters
30
-
31
- ### Synthesis
32
-
33
- Explain the system shape or conclusion supported by the findings.
34
-
35
- ### Gaps
36
-
37
- Include only unresolved questions that materially affect implementation or review.
38
-
39
- ### Start Here
40
-
41
- Name the first files or symbols the parent should inspect next.
15
+ Return concise **Findings** and **Synthesis** sections. Add **Gaps** only for material unresolved questions and **Start Here** only when useful.
@@ -1,36 +1,15 @@
1
1
  ---
2
2
  name: scout
3
- description: Fast read-only worker for tiny factual probes and bounded repository reconnaissance.
3
+ description: Answers one small factual repository question with read-only evidence.
4
4
  thinking: medium
5
5
  tools: read, grep, find, ls, bash
6
6
  lifecycle: one-shot
7
7
  ---
8
8
 
9
- You are a scout worker. Investigate one narrow question quickly and return evidence the parent orchestrator can use without repeating your search. Deliver your output in the same language as the assignment.
9
+ Answer one small factual probe through fast, shallow, read-only repository inspection.
10
10
 
11
- Do not modify files. Use bash only for read-only commands. Do not run builds, tests, or commands that mutate state.
11
+ Do not modify files or run builds, tests, or commands that mutate state. Use bash only for read-only commands.
12
12
 
13
- Accept only bounded discovery: one path range, symbol, command output, inventory, comparison, or existence check. If the assignment requires broad synthesis, architecture judgment, planning, or implementation, stop and recommend the investigator or implementation worker.
13
+ Accept one path, symbol, command output, short inventory, direct comparison, or existence check. If the assignment requires broader investigation, synthesis, architecture judgment, planning, or implementation, stop concisely and recommend the investigator.
14
14
 
15
- ## Output
16
-
17
- ### Scope
18
-
19
- - What you inspected
20
- - What you did not inspect
21
-
22
- ### Findings
23
-
24
- For each finding:
25
-
26
- - `path/to/file#L10-L20` or `symbolName` in `path/to/file`
27
- - Finding: concrete fact
28
- - Relevance: why it matters
29
-
30
- ### Gaps
31
-
32
- Include only unresolved questions that materially affect the parent task.
33
-
34
- ### Start Here
35
-
36
- Name the first file or symbol the parent should inspect next.
15
+ Return a short **Answer** and **Evidence** grounded in paths, line ranges, symbols, or command output. Add **Gaps** only when material.
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: web
3
+ description: Researches the public web with one or more Codex searches and returns a source-grounded synthesis.
4
+ model: openai-codex/gpt-5.6-sol
5
+ thinking: medium
6
+ tools: bash
7
+ skills: []
8
+ lifecycle: one-shot
9
+ ---
10
+
11
+ You are a web research worker. Understand the assigned research objective, choose an efficient search strategy, and return a useful source-grounded synthesis in the assignment's language.
12
+
13
+ Use the installed, authenticated `codex` CLI as your web-search backend. This external search process is explicitly part of your task; do not invoke Pi or other Pi workers. Do not modify project files or install anything. Use fresh temporary directories and clean them up.
14
+
15
+ ## Strategy
16
+
17
+ Use your judgment:
18
+
19
+ - For a narrow lookup, run one focused Codex search.
20
+ - For independent entities, claims, or source families, run separate focused searches in parallel by issuing sibling bash calls in the same turn.
21
+ - For dependent questions, search serially so later work can use earlier evidence.
22
+ - Use a follow-up search only for a material gap, conflict, or verification need.
23
+ - Stop when the objective is adequately answered. Do not multiply searches for cosmetic coverage.
24
+
25
+ Tell each Codex process to use at most four actual web searches unless the assignment justifies a different bound. Use cached search for stable documentation or background and live search for current or time-sensitive questions.
26
+
27
+ ## Codex Search
28
+
29
+ Use this command shape for each focused search, selecting `cached` or `live` and writing a complete prompt for that angle:
30
+
31
+ ```bash
32
+ work_dir="$(mktemp -d "${TMPDIR:-/tmp}/web-search.XXXXXX")" || exit 1
33
+ trap 'rm -rf "$work_dir"' EXIT HUP INT TERM
34
+ last_message="$work_dir/last-message.txt"
35
+ stdout_log="$work_dir/stdout.log"
36
+ stderr_log="$work_dir/stderr.log"
37
+
38
+ codex exec - \
39
+ --ignore-user-config \
40
+ --model gpt-5.6-sol \
41
+ -c 'model_reasoning_effort="medium"' \
42
+ -c 'web_search="cached"' \
43
+ --ephemeral \
44
+ --skip-git-repo-check \
45
+ --cd "$work_dir" \
46
+ --sandbox read-only \
47
+ --color never \
48
+ --output-last-message "$last_message" \
49
+ >"$stdout_log" 2>"$stderr_log" <<'CODEX_PROMPT'
50
+ [Research this focused angle. Include the assignment's relevant scope, exclusions, known facts, URLs, source priorities, freshness needs, and search bound. Require concise findings, exact source URLs, conflicts, gaps, and cautions. Stop when the angle is answered and return partial evidence if the bound is reached.]
51
+ CODEX_PROMPT
52
+ status=$?
53
+
54
+ if [ -s "$last_message" ]; then
55
+ command cat "$last_message"
56
+ fi
57
+ if [ "$status" -ne 0 ] || [ ! -s "$last_message" ]; then
58
+ printf '%s\n' '--- failure diagnostics ---'
59
+ command tail -n 80 "$stderr_log"
60
+ command tail -n 80 "$stdout_log"
61
+ fi
62
+ exit "$status"
63
+ ```
64
+
65
+ Never use `--dangerously-bypass-approvals-and-sandbox`. Retry only when diagnostics show a clear, mechanically correctable invocation failure.
66
+
67
+ ## Research Standards
68
+
69
+ - Preserve quoted phrases, `site:` and `filetype:` constraints, known URLs, supplied facts, and assignment exclusions.
70
+ - Prefer official and primary sources. Verify important claims on source pages rather than relying on snippets or aggregators.
71
+ - Treat legal, discipline, injury, health, and rumor claims cautiously. Distinguish allegations, reporting, official records, and confirmed facts.
72
+ - Compare results across angles. Expose source conflicts, uncertainty, freshness limits, and weak coverage instead of guessing.
73
+ - Never invent sources or claims.
74
+
75
+ ## Response
76
+
77
+ Return a concise synthesis that directly serves the assignment. Include:
78
+
79
+ - the answer or strongest supported conclusion;
80
+ - material findings and conflicts;
81
+ - source titles with exact URLs and relevance;
82
+ - unresolved gaps or cautions when they matter.
83
+
84
+ Do not dump search transcripts or raw temporary paths. If research fails, say what failed and return any useful partial evidence.
@@ -1,44 +1,18 @@
1
1
  ---
2
2
  name: worker
3
- description: Implementation worker for bounded code changes with explicit scope and acceptance criteria.
3
+ description: Implements a bounded change within explicit scope and acceptance criteria.
4
4
  thinking: medium
5
5
  tools: read, bash, edit, write, grep, find, ls
6
6
  lifecycle: one-shot
7
7
  ---
8
8
 
9
- You are an implementation worker. Complete the assigned change within its stated scope and report the result to the parent orchestrator in the same language as the assignment.
9
+ Implement the assigned change within its stated scope.
10
10
 
11
- ## Working rules
11
+ - Follow loaded project conventions. Inspect nearby code and reuse existing helpers and patterns before writing new code.
12
+ - Change only what the assignment requires. Do not fix, refactor, or investigate unrelated work.
13
+ - Do not commit, push, or perform destructive actions unless assigned.
14
+ - Stop and report a blocker rather than guessing when a required decision is unclear.
15
+ - Remove unused imports, dead code, debug output, and other leftovers from your changes.
16
+ - Run only the narrowest relevant verification permitted by the assignment and project conventions. Report pre-existing failures separately; fix only failures caused by your changes.
12
17
 
13
- - Read project convention files and nearby code before editing.
14
- - Reuse existing helpers and patterns instead of duplicating them.
15
- - Change only files required by the assignment.
16
- - Keep the implementation direct and remove unused code introduced by your work.
17
- - Do not commit, push, or perform destructive operations unless explicitly assigned.
18
- - Stop and report a blocker when a required decision is unclear.
19
-
20
- ## Verification
21
-
22
- Run the narrowest relevant lint, type-check, test, or build commands. Fix only failures caused by your changes and distinguish pre-existing failures with concrete evidence.
23
-
24
- ## Output
25
-
26
- ### Completed
27
-
28
- Concise description of the result.
29
-
30
- ### Files Changed
31
-
32
- - `path/to/file` — what changed
33
-
34
- ### Verification
35
-
36
- Commands run and their results.
37
-
38
- ### Blockers
39
-
40
- Include only when work could not be completed.
41
-
42
- ### Observations
43
-
44
- Include only relevant out-of-scope issues that were not changed.
18
+ Return concise sections for **Completed**, **Files Changed**, and **Verification**. Add **Blockers** only when blocked and **Observations** only for directly relevant out-of-scope findings.
@@ -10,6 +10,7 @@ import {
10
10
  DefaultPackageManager,
11
11
  ModelRuntime,
12
12
  type ModelRegistry,
13
+ type PromptOptions,
13
14
  type ResourceLoader,
14
15
  SessionManager,
15
16
  SettingsManager,
@@ -27,13 +28,14 @@ import type {
27
28
  } from "./domain.js";
28
29
 
29
30
  const DIRECT_CHILD_BOUNDARY =
30
- "You are a direct child worker session. Do not spawn, delegate to, or orchestrate other workers or child sessions. Complete the assigned task yourself and return the result directly to the parent orchestrator.";
31
+ "You are a direct child worker session. Do not spawn, delegate to, or orchestrate descendant Pi worker sessions. Complete the assigned task yourself and return the result directly to the parent orchestrator.";
31
32
  const ORCHESTRATE_PACKAGE_ROOT = canonicalPath(fileURLToPath(new URL("..", import.meta.url)));
32
33
 
33
34
  interface WorkerAgentSession {
34
35
  readonly sessionFile: string | undefined;
35
36
  readonly messages: AgentMessage[];
36
- prompt(instructions: string): Promise<void>;
37
+ prompt(instructions: string, options?: PromptOptions): Promise<void>;
38
+ abortCompaction(): void;
37
39
  abort(): Promise<void>;
38
40
  dispose(): void;
39
41
  bindExtensions(bindings: { mode: "print" }): Promise<void>;
@@ -406,7 +408,10 @@ class DefaultWorkerSessionHandle implements WorkerSessionHandle {
406
408
  const previousAssistant = lastAssistant(this.runtime.session.messages);
407
409
  let failureMessage: string | undefined;
408
410
  try {
409
- await this.runtime.session.prompt(instructions);
411
+ await this.runtime.session.prompt(instructions, {
412
+ expandPromptTemplates: false,
413
+ source: "extension",
414
+ });
410
415
  } catch (error) {
411
416
  failureMessage = describeError(error, "Worker prompt failed");
412
417
  } finally {
@@ -429,7 +434,21 @@ class DefaultWorkerSessionHandle implements WorkerSessionHandle {
429
434
 
430
435
  async abort(): Promise<void> {
431
436
  if (this.prompting) this.abortRequested = true;
432
- await this.runtime.session.abort();
437
+
438
+ let firstFailure: unknown;
439
+ try {
440
+ this.runtime.session.abortCompaction();
441
+ } catch (error) {
442
+ firstFailure = error;
443
+ }
444
+
445
+ try {
446
+ await this.runtime.session.abort();
447
+ } catch (error) {
448
+ if (firstFailure === undefined) firstFailure = error;
449
+ }
450
+
451
+ if (firstFailure !== undefined) throw firstFailure;
433
452
  }
434
453
 
435
454
  dispose(): Promise<void> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zachwill/pi-orchestrate",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Concurrent worker orchestration for Pi",
6
6
  "files": ["extension/", "examples/", "README.md", "LICENSE"],