subharness 0.0.1 → 0.0.3

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 (120) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +51 -18
  3. package/dist/adapters/claude-process.d.ts +10 -0
  4. package/dist/adapters/claude-process.js +58 -0
  5. package/dist/adapters/claude-process.js.map +1 -0
  6. package/dist/adapters/claude.js +52 -10
  7. package/dist/adapters/claude.js.map +1 -1
  8. package/dist/adapters/codex-input.d.ts +2 -0
  9. package/dist/adapters/codex-input.js +14 -0
  10. package/dist/adapters/codex-input.js.map +1 -0
  11. package/dist/adapters/codex-permissions.d.ts +13 -0
  12. package/dist/adapters/codex-permissions.js +30 -0
  13. package/dist/adapters/codex-permissions.js.map +1 -0
  14. package/dist/adapters/codex.js +12 -6
  15. package/dist/adapters/codex.js.map +1 -1
  16. package/dist/adapters/fx-auth.js +3 -0
  17. package/dist/adapters/fx-auth.js.map +1 -1
  18. package/dist/adapters/fx-permissions.d.ts +3 -0
  19. package/dist/adapters/fx-permissions.js +128 -0
  20. package/dist/adapters/fx-permissions.js.map +1 -0
  21. package/dist/adapters/fx.js +4 -0
  22. package/dist/adapters/fx.js.map +1 -1
  23. package/dist/cli/args.d.ts +3 -1
  24. package/dist/cli/args.js +18 -12
  25. package/dist/cli/args.js.map +1 -1
  26. package/dist/cli/dashboard-client.d.ts +3 -0
  27. package/dist/cli/dashboard-client.js +78 -0
  28. package/dist/cli/dashboard-client.js.map +1 -0
  29. package/dist/cli/dashboard-layout.d.ts +21 -0
  30. package/dist/cli/dashboard-layout.js +211 -0
  31. package/dist/cli/dashboard-layout.js.map +1 -0
  32. package/dist/cli/dashboard-renderer.d.ts +30 -0
  33. package/dist/cli/dashboard-renderer.js +80 -0
  34. package/dist/cli/dashboard-renderer.js.map +1 -0
  35. package/dist/cli/dashboard.d.ts +31 -0
  36. package/dist/cli/dashboard.js +81 -0
  37. package/dist/cli/dashboard.js.map +1 -0
  38. package/dist/cli/help.d.ts +1 -1
  39. package/dist/cli/help.js +35 -9
  40. package/dist/cli/help.js.map +1 -1
  41. package/dist/cli/main.js +19 -6
  42. package/dist/cli/main.js.map +1 -1
  43. package/dist/cli/output.js +10 -1
  44. package/dist/cli/output.js.map +1 -1
  45. package/dist/config/access.js +4 -4
  46. package/dist/config/access.js.map +1 -1
  47. package/dist/config/loader.js +2 -2
  48. package/dist/config/loader.js.map +1 -1
  49. package/dist/runtime/client.d.ts +5 -1
  50. package/dist/runtime/client.js +91 -40
  51. package/dist/runtime/client.js.map +1 -1
  52. package/dist/runtime/coordinator.d.ts +7 -1
  53. package/dist/runtime/coordinator.js +72 -8
  54. package/dist/runtime/coordinator.js.map +1 -1
  55. package/dist/runtime/daemon.js +100 -18
  56. package/dist/runtime/daemon.js.map +1 -1
  57. package/dist/runtime/dashboard-workspace.d.ts +2 -0
  58. package/dist/runtime/dashboard-workspace.js +38 -0
  59. package/dist/runtime/dashboard-workspace.js.map +1 -0
  60. package/dist/runtime/dashboard.d.ts +28 -0
  61. package/dist/runtime/dashboard.js +19 -0
  62. package/dist/runtime/dashboard.js.map +1 -0
  63. package/dist/runtime/readiness.d.ts +4 -0
  64. package/dist/runtime/readiness.js +17 -0
  65. package/dist/runtime/readiness.js.map +1 -0
  66. package/dist/runtime/select-native.d.ts +2 -1
  67. package/dist/runtime/select-native.js +5 -3
  68. package/dist/runtime/select-native.js.map +1 -1
  69. package/dist/runtime/service.d.ts +1 -1
  70. package/dist/runtime/service.js +10 -3
  71. package/dist/runtime/service.js.map +1 -1
  72. package/dist/runtime/startup-lock.d.ts +5 -0
  73. package/dist/runtime/startup-lock.js +37 -0
  74. package/dist/runtime/startup-lock.js.map +1 -0
  75. package/dist/runtime/startup-protocol.d.ts +17 -0
  76. package/dist/runtime/startup-protocol.js +23 -0
  77. package/dist/runtime/startup-protocol.js.map +1 -0
  78. package/dist/runtime/state.d.ts +1 -2
  79. package/dist/runtime/state.js +8 -43
  80. package/dist/runtime/state.js.map +1 -1
  81. package/dist/runtime/types.d.ts +16 -2
  82. package/dist/runtime/types.js.map +1 -1
  83. package/dist/runtime/worker-client.d.ts +7 -2
  84. package/dist/runtime/worker-client.js +69 -12
  85. package/dist/runtime/worker-client.js.map +1 -1
  86. package/dist/runtime/worker-server.d.ts +7 -0
  87. package/dist/runtime/worker-server.js +101 -0
  88. package/dist/runtime/worker-server.js.map +1 -0
  89. package/dist/runtime/worker.js +2 -66
  90. package/dist/runtime/worker.js.map +1 -1
  91. package/dist/sdk/definitions.js +23 -13
  92. package/dist/sdk/definitions.js.map +1 -1
  93. package/dist/sdk/permission-validation.d.ts +4 -0
  94. package/dist/sdk/permission-validation.js +55 -0
  95. package/dist/sdk/permission-validation.js.map +1 -0
  96. package/dist/sdk/types.d.ts +14 -0
  97. package/dist/sdk/types.js.map +1 -1
  98. package/package.json +17 -17
  99. package/sdk/access-config.md +4 -2
  100. package/sdk/adapter-contract.md +14 -2
  101. package/sdk/agent-skill.md +38 -0
  102. package/sdk/agent.md +6 -2
  103. package/sdk/cli/dashboard-design.md +40 -0
  104. package/sdk/cli/index.md +47 -13
  105. package/sdk/cli/output.md +21 -3
  106. package/sdk/completion-notifications.md +9 -5
  107. package/sdk/config.md +33 -8
  108. package/sdk/distribution.md +21 -7
  109. package/sdk/evals.md +171 -0
  110. package/sdk/fx.md +4 -3
  111. package/sdk/harnesses.md +6 -0
  112. package/sdk/index.md +2 -0
  113. package/sdk/message-delivery.md +6 -2
  114. package/sdk/permissions.md +65 -0
  115. package/sdk/plugins/sub-agents.md +7 -4
  116. package/sdk/pr-integration.md +37 -0
  117. package/sdk/project-team.md +13 -8
  118. package/sdk/sessions.md +1 -1
  119. package/sdk/tools.md +2 -0
  120. package/sdk/v1-runtime.md +22 -7
package/LICENSE CHANGED
@@ -1,21 +1,201 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Agent Draft contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
- # Subharness
1
+ # subharness
2
2
 
3
- Run Codex, Claude Code, or fx from your everyday coding assistant through the `subharness` CLI. Add reusable specialists in TypeScript when a task needs shared instructions, tools, or harness alternatives. V1 connects installed Codex, Claude Code, and fx harnesses. Codex and Claude Code reuse eligible native subscription logins or explicit API access; fx connects through explicit Vercel AI Gateway access.
3
+ <p>
4
+ <a href="https://vercel.com/labs#active-experiments"><img alt="Vercel Labs Experiment" src="https://img.shields.io/badge/LABS-EXPERIMENT-0a0a0a.svg?style=for-the-badge&amp;logo=Vercel&amp;labelColor=000000" height="28"></a>
5
+ <a href="https://www.npmjs.com/package/subharness"><img alt="npm version: subharness" src="https://img.shields.io/npm/v/subharness.svg?style=for-the-badge&amp;labelColor=000000" height="28"></a>
6
+ <a href="https://github.com/vercel-labs/subharness/blob/main/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/License-Apache--2.0-blue.svg?style=for-the-badge&amp;labelColor=000000" height="28"></a>
7
+ </p>
8
+
9
+ Stay with your favorite coding agent. Ask it to delegate tasks across Codex, Claude Code, and fx, and bring results back to one conversation. The main agent uses the local `subharness` CLI to start independent native sessions, check their status, read complete responses, and report the results.
10
+
11
+ TypeScript definitions are optional. Add them when your coding agent needs reusable specialists with shared instructions, tools, or harness alternatives. Codex and Claude Code use eligible native subscription logins or explicitly configured API access; fx uses an explicitly configured Vercel AI Gateway connection.
4
12
 
5
13
  The library coordinates sessions, queues, and subagents. Harnesses own model execution, native tools, and context. You supply the working directory and any sandbox or worktree isolation.
6
14
 
@@ -17,9 +25,32 @@ subharness --help
17
25
 
18
26
  Global installation exposes `subharness` on PATH, with `agent` retained as a compatibility alias. You can also use `npx subharness` without installing a global executable. Direct harness runs need no TypeScript file or SDK dependency in the target project. Install and authenticate the native harness separately. Specialist definitions need a project-local SDK dependency so imports resolve; global definitions likewise need a reachable SDK dependency.
19
27
 
20
- See [package distribution](sdk/distribution.md) for development checkouts, local tarballs, and package boundaries. Subharness uses the [MIT license](LICENSE).
28
+ Optionally install the agent skill to teach your coding agent how to delegate with subharness:
29
+
30
+ ```sh
31
+ npx skills add vercel-labs/subharness
32
+ ```
33
+
34
+ The installer requires access to the subharness repository while the repository is internal. See the [agent-skill reference](sdk/agent-skill.md) for installation behavior and boundaries.
35
+
36
+ See [package distribution](sdk/distribution.md) for development checkouts, local tarballs, and package boundaries. subharness uses the [Apache License 2.0](LICENSE).
37
+
38
+ ## Delegate from your coding agent
21
39
 
22
- ## Run a harness directly
40
+ In the conversation you already use, ask your coding agent:
41
+
42
+ > Delegate the pagination fix and its tests to Claude Code. While that runs, ask Codex to review the README's setup instructions.
43
+
44
+ With shell access to your project, the main agent uses commands like these:
45
+
46
+ ```sh
47
+ subharness run claude --prompt "Fix the pagination bug in search results. Add a regression test and run the relevant checks."
48
+ subharness run codex --prompt "Review the README's setup instructions against the current installation and authentication behavior. Report any inaccuracies."
49
+ ```
50
+
51
+ Each command starts an independent session. The delegated agent receives the explicit task prompt and the project context it can inspect, not a copy of the main conversation's transcript. Overlapping work requires the main agent's host to support background shell execution. A completed command makes its result available, but notification and automatic reactivation of the main conversation also depend on that host. During the coordinator's lifetime, the main agent can retrieve the complete latest retained response with `subharness status <task-id> --full`; records and queues are not restored after coordinator loss.
52
+
53
+ You can also invoke a harness manually:
23
54
 
24
55
  ```sh
25
56
  subharness run claude "Review the current diff."
@@ -37,6 +68,8 @@ subharness run claude --prompt-file ./review-task.txt
37
68
  subharness run codex --prompt-file - < ./task.txt
38
69
  ```
39
70
 
71
+ Use `subharness dashboard` in a terminal to watch agents managed by the local coordinator. The live view groups agents by repository/worktree, pins the checkout containing the launch directory first, and orders other groups by their latest agent update. Each group shows current agents followed by finished runs, with harness, task title, elapsed time, and status. Finished history is retained for the coordinator’s lifetime. It has compact group labels and no controls or application banner; Ctrl+C closes the view without stopping agents.
72
+
40
73
  ## Define a reusable specialist
41
74
 
42
75
  Install the SDK in the project before adding definitions:
@@ -45,7 +78,7 @@ Install the SDK in the project before adding definitions:
45
78
  npm install --save-dev subharness
46
79
  ```
47
80
 
48
- Create `.agents/agents/developer.agent.ts` in your repository:
81
+ Create `.subharness/agents/developer.ts` in your repository:
49
82
 
50
83
  ```ts
51
84
  import { agent, codex, claudeCode } from "subharness";
@@ -61,7 +94,7 @@ export default agent({
61
94
  });
62
95
  ```
63
96
 
64
- Replace the model placeholders with identifiers available through your native harnesses. Each file default-exports one definition. Global definitions live in `~/.agents/agents/`; repository and global names never silently override one another. The bare targets `codex`, `claude`, and `fx` are reserved for harnesses; a specialist with one of those names requires a scope qualifier such as `repo:claude`.
97
+ Replace the model placeholders with identifiers available through your native harnesses. Each file default-exports one definition. Global definitions live in `~/.subharness/agents/`; repository and global names never silently override one another. The bare targets `codex`, `claude`, and `fx` are reserved for harnesses; a specialist with one of those names requires a scope qualifier such as `repo:claude`.
65
98
 
66
99
  ## Run and follow up
67
100
 
@@ -70,12 +103,12 @@ subharness list
70
103
  subharness run repo:developer --cwd /path/to/worktree --prompt "Implement the documented feature."
71
104
  subharness send <session-id> --delivery queue --prompt "Add the integration tests."
72
105
  subharness send <session-id> --delivery steer --prompt "Keep the existing API compatible."
73
- subharness wait <task-id> --after <response-id>
106
+ subharness wait <task-id> [--after <response-id>]
74
107
  subharness status <task-id> --full
75
108
  subharness cancel <task-id>
76
109
  ```
77
110
 
78
- Commands print task/session identifiers and return one complete response with its response identifier and task state. Pending descendant work can continue after that command exits. Run or wait commands can use your assistant's background-task facilities. Native steering is used when supported; otherwise `steer` behaves as `interrupt`, cancels affected descendants, preserves independently queued tasks, and reports the effective mode.
111
+ Commands print task/session identifiers and return one complete response with its response identifier and task state. `wait` returns or awaits the first retained response when `--after` is omitted, and the next response after that cursor when it is supplied. Pending descendant work can continue after that command exits. Run or wait commands can use your assistant's background-task facilities. Native steering is used when supported; otherwise `steer` behaves as `interrupt`, cancels affected descendants, preserves independently queued tasks, and reports the effective mode.
79
112
 
80
113
  Long prompts can use `--prompt-file`. Output is compact text by default; `--format jsonl` selects typed integration records without forwarding native token or tool streams.
81
114
 
@@ -83,7 +116,7 @@ Long prompts can use `--prompt-file`. Output is compact text by default; `--form
83
116
 
84
117
  No project configuration is needed when an eligible native subscription login is available. Login remains with the native harness. Ambient API keys do not silently enable paid fallback.
85
118
 
86
- Personal access preferences can be placed in the ignored `.agents/agents.local.json`. Linked worktrees read that file from the main checkout, while their agent definitions come from the selected worktree.
119
+ Personal access preferences can be placed in the ignored `.subharness/agents.local.json`. Linked worktrees read that file from the main checkout, while their agent definitions come from the selected worktree.
87
120
 
88
121
  ```json
89
122
  {
@@ -118,7 +151,7 @@ subharness run subagent:reviewer --cwd /path/to/worktree --prompt "Review the im
118
151
 
119
152
  The library supplies the parent context. Declaring `subagents` authorizes their invocation. Claude Code receives permissions scoped to its session launcher, declared children, and coordination commands; native approval rules and sandbox restrictions still apply. Children receive explicit task context rather than a copy of the parent's transcript. Cancellation propagates through delegated descendants; a parent task completes after child results and its own continuation are handled.
120
153
 
121
- This checkout includes five [repository roles](sdk/project-team.md): architecture and design with Astra, implementation with Sol, independent review with Opus, research with Gemini, and visual and shader work with Fable 5.1 through fx. Reusable techniques live in `.agents/skills/` and are read only when the task needs them; a new technique does not require another agent definition. Discover the roles with `subharness list` and invoke them through `repo:<name>`. Skill loading, native capability limits, and the image-task execution path are documented with the team.
154
+ This checkout includes six [repository roles](sdk/project-team.md): architecture and design with Astra, implementation with Sol, independent review with Opus, research with Gemini, the integrator with Sol, and visual and shader work with Fable 5.1 through fx. Reusable techniques live in `.agents/skills/` and are read only when the task needs them; a new technique does not require another agent definition. Discover the roles with `subharness list` and invoke them through `repo:<name>`. Skill loading, native capability limits, and the image-task execution path are documented with the team.
122
155
 
123
156
  ## Boundaries
124
157
 
@@ -136,23 +169,23 @@ Live fx checks through an explicit Gateway API key cover execution, conversation
136
169
 
137
170
  The private `apps/docs` workspace contains the Geistdocs website. Its reference pages are generated from the authoritative `sdk/` Markdown files; edit those originals rather than generated MDX.
138
171
 
139
- Website development requires a full `npm install` from the repository root, including workspace dependencies.
172
+ Source development uses pnpm 11.20.0, pinned in `package.json`. Run `pnpm install --frozen-lockfile` from the repository root to install the SDK and website workspaces.
140
173
 
141
174
  ```sh
142
- npm run dev:site
143
- npm run check:site
144
- npm run build:site
175
+ pnpm run dev:site
176
+ pnpm run check:site
177
+ pnpm run build:site
145
178
  ```
146
179
 
147
180
  The [website contracts](website/architecture.md) describe the application boundaries, and the [mascot asset documentation](assets/mascot/README.md) records the reproducible geometry conversion and poster rendering commands.
148
181
 
149
182
  ```sh
150
- npm run check
151
- npm run check:package
183
+ pnpm run check
184
+ pnpm run check:package
152
185
  ```
153
186
 
154
- `npm run check` builds the current SDK first, then runs TypeScript checking and behavioral tests. Building first lets repository agent definitions import the package's current exports on a clean checkout and prevents tests from exercising stale build output. Tests cover native protocol boundaries, credential selection, worktrees, task queues, cancellation races, nested CLI execution, and process lifetime.
187
+ `pnpm run check` builds the current SDK first, then runs TypeScript checking and behavioral tests. Building first lets repository agent definitions import the package's current exports on a clean checkout and prevents tests from exercising stale build output. Tests cover native protocol boundaries, credential selection, worktrees, task queues, cancellation races, nested CLI execution, and process lifetime.
155
188
 
156
- `npm run check:package` packs the SDK and verifies installation, imports, and CLI agent discovery in a temporary consumer project. It downloads dependencies from the public npm registry with install lifecycle scripts disabled and does not run a coding model.
189
+ `pnpm run check:package` packs the SDK and verifies installation, imports, and CLI agent discovery in a temporary consumer project. It downloads dependencies from the public npm registry with install lifecycle scripts disabled and does not run a coding model.
157
190
 
158
191
  The [SDK documentation](sdk/index.md) describes the final contracts. [AGENTS.md](AGENTS.md) defines the project's documentation, TDD, and review workflow. Comparative research and review evidence are kept in the ignored `.context` directory.
@@ -0,0 +1,10 @@
1
+ import type { SpawnedProcess, SpawnOptions } from '@anthropic-ai/claude-agent-sdk';
2
+ /** Retains the concrete SDK subprocess until its termination is confirmed. */
3
+ export declare class ClaudeProcessOwner {
4
+ private child?;
5
+ private exited?;
6
+ private closing?;
7
+ readonly spawn: (options: SpawnOptions) => SpawnedProcess;
8
+ close(): Promise<void>;
9
+ private stop;
10
+ }
@@ -0,0 +1,58 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { AgentError } from '../errors.js';
3
+ const gracefulExitMs = 2_000;
4
+ const terminatedExitMs = 5_000;
5
+ const killedExitMs = 1_000;
6
+ function exitsWithin(exited, timeout) {
7
+ return new Promise(resolve => {
8
+ const timer = setTimeout(() => resolve(false), timeout);
9
+ exited.then(() => { clearTimeout(timer); resolve(true); });
10
+ });
11
+ }
12
+ /** Retains the concrete SDK subprocess until its termination is confirmed. */
13
+ export class ClaudeProcessOwner {
14
+ child;
15
+ exited;
16
+ closing;
17
+ spawn = (options) => {
18
+ if (this.child)
19
+ throw new AgentError('HARNESS_FAILED', 'Claude Code attempted to start more than one native process.');
20
+ const child = spawn(options.command, options.args, {
21
+ cwd: options.cwd,
22
+ env: options.env,
23
+ signal: options.signal,
24
+ stdio: ['pipe', 'pipe', 'ignore'],
25
+ windowsHide: true,
26
+ });
27
+ this.child = child;
28
+ this.exited = new Promise(resolve => {
29
+ child.once('exit', () => resolve());
30
+ child.once('error', () => { if (child.pid === undefined)
31
+ resolve(); });
32
+ });
33
+ return child;
34
+ };
35
+ close() {
36
+ return this.closing ??= this.stop();
37
+ }
38
+ async stop() {
39
+ const child = this.child;
40
+ const exited = this.exited;
41
+ if (!child || !exited)
42
+ return;
43
+ try {
44
+ child.stdin.end();
45
+ }
46
+ catch { /* Continue to bounded termination. */ }
47
+ if (await exitsWithin(exited, gracefulExitMs))
48
+ return;
49
+ child.kill('SIGTERM');
50
+ if (await exitsWithin(exited, terminatedExitMs))
51
+ return;
52
+ child.kill('SIGKILL');
53
+ if (await exitsWithin(exited, killedExitMs))
54
+ return;
55
+ throw new AgentError('HARNESS_FAILED', 'Claude Code process termination could not be confirmed.');
56
+ }
57
+ }
58
+ //# sourceMappingURL=claude-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-process.js","sourceRoot":"","sources":["../../src/adapters/claude-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA4B,MAAM,oBAAoB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,YAAY,GAAG,KAAK,CAAC;AAE3B,SAAS,WAAW,CAAC,MAAqB,EAAE,OAAe;IACzD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,MAAM,OAAO,kBAAkB;IACrB,KAAK,CAA+C;IACpD,MAAM,CAAiB;IACvB,OAAO,CAAiB;IAEvB,KAAK,GAAG,CAAC,OAAqB,EAAkB,EAAE;QACzD,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAC,8DAA8D,CAAC,CAAC;QACtH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAC,OAAO,CAAC,IAAI,EAAC;YAC/C,GAAG,EAAC,OAAO,CAAC,GAAG;YACf,GAAG,EAAC,OAAO,CAAC,GAAG;YACf,MAAM,EAAC,OAAO,CAAC,MAAM;YACrB,KAAK,EAAC,CAAC,MAAM,EAAC,MAAM,EAAC,QAAQ,CAAC;YAC9B,WAAW,EAAC,IAAI;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAClC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAC,GAAG,EAAE,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;gBAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM;YAAE,OAAO;QAC9B,IAAI,CAAC;YAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,sCAAsC,CAAC,CAAC;QAC3E,IAAI,MAAM,WAAW,CAAC,MAAM,EAAC,cAAc,CAAC;YAAE,OAAO;QACrD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,IAAI,MAAM,WAAW,CAAC,MAAM,EAAC,gBAAgB,CAAC;YAAE,OAAO;QACvD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,IAAI,MAAM,WAAW,CAAC,MAAM,EAAC,YAAY,CAAC;YAAE,OAAO;QACnD,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAC,yDAAyD,CAAC,CAAC;IACnG,CAAC;CACF","sourcesContent":["import { spawn, type ChildProcessByStdio } from 'node:child_process';\nimport type { Readable, Writable } from 'node:stream';\nimport type { SpawnedProcess, SpawnOptions } from '@anthropic-ai/claude-agent-sdk';\nimport { AgentError } from '../errors.js';\n\nconst gracefulExitMs = 2_000;\nconst terminatedExitMs = 5_000;\nconst killedExitMs = 1_000;\n\nfunction exitsWithin(exited: Promise<void>, timeout: number): Promise<boolean> {\n return new Promise(resolve => {\n const timer = setTimeout(() => resolve(false),timeout);\n exited.then(() => { clearTimeout(timer); resolve(true); });\n });\n}\n\n/** Retains the concrete SDK subprocess until its termination is confirmed. */\nexport class ClaudeProcessOwner {\n private child?: ChildProcessByStdio<Writable,Readable,null>;\n private exited?: Promise<void>;\n private closing?: Promise<void>;\n\n readonly spawn = (options: SpawnOptions): SpawnedProcess => {\n if (this.child) throw new AgentError('HARNESS_FAILED','Claude Code attempted to start more than one native process.');\n const child = spawn(options.command,options.args,{\n cwd:options.cwd,\n env:options.env,\n signal:options.signal,\n stdio:['pipe','pipe','ignore'],\n windowsHide:true,\n });\n this.child = child;\n this.exited = new Promise(resolve => {\n child.once('exit',() => resolve());\n child.once('error',() => { if (child.pid === undefined) resolve(); });\n });\n return child;\n };\n\n close(): Promise<void> {\n return this.closing ??= this.stop();\n }\n\n private async stop(): Promise<void> {\n const child = this.child;\n const exited = this.exited;\n if (!child || !exited) return;\n try { child.stdin.end(); } catch { /* Continue to bounded termination. */ }\n if (await exitsWithin(exited,gracefulExitMs)) return;\n child.kill('SIGTERM');\n if (await exitsWithin(exited,terminatedExitMs)) return;\n child.kill('SIGKILL');\n if (await exitsWithin(exited,killedExitMs)) return;\n throw new AgentError('HARNESS_FAILED','Claude Code process termination could not be confirmed.');\n }\n}\n"]}
@@ -10,6 +10,7 @@ import { ClaudeInput } from "./claude-input.js";
10
10
  import { claudeDelegationPermissions } from "./claude-permissions.js";
11
11
  import { claudeSettings, verifyClaudeAccess, verifyClaudePolicy, verifyClaudeOptions } from "./claude-auth.js";
12
12
  import { ClaudeSettingsUnavailable, claudeDefaultUnavailable, readClaudeAppliedSettings, verifyAppliedClaudeEffort } from "./claude-settings.js";
13
+ import { ClaudeProcessOwner } from "./claude-process.js";
13
14
  const dependencies = {
14
15
  query,
15
16
  async managedSettings(cwd) {
@@ -42,13 +43,21 @@ export const openClaude = createClaudeOpener(dependencies);
42
43
  /** Dependency injection is internal and replaces only the external SDK boundary in tests. */
43
44
  export function createClaudeOpener(deps) {
44
45
  return async (options) => {
46
+ if (options.harness.kind !== "claudeCode")
47
+ throw new AgentError("INVALID_CONFIG", "Claude Code received configuration for a different harness.");
48
+ const permissionMode = options.harness.permissionMode;
45
49
  const settings = claudeSettings(options);
46
50
  const executable = await deps.executable(options.env);
47
51
  verifyClaudePolicy(await deps.managedSettings(options.cwd), settings.settings);
48
52
  const tools = claudeTools(options.agent);
49
- const allowedTools = [...(tools.config.allowedTools ?? []), ...claudeDelegationPermissions(options)];
53
+ const allowedTools = [
54
+ ...(options.harness.allowedTools ?? []),
55
+ ...(tools.config.allowedTools ?? []),
56
+ ...claudeDelegationPermissions(options),
57
+ ];
50
58
  const config = await privateClaudeConfig(settings.settings);
51
59
  const input = new ClaudeInput();
60
+ const processOwner = new ClaudeProcessOwner();
52
61
  let inputFailure;
53
62
  const requireInput = (toolName) => {
54
63
  tools.stopAdmission();
@@ -61,10 +70,14 @@ export function createClaudeOpener(deps) {
61
70
  try {
62
71
  native = deps.query({ prompt: input, options: {
63
72
  pathToClaudeCodeExecutable: executable,
73
+ spawnClaudeCodeProcess: processOwner.spawn,
64
74
  cwd: options.cwd,
65
75
  ...settings,
66
76
  ...tools.config,
67
77
  ...(allowedTools.length ? { allowedTools } : {}),
78
+ ...(options.harness.disallowedTools !== undefined ? { disallowedTools: [...options.harness.disallowedTools] } : {}),
79
+ ...(permissionMode !== undefined ? { permissionMode } : {}),
80
+ ...(permissionMode === "bypassPermissions" ? { allowDangerouslySkipPermissions: true } : {}),
68
81
  settings: config.path,
69
82
  stderr: () => { },
70
83
  ...(options.harness.model ? { model: options.harness.model } : {}),
@@ -89,7 +102,13 @@ export function createClaudeOpener(deps) {
89
102
  } });
90
103
  }
91
104
  catch {
92
- await config.cleanup();
105
+ input.close();
106
+ try {
107
+ await processOwner.close();
108
+ }
109
+ finally {
110
+ await config.cleanup();
111
+ }
93
112
  throw new AgentError("HARNESS_UNAVAILABLE", "Claude Code could not start.");
94
113
  }
95
114
  const expectedModels = new Set();
@@ -155,7 +174,12 @@ export function createClaudeOpener(deps) {
155
174
  catch (error) {
156
175
  input.close();
157
176
  native.close();
158
- await config.cleanup();
177
+ try {
178
+ await processOwner.close();
179
+ }
180
+ finally {
181
+ await config.cleanup();
182
+ }
159
183
  if (error instanceof AgentError)
160
184
  throw error;
161
185
  throw new AgentError("ACCESS_UNAVAILABLE", "Claude Code authentication could not be verified.");
@@ -167,11 +191,18 @@ export function createClaudeOpener(deps) {
167
191
  const reading = (async () => {
168
192
  try {
169
193
  for await (const message of native) {
170
- if (message.type === "system" && message.subtype === "init" && !expectedModels.has(message.model)) {
171
- sessionFailure = new AgentError("INVALID_CONFIG", "Claude Code selected a different model than requested.");
172
- tools.stopAdmission();
173
- native.close();
174
- break;
194
+ if (message.type === "system" && message.subtype === "init") {
195
+ if (!expectedModels.has(message.model)) {
196
+ sessionFailure = new AgentError("INVALID_CONFIG", "Claude Code selected a different model than requested.");
197
+ }
198
+ else if (permissionMode !== undefined && message.permissionMode !== permissionMode) {
199
+ sessionFailure = new AgentError("INVALID_CONFIG", "Claude Code reported a different permission mode than requested.");
200
+ }
201
+ if (sessionFailure) {
202
+ tools.stopAdmission();
203
+ native.close();
204
+ break;
205
+ }
175
206
  }
176
207
  if (message.type !== "result" || !active)
177
208
  continue;
@@ -205,7 +236,12 @@ export function createClaudeOpener(deps) {
205
236
  active?.reject(sessionFailure ?? inputFailure ?? new AgentError(code, "The Claude Code process stopped before completing the turn."));
206
237
  active?.stop();
207
238
  active = undefined;
208
- await config.cleanup();
239
+ try {
240
+ await processOwner.close();
241
+ }
242
+ finally {
243
+ await config.cleanup();
244
+ }
209
245
  }
210
246
  })();
211
247
  return {
@@ -287,7 +323,13 @@ export function createClaudeOpener(deps) {
287
323
  tools.stopAdmission();
288
324
  input.close();
289
325
  native.close();
290
- await reading;
326
+ const stopping = processOwner.close();
327
+ try {
328
+ await reading;
329
+ }
330
+ finally {
331
+ await stopping;
332
+ }
291
333
  },
292
334
  };
293
335
  };