@heretyc/subagent-mcp 2.10.2 → 2.10.4

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/LICENSE CHANGED
@@ -1,201 +1,201 @@
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 in 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 exercising
24
- 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 Object
36
- form, made available under the License, as indicated by a copyright
37
- notice that is included in or attached to the work (an example is
38
- 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 Work and any Derivative Works thereof, and any modifications
50
- and enhancements to those works or Derivative Works thereof, that is
51
- intentionally submitted to Licensor for inclusion in the Work by the
52
- copyright owner or by an individual or Legal Entity authorized to submit
53
- on behalf of the copyright owner. For the purposes of this definition,
54
- "submitted" means any form of electronic, verbal, or written communication
55
- sent 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 Legal Entity on behalf of
63
- whom a Contribution has been received by Licensor and subsequently
64
- 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, then any
107
- Derivative Works that You distribute must include a readable
108
- copy of the attribution notices contained within such NOTICE
109
- file, excluding those notices that do not pertain to any part
110
- of the Derivative Works, in at least one of the following
111
- places: within a NOTICE text file distributed as part of the
112
- Derivative Works; within the Source form or documentation,
113
- if provided along with the Derivative Works; or, within a
114
- 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 from the Work, provided that
120
- such additional attribution notices cannot be construed as
121
- 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 of this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work by
132
- You to Licensor shall be under the terms and conditions of this License,
133
- without any additional terms or conditions. Notwithstanding the above,
134
- nothing herein shall supersede or modify the terms of any separate
135
- license agreement you may have executed with Licensor regarding such
136
- Contribution.
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 type. You may also add a brief
185
- description of what the file does on the same "printed page" as
186
- the copyright notice for easier identification within third-party
187
- archives.
188
-
189
- Copyright 2026 Lexi Blackburn
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.
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 in 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 exercising
24
+ 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 Object
36
+ form, made available under the License, as indicated by a copyright
37
+ notice that is included in or attached to the work (an example is
38
+ 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 Work and any Derivative Works thereof, and any modifications
50
+ and enhancements to those works or Derivative Works thereof, that is
51
+ intentionally submitted to Licensor for inclusion in the Work by the
52
+ copyright owner or by an individual or Legal Entity authorized to submit
53
+ on behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written communication
55
+ sent 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 Legal Entity on behalf of
63
+ whom a Contribution has been received by Licensor and subsequently
64
+ 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, then any
107
+ Derivative Works that You distribute must include a readable
108
+ copy of the attribution notices contained within such NOTICE
109
+ file, excluding those notices that do not pertain to any part
110
+ of the Derivative Works, in at least one of the following
111
+ places: within a NOTICE text file distributed as part of the
112
+ Derivative Works; within the Source form or documentation,
113
+ if provided along with the Derivative Works; or, within a
114
+ 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 from the Work, provided that
120
+ such additional attribution notices cannot be construed as
121
+ 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 of this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work by
132
+ You to Licensor shall be under the terms and conditions of this License,
133
+ without any additional terms or conditions. Notwithstanding the above,
134
+ nothing herein shall supersede or modify the terms of any separate
135
+ license agreement you may have executed with Licensor regarding such
136
+ Contribution.
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 type. You may also add a brief
185
+ description of what the file does on the same "printed page" as
186
+ the copyright notice for easier identification within third-party
187
+ archives.
188
+
189
+ Copyright 2026 Lexi Blackburn
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/NOTICE CHANGED
@@ -1,5 +1,5 @@
1
- subagent-mcp
2
- Copyright 2026 Lexi Blackburn
3
-
4
- Licensed under the Apache License, Version 2.0.
5
- This product includes software developed by Lexi Blackburn.
1
+ subagent-mcp
2
+ Copyright 2026 Lexi Blackburn
3
+
4
+ Licensed under the Apache License, Version 2.0.
5
+ This product includes software developed by Lexi Blackburn.
package/README.md CHANGED
@@ -1,185 +1,187 @@
1
- # subagent-mcp
2
-
3
- [![npm version](https://img.shields.io/npm/v/@heretyc/subagent-mcp?label=npm)](https://www.npmjs.com/package/@heretyc/subagent-mcp)
4
- [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
5
- [![node](https://img.shields.io/node/v/@heretyc/subagent-mcp)](https://www.npmjs.com/package/@heretyc/subagent-mcp)
6
- [![CI](https://github.com/Heretyc/subagent-mcp/actions/workflows/claude-routine.yml/badge.svg)](https://github.com/Heretyc/subagent-mcp/actions/workflows/claude-routine.yml)
7
-
8
- MCP server that launches and manages always-interactive Claude Code and Codex sub-agent sessions — on macOS, Linux, and Windows. No direct API calls. No API keys.
9
-
10
- ## Install
11
-
12
- ### Prerequisites (runtime)
13
-
14
- To run the published CLI you need:
15
-
16
- - Node.js >= 18 (`node --version`)
17
- - `claude` CLI — globally installed and authenticated (`claude --version`)
18
- - `codex` CLI — globally installed and authenticated (`codex --version`; optional if you only use Claude paths)
19
-
20
- Building from source needs additional developer tooling — see [CONTRIBUTING.md § Prerequisites](CONTRIBUTING.md#prerequisites).
21
-
22
- ### npmjs (default)
23
-
24
- No authentication, no `.npmrc` configuration, and no PAT required. The package is publicly available on [npmjs.com](https://www.npmjs.com/package/@heretyc/subagent-mcp).
25
-
26
- ```bash
27
- npm install -g @heretyc/subagent-mcp
28
- ```
29
-
30
- **Use this path for all standard installs.**
31
-
32
- ### GitHub Packages (org-internal pin / supply-chain auditing)
33
-
34
- Use this path when your organization's `.npmrc` already routes the `@heretyc` scope through GitHub Packages, when you need supply-chain audit tracing against the org-internal artifact, or when you run inside a GitHub Actions workflow whose `GITHUB_TOKEN` carries `read:packages`. Otherwise prefer npmjs above — it is simpler and needs no credentials.
35
-
36
- ```bash
37
- # One-time machine setup
38
- echo "@heretyc:registry=https://npm.pkg.github.com" >> ~/.npmrc
39
- echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc
40
- # PAT must be a classic PAT with the read:packages scope
41
-
42
- npm install -g @heretyc/subagent-mcp
43
- ```
44
-
45
- > **Note:** GitHub Packages requires authentication even for public packages. If you see `401 Unauthorized`, verify your PAT has the `read:packages` scope and has not expired. GitHub Packages does not render a README page — the live documentation appears on [npmjs.com](https://www.npmjs.com/package/@heretyc/subagent-mcp).
46
-
47
- ## Quick Start
48
-
49
- **1. Install** (see [Install](#install) above):
50
-
51
- ```bash
52
- npm install -g @heretyc/subagent-mcp
53
- ```
54
-
55
- **2. Register the MCP server + orchestration hooks:**
56
-
57
- ```bash
58
- subagent-mcp setup
59
- ```
60
-
61
- Installing the package only ships the binary — it does **not** auto-wire anything. `subagent-mcp setup` auto-detects Claude Code / Codex and registers the MCP server plus the per-turn orchestration-mode hooks. Preview with `subagent-mcp setup --dry-run`.
62
-
63
- **3. Restart your host.**
64
-
65
- Restart your Claude Code or Codex session so it picks up the new binary. On Codex, run `/hooks` and trust the new hook.
66
-
67
- **4. Initialize the orchestration invariant (recommended):**
68
-
69
- ```bash
70
- subagent-mcp init --global
71
- ```
72
-
73
- `init --global` writes the managed invariant block into the providers' official global user-config files — `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, `~/.gemini/GEMINI.md` — set up once, works across every project. For a single project instead, use `subagent-mcp init --root /path/to/project` to write into that project's instruction files. `--global` and `--root` are mutually exclusive.
74
-
75
- For manual wiring, Gemini CLI, Claude Desktop, and developer install from source, see [docs/registration.md](docs/registration.md).
76
-
77
- ## Features
78
-
79
- - Start Claude or Codex interactive sessions as managed sub-agents from any MCP host
80
- - Poll status, stream stdout/stderr tails, and enqueue follow-up messages to live sessions
81
- - Concurrency caps: 5 concurrent Claude + 5 concurrent Codex agents (only `processing` agents count toward the cap; `stalled` agents do not hold a slot)
82
- - Liveness tracking via the visible provider stream (Claude SDK events, Codex app-server JSONL): agents with no parsed visible provider stream item for 10 minutes enter `stalled` state (still alive, just quiet — thinking or awaiting a temp-file handoff), and recover to `processing` if the visible stream resumes
83
- - Ultracode mode for Opus 4.8 via `--settings {"ultracode":true}` see [docs/usage.md](docs/usage.md)
84
- - Cross-platform exe resolution (Windows: npm-prefix .exe paths; macOS/Linux: PATH + Homebrew/usr-local fallbacks); immediate `taskkill /t /f` (Windows) / `SIGKILL` (POSIX) force-kill; no graceful shutdown period
85
- - stdio MCP transport; built with `@modelcontextprotocol/sdk` + `zod`
86
- - `orchestration-mode` tool toggles orchestrator directives injected by bundled Claude Code / Codex hooks; Claude also gets a deterministic `PreToolUse` gate
87
-
88
- ## Orchestration Mode
89
-
90
- **ON:** the agent operates as an orchestrator — hook injection governs each session turn, preventing inline reads or writes, and all work is delegated through sub-agent tools.
91
-
92
- **OFF:** the agent operates normally, with no orchestration constraints.
93
-
94
- Toggle with the `orchestration-mode` tool. Desktop hosts toggle the mode but receive no hook injection. See [docs/spec/dev-loop/orchestration-directive-architecture.md](docs/spec/dev-loop/orchestration-directive-architecture.md) for full semantics.
95
-
96
- ## Auto Mode
97
-
98
- `launch_agent` supports **auto mode**: pass `prompt` + `task_category` and the server picks the best provider/model/effort for that category from its routing table, silently falling back to the next-best candidate on any launch-time failure.
99
-
100
- `provider`, `model`, and `effort` are optional overrides omit them to get the auto-selected best combination. Rules: passing `model` requires `provider`; passing `effort` requires both `provider` and `model`.
101
-
102
- **task_category** (required)pick one:
103
-
104
- | Category | What it is |
105
- |---|---|
106
- | `math_proof` | deliverable is a proof/derivation/formally-checkable result |
107
- | `security_review` | security verdict, threat assessment, or demonstrated exploit |
108
- | `debugging` | verified fix/root-cause; requires an observed failure as precondition |
109
- | `quality_review` | evaluative verdict on existing artifact (review, A-vs-B, validate-vs-spec) |
110
- | `architecture` | cross-module design/plan, no code, no execution loop |
111
- | `agentic_execution` | end-state via act/observe/adapt loop (run/deploy/provision/browse) |
112
- | `data_analysis` | empirical finding about structured dataset (query, stat, model) |
113
- | `coding` | bounded runnable code artifact, one-pass (implement, test, refactor) |
114
- | `knowledge_synthesis` | novel integrated prose over sources (synthesize, summarize, draft) |
115
- | `mechanical` | deterministic single-pass transform, exact-match checkable (grep, rename, reformat) |
116
- | `prompt_engineering` | designed/optimized prompt or prompt-system steering an LLM/agent (composite-inferred) |
117
- | `vulnerability_research` | discovery + PoC of a novel vulnerability (composite-inferred) |
118
- | `molecular_biology` | reasoned molecular/computational-biology result over sequences, structures, or -omics data (composite-inferred) |
119
- | `ml_accelerator_design` | hardware/software design for ML acceleration dataflow, kernel, roofline (composite-inferred) |
120
- | `fallback_default` | no category matches with confidence; prefer splitting work instead |
121
-
122
- The last four are **composite-inferred**: they carry no dedicated benchmark and their routing competency is composed from parent categories rather than measured directly.
123
-
124
- **Atomic-split guidance:** if you are unsure which category fits, do NOT submit one large amorphous task. Break the work into smaller atomic steps each mapping to a single category and launch one agent per step.
125
-
126
- ## Configuration
127
-
128
- ### Global concurrent-subagent cap
129
-
130
- subagent-mcp enforces a machine-global cap on the number of **live concurrent subagents** across all agentic sessions and MCP server processes on the machine. The count includes agents started by other active sessions and the whole recursive descendant tree; slots free as agents finish or are killed.
131
-
132
- The cap is configured in `global-concurrency.jsonc`, a dedicated dist-sibling file in the install directory. It is separate from the advanced routing directives file, ships as a commented template, and is retained across installs and updates by the same preserve-user-edits mechanism as the advanced routing directives.
133
-
134
- Set `globalConcurrentSubagents` in that file. The default is `20`; the minimum valid value is `10`. Validation is forced: `0`, unset, missing, or invalid values reset to `20`, and values `1` through `9` are pinned up to `10`. There is no environment-variable override; the file is the sole source of truth. The file is re-read on every `launch_agent` call, so edits take effect on the next launch with no server restart.
135
-
136
- When the cap is reached, `launch_agent` is rejected immediately; it never queues. Before cap checks, hooks and tool calls run default zombie culling with no config knob: live agents idle for more than 6 minutes and terminal-but-alive agents idle for more than 30 seconds are terminated process-tree-first, then force-killed after 20 seconds if needed. Reports include `zombies`, and `poll_agent` keeps the tail with `zombie_killed` when culling terminates an agent.
137
-
138
- ## Tools
139
-
140
- Eight tools are exposed over the stdio MCP transport.
141
-
142
- | Tool | Description |
143
- |---|---|
144
- | `launch_agent` | Start a new sub-agent session with a prompt and optional task category / overrides |
145
- | `poll_agent` | Check status and stream tail output for a running agent |
146
- | `kill_agent` | Terminate a running or stalled agent |
147
- | `send_message` | Enqueue a message into a running agent's stdin |
148
- | `list_agents` | List all tracked agents and their current status |
149
- | `wait` | Block until a specific agent reaches a terminal state |
150
- | `orchestration-mode` | Toggle orchestration-mode ON/OFF; controls whether hook directives are injected into agent sessions |
151
- | `model-selection-mode` | Control model selection: `smart` (auto-pick) or `user-approved-overrides` (30-min override window) |
152
-
153
- Full parameters, return shapes, and the `alive` / `idle_seconds` / `hint` / `recent_stream` fields are in [docs/tools.md](docs/tools.md).
154
-
155
- ## Agent Lifecycle
156
-
157
- Each agent transitions through these states:
158
-
159
- | Status | Meaning |
160
- |---|---|
161
- | `processing` | Driver alive with a visible provider-stream heartbeat in the last 10 minutes — actively working. Launch time counts as the initial heartbeat |
162
- | `stalled` | Driver STILL ALIVE but no parsed visible provider stream item for >= 10 minutes — working, thinking, or awaiting a temp-file handoff (not a failure). Recovers to `processing` if the visible stream resumes |
163
- | `finished` | Current turn completed, or driver exited with code 0 |
164
- | `errored` | Process exited with non-zero code |
165
- | `stopped` | Terminated by `kill_agent` |
166
-
167
- `processing` and `stalled` are live. `stalled` means the driver is alive but quiet (>= 10 min no visible stream); it recovers automatically and is never auto-killed — do not `kill_agent` a stalled agent. `wait` does not return on `stalled`. Full semantics: [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md).
168
-
169
- ## Documentation
170
-
171
- | Document | Contents |
172
- |---|---|
173
- | [docs/registration.md](docs/registration.md) | Per-platform setup: Claude Code, Codex, Gemini CLI, Claude Desktop; manual wiring; developer install from source |
174
- | [docs/tools.md](docs/tools.md) | Full tool reference — all eight tools, parameters, return shapes |
175
- | [docs/usage.md](docs/usage.md) | Model & effort matrix, ultracode mode, CLI invocations, usage examples |
176
- | [docs/SPEC.md](docs/SPEC.md) | Full technical specificationarchitecture, schemas, status lifecycle, error catalogue |
177
- | [docs/spec/interactive-drivers.md](docs/spec/interactive-drivers.md) | Always-interactive Claude/Codex driver model |
178
- | [docs/release-notes.md](docs/release-notes.md) | Operator-facing release notes |
179
- | [CONTRIBUTING.md](CONTRIBUTING.md) | Contributor guide dev environment, build, test, publish |
180
-
181
- ## License
182
-
183
- Apache-2.0 — Copyright 2026 Lexi Blackburn
184
-
185
- See [LICENSE](LICENSE).
1
+ # subagent-mcp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@heretyc/subagent-mcp?label=npm)](https://www.npmjs.com/package/@heretyc/subagent-mcp)
4
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
5
+ [![node](https://img.shields.io/node/v/@heretyc/subagent-mcp)](https://www.npmjs.com/package/@heretyc/subagent-mcp)
6
+ [![CI](https://github.com/Heretyc/subagent-mcp/actions/workflows/claude-routine.yml/badge.svg)](https://github.com/Heretyc/subagent-mcp/actions/workflows/claude-routine.yml)
7
+
8
+ MCP server that launches and manages always-interactive Claude Code and Codex sub-agent sessions — on macOS, Linux, and Windows. No direct API calls. No API keys.
9
+
10
+ ## Install
11
+
12
+ ### Prerequisites (runtime)
13
+
14
+ To run the published CLI you need:
15
+
16
+ - Node.js >= 18 (`node --version`)
17
+ - `claude` CLI — globally installed and authenticated (`claude --version`)
18
+ - `codex` CLI — globally installed and authenticated (`codex --version`; optional if you only use Claude paths)
19
+
20
+ Building from source needs additional developer tooling — see [CONTRIBUTING.md § Prerequisites](CONTRIBUTING.md#prerequisites).
21
+
22
+ ### npmjs (default)
23
+
24
+ No authentication, no `.npmrc` configuration, and no PAT required. The package is publicly available on [npmjs.com](https://www.npmjs.com/package/@heretyc/subagent-mcp).
25
+
26
+ ```bash
27
+ npm install -g @heretyc/subagent-mcp
28
+ ```
29
+
30
+ **Use this path for all standard installs.**
31
+
32
+ `subagent-mcp update` always refreshes from npmjs, even on machines whose `.npmrc` routes `@heretyc` packages through GitHub Packages.
33
+
34
+ ### GitHub Packages (org-internal pin / supply-chain auditing)
35
+
36
+ Use this path when your organization's `.npmrc` already routes the `@heretyc` scope through GitHub Packages, when you need supply-chain audit tracing against the org-internal artifact, or when you run inside a GitHub Actions workflow whose `GITHUB_TOKEN` carries `read:packages`. Otherwise prefer npmjs above — it is simpler and needs no credentials.
37
+
38
+ ```bash
39
+ # One-time machine setup
40
+ echo "@heretyc:registry=https://npm.pkg.github.com" >> ~/.npmrc
41
+ echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc
42
+ # PAT must be a classic PAT with the read:packages scope
43
+
44
+ npm install -g @heretyc/subagent-mcp
45
+ ```
46
+
47
+ > **Note:** GitHub Packages requires authentication even for public packages. If you see `401 Unauthorized`, verify your PAT has the `read:packages` scope and has not expired. GitHub Packages does not render a README page — the live documentation appears on [npmjs.com](https://www.npmjs.com/package/@heretyc/subagent-mcp).
48
+
49
+ ## Quick Start
50
+
51
+ **1. Install** (see [Install](#install) above):
52
+
53
+ ```bash
54
+ npm install -g @heretyc/subagent-mcp
55
+ ```
56
+
57
+ **2. Register the MCP server + orchestration hooks:**
58
+
59
+ ```bash
60
+ subagent-mcp setup
61
+ ```
62
+
63
+ Installing the package only ships the binary — it does **not** auto-wire anything. `subagent-mcp setup` auto-detects Claude Code / Codex and registers the MCP server plus the per-turn orchestration-mode hooks. Preview with `subagent-mcp setup --dry-run`.
64
+
65
+ **3. Restart your host.**
66
+
67
+ Restart your Claude Code or Codex session so it picks up the new binary. On Codex, run `/hooks` and trust the new hook.
68
+
69
+ **4. Initialize the orchestration invariant (recommended):**
70
+
71
+ ```bash
72
+ subagent-mcp init --global
73
+ ```
74
+
75
+ `init --global` writes the managed invariant block into the providers' official global user-config files — `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, `~/.gemini/GEMINI.md` — set up once, works across every project. For a single project instead, use `subagent-mcp init --root /path/to/project` to write into that project's instruction files. `--global` and `--root` are mutually exclusive.
76
+
77
+ For manual wiring, Gemini CLI, Claude Desktop, and developer install from source, see [docs/registration.md](docs/registration.md).
78
+
79
+ ## Features
80
+
81
+ - Start Claude or Codex interactive sessions as managed sub-agents from any MCP host
82
+ - Poll status, stream stdout/stderr tails, and enqueue follow-up messages to live sessions
83
+ - Concurrency caps: 5 concurrent Claude + 5 concurrent Codex agents (only `processing` agents count toward the cap; `stalled` agents do not hold a slot)
84
+ - Liveness tracking via the visible provider stream (Claude SDK events, Codex app-server JSONL): agents with no parsed visible provider stream item for 10 minutes enter `stalled` state (still alive, just quiet — thinking or awaiting a temp-file handoff), and recover to `processing` if the visible stream resumes
85
+ - Ultracode mode for Opus 4.8 via `--settings {"ultracode":true}` see [docs/usage.md](docs/usage.md)
86
+ - Cross-platform exe resolution (Windows: npm-prefix .exe paths; macOS/Linux: PATH + Homebrew/usr-local fallbacks); immediate `taskkill /t /f` (Windows) / `SIGKILL` (POSIX) force-kill; no graceful shutdown period
87
+ - stdio MCP transport; built with `@modelcontextprotocol/sdk` + `zod`
88
+ - `orchestration-mode` tool — toggles orchestrator directives injected by bundled Claude Code / Codex hooks; Claude also gets a deterministic `PreToolUse` gate
89
+
90
+ ## Orchestration Mode
91
+
92
+ **ON:** the agent operates as an orchestrator — hook injection governs each session turn, preventing inline reads or writes, and all work is delegated through sub-agent tools.
93
+
94
+ **OFF:** the agent operates normally, with no orchestration constraints.
95
+
96
+ Toggle with the `orchestration-mode` tool. Desktop hosts toggle the mode but receive no hook injection. See [docs/spec/dev-loop/orchestration-directive-architecture.md](docs/spec/dev-loop/orchestration-directive-architecture.md) for full semantics.
97
+
98
+ ## Auto Mode
99
+
100
+ `launch_agent` supports **auto mode**: pass `prompt` + `task_category` and the server picks the best provider/model/effort for that category from its routing table, silently falling back to the next-best candidate on any launch-time failure.
101
+
102
+ `provider`, `model`, and `effort` are optional overrides omit them to get the auto-selected best combination. Rules: passing `model` requires `provider`; passing `effort` requires both `provider` and `model`.
103
+
104
+ **task_category** (required) pick one:
105
+
106
+ | Category | What it is |
107
+ |---|---|
108
+ | `math_proof` | deliverable is a proof/derivation/formally-checkable result |
109
+ | `security_review` | security verdict, threat assessment, or demonstrated exploit |
110
+ | `debugging` | verified fix/root-cause; requires an observed failure as precondition |
111
+ | `quality_review` | evaluative verdict on existing artifact (review, A-vs-B, validate-vs-spec) |
112
+ | `architecture` | cross-module design/plan, no code, no execution loop |
113
+ | `agentic_execution` | end-state via act/observe/adapt loop (run/deploy/provision/browse) |
114
+ | `data_analysis` | empirical finding about structured dataset (query, stat, model) |
115
+ | `coding` | bounded runnable code artifact, one-pass (implement, test, refactor) |
116
+ | `knowledge_synthesis` | novel integrated prose over sources (synthesize, summarize, draft) |
117
+ | `mechanical` | deterministic single-pass transform, exact-match checkable (grep, rename, reformat) |
118
+ | `prompt_engineering` | designed/optimized prompt or prompt-system steering an LLM/agent (composite-inferred) |
119
+ | `vulnerability_research` | discovery + PoC of a novel vulnerability (composite-inferred) |
120
+ | `molecular_biology` | reasoned molecular/computational-biology result over sequences, structures, or -omics data (composite-inferred) |
121
+ | `ml_accelerator_design` | hardware/software design for ML acceleration — dataflow, kernel, roofline (composite-inferred) |
122
+ | `fallback_default` | no category matches with confidence; prefer splitting work instead |
123
+
124
+ The last four are **composite-inferred**: they carry no dedicated benchmark and their routing competency is composed from parent categories rather than measured directly.
125
+
126
+ **Atomic-split guidance:** if you are unsure which category fits, do NOT submit one large amorphous task. Break the work into smaller atomic steps each mapping to a single category and launch one agent per step.
127
+
128
+ ## Configuration
129
+
130
+ ### Global concurrent-subagent cap
131
+
132
+ subagent-mcp enforces a machine-global cap on the number of **live concurrent subagents** across all agentic sessions and MCP server processes on the machine. The count includes agents started by other active sessions and the whole recursive descendant tree; slots free as agents finish or are killed.
133
+
134
+ The cap is configured in `global-concurrency.jsonc`, a dedicated dist-sibling file in the install directory. It is separate from the advanced routing directives file, ships as a commented template, and is retained across installs and updates by the same preserve-user-edits mechanism as the advanced routing directives.
135
+
136
+ Set `globalConcurrentSubagents` in that file. The default is `20`; the minimum valid value is `10`. Validation is forced: `0`, unset, missing, or invalid values reset to `20`, and values `1` through `9` are pinned up to `10`. There is no environment-variable override; the file is the sole source of truth. The file is re-read on every `launch_agent` call, so edits take effect on the next launch with no server restart.
137
+
138
+ When the cap is reached, `launch_agent` is rejected immediately; it never queues. Before cap checks, hooks and tool calls run default zombie culling with no config knob: stale slots whose owner server is gone may terminate their managed child process-tree, while live owned slots are heartbeated and preserved; terminal-but-alive agents idle for more than 30 seconds are force-killed. Reports include `zombies`, and `poll_agent` keeps the tail with `zombie_killed` when culling terminates an agent.
139
+
140
+ ## Tools
141
+
142
+ Eight tools are exposed over the stdio MCP transport.
143
+
144
+ | Tool | Description |
145
+ |---|---|
146
+ | `launch_agent` | Start a new sub-agent session with a prompt and optional task category / overrides |
147
+ | `poll_agent` | Check status and stream tail output for a running agent |
148
+ | `kill_agent` | Terminate a running or stalled agent |
149
+ | `send_message` | Enqueue a message into a running agent's stdin |
150
+ | `list_agents` | List all tracked agents and their current status |
151
+ | `wait` | Block until a specific agent reaches a terminal state |
152
+ | `orchestration-mode` | Toggle orchestration-mode ON/OFF; controls whether hook directives are injected into agent sessions |
153
+ | `model-selection-mode` | Control model selection: `smart` (auto-pick) or `user-approved-overrides` (30-min override window) |
154
+
155
+ Full parameters, return shapes, and the `alive` / `idle_seconds` / `hint` / `recent_stream` fields are in [docs/tools.md](docs/tools.md).
156
+
157
+ ## Agent Lifecycle
158
+
159
+ Each agent transitions through these states:
160
+
161
+ | Status | Meaning |
162
+ |---|---|
163
+ | `processing` | Driver alive with a visible provider-stream heartbeat in the last 10 minutes — actively working. Launch time counts as the initial heartbeat |
164
+ | `stalled` | Driver STILL ALIVE but no parsed visible provider stream item for >= 10 minutes — working, thinking, or awaiting a temp-file handoff (not a failure). Recovers to `processing` if the visible stream resumes |
165
+ | `finished` | Current turn completed, or driver exited with code 0 |
166
+ | `errored` | Process exited with non-zero code |
167
+ | `stopped` | Terminated by `kill_agent` |
168
+
169
+ `processing` and `stalled` are live. `stalled` means the driver is alive but quiet (>= 10 min no visible stream); it recovers automatically and is never auto-killed — do not `kill_agent` a stalled agent. `wait` does not return on `stalled`. Full semantics: [docs/reference/status-lifecycle.md](docs/reference/status-lifecycle.md).
170
+
171
+ ## Documentation
172
+
173
+ | Document | Contents |
174
+ |---|---|
175
+ | [docs/registration.md](docs/registration.md) | Per-platform setup: Claude Code, Codex, Gemini CLI, Claude Desktop; manual wiring; developer install from source |
176
+ | [docs/tools.md](docs/tools.md) | Full tool referenceall eight tools, parameters, return shapes |
177
+ | [docs/usage.md](docs/usage.md) | Model & effort matrix, ultracode mode, CLI invocations, usage examples |
178
+ | [docs/SPEC.md](docs/SPEC.md) | Full technical specification — architecture, schemas, status lifecycle, error catalogue |
179
+ | [docs/spec/interactive-drivers.md](docs/spec/interactive-drivers.md) | Always-interactive Claude/Codex driver model |
180
+ | [docs/release-notes.md](docs/release-notes.md) | Operator-facing release notes |
181
+ | [CONTRIBUTING.md](CONTRIBUTING.md) | Contributor guide — dev environment, build, test, publish |
182
+
183
+ ## License
184
+
185
+ Apache-2.0 — Copyright 2026 Lexi Blackburn
186
+
187
+ See [LICENSE](LICENSE).
@@ -1,2 +1,2 @@
1
1
  // GENERATED by scripts/gen-ruleset-scaffold.mjs from src/global-concurrency.jsonc — DO NOT EDIT.
2
- export const CONCURRENCY_SCAFFOLD = "// subagent-mcp — Global Concurrent Subagent Cap\r\n// ------------------------------------------------------------------\r\n// SOLE source of truth for the machine-wide limit on how many subagents\r\n// may be ALIVE AT ONCE across EVERY session, process, and user on this\r\n// machine. There is NO environment-variable override.\r\n//\r\n// The whole recursive descendant tree counts toward this ONE number: a\r\n// subagent that itself launches subagents adds to the same machine-wide\r\n// total, and OTHER active agentic sessions count too.\r\n//\r\n// RE-READ on every launch_agent call — edits take effect immediately, no\r\n// server restart required.\r\n//\r\n// Value rules (forcibly applied to the number below):\r\n// - missing / unset / non-integer / 0 / negative -> reset to default 20\r\n// - 1 through 9 -> forced UP to minimum 10\r\n// - 10 or greater -> used as-is\r\n//\r\n// Zombie culling is always enabled. There is no config knob. Before cap\r\n// rejection, launch/tool/hook paths cull stale live agents idle for 6min and\r\n// terminal-but-alive agents idle for 30s. Culling gracefully terminates the\r\n// full process tree, then force-kills after 20s when needed.\r\n//\r\n// When the cap is reached after culling, launch_agent is REJECTED (never\r\n// queued). Free a slot with list_agents + kill_agent, then retry.\r\n{\r\n \"globalConcurrentSubagents\": 20\r\n}\r\n";
2
+ export const CONCURRENCY_SCAFFOLD = "// subagent-mcp — Global Concurrent Subagent Cap\r\n// ------------------------------------------------------------------\r\n// SOLE source of truth for the machine-wide limit on how many subagents\r\n// may be ALIVE AT ONCE across EVERY session, process, and user on this\r\n// machine. There is NO environment-variable override.\r\n//\r\n// The whole recursive descendant tree counts toward this ONE number: a\r\n// subagent that itself launches subagents adds to the same machine-wide\r\n// total, and OTHER active agentic sessions count too.\r\n//\r\n// RE-READ on every launch_agent call — edits take effect immediately, no\r\n// server restart required.\r\n//\r\n// Value rules (forcibly applied to the number below):\r\n// - missing / unset / non-integer / 0 / negative -> reset to default 20\r\n// - 1 through 9 -> forced UP to minimum 10\r\n// - 10 or greater -> used as-is\r\n//\r\n// Zombie culling is always enabled. There is no config knob. Before cap\n// rejection, launch/tool/hook paths refresh live owned slots, preserve stale\n// slots whose owner server is still alive, and cull stale slots whose owner is\n// gone. Managed stale slots terminate the child process tree, then force-kill\n// after 20s when needed; unmanaged stale slots are only unlinked.\n//\r\n// When the cap is reached after culling, launch_agent is REJECTED (never\r\n// queued). Free a slot with list_agents + kill_agent, then retry.\r\n{\r\n \"globalConcurrentSubagents\": 20\r\n}\r\n";
@@ -16,10 +16,11 @@
16
16
  // - 1 through 9 -> forced UP to minimum 10
17
17
  // - 10 or greater -> used as-is
18
18
  //
19
- // Zombie culling is always enabled. There is no config knob. Before cap
20
- // rejection, launch/tool/hook paths cull stale live agents idle for 6min and
21
- // terminal-but-alive agents idle for 30s. Culling gracefully terminates the
22
- // full process tree, then force-kills after 20s when needed.
19
+ // Zombie culling is always enabled. There is no config knob. Before cap
20
+ // rejection, launch/tool/hook paths refresh live owned slots, preserve stale
21
+ // slots whose owner server is still alive, and cull stale slots whose owner is
22
+ // gone. Managed stale slots terminate the child process tree, then force-kill
23
+ // after 20s when needed; unmanaged stale slots are only unlinked.
23
24
  //
24
25
  // When the cap is reached after culling, launch_agent is REJECTED (never
25
26
  // queued). Free a slot with list_agents + kill_agent, then retry.
package/dist/index.js CHANGED
@@ -91,9 +91,31 @@ function withZombieReport(result, records) {
91
91
  result.content[0].text = `${text}\n${report}`;
92
92
  return result;
93
93
  }
94
- function updateSlotMetadata(agent) {
94
+ function slotHeartbeatIntervalMs() {
95
+ return Math.max(1000, Math.min(30_000, Math.floor(zombieLiveIdleMs() / 3)));
96
+ }
97
+ function isLiveAgent(agent) {
98
+ return agent.status === "processing" || agent.status === "stalled";
99
+ }
100
+ function isSameOwnerSlot(agent, slotMeta) {
101
+ if (!slotMeta)
102
+ return true;
103
+ if (slotMeta.agent_id !== agent.id)
104
+ return false;
105
+ return slotMeta.server_pid === null || slotMeta.server_pid === process.pid;
106
+ }
107
+ function adoptNewerSlotActivity(agent, slotMeta) {
108
+ if (!slotMeta?.last_activity_ms || !isSameOwnerSlot(agent, slotMeta))
109
+ return;
110
+ if (slotMeta.last_activity_ms > agent.slotLastActivity) {
111
+ agent.slotLastActivity = slotMeta.last_activity_ms;
112
+ }
113
+ }
114
+ function updateSlotMetadata(agent, slotActivityMs) {
95
115
  if (!agent.slotPath)
96
116
  return;
117
+ const lastActivityMs = Math.max(agent.slotLastActivity, agent.lastActivity, slotActivityMs ?? 0);
118
+ agent.slotLastActivity = lastActivityMs;
97
119
  writeSlotMetadata(agent.slotPath, {
98
120
  agent_id: agent.id,
99
121
  server_pid: process.pid,
@@ -101,10 +123,25 @@ function updateSlotMetadata(agent) {
101
123
  cwd: agent.cwd,
102
124
  started_at: new Date(agent.startedAt).toISOString(),
103
125
  started_at_ms: agent.startedAt,
104
- last_activity_ms: agent.lastActivity,
126
+ last_activity_ms: lastActivityMs,
105
127
  status: agent.status,
106
128
  });
107
129
  }
130
+ function refreshLiveSlotMetadata(agent, now) {
131
+ if (!agent.slotPath || !isLiveAgent(agent))
132
+ return;
133
+ const slotMeta = readSlotMetadata(agent.slotPath);
134
+ if (!isSameOwnerSlot(agent, slotMeta))
135
+ return;
136
+ adoptNewerSlotActivity(agent, slotMeta);
137
+ const diskActivityMs = slotMeta?.last_activity_ms ?? null;
138
+ const shouldRefresh = slotMeta === null ||
139
+ diskActivityMs === null ||
140
+ diskActivityMs < agent.slotLastActivity ||
141
+ now - agent.slotLastActivity >= slotHeartbeatIntervalMs();
142
+ if (shouldRefresh)
143
+ updateSlotMetadata(agent, now);
144
+ }
108
145
  function spawnProcessTreeKill(pid, force) {
109
146
  const commands = buildProcessTreeKillCommands(pid);
110
147
  const command = force ? commands.force : commands.graceful;
@@ -202,17 +239,13 @@ function runToolMaintenance() {
202
239
  if (agent.status === "zombie_killed")
203
240
  continue;
204
241
  reconcileAgent(agent, now);
205
- const slotMeta = agent.slotPath ? readSlotMetadata(agent.slotPath) : null;
206
- if (slotMeta?.last_activity_ms !== null && slotMeta?.last_activity_ms !== undefined) {
207
- agent.lastActivity = Math.min(agent.lastActivity, slotMeta.last_activity_ms);
208
- }
209
- const live = agent.status === "processing" || agent.status === "stalled";
210
- if (live && now - agent.lastActivity > zombieLiveIdleMs()) {
211
- const record = markZombieKilled(agent, "stale_live", now);
212
- records.push(record);
213
- applied.add(agent.id);
242
+ const live = isLiveAgent(agent);
243
+ if (live) {
244
+ refreshLiveSlotMetadata(agent, now);
214
245
  continue;
215
246
  }
247
+ const slotMeta = agent.slotPath ? readSlotMetadata(agent.slotPath) : null;
248
+ adoptNewerSlotActivity(agent, slotMeta);
216
249
  const terminalButAlive = (agent.status === "finished" || agent.status === "errored" || agent.status === "stopped") &&
217
250
  !agent.driver.closed &&
218
251
  agent.exitedAt !== null &&
@@ -227,10 +260,12 @@ function runToolMaintenance() {
227
260
  }
228
261
  return records;
229
262
  }
230
- function withMaintenance(handler) {
263
+ function withMaintenance(handler, options = {}) {
231
264
  return async (params) => {
232
265
  const zombieRecords = runToolMaintenance();
233
266
  const result = await handler(params, zombieRecords);
267
+ if (options.omitZombieReport)
268
+ return result;
234
269
  if (result && typeof result === "object" && "content" in result) {
235
270
  return withZombieReport(result, zombieRecords);
236
271
  }
@@ -311,6 +346,7 @@ const reconcileInterval = setInterval(() => {
311
346
  const now = Date.now();
312
347
  for (const agent of agents.values()) {
313
348
  reconcileAgent(agent, now);
349
+ refreshLiveSlotMetadata(agent, now);
314
350
  }
315
351
  }, 10000);
316
352
  reconcileInterval.unref();
@@ -327,7 +363,7 @@ const ORCHESTRATION_INSTRUCTIONS = "subagent-mcp - CANONICAL OPERATING MODEL (fu
327
363
  const SUBAGENT_INSTRUCTIONS = "SUB-AGENT SESSION: you are a child process launched by subagent-mcp. Follow the parent prompt. Do not treat yourself as the orchestrator, do not re-trigger orchestration carryover, and do not launch further sub-agents unless the parent prompt explicitly assigns that.\n\nMODEL SELECTION MODE (parallel to orchestration-mode, set via the model-selection-mode tool). DEFAULT is \"smart\" and is used whenever unset: in smart, launch_agent REJECTS any call supplying provider/model/effort selectors and the server auto-picks the best model. \"user-approved-overrides\" opens a 30-MINUTE window where selectors are HONORED, enforced LAZILY (the mode reverts to smart on the next launch_agent call after 30 minutes) and re-enabling does NOT extend an active window. HONOR-BASED: you MUST NOT set \"user-approved-overrides\" without explicit interactive USER authorization via the structured-question tool (AskUserQuestion on Claude / request-user-input on Codex); never enable it on your own initiative.";
328
364
  const server = new McpServer({
329
365
  name: "subagent-mcp",
330
- version: "2.10.2",
366
+ version: "2.10.4",
331
367
  description: "Launches always-interactive local Claude and Codex sub-agent sessions and is the orchestrator's sole launch channel. Claude runs via the Claude Agent SDK over the local Claude Code executable; Codex via `codex app-server` over stdio. The server never calls Anthropic or OpenAI HTTP APIs directly.",
332
368
  }, {
333
369
  instructions: process.env.SUBAGENT_MCP_SUBAGENT === "1"
@@ -474,6 +510,7 @@ async function tryLaunchCandidate(candidate, prompt, agentCwd, routingTier, rule
474
510
  waitReported: false,
475
511
  visibleStream: [],
476
512
  streamBuf: "",
513
+ slotLastActivity: now,
477
514
  };
478
515
  childProcess.on("error", (err) => {
479
516
  // Captured into the stderr tail for debugging. Not a visible provider stream
@@ -896,7 +933,8 @@ server.tool("launch_agent", "Spawn a sub-agent session. CONTRACT: every `prompt`
896
933
  .map((s, i) => ` ${i + 1}. ${s.model}@${s.effort} (${s.provider}) [${s.failure_type}]: ${s.reason}`)
897
934
  .join("\n");
898
935
  return errorResult(`Error: all ${skipped.length} candidate launches failed for task_category ${task_category}:\n${lines}\n${SPLIT_HINT}\n${AUTO_HINT}`);
899
- }));
936
+ }, { omitZombieReport: true }) // ponytail: launch_agent still reaps, but callers do not receive zombie_report.
937
+ );
900
938
  // Tool 2: poll_agent
901
939
  server.tool("poll_agent", "Get an agent's current status and output. `processing` = ALIVE with visible provider activity in the last 10 min; `stalled` = ALIVE but no visible provider stream item for 10 min (thinking, or awaiting a temp-file handoff) — NOT dead, so prefer `wait`/re-poll over killing. Always returns `alive` + `idle_seconds`, plus `recent_stream` (last 3 timestamped visible stream items) and a `hint` while stalled. `verbose: true` also returns `final_output`, the agent's final assistant turn from its captured stdout.", {
902
940
  agent_id: z.string(),
@@ -1145,7 +1183,7 @@ server.tool("list_agents", "List all agents with token-efficient core metrics (s
1145
1183
  // Tool 6: wait
1146
1184
  server.tool("wait", "Blocks until one or more sub-agents reach a reportable state (turn-finished, errored, stopped, or zombie_killed), returning exit code when known + local-time timestamp; or returns the live-job list after a 15-minute timeout. This is how you learn an agent finished — do NOT poll-loop. A `finished` agent with null exit_code is still alive and accepts `send_message`; a `stalled` agent is still ALIVE and does NOT end the wait. `verbose: true` adds each finished agent's `final_output`.", {
1147
1185
  verbose: z.boolean().optional().default(false),
1148
- }, withMaintenance(async (params) => {
1186
+ }, withMaintenance(async (params, zombieRecords) => {
1149
1187
  const { verbose } = params;
1150
1188
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
1151
1189
  const TIMEOUT_MS = 15 * 60 * 1000;
@@ -1202,6 +1240,7 @@ server.tool("wait", "Blocks until one or more sub-agents reach a reportable stat
1202
1240
  while (Date.now() < deadline) {
1203
1241
  await sleep(250);
1204
1242
  unreported = selectUnreported(Array.from(agents.values()));
1243
+ zombieRecords.push(...runToolMaintenance());
1205
1244
  if (unreported.length > 0) {
1206
1245
  for (const a of unreported)
1207
1246
  a.waitReported = true;
@@ -1337,7 +1376,17 @@ if (isMain) {
1337
1376
  }
1338
1377
  if (arg === "update" || arg === "--update") {
1339
1378
  const pkg = readPkg();
1340
- const npmArgs = ["install", "-g", `${pkg.name}@latest`];
1379
+ const scope = pkg.name.startsWith("@") ? pkg.name.split("/")[0] : null;
1380
+ const npmjsRegistryArgs = [
1381
+ "--registry=https://registry.npmjs.org",
1382
+ ...(scope ? [`--${scope}:registry=https://registry.npmjs.org`] : []),
1383
+ ];
1384
+ const npmArgs = [
1385
+ "install",
1386
+ "-g",
1387
+ ...npmjsRegistryArgs,
1388
+ `${pkg.name}@latest`,
1389
+ ];
1341
1390
  console.log(`subagent-mcp ${pkg.version} -> npm ${npmArgs.join(" ")}`);
1342
1391
  // npm on Windows is npm.cmd; spawning a .cmd without a shell fails
1343
1392
  // (EINVAL on modern Node). Resolve the underlying npm-cli.js and run it
package/dist/zombie.js CHANGED
@@ -122,6 +122,18 @@ export function drainZombieIntents(dir) {
122
122
  function defaultRunCommand(command, args) {
123
123
  execFileSync(command, args, { stdio: "ignore" });
124
124
  }
125
+ function defaultIsProcessAlive(pid) {
126
+ try {
127
+ process.kill(pid, 0);
128
+ return true;
129
+ }
130
+ catch (err) {
131
+ return err.code === "EPERM";
132
+ }
133
+ }
134
+ function livePid(pid) {
135
+ return typeof pid === "number" && Number.isInteger(pid) && pid > 0;
136
+ }
125
137
  function defaultSleepMs(ms) {
126
138
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
127
139
  }
@@ -130,6 +142,7 @@ export function cullStaleSlots(dir, deps = {}) {
130
142
  const runCommand = deps.runCommand ?? defaultRunCommand;
131
143
  const sleepMs = deps.sleepMs ?? defaultSleepMs;
132
144
  const forceGraceMs = deps.forceGraceMs?.() ?? ZOMBIE_FORCE_GRACE_MS;
145
+ const isProcessAlive = deps.isProcessAlive ?? defaultIsProcessAlive;
133
146
  const p = deps.platform ?? platform();
134
147
  const records = [];
135
148
  let files;
@@ -146,8 +159,16 @@ export function cullStaleSlots(dir, deps = {}) {
146
159
  continue;
147
160
  if (now - meta.last_activity_ms <= ZOMBIE_LIVE_IDLE_MS)
148
161
  continue;
162
+ const ownerPid = livePid(meta.server_pid) ? meta.server_pid : null;
163
+ if (ownerPid !== null) {
164
+ try {
165
+ if (isProcessAlive(ownerPid))
166
+ continue;
167
+ }
168
+ catch { }
169
+ }
149
170
  const pid = meta.child_pid;
150
- if (pid && pid !== process.pid) {
171
+ if (ownerPid !== null && livePid(pid) && pid !== process.pid) {
151
172
  const commands = buildProcessTreeKillCommands(pid, p);
152
173
  try {
153
174
  runCommand(commands.graceful.command, commands.graceful.args);
package/package.json CHANGED
@@ -1,68 +1,69 @@
1
- {
2
- "name": "@heretyc/subagent-mcp",
3
- "version": "2.10.2",
4
- "description": "MCP server that launches and manages always-interactive Claude Code and Codex sub-agent sessions (no direct Anthropic/OpenAI API).",
5
- "keywords": [
6
- "mcp",
7
- "model-context-protocol",
8
- "mcp-server",
9
- "claude",
10
- "claude-code",
11
- "codex",
12
- "orchestration",
13
- "subagent",
14
- "sub-agent",
15
- "multi-agent",
16
- "ai-agents",
17
- "anthropic",
18
- "openai"
19
- ],
20
- "type": "module",
21
- "main": "dist/index.js",
22
- "bin": {
23
- "subagent-mcp": "dist/index.js"
24
- },
25
- "files": [
26
- "dist",
27
- "directives",
28
- "scripts/postinstall.mjs",
29
- "LICENSE",
30
- "NOTICE",
31
- "README.md"
32
- ],
33
- "scripts": {
34
- "check:versions": "node scripts/check_version_sync.mjs",
35
- "build": "npm run check:versions && node scripts/gen-ruleset-scaffold.mjs && tsc && node scripts/copy-provider.mjs",
36
- "start": "node dist/index.js",
37
- "postinstall": "node scripts/postinstall.mjs",
38
- "prepare": "npm run build",
39
- "prepublishOnly": "npm test",
40
- "test": "npm run check:versions && node test/effort.test.mjs && node test/drivers.test.mjs && node test/platform.test.mjs && node test/wait.test.mjs && node test/status.test.mjs && node test/output.test.mjs && node test/stream.test.mjs && node test/routing.test.mjs && node test/deadlock.test.mjs && node test/handler-validation.test.mjs && node test/index-handler.test.mjs && node test/ruleset.test.mjs && node test/ruleset-exec.test.mjs && node test/ruleset-handler.test.mjs && node test/failover.test.mjs && node test/global-concurrency-cap.test.mjs && node test/zombie.test.mjs && node test/orchestration-marker.test.mjs && node test/orchestration-hook-core.test.mjs && node test/orchestration-adapters.test.mjs && node test/orchestration-pretool.test.mjs && node test/orchestration-directives.test.mjs && node test/no-five-call.test.mjs && node test/check-worktree-subagent.test.mjs && node test/launch-agent-upsert.test.mjs && node test/claude-session-limit.test.mjs && node test/init-migration.test.mjs && node test/init-global.test.mjs && node test/mirror-fragments.test.mjs && node test/performance-tier-effort.test.mjs && node test/setup-repair.test.mjs && node test/setup-quoting.test.mjs && node test/setup-wire.test.mjs && node test/setup-cli-integration.test.mjs && node test/init.test.mjs && node test/model-selection-mode.test.mjs && node test/cli-args.test.mjs && node scripts/validate_provider.mjs && node scripts/validate_seed_sites.mjs && node scripts/validate_routing_audit.mjs && node test/seed-sites.test.mjs && node test/mcp-compliance.test.mjs"
41
- },
42
- "author": "Lexi Blackburn",
43
- "license": "Apache-2.0",
44
- "repository": {
45
- "type": "git",
46
- "url": "git+https://github.com/Heretyc/subagent-mcp.git"
47
- },
48
- "homepage": "https://github.com/Heretyc/subagent-mcp#readme",
49
- "bugs": {
50
- "url": "https://github.com/Heretyc/subagent-mcp/issues"
51
- },
52
- "dependencies": {
53
- "@anthropic-ai/claude-agent-sdk": "^0.3.177",
54
- "@modelcontextprotocol/sdk": "^1.0.0",
55
- "zod": "^4.4.3"
56
- },
57
- "devDependencies": {
58
- "@types/node": "^20.0.0",
59
- "typescript": "^5.0.0"
60
- },
61
- "engines": {
62
- "node": ">=18"
63
- },
64
- "publishConfig": {
65
- "registry": "https://registry.npmjs.org",
66
- "access": "public"
67
- }
68
- }
1
+ {
2
+ "name": "@heretyc/subagent-mcp",
3
+ "version": "2.10.4",
4
+ "description": "MCP server that launches and manages always-interactive Claude Code and Codex sub-agent sessions (no direct Anthropic/OpenAI API).",
5
+ "keywords": [
6
+ "mcp",
7
+ "model-context-protocol",
8
+ "mcp-server",
9
+ "claude",
10
+ "claude-code",
11
+ "codex",
12
+ "orchestration",
13
+ "subagent",
14
+ "sub-agent",
15
+ "multi-agent",
16
+ "ai-agents",
17
+ "anthropic",
18
+ "openai"
19
+ ],
20
+ "type": "module",
21
+ "main": "dist/index.js",
22
+ "bin": {
23
+ "subagent-mcp": "dist/index.js"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "directives",
28
+ "scripts/postinstall.mjs",
29
+ "LICENSE",
30
+ "NOTICE",
31
+ "README.md"
32
+ ],
33
+ "scripts": {
34
+ "check:versions": "node scripts/check_version_sync.mjs",
35
+ "build": "npm run check:versions && node scripts/gen-ruleset-scaffold.mjs && tsc && node scripts/copy-provider.mjs",
36
+ "verify:npmjs-release": "node scripts/verify_npmjs_release.mjs",
37
+ "start": "node dist/index.js",
38
+ "postinstall": "node scripts/postinstall.mjs",
39
+ "prepare": "npm run build",
40
+ "prepublishOnly": "npm test",
41
+ "test": "npm run check:versions && node test/effort.test.mjs && node test/drivers.test.mjs && node test/platform.test.mjs && node test/wait.test.mjs && node test/status.test.mjs && node test/output.test.mjs && node test/stream.test.mjs && node test/routing.test.mjs && node test/deadlock.test.mjs && node test/handler-validation.test.mjs && node test/index-handler.test.mjs && node test/ruleset.test.mjs && node test/ruleset-exec.test.mjs && node test/ruleset-handler.test.mjs && node test/failover.test.mjs && node test/global-concurrency-cap.test.mjs && node test/zombie.test.mjs && node test/orchestration-marker.test.mjs && node test/orchestration-hook-core.test.mjs && node test/orchestration-adapters.test.mjs && node test/orchestration-pretool.test.mjs && node test/orchestration-directives.test.mjs && node test/no-five-call.test.mjs && node test/check-worktree-subagent.test.mjs && node test/launch-agent-upsert.test.mjs && node test/claude-session-limit.test.mjs && node test/init-migration.test.mjs && node test/init-global.test.mjs && node test/mirror-fragments.test.mjs && node test/performance-tier-effort.test.mjs && node test/setup-repair.test.mjs && node test/setup-quoting.test.mjs && node test/setup-wire.test.mjs && node test/setup-cli-integration.test.mjs && node test/init.test.mjs && node test/model-selection-mode.test.mjs && node test/cli-args.test.mjs && node scripts/validate_provider.mjs && node scripts/validate_seed_sites.mjs && node scripts/validate_routing_audit.mjs && node test/seed-sites.test.mjs && node test/mcp-compliance.test.mjs"
42
+ },
43
+ "author": "Lexi Blackburn",
44
+ "license": "Apache-2.0",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/Heretyc/subagent-mcp.git"
48
+ },
49
+ "homepage": "https://github.com/Heretyc/subagent-mcp#readme",
50
+ "bugs": {
51
+ "url": "https://github.com/Heretyc/subagent-mcp/issues"
52
+ },
53
+ "dependencies": {
54
+ "@anthropic-ai/claude-agent-sdk": "^0.3.177",
55
+ "@modelcontextprotocol/sdk": "^1.0.0",
56
+ "zod": "^4.4.3"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^20.0.0",
60
+ "typescript": "^5.0.0"
61
+ },
62
+ "engines": {
63
+ "node": ">=18"
64
+ },
65
+ "publishConfig": {
66
+ "registry": "https://registry.npmjs.org",
67
+ "access": "public"
68
+ }
69
+ }