delegation-layer 0.1.21 → 0.1.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "delegation-layer",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
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",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "delegation-layer",
3
3
  "displayName": "Delegation Layer",
4
- "version": "0.1.21",
4
+ "version": "0.1.22",
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.21",
3
+ "version": "0.1.22",
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",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agent-integration
3
- description: Coordinate external agent, model, and separate harness tasks through Delegate, including research, implementation, tests, reviews, consultations, comparisons, and debates. Use before choosing an external integration; ordinary native subagents and questions about tools remain local.
3
+ description: Use Delegate for work assigned to another agent, model, or separate harness CLI session. Load this before a provider-specific skill or plugin, including when a user names a CLI for research, implementation, tests, reviews, consultations, comparisons, or debates. A named destination still routes through Delegate. Ordinary same-harness subagents and questions about tools remain local; respect an explicit choice of another integration.
4
4
  ---
5
5
 
6
6
  # Delegation Layer
@@ -13,6 +13,8 @@ external harness to do work. Requests such as “ask Codex to review this”,
13
13
  collaboration even when the user never mentions Delegate. The same applies
14
14
  when you decide external expertise is useful to fulfill the user's task.
15
15
  These names are examples; discover supported destinations through the CLI.
16
+ A destination name identifies who should do the work; it does not by itself
17
+ select a provider-specific skill, plugin, or direct CLI integration.
16
18
  “Claude Code Router” and “CCR” mean `ccr:print`, not ordinary Claude Code.
17
19
  For that request, use Delegate with a CCR model alias; a Claude-specific skill
18
20
  or subscription model does not fulfill the requested route.
@@ -36,8 +38,10 @@ not turn that request into an environment-repair task. When a response says
36
38
  `failure.next_action: "stop_and_report"`, that attempt is finished. Include its
37
39
  failure in your final response without opening a clarification dialog to choose
38
40
  a fallback. For `task_record: not_created`, identify the requested destination
39
- and quote the returned `task_id` (if present), `task_record`, `failure`, and
40
- `error`. Do not append inferred state paths or provider-setup diagnoses. Do not run diagnostic commands, retry it, or use another integration.
41
+ and include the saved JSON failure response verbatim. A `task_id` can be returned
42
+ even when no task record was created. Do not infer that an unavailable provider
43
+ is uninstalled or unauthenticated. Do not append inferred state paths or
44
+ provider-setup diagnoses, run diagnostic commands, retry it, or use another integration.
41
45
  Troubleshooting requires a separate user request. Other independently requested
42
46
  tasks may proceed; the failed attempt must remain reported as failed or blocked.
43
47
 
@@ -79,18 +83,23 @@ tasks may proceed; the failed attempt must remain reported as failed or blocked.
79
83
  Collection may recover the
80
84
  saved supervisor only to observe an already-requested budget stop; it never
81
85
  launches a provider or retries a task.
82
- 6. If a task is timed out and its JSON says `continuation.resumable: true`, use
86
+ 6. If `failure.next_action` is `recheck`, follow
87
+ [offline recovery](references/result-handling.md#offline-recovery) once for
88
+ that task. Rechecking saved evidence does not run the provider again.
89
+ Otherwise, report a rejected result without redispatching or reading raw
90
+ output as an answer.
91
+ 7. If a task is timed out and its JSON says `continuation.resumable: true`, use
83
92
  `continue --task TASK_ID`, optionally with a new `--brief`. Do not create a
84
93
  fresh unrelated dispatch to replace a resumable task.
85
- 7. Treat `blocked` authentication as unresolved. Do not call it compatible,
94
+ 8. Treat `blocked` authentication as unresolved. Do not call it compatible,
86
95
  successful, or failed provider behavior, and do not invent login commands.
87
- 8. Never put credentials, tokens, or unrestricted provider output in a brief,
96
+ 9. Never put credentials, tokens, or unrestricted provider output in a brief,
88
97
  option, receipt, or agent message.
89
- 9. Permission modes select provider-native behavior, not an independent sandbox.
98
+ 10. Permission modes select provider-native behavior, not an independent sandbox.
90
99
  Providers load their own configuration and extensions. If a task is rejected,
91
100
  report delegate's evidence; do not assume the user's configuration is faulty
92
101
  or remove MCP servers, plugins, settings, or credentials to make it pass.
93
- 10. The model chooses ordinary-task fan-out by issuing independent `dispatch`
102
+ 11. The model chooses ordinary-task fan-out by issuing independent `dispatch`
94
103
  commands concurrently. The private supervisor does not impose a task-count
95
104
  or CPU-based limit. Use this for independent investigation, debate, review,
96
105
  or provider comparison. Concurrent write tasks must use separate workspaces
@@ -162,6 +171,8 @@ Use an existing task brief when one is supplied. Otherwise create a bounded
162
171
  brief file that contains the requested work and its acceptance criteria. Keep
163
172
  the state root outside the workspace and provider-writable trees (which can
164
173
  include the system temporary directory). Use `DELEGATE_ROOT` when supplied.
174
+ Pass a regular file path for `--brief`, not shell process substitution such as
175
+ `<(...)` or an ephemeral `/dev/fd/...` path.
165
176
 
166
177
  Run path preparation and dispatch in **one shell/tool invocation**, as shown
167
178
  below. Shell variables may disappear between tool calls. For later commands,
@@ -190,7 +201,10 @@ when waiting, replying, steering, or continuing.
190
201
 
191
202
  Use automatic selection unless the user named a destination.
192
203
  For a named harness or provider resolved in step 2, replace `--auto` with `--provider PROVIDER_ID`; never
193
- combine the two:
204
+ combine the two.
205
+
206
+ Capture the dispatch exit code with `if`, as below. This prints the response
207
+ even when dispatch fails and the surrounding shell has `set -e` enabled.
194
208
 
195
209
  ```sh
196
210
  WORKSPACE="$PWD"
@@ -200,13 +214,17 @@ cat >"$BRIEF" <<'EOF'
200
214
  Describe the delegated task, the files or behavior to change, and the checks
201
215
  that must pass. Keep the response concise and report validation evidence.
202
216
  EOF
203
- delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
217
+ printf 'Saved response: %s\n' "$RESPONSE"
218
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
204
219
  --brief "$BRIEF" \
205
220
  --cwd "$WORKSPACE" \
206
221
  --permission read-only \
207
222
  --budget 30m \
208
- --json >"$RESPONSE"
209
- dispatch_exit=$?
223
+ --json >"$RESPONSE"; then
224
+ dispatch_exit=0
225
+ else
226
+ dispatch_exit=$?
227
+ fi
210
228
  cat "$RESPONSE"
211
229
  printf '\nDispatch exit: %s; saved response: %s\n' "$dispatch_exit" "$RESPONSE"
212
230
  ```
@@ -199,6 +199,32 @@
199
199
  ],
200
200
  "split": "validation"
201
201
  },
202
+ {
203
+ "name": "recheck-recoverable",
204
+ "prompt": "Ask a separate Codex CLI session to review pricing.py against README.md without editing. If the terminal result is rejected with failure.next_action=recheck, recheck the same task once and report only the verified recovered answer.",
205
+ "external": true,
206
+ "provider": "codex:exec",
207
+ "fixture_scenario": "recoverable-rejection",
208
+ "holdout": true,
209
+ "split": "validation"
210
+ },
211
+ {
212
+ "name": "recheck-still-rejected",
213
+ "prompt": "Ask a separate Codex CLI session to review pricing.py against README.md without editing. If the terminal result is rejected with failure.next_action=recheck, recheck the same task once and report the rejection without using raw output as an answer.",
214
+ "external": true,
215
+ "provider": "codex:exec",
216
+ "fixture_scenario": "still-rejected-recheck",
217
+ "holdout": true,
218
+ "split": "validation"
219
+ },
220
+ {
221
+ "name": "external-collaboration-holdout",
222
+ "prompt": "Ask a separate Codex CLI session to review pricing.py against README.md and report its finding without editing.",
223
+ "external": true,
224
+ "provider": "codex:exec",
225
+ "holdout": true,
226
+ "split": "validation"
227
+ },
202
228
  {
203
229
  "name": "requested-model-effort",
204
230
  "prompt": "Ask a separate Codex CLI session to review pricing.py without edits. Use model gpt-5.6-luna and effort max, preserving both choices.",
@@ -13,6 +13,7 @@ All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
13
13
  | `delegate dispatch --auto ... --json` | Select and admit one bounded turn | Yes, at most once |
14
14
  | `delegate status TASK --json` | Reconcile and observe task state | No provider launch |
15
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 |
16
17
  | `delegate continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
17
18
  | `delegate reply TASK --request ID --answers FILE --id MESSAGE_ID --json` | Answer a pending native question | No new launch |
18
19
  | `delegate steer TASK --brief FILE --id MESSAGE_ID --json` | Guide a supported active turn | No new launch |
@@ -15,8 +15,9 @@ the same as a successful provider result.
15
15
  permits a linked successor even when no outcome has been published.
16
16
  4. If `publication` is committed and `outcome.verdict` is committed, return
17
17
  the result and its payload/evidence descriptors.
18
- 5. If `outcome.verdict` is rejected, report a terminal rejected result with its
19
- refusal and evidence. Do not retry automatically.
18
+ 5. If `outcome.verdict` is rejected and `failure.next_action` is `recheck`,
19
+ follow [offline recovery](#offline-recovery) once. Otherwise report the
20
+ terminal rejection with its diagnostic and evidence. Do not redispatch.
20
21
  6. If `pending.kind` is `interaction`, handle the returned questions using
21
22
  [interaction guidance](interaction.md) before waiting again. Otherwise, if
22
23
  `liveness` is queued or running or publication is pending, observe the same
@@ -44,3 +45,29 @@ checks static readiness; runtime verification requires the supervised probe.
44
45
  Versions and help are observations, not semantic-version allowlists.
45
46
  Authentication is a separate live gate (`not_run`, `passed`, or `blocked`).
46
47
  Report a blocked prerequisite without inventing a login command or retrying.
48
+
49
+ ## Offline recovery
50
+
51
+ When Delegate returns `failure.next_action: "recheck"`, use the same root and
52
+ exact task ID:
53
+
54
+ ```sh
55
+ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" recheck TASK_ID --json
56
+ ```
57
+
58
+ This command checks the already sealed evidence with an explicitly compatible
59
+ new interpreter. It does not run the provider, contact a service, spend model
60
+ tokens, or change the original outcome.
61
+
62
+ - Exit `0` with `recheck.status: "recovered"`: use only the answer descriptor
63
+ returned for that recheck. Report that the answer was recovered from saved
64
+ evidence. The original `publication` remains `rejected`; do not call the
65
+ original task committed or use recovery to infer continuation permission.
66
+ - Exit `4` with `recheck.status: "rejected"`: report the diagnostic and stop.
67
+ - Exit `1` or `2`, or any response without a verified recovered answer:
68
+ report the error and stop. Do not read raw streams as a substitute answer,
69
+ invent a result path, run a provider directly, or launch a replacement task.
70
+
71
+ Keep the assessment ID and source/target descriptors with the result. Do not
72
+ loop on the same recheck. A separate user request is required for further
73
+ troubleshooting or a new provider task.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agent-integration
3
- description: Coordinate external agent, model, and separate harness tasks through Delegate, including research, implementation, tests, reviews, consultations, comparisons, and debates. Use before choosing an external integration; ordinary native subagents and questions about tools remain local.
3
+ description: Use Delegate for work assigned to another agent, model, or separate harness CLI session. Load this before a provider-specific skill or plugin, including when a user names a CLI for research, implementation, tests, reviews, consultations, comparisons, or debates. A named destination still routes through Delegate. Ordinary same-harness subagents and questions about tools remain local; respect an explicit choice of another integration.
4
4
  ---
5
5
 
6
6
  # Delegation Layer
@@ -13,6 +13,8 @@ external harness to do work. Requests such as “ask Codex to review this”,
13
13
  collaboration even when the user never mentions Delegate. The same applies
14
14
  when you decide external expertise is useful to fulfill the user's task.
15
15
  These names are examples; discover supported destinations through the CLI.
16
+ A destination name identifies who should do the work; it does not by itself
17
+ select a provider-specific skill, plugin, or direct CLI integration.
16
18
  “Claude Code Router” and “CCR” mean `ccr:print`, not ordinary Claude Code.
17
19
  For that request, use Delegate with a CCR model alias; a Claude-specific skill
18
20
  or subscription model does not fulfill the requested route.
@@ -36,8 +38,10 @@ not turn that request into an environment-repair task. When a response says
36
38
  `failure.next_action: "stop_and_report"`, that attempt is finished. Include its
37
39
  failure in your final response without opening a clarification dialog to choose
38
40
  a fallback. For `task_record: not_created`, identify the requested destination
39
- and quote the returned `task_id` (if present), `task_record`, `failure`, and
40
- `error`. Do not append inferred state paths or provider-setup diagnoses. Do not run diagnostic commands, retry it, or use another integration.
41
+ and include the saved JSON failure response verbatim. A `task_id` can be returned
42
+ even when no task record was created. Do not infer that an unavailable provider
43
+ is uninstalled or unauthenticated. Do not append inferred state paths or
44
+ provider-setup diagnoses, run diagnostic commands, retry it, or use another integration.
41
45
  Troubleshooting requires a separate user request. Other independently requested
42
46
  tasks may proceed; the failed attempt must remain reported as failed or blocked.
43
47
 
@@ -79,18 +83,23 @@ tasks may proceed; the failed attempt must remain reported as failed or blocked.
79
83
  Collection may recover the
80
84
  saved supervisor only to observe an already-requested budget stop; it never
81
85
  launches a provider or retries a task.
82
- 6. If a task is timed out and its JSON says `continuation.resumable: true`, use
86
+ 6. If `failure.next_action` is `recheck`, follow
87
+ [offline recovery](references/result-handling.md#offline-recovery) once for
88
+ that task. Rechecking saved evidence does not run the provider again.
89
+ Otherwise, report a rejected result without redispatching or reading raw
90
+ output as an answer.
91
+ 7. If a task is timed out and its JSON says `continuation.resumable: true`, use
83
92
  `continue --task TASK_ID`, optionally with a new `--brief`. Do not create a
84
93
  fresh unrelated dispatch to replace a resumable task.
85
- 7. Treat `blocked` authentication as unresolved. Do not call it compatible,
94
+ 8. Treat `blocked` authentication as unresolved. Do not call it compatible,
86
95
  successful, or failed provider behavior, and do not invent login commands.
87
- 8. Never put credentials, tokens, or unrestricted provider output in a brief,
96
+ 9. Never put credentials, tokens, or unrestricted provider output in a brief,
88
97
  option, receipt, or agent message.
89
- 9. Permission modes select provider-native behavior, not an independent sandbox.
98
+ 10. Permission modes select provider-native behavior, not an independent sandbox.
90
99
  Providers load their own configuration and extensions. If a task is rejected,
91
100
  report delegate's evidence; do not assume the user's configuration is faulty
92
101
  or remove MCP servers, plugins, settings, or credentials to make it pass.
93
- 10. The model chooses ordinary-task fan-out by issuing independent `dispatch`
102
+ 11. The model chooses ordinary-task fan-out by issuing independent `dispatch`
94
103
  commands concurrently. The private supervisor does not impose a task-count
95
104
  or CPU-based limit. Use this for independent investigation, debate, review,
96
105
  or provider comparison. Concurrent write tasks must use separate workspaces
@@ -162,6 +171,8 @@ Use an existing task brief when one is supplied. Otherwise create a bounded
162
171
  brief file that contains the requested work and its acceptance criteria. Keep
163
172
  the state root outside the workspace and provider-writable trees (which can
164
173
  include the system temporary directory). Use `DELEGATE_ROOT` when supplied.
174
+ Pass a regular file path for `--brief`, not shell process substitution such as
175
+ `<(...)` or an ephemeral `/dev/fd/...` path.
165
176
 
166
177
  Run path preparation and dispatch in **one shell/tool invocation**, as shown
167
178
  below. Shell variables may disappear between tool calls. For later commands,
@@ -190,7 +201,10 @@ when waiting, replying, steering, or continuing.
190
201
 
191
202
  Use automatic selection unless the user named a destination.
192
203
  For a named harness or provider resolved in step 2, replace `--auto` with `--provider PROVIDER_ID`; never
193
- combine the two:
204
+ combine the two.
205
+
206
+ Capture the dispatch exit code with `if`, as below. This prints the response
207
+ even when dispatch fails and the surrounding shell has `set -e` enabled.
194
208
 
195
209
  ```sh
196
210
  WORKSPACE="$PWD"
@@ -200,13 +214,17 @@ cat >"$BRIEF" <<'EOF'
200
214
  Describe the delegated task, the files or behavior to change, and the checks
201
215
  that must pass. Keep the response concise and report validation evidence.
202
216
  EOF
203
- delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
217
+ printf 'Saved response: %s\n' "$RESPONSE"
218
+ if delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" dispatch --auto \
204
219
  --brief "$BRIEF" \
205
220
  --cwd "$WORKSPACE" \
206
221
  --permission read-only \
207
222
  --budget 30m \
208
- --json >"$RESPONSE"
209
- dispatch_exit=$?
223
+ --json >"$RESPONSE"; then
224
+ dispatch_exit=0
225
+ else
226
+ dispatch_exit=$?
227
+ fi
210
228
  cat "$RESPONSE"
211
229
  printf '\nDispatch exit: %s; saved response: %s\n' "$dispatch_exit" "$RESPONSE"
212
230
  ```
@@ -199,6 +199,32 @@
199
199
  ],
200
200
  "split": "validation"
201
201
  },
202
+ {
203
+ "name": "recheck-recoverable",
204
+ "prompt": "Ask a separate Codex CLI session to review pricing.py against README.md without editing. If the terminal result is rejected with failure.next_action=recheck, recheck the same task once and report only the verified recovered answer.",
205
+ "external": true,
206
+ "provider": "codex:exec",
207
+ "fixture_scenario": "recoverable-rejection",
208
+ "holdout": true,
209
+ "split": "validation"
210
+ },
211
+ {
212
+ "name": "recheck-still-rejected",
213
+ "prompt": "Ask a separate Codex CLI session to review pricing.py against README.md without editing. If the terminal result is rejected with failure.next_action=recheck, recheck the same task once and report the rejection without using raw output as an answer.",
214
+ "external": true,
215
+ "provider": "codex:exec",
216
+ "fixture_scenario": "still-rejected-recheck",
217
+ "holdout": true,
218
+ "split": "validation"
219
+ },
220
+ {
221
+ "name": "external-collaboration-holdout",
222
+ "prompt": "Ask a separate Codex CLI session to review pricing.py against README.md and report its finding without editing.",
223
+ "external": true,
224
+ "provider": "codex:exec",
225
+ "holdout": true,
226
+ "split": "validation"
227
+ },
202
228
  {
203
229
  "name": "requested-model-effort",
204
230
  "prompt": "Ask a separate Codex CLI session to review pricing.py without edits. Use model gpt-5.6-luna and effort max, preserving both choices.",
@@ -13,6 +13,7 @@ All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
13
13
  | `delegate dispatch --auto ... --json` | Select and admit one bounded turn | Yes, at most once |
14
14
  | `delegate status TASK --json` | Reconcile and observe task state | No provider launch |
15
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 |
16
17
  | `delegate continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
17
18
  | `delegate reply TASK --request ID --answers FILE --id MESSAGE_ID --json` | Answer a pending native question | No new launch |
18
19
  | `delegate steer TASK --brief FILE --id MESSAGE_ID --json` | Guide a supported active turn | No new launch |
@@ -15,8 +15,9 @@ the same as a successful provider result.
15
15
  permits a linked successor even when no outcome has been published.
16
16
  4. If `publication` is committed and `outcome.verdict` is committed, return
17
17
  the result and its payload/evidence descriptors.
18
- 5. If `outcome.verdict` is rejected, report a terminal rejected result with its
19
- refusal and evidence. Do not retry automatically.
18
+ 5. If `outcome.verdict` is rejected and `failure.next_action` is `recheck`,
19
+ follow [offline recovery](#offline-recovery) once. Otherwise report the
20
+ terminal rejection with its diagnostic and evidence. Do not redispatch.
20
21
  6. If `pending.kind` is `interaction`, handle the returned questions using
21
22
  [interaction guidance](interaction.md) before waiting again. Otherwise, if
22
23
  `liveness` is queued or running or publication is pending, observe the same
@@ -44,3 +45,29 @@ checks static readiness; runtime verification requires the supervised probe.
44
45
  Versions and help are observations, not semantic-version allowlists.
45
46
  Authentication is a separate live gate (`not_run`, `passed`, or `blocked`).
46
47
  Report a blocked prerequisite without inventing a login command or retrying.
48
+
49
+ ## Offline recovery
50
+
51
+ When Delegate returns `failure.next_action: "recheck"`, use the same root and
52
+ exact task ID:
53
+
54
+ ```sh
55
+ delegate --root "${DELEGATE_ROOT:-$HOME/delegation-state}" recheck TASK_ID --json
56
+ ```
57
+
58
+ This command checks the already sealed evidence with an explicitly compatible
59
+ new interpreter. It does not run the provider, contact a service, spend model
60
+ tokens, or change the original outcome.
61
+
62
+ - Exit `0` with `recheck.status: "recovered"`: use only the answer descriptor
63
+ returned for that recheck. Report that the answer was recovered from saved
64
+ evidence. The original `publication` remains `rejected`; do not call the
65
+ original task committed or use recovery to infer continuation permission.
66
+ - Exit `4` with `recheck.status: "rejected"`: report the diagnostic and stop.
67
+ - Exit `1` or `2`, or any response without a verified recovered answer:
68
+ report the error and stop. Do not read raw streams as a substitute answer,
69
+ invent a result path, run a provider directly, or launch a replacement task.
70
+
71
+ Keep the assessment ID and source/target descriptors with the result. Do not
72
+ loop on the same recheck. A separate user request is required for further
73
+ troubleshooting or a new provider task.