@tranhoangnguyen0310/pi-flow-external 2.1.0-external.0 → 2.1.0-external.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/CHANGELOG.md +7 -0
- package/CONTEXT.md +2 -0
- package/README.md +15 -3
- package/package.json +1 -1
- package/src/external-help.ts +5 -2
- package/src/pi-subagent.ts +1 -1
- package/src/prompts.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to pi-flow external are documented here.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## [2.1.0-external.1] - 2026-09-16
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Coordinator guidance now names all four harnesses (`Agent` description, `buildCoordinatorPrompt` body): registered Pi harnesses are first-class alongside Claude Code/Codex CLI/Antigravity, not "external CLIs only" leftovers of the pre-2.1.0 copy. `test/agent-contract`/`agent-rendering` pin the copy.
|
|
12
|
+
- Parent guidance states the blocking default explicitly (`background:true` is opt-in, use `external_runs` on the returned handle) and how same-harness parallel work actually shares the one `maxConcurrentSubagents` limiter: workflow `parallel([() => agent(...), ...])` or separate background `Agent` calls in one turn; sequential awaits stay serial. Includes a three-`agy` workflow example plus fore/background meta examples in `external_help`. Pinned by a new `test/external-help` regression.
|
|
13
|
+
|
|
7
14
|
## [2.1.0-external.0] - 2026-09-15
|
|
8
15
|
|
|
9
16
|
Named Pi harness configurations (`pi-*`): a fourth delegation surface running in-process through Pi's own SDK, selectable exactly like `agy`/`claude`/`codex`. Design: `docs/plans/pi-named-configurations-design.md`; plan: `docs/plans/pi-named-configurations-implementation-plan.md`.
|
package/CONTEXT.md
CHANGED
|
@@ -32,6 +32,8 @@ The split is global and intentional to avoid tool ambiguity across projects. The
|
|
|
32
32
|
|
|
33
33
|
User operations are namespaced under `/external`: status, Doctor, settings, profiles, profile creation, workflows, interactive run navigation, durable run summary/pruning, and help. `/external runs` uses the same registry/readers as `external_runs`, including every cursor-paged workflow child and output/diagnostic page. Extension-owned concurrency, timeout, and global default-harness settings live in `$PI_CODING_AGENT_DIR/pi-flow-external/settings.json`; profiles remain authoritative for downstream backend/model/thinking metadata. Named Pi harness configurations live in the sibling `pi-flow-external/harnesses.json` registry. A trusted project may override only `defaultHarness`, which may itself name a registered `pi-*` harness.
|
|
34
34
|
|
|
35
|
+
> Next agent: full implementation map is `docs/ARCHITECTURE_SNAPSHOT.md` (verified 2026-09-16). Keep this file and `AGENTS.md` as the persistent breadcrumbs.
|
|
36
|
+
|
|
35
37
|
## Design stance
|
|
36
38
|
|
|
37
39
|
Guardrails exist to keep lanes from bleeding into each other (a reviewer that edits, a worker that fixes), not to constrain how a model works. Role bodies stay short: define the job, state the boundary, then get out of the way and trust the model's judgment on approach, depth, and method. The generic `worker` role covers non-coding tasks with no method constraints at all. The shipped default roster is five code-oriented roles (explorer, planner, implementer, reviewer, qa) plus `worker`; other roles are user-created through `/external profile create` and still receive the name-based execution permission floor. External agents must not be arbitrarily handcuffed just to satisfy a theoretical safety checklist: what transpires on the ground is what matters. When an external agent needs heightened permissions to inspect, run tests, and execute tools, the system defaults to providing that authority rather than blocking execution.
|
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ Workflows show access once at the workflow level, retain done/active/queued/fail
|
|
|
253
253
|
|
|
254
254
|
## Background runs and supervision
|
|
255
255
|
|
|
256
|
-
`Agent` and `workflow` are blocking by default. Add `background: true`
|
|
256
|
+
`Agent` and `workflow` are blocking by default — an ordinary call waits for its child and returns the result, run everything this way unless the parent has other work to do first. Add `background: true` only when the parent can productively proceed before completion; it returns a stable `run_...` or `wf_...` handle after validation and registration while the originating Pi session continues to own the work:
|
|
257
257
|
|
|
258
258
|
```ts
|
|
259
259
|
Agent({
|
|
@@ -275,7 +275,19 @@ Interrupting a blocking `Agent`/`workflow` call cancels its work. Interrupting `
|
|
|
275
275
|
|
|
276
276
|
## Workflow usage
|
|
277
277
|
|
|
278
|
-
The `workflow` tool runs trusted JavaScript that calls one or more external roles and returns a JSON-serializable result.
|
|
278
|
+
The `workflow` tool runs trusted JavaScript that calls one or more external roles and returns a JSON-serializable result. Workflows are for explicit fan-out — and for the case this extension was built to make explicit: running several children on the **same** harness at once. Example:
|
|
279
|
+
|
|
280
|
+
```js
|
|
281
|
+
export const meta = { apiVersion: 1, name: "triage", description: "Three parallel agy reviewers" };
|
|
282
|
+
const [a, b, c] = await parallel([
|
|
283
|
+
() => agent("Review slice A read-only: /absolute/repo", { label: "rev-a", role: "reviewer", harness: "agy" }),
|
|
284
|
+
() => agent("Review slice B read-only: /absolute/repo", { label: "rev-b", role: "reviewer", harness: "agy" }),
|
|
285
|
+
() => agent("Review slice C read-only: /absolute/repo", { label: "rev-c", role: "reviewer", harness: "agy" }),
|
|
286
|
+
]);
|
|
287
|
+
return { a, b, c };
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Sequential `await agent(...)` stays serial by construction; `parallel([...])` is how parallel children share the single `maxConcurrentSubagents` limiter at once. Top-level direct `Agent` calls issued together also run together (`executionMode: "parallel"`, default under one limiter). `external_runs wait` and `external_runs inspect` cover both surfaces. Its first statement must be the current declaration `export const meta = { apiVersion: 1, name, description }`; missing or unsupported versions fail before any child launches. Every `agent()` child uses the same `role`/optional `harness` resolution as direct `Agent` calls, with legacy exact `subagent_type` also supported.
|
|
279
291
|
|
|
280
292
|
Saved workflows are discovered on demand through `external_help({ topic: "workflow" })`; project `.pi/workflows` entries are included only when Pi reports the project trusted.
|
|
281
293
|
|
|
@@ -285,7 +297,7 @@ Example request:
|
|
|
285
297
|
Use the workflow tool to ask role "explorer" on harness "claude" for an architecture map and role "reviewer" on harness "codex" for a risk review, then synthesize their findings.
|
|
286
298
|
```
|
|
287
299
|
|
|
288
|
-
Direct `Agent` calls and workflow children share
|
|
300
|
+
Direct `Agent` calls and workflow children share one concurrency limiter (`maxConcurrentSubagents`, default 12) and the same timeout controls. There is no per-harness cap: three `agy` children run together when started together — `parallel([() => agent(..., { harness: "agy" }), ...])` in a workflow, or three `background: true` `Agent` calls in one turn followed by `external_runs wait`. Sequentially `await`ed children stay serial by construction. Direct calls default `executionMode: "parallel"` so top-level `Agent` calls issued together run together. Workflow `agent(prompt, { role, context: { mode: "recent", turns: 5 } })` accepts the same context modes. Every current-version `agent()` returns its value or throws a catchable `ChildRunError` with `runId`, `outcome` (`failed`, `cancelled`, or `timed_out`), `message`, and output/diagnostic references. Catch an optional failure explicitly; an uncaught child error fails the workflow and drains active siblings. `parallel` and `pipeline` preserve this contract and never convert failure to `null`.
|
|
289
301
|
|
|
290
302
|
Every child selects from one parent snapshot and effective settings frozen at workflow invocation; earlier child results must still be passed explicitly. `resumeFromRunId` is explicit replay for a persisted `scriptPath`: it reuses only the longest unchanged prefix of successful child calls. The API version, transferred context, prompt, selection, and relevant options participate in fingerprints. The first changed, failed, cancelled, or timed-out call and everything after it executes again. Recomposition is cheap, but rerun children may cost money or repeat side effects; the runtime never retries or replays a repaired script automatically.
|
|
291
303
|
|
package/package.json
CHANGED
package/src/external-help.ts
CHANGED
|
@@ -94,11 +94,14 @@ Provide exactly one workflow source: name, scriptPath, or script. Every script s
|
|
|
94
94
|
|
|
95
95
|
APIs: agent(prompt, { label, role, harness, subagent_type, permission, max_budget_usd, resume, context, schema, phase }); parallel(thunks); pipeline(items, ...stages); phase(title); log(message). Globals: args and cwd. Agent options other than the profile selector are optional. Choose role/harness or legacy exact subagent_type, never both. Use unique labels and clear task prompts. An agent() succeeds with its value or throws ChildRunError { runId, outcome, message, outputRef, diagnosticsRef }; catch optional failures explicitly. Uncaught failures terminate the workflow and drain siblings. Helpers never convert failures to null. Context options: {mode:"none"} (default), {mode:"recent",turns:N} (positive integer, includes current user turn), or {mode:"full"} (available context after compaction). All children share invocation-time context/settings; earlier child results must still be passed explicitly. Context excludes thinking/system instructions and pending calls; images and snapshots over 1 MiB fail without truncation. Context sharing cannot be combined with resume. Use schema for results that control branching or aggregation. Imports, filesystem globals, Date APIs, and Math.random() are unavailable.
|
|
96
96
|
|
|
97
|
-
Background and supervision:
|
|
97
|
+
Background and supervision: blocking by default — an ordinary call waits for its child and returns the result, run everything this way unless the parent has other work to do first. Set background:true only when the parent can proceed before completion, then use external_runs on the returned stable run ID while session-owned work continues. Parallel same-harness work (e.g. three agy workers) runs concurrently under the shared maxConcurrentSubagents cap: call parallel([() => agent(...), ...]) in a workflow, or issue separate Agent calls with background:true in one turn, then external_runs wait/inspect/cancel. Awaiting agent() calls sequentially stays serial by construction. external_runs actions are list (optional workflowRunId/cursor/workflowCursor/limit), inspect (runId, view summary|output|diagnostics, optional opaque cursor/limitBytes), wait (runId or runIds, mode any|all), and cancel (runId, optional reason). Follow nextCursor/nextWorkflowCursor for complete results. Wait returns selected terminal outcomes and pending IDs, never cancels pending work, and returns an unsuccessful workflow early; interrupting wait stops only the wait. Cancelling a workflow stops active children, while cancelling one child is a catchable workflow error. Blocking-call interruption cancels that call; background work survives tool return but is cancelled on orderly owning-session shutdown. It is not a daemon: crashes leave unfinished evidence interrupted/uncertain, restart does not adopt work, and live steering is unavailable.
|
|
98
98
|
|
|
99
99
|
Replay: resumeFromRunId works only with persisted scriptPath and starts an explicit new attempt. It reuses the longest unchanged prefix of successful child calls; the first changed/failed/cancelled/timed-out call and its suffix run again. Script recomposition is cheap, but child reruns can cost money or repeat side effects. There is no automatic repaired-script replay.
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Background example:
|
|
102
|
+
export const meta = { apiVersion: 1, name: "review", description: "Map and review a repository", background: true };
|
|
103
|
+
|
|
104
|
+
Foreground example:
|
|
102
105
|
export const meta = { apiVersion: 1, name: "review", description: "Map and review a repository" };
|
|
103
106
|
const [map, review] = await parallel([
|
|
104
107
|
() => agent("Map /absolute/repo read-only.", { label: "map", role: "explorer" }),
|
package/src/pi-subagent.ts
CHANGED
|
@@ -352,7 +352,7 @@ function createAgentTool(
|
|
|
352
352
|
return defineTool({
|
|
353
353
|
name: "Agent",
|
|
354
354
|
label: "Agent",
|
|
355
|
-
description: "Delegate one task to an external Claude Code, Codex CLI, or
|
|
355
|
+
description: "Delegate one task to an external Claude Code, Codex CLI, Antigravity, or registered Pi harness role.",
|
|
356
356
|
promptSnippet: AGENT_PROMPT_SNIPPET,
|
|
357
357
|
parameters: agentToolParameters,
|
|
358
358
|
executionMode: "parallel",
|
package/src/prompts.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { EXTERNAL_HARNESSES, type SubagentProfile } from "./types.ts";
|
|
|
3
3
|
import { externalProfileRole, externalRoleAvailability } from "./profiles.ts";
|
|
4
4
|
|
|
5
5
|
export const AGENT_PROMPT_SNIPPET =
|
|
6
|
-
"Delegate one task to an external Claude Code, Codex CLI, or
|
|
6
|
+
"Delegate one task to an external Claude Code, Codex CLI, Antigravity, or registered Pi harness role.";
|
|
7
7
|
|
|
8
8
|
export const WORKFLOW_PROMPT_SNIPPET =
|
|
9
9
|
"Run requested multi-agent orchestration with external roles; use external_help for syntax and saved workflows.";
|
|
@@ -92,5 +92,5 @@ export function buildCoordinatorPrompt(
|
|
|
92
92
|
|
|
93
93
|
${formatExternalRoleCatalog(profiles, defaultHarness, configuredHarnessNames)}
|
|
94
94
|
|
|
95
|
-
Catalog availability reflects configured profiles, not CLI installation or authentication. External delegation tools use external CLIs
|
|
95
|
+
Catalog availability reflects configured profiles, not CLI installation or authentication. External delegation tools use external CLIs and registered Pi harnesses; use native Pi subagents for Pi-backed work. Give each child a clear task, absolute paths, and read-only/edit intent; nested agents may start elsewhere. Share parent context explicitly when a child needs it: context: {mode:"recent", turns:N} for the last N user turns (including the current turn), {mode:"full"} for available post-compaction conversation, or omit it for independent tasks. Prefer the smallest sufficient snapshot; snapshots exclude thinking/system instructions and pending calls, fail on images or over 1 MiB, and may contain sensitive data sent to the external harness. Use resume to follow up on an existing child; never combine it with sharing. This is text transfer, not a native session clone or guaranteed cache reuse. Blocking by default; set background:true only when the parent can proceed before completion, then use external_runs on the returned run ID. Parallel same-harness work shares one maxConcurrentSubagents cap: use parallel([() => agent(...), ...]) or separate background Agent calls in one turn; sequential awaits stay serial. External CLIs have host access, and agy always runs unsandboxed (readonly/edit are advisory). Role selection never falls back. Do not retry failed runs: agy alone may make one disclosed infrastructure retry. Use external_help for role descriptions, permission details, workflow syntax, supervision syntax, and saved workflows.`;
|
|
96
96
|
}
|