@tranhoangnguyen0310/pi-flow-external 2.0.0-external.0 → 2.1.0-external.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/AGENTS.md +12 -12
- package/CHANGELOG.md +20 -0
- package/CONTEXT.md +10 -7
- package/README.md +44 -9
- package/docs/field-testing.md +11 -0
- package/package.json +1 -1
- package/src/core/model.ts +26 -1
- package/src/core/permissions.ts +61 -5
- package/src/core/spawn.ts +204 -51
- package/src/default-roles.ts +58 -0
- package/src/defaults.ts +4 -98
- package/src/external-command.ts +43 -35
- package/src/external-help.ts +58 -16
- package/src/harnesses.ts +213 -0
- package/src/pi-subagent.ts +63 -31
- package/src/profile-creator.ts +226 -28
- package/src/profiles.ts +207 -23
- package/src/prompts.ts +22 -13
- package/src/settings.ts +24 -10
- package/src/types.ts +20 -1
- package/src/workflow/replay-cache.ts +76 -2
- package/src/workflow/runtime.ts +10 -1
- package/src/workflow/tool.ts +54 -13
- package/src/workflow/types.ts +29 -0
package/AGENTS.md
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## pi-flow external contract
|
|
4
4
|
|
|
5
|
-
This fork changes the original pi-flow contract: `Agent` is not a generic Pi subagent launcher. It delegates only to external Claude Code, Codex CLI, and Antigravity harnesses.
|
|
5
|
+
This fork changes the original pi-flow contract: `Agent` is not a generic Pi subagent launcher. It delegates only to external Claude Code, Codex CLI, and Antigravity harnesses, plus named Pi harness configurations (below) — in-process, per-model configs registered by the user, not a fourth CLI.
|
|
6
6
|
|
|
7
|
-
- Ordinary driver tools: `Agent`, read-only `external_help`, `external_runs`, and optional `workflow`. `pi_flow_profile_create`
|
|
7
|
+
- Ordinary driver tools: `Agent`, read-only `external_help`, `external_runs`, and optional `workflow`. `pi_flow_profile_create` and `pi_flow_harness_create` are active only inside `/external profile create`.
|
|
8
8
|
- User operations use `/external`; `/pi-flow-profile create` is a temporary deprecated alias.
|
|
9
|
-
- Extension-owned concurrency, timeout, and global default-harness settings live in `$PI_CODING_AGENT_DIR/pi-flow-external/settings.json`. Profile backend/model/thinking metadata remains in `subagents/*.md`. A trusted project may override `defaultHarness` via `.pi/pi-flow-external/settings.json` (that key only, read-only to the extension); explicit call harness > project default > global default.
|
|
10
|
-
- Every `Agent` call requires `description`, `prompt`, and either `role` with optional `harness` (`agy`, `claude`, or `
|
|
11
|
-
- Valid profiles come from `~/.pi/agent/subagents/*.md` and set `backend: claude`, `backend: codex`, or `backend:
|
|
12
|
-
- A default roster ships with the extension and seeds once on session start: five code-oriented roles (explorer, planner, implementer, reviewer, qa) plus the generalist worker, one storage profile per backend (18 files, but six advertised roles). Seeding never overwrites existing files and respects later deletions. Roles outside the default roster
|
|
13
|
-
-
|
|
14
|
-
-
|
|
9
|
+
- Extension-owned concurrency, timeout, and global default-harness settings live in `$PI_CODING_AGENT_DIR/pi-flow-external/settings.json`. Profile backend/model/thinking metadata remains in `subagents/*.md`. Named Pi harness configurations live in the sibling `$PI_CODING_AGENT_DIR/pi-flow-external/harnesses.json` registry (one shared file, `pi-<label>` keys pinning `model`/`thinking`). Registry writes are atomic per file, but there is no inter-process lock: concurrent writers adding distinct names from separate sessions are last-writer-wins and may drop one update. This is an accepted v1 limitation shared with `settings.json` and `subagents/*.md`, not a bug to re-report. A trusted project may override `defaultHarness` via `.pi/pi-flow-external/settings.json` (that key only, read-only to the extension); explicit call harness > project default > global default. `defaultHarness` may itself name a registered `pi-*` harness.
|
|
10
|
+
- Every `Agent` call requires `description`, `prompt`, and either `role` with optional `harness` (`agy`, `claude`, `codex`, or a registered `pi-*` harness name) or the legacy exact-profile `subagent_type`. The selectors cannot be combined. Without `harness`, use the effective default harness; if that default names a `pi-*` harness that is no longer registered, the call fails with an actionable error rather than silently falling back to `agy`.
|
|
11
|
+
- Valid profiles come from `~/.pi/agent/subagents/*.md` and set `backend: claude`, `backend: codex`, `backend: agy`, or (only when also declaring `harness: <registered pi-* name>`) `backend: pi`. Use matching names such as `claude-*`, `codex-*`, `agy-*`, or `<harness>-*`; the assisted creator enforces that convention.
|
|
12
|
+
- A default roster ships with the extension and seeds once on session start: five code-oriented roles (explorer, planner, implementer, reviewer, qa) plus the generalist worker, one storage profile per CLI backend (18 files, but six advertised roles). Seeding never overwrites existing files and respects later deletions. Roles outside the default roster are user-created via `/external profile create`. Every registered named Pi harness automatically and immediately gets the same six roles too, synthesized in-memory from the identical canonical role source — no per-harness file needed, and no on-disk seeding for pi harnesses.
|
|
13
|
+
- A `backend: pi` profile is external-delegation-eligible only when it also declares `harness: <name>` for a name present in the live `harnesses.json` registry; a bare `backend: pi` profile (no `harness`, or one naming an unregistered config) is filtered out and rejected exactly as before — it belongs to Pi's native subagent system and this extension never modifies it.
|
|
14
|
+
- **Named Pi harness configuration:** a `pi-<label>` entry in `harnesses.json` pinning a `provider/model` id (resolved through Pi's own model registry) and a thinking level (`off|minimal|low|medium|high|xhigh`, always persisted explicitly). It runs in-process via Pi's own SDK, not as a spawned CLI. A pi child loads no project/user extensions, skills, prompt templates, or themes — its entire tool surface is the SDK's own builtins (`read`/`bash`/`edit`/`write`, plus `grep`/`find`/`ls` where a tier's default allow-list adds them), curated but never claimed to be an OS sandbox: `danger` tier `bash` is exactly as exposed as on any external CLI. Retry is disabled per child (in-memory, call-scoped, never touching the user's real settings) to honor this extension's no-auto-retry contract, since the underlying SDK otherwise retries transient provider errors on its own. Pi children cannot resume (no persisted session) and have no enforced budget cap — both are deliberate v1 limitations, not oversights. Custom (non-canonical) roles are still authored per harness via `/external profile create`, not shared across harnesses automatically. Follow-up capability expansion (trusted extensions/MCP/skills, shared custom roles, resumable sessions, real budget controls) is tracked in issue #43.
|
|
15
15
|
- Use Pi's native subagent system for Pi-backed scout/reviewer/planner/worker/oracle work.
|
|
16
|
-
- External backends use their own tools and permission mechanisms. Codex tiers map to its `--sandbox` axis. Claude falls back to `--permission-mode auto` when its effective UID is 0 because Claude refuses bypass mode under root. Execution lanes (implementer,
|
|
16
|
+
- External CLI backends use their own tools and permission mechanisms. Codex tiers map to its `--sandbox` axis. Claude falls back to `--permission-mode auto` when its effective UID is 0 because Claude refuses bypass mode under root. Execution lanes (implementer, qa, worker) require shell command authority to inspect repositories and run tests; on Claude and on pi harnesses (where `edit` tier excludes `bash`), execution lanes maintain a danger floor so agents are not artificially handcuffed. Antigravity (`agy`) has no granular headless permission mode — its default sandbox denies even read-only tools — so every agy run is unsandboxed (`--dangerously-skip-permissions`) and `readonly`/`edit` on agy are advisory profile-body instructions, not a boundary. Run them only in trusted repositories and state whether the task is read-only or may edit files.
|
|
17
17
|
- Children receive no parent history by default. `Agent` and workflow `agent()` can opt into `context: {mode: "recent", turns: N}` (last N user turns, including the current one) or `{mode: "full"}` (available post-compaction conversation). Snapshots exclude system instructions, thinking, tool-result metadata, and pending calls; unsupported content/images and more than 1 MiB fail explicitly. Use the smallest sufficient snapshot plus a clear task, absolute paths, and read-only/edit intent. Shared context goes to the external harness and private local evidence; avoid unnecessary sensitive history. `resume` continues an existing child and cannot be combined with sharing. Workflow children select from one frozen parent snapshot, and replay fingerprints include the transferred context.
|
|
18
18
|
- Backend-native nested agents may use a different workspace. Include explicit absolute paths and required context when asking an external backend to delegate further.
|
|
19
19
|
- `Agent` and `workflow` block by default; `background: true` returns a stable handle after validation/registration. Background work is owned by the originating session, not by the launching tool call or a daemon. Blocking-call interruption cancels work; wait interruption only stops waiting. Orderly session shutdown requests cancellation with bounded cleanup. A crash or unconfirmed shutdown leaves unfinished evidence interrupted/uncertain; restart never adopts live work.
|
|
@@ -21,7 +21,7 @@ This fork changes the original pi-flow contract: `Agent` is not a generic Pi sub
|
|
|
21
21
|
## Delegation transparency invariants
|
|
22
22
|
|
|
23
23
|
- Treat each `description` as a concise user-facing task label. Profile descriptions are also user-visible as the declared reason for profile selection.
|
|
24
|
-
- `unsandboxed external CLI` and `external host access` disclose the real execution boundary. Never present a read-only prompt as permission enforcement: on agy every run is unsandboxed regardless of tier, so the profile body — not the tier — is what asks the agent to stay read-only.
|
|
24
|
+
- `unsandboxed external CLI` and `external host access` disclose the real execution boundary for CLI backends; a pi harness delegation discloses `Pi SDK child · host access · curated tools` instead — never call an in-process pi child an "external CLI". Never present a read-only prompt as permission enforcement: on agy every run is unsandboxed regardless of tier, so the profile body — not the tier — is what asks the agent to stay read-only; on pi, the curated tool table bounds which tool *names* exist, but does not make `bash` at `danger` tier any less exposed.
|
|
25
25
|
- Keep direct intent visible during execution. Workflow access belongs once at the workflow level, not on every child row.
|
|
26
26
|
- Parent-context sharing is a disclosure, not a silent optimization: the intent card names the mode before launch, and receipts name the mode and shared/requested turns. Shared conversation content leaves for the external harness and lands in local evidence, so never describe sharing as internal or free.
|
|
27
27
|
- Keep default progress bounded and human-readable. Expanded terminal output shows bounded canonical output and a full-ID `/external runs` route; record paths, backend-event counts, workflow IDs, and journal paths remain advanced evidence.
|
|
@@ -40,7 +40,7 @@ This fork changes the original pi-flow contract: `Agent` is not a generic Pi sub
|
|
|
40
40
|
|
|
41
41
|
## Workflow contract
|
|
42
42
|
|
|
43
|
-
`workflow` remains trusted JavaScript orchestration over the same external-only role roster. Its first statement declares `meta.apiVersion: 1`; missing/unsupported versions fail before child launch. Every workflow `agent()` child uses the same `role`/optional `harness` resolution as `Agent`, with legacy exact-profile `subagent_type` available as an escape hatch. Successful calls return their value; failed, cancelled, and timed-out calls throw structured catchable child errors. Explicitly handled errors permit siblings to finish; escaping errors fail the workflow and drain active siblings.
|
|
43
|
+
`workflow` remains trusted JavaScript orchestration over the same external-only role roster, including registered named Pi harnesses. Its first statement declares `meta.apiVersion: 1`; missing/unsupported versions fail before child launch. Every workflow `agent()` child uses the same `role`/optional `harness` resolution as `Agent`, with legacy exact-profile `subagent_type` available as an escape hatch. A workflow run freezes one resolved profile (and model) snapshot up front — real on-disk profiles plus every registered pi harness's synthesized canonical roles — so a synthesized pi role executes exactly like a real file, and a `harnesses.json` edit mid-run cannot desync what the replay fingerprint recorded from what actually ran. Successful calls return their value; failed, cancelled, and timed-out calls throw structured catchable child errors. Explicitly handled errors permit siblings to finish; escaping errors fail the workflow and drain active siblings.
|
|
44
44
|
|
|
45
45
|
Replay is explicit through a persisted `scriptPath` plus `resumeFromRunId`. Reuse only the longest unchanged successful prefix; changed or unsuccessful calls and their suffix execute again. Never describe script recomposition as making child reruns free or side-effect-free. There is no live steering or automatic repaired-script retry.
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ Use workflows for requested fan-out or multi-agent orchestration across Claude/C
|
|
|
52
52
|
- Test public contracts, trust/security boundaries, process lifecycle, cancellation/timeouts, profile rollback, workflow execution/resume, and receipt integrity.
|
|
53
53
|
- Do not test cosmetic rendering variations, prompt prose fragments, trivial accessors, or a model's interpretation of instructions.
|
|
54
54
|
- Do not repeat the same behavior at unit, integration, and E2E levels. A regression test must replace or extend overlapping coverage.
|
|
55
|
-
- `npm test` must remain deterministic and offline. Real-provider E2E is opt-in and change-triggered through `npm run e2e -- --backend <claude|codex|agy> [--workflow]
|
|
55
|
+
- `npm test` must remain deterministic and offline. Real-provider E2E is opt-in and change-triggered through `npm run e2e -- --backend <claude|codex|agy> [--workflow]`, or `npm run e2e -- --backend pi --harness <registered-name> [--workflow]` for a named Pi harness the caller has already registered in their own real `harnesses.json` with real credentials configured.
|
|
56
56
|
|
|
57
57
|
## Verification and release
|
|
58
58
|
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ All notable changes to pi-flow external are documented here.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## [2.1.0-external.0] - 2026-09-15
|
|
8
|
+
|
|
9
|
+
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`.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Named `pi-*` harness configurations: arbitrary labels pinning any `provider/model` resolvable through Pi's model registry (built-in, self-hosted, or OpenAI-compatible) plus an explicit thinking level, registered in `~/.pi/agent/pi-flow-external/harnesses.json`.
|
|
14
|
+
- `Agent({ role, harness: "pi-<label>" })` and workflow `agent()` treat `pi-*` names as first-class harnesses; the six canonical roles (`explorer`/`planner`/`implementer`/`reviewer`/`qa`/`worker`) are synthesized automatically for every registered pi harness with no per-harness files.
|
|
15
|
+
- A `backend: pi` profile is delegation-eligible only when it declares a registered `harness`; the registry stays authoritative for model/thinking (conflicting on-disk overrides fail rather than silently win).
|
|
16
|
+
- Profile creator gains a harness-declaration branch (`pi_flow_harness_create`) and role profiles targeting an existing pi harness, both smoke-tested through the real runtime with atomic staged writes.
|
|
17
|
+
- Pi runtime contract: curated built-in-only child tools (no extensions/skills/themes), synchronous model/auth/thinking preflights, tier→tool allow-lists, execution-role `edit`→`danger` floor, per-child in-memory retry disable (never touching user settings), observed non-retrying terminal-event + non-whitespace completion, thinking-clamp disclosure, and backend-aware permission labels that never call an in-process child an "external CLI".
|
|
18
|
+
- `/external settings`, `/external doctor`, and `external_help` disclose pi harnesses and their model/thinking; stale or deleted `defaultHarness` fails the delegation explicitly rather than silently rerouting to `agy`.
|
|
19
|
+
- Workflow replay fingerprints include the resolved backend/harness/model/thinking/profile body/tools/effective permission plus an SDK-version policy tag; each workflow freezes one complete profile snapshot (synthesized profiles included) for its run.
|
|
20
|
+
|
|
21
|
+
### Limitations (v1)
|
|
22
|
+
|
|
23
|
+
- Pi children are built-in tools only; they do not load project/user extensions, skills, prompt templates, themes, or MCP tools. Expansion tracked in issue #43.
|
|
24
|
+
- Custom (non-canonical) pi roles are authored per harness in v1.
|
|
25
|
+
- Pi children cannot be resumed and enforce no hard budget cap; both are disclosed, not approximated.
|
|
26
|
+
|
|
7
27
|
## [2.0.0-external.0] - 2026-09-14
|
|
8
28
|
|
|
9
29
|
Child observation and workflow-aware supervision. Full design: `docs/plans/2026-09-14-child-observation-and-supervision-design.md`.
|
package/CONTEXT.md
CHANGED
|
@@ -4,9 +4,10 @@ This package is a fork of pi-flow whose `Agent` and `workflow` tools are reserve
|
|
|
4
4
|
|
|
5
5
|
## Domain language
|
|
6
6
|
|
|
7
|
-
- **External profile:** A markdown file under `~/.pi/agent/subagents/*.md` whose filename and frontmatter select `backend: claude`, `backend: codex`, or `backend:
|
|
7
|
+
- **External profile:** A markdown file under `~/.pi/agent/subagents/*.md` whose filename and frontmatter select `backend: claude`, `backend: codex`, `backend: agy`, or (only alongside a registered `harness:`) `backend: pi`.
|
|
8
8
|
- **Native Pi subagent:** A subagent exposed by Pi's native subagent system. This fork intentionally does not route it through `Agent`.
|
|
9
|
-
- **Agent call:** A direct external delegation selected by `role` and optional `harness
|
|
9
|
+
- **Agent call:** A direct external delegation selected by `role` and optional `harness` (an external CLI or a registered named Pi harness), or by legacy exact-profile `subagent_type`.
|
|
10
|
+
- **Named Pi harness configuration:** A `pi-<label>` entry in `harnesses.json` pinning a `provider/model` id and a thinking level, run in-process via Pi's own SDK rather than as a spawned CLI. `harness` selects *which* configuration; `backend` (always the literal `"pi"` for these) selects the execution mechanism. The six default roles are synthesized automatically for every registered pi harness from the same canonical source the three CLI backends' default files already come from.
|
|
10
11
|
- **Parent context:** An opt-in frozen text snapshot: `none` (default), `recent` with last N user turns including the current turn, or `full` available post-compaction conversation. It is background for a new external conversation, not a native session clone, system-prompt inheritance, or guaranteed cache reuse. Sharing excludes thinking and pending calls and cannot be combined with child `resume`. Workflow children share one invocation-time snapshot; prior child outputs remain explicit inputs.
|
|
11
12
|
- **Workflow call:** Trusted JavaScript orchestration beginning with `meta.apiVersion: 1` that may fan out several explicit external `agent()` calls. Each child returns a value or throws a catchable `ChildRunError`; escaping child errors fail the workflow and drain siblings.
|
|
12
13
|
- **Background run:** A validated, registered `Agent` or `workflow` invocation that returns a stable handle while work remains owned by the originating session. It is not a daemon or cross-session job.
|
|
@@ -23,17 +24,17 @@ This package is a fork of pi-flow whose `Agent` and `workflow` tools are reserve
|
|
|
23
24
|
## Routing rule
|
|
24
25
|
|
|
25
26
|
- Native Pi work -> native subagent tool.
|
|
26
|
-
- Claude Code / Codex CLI / Antigravity work -> this extension's `Agent` or `workflow`.
|
|
27
|
+
- Claude Code / Codex CLI / Antigravity work, and named Pi harness work -> this extension's `Agent` or `workflow`.
|
|
27
28
|
|
|
28
|
-
The split is global and intentional to avoid tool ambiguity across projects. The ordinary driver sees `Agent`, optional `workflow`, and read-only `external_help`; the profile finalizer is activated only by `/external profile create`. External children start in the requested working directory, but backend-native nested helpers may create or use a separate workspace; prompts that request further nesting should include explicit absolute paths and all required context.
|
|
29
|
+
The split is global and intentional to avoid tool ambiguity across projects. The ordinary driver sees `Agent`, optional `workflow`, and read-only `external_help`; the profile finalizer is activated only by `/external profile create`. External children start in the requested working directory, but backend-native nested helpers may create or use a separate workspace; prompts that request further nesting should include explicit absolute paths and all required context. Named Pi harness children are the one exception to "backend-native nested helpers may use a different workspace": a pi child runs in-process with no extensions, skills, prompts, or themes loaded, so it structurally cannot itself launch a further nested agent.
|
|
29
30
|
|
|
30
31
|
## User control surface
|
|
31
32
|
|
|
32
|
-
User operations are namespaced under `/external`: status, Doctor, settings, profiles, profile creation,
|
|
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.
|
|
33
34
|
|
|
34
35
|
## Design stance
|
|
35
36
|
|
|
36
|
-
Guardrails exist to keep lanes from bleeding into each other (a reviewer that edits, a
|
|
37
|
+
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.
|
|
37
38
|
|
|
38
39
|
Role resolution is mechanical, not model-routed: a profile whose name begins with its declared backend plus `-` exposes the remaining name as its role (`agy-reviewer` -> `reviewer`). The selected role and harness must resolve to that exact profile; unavailable roles report their supported harnesses and never fall back. Nonstandard names remain available only through legacy exact `subagent_type`. The resolved profile stays authoritative for its instructions, model, and permissions.
|
|
39
40
|
|
|
@@ -43,10 +44,12 @@ Workflow replay is explicit and successful-prefix-only. A persisted script resum
|
|
|
43
44
|
|
|
44
45
|
Applied to Antigravity (`agy`), that stance is absolute: the harness offers no granular headless permission mode — its default sandbox (`proceed-in-sandbox`) hard-denies even read-only tools like `read_url_content`, and `--dangerously-skip-permissions` is the only unsandboxed mode. So every agy run is unsandboxed, and `readonly`/`edit` on agy profiles are advisory instructions carried by the profile body, never an enforced boundary. We disclose that plainly (`unsandboxed external CLI`) rather than pretend a read-only tier restrains what the harness will actually allow.
|
|
45
46
|
|
|
47
|
+
Applied to named Pi harness configurations, the same "get out of the way" stance takes a different, honestly-scoped shape: a curated, builtins-only tool surface (no project/user extensions, skills, prompts, or themes) genuinely bounds which tool *names* a pi child can reach — that claim is mechanically true because nothing else loads — but it is not a claim that `bash` at `danger` tier is any less dangerous than on an external CLI once it is granted. `readonly`/`edit` tiers get a real default tool allow-list (`read`/`grep`/`find`/`ls`, plus `edit`/`write` at `edit`) so those tiers are actually usable, not just technically restrictive. Execution-lane roles requested at `edit` are still elevated to `danger` (the same floor as Claude), because `edit` excludes `bash` entirely and an execution lane without shell access cannot do its job.
|
|
48
|
+
|
|
46
49
|
## Known inelegance
|
|
47
50
|
|
|
48
51
|
<!-- ponytail: one-backend-per-file profile format forces role x backend file duplication; extend src/profiles.ts with multi-backend profiles (e.g. backends: [claude, codex, agy] plus per-backend model map) if maintaining N copies of identical role bodies ever hurts -->
|
|
49
|
-
A standardized role roster needs one file per role per backend (e.g. `claude-qa`, `codex-qa`, `agy-qa` with identical bodies) because the profile format binds `backend:` and `model:` to a single file. The duplication is accepted for now; a future format extension could let one role file cover all backends. The same applies to `permission:` tiers: one tier per profile, but backends interpret tiers differently (Claude
|
|
52
|
+
A standardized role roster needs one file per role per backend (e.g. `claude-qa`, `codex-qa`, `agy-qa` with identical bodies) because the profile format binds `backend:` and `model:` to a single file. The duplication is accepted for now; a future format extension could let one role file cover all backends. Named Pi harnesses partially resolve this for the six canonical roles specifically (synthesized once from a single shared source, applied identically to every registered `pi-*` config, with zero files written) — but a *custom* role outside the six still needs one file per pi harness, exactly like the three CLI backends; a user with several registered pi harnesses wanting the same custom role on all of them still duplicates one file per harness. The same applies to `permission:` tiers: one tier per profile, but backends interpret tiers differently (Claude and pi deny Bash at anything below `danger`), so command-running roles declare `danger` and maintain `danger` as their floor even if an explicit `edit` override is requested. Custom profiles outside the role-name convention get that floor only by declaring `permission: danger`; an undeclared custom profile that meets an `edit` tier still hits headless Bash denials (or, on pi, a curated tool set without `bash`), so `permission: danger` doubles as the lane's "needs shell" capability declaration. Named Pi harnesses also ship with no resume and no enforced budget cap in v1 — both deliberate limitations, tracked alongside the shared-custom-role gap in issue #43, not oversights.
|
|
50
53
|
|
|
51
54
|
## Evidence boundary
|
|
52
55
|
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ External agent delegation for [pi](https://github.com/earendil-works/pi) through
|
|
|
5
5
|
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) profiles with `backend: claude`
|
|
6
6
|
- [Codex CLI](https://github.com/openai/codex) profiles with `backend: codex`
|
|
7
7
|
- Antigravity profiles with `backend: agy`
|
|
8
|
+
- Named Pi harness configurations (`pi-<label>`) — in-process, per-model configs you register yourself, not a spawned CLI
|
|
8
9
|
|
|
9
10
|
The ordinary driver has four tools (`workflow` can be disabled):
|
|
10
11
|
|
|
@@ -13,7 +14,7 @@ The ordinary driver has four tools (`workflow` can be disabled):
|
|
|
13
14
|
- `external_help` returns role details, permission behavior, or workflow guidance on demand.
|
|
14
15
|
- `external_runs` lists, inspects, waits for, and cancels session-owned runs.
|
|
15
16
|
|
|
16
|
-
`Agent` and `workflow` accept external roles with an optional harness override. Use pi's native subagent system for Pi-backed agents. The `pi_flow_profile_create`
|
|
17
|
+
`Agent` and `workflow` accept external roles with an optional harness override — one of the three CLIs, or a registered named Pi harness. Use pi's native subagent system for Pi-backed agents. The `pi_flow_profile_create` and `pi_flow_harness_create` finalizers are active only during `/external profile create`.
|
|
17
18
|
|
|
18
19
|
## Install
|
|
19
20
|
|
|
@@ -56,10 +57,11 @@ External agents use the effective permission tier and each harness's native mech
|
|
|
56
57
|
- Claude: `--permission-mode plan`, `--permission-mode acceptEdits`, or `--dangerously-skip-permissions`
|
|
57
58
|
- Codex: `--sandbox read-only`, `workspace-write`, or `danger-full-access`
|
|
58
59
|
- Antigravity: always `--dangerously-skip-permissions`
|
|
60
|
+
- Named Pi harnesses: a curated `tools:` allow-list (`read`/`grep`/`find`/`ls` at `readonly`; those plus `edit`/`write` at `edit`), or the SDK's own default active tools (`read`/`bash`/`edit`/`write`) at `danger`
|
|
59
61
|
|
|
60
|
-
Claude refuses bypass mode when its effective UID is `0`; in that case the extension uses `--permission-mode auto`. External execution lanes (like `implementer`, `
|
|
62
|
+
Claude refuses bypass mode when its effective UID is `0`; in that case the extension uses `--permission-mode auto`. External execution lanes (like `implementer`, `qa`, and `worker`) require shell execution to inspect repositories, run tests, and verify code. On Claude Code and named Pi harnesses, headless/`edit`-tier access excludes shell entirely; therefore, execution lanes maintain a `danger` floor so the model is not artificially handcuffed by permission blocks. Run external agents only in repositories you trust and state whether each task is read-only or may edit files.
|
|
61
63
|
|
|
62
|
-
The TUI labels a direct run with its effective access, including `unsandboxed external CLI` for danger and all Agy runs, and shows `external host access` while workflow work is active. These labels disclose actual execution authority; they do not turn a read-only prompt into an enforced permission boundary.
|
|
64
|
+
The TUI labels a direct run with its effective access, including `unsandboxed external CLI` for danger and all Agy runs, `Pi SDK child · host access · curated tools` for a danger-tier named Pi harness, and shows `external host access` while workflow work is active. These labels disclose actual execution authority; they do not turn a read-only prompt into an enforced permission boundary.
|
|
63
65
|
|
|
64
66
|
## Quick start
|
|
65
67
|
|
|
@@ -95,7 +97,6 @@ All user commands use the `/external` namespace:
|
|
|
95
97
|
| `/external settings` | Show the default harness and effective runtime settings |
|
|
96
98
|
| `/external profiles` | List configured external profiles |
|
|
97
99
|
| `/external profile create` | Create and smoke-test a profile |
|
|
98
|
-
| `/external profile clean-up` | Archive retired pi-flow default profiles |
|
|
99
100
|
| `/external workflows` | List saved workflows |
|
|
100
101
|
| `/external runs` | Interactively browse current-session runs, every workflow child, paged output/diagnostics, and cancellation |
|
|
101
102
|
| `/external runs summary` | Summarize durable run records |
|
|
@@ -112,7 +113,7 @@ Profiles live in:
|
|
|
112
113
|
~/.pi/agent/subagents/<name>.md
|
|
113
114
|
```
|
|
114
115
|
|
|
115
|
-
Names may contain lowercase letters, numbers, and hyphens. A profile must declare `backend: claude`, `backend: codex`, or `backend:
|
|
116
|
+
Names may contain lowercase letters, numbers, and hyphens. A profile must declare `backend: claude`, `backend: codex`, `backend: agy`, or (alongside `harness: <a registered pi-* name>`) `backend: pi`, and its name should start with the matching harness name.
|
|
116
117
|
|
|
117
118
|
Example Claude profile, `~/.pi/agent/subagents/claude-explorer.md`:
|
|
118
119
|
|
|
@@ -139,16 +140,46 @@ backend: agy
|
|
|
139
140
|
model: gemini-3.7-flash-high
|
|
140
141
|
```
|
|
141
142
|
|
|
142
|
-
Profile instructions become the external agent's system instructions. A profile's `description` is also shown as the user-visible reason for its selection, so keep it concise and concrete. External CLIs use their own tools, so a profile's `tools:` field does not control them
|
|
143
|
-
|
|
144
|
-
Profiles created through `/external profile create` are stamped `owner: user`, and clean-up never archives `owner: user` profiles. When writing a profile by hand, add `owner: user` to its frontmatter to protect it from clean-up.
|
|
143
|
+
Profile instructions become the external agent's system instructions. A profile's `description` is also shown as the user-visible reason for its selection, so keep it concise and concrete. External CLIs use their own tools, so a profile's `tools:` field does not control them; a pi profile's `tools:` field does apply, intersected with its permission tier's curated tool table. A `backend: pi` profile is only available to this extension when it also declares `harness: <name>` for a name registered in `harnesses.json` (see below); a bare `backend: pi` profile, or no backend at all, belongs to Pi's native subagent system and is never modified by this extension.
|
|
145
144
|
|
|
146
145
|
### Default profiles
|
|
147
146
|
|
|
148
|
-
On first session start the extension seeds a default roster — five code-oriented roles (explorer, planner, implementer, reviewer, qa) plus the generalist worker — as one storage profile per backend (18 files). The compact agent catalog advertises each role once rather than presenting 18 choices. Seeding happens once: it never overwrites existing files, and profiles you delete or customize afterwards stay that way. Default profiles leave `model` and `thinking` unpinned so they track the CLI's own model and the current Pi thinking level. Roles not in the default roster
|
|
147
|
+
On first session start the extension seeds a default roster — five code-oriented roles (explorer, planner, implementer, reviewer, qa) plus the generalist worker — as one storage profile per backend (18 files). The compact agent catalog advertises each role once rather than presenting 18 choices. Seeding happens once: it never overwrites existing files, and profiles you delete or customize afterwards stay that way. Default profiles leave `model` and `thinking` unpinned so they track the CLI's own model and the current Pi thinking level. Roles not in the default roster can be added with `/external profile create`.
|
|
149
148
|
|
|
150
149
|
Project-local profiles are not supported; global profiles are used for both global and project-only package installations.
|
|
151
150
|
|
|
151
|
+
## Named Pi harness configurations
|
|
152
|
+
|
|
153
|
+
A named Pi harness runs in-process through Pi's own SDK rather than as a spawned CLI, letting you delegate to any model Pi can already resolve (built-in, self-hosted, or a custom-registered provider) without an external CLI. Register one via `/external profile create` (choose the "declare a new named Pi harness" branch): give it a `pi-<label>` name, a `provider/model` id, and an optional thinking level. Registration is smoke-tested against the real pi runtime before it is saved, exactly like a CLI profile, into:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
~/.pi/agent/pi-flow-external/harnesses.json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"version": 1,
|
|
162
|
+
"harnesses": {
|
|
163
|
+
"pi-deepseek": { "model": "deepseek/deepseek-chat", "thinking": "high" }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The moment a harness is registered, all six default roles (explorer, planner, implementer, reviewer, qa, worker) become available on it automatically — no per-role file to write. Delegate to it exactly like any other harness:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
Agent({
|
|
172
|
+
description: "Cheap repository review",
|
|
173
|
+
prompt: "Review this diff read-only.",
|
|
174
|
+
role: "reviewer",
|
|
175
|
+
harness: "pi-deepseek",
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
A custom (non-canonical) role still needs its own profile file per harness, the same as for the three CLI backends: `~/.pi/agent/subagents/pi-deepseek-security-reviewer.md` with `backend: pi` and `harness: pi-deepseek`. That file's body/permission/tools may be customized; its `model`/`thinking` are not — they always come from the harness's registered config, and a file that tries to override them to a different value is rejected rather than silently honored.
|
|
180
|
+
|
|
181
|
+
**v1 scope, by design:** a pi child's entire tool surface is the SDK's own builtins (`read`/`bash`/`edit`/`write`, plus `grep`/`find`/`ls` at `readonly`/`edit` tiers) — no project/user extensions, skills, prompt templates, or themes load into it. This bounds which tool *names* exist; it does not make `bash` at `danger` tier any less exposed than on an external CLI. Retry is disabled per pi child (in-memory, never touching your real Pi settings) so a transient provider error fails immediately rather than silently retrying. Pi children cannot resume a prior conversation and have no enforced budget cap. Expanding this capability set (trusted extensions/MCP/skills, a shared custom-role format, resumable sessions, real budget controls) is tracked in [issue #43](https://github.com/tranhoangnguyen03/pi-flow-external/issues/43).
|
|
182
|
+
|
|
152
183
|
## Agent usage
|
|
153
184
|
|
|
154
185
|
A direct tool call requires `description`, `prompt`, and either `role` or legacy exact-profile `subagent_type`. With `role`, `harness` is optional and defaults to the global `defaultHarness` setting:
|
|
@@ -374,8 +405,12 @@ npm run e2e -- --backend agy
|
|
|
374
405
|
npm run e2e -- --backend claude --workflow
|
|
375
406
|
npm run e2e -- --backend codex --workflow
|
|
376
407
|
npm run e2e -- --backend agy --workflow
|
|
408
|
+
npm run e2e -- --backend pi --harness pi-deepseek
|
|
409
|
+
npm run e2e -- --backend pi --harness pi-deepseek --workflow
|
|
377
410
|
```
|
|
378
411
|
|
|
412
|
+
The `pi` backend requires a harness you have already registered yourself in your real `harnesses.json` with real credentials configured; the script never registers or pays for one on your behalf.
|
|
413
|
+
|
|
379
414
|
See [`docs/field-testing.md`](docs/field-testing.md) for provider checks and [`docs/releasing.md`](docs/releasing.md) for the release process.
|
|
380
415
|
|
|
381
416
|
Run directly from a checkout with:
|
package/docs/field-testing.md
CHANGED
|
@@ -39,6 +39,16 @@ Defaults:
|
|
|
39
39
|
|
|
40
40
|
Override with `--model`, `--thinking`, `--root-model`, or `--root-thinking`. Use `--keep` only when evidence inspection is necessary; it preserves sensitive output and the temporary profile path printed by the runner.
|
|
41
41
|
|
|
42
|
+
### Named Pi harness receipt
|
|
43
|
+
|
|
44
|
+
Run only when the pi runtime contract (§7 of the design), harness registry, or canonical role synthesis changes, and only if you have already registered a real `pi-*` harness in your own `harnesses.json` with real credentials configured:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm run e2e -- --backend pi --harness pi-deepseek
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This lane never registers a harness or writes a temporary profile — canonical synthesis already provides the `worker` role for any registered harness — it only delegates to the harness you name and requires the same one complete `done` receipt.
|
|
51
|
+
|
|
42
52
|
## Supervised workflow receipt
|
|
43
53
|
|
|
44
54
|
When workflow runtime, scheduling, supervision, or tool integration changes, run the affected backend; run all three before release:
|
|
@@ -47,6 +57,7 @@ When workflow runtime, scheduling, supervision, or tool integration changes, run
|
|
|
47
57
|
npm run e2e -- --backend claude --workflow
|
|
48
58
|
npm run e2e -- --backend codex --workflow
|
|
49
59
|
npm run e2e -- --backend agy --workflow
|
|
60
|
+
npm run e2e -- --backend pi --harness pi-deepseek --workflow
|
|
50
61
|
```
|
|
51
62
|
|
|
52
63
|
Each command declares `meta.apiVersion: 1`, starts a two-child workflow with `background: true`, waits for the selected workflow through `external_runs`, inspects its summary/output, requires two complete child receipts, and verifies the read-only fixture stayed clean. Forced multi-page cursor behavior remains covered by deterministic offline tests; this check exercises real workflow child handling without duplicating those semantics.
|
package/package.json
CHANGED
package/src/core/model.ts
CHANGED
|
@@ -20,7 +20,32 @@ export function resolveProfileModel(profile: SubagentProfile, ctx: ExtensionCont
|
|
|
20
20
|
if (!usesPiBackend(profile)) {
|
|
21
21
|
return undefined;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
// A legitimate pi profile always pins a model (either declared directly or
|
|
24
|
+
// inherited from its registered harness at resolution time), so there is no
|
|
25
|
+
// "fall back to the parent's own model" case here: an admitted pi profile
|
|
26
|
+
// with no resolvable model is a real error, surfaced by describeMissingModel.
|
|
27
|
+
return profile.model ? findProfileModel(profile, ctx.modelRegistry) : undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Distinguish "profile pins no parseable model string" from "profile pins a
|
|
32
|
+
* parseable model that isn't in the registry" so callers can surface the two
|
|
33
|
+
* distinct failures from design §7.1 instead of one generic message.
|
|
34
|
+
*/
|
|
35
|
+
export function describeMissingModel(profile: SubagentProfile, modelRegistry: ModelRegistry): string {
|
|
36
|
+
if (!profile.model) {
|
|
37
|
+
return "No model is selected";
|
|
38
|
+
}
|
|
39
|
+
const separator = profile.model.indexOf("/");
|
|
40
|
+
if (separator === -1) {
|
|
41
|
+
return `Profile "${profile.name}" pins no resolvable model (expected "<provider>/<id>", got ${JSON.stringify(profile.model)}).`;
|
|
42
|
+
}
|
|
43
|
+
const provider = profile.model.slice(0, separator);
|
|
44
|
+
const id = profile.model.slice(separator + 1);
|
|
45
|
+
if (modelRegistry.find(provider, id)) {
|
|
46
|
+
return "No model is selected";
|
|
47
|
+
}
|
|
48
|
+
return `Profile "${profile.name}" pins model "${profile.model}", which was not found in the registry.`;
|
|
24
49
|
}
|
|
25
50
|
|
|
26
51
|
export function filterProfilesForModelRegistry(
|
package/src/core/permissions.ts
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import type { PermissionTier, SubagentBackend, SubagentProfile } from "../types.ts";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Single source of truth for which pi-child SDK builtin tools are active at
|
|
5
|
+
* each permission tier (design §6's curated tier table). Both the runtime
|
|
6
|
+
* (src/core/spawn.ts, which derives its actual excludeTools/tools allow-list
|
|
7
|
+
* from this) and this module's disclosure caveat read from here, so the
|
|
8
|
+
* caveat text can never drift out of sync with what actually executes.
|
|
9
|
+
*/
|
|
10
|
+
export const PI_TIER_ACTIVE_TOOLS: Readonly<Record<PermissionTier, readonly string[]>> = {
|
|
11
|
+
readonly: ["read", "grep", "find", "ls"],
|
|
12
|
+
edit: ["read", "grep", "find", "ls", "edit", "write"],
|
|
13
|
+
danger: ["read", "bash", "edit", "write"],
|
|
14
|
+
};
|
|
15
|
+
|
|
3
16
|
export interface PermissionResolution {
|
|
4
17
|
tier: PermissionTier;
|
|
5
18
|
/** True when the backend enforces the tier with a native mechanism. */
|
|
6
19
|
enforced: boolean;
|
|
7
20
|
/** Short human-readable caveat shown in disclosure labels. */
|
|
8
21
|
caveat: string | undefined;
|
|
22
|
+
/** Backend this resolution was computed for; lets permissionLabel branch on it. */
|
|
23
|
+
backend?: SubagentBackend;
|
|
9
24
|
}
|
|
10
25
|
|
|
11
26
|
/**
|
|
12
27
|
* Known execution-oriented roles that require command/Bash execution
|
|
13
28
|
* (running tests, build tools, git inspection, etc.).
|
|
14
29
|
*/
|
|
15
|
-
export const EXECUTION_ROLES: readonly string[] = ["implementer", "
|
|
30
|
+
export const EXECUTION_ROLES: readonly string[] = ["implementer", "qa", "worker"];
|
|
16
31
|
|
|
17
32
|
/** Minimal profile shape needed to reason about permission tiers. */
|
|
18
33
|
export type PermissionProfileRef = Pick<SubagentProfile, "name" | "backend" | "description" | "permission">;
|
|
@@ -29,7 +44,7 @@ export function isExecutionProfile(profile?: PermissionProfileRef): boolean {
|
|
|
29
44
|
*
|
|
30
45
|
* Pragmatic execution principle: do not get in the way of external agents
|
|
31
46
|
* doing good work. Claude in headless mode auto-denies all Bash commands at
|
|
32
|
-
* `edit` (acceptEdits); execution profiles (such as implementer,
|
|
47
|
+
* `edit` (acceptEdits); execution profiles (such as implementer, qa,
|
|
33
48
|
* worker) require shell access to inspect repositories, run tests, and validate
|
|
34
49
|
* fixes. An override to `edit` on these lanes would handcuff the model into
|
|
35
50
|
* headless permission denials. We elevate to `danger` so the agent has the
|
|
@@ -49,7 +64,11 @@ export function resolveEffectivePermissionTier(
|
|
|
49
64
|
// by the profile body, not a harness boundary.
|
|
50
65
|
return "danger";
|
|
51
66
|
}
|
|
52
|
-
if (profile?.backend === "claude" && isExecutionProfile(profile) && baseTier === "edit") {
|
|
67
|
+
if ((profile?.backend === "claude" || profile?.backend === "pi") && isExecutionProfile(profile) && baseTier === "edit") {
|
|
68
|
+
// Same floor as claude, for the same reason: §6's curated pi tool table
|
|
69
|
+
// strips `bash` at `edit` tier, so an execution-lane pi profile (implementer,
|
|
70
|
+
// qa, worker) requested at `edit` would otherwise lose shell
|
|
71
|
+
// access entirely. Elevate rather than silently handcuff the agent.
|
|
53
72
|
return "danger";
|
|
54
73
|
}
|
|
55
74
|
return baseTier;
|
|
@@ -65,6 +84,7 @@ export function resolvePermission(tier: PermissionTier, backend: SubagentBackend
|
|
|
65
84
|
return {
|
|
66
85
|
tier,
|
|
67
86
|
enforced: true,
|
|
87
|
+
backend,
|
|
68
88
|
// plan/acceptEdits auto-deny Bash headlessly; denials are surfaced.
|
|
69
89
|
caveat: tier === "danger" ? undefined : "Bash auto-denied headlessly",
|
|
70
90
|
};
|
|
@@ -72,6 +92,7 @@ export function resolvePermission(tier: PermissionTier, backend: SubagentBackend
|
|
|
72
92
|
return {
|
|
73
93
|
tier,
|
|
74
94
|
enforced: true,
|
|
95
|
+
backend,
|
|
75
96
|
// --sandbox governs model-generated shell commands, not MCP/plugins/hooks.
|
|
76
97
|
caveat: tier === "danger" ? undefined : "shell commands only",
|
|
77
98
|
};
|
|
@@ -84,10 +105,27 @@ export function resolvePermission(tier: PermissionTier, backend: SubagentBackend
|
|
|
84
105
|
return {
|
|
85
106
|
tier,
|
|
86
107
|
enforced: tier === "danger",
|
|
108
|
+
backend,
|
|
87
109
|
caveat: tier === "danger" ? undefined : "runs unsandboxed; tier advisory only",
|
|
88
110
|
};
|
|
111
|
+
case "pi":
|
|
112
|
+
// A curated builtins-only tool surface bounds which tool *names* exist
|
|
113
|
+
// (see spawn.ts's pi branch); it is a real, truthful tool-level
|
|
114
|
+
// restriction and not an OS sandbox. It never makes `bash` at `danger`
|
|
115
|
+
// tier meaningfully less exposed than any other backend's `danger` tier.
|
|
116
|
+
// The caveat names exactly the tools active *at this tier* (from the
|
|
117
|
+
// same PI_TIER_ACTIVE_TOOLS table spawn.ts's runtime derives its actual
|
|
118
|
+
// allow-list from) — never the full builtin universe regardless of
|
|
119
|
+
// tier, which would misrepresent readonly/edit as having bash/write
|
|
120
|
+
// available when the tier table excludes them.
|
|
121
|
+
return {
|
|
122
|
+
tier,
|
|
123
|
+
enforced: true,
|
|
124
|
+
backend,
|
|
125
|
+
caveat: tier === "danger" ? undefined : `${PI_TIER_ACTIVE_TOOLS[tier].join("/")} tools only; no project extensions`,
|
|
126
|
+
};
|
|
89
127
|
default:
|
|
90
|
-
return { tier, enforced: false, caveat: "advisory, not enforced" };
|
|
128
|
+
return { tier, enforced: false, backend, caveat: "advisory, not enforced" };
|
|
91
129
|
}
|
|
92
130
|
}
|
|
93
131
|
|
|
@@ -118,7 +156,25 @@ export function buildPermissionArgs(
|
|
|
118
156
|
|
|
119
157
|
/** Disclosure label used in delegation cards and receipts. */
|
|
120
158
|
export function permissionLabel(resolution: PermissionResolution): string {
|
|
121
|
-
const { tier, enforced, caveat } = resolution;
|
|
159
|
+
const { tier, enforced, caveat, backend } = resolution;
|
|
160
|
+
if (backend === "pi") {
|
|
161
|
+
// A pi child is an in-process SDK session, not an external CLI process:
|
|
162
|
+
// never describe it as "external CLI" (design §9, "Delegation transparency
|
|
163
|
+
// invariants" in AGENTS.md). "host access" discloses the real boundary —
|
|
164
|
+
// the curated tool table restricts which tool *names* exist, not what an
|
|
165
|
+
// admitted bash tool can do.
|
|
166
|
+
if (tier === "danger") {
|
|
167
|
+
return "Pi SDK child · host access · curated tools";
|
|
168
|
+
}
|
|
169
|
+
const parts = [`Pi SDK child · ${tier} · curated tools`];
|
|
170
|
+
if (!enforced) {
|
|
171
|
+
parts.push("advisory, not enforced");
|
|
172
|
+
}
|
|
173
|
+
if (caveat && caveat !== "advisory, not enforced") {
|
|
174
|
+
parts.push(caveat);
|
|
175
|
+
}
|
|
176
|
+
return parts.join(" · ");
|
|
177
|
+
}
|
|
122
178
|
if (tier === "danger") {
|
|
123
179
|
return "unsandboxed external CLI";
|
|
124
180
|
}
|