delegation-layer 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +58 -14
  2. package/docs/assets/delegation-layer-hero.jpg +0 -0
  3. package/package.json +3 -2
  4. package/plugins/delegation-layer/.claude-plugin/plugin.json +1 -1
  5. package/plugins/delegation-layer/.codex-plugin/plugin.json +1 -1
  6. package/plugins/delegation-layer/skills/agent-integration/SKILL.md +27 -8
  7. package/plugins/delegation-layer/skills/agent-integration/examples/json-results.md +6 -7
  8. package/plugins/delegation-layer/skills/agent-integration/examples/managed-workspace.md +68 -0
  9. package/plugins/delegation-layer/skills/agent-integration/references/collaboration.md +22 -6
  10. package/plugins/delegation-layer/skills/agent-integration/references/command-reference.md +56 -18
  11. package/plugins/delegation-layer/skills/agent-integration/references/continuation.md +36 -0
  12. package/plugins/delegation-layer/skills/agent-integration/references/result-handling.md +46 -2
  13. package/plugins/delegation-layer/skills/agent-integration/references/workspaces.md +197 -0
  14. package/scripts/install-agent-integration.mjs +15 -829
  15. package/scripts/install-cli.mjs +26 -66
  16. package/scripts/installer/application.mjs +250 -0
  17. package/scripts/installer/arguments.mjs +123 -0
  18. package/scripts/installer/catalog.mjs +95 -0
  19. package/scripts/installer/detection.mjs +41 -0
  20. package/scripts/installer/filesystem.mjs +97 -0
  21. package/scripts/installer/paths.mjs +14 -0
  22. package/scripts/installer/picker-state.mjs +46 -0
  23. package/scripts/installer/routing-rules.mjs +99 -0
  24. package/scripts/installer/routing-store.mjs +151 -0
  25. package/scripts/installer/selection.mjs +34 -0
  26. package/scripts/installer/skill-store.mjs +33 -0
  27. package/scripts/installer/terminal.mjs +104 -0
  28. package/skills/agent-integration/SKILL.md +27 -8
  29. package/skills/agent-integration/examples/json-results.md +6 -7
  30. package/skills/agent-integration/examples/managed-workspace.md +68 -0
  31. package/skills/agent-integration/references/collaboration.md +22 -6
  32. package/skills/agent-integration/references/command-reference.md +56 -18
  33. package/skills/agent-integration/references/continuation.md +36 -0
  34. package/skills/agent-integration/references/result-handling.md +46 -2
  35. package/skills/agent-integration/references/workspaces.md +197 -0
package/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Delegation Layer
2
2
 
3
3
  <p align="center">
4
- <a href="#install"><img src="docs/assets/delegation-layer-hero.jpg" alt="A lead AI model coordinating several specialist coding agents through Delegation Layer" width="1400"></a>
4
+ <a href="#install"><img src="docs/assets/delegation-layer-hero.jpg" alt="One lead AI sends briefs through Delegate to three specialist agents and collects their findings" width="1400"></a>
5
5
  </p>
6
6
 
7
+ Briefs out. Findings back. One place to track the work.
8
+
7
9
  Give your lead AI agent a reliable way to delegate bounded coding work to the
8
10
  provider that fits the task.
9
11
 
@@ -25,9 +27,11 @@ already use instead of replacing them.
25
27
  - **Resumable turns** — a durable timeout can continue the exact provider
26
28
  session through a linked successor task.
27
29
  - **Runtime compatibility** — the selected provider's executable and advertised
28
- capabilities are checked when the task is prepared.
30
+ capabilities are checked before provider execution.
29
31
  - **Model choice when needed** — native model and effort discovery is available
30
32
  without turning discovery into an admission allowlist.
33
+ - **Optional retained worktrees** — independent Git writes can use a managed
34
+ worktree with explicit capture and Lead-controlled release.
31
35
  - **Native authentication** — provider login stays with the provider CLI; task
32
36
  state does not contain copied credentials.
33
37
 
@@ -205,9 +209,11 @@ delegate --root "$HOME/delegation-state" collect TASK_ID --watch 5s --json
205
209
  Use `delegate providers --json` for the compiled provider catalog and
206
210
  `delegate capabilities --provider PROFILE --json` for a provider-neutral
207
211
  capability response. `delegate preflight --provider PROFILE --cwd ABS --json`
208
- checks static admission without creating a task. Dispatch still performs the
209
- host-specific runtime probe; catalog discovery alone does not prove
210
- authentication or supervisor readiness.
212
+ checks static admission without creating a task. Managed runtime-only tasks
213
+ perform the fresh runtime probe inside their supervised worker before provider
214
+ execution; inspection-backed paths retain admission checks. See
215
+ [architecture](docs/architecture.md#ownership-boundaries). Catalog discovery
216
+ alone does not prove authentication or supervisor readiness.
211
217
 
212
218
  When an explicit model or effort choice is needed, query the implemented native
213
219
  discovery command:
@@ -229,19 +235,36 @@ Discovery exits `0` for `available` or `partial`, `2` for `blocked` or
229
235
  `unavailable`, and `1` for `failed`.
230
236
 
231
237
  For Codex's native read-only review command, select `codex:review` and make
232
- the Git state explicit:
238
+ the Git state explicit. Run this from an existing Git checkout outside the
239
+ Delegate state root, with the changes you want reviewed:
233
240
 
234
241
  ```sh
235
- delegate --root "$HOME/delegation-state" dispatch \
242
+ (
243
+ REVIEW_WORKSPACE="$(git rev-parse --show-toplevel)" || exit 1
244
+ REVIEW_BRIEF="$(mktemp)" || exit 1
245
+ REVIEW_RESPONSE="$(mktemp)" || exit 1
246
+ printf '%s\n' 'Review the uncommitted changes in this Git checkout.' >"$REVIEW_BRIEF"
247
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch \
236
248
  --provider codex:review \
237
249
  --review-target uncommitted \
238
- --brief "$PWD/review-brief.txt" \
239
- --cwd "$HOME/delegation-workspace" \
250
+ --brief "$REVIEW_BRIEF" \
251
+ --cwd "$REVIEW_WORKSPACE" \
240
252
  --permission read-only \
241
- --budget 30m \
242
- --json
253
+ --budget 1h \
254
+ --json >"$REVIEW_RESPONSE"; then
255
+ review_exit=0
256
+ else
257
+ review_exit=$?
258
+ fi
259
+ cat "$REVIEW_RESPONSE"
260
+ printf '\nDispatch exit: %s; saved response: %s\n' "$review_exit" "$REVIEW_RESPONSE"
261
+ )
243
262
  ```
244
263
 
264
+ When that response says `task_record: "created"`, observe its exact `task_id`
265
+ with the `status` and `collect` commands above, using the same state root.
266
+ Otherwise follow the returned failure; do not dispatch again to recover output.
267
+
245
268
  Use `base:BRANCH` or `commit:SHA` for a different review target. Review tasks
246
269
  are persisted as read-only tasks and do not support continuation or active-turn
247
270
  interaction. The brief is retained in the task evidence; Codex's explicit
@@ -259,6 +282,25 @@ delegate --root "$HOME/delegation-state" continue \
259
282
  The successor receives a new task ID and is observed with the same `status` and
260
283
  `collect` commands.
261
284
 
285
+ ### Optional managed Git workspaces
286
+
287
+ Ordinary delegation is unchanged. For independent parallel writes, use a
288
+ managed worktree unless the user explicitly chooses shared coordination:
289
+
290
+ ```sh
291
+ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
292
+ --brief /absolute/brief.txt --cwd /absolute/git/source \
293
+ --permission workspace-write --isolation git-worktree \
294
+ --base HEAD --workspace-budget 5m --budget 30m --json
295
+ ```
296
+
297
+ The committed base is authoritative; dirty and untracked source changes are
298
+ excluded. The worktree remains retained until the Lead reviews the captured
299
+ Git-content evidence and explicitly releases it. Use the [managed workspace
300
+ reference](skills/agent-integration/references/workspaces.md) for attachment,
301
+ continuation, verification, review scope, release, and forgetting. This
302
+ feature does not automatically apply, commit, branch, or merge worker changes.
303
+
262
304
  ## Documentation
263
305
 
264
306
  - [Getting started](docs/getting-started.md) — install and run a first task.
@@ -268,14 +310,16 @@ The successor receives a new task ID and is observed with the same `status` and
268
310
  behavior.
269
311
  - [Provider guide](docs/providers.md) — profiles and runtime compatibility.
270
312
  - [Architecture](docs/architecture.md) — lifecycle and ownership boundaries.
271
- - [System components](diagrams/components.html) — interactive Archify view.
272
- - [Task lifecycle](diagrams/lead-interface.html) — interactive lifecycle view.
313
+ - [System components](diagrams/components.html) — interactive Archify view; [SVG](diagrams/components.light.svg) · [PNG](diagrams/components.light.png).
314
+ - [Task lifecycle](diagrams/lead-interface.html) — interactive lifecycle view; [SVG](diagrams/lead-interface.light.svg) · [PNG](diagrams/lead-interface.light.png).
273
315
  - [Security](docs/security.md) — isolation, policy, and result integrity.
274
316
  - [Troubleshooting](docs/troubleshooting.md) — common setup and runtime
275
317
  failures.
276
318
  - [Agent integration skill](skills/agent-integration/SKILL.md) — the
277
319
  provider-neutral instructions installed into an agent harness.
278
- - [Contributing](CONTRIBUTING.md) — development and review guidance.
320
+ - [Managed workspaces](skills/agent-integration/references/workspaces.md) —
321
+ optional Git checkout, capture, and retention policy.
322
+ - [Contributing](docs/contributing.md) — development and review guidance.
279
323
 
280
324
  ## License
281
325
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "delegation-layer",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Multi-provider AI agent delegation CLI and Agent Skill for running bounded coding tasks across provider CLIs.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -27,7 +27,8 @@
27
27
  "skills/agent-integration/",
28
28
  "plugins/delegation-layer/",
29
29
  "scripts/install-agent-integration.mjs",
30
- "scripts/install-cli.mjs"
30
+ "scripts/install-cli.mjs",
31
+ "scripts/installer/"
31
32
  ],
32
33
  "engines": {
33
34
  "node": ">=18"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "delegation-layer",
3
3
  "displayName": "Delegation Layer",
4
- "version": "0.1.27",
4
+ "version": "0.1.29",
5
5
  "description": "Consult external AI harnesses and CCR-configured models for reviews, research, implementation, and debate through the resumable Delegate CLI.",
6
6
  "author": {
7
7
  "name": "Hesham Karam",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "delegation-layer",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Consult external AI harnesses and CCR-configured models for reviews, research, implementation, and debate through the resumable Delegate CLI.",
5
5
  "author": {
6
6
  "name": "Hesham Karam",
@@ -34,7 +34,7 @@ Do not inspect, authenticate, install, or repair provider CLIs to bypass a
34
34
  Delegate blocker.
35
35
 
36
36
  A reported blocker is a valid final response to a delegation request. It does
37
- not turn that request into an environment-repair task. The one lifecycle
37
+ not turn that request into an environment-repair task. The supervisor recovery
38
38
  exception is `failure.code: "supervisor_upgrade_required"` with
39
39
  `next_action: "run_supervisor_migrate"`: run Delegate's own
40
40
  `supervisor migrate` command once with the exact same state root, then retry the
@@ -47,6 +47,9 @@ not Pueue administration. Never run `pueue`, `pueued`, socket inspection,
47
47
  process searches, root deletion, or a provider CLI during recovery. Executable
48
48
  path or hash drift alone is handled by normal adoption and does not require
49
49
  this command.
50
+ Managed admission also permits the two explicit `watch_workspace` responses
51
+ in the task-record table below. They keep the exact admission command and
52
+ inputs, including `continue`; they do not authorize environment repair.
50
53
  When a response says `failure.next_action: "stop_and_report"`, that attempt is
51
54
  finished. Include its failure in your final response without opening a
52
55
  clarification dialog to choose a fallback. For `task_record: not_created`,
@@ -72,7 +75,9 @@ tasks may proceed; the failed attempt must remain reported as failed or blocked.
72
75
  3. Give every turn an absolute workspace, an explicit permission mode, and a
73
76
  finite budget. Keep the state root outside the workspace. Reuse a supplied
74
77
  `DELEGATE_ROOT` for all providers and tasks; do not invent per-provider or
75
- per-task state roots. Task IDs separate work within that root.
78
+ per-task state roots. Task IDs separate work within that root. Managed Git
79
+ workspaces are optional; read [managed workspace guidance](references/workspaces.md)
80
+ before creating or attaching one.
76
81
  4. Use `--json` and save each response separately with its requested destination,
77
82
  model, effort, workspace, and returned `task_id`. Never merge concurrent
78
83
  responses into an unlabeled output stream. Read `admission`, `liveness`,
@@ -119,8 +124,10 @@ tasks may proceed; the failed attempt must remain reported as failed or blocked.
119
124
  11. The model chooses ordinary-task fan-out by issuing independent `dispatch`
120
125
  commands concurrently. The private supervisor does not impose a task-count
121
126
  or CPU-based limit. Use this for independent investigation, debate, review,
122
- or provider comparison. Concurrent write tasks must use separate workspaces
123
- or explicit coordination to avoid file conflicts.
127
+ or provider comparison. For independent parallel writes, choose
128
+ `--isolation git-worktree` automatically unless the user explicitly chooses
129
+ shared coordination; the model chooses fan-out and task scope. A read-only
130
+ review may attach a retained workspace with `--workspace ID`.
124
131
 
125
132
  For an explicit Codex code review, use the discoverable `codex:review` profile
126
133
  with one persisted target: `--review-target uncommitted`,
@@ -131,6 +138,13 @@ provider to edit files; the review profile is for Codex's native review
131
138
  operation and keeps the reviewed Git state explicit. The brief is retained as
132
139
  task evidence; the review target supplies Codex's review scope because its
133
140
  native command does not accept a prompt with the target flag.
141
+ For a complete managed-workspace turn, review the recorded initial base against
142
+ its captured tree through an ordinary read-only task. Include both sealed refs
143
+ and an explicit `git diff BASE TREE` scope. A native `uncommitted` review covers
144
+ current staged, unstaged, and untracked changes; it excludes worker commits.
145
+ Do not pass a tree as a native branch target. Preserve an explicitly requested
146
+ native review target and state its narrower scope. See [workspace review
147
+ guidance](references/workspaces.md#recovery-and-review-scope).
134
148
 
135
149
  ## Operating procedure
136
150
 
@@ -152,7 +166,7 @@ If no destination was named, use automatic selection directly. If the user
152
166
  named a harness (for example, “Codex”), resolve its exact provider ID from:
153
167
 
154
168
  ```sh
155
- delegate providers --json
169
+ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" providers --json
156
170
  ```
157
171
 
158
172
  Use the matching catalog ID with `--provider`; do not silently substitute
@@ -287,6 +301,7 @@ for **each attempt**, including requests issued together:
287
301
  | Usage error, no JSON response | Correct the reported syntax using Delegate help or `providers --json`, then invoke that request again. Parsing failed before admission. |
288
302
  | `task_record: not_created`, `failure.code: supervisor_upgrade_required`, and `failure.next_action: run_supervisor_migrate` | Run `delegate --root "<the exact absolute state root used by the failed command>" supervisor migrate --json` once. Retry the exact original admission argv once only after `supervisor_control.state: migrated` and `supervisor_control.next_action: retry_dispatch`; otherwise stop and report the migration response. Preserve an explicit custom root exactly. A failed `continue` must be retried as the same `continue`; never replace it with a fresh `dispatch` or a direct provider call. |
289
303
  | `task_record: not_created` and `failure.next_action: correct_request` | Correct that request and retry it. |
304
+ | `task_record: not_created`, `failure.code: workspace_provision_pending` or `workspace_busy`, and `failure.next_action: watch_workspace` | Follow [managed workspace recovery](references/result-handling.md#managed-workspace-results) using the same root and workspace. Once ready, retry the exact admission command and inputs. A failed `continue` remains that same `continue`, never a new dispatch. |
290
305
  | `task_record: not_created` with any other next action | Report that attempt's failure and stop it. Do not diagnose provider setup or substitute an integration. |
291
306
  | `task_record: created` | Use `status` before taking any other action. Do not dispatch again. |
292
307
  | `task_record: unknown` or an ambiguous response | Stop and report; do not retry an uncertain task creation. |
@@ -352,10 +367,14 @@ recruit more agents unless that is explicitly part of the task.
352
367
  admission, publication, authentication, errors, or exit codes.
353
368
  - Read [continuation](references/continuation.md) for timeout recovery or an
354
369
  exact-session follow-up.
370
+ - Read [managed workspaces](references/workspaces.md) for optional Git
371
+ worktrees, capture, review scope, release, and forgetting.
355
372
  - Use [read-only example](examples/read-only-task.md),
356
- [write example](examples/workspace-write-task.md), and
357
- [JSON examples](examples/json-results.md) when constructing a task or parsing
358
- unfamiliar output. Do not load every reference for a routine dispatch.
373
+ [write example](examples/workspace-write-task.md),
374
+ [JSON examples](examples/json-results.md), and
375
+ [managed workspace example](examples/managed-workspace.md) when constructing
376
+ a task or parsing unfamiliar output. Do not load every reference for a
377
+ routine dispatch.
359
378
 
360
379
  ## Completion report
361
380
 
@@ -5,10 +5,9 @@ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status "$TASK_ID" --j
5
5
  delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect "$TASK_ID" --watch 5s --json
6
6
  ```
7
7
 
8
- Decision order:
9
-
10
- 1. Save `task_id`.
11
- 2. Check `admission` and `error`.
12
- 3. Wait while publication is pending.
13
- 4. Accept only a committed terminal `outcome`.
14
- 5. If `status` is `timed_out`, follow `continuation.resumable`.
8
+ Apply [result handling](../references/result-handling.md) to each response and
9
+ follow [Observe and collect](../SKILL.md#5-observe-and-collect). Those sections
10
+ own the decision order for task creation, failures, timeout continuation,
11
+ terminal outcomes, pending interaction, and bounded collection. Read them
12
+ before interpreting these commands; pending publication alone is not a reason
13
+ to wait when the task needs an answer or timeout recovery.
@@ -0,0 +1,68 @@
1
+ # Managed workspace example
2
+
3
+ Use this example for independent write work that should be isolated in a
4
+ retained Git worktree. The source must be a Git checkout and the state root
5
+ must remain outside provider-writable workspaces.
6
+
7
+ ```sh
8
+ SOURCE="$PWD"
9
+ BRIEF="$(mktemp)"
10
+ RESPONSE="$(mktemp)"
11
+ printf '%s\n' 'Implement the requested change and report the files changed.' >"$BRIEF"
12
+
13
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
14
+ --brief "$BRIEF" --cwd "$SOURCE" \
15
+ --permission workspace-write --isolation git-worktree \
16
+ --base HEAD --workspace-budget 5m --budget 30m --json >"$RESPONSE"; then
17
+ dispatch_exit=0
18
+ else
19
+ dispatch_exit=$?
20
+ fi
21
+ printf '%s\n' "$dispatch_exit" >"$RESPONSE.exit"
22
+ cat "$RESPONSE"
23
+ ```
24
+
25
+ Read the saved JSON before running another command. When
26
+ `task_record: "created"`, use its `task_id` as `TASK_ID` below. When no task
27
+ was created, follow the [result decisions](../references/result-handling.md#managed-workspace-results);
28
+ do not run task status or collection against that nonexistent record.
29
+
30
+ ```sh
31
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" status TASK_ID --json >"$RESPONSE.status"; then
32
+ status_exit=0
33
+ else
34
+ status_exit=$?
35
+ fi
36
+ printf '%s\n' "$status_exit" >"$RESPONSE.status.exit"
37
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" collect TASK_ID --watch 5s --json >"$RESPONSE.collect"; then
38
+ collect_exit=0
39
+ else
40
+ collect_exit=$?
41
+ fi
42
+ printf '%s\n' "$collect_exit" >"$RESPONSE.collect.exit"
43
+ ```
44
+
45
+ Continue observing that created task when collection exits `3`. Wait for the
46
+ workspace to return to `state: retained` and inspect its final capture. Only
47
+ after the Lead explicitly chooses release, run:
48
+
49
+ ```sh
50
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" workspace release WORKSPACE_ID \
51
+ --budget 5m --json >"$RESPONSE.release"; then
52
+ release_exit=0
53
+ else
54
+ release_exit=$?
55
+ fi
56
+ printf '%s\n' "$release_exit" >"$RESPONSE.release.exit"
57
+ ```
58
+
59
+ Read the release acknowledgement. `watch_workspace` means observe this
60
+ accepted release; a `retry_release` acknowledgement means it was not accepted.
61
+ Follow the same result decisions rather than assuming either response is
62
+ completed cleanup.
63
+
64
+ Save each response and exit code once. A created task is observed with
65
+ `status` first and collected in the foreground. Exit `3` means pending, not
66
+ success; continue observing the same task. The Lead reviews the capture and
67
+ owns landing any changes. `workspace release` is explicit; no automatic
68
+ apply, commit, branch merge, TTL eviction, or provider-CLI fallback occurs.
@@ -1,5 +1,13 @@
1
1
  # Parallel reviews and debates
2
2
 
3
+ For independent parallel write work, choose `--isolation git-worktree`
4
+ automatically unless the user explicitly chooses shared coordination. The
5
+ model chooses fan-out and task scope; the supervisor has no fixed task-count
6
+ cap or TTL eviction. A read-only review may attach a retained workspace with
7
+ `--workspace ID`. The single managed-workspace policy, capture boundary, and
8
+ release rules live in [managed workspace guidance](workspaces.md); do not
9
+ restate them in each collaboration brief.
10
+
3
11
  ## Keep each request identifiable
4
12
 
5
13
  Choose the fan-out needed for the user's task. Each participant needs its own
@@ -19,18 +27,26 @@ RECEIPTS="$(mktemp -d)" || exit 1
19
27
  # Set these absolute paths and catalog IDs in this same tool invocation.
20
28
  # BRIEF_A and BRIEF_B contain the real independent assignments.
21
29
  (
22
- delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_A" \
30
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_A" \
23
31
  --brief "$BRIEF_A" --cwd "$WORKSPACE_A" \
24
32
  --permission read-only --budget 30m --json \
25
- >"$RECEIPTS/review-a.json" 2>"$RECEIPTS/review-a.stderr"
26
- printf '%s\n' "$?" >"$RECEIPTS/review-a.exit"
33
+ >"$RECEIPTS/review-a.json" 2>"$RECEIPTS/review-a.stderr"; then
34
+ dispatch_exit=0
35
+ else
36
+ dispatch_exit=$?
37
+ fi
38
+ printf '%s\n' "$dispatch_exit" >"$RECEIPTS/review-a.exit"
27
39
  ) &
28
40
  (
29
- delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_B" \
41
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --provider "$PROVIDER_B" \
30
42
  --brief "$BRIEF_B" --cwd "$WORKSPACE_B" \
31
43
  --permission read-only --budget 30m --json \
32
- >"$RECEIPTS/review-b.json" 2>"$RECEIPTS/review-b.stderr"
33
- printf '%s\n' "$?" >"$RECEIPTS/review-b.exit"
44
+ >"$RECEIPTS/review-b.json" 2>"$RECEIPTS/review-b.stderr"; then
45
+ dispatch_exit=0
46
+ else
47
+ dispatch_exit=$?
48
+ fi
49
+ printf '%s\n' "$dispatch_exit" >"$RECEIPTS/review-b.exit"
34
50
  ) &
35
51
  wait
36
52
  printf 'Read each response separately in %s\n' "$RECEIPTS"
@@ -3,25 +3,32 @@
3
3
  All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
4
4
  `--json` to commands that return an agent-consumable response.
5
5
 
6
+ Pass the intended workspace directly. Delegate handles provider launch options;
7
+ do not initialize Git, change trust settings, or call a provider CLI as a
8
+ workspace workaround. Ordinary tasks support non-Git directories. Git is
9
+ required for managed worktree creation/attachment only; native review retains
10
+ its separate explicit review-target contract. See [managed workspace guidance](workspaces.md)
11
+ for the policy owner.
12
+
6
13
  | Command | Purpose | Launches provider work? |
7
14
  | --- | --- | --- |
8
15
  | `delegate --version` | Confirm the installed control CLI | No |
9
- | `delegate providers --json` | List compiled provider metadata | No |
10
- | `delegate capabilities --provider ID --json` | Read the catalog contract | No |
11
- | `delegate models --provider ID [--cwd ABS] --json` | Discover advisory native model and effort facts | Native inspection only; no admitted task |
12
- | `delegate preflight --provider ID --cwd ABS --json` | Check static provider admission | No |
13
- | `delegate dispatch --auto ... --json` | Select and admit one bounded turn | Yes, at most once |
14
- | `delegate status TASK --json` | Reconcile and observe task state | No provider launch |
15
- | `delegate collect TASK --watch 5s --json` | Read or wait for publication | No provider launch |
16
- | `delegate recheck TASK --json` | Reassess eligible rejected evidence offline | No provider launch; original outcome unchanged |
17
- | `delegate continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
18
- | `delegate reply TASK --request ID --answers FILE --id MESSAGE_ID --json` | Answer a pending native question | No new launch |
19
- | `delegate steer TASK --brief FILE --id MESSAGE_ID --json` | Guide a supported active turn | No new launch |
20
- | `delegate events TASK --after SEQUENCE --watch 5s --json` | Read a bounded interaction event page | No |
21
- | `delegate logs TASK --json` | Return validated output descriptors | No |
22
- | `delegate cancel TASK --json` | Record one explicit stop request | Stops, does not relaunch |
23
-
24
- `delegate supervisor migrate --json` is the single command-neutral recovery
16
+ | `delegate --root ROOT providers --json` | List compiled provider metadata | No |
17
+ | `delegate --root ROOT capabilities --provider ID --json` | Read the catalog contract | No |
18
+ | `delegate --root ROOT models --provider ID [--cwd ABS] --json` | Discover advisory native model and effort facts | Native inspection only; no admitted task |
19
+ | `delegate --root ROOT preflight --provider ID --cwd ABS --json` | Check static provider admission | No |
20
+ | `delegate --root ROOT dispatch --auto ... --json` | Select and admit one bounded turn | Yes, at most once |
21
+ | `delegate --root ROOT status TASK --json` | Reconcile and observe task state | No provider launch |
22
+ | `delegate --root ROOT collect TASK --watch 5s --json` | Read or wait for publication | No provider launch |
23
+ | `delegate --root ROOT recheck TASK --json` | Reassess eligible rejected evidence offline | No provider launch; original outcome unchanged |
24
+ | `delegate --root ROOT continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
25
+ | `delegate --root ROOT reply TASK --request ID --answers FILE --id MESSAGE_ID --json` | Answer a pending native question | No new launch |
26
+ | `delegate --root ROOT steer TASK --brief FILE --id MESSAGE_ID --json` | Guide a supported active turn | No new launch |
27
+ | `delegate --root ROOT events TASK --after SEQUENCE --watch 5s --json` | Read a bounded interaction event page | No |
28
+ | `delegate --root ROOT logs TASK --json` | Return validated output descriptors | No |
29
+ | `delegate --root ROOT cancel TASK --json` | Record one explicit stop request | Stops, does not relaunch |
30
+
31
+ `delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" supervisor migrate --json` is the single command-neutral recovery
25
32
  step for a `supervisor_upgrade_required` admission response. Run it once with
26
33
  the failed command's exact root. A successful response names its next action
27
34
  `retry_dispatch`, but the original command and argv remain authoritative:
@@ -50,6 +57,35 @@ Dispatch flags:
50
57
  - `--interactive`: enable advertised native clarification and steering; see [interaction](interaction.md);
51
58
  - `--native-timeout DURATION`: optional provider-native timeout where advertised.
52
59
 
60
+ ## Managed workspace commands
61
+
62
+ Managed workspaces are optional. For independent parallel writes, choose
63
+ `--isolation git-worktree` unless the user explicitly chooses shared
64
+ coordination. The model chooses fan-out and task scope; there is no fixed task
65
+ count cap or TTL eviction. Use the canonical [workspace reference](workspaces.md)
66
+ for retention, capture, release, forgetting, and review-scope rules.
67
+
68
+ The public forms are:
69
+
70
+ ```sh
71
+ delegate --root ROOT dispatch --isolation git-worktree --cwd ABS \
72
+ [--base REV] [--workspace-budget DURATION] ... --json
73
+ delegate --root ROOT dispatch --workspace WORKSPACE_ID ... --json
74
+ delegate --root ROOT workspace list [--after ID] [--limit 1..50] --json
75
+ delegate --root ROOT workspace status ID [--operation OP] [--watch DURATION] --json
76
+ delegate --root ROOT workspace exec ID --budget DURATION -- ARGV...
77
+ delegate --root ROOT workspace release ID [--discard] [--budget DURATION] --json
78
+ delegate --root ROOT workspace forget ID [--budget DURATION] --json
79
+ ```
80
+
81
+ `--workspace` cannot be combined with public `--cwd`, `--base`, or
82
+ `--isolation`. `workspace exec` passes literal argv after `--` and initially
83
+ returns asynchronously; exit `3` means the operation is pending. The helper
84
+ budget defaults to 5m, is persisted/overridable, and does not renew the task
85
+ budget. `continue --task TASK` inherits the predecessor workspace, cwd, and
86
+ session while creating a new task ID. A read-only review may attach a retained
87
+ workspace with `--workspace ID`.
88
+
53
89
  Model discovery uses the same `--provider ID` profiles and accepts an optional
54
90
  absolute `--cwd` (default: current directory). Its JSON has `status` values
55
91
  `available`, `partial`, `blocked`, `unavailable`, or `failed`; exits are `0`,
@@ -72,7 +108,8 @@ is incomplete or does not list them. To resolve a natural-language model name
72
108
  or choose an option the caller left open, use native discovery:
73
109
 
74
110
  ```sh
75
- delegate models --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE --json
111
+ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" models \
112
+ --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE --json
76
113
  ```
77
114
 
78
115
  Omit `--cwd` to use the current directory. Run discovery only when the caller
@@ -106,7 +143,8 @@ Use `preflight` when the caller asks about static readiness, rather than as a
106
143
  required step before every dispatch:
107
144
 
108
145
  ```sh
109
- delegate preflight --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE \
146
+ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" preflight \
147
+ --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE \
110
148
  --permission REQUESTED_MODE --json
111
149
  ```
112
150
 
@@ -40,6 +40,19 @@ but it does not authorize a fresh dispatch. Apply the remaining `task_record`
40
40
  error rules in [result handling](result-handling.md) before retrying or
41
41
  observing.
42
42
 
43
+ When the predecessor is bound to a managed workspace, `continue --task` carries
44
+ the recorded workspace, working directory, provider session, and environment
45
+ to the new task ID. It does not mutate the predecessor's immutable request or
46
+ reservation. A changed provider request is a new turn and must pass the normal
47
+ workspace-use reservation. Read [managed workspace guidance](workspaces.md)
48
+ before attaching another provider, review, or verification operation.
49
+
50
+ If `continue` returns `workspace_busy` with `task_record: "not_created"` and
51
+ `next_action: "watch_workspace"`, observe that workspace with the same root.
52
+ Then retry the exact `continue --task PREDECESSOR_ID` after it becomes retained.
53
+ Keep the original predecessor, brief, and budget; do not replace continuation
54
+ with a fresh dispatch. A created successor is only observed.
55
+
43
56
  `mode` describes the provider contract:
44
57
 
45
58
  - `native` uses the provider’s exact persisted conversation/session ID;
@@ -53,3 +66,26 @@ terminal outcome or a durable Pueue-ended observation backed by a guardian
53
66
  lifetime-termination record with independently proven empty scope for the
54
67
  session handoff; without one of those proofs it refuses continuation. Inspect
55
68
  the predecessor again rather than bypassing that boundary.
69
+
70
+ For a managed workspace timeout, capture is a new finite auxiliary operation
71
+ after canonical closure. The normal path proves the provider scope empty and
72
+ records the managed worker's exact `Wait`; recovery can instead use a validated
73
+ absence disposition or previous-boot termination without inventing a native
74
+ `Wait`. Capture never renews the expired provider deadline or reuses its scope. Closure with an
75
+ unavailable capture can still preserve continuation evidence; it does not
76
+ change the provider outcome.
77
+
78
+
79
+ ## Follow up after normal completion
80
+
81
+ A validated terminal outcome, committed or rejected, can also support a new
82
+ turn when the provider supports continuation, its exact session was recorded,
83
+ and the runner/session reservation has been released. Not every rejection has
84
+ a usable session. A normal completion without a budget stop need not expose
85
+ `continuation.resumable` in `status` or `collect`. Use `continue` with the exact
86
+ predecessor and a finite budget, then apply its task-creation and failure
87
+ response as described in [result handling](result-handling.md).
88
+
89
+ If the response says `stop_and_report`, stop that attempt; do not automatically
90
+ retry it. A caller may make a later request after observing the predecessor.
91
+ Native `codex:review` tasks cannot be continued.
@@ -13,8 +13,11 @@ the same as a successful provider result.
13
13
  `supervisor_control.next_action: "retry_dispatch"`, retry the exact original
14
14
  admission argv once. The retry is command-neutral: `dispatch` remains
15
15
  `dispatch`, and `continue` remains `continue`; never create a fresh dispatch
16
- or call a provider directly to replace a failed continuation. For every
17
- other `not_created` response, do not poll; correct the request only if
16
+ or call a provider directly to replace a failed continuation. Also handle
17
+ `workspace_provision_pending` or `workspace_busy` with `watch_workspace`
18
+ using [managed workspace recovery](#managed-workspace-results) before the
19
+ generic stop rule. For every other `not_created` response, do not poll;
20
+ correct the request only if
18
21
  `failure.next_action` is `correct_request`, otherwise report and stop. When
19
22
  `task_record` is `unknown`, stop and report without polling or retrying.
20
23
  Status and collect can report `admission: "unknown"` alongside valid terminal
@@ -68,6 +71,47 @@ Versions and help are observations, not semantic-version allowlists.
68
71
  Authentication is a separate live gate (`not_run`, `passed`, or `blocked`).
69
72
  Report a blocked prerequisite without inventing a login command or retrying.
70
73
 
74
+ ## Managed workspace results
75
+
76
+ Treat `response.workspace` as a separate resource and Git-content evidence
77
+ projection. It does not replace `outcome`, `publication`, or `continuation`.
78
+ The provider outcome is immutable and the workspace `CaptureReceipt` is a
79
+ separate immutable fact; a failed or unavailable capture must not be reported
80
+ as a provider failure when native closure is already proven.
81
+
82
+ Before a task record exists, a pending workspace provision returns
83
+ `task_record: "not_created"` with
84
+ `failure.code: "workspace_provision_pending"` and
85
+ `failure.next_action: "watch_workspace"`. Run the returned workspace-status
86
+ command with the same root and workspace ID. Once ready, retry the same
87
+ admission with the returned task ID in `--id` and unchanged provider, brief,
88
+ permission, model, effort, and source options. A proven never-launched attempt
89
+ gets a fresh helper deadline; a created task is only observed.
90
+
91
+ An occupied managed workspace can return `workspace_busy` with
92
+ `task_record: "not_created"` and `watch_workspace` before authorizing a task.
93
+ Observe the owning workspace, then retry the exact original admission command.
94
+ For `continue`, keep `continue --task PREDECESSOR_ID`; never replace it with a
95
+ dispatch. These two workspace responses are narrow exceptions to the generic
96
+ stop rule. Do not invent another recovery code or provider retry.
97
+
98
+ Read the acknowledgement before observing or repeating a workspace mutation:
99
+
100
+ | Response | Required action |
101
+ | --- | --- |
102
+ | Exit `3`, reason `requested_action_not_authorized`, next action `retry_exec`, `retry_release`, or `retry_forget` | The requested mutation was not accepted. Observe the workspace without `--operation` until the prior use ends, then retry that exact mutation. `exec` and `release` need `state: retained`; `forget` needs `state: released`. |
103
+ | Exit `3`, next action `watch_workspace` | The action is accepted. Observe the same workspace; add `--operation OP` only when its response supplies `operation_id`. Do not repeat the mutation or invent an operation ID. |
104
+ | A concrete failure or `stop_and_report` | Preserve the response and report it; do not turn it into a pending watch or provider fallback. |
105
+
106
+ Use `workspace status ID [--operation OP] --watch DURATION --json` for these
107
+ observations. An accepted action may not have a helper ID yet. An `exec`
108
+ result of `succeeded` proves the command finished; wait for `state: retained`
109
+ before another use, because recapture must finish too. Verification evidence
110
+ does not replace the provider outcome. Keep the checkout retained until the
111
+ Lead has terminal task/capture evidence and explicitly releases it. Read
112
+ [managed workspace guidance](workspaces.md) for the exact command surface and
113
+ review/capture/forgetting boundaries.
114
+
71
115
  ## Offline recovery
72
116
 
73
117
  When Delegate returns `failure.next_action: "recheck"`, use the same root and