subagent-cli 0.1.1__py3-none-any.whl
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.
- subagent/__init__.py +7 -0
- subagent/acp_client.py +366 -0
- subagent/approval_utils.py +57 -0
- subagent/cli.py +1125 -0
- subagent/config.py +305 -0
- subagent/constants.py +21 -0
- subagent/controller_service.py +267 -0
- subagent/daemon.py +133 -0
- subagent/errors.py +24 -0
- subagent/handoff_service.py +354 -0
- subagent/hints.py +36 -0
- subagent/input_contract.py +121 -0
- subagent/launcher_service.py +30 -0
- subagent/output.py +41 -0
- subagent/paths.py +63 -0
- subagent/prompt_service.py +114 -0
- subagent/runtime_service.py +342 -0
- subagent/simple_yaml.py +202 -0
- subagent/state.py +1049 -0
- subagent/turn_service.py +558 -0
- subagent/worker_runtime.py +758 -0
- subagent/worker_service.py +362 -0
- subagent_cli-0.1.1.dist-info/METADATA +98 -0
- subagent_cli-0.1.1.dist-info/RECORD +27 -0
- subagent_cli-0.1.1.dist-info/WHEEL +4 -0
- subagent_cli-0.1.1.dist-info/entry_points.txt +3 -0
- subagent_cli-0.1.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"""Worker lifecycle service helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import shutil
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from .config import SubagentConfig
|
|
10
|
+
from .controller_service import read_env_handle, resolve_controller_id
|
|
11
|
+
from .errors import SubagentError
|
|
12
|
+
from .paths import resolve_workspace_path
|
|
13
|
+
from .runtime_service import launch_worker_runtime, stop_worker_runtime
|
|
14
|
+
from .state import WORKER_STATE_ERROR, StateStore
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def resolve_worker_controller_id(
|
|
18
|
+
store: StateStore,
|
|
19
|
+
*,
|
|
20
|
+
workspace: Path,
|
|
21
|
+
explicit_controller_id: str | None = None,
|
|
22
|
+
) -> str:
|
|
23
|
+
env_handle = read_env_handle()
|
|
24
|
+
env_controller_id: str | None = None
|
|
25
|
+
if env_handle is not None:
|
|
26
|
+
if env_handle.get("valid") is False:
|
|
27
|
+
raise SubagentError(
|
|
28
|
+
code="INVALID_CONTROLLER_HANDLE",
|
|
29
|
+
message="SUBAGENT_CTL_EPOCH is not a valid integer",
|
|
30
|
+
)
|
|
31
|
+
env_controller_id = str(env_handle["controllerId"])
|
|
32
|
+
|
|
33
|
+
target_controller_id = explicit_controller_id or env_controller_id
|
|
34
|
+
if target_controller_id is None:
|
|
35
|
+
target_controller_id = resolve_controller_id(
|
|
36
|
+
store,
|
|
37
|
+
workspace,
|
|
38
|
+
explicit_controller_id=None,
|
|
39
|
+
)
|
|
40
|
+
if target_controller_id is None:
|
|
41
|
+
raise SubagentError(
|
|
42
|
+
code="CONTROLLER_NOT_FOUND",
|
|
43
|
+
message=(
|
|
44
|
+
"Controller could not be resolved. Set SUBAGENT_CTL_* env vars, "
|
|
45
|
+
"use --controller-id, or run `subagent controller init` first."
|
|
46
|
+
),
|
|
47
|
+
details={"workspaceKey": str(workspace)},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if env_handle is not None and "epoch" in env_handle and "token" in env_handle:
|
|
51
|
+
if env_controller_id != target_controller_id:
|
|
52
|
+
raise SubagentError(
|
|
53
|
+
code="INVALID_CONTROLLER_HANDLE",
|
|
54
|
+
message="SUBAGENT_CTL_ID does not match target controller",
|
|
55
|
+
details={
|
|
56
|
+
"envControllerId": env_controller_id,
|
|
57
|
+
"targetControllerId": target_controller_id,
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
valid = store.validate_handle(
|
|
61
|
+
target_controller_id,
|
|
62
|
+
int(env_handle["epoch"]),
|
|
63
|
+
str(env_handle["token"]),
|
|
64
|
+
)
|
|
65
|
+
if not valid:
|
|
66
|
+
raise SubagentError(
|
|
67
|
+
code="INVALID_CONTROLLER_HANDLE",
|
|
68
|
+
message="Controller handle is stale or invalid",
|
|
69
|
+
details={"controllerId": target_controller_id},
|
|
70
|
+
)
|
|
71
|
+
elif env_handle is not None:
|
|
72
|
+
raise SubagentError(
|
|
73
|
+
code="INVALID_CONTROLLER_HANDLE",
|
|
74
|
+
message="Incomplete controller handle in environment",
|
|
75
|
+
details={"env": env_handle},
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
controller = store.get_controller(target_controller_id)
|
|
79
|
+
if controller is None:
|
|
80
|
+
raise SubagentError(
|
|
81
|
+
code="CONTROLLER_NOT_FOUND",
|
|
82
|
+
message=f"Controller not found: {target_controller_id}",
|
|
83
|
+
details={"controllerId": target_controller_id},
|
|
84
|
+
)
|
|
85
|
+
return target_controller_id
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _resolve_launcher(config: SubagentConfig, launcher: str | None) -> str:
|
|
89
|
+
value = launcher
|
|
90
|
+
if value is None:
|
|
91
|
+
default_launcher = config.defaults.get("launcher")
|
|
92
|
+
if isinstance(default_launcher, str) and default_launcher:
|
|
93
|
+
value = default_launcher
|
|
94
|
+
if value is None:
|
|
95
|
+
raise SubagentError(
|
|
96
|
+
code="LAUNCHER_NOT_FOUND",
|
|
97
|
+
message="Launcher is required. Set --launcher or defaults.launcher in config.",
|
|
98
|
+
)
|
|
99
|
+
if value not in config.launchers:
|
|
100
|
+
raise SubagentError(
|
|
101
|
+
code="LAUNCHER_NOT_FOUND",
|
|
102
|
+
message=f"Launcher not found: {value}",
|
|
103
|
+
details={"launcher": value},
|
|
104
|
+
)
|
|
105
|
+
return value
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _resolve_profile(config: SubagentConfig, profile: str | None) -> str:
|
|
109
|
+
value = profile
|
|
110
|
+
if value is None:
|
|
111
|
+
default_profile = config.defaults.get("profile")
|
|
112
|
+
if isinstance(default_profile, str) and default_profile:
|
|
113
|
+
value = default_profile
|
|
114
|
+
if value is None:
|
|
115
|
+
raise SubagentError(
|
|
116
|
+
code="PROFILE_NOT_FOUND",
|
|
117
|
+
message="Profile is required. Set --profile or defaults.profile in config.",
|
|
118
|
+
)
|
|
119
|
+
if value not in config.profiles:
|
|
120
|
+
raise SubagentError(
|
|
121
|
+
code="PROFILE_NOT_FOUND",
|
|
122
|
+
message=f"Profile not found: {value}",
|
|
123
|
+
details={"profile": value},
|
|
124
|
+
)
|
|
125
|
+
return value
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _resolve_packs(config: SubagentConfig, profile_name: str, packs: list[str]) -> list[str]:
|
|
129
|
+
resolved: list[str] = []
|
|
130
|
+
if packs:
|
|
131
|
+
resolved = packs
|
|
132
|
+
else:
|
|
133
|
+
profile = config.profiles[profile_name]
|
|
134
|
+
if profile.default_packs:
|
|
135
|
+
resolved = list(profile.default_packs)
|
|
136
|
+
else:
|
|
137
|
+
defaults_packs = config.defaults.get("packs")
|
|
138
|
+
if isinstance(defaults_packs, list):
|
|
139
|
+
resolved = [str(item) for item in defaults_packs]
|
|
140
|
+
for pack_name in resolved:
|
|
141
|
+
if pack_name not in config.packs:
|
|
142
|
+
raise SubagentError(
|
|
143
|
+
code="PACK_NOT_FOUND",
|
|
144
|
+
message=f"Pack not found: {pack_name}",
|
|
145
|
+
details={"pack": pack_name},
|
|
146
|
+
)
|
|
147
|
+
return resolved
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def start_worker(
|
|
151
|
+
store: StateStore,
|
|
152
|
+
config: SubagentConfig,
|
|
153
|
+
*,
|
|
154
|
+
workspace: Path,
|
|
155
|
+
worker_cwd: Path,
|
|
156
|
+
controller_id: str | None,
|
|
157
|
+
launcher: str | None,
|
|
158
|
+
profile: str | None,
|
|
159
|
+
packs: list[str],
|
|
160
|
+
label: str | None,
|
|
161
|
+
debug_mode: bool = False,
|
|
162
|
+
) -> dict[str, Any]:
|
|
163
|
+
resolved_workspace = resolve_workspace_path(workspace)
|
|
164
|
+
target_controller_id = resolve_worker_controller_id(
|
|
165
|
+
store,
|
|
166
|
+
workspace=resolved_workspace,
|
|
167
|
+
explicit_controller_id=controller_id,
|
|
168
|
+
)
|
|
169
|
+
target_launcher = _resolve_launcher(config, launcher)
|
|
170
|
+
target_profile = _resolve_profile(config, profile)
|
|
171
|
+
target_packs = _resolve_packs(config, target_profile, packs)
|
|
172
|
+
resolved_cwd = resolve_workspace_path(worker_cwd)
|
|
173
|
+
resolved_label = label or "worker"
|
|
174
|
+
|
|
175
|
+
worker = store.create_worker(
|
|
176
|
+
controller_id=target_controller_id,
|
|
177
|
+
launcher=target_launcher,
|
|
178
|
+
profile=target_profile,
|
|
179
|
+
packs=target_packs,
|
|
180
|
+
cwd=str(resolved_cwd),
|
|
181
|
+
label=resolved_label,
|
|
182
|
+
)
|
|
183
|
+
launcher_entry = config.launchers[target_launcher]
|
|
184
|
+
if not debug_mode:
|
|
185
|
+
if launcher_entry.backend_kind != "acp-stdio":
|
|
186
|
+
raise SubagentError(
|
|
187
|
+
code="BACKEND_UNAVAILABLE",
|
|
188
|
+
message=f"Unsupported backend kind for runtime: {launcher_entry.backend_kind}",
|
|
189
|
+
details={"launcher": target_launcher, "backendKind": launcher_entry.backend_kind},
|
|
190
|
+
)
|
|
191
|
+
if shutil.which(launcher_entry.command) is None and "/" not in launcher_entry.command:
|
|
192
|
+
raise SubagentError(
|
|
193
|
+
code="BACKEND_UNAVAILABLE",
|
|
194
|
+
message=f"Launcher command not available: {launcher_entry.command}",
|
|
195
|
+
details={"launcher": target_launcher, "command": launcher_entry.command},
|
|
196
|
+
)
|
|
197
|
+
if "/" in launcher_entry.command and not Path(launcher_entry.command).expanduser().exists():
|
|
198
|
+
raise SubagentError(
|
|
199
|
+
code="BACKEND_UNAVAILABLE",
|
|
200
|
+
message=f"Launcher command not available: {launcher_entry.command}",
|
|
201
|
+
details={"launcher": target_launcher, "command": launcher_entry.command},
|
|
202
|
+
)
|
|
203
|
+
try:
|
|
204
|
+
launch_worker_runtime(
|
|
205
|
+
store,
|
|
206
|
+
worker_id=str(worker["worker_id"]),
|
|
207
|
+
launcher=launcher_entry,
|
|
208
|
+
cwd=str(resolved_cwd),
|
|
209
|
+
)
|
|
210
|
+
except SubagentError as error:
|
|
211
|
+
store.update_worker_state(
|
|
212
|
+
str(worker["worker_id"]),
|
|
213
|
+
next_state=WORKER_STATE_ERROR,
|
|
214
|
+
allow_any_transition=True,
|
|
215
|
+
last_error=error.message,
|
|
216
|
+
)
|
|
217
|
+
raise
|
|
218
|
+
refreshed = store.get_worker(str(worker["worker_id"]))
|
|
219
|
+
if refreshed is not None:
|
|
220
|
+
worker = refreshed
|
|
221
|
+
return {
|
|
222
|
+
"workerId": worker["worker_id"],
|
|
223
|
+
"controllerId": worker["controller_id"],
|
|
224
|
+
"sessionId": worker["session_id"],
|
|
225
|
+
"launcher": worker["launcher"],
|
|
226
|
+
"profile": worker["profile"],
|
|
227
|
+
"packs": worker["packs"],
|
|
228
|
+
"cwd": worker["cwd"],
|
|
229
|
+
"label": worker["label"],
|
|
230
|
+
"state": worker["state"],
|
|
231
|
+
"recoveryState": worker["recovery_state"],
|
|
232
|
+
"runtimePid": worker.get("runtime_pid"),
|
|
233
|
+
"runtimeSocket": worker.get("runtime_socket"),
|
|
234
|
+
"createdAt": worker["created_at"],
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def list_workers(
|
|
239
|
+
store: StateStore,
|
|
240
|
+
*,
|
|
241
|
+
controller_id: str | None = None,
|
|
242
|
+
) -> list[dict[str, Any]]:
|
|
243
|
+
workers = store.list_workers(controller_id=controller_id)
|
|
244
|
+
return [
|
|
245
|
+
{
|
|
246
|
+
"workerId": row["worker_id"],
|
|
247
|
+
"controllerId": row["controller_id"],
|
|
248
|
+
"label": row["label"],
|
|
249
|
+
"launcher": row["launcher"],
|
|
250
|
+
"profile": row["profile"],
|
|
251
|
+
"state": row["state"],
|
|
252
|
+
"cwd": row["cwd"],
|
|
253
|
+
"sessionId": row["session_id"],
|
|
254
|
+
"activeTurnId": row.get("active_turn_id"),
|
|
255
|
+
"runtimePid": row.get("runtime_pid"),
|
|
256
|
+
"runtimeSocket": row.get("runtime_socket"),
|
|
257
|
+
"createdAt": row["created_at"],
|
|
258
|
+
"updatedAt": row["updated_at"],
|
|
259
|
+
"stoppedAt": row["stopped_at"],
|
|
260
|
+
}
|
|
261
|
+
for row in workers
|
|
262
|
+
]
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def show_worker(store: StateStore, worker_id: str) -> dict[str, Any]:
|
|
266
|
+
worker = store.get_worker(worker_id)
|
|
267
|
+
if worker is None:
|
|
268
|
+
raise SubagentError(
|
|
269
|
+
code="WORKER_NOT_FOUND",
|
|
270
|
+
message=f"Worker not found: {worker_id}",
|
|
271
|
+
details={"workerId": worker_id},
|
|
272
|
+
)
|
|
273
|
+
return {
|
|
274
|
+
"workerId": worker["worker_id"],
|
|
275
|
+
"controllerId": worker["controller_id"],
|
|
276
|
+
"label": worker["label"],
|
|
277
|
+
"launcher": worker["launcher"],
|
|
278
|
+
"profile": worker["profile"],
|
|
279
|
+
"packs": worker["packs"],
|
|
280
|
+
"cwd": worker["cwd"],
|
|
281
|
+
"sessionId": worker["session_id"],
|
|
282
|
+
"activeTurnId": worker.get("active_turn_id"),
|
|
283
|
+
"runtimePid": worker.get("runtime_pid"),
|
|
284
|
+
"runtimeSocket": worker.get("runtime_socket"),
|
|
285
|
+
"state": worker["state"],
|
|
286
|
+
"recoveryState": worker["recovery_state"],
|
|
287
|
+
"createdAt": worker["created_at"],
|
|
288
|
+
"updatedAt": worker["updated_at"],
|
|
289
|
+
"stoppedAt": worker["stopped_at"],
|
|
290
|
+
"lastError": worker["last_error"],
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def stop_worker(store: StateStore, worker_id: str, *, force: bool = False) -> dict[str, Any]:
|
|
295
|
+
worker = store.get_worker(worker_id)
|
|
296
|
+
if worker is None:
|
|
297
|
+
raise SubagentError(
|
|
298
|
+
code="WORKER_NOT_FOUND",
|
|
299
|
+
message=f"Worker not found: {worker_id}",
|
|
300
|
+
details={"workerId": worker_id},
|
|
301
|
+
)
|
|
302
|
+
if worker.get("runtime_socket"):
|
|
303
|
+
stop_worker_runtime(store, worker_id=worker_id, reason="worker stopped by manager")
|
|
304
|
+
worker = store.stop_worker(worker_id, force=force)
|
|
305
|
+
return {
|
|
306
|
+
"workerId": worker["worker_id"],
|
|
307
|
+
"controllerId": worker["controller_id"],
|
|
308
|
+
"state": worker["state"],
|
|
309
|
+
"stoppedAt": worker["stopped_at"],
|
|
310
|
+
"updatedAt": worker["updated_at"],
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def inspect_worker(store: StateStore, worker_id: str, *, events_limit: int = 20) -> dict[str, Any]:
|
|
315
|
+
worker = show_worker(store, worker_id)
|
|
316
|
+
row = store.get_worker(worker_id)
|
|
317
|
+
assert row is not None
|
|
318
|
+
pending_approvals = store.list_pending_approval_requests(worker_id)
|
|
319
|
+
latest_handoff = store.get_latest_handoff_snapshot(worker_id)
|
|
320
|
+
events = store.list_worker_events(worker_id, limit=events_limit)
|
|
321
|
+
event_items = [
|
|
322
|
+
{
|
|
323
|
+
"eventId": event["event_id"],
|
|
324
|
+
"ts": event["ts"],
|
|
325
|
+
"type": event["event_type"],
|
|
326
|
+
"turnId": event.get("turn_id"),
|
|
327
|
+
"data": event["data"],
|
|
328
|
+
}
|
|
329
|
+
for event in events
|
|
330
|
+
]
|
|
331
|
+
|
|
332
|
+
recovery_state = "restartable"
|
|
333
|
+
if latest_handoff is not None:
|
|
334
|
+
recovery_state = "handoff_available"
|
|
335
|
+
if str(row["state"]) == "stopped" and latest_handoff is None:
|
|
336
|
+
recovery_state = "lost"
|
|
337
|
+
worker["recoveryState"] = recovery_state
|
|
338
|
+
return {
|
|
339
|
+
"worker": worker,
|
|
340
|
+
"pendingApprovals": [
|
|
341
|
+
{
|
|
342
|
+
"requestId": req["request_id"],
|
|
343
|
+
"turnId": req.get("turn_id"),
|
|
344
|
+
"kind": req["kind"],
|
|
345
|
+
"message": req["message"],
|
|
346
|
+
"options": req["options"],
|
|
347
|
+
"createdAt": req["created_at"],
|
|
348
|
+
}
|
|
349
|
+
for req in pending_approvals
|
|
350
|
+
],
|
|
351
|
+
"latestHandoff": (
|
|
352
|
+
{
|
|
353
|
+
"snapshotId": latest_handoff["snapshot_id"],
|
|
354
|
+
"handoffPath": latest_handoff["handoff_path"],
|
|
355
|
+
"checkpointPath": latest_handoff["checkpoint_path"],
|
|
356
|
+
"createdAt": latest_handoff["created_at"],
|
|
357
|
+
}
|
|
358
|
+
if latest_handoff is not None
|
|
359
|
+
else None
|
|
360
|
+
),
|
|
361
|
+
"events": event_items,
|
|
362
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: subagent-cli
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Protocol-agnostic worker orchestration CLI
|
|
5
|
+
Author: niitsuma-t
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 niitsuma-t
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Keywords: acp,agent,automation,cli,orchestration
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Environment :: Console
|
|
31
|
+
Classifier: Intended Audience :: Developers
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
39
|
+
Classifier: Topic :: Utilities
|
|
40
|
+
Requires-Python: >=3.11
|
|
41
|
+
Requires-Dist: typer>=0.24.1
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# subagent-cli
|
|
45
|
+
|
|
46
|
+
`subagent-cli` is a protocol-agnostic CLI for orchestrating worker agents from a parent controller.
|
|
47
|
+
In practice, it is a control-plane CLI that a manager agent (for example Codex or Claude Code) can use to launch and coordinate other worker agents.
|
|
48
|
+
The CLI surface is protocol-agnostic, while the current runtime implementation is ACP-based (`acp-stdio`).
|
|
49
|
+
|
|
50
|
+
## Status
|
|
51
|
+
- Alpha (`v0.1.x`)
|
|
52
|
+
- Local single-host focused
|
|
53
|
+
- Python 3.11+
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
- Worker lifecycle: start, list, show, inspect, stop
|
|
57
|
+
- Turn operations: send, watch, wait, approve, cancel
|
|
58
|
+
- Handoff workflow: `worker handoff` and `worker continue`
|
|
59
|
+
- Strict approval flow with structured events
|
|
60
|
+
- ACP runtime integration (`acp-stdio`) with runtime restart + session resume (`session/load`)
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
- From PyPI:
|
|
64
|
+
`pip install subagent-cli`
|
|
65
|
+
- From local artifacts:
|
|
66
|
+
`pip install dist/subagent_cli-*.whl`
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
1. Prepare config:
|
|
70
|
+
`mkdir -p ~/.config/subagent && cp config.example.yaml ~/.config/subagent/config.yaml`
|
|
71
|
+
2. Initialize a controller in your workspace:
|
|
72
|
+
`subagent controller init --cwd .`
|
|
73
|
+
3. Start a worker:
|
|
74
|
+
`subagent worker start --cwd .`
|
|
75
|
+
4. Send an instruction:
|
|
76
|
+
`subagent send --worker <worker-id> --text "Investigate failing tests"`
|
|
77
|
+
5. Watch events:
|
|
78
|
+
`subagent watch --worker <worker-id> --ndjson`
|
|
79
|
+
|
|
80
|
+
For local simulation/testing without a real ACP launcher:
|
|
81
|
+
`subagent worker start --cwd . --debug-mode`
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
- Default config path: `~/.config/subagent/config.yaml`
|
|
85
|
+
- Override config path: `SUBAGENT_CONFIG=/path/to/config.yaml`
|
|
86
|
+
- Example config: [config.example.yaml](config.example.yaml)
|
|
87
|
+
|
|
88
|
+
## State
|
|
89
|
+
- Default state DB: `~/.local/share/subagent/state.db`
|
|
90
|
+
- Project hint file: `<workspace>/.subagent/controller.json`
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
- Architecture note: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)
|
|
94
|
+
- Examples: [docs/examples](docs/examples)
|
|
95
|
+
- Contributing and release process: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
MIT ([LICENSE](LICENSE))
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
subagent/__init__.py,sha256=qnX1gfMPNNNem-NAVnTgNAksmtnx2akJGvHU0cWUtYk,135
|
|
2
|
+
subagent/acp_client.py,sha256=VTkQtgV2-sD0_e2CNxsOxN5eKzrF8tulrGrwhYuuczY,12166
|
|
3
|
+
subagent/approval_utils.py,sha256=hu55JOvFNpvmE1gGAilc_4g5wUP0OKL07BOFv36J1Z0,1755
|
|
4
|
+
subagent/cli.py,sha256=j7FSR64XeA1Hy9dWdf0q7eb4mOLGn5SdP-qL3dosoak,41155
|
|
5
|
+
subagent/config.py,sha256=RAl18DpwHP0KZFpWMz4vpSmPleQsxZBrjWLR7zbb_eI,11119
|
|
6
|
+
subagent/constants.py,sha256=B7yVltkQh2AetpkUIJ3CE8rqWvB9lJVmbzawHHSbX9w,693
|
|
7
|
+
subagent/controller_service.py,sha256=HpRs4Z8WxJZKlEkbDrF_1XJK8bkkrLREHqi5BBXMPNo,8396
|
|
8
|
+
subagent/daemon.py,sha256=h0vdM1UX9hNZOorAq76VrVxLmV_wyM5LWJA2DkOsU2I,3726
|
|
9
|
+
subagent/errors.py,sha256=8cInh4Ly_BGtIlRSVcbmG0pGuEYtCW_DSOgrUIS9l8A,637
|
|
10
|
+
subagent/handoff_service.py,sha256=4Gol2MGl55WK27ftIIxmfzpLVxmzIgb7V2e8v5ys90Y,11727
|
|
11
|
+
subagent/hints.py,sha256=Di71I3y5zlXp-EHGBOtxeho005yKdKs-2k24Npdg5QU,1067
|
|
12
|
+
subagent/input_contract.py,sha256=00ep9qn_azDoSH8s5VjtRATnK5VBG8nlNT_kJrZyf1U,3469
|
|
13
|
+
subagent/launcher_service.py,sha256=xGvi7xqT31ZXrPKfuyApL0_ymwo9yWg4RIHZtiJiUH4,919
|
|
14
|
+
subagent/output.py,sha256=k-YUydAcmcZKO1gyJVpcbyssreJJTnrAvU1yiGk2bAA,1001
|
|
15
|
+
subagent/paths.py,sha256=wswLFq4Hx7x00offBYksO-0eeNHbfnBQ4vzW7bVUzA8,1848
|
|
16
|
+
subagent/prompt_service.py,sha256=f3T0emS9_JsIQo-CEHi2vusCMcMf5UiMPV2SZbkdefo,4046
|
|
17
|
+
subagent/runtime_service.py,sha256=bi3ZkdsHNZUODX8VNAhMkDSU9dnaIUxlnF5eILhRfuc,10984
|
|
18
|
+
subagent/simple_yaml.py,sha256=LeGdC0K_UQyilwAV7jY5JjMXHyJFLFRd7h55Sbv66FQ,6418
|
|
19
|
+
subagent/state.py,sha256=1juhxJNFDd7rytjTMeEjsZ9FAgIxvzIghx0yRFbr5F8,37722
|
|
20
|
+
subagent/turn_service.py,sha256=B15L5yKxXl8N7KiWsuoLcDf4L2-yaYtTrDLYYbyG1fE,17095
|
|
21
|
+
subagent/worker_runtime.py,sha256=h_c7giLmqnRa2qD3o946DEQJ7j0fkIv96hzkrOppcP0,30255
|
|
22
|
+
subagent/worker_service.py,sha256=S5BZZiQoYOI625r5d7IokfWqcnyi_aVH0nFNWMmWHSY,12992
|
|
23
|
+
subagent_cli-0.1.1.dist-info/METADATA,sha256=9V0a_Rad7YjA7ZzgCkqUj7qoGjDj480AacWefyX1stE,3994
|
|
24
|
+
subagent_cli-0.1.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
25
|
+
subagent_cli-0.1.1.dist-info/entry_points.txt,sha256=ej72eXylNqoh_MXworT0vZAvw-eRSB_DhAfmL8KDH6k,80
|
|
26
|
+
subagent_cli-0.1.1.dist-info/licenses/LICENSE,sha256=HiXGtv_7dfZp45AN24NM90E2jwRj7JI9VnetTQ91Z_o,1067
|
|
27
|
+
subagent_cli-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 niitsuma-t
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|