delegation-layer 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -24,6 +24,8 @@ already use instead of replacing them.
24
24
  session through a linked successor task.
25
25
  - **Runtime compatibility** — the selected provider's executable and advertised
26
26
  capabilities are checked when the task is prepared.
27
+ - **Model choice when needed** — native model and effort discovery is available
28
+ without turning discovery into an admission allowlist.
27
29
  - **Native authentication** — provider login stays with the provider CLI; task
28
30
  state does not contain copied credentials.
29
31
 
@@ -117,7 +119,9 @@ advanced integrations. Node.js 18 or newer is needed only for the npm-based
117
119
  installers; it is not a runtime requirement for the released Go CLI. Provider
118
120
  authentication remains native to each provider. Your provider settings, MCP
119
121
  servers, plugins, and skills stay with that provider. Permission modes select
120
- native behavior; Delegation Layer is not an independent sandbox.
122
+ native behavior; Delegation Layer is not an independent sandbox. Authorized
123
+ `workspace-write` tasks run unattended using native approval behavior, including
124
+ Pi file edits and shell commands. Native access can extend beyond the workspace.
121
125
 
122
126
  ## Try one bounded task
123
127
 
@@ -140,8 +144,8 @@ The response contains a task ID and separate admission, liveness, and
140
144
  publication fields. Observe and collect it with:
141
145
 
142
146
  ```sh
143
- delegate status TASK_ID --json
144
- delegate collect TASK_ID --watch 5s --json
147
+ delegate --root "$HOME/delegation-state" status TASK_ID --json
148
+ delegate --root "$HOME/delegation-state" collect TASK_ID --watch 5s --json
145
149
  ```
146
150
 
147
151
  Use `delegate providers --json` for the compiled provider catalog and
@@ -151,6 +155,24 @@ checks static admission without creating a task. Dispatch still performs the
151
155
  host-specific runtime probe; catalog discovery alone does not prove
152
156
  authentication or supervisor readiness.
153
157
 
158
+ When an explicit model or effort choice is needed, query the implemented native
159
+ discovery command:
160
+
161
+ ```sh
162
+ delegate models --provider codex:exec --cwd "$HOME/delegation-workspace" --json
163
+ ```
164
+
165
+ `--cwd` defaults to the current directory. Model discovery uses the
166
+ state-rooted supervisor and a bounded `model-discovery-v1` 60-second inspection,
167
+ creates inspection evidence without admitting a provider task, and may contact
168
+ the provider CLI.
169
+ It is advisory: a discovered model is not an admission guarantee or an
170
+ allowlist. `complete` describes model enumeration. A null effort list means
171
+ unknown metadata; an empty list means the provider explicitly reported no
172
+ choices. Per-model effort metadata is independent of the harness-wide list.
173
+ Discovery exits `0` for `available` or `partial`, `2` for `blocked` or
174
+ `unavailable`, and `1` for `failed`.
175
+
154
176
  If a task reports `status: "timed_out"` and
155
177
  `continuation.resumable: true`, continue the exact session:
156
178
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "delegation-layer",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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",
@@ -16,7 +16,7 @@ inspect, authenticate, or install a provider CLI directly.
16
16
  2. Use `dispatch --auto` unless the user explicitly selected a provider ID.
17
17
  Provider selection, executable checks, compatibility checks, authentication
18
18
  gates, and supervisor admission belong inside Delegation Layer.
19
- 3. Give every turn an absolute workspace, a separate state root, a finite
19
+ 3. Give every turn an absolute workspace, a separate state root, an explicit
20
20
  permission mode, and a finite budget.
21
21
  4. Use `--json` and save the returned `task_id`. Read `admission`, `liveness`,
22
22
  `publication`, `status`, `outcome`, `continuation`, and `error` as separate
@@ -46,8 +46,9 @@ Run a quick local check:
46
46
  command -v delegate && delegate --version
47
47
  ```
48
48
 
49
- If this fails, tell the caller that Delegation Layer is not installed and
50
- stop. Do not substitute a provider command.
49
+ If discovery fails, report that Delegation Layer is missing. If the version
50
+ command fails, report that the installed CLI is unusable. Stop in either case.
51
+ Do not substitute a provider command.
51
52
 
52
53
  ### 2. Discover only when useful
53
54
 
@@ -63,13 +64,43 @@ ready. If the caller named one provider ID and wants a side-effect-free check,
63
64
  run:
64
65
 
65
66
  ```sh
66
- delegate preflight --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE --json
67
+ delegate preflight --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE \
68
+ --permission REQUESTED_MODE --json
67
69
  ```
68
70
 
69
- Preflight reports static admission only. It does not create a task, start the
70
- supervisor, or launch a provider. Do not keep retrying preflight when it says
71
+ Replace `REQUESTED_MODE` with `read-only` for investigation or
72
+ `workspace-write` for authorized edits. Preflight reports static admission only.
73
+ It does not create a task, start the supervisor, or launch a provider. Do not keep
74
+ retrying preflight when it says
71
75
  `blocked` or `unsupported`; report the bounded reason.
72
76
 
77
+ If the caller needs an explicit model or effort, use the implemented native
78
+ discovery command for that provider:
79
+
80
+ ```sh
81
+ delegate models --provider PROVIDER_ID --cwd ABSOLUTE_WORKSPACE --json
82
+ ```
83
+
84
+ Omit `--cwd` to use the current directory. Run discovery only when the caller
85
+ needs a non-default choice; provider defaults are valid. The command uses the
86
+ state-rooted supervisor and a bounded `model-discovery-v1` 60-second native
87
+ inspection, creates inspection evidence without admitting a provider task, and may contact the
88
+ provider CLI. It is advisory and never an admission allowlist. Do not reject a
89
+ requested value merely because discovery did not list it, and do not infer
90
+ per-model effort support from the harness-wide list. If a selected model has
91
+ `efforts: null` or `efforts: []`, omit `--effort` unless the caller explicitly
92
+ requested it; do not invent model aliases or combine options by guessing.
93
+
94
+ The response includes `schema_version`, `command: "models"`, `provider`,
95
+ `observed_at`, `status`, `reason_code`, `complete`, `source`, nullable
96
+ `efforts`, and model rows with exact `id` values plus optional `name`, nullable
97
+ `efforts`, and optional `default_effort`. `complete` describes model
98
+ enumeration, not effort metadata. `null` means effort metadata is unknown;
99
+ `[]` means the provider explicitly reported no choices. Discovery exits `0`
100
+ for `available` or `partial`, `2` for `blocked` or `unavailable`, and `1` for
101
+ `failed`. Preserve a blocked or unavailable discovery result as unresolved;
102
+ defaults remain allowed.
103
+
73
104
  ### 3. Prepare separate paths and a finite brief
74
105
 
75
106
  Use an existing task brief when one is supplied. Otherwise create a bounded
@@ -77,7 +108,7 @@ brief file that contains the requested work and its acceptance criteria. Keep
77
108
  the state root outside the workspace:
78
109
 
79
110
  ```sh
80
- STATE_ROOT="${DELEGATE_ROOT:-$HOME/.local/state/delegation-layer}"
111
+ STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
81
112
  WORKSPACE="$PWD"
82
113
  BRIEF="$(mktemp)"
83
114
  cat >"$BRIEF" <<'EOF'
@@ -87,11 +118,17 @@ EOF
87
118
  ```
88
119
 
89
120
  Replace the example brief with the actual user request. Do not place the state
90
- root inside the workspace or place secrets in either path’s task data.
121
+ root inside the workspace or place secrets in either path’s task data. Keep it
122
+ outside provider configuration and runtime directories as well. If delegate
123
+ rejects placement before admission, choose a separate state directory; do not
124
+ change provider settings. Once admitted, retain that state root for every
125
+ observation and continuation.
91
126
 
92
127
  ### 4. Dispatch one bounded turn
93
128
 
94
- Use automatic selection unless the user explicitly supplied `PROVIDER_ID`:
129
+ Use automatic selection unless the user explicitly supplied `PROVIDER_ID`.
130
+ For a named provider, replace `--auto` with `--provider PROVIDER_ID`; never
131
+ combine the two:
95
132
 
96
133
  ```sh
97
134
  delegate --root "$STATE_ROOT" dispatch --auto \
@@ -102,10 +139,22 @@ delegate --root "$STATE_ROOT" dispatch --auto \
102
139
  --json
103
140
  ```
104
141
 
105
- For an authorized code change, use `--permission workspace-write`. Keep the
106
- budget finite. A successful dispatch means the request was durably admitted;
142
+ For an authorized code change, use `--permission workspace-write`; this requests
143
+ unattended native tool execution, including shell commands and file edits.
144
+ The provider may allow access beyond the selected workspace. Delegate supplies
145
+ the native approval options; do not add provider flags or call its CLI yourself.
146
+ Keep the budget finite. A successful dispatch means the request was durably admitted;
107
147
  it does not mean the delegated work finished.
108
148
 
149
+ When an explicit selection is supplied, pass it through the public fields:
150
+ `--model MODEL` and `--effort VALUE`. Codex encodes effort as its native TOML
151
+ `model_reasoning_effort` setting; Claude and AGY use their native effort flags;
152
+ Pi maps effort to `--thinking`; and OpenCode maps effort to `--variant`. An
153
+ omitted or `default` effort is omitted from native argv. For AGY read-only,
154
+ `--permission read-only` selects the exact native `--sandbox --mode plan` path
155
+ without a bypass. Authorized AGY workspace-write retains its existing native
156
+ bypass. Do not add these native flags yourself.
157
+
109
158
  Save the exact `task_id` from the JSON response. If dispatch returns an error,
110
159
  use its `status`, `capability`, and `error` fields to report whether the request
111
160
  was invalid, unsupported, blocked by authentication, or operationally
@@ -121,8 +170,10 @@ delegate --root "$STATE_ROOT" status TASK_ID --json
121
170
  delegate --root "$STATE_ROOT" collect TASK_ID --watch 5s --json
122
171
  ```
123
172
 
124
- If `collect` exits with code `3` because publication is still pending, wait a
125
- short interval and run `collect` again. Do not dispatch again. Continue until
173
+ Check `status` first: if it is `timed_out`, follow step 6 even when publication
174
+ is pending and no outcome is present. Otherwise, if `collect` exits with code
175
+ `3` because publication is still pending, wait a short interval and run
176
+ `collect` again. Do not dispatch again. Continue until
126
177
  the response has a terminal `outcome` or a bounded operational error that
127
178
  requires the caller’s attention.
128
179
 
@@ -160,8 +211,10 @@ delegate --root "$STATE_ROOT" continue \
160
211
  --json
161
212
  ```
162
213
 
163
- The command preserves the exact provider session and creates a new task ID.
164
- Observe and collect the successor by repeating step 5. If `resumable` is
214
+ The command preserves the exact provider session and permission mode and
215
+ creates a new task ID. Do not add `--permission` to `continue`. Always include
216
+ the original `--root`, even if a returned command hint omits it. Observe and
217
+ collect the successor by repeating step 5. If `resumable` is
165
218
  false, report the reason and stop; a fresh dispatch would lose the original
166
219
  conversation and is not an equivalent recovery.
167
220
 
@@ -180,7 +233,8 @@ The adapter’s required flags and runtime behavior decide compatibility.
180
233
 
181
234
  Authentication is a separate live gate. `live_acceptance.status` values are
182
235
  `not_run`, `passed`, or `blocked`; a blocked authentication prerequisite is
183
- neutral evidence and must not be relabeled.
236
+ neutral evidence and must not be relabeled. Report the missing authentication
237
+ prerequisite and stop that attempt; do not retry or authenticate the provider.
184
238
 
185
239
  The task response separates:
186
240
 
@@ -12,6 +12,16 @@
12
12
  "prompt": "Run one bounded task through the available agent provider.",
13
13
  "expected": ["dispatch --auto", "--json", "save task_id", "status", "collect"]
14
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
+ },
15
25
  {
16
26
  "name": "timeout",
17
27
  "prompt": "The result says status timed_out and continuation.resumable is true.",
@@ -26,6 +36,26 @@
26
36
  "name": "provider-neutrality",
27
37
  "prompt": "Use the skill without a provider name.",
28
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"]
29
59
  }
30
60
  ]
31
61
  }
@@ -1,7 +1,7 @@
1
1
  # Read-only task
2
2
 
3
3
  ```sh
4
- STATE_ROOT="${DELEGATE_ROOT:-$HOME/.local/state/delegation-layer}"
4
+ STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
5
5
  BRIEF="$(mktemp)"
6
6
  printf '%s\n' 'Inspect the workspace and summarize the current test failures. Do not edit files.' >"$BRIEF"
7
7
  delegate --root "$STATE_ROOT" dispatch --auto \
@@ -1,12 +1,14 @@
1
1
  # Authorized workspace write task
2
2
 
3
3
  ```sh
4
- STATE_ROOT="${DELEGATE_ROOT:-$HOME/.local/state/delegation-layer}"
4
+ STATE_ROOT="${DELEGATE_ROOT:-$HOME/delegation-state}"
5
5
  delegate --root "$STATE_ROOT" dispatch --auto \
6
6
  --brief "$PWD/delegated-task.md" --cwd "$PWD" \
7
7
  --permission workspace-write --budget 30m --json
8
8
  ```
9
9
 
10
10
  Use `workspace-write` only when the caller authorized edits in the selected
11
- workspace. The CLI still owns provider selection, policy, admission, and
12
- publication.
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.
@@ -8,6 +8,7 @@ All paths passed to `--root`, `--cwd`, and `--brief` must be absolute. Add
8
8
  | `delegate --version` | Confirm the installed control CLI | No |
9
9
  | `delegate providers --json` | List compiled provider metadata | No |
10
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 |
11
12
  | `delegate preflight --provider ID --cwd ABS --json` | Check static provider admission | No |
12
13
  | `delegate dispatch --auto ... --json` | Select and admit one bounded turn | Yes, at most once |
13
14
  | `delegate status TASK --json` | Reconcile and observe task state | No provider launch |
@@ -24,13 +25,24 @@ Dispatch flags:
24
25
 
25
26
  - `--brief FILE`: bounded task instructions;
26
27
  - `--cwd ABS`: workspace for the delegated turn;
27
- - `--permission read-only|workspace-write`: requested native permission mode (not independent containment);
28
+ - `--permission read-only|workspace-write`: read-only investigation or authorized unattended write execution, including commands (not independent containment);
28
29
  - `--budget DURATION`: finite turn budget;
29
30
  - `--auto`: let the CLI select a ready provider;
30
31
  - `--provider ID`: use only when the caller explicitly selected an ID;
31
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;
32
36
  - `--native-timeout DURATION`: optional provider-native timeout where advertised.
33
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
+
34
46
  Continuation flags:
35
47
 
36
48
  - `--task TASK`: predecessor task ID;
@@ -24,6 +24,10 @@ delegate --root "$STATE_ROOT" continue \
24
24
  --json
25
25
  ```
26
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
+
27
31
  The follow-up brief is optional. If it is omitted, Delegation Layer reuses the
28
32
  validated predecessor brief. A successful continuation returns a new task ID
29
33
  and links it to the predecessor. Observe and collect the new ID separately.
@@ -4,22 +4,34 @@ Use the response fields independently. A successful control command is not
4
4
  the same as a successful provider result.
5
5
 
6
6
  1. Save `task_id` immediately after dispatch or continue.
7
- 2. If `admission` is not admitted, report the bounded `error` and do not claim
8
- that provider work ran.
9
- 3. If `liveness` is queued or running, call `status` or `collect` again with a
10
- finite watch interval.
7
+ 2. If a dispatch or continue response does not confirm admission, preserve any
8
+ task ID and report its bounded error. An uncertain admission must be
9
+ inspected, never automatically dispatched again. Status and collect can
10
+ report `admission: "unknown"` alongside valid terminal evidence.
11
+ 3. If `status` is `timed_out`, follow the continuation procedure before treating
12
+ pending publication as a reason to wait. `continuation.resumable: true`
13
+ permits a linked successor even when no outcome has been published.
11
14
  4. If `publication` is committed and `outcome.verdict` is committed, return
12
15
  the result and its payload/evidence descriptors.
13
16
  5. If `outcome.verdict` is rejected, report a terminal rejected result with its
14
17
  refusal and evidence. Do not retry automatically.
15
- 6. If `status` is `timed_out`, follow the continuation procedure. A timeout is
16
- recoverable only when `continuation.resumable` is true.
18
+ 6. Otherwise, if `liveness` is queued or running or publication is pending,
19
+ observe the same task again with a finite watch interval.
17
20
  7. If authentication is `blocked`, preserve that neutral state and tell the
18
21
  caller what prerequisite is unavailable without inventing a login command.
19
22
  8. If a command reports an operational uncertainty, inspect the original task
20
23
  with `status` and `collect` before considering any action. Never relaunch an
21
24
  uncertain task by guessing.
22
25
 
26
+ For `delegate models`, validate the complete JSON envelope before using any
27
+ fact. Treat `available` and `partial` with exit `0` as observations, preserve
28
+ `blocked` and `unavailable` with exit `2` as unresolved prerequisites, and
29
+ preserve `failed` with exit `1` as a discovery failure. `complete` refers to
30
+ model enumeration. Keep `efforts: null` distinct from `efforts: []`, and do not
31
+ apply harness-wide effort choices to every model. Discovery is advisory and
32
+ never an admission allowlist; a provider default remains valid and a listed
33
+ model is not an execution guarantee.
34
+
23
35
  Exit codes are bounded control signals: `0` is a completed command, `1` is an
24
36
  operational error, `2` is an invalid or unsupported request, `3` is a pending
25
37
  collection watch, and `4` is a validated rejected outcome.