subharness 0.0.5 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -5
- package/dist/adapters/claude-events.d.ts +71 -0
- package/dist/adapters/claude-events.js +860 -0
- package/dist/adapters/claude-events.js.map +1 -0
- package/dist/adapters/claude-process.js +8 -1
- package/dist/adapters/claude-process.js.map +1 -1
- package/dist/adapters/claude-tools.d.ts +6 -2
- package/dist/adapters/claude-tools.js +14 -12
- package/dist/adapters/claude-tools.js.map +1 -1
- package/dist/adapters/claude-worker-client.d.ts +60 -0
- package/dist/adapters/claude-worker-client.js +573 -0
- package/dist/adapters/claude-worker-client.js.map +1 -0
- package/dist/adapters/claude-worker-process.d.ts +20 -0
- package/dist/adapters/claude-worker-process.js +76 -0
- package/dist/adapters/claude-worker-process.js.map +1 -0
- package/dist/adapters/claude-worker-protocol.d.ts +96 -0
- package/dist/adapters/claude-worker-protocol.js +2 -0
- package/dist/adapters/claude-worker-protocol.js.map +1 -0
- package/dist/adapters/claude-worker.d.ts +1 -0
- package/dist/adapters/claude-worker.js +171 -0
- package/dist/adapters/claude-worker.js.map +1 -0
- package/dist/adapters/claude.d.ts +20 -6
- package/dist/adapters/claude.js +151 -69
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex-events.d.ts +52 -0
- package/dist/adapters/codex-events.js +672 -0
- package/dist/adapters/codex-events.js.map +1 -0
- package/dist/adapters/codex-turn-failure.d.ts +2 -0
- package/dist/adapters/codex-turn-failure.js +116 -0
- package/dist/adapters/codex-turn-failure.js.map +1 -0
- package/dist/adapters/codex.js +44 -7
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/copilot-events.d.ts +68 -0
- package/dist/adapters/copilot-events.js +650 -0
- package/dist/adapters/copilot-events.js.map +1 -0
- package/dist/adapters/copilot.js +24 -4
- package/dist/adapters/copilot.js.map +1 -1
- package/dist/adapters/cursor-acp-events.d.ts +36 -0
- package/dist/adapters/cursor-acp-events.js +251 -0
- package/dist/adapters/cursor-acp-events.js.map +1 -0
- package/dist/adapters/cursor-cli-session.d.ts +1 -0
- package/dist/adapters/cursor-cli-session.js +26 -5
- package/dist/adapters/cursor-cli-session.js.map +1 -1
- package/dist/adapters/cursor-cli.js +5 -0
- package/dist/adapters/cursor-cli.js.map +1 -1
- package/dist/adapters/cursor-sdk-events.d.ts +30 -0
- package/dist/adapters/cursor-sdk-events.js +233 -0
- package/dist/adapters/cursor-sdk-events.js.map +1 -0
- package/dist/adapters/cursor-session.js +56 -7
- package/dist/adapters/cursor-session.js.map +1 -1
- package/dist/adapters/cursor-startup.js +8 -2
- package/dist/adapters/cursor-startup.js.map +1 -1
- package/dist/adapters/event-normalizer.d.ts +57 -0
- package/dist/adapters/event-normalizer.js +143 -0
- package/dist/adapters/event-normalizer.js.map +1 -0
- package/dist/adapters/event-secrets.d.ts +17 -0
- package/dist/adapters/event-secrets.js +28 -0
- package/dist/adapters/event-secrets.js.map +1 -0
- package/dist/adapters/event-types.d.ts +58 -0
- package/dist/adapters/event-types.js +2 -0
- package/dist/adapters/event-types.js.map +1 -0
- package/dist/adapters/fx-events.d.ts +37 -0
- package/dist/adapters/fx-events.js +393 -0
- package/dist/adapters/fx-events.js.map +1 -0
- package/dist/adapters/fx-rpc.d.ts +2 -0
- package/dist/adapters/fx-rpc.js +11 -5
- package/dist/adapters/fx-rpc.js.map +1 -1
- package/dist/adapters/fx.js +73 -8
- package/dist/adapters/fx.js.map +1 -1
- package/dist/adapters/opencode-events.d.ts +58 -0
- package/dist/adapters/opencode-events.js +653 -0
- package/dist/adapters/opencode-events.js.map +1 -0
- package/dist/adapters/opencode-http.d.ts +1 -0
- package/dist/adapters/opencode-http.js +8 -7
- package/dist/adapters/opencode-http.js.map +1 -1
- package/dist/adapters/opencode.js +50 -9
- package/dist/adapters/opencode.js.map +1 -1
- package/dist/adapters/rpc.d.ts +2 -0
- package/dist/adapters/rpc.js +11 -5
- package/dist/adapters/rpc.js.map +1 -1
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/cli/args.d.ts +3 -1
- package/dist/cli/args.js +25 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/catalog-worker.js.map +1 -1
- package/dist/cli/dashboard-client.d.ts +1 -0
- package/dist/cli/dashboard-client.js +32 -31
- package/dist/cli/dashboard-client.js.map +1 -1
- package/dist/cli/dashboard-controller.js +6 -7
- package/dist/cli/dashboard-controller.js.map +1 -1
- package/dist/cli/dashboard-detail-view.d.ts +14 -8
- package/dist/cli/dashboard-detail-view.js +15 -44
- package/dist/cli/dashboard-detail-view.js.map +1 -1
- package/dist/cli/dashboard-history-view.d.ts +3 -12
- package/dist/cli/dashboard-history-view.js +18 -82
- package/dist/cli/dashboard-history-view.js.map +1 -1
- package/dist/cli/dashboard-live.d.ts +32 -0
- package/dist/cli/dashboard-live.js +177 -0
- package/dist/cli/dashboard-live.js.map +1 -0
- package/dist/cli/dashboard-renderer.d.ts +21 -1
- package/dist/cli/dashboard-renderer.js +85 -21
- package/dist/cli/dashboard-renderer.js.map +1 -1
- package/dist/cli/dashboard-steps.d.ts +53 -0
- package/dist/cli/dashboard-steps.js +157 -0
- package/dist/cli/dashboard-steps.js.map +1 -0
- package/dist/cli/dashboard-task-format.d.ts +15 -0
- package/dist/cli/dashboard-task-format.js +119 -0
- package/dist/cli/dashboard-task-format.js.map +1 -0
- package/dist/cli/dashboard-task-view.d.ts +66 -0
- package/dist/cli/dashboard-task-view.js +325 -0
- package/dist/cli/dashboard-task-view.js.map +1 -0
- package/dist/cli/dashboard.d.ts +2 -0
- package/dist/cli/dashboard.js +71 -6
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/extensions-client.d.ts +23 -0
- package/dist/cli/extensions-client.js +147 -0
- package/dist/cli/extensions-client.js.map +1 -0
- package/dist/cli/extensions.d.ts +14 -0
- package/dist/cli/extensions.js +181 -0
- package/dist/cli/extensions.js.map +1 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +21 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +107 -47
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.js +1 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/events/content.d.ts +43 -0
- package/dist/events/content.js +249 -0
- package/dist/events/content.js.map +1 -0
- package/dist/events/queue.d.ts +59 -0
- package/dist/events/queue.js +144 -0
- package/dist/events/queue.js.map +1 -0
- package/dist/events/validate.d.ts +22 -0
- package/dist/events/validate.js +542 -0
- package/dist/events/validate.js.map +1 -0
- package/dist/extensions/catalog.d.ts +33 -0
- package/dist/extensions/catalog.js +101 -0
- package/dist/extensions/catalog.js.map +1 -0
- package/dist/extensions/child-protocol.d.ts +38 -0
- package/dist/extensions/child-protocol.js +2 -0
- package/dist/extensions/child-protocol.js.map +1 -0
- package/dist/extensions/child.d.ts +1 -0
- package/dist/extensions/child.js +125 -0
- package/dist/extensions/child.js.map +1 -0
- package/dist/extensions/consent.d.ts +13 -0
- package/dist/extensions/consent.js +204 -0
- package/dist/extensions/consent.js.map +1 -0
- package/dist/extensions/environment.d.ts +1 -0
- package/dist/extensions/environment.js +12 -0
- package/dist/extensions/environment.js.map +1 -0
- package/dist/extensions/identity.d.ts +9 -0
- package/dist/extensions/identity.js +28 -0
- package/dist/extensions/identity.js.map +1 -0
- package/dist/extensions/log.d.ts +5 -0
- package/dist/extensions/log.js +80 -0
- package/dist/extensions/log.js.map +1 -0
- package/dist/extensions/manifest.d.ts +7 -0
- package/dist/extensions/manifest.js +213 -0
- package/dist/extensions/manifest.js.map +1 -0
- package/dist/extensions/types.d.ts +24 -0
- package/dist/extensions/types.js +2 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/extensions.d.ts +5 -0
- package/dist/extensions.js +2 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/approval-registry.d.ts +15 -2
- package/dist/runtime/approval-registry.js +173 -6
- package/dist/runtime/approval-registry.js.map +1 -1
- package/dist/runtime/capture.d.ts +22 -0
- package/dist/runtime/capture.js +352 -0
- package/dist/runtime/capture.js.map +1 -0
- package/dist/runtime/catalog.d.ts +39 -0
- package/dist/runtime/catalog.js +84 -0
- package/dist/runtime/catalog.js.map +1 -0
- package/dist/runtime/client.d.ts +2 -1
- package/dist/runtime/client.js +52 -65
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +49 -8
- package/dist/runtime/coordinator.js +380 -44
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/daemon.js +20 -6
- package/dist/runtime/daemon.js.map +1 -1
- package/dist/runtime/dashboard-workspace.js +5 -1
- package/dist/runtime/dashboard-workspace.js.map +1 -1
- package/dist/runtime/dashboard.d.ts +4 -0
- package/dist/runtime/dashboard.js +8 -0
- package/dist/runtime/dashboard.js.map +1 -1
- package/dist/runtime/definition.d.ts +6 -1
- package/dist/runtime/definition.js +31 -1
- package/dist/runtime/definition.js.map +1 -1
- package/dist/runtime/event-operation.d.ts +41 -0
- package/dist/runtime/event-operation.js +290 -0
- package/dist/runtime/event-operation.js.map +1 -0
- package/dist/runtime/event-owner.d.ts +94 -0
- package/dist/runtime/event-owner.js +429 -0
- package/dist/runtime/event-owner.js.map +1 -0
- package/dist/runtime/event-source.d.ts +39 -0
- package/dist/runtime/event-source.js +344 -0
- package/dist/runtime/event-source.js.map +1 -0
- package/dist/runtime/extension-instance.d.ts +61 -0
- package/dist/runtime/extension-instance.js +356 -0
- package/dist/runtime/extension-instance.js.map +1 -0
- package/dist/runtime/extension-protocol.d.ts +47 -0
- package/dist/runtime/extension-protocol.js +33 -0
- package/dist/runtime/extension-protocol.js.map +1 -0
- package/dist/runtime/extension-service.d.ts +10 -0
- package/dist/runtime/extension-service.js +35 -0
- package/dist/runtime/extension-service.js.map +1 -0
- package/dist/runtime/extension-supervisor.d.ts +33 -0
- package/dist/runtime/extension-supervisor.js +251 -0
- package/dist/runtime/extension-supervisor.js.map +1 -0
- package/dist/runtime/native-owner.js +7 -1
- package/dist/runtime/native-owner.js.map +1 -1
- package/dist/runtime/pagination.d.ts +9 -0
- package/dist/runtime/pagination.js +36 -0
- package/dist/runtime/pagination.js.map +1 -0
- package/dist/runtime/sdk-observation.d.ts +8 -0
- package/dist/runtime/sdk-observation.js +75 -0
- package/dist/runtime/sdk-observation.js.map +1 -0
- package/dist/runtime/sdk-projection.d.ts +8 -0
- package/dist/runtime/sdk-projection.js +19 -0
- package/dist/runtime/sdk-projection.js.map +1 -0
- package/dist/runtime/sdk-service.d.ts +11 -0
- package/dist/runtime/sdk-service.js +109 -0
- package/dist/runtime/sdk-service.js.map +1 -0
- package/dist/runtime/select-native.d.ts +5 -1
- package/dist/runtime/select-native.js +39 -18
- package/dist/runtime/select-native.js.map +1 -1
- package/dist/runtime/service.d.ts +16 -1
- package/dist/runtime/service.js +257 -8
- package/dist/runtime/service.js.map +1 -1
- package/dist/runtime/session-event-wire.d.ts +29 -0
- package/dist/runtime/session-event-wire.js +2 -0
- package/dist/runtime/session-event-wire.js.map +1 -0
- package/dist/runtime/session-events-service.d.ts +8 -0
- package/dist/runtime/session-events-service.js +124 -0
- package/dist/runtime/session-events-service.js.map +1 -0
- package/dist/runtime/session-events-transport.d.ts +8 -0
- package/dist/runtime/session-events-transport.js +142 -0
- package/dist/runtime/session-events-transport.js.map +1 -0
- package/dist/runtime/session-launcher.js +1 -1
- package/dist/runtime/session-launcher.js.map +1 -1
- package/dist/runtime/snapshots.d.ts +103 -0
- package/dist/runtime/snapshots.js +124 -0
- package/dist/runtime/snapshots.js.map +1 -0
- package/dist/runtime/startup-lock.d.ts +2 -0
- package/dist/runtime/startup-lock.js +49 -5
- package/dist/runtime/startup-lock.js.map +1 -1
- package/dist/runtime/state.d.ts +27 -0
- package/dist/runtime/state.js +90 -17
- package/dist/runtime/state.js.map +1 -1
- package/dist/runtime/task-data.d.ts +38 -0
- package/dist/runtime/task-data.js +2 -0
- package/dist/runtime/task-data.js.map +1 -0
- package/dist/runtime/transport.d.ts +14 -0
- package/dist/runtime/transport.js +168 -0
- package/dist/runtime/transport.js.map +1 -0
- package/dist/runtime/types.d.ts +50 -9
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/worker-client.js +44 -13
- package/dist/runtime/worker-client.js.map +1 -1
- package/dist/runtime/worker-event-channel.d.ts +30 -0
- package/dist/runtime/worker-event-channel.js +141 -0
- package/dist/runtime/worker-event-channel.js.map +1 -0
- package/dist/runtime/worker-event-protocol.d.ts +88 -0
- package/dist/runtime/worker-event-protocol.js +114 -0
- package/dist/runtime/worker-event-protocol.js.map +1 -0
- package/dist/runtime/worker-events.d.ts +73 -0
- package/dist/runtime/worker-events.js +704 -0
- package/dist/runtime/worker-events.js.map +1 -0
- package/dist/runtime/worker-server.d.ts +3 -1
- package/dist/runtime/worker-server.js +163 -27
- package/dist/runtime/worker-server.js.map +1 -1
- package/dist/sdk/connected-events.d.ts +3 -0
- package/dist/sdk/connected-events.js +259 -0
- package/dist/sdk/connected-events.js.map +1 -0
- package/dist/sdk/connected-types.d.ts +44 -0
- package/dist/sdk/connected-types.js +2 -0
- package/dist/sdk/connected-types.js.map +1 -0
- package/dist/sdk/connected.d.ts +3 -0
- package/dist/sdk/connected.js +235 -0
- package/dist/sdk/connected.js.map +1 -0
- package/dist/sdk/event-types.d.ts +182 -0
- package/dist/sdk/event-types.js +2 -0
- package/dist/sdk/event-types.js.map +1 -0
- package/dist/sdk/execution-definition.d.ts +3 -0
- package/dist/sdk/execution-definition.js +59 -0
- package/dist/sdk/execution-definition.js.map +1 -0
- package/dist/sdk/execution-driver.d.ts +6 -0
- package/dist/sdk/execution-driver.js +86 -0
- package/dist/sdk/execution-driver.js.map +1 -0
- package/dist/sdk/execution-observation.d.ts +3 -0
- package/dist/sdk/execution-observation.js +35 -0
- package/dist/sdk/execution-observation.js.map +1 -0
- package/dist/sdk/execution-options.d.ts +17 -0
- package/dist/sdk/execution-options.js +115 -0
- package/dist/sdk/execution-options.js.map +1 -0
- package/dist/sdk/execution-types.d.ts +74 -0
- package/dist/sdk/execution-types.js +2 -0
- package/dist/sdk/execution-types.js.map +1 -0
- package/dist/sdk/execution.d.ts +3 -0
- package/dist/sdk/execution.js +3 -0
- package/dist/sdk/execution.js.map +1 -0
- package/dist/sdk/hosted-error.d.ts +3 -0
- package/dist/sdk/hosted-error.js +14 -0
- package/dist/sdk/hosted-error.js.map +1 -0
- package/dist/sdk/hosted.d.ts +23 -0
- package/dist/sdk/hosted.js +204 -0
- package/dist/sdk/hosted.js.map +1 -0
- package/dist/sdk/runner.d.ts +5 -0
- package/dist/sdk/runner.js +109 -0
- package/dist/sdk/runner.js.map +1 -0
- package/dist/sdk/tools.js +4 -1
- package/dist/sdk/tools.js.map +1 -1
- package/package.json +7 -3
- package/sdk/access-config.md +2 -0
- package/sdk/adapter-contract.md +32 -2
- package/sdk/agent-skill.md +3 -2
- package/sdk/agent.md +1 -1
- package/sdk/approvals.md +2 -0
- package/sdk/cli/dashboard-design.md +37 -9
- package/sdk/cli/dashboard-inspection.md +14 -6
- package/sdk/cli/extensions.md +44 -0
- package/sdk/cli/index.md +27 -4
- package/sdk/cli/output.md +13 -1
- package/sdk/completion-notifications.md +3 -1
- package/sdk/config.md +31 -2
- package/sdk/copilot.md +1 -1
- package/sdk/cursor.md +2 -2
- package/sdk/diagnostics.md +68 -0
- package/sdk/distribution.md +16 -4
- package/sdk/events.md +339 -0
- package/sdk/examples/chat-tool.ts +126 -0
- package/sdk/execution.md +762 -0
- package/sdk/extensions.md +181 -0
- package/sdk/fx.md +4 -2
- package/sdk/harnesses.md +1 -1
- package/sdk/index.md +48 -21
- package/sdk/message-delivery.md +4 -0
- package/sdk/opencode.md +1 -1
- package/sdk/permissions.md +2 -0
- package/sdk/plugins/sub-agents.md +4 -2
- package/sdk/project-team.md +29 -1
- package/sdk/sessions.md +6 -0
- package/sdk/tools.md +3 -1
- package/sdk/v1-runtime.md +20 -8
- package/dist/cli/catalog.d.ts +0 -26
- package/dist/cli/catalog.js +0 -41
- package/dist/cli/catalog.js.map +0 -1
package/sdk/v1-runtime.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# V1 Runtime Contract
|
|
2
2
|
|
|
3
|
-
The first usable version supplies a TypeScript definition SDK and the `subharness` CLI with Codex, Claude Code, fx, OpenCode, GitHub Copilot, and Cursor adapters. The library coordinates existing harnesses; it does not implement a model loop, sandbox, worktree manager, or native permission system.
|
|
3
|
+
The first usable version supplies a TypeScript definition and execution SDK and the `subharness` CLI with Codex, Claude Code, fx, OpenCode, GitHub Copilot, and Cursor adapters. The library coordinates existing harnesses; it does not implement a model loop, sandbox, worktree manager, or native permission system.
|
|
4
4
|
|
|
5
5
|
## Package and definitions
|
|
6
6
|
|
|
7
|
-
The package is `subharness`, with the primary executable `subharness` and identical `agent` compatibility alias. Node.js 22.18 or newer is required. ESM exports include `agent`, `tool`, `toolResult`, `codex`, `claudeCode`, `fx`, `opencode`, `copilot`, `cursor`, and their definition/configuration types. The public SDK defines reusable specialists; direct CLI harness targets also execute without a definition. Execution in
|
|
7
|
+
The package is `subharness`, with the primary executable `subharness` and identical `agent` compatibility alias. Node.js 22.18 or newer is required. ESM exports include `agent`, `tool`, `toolResult`, `codex`, `claudeCode`, `fx`, `opencode`, `copilot`, `cursor`, and their definition/configuration types. The public SDK defines reusable specialists; direct CLI harness targets also execute without a definition. Execution uses either the CLI or the connected or embedded [execution SDK](execution.md). The SDK additionally exports the client, runner, handle, result, access, approval and error types defined there, and the normalized types and subscriptions in [Session events](events.md). The `subharness/extensions` subpath supplies the authoring types for [User extensions](extensions.md); compiled extension modules require no runtime import of Subharness. The daemon, worker, catalog, and launcher rules below describe CLI execution; an embedded runner owns its coordinator and inline tool closures in the host process, while a connected client shares the CLI coordinator. Definition objects have readonly configuration fields and no execution methods. They contain functions and schemas and are not a serialization format.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
import { agent, codex, claudeCode, tool } from "subharness";
|
|
@@ -28,17 +28,17 @@ An omitted `--cwd` uses the command's working directory. `--prompt-file` paths r
|
|
|
28
28
|
|
|
29
29
|
An on-demand local coordinator owns sessions, queues, task relationships, and response records independently of individual CLI commands. It starts automatically; users do not install or manage a service. Each native session runs in a separate worker process whose working directory is the selected execution directory. Definition loading and custom tool execution in that worker use the same directory. Direct harness sessions carry a built-in target descriptor instead of a definition source reference and do not load TypeScript modules. They supply no specialist instructions, custom tools, or declared children; native instructions and project settings remain effective. Workers inherit the submitting environment, subject to the adapter's explicit authentication selection.
|
|
30
30
|
|
|
31
|
-
`check` is a CLI startup probe rather than an execution operation. It resolves the target and access configuration as `run` does, opens the native session in an isolated worker, and closes it without admitting a task or calling the adapter's turn interface. Success is withheld until the isolated worker exits and adapter-owned native processes confirm termination. Cleanup failure or uncertain native termination produces an error; after a failed graceful close, worker termination remains bounded and retains the cleanup diagnostic.
|
|
31
|
+
`check` is a CLI startup probe rather than an execution operation. It resolves the target and access configuration as `run` does, opens the native session in an isolated worker, and closes it without admitting a task or calling the adapter's turn interface. Success is withheld until the isolated worker exits and adapter-owned native processes confirm termination. Cleanup failure or uncertain native termination produces an error; after a failed graceful close, worker termination remains bounded and retains the cleanup diagnostic. The connected SDK exposes its own startup probe as `client.agents.check` under the [execution contract](execution.md); neither probe submits a task. The CLI probe does not require a coordinator for ordinary direct or specialist checks. Managed declared-child resolution still requires the active parent context used by `run`.
|
|
32
32
|
|
|
33
33
|
Readiness means only that the selected target's startup checks passed at that moment. It does not guarantee quota, successful task execution, shell or child-launch permissions, or continued availability, and it does not recursively check descendants. The probe may create an empty native conversation, a temporary session launcher, and adapter-owned temporary files. Loading personal access settings may update Git's local exclude file. Normal worker close removes library-owned temporary files. A removal failure is reported even though files can remain, and abrupt environment termination still cannot guarantee file cleanup.
|
|
34
34
|
|
|
35
35
|
The coordinator accepts local connections only. Its endpoint, instance identifier, and access token are stored with owner-only permissions under `~/.subharness/state/`. Task and session identifiers resolve through this coordinator from any working directory. Child invocation context is supplied privately by a session launcher that restores the coordinator location and parent context even when native shells change the inherited environment. Launchers use owner-only permissions, contain no provider credentials, and are removed when the session worker closes. Users do not supply parent identifiers or tokens in command flags. A context is accepted only while its parent task allows delegation.
|
|
36
36
|
|
|
37
|
-
Closing a response-reading command does not cancel work. The coordinator retains responses and session records for its lifetime. A coordinator restart does not replay tasks or reconstruct queues; unavailable identifiers return an explicit error.
|
|
37
|
+
Closing a response-reading command does not cancel work. The coordinator retains responses and session records for its lifetime. A coordinator restart does not replay tasks or reconstruct queues; unavailable identifiers return an explicit error. This version does not recover library sessions after coordinator or environment exit. Responses are not consumed by readers; each reader supplies its own position. Task/session metadata and complete-response records are not silently evicted while the coordinator is running. Live event delivery is separate and does not retain content for later subscribers.
|
|
38
38
|
|
|
39
39
|
## Task states and responses
|
|
40
40
|
|
|
41
|
-
The coordinator supplies the terminal dashboard with a read-only snapshot of current session work followed by retained finished tasks, including failed active tasks that pause a queue. Each task appears at most once, and retained history is available to newly opened dashboards for the coordinator’s lifetime. The private snapshot includes
|
|
41
|
+
The coordinator supplies the terminal dashboard with a read-only snapshot of current session work followed by retained finished tasks, including failed active tasks that pause a queue. Each task appears at most once, and retained history is available to newly opened dashboards for the coordinator’s lifetime. The private snapshot includes `history: true` for finished history, `grouping: true` for grouped context, and `taskDetails: true` for the expanded task-detail fields. Missing `history` or `grouping` ends the dashboard with `COORDINATOR_OUTDATED` and exit `1`. Missing `taskDetails` keeps the dashboard running; opening a task screen shows `COORDINATOR_OUTDATED` with restart guidance instead of task details. It carries only session/task identity, selected harness, bounded prompt title, task state, canonical checkout/repository paths, and timestamps needed by the display; it excludes environment variables, credentials, definitions, transcripts, and native diagnostics. Reading it does not acknowledge responses or change task execution. Workers report the actual selected harness to the coordinator after native startup succeeds. Task timing records the first dispatch, latest failure, and terminal completion or confirmed-stop time without resetting on native continuations. Finished rows retain a fixed elapsed duration; recovery clears terminal timing for the resumed task. Snapshot observation adds no public SDK execution method or persistent history. The inspector uses a separate authenticated, read-only session-history projection for retained work requests, stable admission ordinals, queue state and direct child sessions. Full prompt/response content and summarized agent/model identity are fetched only for the open task screen through the task-detail projection. It omits already-cached prompt and response text on refresh and never acknowledges delegated outcomes or changes execution. The core task screen renders steps from a task-scoped live subscription; those events are absent from private dashboard projections. The private transport is defined in [Dashboard inspection](cli/dashboard-inspection.md); presentation is defined in [CLI](cli/index.md#live-dashboard).
|
|
42
42
|
|
|
43
43
|
Task states are `queued`, `running`, `waiting`, `awaiting_approval`, `completed`, `failed`, `cancelled`, and `interrupted`. `waiting` means the library task remains active between native turns while delegated work or child-result processing is pending. A native permission request is not a completed response. Terminal outcomes are `completed`, `failed`, `cancelled`, and `interrupted`.
|
|
44
44
|
|
|
@@ -50,7 +50,9 @@ Each session admits task-creating requests in the order the coordinator receives
|
|
|
50
50
|
|
|
51
51
|
Steering an actively generating native turn uses native steering when available; otherwise it follows the interrupt contract: cancel the active task and its descendants, then create a replacement task with the supplied message while preserving independently queued work. The output reports the effective delivery mode. Steering a `waiting` task starts a native continuation of that same task with the new input, leaving descendants running. With no active task, steering fails; callers can submit a queued task. Acceptance means the native integration accepted the input, not that the model has acted on it.
|
|
52
52
|
|
|
53
|
-
Cancellation closes admission of new descendants, removes queued descendants, and requests native interruption for running descendants. `cancel` returns after affected
|
|
53
|
+
Cancellation closes admission of new descendants, removes queued descendants, and requests native interruption for running descendants. `cancel` returns after affected native turns have stopped. Repeating cancellation of a terminal task is a harmless status read. Interruption uses the same boundary before the replacement starts; independently queued tasks keep their order. A failed cancellation leaves dispatch paused and returns an error rather than claiming execution stopped. Concurrent interrupts are serialized in admission order.
|
|
54
|
+
|
|
55
|
+
A native harness can retain a tracked tool process as session-owned background work across turns. Such a process can remain alive after cancellation or task completion even though the native turn has stopped. Closing the session through the CLI or SDK, or shutting down the coordinator, closes native resources and lets the harness terminate the tool processes it tracks. A process deliberately detached outside native harness tracking remains outside both Subharness and harness ownership and can survive session close.
|
|
54
56
|
|
|
55
57
|
On parent execution failure, affected descendants are cancelled before reporting the settled failure. A failed or cancelled child is delivered to its parent as an outcome the parent can interpret; it does not automatically fail the parent. Parent continuation uses the existing native session and original task. Child results received while the parent is busy are retained until they can be delivered without interrupting its turn. Results available together may be delivered in one continuation, once each.
|
|
56
58
|
|
|
@@ -66,13 +68,23 @@ Ordinary text/JSON tool results and complete responses are limited to 1 MiB. Ric
|
|
|
66
68
|
|
|
67
69
|
A managed task cannot delegate follow-up work into its own session or an ancestor's session. Such an admission returns `INVALID_PARENT` before changing any execution: that queued work would otherwise wait for the very task whose completion depends on it. Invalid delegation and replacement requests never cancel existing work.
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
The CLI and connected SDK select the same coordinator directory: an explicit SDK `stateDirectory`, otherwise `AGENT_STATE_DIR`, otherwise `~/.subharness/state/shared`. Connection authenticates the instance and requires protocol version 1 with the applicable `sdk-v1` or `cli-v1` capability.
|
|
72
|
+
|
|
73
|
+
Each candidate coordinator, rather than the CLI command that spawned it, holds an operating-system-backed startup lock from its final endpoint check through service startup and atomic endpoint publication. The lock is released automatically if the candidate exits. After acquiring it, a candidate retires without publishing when the retained endpoint gives a compatible authenticated health response for the recorded coordinator instance. It starts only when metadata is absent, or a well-formed stale record has a proven-dead owner and an unresponsive endpoint. Malformed, unauthorized, incompatible, or uncertain endpoints fail explicitly without replacement. This prevents a caller exit or a later candidate from exposing competing endpoint publication.
|
|
70
74
|
|
|
71
75
|
Startup callers do not infer whether their candidate published from an endpoint observation and do not signal a candidate based on such an observation. When its startup deadline expires, a caller sends its candidate a private retirement request. The candidate serializes that request with its publication transition while it still owns the startup lock. If retirement wins, the candidate closes any service that was never published, releases startup ownership, and confirms that it cannot publish later. If publication wins, including when another caller has already admitted work, the candidate reports its published endpoint and remains running. The original caller then uses that endpoint instead of terminating the coordinator.
|
|
72
76
|
|
|
73
77
|
Lock contention is bounded by the spawning command's startup deadline. Waiting for the candidate's publication-or-retirement response uses an additional fixed confirmation window, so command completion remains bounded. If the candidate does not respond, startup fails with `STARTUP_FAILED` stating that retirement could not be confirmed, and the caller leaves the candidate untouched. A later authenticated endpoint discovery may therefore find that candidate. An unconfirmed result never claims that the process stopped and never authorizes killing a potentially published coordinator.
|
|
74
78
|
|
|
75
|
-
Coordinators leave endpoint records in place during shutdown. Legacy pathname lock artifacts do not grant startup ownership and are left untouched. An unavailable endpoint
|
|
79
|
+
Coordinators leave endpoint records in place during shutdown. Legacy pathname lock artifacts do not grant startup ownership and are left untouched. An unavailable endpoint alone does not prove absence. A live or unknown owner, authentication failure, incompatible protocol, or instance mismatch forbids replacement startup. A permitted replacement atomically overwrites only a proven-stale record; tasks owned by the previous coordinator are not reconstructed. An interrupted coordinator response is reported as unavailable without exposing native diagnostics or automatically repeating the request. Disconnecting an observer detaches that observation; it does not cancel execution.
|
|
76
80
|
A successful detached task-creation request ends its service observation explicitly after the admission record while the coordinator continues to own the task.
|
|
77
81
|
|
|
78
82
|
Catalog discovery evaluates TypeScript in a short-lived process with the selected execution directory as its working directory. Module stdout and stderr are not mixed into CLI output. Session workers retain their loaded instructions, tools, and harness configuration. New sessions, including delegated child sessions, load the current definition source; the library does not serialize or freeze arbitrary TypeScript closures across sessions.
|
|
83
|
+
|
|
84
|
+
## Live events and user extensions
|
|
85
|
+
|
|
86
|
+
The public [live event API](events.md) forwards normalized session events only to currently matching subscribers. With no subscriber, adapters skip event normalization and event IPC. Native startup options needed for partial output are enabled for every session so later subscribers receive supported deltas. Opening registers before its promise resolves, and only events accepted after that registration point are delivered. Adapters keep no extra observation content. Earlier content appears only when the native route later supplies it in a snapshot; for mid-item joins on chunk-only `fx-acp` and `cursor-acp`, turn-boundary snapshots cover only content normalized since registration and use state `"incomplete"`. Pending delivery is limited to 128 events or 1 MiB per subscriber; falling behind rejects observation with `EVENT_BACKPRESSURE` without delaying execution. Content limits and redaction apply before transfer.
|
|
87
|
+
|
|
88
|
+
Static extension manifests live in global and repository directories. Explicit per-user consent is stored in the owner-only `~/.subharness/extensions.json` file under the [extension consent schema](config.md#extension-consent-and-logs), with repository consent per canonical checkout. At every newly admitted coordinator session, including connected SDK creation, the coordinator selects all enabled global extensions and enabled repository extensions for that checkout. Instance identity is the qualified reference plus the canonical checkout for repository extensions; global instances have no checkout component. Failure state, admission eligibility and re-enablement are scoped to that identity. Enabling in one checkout affects only that checkout's repository instance. Each applicable extension runs in a separately supervised child process from its first matching session until coordinator close, unless failure disables it. Execution workers, CLI dashboards and embedded runners do not load extension modules. Disabling removes eligibility for newly admitted sessions while existing assignments continue. A failed instance remains disabled and visible through `subharness extensions list` for the coordinator's lifetime, without automatic restart or failure of agents or other extensions. Explicitly enabling the selected instance identity again saves consent and notifies a running coordinator to permit a new process at the first newly admitted matching session; sessions assigned to the failed instance are not reassigned. If notification fails, consent stays saved and enable warns that the failure state clears on coordinator restart, exiting `0`. No notification is needed when no coordinator is running. Restarting the coordinator resets runtime failure state.
|
|
89
|
+
|
|
90
|
+
The CLI task screen itself opens the public task-scoped live subscription and renders incoming turns, assistant text, reasoning, tool and approval steps, and inline session-error notices. Approval and session-error rows count toward the display bound. Its original request, task error and latest complete response come from ordinary inspection. The open screen displays at most 500 steps, dropping the oldest with a visible omission notice; this bound belongs only to dashboard display state. Leaving closes the subscription and discards that state. Reopening does not retrieve past events. Earlier content appears only when the native route itself supplies it in a later snapshot; chunk-only mid-item views remain incomplete. The screen consumes events independently of rendering. After `EVENT_BACKPRESSURE`, it shows a missed-steps notice and follows the [dashboard retry bounds](cli/dashboard-design.md#refresh-and-compatibility): at most one reopen every 2 seconds, stopping after 3 consecutive failures within 60 seconds, counting failed reopens. It then shows “Live steps paused; reopen the task to retry.” SDK applications implement custom event handling through direct subscriptions. [User extensions](extensions.md) defines the plain-object module API, supervised lifetime, manifest, diagnostics and complete logger example.
|
package/dist/cli/catalog.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ErrorInfo } from "../errors.js";
|
|
2
|
-
import type { AgentReference, ExecutionReference } from "../runtime/types.js";
|
|
3
|
-
export interface CatalogSnapshot {
|
|
4
|
-
entries: {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
description: string;
|
|
8
|
-
scope: "repo" | "global";
|
|
9
|
-
file: string;
|
|
10
|
-
}[];
|
|
11
|
-
children: {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
}[];
|
|
15
|
-
}
|
|
16
|
-
export type CatalogReply = {
|
|
17
|
-
result: CatalogSnapshot;
|
|
18
|
-
error?: never;
|
|
19
|
-
} | {
|
|
20
|
-
result?: never;
|
|
21
|
-
error: ErrorInfo;
|
|
22
|
-
};
|
|
23
|
-
/** Definition modules run in their selected directory without sharing the CLI's output streams. */
|
|
24
|
-
export declare function loadCatalog(cwd: string, parent?: ExecutionReference): Promise<CatalogSnapshot>;
|
|
25
|
-
/** Declared-child lookup evaluates only the active parent's definition source. */
|
|
26
|
-
export declare function loadDeclaredChildren(cwd: string, parent: AgentReference): Promise<CatalogSnapshot['children']>;
|
package/dist/cli/catalog.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { fork } from "node:child_process";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { AgentError } from "../errors.js";
|
|
4
|
-
/** Definition modules run in their selected directory without sharing the CLI's output streams. */
|
|
5
|
-
export function loadCatalog(cwd, parent) {
|
|
6
|
-
return loadCatalogSnapshot(cwd, parent, true);
|
|
7
|
-
}
|
|
8
|
-
/** Declared-child lookup evaluates only the active parent's definition source. */
|
|
9
|
-
export async function loadDeclaredChildren(cwd, parent) {
|
|
10
|
-
return (await loadCatalogSnapshot(cwd, parent, false)).children;
|
|
11
|
-
}
|
|
12
|
-
function loadCatalogSnapshot(cwd, parent, discover) {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
const extension = import.meta.url.endsWith(".ts") ? "ts" : "js";
|
|
15
|
-
const child = fork(fileURLToPath(new URL(`./catalog-worker.${extension}`, import.meta.url)), [], {
|
|
16
|
-
cwd, env: process.env, stdio: ["ignore", "ignore", "ignore", "ipc"],
|
|
17
|
-
execArgv: extension === "ts" ? ["--import", import.meta.resolve("tsx")] : [],
|
|
18
|
-
});
|
|
19
|
-
let reply;
|
|
20
|
-
const failed = () => reject(new AgentError("INVALID_DEFINITION", "The agent catalog worker exited before returning its catalog."));
|
|
21
|
-
child.once("error", failed);
|
|
22
|
-
child.once("exit", () => {
|
|
23
|
-
if (!reply)
|
|
24
|
-
failed();
|
|
25
|
-
else if (reply.error)
|
|
26
|
-
reject(new AgentError(reply.error.code, reply.error.message));
|
|
27
|
-
else
|
|
28
|
-
resolve(reply.result);
|
|
29
|
-
});
|
|
30
|
-
child.once("message", (message) => {
|
|
31
|
-
reply = message;
|
|
32
|
-
child.send({ received: true }, (error) => { if (error)
|
|
33
|
-
child.kill(); });
|
|
34
|
-
});
|
|
35
|
-
child.send({ cwd, parent, discover }, (error) => { if (error) {
|
|
36
|
-
child.kill();
|
|
37
|
-
failed();
|
|
38
|
-
} });
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=catalog.js.map
|
package/dist/cli/catalog.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/cli/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAS1D,mGAAmG;AACnG,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,MAA2B;IAClE,OAAO,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,GAAW,EAAE,MAAsB;IAC5E,OAAO,CAAC,MAAM,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAClE,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW,EAAE,MAAsC,EAAE,QAAiB;IACjG,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAChE,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,oBAAoB,SAAS,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;YAC/F,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC;YACnE,QAAQ,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;SAC7E,CAAC,CAAC;QACH,IAAI,KAA+B,CAAC;QACpC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,oBAAoB,EAAE,+DAA+D,CAAC,CAAC,CAAC;QACnI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;YACtB,IAAI,CAAC,KAAK;gBAAE,MAAM,EAAE,CAAC;iBAChB,IAAI,KAAK,CAAC,KAAK;gBAAE,MAAM,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;;gBAC/E,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAqB,EAAE,EAAE;YAC9C,KAAK,GAAG,OAAO,CAAC;YAChB,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,KAAK,EAAE,CAAC;YAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAAC,MAAM,EAAE,CAAC;QAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { fork } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { AgentError, type ErrorInfo } from \"../errors.js\";\nimport type { AgentReference, ExecutionReference } from \"../runtime/types.js\";\n\nexport interface CatalogSnapshot {\n entries: { id: string; name: string; description: string; scope: \"repo\" | \"global\"; file: string }[];\n children: { name: string; description: string }[];\n}\nexport type CatalogReply = { result: CatalogSnapshot; error?: never } | { result?: never; error: ErrorInfo };\n\n/** Definition modules run in their selected directory without sharing the CLI's output streams. */\nexport function loadCatalog(cwd: string, parent?: ExecutionReference): Promise<CatalogSnapshot> {\n return loadCatalogSnapshot(cwd, parent, true);\n}\n\n/** Declared-child lookup evaluates only the active parent's definition source. */\nexport async function loadDeclaredChildren(cwd: string, parent: AgentReference): Promise<CatalogSnapshot['children']> {\n return (await loadCatalogSnapshot(cwd, parent, false)).children;\n}\n\nfunction loadCatalogSnapshot(cwd: string, parent: ExecutionReference | undefined, discover: boolean): Promise<CatalogSnapshot> {\n return new Promise((resolve, reject) => {\n const extension = import.meta.url.endsWith(\".ts\") ? \"ts\" : \"js\";\n const child = fork(fileURLToPath(new URL(`./catalog-worker.${extension}`, import.meta.url)), [], {\n cwd, env: process.env, stdio: [\"ignore\", \"ignore\", \"ignore\", \"ipc\"],\n execArgv: extension === \"ts\" ? [\"--import\", import.meta.resolve(\"tsx\")] : [],\n });\n let reply: CatalogReply | undefined;\n const failed = () => reject(new AgentError(\"INVALID_DEFINITION\", \"The agent catalog worker exited before returning its catalog.\"));\n child.once(\"error\", failed);\n child.once(\"exit\", () => {\n if (!reply) failed();\n else if (reply.error) reject(new AgentError(reply.error.code, reply.error.message));\n else resolve(reply.result);\n });\n child.once(\"message\", (message: CatalogReply) => {\n reply = message;\n child.send({ received: true }, (error) => { if (error) child.kill(); });\n });\n child.send({ cwd, parent, discover }, (error) => { if (error) { child.kill(); failed(); } });\n });\n}\n"]}
|