delegation-layer 0.1.16 → 0.1.18

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 (22) hide show
  1. package/README.md +47 -4
  2. package/install.sh +37 -6
  3. package/package.json +2 -1
  4. package/plugins/delegation-layer/.claude-plugin/plugin.json +22 -0
  5. package/plugins/delegation-layer/.codex-plugin/plugin.json +33 -0
  6. package/plugins/delegation-layer/hooks/hooks.json +14 -0
  7. package/plugins/delegation-layer/scripts/ensure-delegate.sh +123 -0
  8. package/plugins/delegation-layer/scripts/install-cli.sh +108 -0
  9. package/plugins/delegation-layer/skills/agent-integration/SKILL.md +251 -0
  10. package/plugins/delegation-layer/skills/agent-integration/evals/evals.json +61 -0
  11. package/plugins/delegation-layer/skills/agent-integration/evals/routing.json +155 -0
  12. package/plugins/delegation-layer/skills/agent-integration/examples/json-results.md +14 -0
  13. package/plugins/delegation-layer/skills/agent-integration/examples/read-only-task.md +12 -0
  14. package/plugins/delegation-layer/skills/agent-integration/examples/workspace-write-task.md +14 -0
  15. package/plugins/delegation-layer/skills/agent-integration/references/command-reference.md +80 -0
  16. package/plugins/delegation-layer/skills/agent-integration/references/continuation.md +49 -0
  17. package/plugins/delegation-layer/skills/agent-integration/references/result-handling.md +44 -0
  18. package/skills/agent-integration/SKILL.md +80 -124
  19. package/skills/agent-integration/evals/routing.json +155 -0
  20. package/skills/agent-integration/references/command-reference.md +31 -1
  21. package/skills/agent-integration/references/continuation.md +4 -1
  22. package/skills/agent-integration/references/result-handling.md +14 -7
@@ -0,0 +1,251 @@
1
+ ---
2
+ name: agent-integration
3
+ description: Consult external AI agents and harnesses through Delegate for reviews, research, implementation, testing, second opinions, comparisons, and debates. Use when asked to ask Codex, consult Claude, get Antigravity’s opinion, or assign work to another harness or model, including external collaboration you choose during a task. Not for ordinary native subagents, provider setup, or questions merely about a tool.
4
+ ---
5
+
6
+ # Delegation Layer
7
+
8
+ ## When to use
9
+
10
+ Use this skill before selecting a provider-specific plugin or launching an
11
+ external harness to do work. Requests such as “ask Codex to review this”,
12
+ “get Antigravity’s opinion”, and “have Claude investigate” are external
13
+ collaboration even when the user never mentions Delegate. The same applies
14
+ when you decide external expertise is useful to fulfill the user's task.
15
+ These names are examples; discover supported destinations through the CLI.
16
+
17
+ Ordinary subagents within the current harness remain available. Naming the
18
+ current harness (for example, “have Claude investigate” while using Claude)
19
+ also permits native delegation unless the user requests a separate session.
20
+ A separate CLI session uses Delegate even when its brand matches yours. A subagent
21
+ or plugin that calls an external harness is still external collaboration and
22
+ uses Delegate. Merely discussing a provider, editing documentation about it,
23
+ or troubleshooting its installation does not trigger delegation. Respect an
24
+ explicit user choice of another integration; this skill does not override it.
25
+
26
+ The local `delegate` CLI is the integration surface for external work. Do not
27
+ replace it with a provider command, a provider-specific plugin, or an API call.
28
+ Do not inspect, authenticate, install, or repair provider CLIs to bypass a
29
+ Delegate blocker.
30
+
31
+ ## Rules
32
+
33
+ 1. Check whether `delegate` is already installed. A plugin SessionStart hook
34
+ normally bootstraps the self-contained CLI when it is missing. This skill
35
+ never installs or repairs the CLI itself. If `delegate` is still missing or
36
+ unusable, report the bootstrap failure and stop; never fall back to a native
37
+ provider command.
38
+ 2. Preserve a named harness or provider, even when the user supplied a natural
39
+ name rather than a provider ID. Use `dispatch --auto` when none was chosen.
40
+ Provider selection, executable checks, compatibility checks, authentication
41
+ gates, and supervisor admission belong inside Delegation Layer.
42
+ 3. Give every turn an absolute workspace, a separate state root, an explicit
43
+ permission mode, and a finite budget. Preserve a caller-supplied
44
+ `DELEGATE_ROOT`; do not replace it with a temporary directory.
45
+ 4. Use `--json` and save the returned `task_id`. Read `admission`, `liveness`,
46
+ `publication`, `status`, `outcome`, `continuation`, `task_record`, `failure`,
47
+ and `error` as separate fields.
48
+ Delegate owns the supervisor lifecycle. Never install, configure, start,
49
+ inspect, or repair Pueue, and never poll a task unless the response says its
50
+ `task_record` is `created`.
51
+ 5. Observe with `status` and collect with `collect`. Collection may recover the
52
+ saved supervisor only to observe an already-requested budget stop; it never
53
+ launches a provider or retries a task.
54
+ 6. If a task is timed out and its JSON says `continuation.resumable: true`, use
55
+ `continue --task TASK_ID`, optionally with a new `--brief`. Do not create a
56
+ fresh unrelated dispatch to replace a resumable task.
57
+ 7. Treat `blocked` authentication as unresolved. Do not call it compatible,
58
+ successful, or failed provider behavior, and do not invent login commands.
59
+ 8. Never put credentials, tokens, or unrestricted provider output in a brief,
60
+ option, receipt, or agent message.
61
+ 9. Permission modes select provider-native behavior, not an independent sandbox.
62
+ Providers load their own configuration and extensions. If a task is rejected,
63
+ report delegate's evidence; do not assume the user's configuration is faulty
64
+ or remove MCP servers, plugins, settings, or credentials to make it pass.
65
+ 10. The model chooses ordinary-task fan-out by issuing independent `dispatch`
66
+ commands concurrently. The private supervisor does not impose a task-count
67
+ or CPU-based limit. Use this for independent investigation, debate, review,
68
+ or provider comparison. Concurrent write tasks must use separate workspaces
69
+ or explicit coordination to avoid file conflicts.
70
+
71
+ ## Operating procedure
72
+
73
+ ### 1. Verify the control CLI
74
+
75
+ Run a quick local check:
76
+
77
+ ```sh
78
+ command -v delegate && delegate --version
79
+ ```
80
+
81
+ If discovery fails, report that Delegation Layer is missing. If the version
82
+ command fails, report that the installed CLI is unusable. Stop in either case.
83
+ Do not substitute a provider command.
84
+
85
+ ### 2. Discover only when useful
86
+
87
+ If no destination was named, use automatic selection directly. If the user
88
+ named a harness (for example, “Codex”), resolve its exact provider ID from:
89
+
90
+ ```sh
91
+ delegate providers --json
92
+ ```
93
+
94
+ Use the matching catalog ID with `--provider`; do not silently substitute
95
+ `--auto` or another provider. If the name is ambiguous, clarify the intended
96
+ destination. If it is absent, report that this build does not support it.
97
+ The catalog is not proof that a provider is installed, authenticated, or ready.
98
+ If a side-effect-free readiness check is useful,
99
+ run:
100
+
101
+ ```sh
102
+ delegate preflight --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE \
103
+ --permission REQUESTED_MODE --json
104
+ ```
105
+
106
+ Replace `REQUESTED_MODE` with `read-only` for investigation or
107
+ `workspace-write` for authorized edits. Preflight reports static admission only.
108
+ It does not create a task, start the supervisor, or launch a provider. Do not keep
109
+ retrying preflight when it says
110
+ `blocked` or `unsupported`; report the bounded reason.
111
+
112
+ The catalog and `capabilities` response expose supported permission modes,
113
+ request options, continuation, and the read-only mechanism. A read-only
114
+ capability with `containment: "provider-owned"` selects the provider's native
115
+ behavior but is not an independent delegate-owned sandbox. Static discovery
116
+ does not prove authentication or live acceptance; use the dispatch or live
117
+ acceptance result for that evidence.
118
+
119
+ Keep provider defaults when no model or effort was requested. When an explicit
120
+ choice is needed, read [model and effort guidance](references/command-reference.md#choosing-models-and-effort).
121
+ Pass requested choices through Delegate's public `--model` and `--effort`
122
+ fields; discovery is advisory, never an allowlist.
123
+
124
+ ### 3. Prepare separate paths and a finite brief
125
+
126
+ Use an existing task brief when one is supplied. Otherwise create a bounded
127
+ brief file that contains the requested work and its acceptance criteria. Keep
128
+ the state root outside the workspace and provider-writable trees (which can
129
+ include the system temporary directory). Use `DELEGATE_ROOT` when supplied:
130
+
131
+ ```sh
132
+ STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
133
+ WORKSPACE="$PWD"
134
+ BRIEF="$(mktemp)"
135
+ cat >"$BRIEF" <<'EOF'
136
+ Describe the delegated task, the files or behavior to change, and the checks
137
+ that must pass. Keep the response concise and report validation evidence.
138
+ EOF
139
+ ```
140
+
141
+ Replace the example brief with the actual user request. Do not place the state
142
+ root inside the workspace or place secrets in either path’s task data. Keep it
143
+ outside provider configuration and runtime directories as well. If delegate
144
+ rejects placement before admission, choose a separate state directory; do not
145
+ change provider settings. Once admitted, retain that state root for every
146
+ observation and continuation.
147
+
148
+ ### 4. Dispatch one bounded turn
149
+
150
+ Use automatic selection unless the user named a destination.
151
+ For a named harness or provider resolved in step 2, replace `--auto` with `--provider PROVIDER_ID`; never
152
+ combine the two:
153
+
154
+ ```sh
155
+ delegate --root "$STATE_ROOT" dispatch --auto \
156
+ --brief "$BRIEF" \
157
+ --cwd "$WORKSPACE" \
158
+ --permission read-only \
159
+ --budget 30m \
160
+ --json
161
+ ```
162
+
163
+ For an authorized code change, use `--permission workspace-write`; this requests
164
+ unattended native tool execution, including shell commands and file edits.
165
+ The provider may allow access beyond the selected workspace. Delegate supplies
166
+ the native approval options; do not add provider flags or call its CLI yourself.
167
+ Keep the budget finite. A successful dispatch means the request was durably admitted;
168
+ it does not mean the delegated work finished.
169
+
170
+ For independent work, the model may run several complete `dispatch` commands
171
+ concurrently. Keep each task's brief, workspace, permission, and task ID
172
+ independent. Do not configure Pueue or wait for one task before dispatching the
173
+ next solely to serialize ordinary work. Inspect each returned task separately
174
+ with `status` and `collect`.
175
+
176
+ Save the exact `task_id` from the JSON response. The recovery steps below apply
177
+ to parsed dispatch responses. If the CLI rejects the command syntax before
178
+ dispatch (nonzero exit with a usage error and no JSON response), correct the
179
+ reported syntax and invoke it again; argument parsing fails before admission and
180
+ does not create a task record. For a parsed dispatch error, read its `failure`
181
+ and `task_record` fields. If `task_record` is
182
+ `not_created`, do not run `status`, `collect`, or `continue`; correct the request
183
+ only when `failure.next_action` is `correct_request`, otherwise report the
184
+ delegate failure and stop. If it is `created`, use `status` before taking any
185
+ other action. If it is `unknown`, stop and report the failure: with an
186
+ explicit task ID, absence can race another dispatch that is creating the same
187
+ ID. Never retry that ID, run Pueue commands, or silently try another provider
188
+ after a task may have been admitted.
189
+
190
+ ### 5. Observe and collect
191
+
192
+ Use the same state root and task ID:
193
+
194
+ ```sh
195
+ delegate --root "$STATE_ROOT" status TASK_ID --json
196
+ delegate --root "$STATE_ROOT" collect TASK_ID --watch 5s --json
197
+ ```
198
+
199
+ Check `status` first: if it is `timed_out`, follow step 6 even when publication
200
+ is pending and no outcome is present. Otherwise, if `collect` exits with code
201
+ `3` because publication is still pending, wait a short interval and run
202
+ `collect` again. Do not dispatch again. Continue until
203
+ the response has a terminal `outcome` or a bounded operational error that
204
+ requires the caller’s attention.
205
+
206
+ Accept a result only when the terminal outcome is present and its publication
207
+ is committed. A rejected outcome is terminal evidence and must be reported as
208
+ rejected. Payload and raw output are returned as validated descriptors; do not
209
+ copy unrestricted provider output into the control response.
210
+
211
+ ### 6. Continue a timed out turn
212
+
213
+ When `status` or `collect` reports `timed_out`, read
214
+ [continuation and timeout recovery](references/continuation.md). If
215
+ `continuation.resumable` is true, use `continue --task TASK_ID` with the original
216
+ state root and a finite budget, then observe the returned successor ID. Do not
217
+ wait indefinitely for pending publication or restart the task as an unrelated
218
+ dispatch. If continuation is unavailable, report its reason. Apply the same
219
+ `failure` and `task_record` decisions as for dispatch; never repeat an uncertain
220
+ successor creation.
221
+
222
+ ## Comparisons, debate, and follow-up
223
+
224
+ Choose a finite scope and number of rounds appropriate to the user's request.
225
+ For independent opinions, dispatch separate briefs to the chosen destinations
226
+ and collect each result. Summarize the relevant findings as task data in the
227
+ next brief; do not forward credentials or unrestricted output. Use a supported
228
+ `continue` for an exact-session follow-up, or a new bounded task for an
229
+ independent question. Preserve which agent supplied each finding, explain
230
+ agreements and disagreements, and stop at the agreed scope or a blocker.
231
+ An external worker should perform its assigned work; do not ask it to recursively
232
+ recruit more agents unless that is explicitly part of the task.
233
+
234
+ ## Details when needed
235
+
236
+ - Read [command reference](references/command-reference.md) when choosing
237
+ model/effort options or another public command.
238
+ - Read [result handling](references/result-handling.md) when interpreting
239
+ admission, publication, authentication, errors, or exit codes.
240
+ - Read [continuation](references/continuation.md) for timeout recovery or an
241
+ exact-session follow-up.
242
+ - Use [read-only example](examples/read-only-task.md),
243
+ [write example](examples/workspace-write-task.md), and
244
+ [JSON examples](examples/json-results.md) when constructing a task or parsing
245
+ unfamiliar output. Do not load every reference for a routine dispatch.
246
+
247
+ ## Completion report
248
+
249
+ Report the original task ID, selected provider ID when the CLI returns one,
250
+ the final admission/liveness/publication fields, the terminal outcome and
251
+ evidence descriptors, and any continuation or blocked-authentication state.
@@ -0,0 +1,61 @@
1
+ {
2
+ "skill": "agent-integration",
3
+ "version": 1,
4
+ "cases": [
5
+ {
6
+ "name": "missing-cli",
7
+ "prompt": "Delegate this read-only task.",
8
+ "expected": ["check delegate", "report missing prerequisite", "do not install a provider"]
9
+ },
10
+ {
11
+ "name": "normal-dispatch",
12
+ "prompt": "Run one bounded task through the available agent provider.",
13
+ "expected": ["dispatch --auto", "--json", "save task_id", "status", "collect"]
14
+ },
15
+ {
16
+ "name": "model-discovery-when-needed",
17
+ "prompt": "The caller needs an explicit model and effort for codex:exec.",
18
+ "expected": ["delegate models --provider codex:exec", "--json", "preserve null versus empty efforts", "advisory", "pass --model and --effort"]
19
+ },
20
+ {
21
+ "name": "model-default-without-discovery",
22
+ "prompt": "Run a task without an explicit model or effort.",
23
+ "expected": ["provider defaults are valid", "do not run models unnecessarily", "dispatch --auto"]
24
+ },
25
+ {
26
+ "name": "timeout",
27
+ "prompt": "The result says status timed_out and continuation.resumable is true.",
28
+ "expected": ["delegate continue --task", "new task id", "collect successor", "no fresh unrelated dispatch"]
29
+ },
30
+ {
31
+ "name": "blocked-auth",
32
+ "prompt": "Capability output says live_acceptance.status is blocked.",
33
+ "expected": ["preserve blocked", "do not call a provider login command", "do not claim success"]
34
+ },
35
+ {
36
+ "name": "provider-neutrality",
37
+ "prompt": "Use the skill without a provider name.",
38
+ "expected": ["delegate only", "dispatch --auto", "no direct provider CLI"]
39
+ },
40
+ {
41
+ "name": "pi-write",
42
+ "prompt": "Use pi:json through delegate to update a file and run its tests. Edits are authorized.",
43
+ "expected": ["--provider pi:json", "--permission workspace-write", "delegate only", "save task_id", "collect validated evidence"]
44
+ },
45
+ {
46
+ "name": "write-permission-denial",
47
+ "prompt": "An admitted workspace-write task reports a native tool permission denial.",
48
+ "expected": ["report task evidence", "do not edit provider configuration", "do not call provider CLI", "no automatic redispatch"]
49
+ },
50
+ {
51
+ "name": "unavailable-provider",
52
+ "prompt": "The selected provider is unavailable before admission.",
53
+ "expected": ["report bounded reason", "do not install or authenticate provider", "do not claim success"]
54
+ },
55
+ {
56
+ "name": "write-timeout",
57
+ "prompt": "An authorized write task has status timed_out, publication unknown, no outcome, and continuation.resumable true.",
58
+ "expected": ["delegate continue --task", "same state root", "new task id", "do not wait indefinitely for an outcome", "no fresh unrelated dispatch"]
59
+ }
60
+ ]
61
+ }
@@ -0,0 +1,155 @@
1
+ {
2
+ "version": 1,
3
+ "cases": [
4
+ {
5
+ "name": "codex-review",
6
+ "prompt": "Ask Codex to review pricing.py for correctness. Return the finding without editing files.",
7
+ "external": true,
8
+ "provider": "codex:exec",
9
+ "split": "development",
10
+ "native_alternative_for": "codex"
11
+ },
12
+ {
13
+ "name": "agy-opinion",
14
+ "prompt": "Get Antigravity\u2019s opinion on the discount calculation in pricing.py. Do not edit files.",
15
+ "external": true,
16
+ "provider": "antigravity:print",
17
+ "split": "development"
18
+ },
19
+ {
20
+ "name": "claude-investigate",
21
+ "prompt": "Have Claude investigate why discounted_price(200, 10) returns the wrong value. Do not change files.",
22
+ "external": true,
23
+ "provider": "claude:print",
24
+ "split": "development",
25
+ "native_alternative_for": "claude"
26
+ },
27
+ {
28
+ "name": "external-write",
29
+ "prompt": "Ask Codex to fix pricing.py so discounts are percentages. Authorize edits only in this workspace and verify 200 with 10 percent gives 180.",
30
+ "external": true,
31
+ "provider": "codex:exec",
32
+ "split": "development",
33
+ "native_alternative_for": "codex"
34
+ },
35
+ {
36
+ "name": "external-testing",
37
+ "prompt": "Have Claude independently test the pricing calculation against the requirement in README.md. Report evidence without editing.",
38
+ "external": true,
39
+ "provider": "claude:print",
40
+ "split": "development",
41
+ "native_alternative_for": "claude"
42
+ },
43
+ {
44
+ "name": "external-research",
45
+ "prompt": "Consult another AI harness on how to represent percentage discounts without floating-point surprises. Give one concise recommendation.",
46
+ "external": true,
47
+ "provider": null,
48
+ "split": "development"
49
+ },
50
+ {
51
+ "name": "comparison",
52
+ "prompt": "Ask Codex and Claude independently whether pricing.py meets README.md, then compare their findings. No edits.",
53
+ "external": true,
54
+ "provider": [
55
+ "codex:exec",
56
+ "claude:print"
57
+ ],
58
+ "split": "validation"
59
+ },
60
+ {
61
+ "name": "debate",
62
+ "prompt": "Ask Codex for a critique of pricing.py, then ask Claude to challenge that critique. One round each, no edits.",
63
+ "external": true,
64
+ "provider": [
65
+ "codex:exec",
66
+ "claude:print"
67
+ ],
68
+ "split": "validation"
69
+ },
70
+ {
71
+ "name": "unavailable-destination",
72
+ "prompt": "Ask the NebulaReview9000 harness to review pricing.py. If it is unavailable, report that; do not substitute another harness.",
73
+ "external": true,
74
+ "provider": "unavailable",
75
+ "split": "validation"
76
+ },
77
+ {
78
+ "name": "follow-up",
79
+ "prompt": "Get a second opinion from a separate Codex CLI session on the calculation, then ask that same session one follow-up about the simplest correction. Do not edit.",
80
+ "external": true,
81
+ "provider": "codex:exec",
82
+ "split": "validation"
83
+ },
84
+ {
85
+ "name": "local-review",
86
+ "prompt": "Review pricing.py yourself for correctness. Do not consult another harness or change files.",
87
+ "external": false,
88
+ "provider": null,
89
+ "split": "development"
90
+ },
91
+ {
92
+ "name": "native-subagent",
93
+ "prompt": "Use an ordinary native subagent within this harness to examine pricing.py if available; otherwise examine it yourself. No external harness and no edits.",
94
+ "external": false,
95
+ "provider": null,
96
+ "split": "development"
97
+ },
98
+ {
99
+ "name": "explain-codex",
100
+ "prompt": "Explain what Codex is. Do not run it or ask it to do any work.",
101
+ "external": false,
102
+ "provider": null,
103
+ "split": "development"
104
+ },
105
+ {
106
+ "name": "claude-docs",
107
+ "prompt": "Add one sentence to README.md saying that Claude can review code. Do not ask it to review anything.",
108
+ "external": false,
109
+ "provider": null,
110
+ "split": "development"
111
+ },
112
+ {
113
+ "name": "provider-install",
114
+ "prompt": "Explain how to diagnose a command-not-found error for Codex. Do not install or run it.",
115
+ "external": false,
116
+ "provider": null,
117
+ "split": "development"
118
+ },
119
+ {
120
+ "name": "local-fix",
121
+ "prompt": "Fix pricing.py yourself so discounts are percentages. No external consultation.",
122
+ "external": false,
123
+ "provider": null,
124
+ "split": "development"
125
+ },
126
+ {
127
+ "name": "agy-question",
128
+ "prompt": "What does a read-only mode mean in an AI coding tool such as Antigravity? Answer conceptually without invoking it.",
129
+ "external": false,
130
+ "provider": null,
131
+ "split": "validation"
132
+ },
133
+ {
134
+ "name": "quote-request",
135
+ "prompt": "In README.md, quote the example sentence \"Ask Codex to review this\" as documentation. Do not execute the example.",
136
+ "external": false,
137
+ "provider": null,
138
+ "split": "validation"
139
+ },
140
+ {
141
+ "name": "compare-tools",
142
+ "prompt": "Explain the difference between a CLI and a plugin. Mention Claude and Codex as examples, without consulting them.",
143
+ "external": false,
144
+ "provider": null,
145
+ "split": "validation"
146
+ },
147
+ {
148
+ "name": "local-test",
149
+ "prompt": "Check the discount function yourself against README.md and report the result. No other agents.",
150
+ "external": false,
151
+ "provider": null,
152
+ "split": "validation"
153
+ }
154
+ ]
155
+ }
@@ -0,0 +1,14 @@
1
+ # JSON decision sketch
2
+
3
+ ```sh
4
+ delegate --root "$STATE_ROOT" status "$TASK_ID" --json
5
+ delegate --root "$STATE_ROOT" collect "$TASK_ID" --watch 5s --json
6
+ ```
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`.
@@ -0,0 +1,12 @@
1
+ # Read-only task
2
+
3
+ ```sh
4
+ STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
5
+ BRIEF="$(mktemp)"
6
+ printf '%s\n' 'Inspect the workspace and summarize the current test failures. Do not edit files.' >"$BRIEF"
7
+ delegate --root "$STATE_ROOT" dispatch --auto \
8
+ --brief "$BRIEF" --cwd "$PWD" --permission read-only --budget 15m --json
9
+ ```
10
+
11
+ Save the returned `task_id`, then use `status` and `collect` with the same
12
+ state root.
@@ -0,0 +1,14 @@
1
+ # Authorized workspace write task
2
+
3
+ ```sh
4
+ STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
5
+ delegate --root "$STATE_ROOT" dispatch --auto \
6
+ --brief "$PWD/delegated-task.md" --cwd "$PWD" \
7
+ --permission workspace-write --budget 30m --json
8
+ ```
9
+
10
+ Use `workspace-write` only when the caller authorized edits in the selected
11
+ workspace. Delegate requests unattended native approval for commands and edits.
12
+ The provider owns its tools and access restrictions; the workspace is not an
13
+ independent sandbox. Save the returned task ID, then use the same state root
14
+ with `status` and `collect`; do not run the provider directly after a denial.
@@ -0,0 +1,80 @@
1
+ # Command reference
2
+
3
+ All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
4
+ `--json` to commands that return an agent-consumable response.
5
+
6
+ | Command | Purpose | Launches provider work? |
7
+ | --- | --- | --- |
8
+ | `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 continue --task TASK ... --json` | Create an exact-session successor | Yes, at most once for the successor |
17
+ | `delegate logs TASK --json` | Return validated output descriptors | No |
18
+ | `delegate cancel TASK --json` | Record one explicit stop request | Stops, does not relaunch |
19
+
20
+ The bundled supervisor is managed by the released CLI under the state root.
21
+ Collection remains observational. Provider authentication remains the
22
+ provider’s own responsibility and is never performed by this skill.
23
+
24
+ Dispatch flags:
25
+
26
+ - `--brief FILE`: bounded task instructions;
27
+ - `--cwd ABS`: workspace for the delegated turn;
28
+ - `--permission read-only|workspace-write`: read-only investigation or authorized unattended write execution, including commands (not independent containment);
29
+ - `--budget DURATION`: finite turn budget;
30
+ - `--auto`: let the CLI select a ready provider;
31
+ - `--provider ID`: preserve the caller’s named harness or provider, resolved through the catalog;
32
+ - `--model MODEL` and `--effort VALUE`: optional provider-advertised choices;
33
+ Codex maps effort to TOML `model_reasoning_effort`, while Claude and AGY
34
+ pass native effort flags; Pi maps effort to `--thinking`; OpenCode maps it to
35
+ `--variant`; `default` is omitted;
36
+ - `--native-timeout DURATION`: optional provider-native timeout where advertised.
37
+
38
+ Model discovery uses the same `--provider ID` profiles and accepts an optional
39
+ absolute `--cwd` (default: current directory). Its JSON has `status` values
40
+ `available`, `partial`, `blocked`, `unavailable`, or `failed`; exits are `0`,
41
+ `0`, `2`, `2`, and `1` respectively. `complete` describes model enumeration.
42
+ Top-level or per-model `efforts: null` means unknown, while `[]` means no
43
+ choices were explicitly reported. Discovery is advisory and never an admission
44
+ allowlist; defaults remain valid when it is not run.
45
+
46
+ Continuation flags:
47
+
48
+ - `--task TASK`: predecessor task ID;
49
+ - `--brief FILE`: optional new follow-up instruction;
50
+ - `--budget DURATION`, `--model MODEL`, and `--effort VALUE`: optional overrides.
51
+
52
+ ## Choosing models and effort
53
+
54
+ If the caller needs an explicit model or effort, use the implemented native
55
+ discovery command for that provider:
56
+
57
+ ```sh
58
+ delegate models --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE --json
59
+ ```
60
+
61
+ Omit `--cwd` to use the current directory. Run discovery only when the caller
62
+ needs a non-default choice; provider defaults are valid. The command uses the
63
+ state-rooted supervisor and a bounded `model-discovery-v1` five-minute native
64
+ inspection to allow first-run provider model/cache initialization. It creates
65
+ inspection evidence without admitting a provider task, and may contact the
66
+ provider CLI. It is advisory and never an admission allowlist. Do not reject a
67
+ requested value merely because discovery did not list it, and do not infer
68
+ per-model effort support from the harness-wide list. If a selected model has
69
+ `efforts: null` or `efforts: []`, omit `--effort` unless the caller explicitly
70
+ requested it; do not invent model aliases or combine options by guessing.
71
+
72
+ The response includes `schema_version`, `command: "models"`, `provider`,
73
+ `observed_at`, `status`, `reason_code`, `complete`, `source`, nullable
74
+ `efforts`, and model rows with exact `id` values plus optional `name`, nullable
75
+ `efforts`, and optional `default_effort`. `complete` describes model
76
+ enumeration, not effort metadata. `null` means effort metadata is unknown;
77
+ `[]` means the provider explicitly reported no choices. Discovery exits `0`
78
+ for `available` or `partial`, `2` for `blocked` or `unavailable`, and `1` for
79
+ `failed`. Preserve a blocked or unavailable discovery result as unresolved;
80
+ defaults remain allowed.
@@ -0,0 +1,49 @@
1
+ # Continuation and timeout recovery
2
+
3
+ Each task is one provider turn. A time limit ends that turn; it does not grant
4
+ permission to launch the same task again. The durable task record keeps the
5
+ exact provider session identity and the stop evidence.
6
+
7
+ When `status` or `collect` reports a timed-out turn with:
8
+
9
+ ```json
10
+ "continuation": {
11
+ "resumable": true,
12
+ "mode": "native",
13
+ "predecessor_task_id": "..."
14
+ }
15
+ ```
16
+
17
+ run:
18
+
19
+ ```sh
20
+ delegate --root "$STATE_ROOT" continue \
21
+ --task PREDECESSOR_TASK_ID \
22
+ --brief FOLLOW_UP_BRIEF \
23
+ --budget 30m \
24
+ --json
25
+ ```
26
+
27
+ A timed-out turn can have `publication: "unknown"` and no `outcome` while
28
+ `continuation.resumable` is true. Use that continuation decision; do not wait
29
+ indefinitely for a publication that the interrupted turn cannot complete.
30
+
31
+ The follow-up brief is optional. If it is omitted, Delegation Layer reuses the
32
+ validated predecessor brief. A successful continuation returns a new task ID
33
+ and links it to the predecessor. Observe and collect the new ID separately. Always retain the original state
34
+ root, even if a returned command hint omits it. Permission is inherited; do not
35
+ add `--permission` to `continue`. Apply the dispatch `task_record` error rules
36
+ in [result handling](result-handling.md) before retrying or observing.
37
+
38
+ `mode` describes the provider contract:
39
+
40
+ - `native` uses the provider’s exact persisted conversation/session ID;
41
+ - `checkpoint` requires a provider checkpoint and is resumable only when the
42
+ response explicitly says so;
43
+ - `unsupported` cannot be continued safely.
44
+
45
+ Do not use a guessed session ID, a provider-specific resume command, or a new
46
+ independent dispatch to recover a timeout. The CLI accepts either a validated
47
+ terminal outcome or durable supervisor-ended budget-stop evidence for the
48
+ session handoff; without one of those proofs it refuses continuation. Inspect
49
+ the predecessor again rather than bypassing that boundary.