delegation-layer 0.1.28 → 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 +53 -20
  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 +53 -20
  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
@@ -0,0 +1,197 @@
1
+ # Optional managed Git workspaces
2
+
3
+ Managed workspaces are an optional Delegate feature for tasks that need a
4
+ retained Git worktree. Ordinary delegation, including ordinary work in a
5
+ non-Git directory, is unchanged. Git is required only when a request creates
6
+ or attaches to a managed workspace (`--isolation git-worktree` or
7
+ `--workspace ID`).
8
+
9
+ This reference is self-contained guidance for using managed workspaces.
10
+
11
+ Provider-native permissions still apply inside an isolated checkout. A provider
12
+ may edit files but be unable to stage or commit because linked-worktree Git
13
+ metadata lives outside that checkout. Leave edits uncommitted for capture;
14
+ do not bypass the provider's permissions. When a commit is needed, the Lead can
15
+ explicitly authorize a bounded Git command through `workspace exec`.
16
+
17
+ Delegate owns durable records, process lifetimes, capture, and recovery; use
18
+ the public commands below to observe and manage them.
19
+
20
+ ## Choose the boundary
21
+
22
+ For independent parallel write work, choose `--isolation git-worktree`
23
+ automatically unless the user explicitly chooses shared coordination. The
24
+ model chooses the fan-out and task scope; there is no fixed task-count cap and
25
+ no TTL eviction. Shared coordination means the caller deliberately accepts a
26
+ common checkout and its write conflicts. A separate managed workspace is the
27
+ safer default for independent edits.
28
+
29
+ Automatic provider-agnostic routing still goes through Delegate. A native
30
+ subagent in the current harness remains allowed, and an explicit bypass is
31
+ respected. This workspace feature does not force external routing or replace a
32
+ user's explicit integration choice.
33
+
34
+ The coordinator owns one workspace usage reservation at a time. A provider
35
+ turn, continuation, read-only review, or verification operation waits for the
36
+ canonical native closure and terminal capture of the current owner. A queue
37
+ row ending or a provider outcome alone is not closure evidence.
38
+
39
+ ## Source and checkout
40
+
41
+ Create a managed workspace from a committed source base:
42
+
43
+ ```text
44
+ delegate --root ROOT dispatch --isolation git-worktree --cwd ABS \
45
+ [--base REV] [--workspace-budget DURATION] ... --json
46
+ ```
47
+
48
+ `--base` resolves to a commit; the default is `HEAD`. Dirty and untracked
49
+ source changes are observed but excluded from the managed checkout. The
50
+ provider runs in the retained detached worktree, with the source-relative
51
+ working subdirectory preserved. A request that attaches to an existing
52
+ workspace uses its recorded checkout and source identity:
53
+
54
+ ```text
55
+ delegate --root ROOT dispatch --workspace WORKSPACE_ID ... --json
56
+ ```
57
+
58
+ Public `--workspace` cannot be combined with `--cwd`, `--base`, or
59
+ `--isolation`. It is an attachment by durable ID, not a path alias. The Lead
60
+ owns landing decisions; Delegate does not automatically apply changes, commit,
61
+ create branches, or merge them.
62
+
63
+ Git-content capture is not a complete filesystem backup, index partition, or
64
+ worker commit-history backup. It does not promise ignored runtime files,
65
+ submodule interiors, empty directories, extended attributes, or LFS payloads
66
+ behind pointers. Read paths from `workspace.artifacts` and verify each
67
+ descriptor’s length and SHA-256 before using its bytes. Entries marked
68
+ `forgetting`, `forgotten`, or `omitted` have no readable path.
69
+
70
+ Shared Git refs, config, and other global resources mean that
71
+ worktree separation is cooperative checkout isolation, not a security sandbox
72
+ or read-only enforcement. A clean Git status does not prove that a provider
73
+ made no write outside the promised content scope.
74
+
75
+ ## Public commands
76
+
77
+ The CLI currently exposes these managed-workspace commands:
78
+
79
+ ```text
80
+ delegate --root ROOT workspace list [--after ID] [--limit 1..50] --json
81
+ delegate --root ROOT workspace status ID [--operation OP] [--watch DURATION] --json
82
+ delegate --root ROOT workspace exec ID --budget DURATION --json -- ARGV...
83
+ delegate --root ROOT workspace release ID [--discard] [--budget DURATION] --json
84
+ delegate --root ROOT workspace forget ID [--budget DURATION] --json
85
+ ```
86
+
87
+ `workspace exec` passes `ARGV...` directly to the supervised helper; the
88
+ `--` delimiter makes the arguments literal and no shell is inserted. Its
89
+ initial response is asynchronous and uses exit code `3` while the operation
90
+ is pending. `status` can watch one operation, while `list` returns summaries
91
+ and a cursor for the next page. `--limit` is between 1 and 50.
92
+ Follow the [workspace acknowledgement decisions](result-handling.md#managed-workspace-results)
93
+ before retrying a mutation. A busy precondition and an accepted pending action
94
+ have different next actions; an accepted action can have no helper ID yet.
95
+
96
+ The workspace helper budget defaults to 5 minutes, is persisted with the
97
+ workspace or operation, and can be overridden by the corresponding budget
98
+ flag. This auxiliary budget is separate from and does not renew the provider
99
+ task budget. The existing `codex:review` default remains 1 hour.
100
+
101
+ `continue --task PREDECESSOR_ID` inherits the predecessor's managed workspace,
102
+ working directory, provider session, and recorded environment, while creating
103
+ a new task ID. A changed provider request is a new turn; it must not mutate the
104
+ predecessor's immutable records. A retained workspace can be used by a
105
+ read-only review by attaching its ID, for example:
106
+
107
+ ```text
108
+ delegate --root ROOT dispatch --provider codex:review \
109
+ --workspace WORKSPACE_ID --review-target TARGET --brief ABS_BRIEF \
110
+ --permission read-only --budget 1h --json
111
+ ```
112
+
113
+ ## Capture and verification
114
+
115
+ The provider outcome and Git-content `CaptureReceipt` are separate immutable
116
+ facts. Normal capture covers the initial committed base through the captured
117
+ tree, including worker commits and added untracked files that belong to the
118
+ Git-content view. It uses a private temporary Git index and records an owned
119
+ base pin plus tree/snapshot reference.
120
+ Optional binary patch and name-status artifacts are bounded to 8 MiB each; an
121
+ overflow is omitted, never silently truncated. Verification diagnostics retain
122
+ an 8 MiB prefix per stream, mark truncation explicitly, and continue draining
123
+ the stream. A verification command's exit is verification evidence, not the
124
+ provider task outcome.
125
+
126
+ A failed helper may retain an `error.txt` diagnostic with a bounded, validated
127
+ descriptor. It is operation evidence, not captured Git content or a provider
128
+ answer. Diagnostic write failure does not turn a known helper failure into
129
+ success. Temporary result-read errors keep capture retryable.
130
+
131
+ The normal timeout path is ordered: the provider's native scope closes, the
132
+ managed worker's exact `Wait` is recorded, then a new finite auxiliary capture
133
+ scope runs. Recovery may instead record a validated absence disposition; it
134
+ proves closure without inventing a native `Wait` or provider success. The
135
+ expired provider scope is never renewed or reused. If capture
136
+ is unavailable after closure, the closure evidence can still preserve a valid
137
+ continuation decision; it does not rewrite the provider outcome.
138
+
139
+ ## Retention and forgetting
140
+
141
+ A created managed checkout is retained for every outcome, including no-op and
142
+ provider-failure outcomes, until the Lead explicitly releases it. A failed
143
+ admission before checkout creation has no checkout to retain. Normal release
144
+ captures final content before exclusive durable cleanup. A failed capture or
145
+ identity check retains the checkout and evidence for retry. `--discard` accepts
146
+ loss of uncaptured checkout content; it does not waive native closure,
147
+ ownership, or identity proof.
148
+
149
+ Release leaves the pinned refs/blobs and capture receipts as evidence. After a
150
+ proven release, `workspace forget ID` writes an exact inventory intent before
151
+ removing only matching owned refs and optional artifacts by identity/CAS. It
152
+ retains capture receipts, tombstones, all provider outcomes, raw evidence, and
153
+ payload descriptors. Readers should label an intentionally forgotten item as
154
+ `forgotten`, not as corruption.
155
+
156
+ Release and forget keep a compact container anchor, ownership marker, and durable
157
+ journal metadata. They remove the checkout and the exact evidence authorized by
158
+ the forget inventory. A failed forget attempt can retain a diagnostic written
159
+ after its inventory was committed; do not delete these internal paths manually.
160
+
161
+ Unknown or busy workspace state is retained and receives no cleanup. There is
162
+ no TTL cleanup, workspace renaming, global Git prune, or unowned goroutine
163
+ unlink path.
164
+
165
+ ## Recovery and review scope
166
+
167
+ When provision is pending and Delegate proves the provider task was not created,
168
+ the response contains `task_record: "not_created"`,
169
+ `failure.code: "workspace_provision_pending"`, and
170
+ `failure.next_action: "watch_workspace"`. Run the returned recovery command
171
+ with the same state root and workspace ID. Do not poll a nonexistent task or
172
+ start the provider again. An explicit task ID can have unknown creation state;
173
+ follow the returned failure instead of inferring absence.
174
+
175
+ `state: "preparation_failed"` with `reason_code: "admission_not_launched"`
176
+ means the admission closed without a registered checkout or provider launch.
177
+ Report its `stop_and_report` failure; do not keep watching it as provisioning.
178
+ A short observation window does not cancel accepted scheduling or renew the
179
+ helper's deadline. Continue observing an accepted pending action as directed.
180
+
181
+ After provision, keep the returned task ID and the same admission inputs when
182
+ retrying a request proven not created. Delegate gives a safely closed attempt
183
+ a new helper identity and deadline; it never reopens the earlier worker or
184
+ renews its deadline. Changed provider input needs a new task ID. Partial setup keeps its
185
+ durable source and ownership records. Explicit release removes only an exactly
186
+ verified owned checkout; changed paths or unverifiable Git metadata remain
187
+ retained with an error. Recovery never creates a checkout just to delete it.
188
+
189
+ Review the whole delegated turn against its recorded initial base and captured
190
+ tree, including worker commits. For that scope, use an ordinary read-only task
191
+ with explicit base/snapshot refs and a `git diff BASE TREE` instruction. Native
192
+ Codex review targets have their own scope: `uncommitted` covers current staged,
193
+ unstaged, and untracked changes; `base:BRANCH` compares a branch; `commit:SHA`
194
+ reviews a commit. An uncommitted review does not cover changes already committed
195
+ by the worker. Do not pass a tree reference as a branch or assume a native
196
+ target reviews the complete delegated turn. Preserve an explicitly requested
197
+ native review target and state its scope.