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/adapter-contract.md
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
# Native Adapter Contract
|
|
2
2
|
|
|
3
|
+
The [execution SDK](execution.md) reuses native adapters. Embedded runners use an in-process session driver and host-owned custom tools; connected clients use coordinator-owned captured definitions and native sessions. It exposes complete responses, task snapshots and normalized [live session events](events.md). Event content is a bounded, redacted preview whose capabilities depend on the selected native route.
|
|
4
|
+
|
|
3
5
|
Adapters create native Codex, Claude Code, fx, OpenCode, GitHub Copilot, or Cursor conversations in the caller-supplied directory. Their implementation interface is internal and is not an SDK extension API. A session supplies `turn(prompt)`, `steer(prompt)`, `interrupt()`, `resume()`, and `close()`. A turn resolves with its complete text; machine-reported execution failures reject with a stable error code. The Cursor subscription ACP route has the documented limitation that some native backend failures arrive only as assistant text. Interrupt resolves only when active execution has stopped. Unsupported operations return explicit capability errors. Harness-specific contracts are defined for [fx](fx.md), [OpenCode](opencode.md), [Copilot](copilot.md), and [Cursor](cursor.md).
|
|
4
6
|
|
|
5
|
-
[Error diagnostics](diagnostics.md) defines startup failure classification, safe native failure categories, and process termination context. Unexpected Claude account-inspection or model-catalog exceptions are harness failures, not evidence that another access route should be tried.
|
|
7
|
+
[Error diagnostics](diagnostics.md) defines startup failure classification, safe native failure categories, and process termination context. A failed Codex terminal turn is classified from its terminal App Server error category, including the harness-neutral `CONTEXT_WINDOW_EXCEEDED` code; retrying native error notifications do not fail a turn, and freeform native error text is not exposed. Unexpected Claude account-inspection or model-catalog exceptions are harness failures, not evidence that another access route should be tried.
|
|
6
8
|
|
|
7
9
|
Adapter startup receives the selected harness configuration, loaded agent definition, execution directory, environment, and resolved personal access. Startup verifies compatibility and access before submitting any task. A direct CLI harness target supplies no specialist instructions, custom tools, or declared children. Codex, Claude Code, and fx may request a verifiable native default model internally; OpenCode, Copilot, and Cursor require an explicit CLI model. Public SDK constructors always require a model. Default resolution happens before the first prompt, within the authorized access route, and the resolved model is retained for follow-ups. An unavailable or unverifiable default fails with guidance to supply `--model`, without probing it through a paid generation. Explicit model and effort validation remains effective. `HARNESS_UNAVAILABLE` and `ACCESS_UNAVAILABLE` permit trying another declared alternative before submission. Invalid configuration and unsupported explicit options do not. No adapter performs automatic fallback after turn submission.
|
|
8
10
|
|
|
9
11
|
The CLI readiness check uses this same startup and pre-submission fallback path in an isolated worker, then closes the native session without calling `turn`. It therefore verifies only capabilities observable during startup. It does not probe quota with generation, exercise native tools, or establish shell and child-launch permissions. Startup may create an empty native conversation and private temporary files; normal close removes library-owned temporary files under the adapter lifecycle rules.
|
|
10
12
|
|
|
11
|
-
A readiness check reports success only after the isolated worker has exited and every adapter-owned native process has confirmed termination. Native close first permits graceful shutdown and then uses bounded termination when required. If native termination cannot be confirmed, or worker cleanup fails, the check emits an error instead of a readiness record. A failed worker close preserves its cleanup diagnostic while forcibly ending the isolated worker; it does not leave the CLI waiting indefinitely for that worker.
|
|
13
|
+
A readiness check reports success only after the isolated worker has exited and every adapter-owned native process has confirmed termination. Native close first permits graceful shutdown and then uses bounded termination when required. The Codex RPC, fx RPC, and OpenCode native-process owners allow five seconds after `SIGTERM` before escalating to `SIGKILL`; their native-close sequences keep every other step and bound unchanged. If native termination cannot be confirmed, or worker cleanup fails, the check emits an error instead of a readiness record. A failed worker close preserves its cleanup diagnostic while forcibly ending the isolated worker; it does not leave the CLI waiting indefinitely for that worker.
|
|
14
|
+
|
|
15
|
+
Task cancellation and interrupt stop the active native turn without closing the retained native session. Native tool processes that a harness tracks across turns can therefore remain alive after cancellation or task completion. Session close retires native resources, allowing the harness to terminate the tool processes it tracks. Processes deliberately detached outside native tracking are outside both ownership layers and can survive close.
|
|
16
|
+
|
|
17
|
+
Verified evidence covers live Codex 0.157.0 background terminals, live Claude Code 2.1.288 `run_in_background` shells, and source inspection of fx 0.0.12 managed-process cleanup. The fx source also confirms that a deliberately detached daemon released from fx tracking can survive. OpenCode, GitHub Copilot, and Cursor have no equivalent verified tool-process evidence; the general close contract still applies.
|
|
12
18
|
|
|
13
19
|
Agent instructions supplement native instructions. The adapter exposes declared tools without implementing its own model loop. Tool input is validated before the function runs, and returned text or JSON data is encoded as a native text result. Explicit `toolResult` values preserve their text and image blocks through the native protocol, as defined in [custom tools](tools.md). Declared subagents authorize delegation. The Claude adapter translates that authorization into session-only native allow rules for the exact session launcher, declared child invocations, and documented coordination commands. The Codex adapter does not install equivalent launcher rules. Explicit constructor options select the session's native sandbox, network, and approval policy as defined in [Native Permissions](permissions.md); omission preserves native settings. The installed native harness and execution environment continue to enforce their restrictions. Supported active-turn native approvals use the [structured approval flow](approvals.md), keeping the original operation pending until a valid caller answer or native withdrawal. Unsupported interactive input and startup-time requests fail with `INPUT_REQUIRED`; no adapter grants them automatically.
|
|
14
20
|
|
|
15
21
|
Codex uses its native App Server protocol. Claude Code uses its native Agent SDK with the installed Claude executable. A Claude session accepts queued native turns and interruption. Its native steering method reports `UNSUPPORTED_DELIVERY` before any mutation; the coordinator converts that request to the documented interrupt operation and reports the effective delivery mode. Codex steering targets the active native turn. Neither adapter synthesizes native recovery by replaying the original prompt; unavailable recovery returns `RECOVERY_UNSUPPORTED`.
|
|
16
22
|
|
|
23
|
+
Adapter selection loads only the adapter being attempted. Claude's Agent SDK runs in a private worker for each session because its module initialization can change process environment variables. The worker receives a copy of the captured session environment and never shares the application's `process.env`. This boundary is internal and does not change the public session or tool interfaces.
|
|
24
|
+
|
|
25
|
+
The host retains the original tool schemas, closures, validation, and callback admission and draining. The worker receives tool descriptions and JSON schemas and forwards calls to those original host tools; it does not reconstruct application schemas or execute application callbacks. Native approval requests, answers, and withdrawals cross the same private boundary without changing offered permissions or admitting stale answers. No environment or credential values enter bridge diagnostics.
|
|
26
|
+
|
|
27
|
+
The host owns Claude's concrete native subprocess and private configuration cleanup, including when the worker fails. The SDK's custom process hook bridges native streams and process events to the worker with backpressure. Closing confirms native termination and drains admitted callbacks before reporting completion; terminating the worker alone is insufficient. A close requested during startup waits for that attempt to settle and closes any resulting session without submitting a turn; it does not impose a startup deadline. Interruption confirms that the active native turn has stopped and drains its admitted callbacks while retaining the session. Cleanup failures retain ownership for retry. Unexpected worker or bridge failures are execution failures, not reasons to replay input or switch providers.
|
|
28
|
+
|
|
17
29
|
Personal subscription selection must verify native subscription access. Ambient API keys, alternate endpoints, provider overrides, and native API-key helpers must not silently change the selected billing method. Explicit API or Gateway selections supply only the selected credential route. Credentials are never included in CLI records or diagnostic output.
|
|
18
30
|
|
|
19
31
|
Unsupported approval and interactive-input diagnostics use `INPUT_REQUIRED`. Claude diagnostics may identify a bounded native tool name; Codex diagnostics identify the recognized fixed approval method and category. Diagnostics do not expose raw tool arguments, settings or credentials. Supported approval requests expose the bounded action context needed for the caller's decision under the [approval contract](approvals.md), separately from error diagnostics.
|
|
@@ -37,3 +49,21 @@ When every eligible connection or declared harness is unavailable, selection rep
|
|
|
37
49
|
An adapter may create a private temporary native configuration file outside the repository to pass explicit API/Gateway credentials without putting secrets in process arguments. The directory uses owner-only access and the file uses mode `0600`. Startup failures and normal session close remove the file. Project settings and coordinator endpoint records never contain those credentials, and subscription tokens are never extracted. Abrupt environment termination does not guarantee cleanup of native temporary files.
|
|
38
50
|
|
|
39
51
|
Cancellation waits for custom tool callbacks already admitted to settle before reporting execution stopped. `execute(input)` has no cancellation signal. The library cannot undo their completed side effects or truthfully report a still-running callback as cancelled.
|
|
52
|
+
|
|
53
|
+
## Normalized observation
|
|
54
|
+
|
|
55
|
+
An adapter's internal event sink receives the owning operation/turn context and emits the normalized event families defined in [Session events](events.md). Its complete-string turn result and stop-confirmation semantics remain unchanged. Native item snapshots, safe text deltas, tool state/results, provider-exposed reasoning and supported approval/error events are correlated before transfer. Known native IDs deduplicate streamed items and complete/tool callback observations; uncertain late frames are never assigned to whichever task is current. No raw native payload is public.
|
|
56
|
+
|
|
57
|
+
Items still open when a turn ends without native completion, including turn failure, transport loss, an invalid native terminal result or interruption, close with `item.completed` and `completion: "interrupted"`. Assistant and reasoning items use state `"interrupted"`; tool items use state `"unknown"`. When native stop remains unconfirmed, open items stay open until the session is retired and then close the same way. Retirement does not invent `turn.completed` for an unconfirmed stop.
|
|
58
|
+
|
|
59
|
+
Each adapter keeps normalization state for at most 1,024 open items per session. Items beyond that bound are not forwarded, and the adapter raises one `session.error` with `category: "capture"` and `origin: "adapter"` per turn that overflows. Effective capabilities may include `SessionEventCapabilities.nativeVersion` only when it is at most 64 bytes of printable ASCII (characters `0x20` through `0x7E`); otherwise the optional field is omitted.
|
|
60
|
+
|
|
61
|
+
The Codex, Claude Code, fx, Copilot and Cursor SDK adapters also track at most 1,024 distinct item identities per turn. After that bound is reached, later new identities are not forwarded and the adapter raises one capture error for the turn. Previously admitted identities may still complete. Identity-bound capture errors do not change the execution outcome.
|
|
62
|
+
|
|
63
|
+
The Copilot SDK route omits `SessionEventCapabilities.nativeVersion`. Its pinned SDK package version is not the native runtime version, and the adapter does not expose a verified runtime version through this capability.
|
|
64
|
+
|
|
65
|
+
Adapters normalize and forward events only while at least one subscriber matches their session. With no subscriber they skip normalization and event IPC while retaining required native execution/protocol handling. Native partial-message options that must be selected at startup, including Claude `includePartialMessages` and Copilot `streaming`, are enabled for every session. This allows late subscribers to receive subsequent supported deltas without reconfiguring or restarting native execution. A delta carries item ID, ordinal, native/synthetic identity, kind, state and tool name when applicable so it can be displayed when its start was not observed. Adapters keep no extra content for later observation. Content from before registration appears only if the native route later supplies it in a snapshot, such as Codex `item/completed` or a Claude assistant message. On chunk-only `fx-acp` and `cursor-acp`, a mid-item turn-boundary snapshot includes only content normalized since registration and uses item state `"incomplete"`. Effective capabilities remain per route; generic ACP variants do not establish vendor emission.
|
|
66
|
+
|
|
67
|
+
Final-response selection, error classification, tool callbacks, approval ownership and native persistence/deletion retain their existing rules. Normalization/redaction occur before event IPC. The owner validates lease/operation identity, ordering and content size. Event-processing failures detected by the owner itself, such as a dropped invalid adapter draft, are `session.error` events with `category: "capture"` and `origin: "owner"`. Owner-raised errors may have category `"execution"` or `"capture"`; adapter-raised errors are capture only. Pending delivery is bounded; a subscriber that falls behind fails with `EVENT_BACKPRESSURE` rather than delaying cancellation, approval replies or complete turn results. Event content is not retained for later observers.
|
|
68
|
+
|
|
69
|
+
Claude's SDK worker and captured definition graphs preserve callback/credential isolation. Execution workers do not import extension code. The coordinator supervises user extensions in separate child processes and delivers only events for their admission-selected sessions; the CLI dashboard consumes live events itself. Embedded runners serve explicit application subscriptions without loading user extensions.
|
package/sdk/agent-skill.md
CHANGED
|
@@ -14,7 +14,7 @@ The installer reads the source repository, so installation requires access to [v
|
|
|
14
14
|
|
|
15
15
|
## Location and discovery
|
|
16
16
|
|
|
17
|
-
The skill's entry point is `skills/subharness/SKILL.md` at the repository root, with its credential helper in `skills/subharness/scripts/refresh-vercel-oidc.mjs`. Its frontmatter `name` is `subharness`, and its `description` states that the skill applies when the human asks the agent to delegate, parallelize, or hand off work to Codex, Claude Code, fx, OpenCode, GitHub Copilot, or Cursor, or to follow up on, check, or
|
|
17
|
+
The skill's entry point is `skills/subharness/SKILL.md` at the repository root, with its credential helper in `skills/subharness/scripts/refresh-vercel-oidc.mjs`. Its frontmatter `name` is `subharness`, and its `description` states that the skill applies when the human asks the agent to delegate, parallelize, or hand off work to Codex, Claude Code, fx, OpenCode, GitHub Copilot, or Cursor, or to follow up on, check, cancel, or close delegated work.
|
|
18
18
|
|
|
19
19
|
`npx skills add vercel-labs/subharness` offers only this skill. The repository's development skills under `.agents/skills/` set `metadata.internal: true` in their frontmatter, which the installer hides by default. That field does not change how native harnesses read those skills.
|
|
20
20
|
|
|
@@ -27,13 +27,14 @@ The skill is concise, task-oriented guidance for the main agent. It agrees with
|
|
|
27
27
|
- When to delegate: independent, well-scoped work that can run while the conversation continues, and when the human names a harness.
|
|
28
28
|
- Choosing a target: the reserved `codex`, `claude`, `fx`, `opencode`, `copilot`, and `cursor` direct targets, and `subharness list` for discovered specialists.
|
|
29
29
|
- Starting work with `subharness run <target> [--cwd <directory>] <prompt>`, `--prompt`, or `--prompt-file`, including quoting a positional prompt and giving the child explicit task context, because children do not receive the main conversation's transcript or loaded skills.
|
|
30
|
+
- Using `--prompt-file <path>` for generated long or multiline prompts, with an owner-private file (`0600` inside a `0700` directory on POSIX), removing it after a `started` or `accepted` record or command exit confirms the CLI read it, and using `--prompt-file -` only when the host owns standard input. The guidance keeps generated prompt payloads out of large argument vectors while noting that unrelated host pressure can still prevent admission.
|
|
30
31
|
- Preferring a single `subharness run <target> <prompt>` through the host's background-task controls when that capability is known to be available. The caller collects that hosted command's output later; a separate `--detach` and `wait` sequence is unnecessary for its first response.
|
|
31
32
|
- Using `subharness run <target> --detach <prompt>` when background-command support is unavailable or uncertain, returning after admission and retaining the task identifier. `wait` returns or awaits the first response and runs only after useful independent work, when the caller is ready to wait. The minimal example contains only `run --detach` and `wait`; `status` is a separate optional nonblocking snapshot, not an unconditional step before or after `wait`.
|
|
32
33
|
- Noting that background execution, process survival, and completion notifications depend on the host; detached admission alone does not provide them.
|
|
33
34
|
- Reading results: the returned session, task, and response identifiers; `subharness wait <task-id>` for the first response; `subharness wait <task-id> --after <response-id>` for the next response; and `subharness status <task-id> --full` for the complete latest response.
|
|
34
35
|
- Answering `approval_required` requests by inspecting the actual action, authorization scope, and request-specific schema. Examples cover an authorized single-use choice, an offered denial, and a grant selection with an explicit duration; examples never establish universal decision values. The caller uses `respond --content` or `--content-file`, then observes the original task with its existing response cursor. Acknowledging an answer does not imply task completion.
|
|
35
36
|
- Distinguishing native denial from task cancellation, validating request ownership, correcting invalid content without replaying the task, and reporting expired requests or hard permission failures without broadening policy.
|
|
36
|
-
- Following up with `subharness send <session-id>` and its `queue`, `steer`, and `interrupt` delivery modes; inspecting work with `subharness queue <session-id>`;
|
|
37
|
+
- Following up with `subharness send <session-id>` and its `queue`, `steer`, and `interrupt` delivery modes; inspecting work with `subharness queue <session-id>`; stopping it with `subharness cancel <task-id>`; and closing sessions that are no longer needed with `subharness close <session-id>`.
|
|
37
38
|
- Reporting results back to the human in the main conversation, rather than relaying raw output.
|
|
38
39
|
- Recovering an expired file-backed development OIDC credential through the lead agent's existing authenticated Vercel CLI for the established project, using the bundled helper without changing other settings, exposing credentials, or replaying submitted work.
|
|
39
40
|
- Limits: subharness does not create worktrees or sandboxes, the caller supplies an existing working directory, native authentication stays with each harness, and records do not survive coordinator loss.
|
package/sdk/agent.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Defining an Agent
|
|
2
2
|
|
|
3
|
-
Import definitions from `subharness`. The helpers are synchronous declarations: they do not start harnesses, authenticate, call models, or execute tools. Execution uses the CLI.
|
|
3
|
+
Import definitions from `subharness`. The helpers are synchronous declarations: they do not start harnesses, authenticate, call models, or execute tools. Execution uses either the CLI or the application-owned [execution SDK](execution.md).
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { agent, codex, claudeCode } from "subharness";
|
package/sdk/approvals.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Responding to Native Permission Requests
|
|
2
2
|
|
|
3
|
+
The [execution SDK](execution.md#unified-approval-types) exposes normalized approval actions through task snapshots. `runner.respond` and `client.approvals.respond` select an advertised action ID, with explicit permission grants when required. They resolve the same retained requests as the native-schema CLI and hosted-tool flow below. These are separate response formats: SDK callers use `{ actionId, grants? }`; CLI and hosted tools use request-specific native schema content. Neither response completes or restarts the task. The internal native approval callback remains adapter-facing.
|
|
4
|
+
|
|
3
5
|
A native tool permission request suspends the operation that needs authorization while its original native turn stays open. Subharness returns a structured request to the observing caller. The caller can answer the request and then observe the same task. Permission handling never replays a prompt, creates a replacement task, changes the selected native policy, or automatically approves an operation. Independent native operations and sibling tasks may continue.
|
|
4
6
|
|
|
5
7
|
## Observe and respond
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Dashboard presentation
|
|
2
2
|
|
|
3
|
-
This document defines the grouped
|
|
3
|
+
This document defines the grouped overview, agent request list and dedicated task screen. Command lifecycle and history retention are defined in [Live dashboard](index.md#live-dashboard).
|
|
4
4
|
|
|
5
5
|
The dashboard groups agent rows by repository and worktree. Each group has one compact `repository / worktree` label. A repository with multiple worktrees has a separate group for each checkout rather than a shared enclosing section.
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ A session captures its checkout context when admitted. Git subdirectories resolv
|
|
|
29
29
|
|
|
30
30
|
Labels use repository and checkout directory names, not branch names. Ambiguous short labels include a distinguishing parent path. All labels and task titles are sanitized before terminal output.
|
|
31
31
|
|
|
32
|
-
Each task records its latest coordinator-observed update: admission, dispatch or continuation, a selected-harness change, accepted steering, creation or retirement of a native permission request, a complete native response, or a settled lifecycle outcome.
|
|
32
|
+
Each task records its latest coordinator-observed update: admission, dispatch or continuation, a selected-harness change, accepted steering, creation or retirement of a native permission request, a complete native response, or a settled lifecycle outcome. Live text, reasoning and tool events update an open task screen without advancing task/group recency. Snapshot reads, response reads, and cancelling an already settled task do not advance recency. A queued follow-up that has no displayed row does not affect group ordering until displayed. Equal group update times preserve the group's first-observed order in the open dashboard.
|
|
33
33
|
|
|
34
34
|
## Row presentation
|
|
35
35
|
|
|
@@ -53,11 +53,33 @@ The compact fixed header contains the repository/worktree label, the session's o
|
|
|
53
53
|
|
|
54
54
|
The body begins with `Requests`. A paused session queue is explicitly labelled beside it. Queued requests are first, newest admitted first; remaining requests follow newest admitted first. The original one-based admission ordinal is stable and displayed even though rows are reversed. State updates do not otherwise reorder requests. Each row shows ordinal, title, explicit state and execution duration; an undispatched request shows `—` for duration. An unconfirmed stop is explicitly labelled on its request. Selection tracks task identity through reordering and refreshes.
|
|
55
55
|
|
|
56
|
-
Up/Down selects the previous/next request
|
|
56
|
+
Up/Down selects the previous/next request. Enter opens a dedicated task screen for that request; it never expands content inline. Escape from the request list returns to the overview. Selection and scroll context survive returning from a task screen.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
PageUp/PageDown move request selection by the visible body height; Home/End select the first/last request. The header and footer remain fixed. Selecting a request scrolls its row into view. Narrow and short terminals retain at least one body row.
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
## Task screen
|
|
61
|
+
|
|
62
|
+
The task screen is core CLI behavior. Its fixed header summarizes the agent name, selected harness and model when known, task state, workspace and elapsed execution time. It uses the selected request row immediately and refreshes those row facts while task details are pending or unavailable, so state and finished duration do not regress or keep advancing. A specialist uses its captured definition name; a direct target uses its harness name. An empty captured display name is unknown and falls back to the selected harness name when that harness is known. Other unknown harness/model values are omitted rather than guessed from an unselected alternative. Queued work shows `—` for elapsed execution time. Finished duration remains fixed; unconfirmed stop remains explicit. The original task title can supplement this identity and remains visible when the agent name is not yet known, without filling the missing agent field.
|
|
63
|
+
|
|
64
|
+
The scrolling body contains the original `Request`, live turns and steps, and the latest complete `Response` or `No response yet` once task inspection establishes those facts. During a supported initial detail read, the request section says `Loading task details…` and the response section is omitted. When task details are unavailable, the unknown request is omitted and the response section says `Response unavailable`; it never claims that no response exists. Errors and unconfirmed cancellation remain clearly visible when supplied by task inspection. Opening a task screen starts a task-scoped subscription through the public [live event API](../events.md). Leaving closes it. Only the selected task's own steps are shown; managed descendants appear in their own task screens. The dashboard does not load user extensions or depend on their enablement.
|
|
65
|
+
|
|
66
|
+
Only events accepted after the screen's subscription is registered are displayed as turns and steps. The request, task error and latest complete response remain available through ordinary task inspection. Past events are not loaded into the steps list. Earlier content appears only when the native route itself supplies it in a later snapshot. Adapters keep no extra observation content for late subscribers. The screen labels its live scope so an empty list is not mistaken for a task with no prior activity. Reopening a task begins a new live view. A completed task can show its request/error/latest response with no live steps.
|
|
67
|
+
|
|
68
|
+
Assistant text, provider-exposed reasoning and tools have selectable rows showing a label, explicit state and summary. A tool row uses `Tool · <tool name>`, where `<tool name>` is the normalized event tool name such as `shell` or `read_file`. Its collapsed summary is a one-line preview of the bounded tool input. For the supported shell-command names `shell`, `command`, `Bash` and `shell.run`, matched case-insensitively, a structured input with a non-blank string `command` previews that command; other inputs preview their bounded text. Missing input is labelled `No tool input`. Tool output is not shown in the collapsed summary. Enter expands the selected row's full bounded details. Expanded tool details show the full bounded input and output where delivered, followed by the exit code and duration in milliseconds when present. Assistant and reasoning summaries retain their content previews.
|
|
69
|
+
|
|
70
|
+
The task-screen selection cursor is `›` in the first column. Every expandable row uses `▸` in the next column while collapsed and `▾` while expanded, so the cursor and disclosure marker never repeat the same glyph. `NO_COLOR` preserves these glyphs while disabling only styling.
|
|
71
|
+
|
|
72
|
+
Content follows the [event bounds and redaction](../events.md#content-bounds-and-redaction). A self-describing delta can create a row when the subscription joined mid-item; that row initially shows text received from the join point and is labelled as a partial view. A later native `item.updated` or `item.completed` snapshot replaces the partial view with the content supplied by that route. On chunk-only `fx-acp` and `cursor-acp`, a mid-item turn-boundary snapshot covers only content normalized since registration and uses item state `"incomplete"`. Missing tool results, unavailable reasoning, unknown states and truncation remain explicit. A terminal item update does not by itself establish task completion.
|
|
73
|
+
|
|
74
|
+
An `approval.requested` event creates an `Approval` step row showing the request message and state `pending`. `approval.resolved` creates or updates that request's row with state `answered` or `withdrawn`. The row uses the message received with `approval.requested`; a resolution received without that request shows its state but cannot supply the missing message. A `session.error` event appears as an inline notice row with its safe code and message. Approval rows and session-error notice rows count toward the display bound.
|
|
75
|
+
|
|
76
|
+
The open task screen displays at most 500 steps. As more steps arrive, it drops the oldest and shows a visible notice that earlier steps were omitted. This limit applies only to the dashboard process's display state; it does not change event delivery or other subscribers' state.
|
|
77
|
+
|
|
78
|
+
Up/Down selects previous/next step rows, stops at the ends and scrolls selection into view. Initial selection is the first step when one exists. Enter expands or collapses its details, keyed by turn/item identity for item rows and request identity for Approval rows; moving selection preserves expansion state. Without step rows, Up/Down scrolls the body by one line and Enter has no effect. PageUp/PageDown scroll by available body height; Home/End scroll to the beginning/end. Escape closes the subscription and discards this screen's live display state, returning to the request list with task selection and scroll position preserved. A second Escape returns to the overview. Ctrl+C exits without cancelling agents.
|
|
79
|
+
|
|
80
|
+
New events and response updates preserve reading position and selection. If a selected row disappears, selection moves to the nearest remaining row by its previous position. Explicit End follows the body's end until the user scrolls away or moves selection. The fixed header stays visible; short terminals reduce it to a clipped identity line while preserving at least one body row. A one-row terminal prioritizes selected content. The request list's Sub-agents footer is not repeated here.
|
|
81
|
+
|
|
82
|
+
Prose wraps at up to 100 terminal cells, preferring whitespace and preserving indentation and line breaks. Long unbroken text wraps by grapheme width. Content, labels, states and errors are sanitized before measurement and rendering; native terminal controls are never executed. `NO_COLOR` applies to the whole screen. The CLI owns all layout and input handling. There is no usage/cost report or file attribution. Quiet work is not labelled stalled, waiting does not imply human intervention, and completion does not claim independent verification of success.
|
|
61
83
|
|
|
62
84
|
## Sub-agents footer
|
|
63
85
|
|
|
@@ -67,14 +89,20 @@ The footer is a read-only summary, independent of request selection. It uses at
|
|
|
67
89
|
|
|
68
90
|
## Refresh and compatibility
|
|
69
91
|
|
|
70
|
-
The overview remains a small snapshot. An open
|
|
92
|
+
The overview remains a small snapshot. An open request list requests only that session's metadata. Full prompt/response content is fetched only for the open task screen and retained only for that screen, omitting unchanged content on refresh. Polling is serialized, with each read bounded by a five-second timeout. Changing view/task aborts obsolete reads and ignores late results. Wrapping is reused while text and width are unchanged. Rendering retains bounded pending state under output backpressure and does not redraw unchanged lines.
|
|
93
|
+
|
|
94
|
+
The live subscription is separate from serialized metadata/detail polling. Event consumption updates the bounded display state independently of terminal rendering, so rendering speed never causes subscription backpressure. It supplies only events accepted after registration; the CLI can query current route capabilities separately when needed. Closing or switching task screens closes the previous subscription and ignores its late delivery. When a stream ends normally, steps already displayed remain until the screen closes.
|
|
95
|
+
|
|
96
|
+
If the subscription fails with `EVENT_BACKPRESSURE`, the screen shows its code and safe message and a notice that some steps were missed, then reopens the task-scoped subscription while the screen remains open. Reopen attempts occur at most once every 2 seconds. After 3 consecutive backpressure failures within 60 seconds, including any failed reopen as a failure, automatic retries stop and the screen shows “Live steps paused; reopen the task to retry.” Reopening the task starts a new observation and retry interval. Each subscription receives only subsequent events; it does not recover missed activity. Other event-stream failures show a safe live-observation error while core task inspection remains available.
|
|
97
|
+
|
|
98
|
+
A coordinator lacking `session-events-v1` can still supply core task inspection. In place of live steps, the task screen shows `COORDINATOR_OUTDATED` with guidance to stop the coordinator after active work ends and start a new run, while preserving the header, request, error and latest complete response. Restarting only the dashboard does not reload coordinator code; coordinator restart discards retained history. The SDK event operation still uses `COORDINATOR_INCOMPATIBLE`; this is the dashboard's compatibility presentation. Extension diagnostics are shown only by `subharness extensions list` and remain available through the coordinator's existing safe diagnostics. The dashboard neither loads nor hosts extensions; its task screen displays neither extension diagnostics nor extension log contents.
|
|
71
99
|
|
|
72
100
|
Inspection never sends prompts, steers, cancels, resumes or acknowledges work, starts execution, or restarts the coordinator. The private transport is defined in [Inspection transport](dashboard-inspection.md).
|
|
73
101
|
|
|
74
|
-
Snapshots require finished
|
|
102
|
+
Snapshots require the `history: true` and `grouping: true` markers for finished history and grouped context. Opening a task screen additionally requires the snapshot marker `taskDetails: true`, which covers `DashboardDetail.agentName` and `model`. An absent or false `taskDetails` marker keeps the dashboard running; opening a task screen preserves and refreshes the known request-row header, shows `COORDINATOR_OUTDATED` with the same restart guidance instead of task details, omits the unavailable request, and labels the response `Response unavailable`. It does not retain a loading label when no detail read is active and is not a malformed-detail error. Among these markers, only missing `history` or `grouping` ends the dashboard with `COORDINATOR_OUTDATED` and exit `1`; the exact legacy unknown-operation response for the overview has the same exit behavior. Opening the request list against a coordinator without the history operation reports the same error rather than presenting incomplete history. Other malformed or failed reads report `COORDINATOR_UNAVAILABLE` after terminal cleanup. Restarting a coordinator discards retained history and is never performed automatically.
|
|
75
103
|
|
|
76
104
|
## Shared presentation boundary
|
|
77
105
|
|
|
78
|
-
The terminal command and website demonstration reuse the internal ANSI renderer, layout,
|
|
106
|
+
The terminal command and website demonstration reuse the internal ANSI renderer, overview/request/task layout, live turn/step formatting, text sanitization, input decoding and key-action dispatch. Presentation code accepts explicit dimensions, data and time; it does not discover workspaces, access credentials, read files or contact the coordinator. This boundary adds no public SDK method. The terminal command preserves its existing process lifecycle, serialized reads and backpressure behavior. The website supplies fictional read-only projections and owns its browser terminal lifecycle.
|
|
79
107
|
|
|
80
|
-
The internal `dispatchDashboardKey(renderer, key)` function in `src/cli/dashboard-controller.ts` applies a `DashboardKey` to a `DashboardRenderer` and returns `{ interrupt: boolean; refreshInspection: boolean }`. Interrupt requests process exit only in the CLI host; the browser host instead releases focus. `refreshInspection` is true when
|
|
108
|
+
The internal `dispatchDashboardKey(renderer, key)` function in `src/cli/dashboard-controller.ts` applies a `DashboardKey` to a `DashboardRenderer` and returns `{ interrupt: boolean; refreshInspection: boolean }`. Interrupt requests process exit only in the CLI host; the browser host instead releases focus. `refreshInspection` is true when entering or leaving a request list or task screen invalidates the current inspection scope. After that signal, hosts read the renderer's current view and inspected session/task identity. The CLI host uses that state to cancel obsolete reads and open or close the task-scoped subscription. The website host supplies the corresponding fictional projection and live steps without a coordinator. Moving among request rows, selecting/expanding live step rows, and scrolling within one task screen do not fetch another task's full content. The dispatcher never fetches data, loads user code or schedules timers.
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# Private dashboard inspection transport
|
|
2
2
|
|
|
3
|
-
This authenticated coordinator operation serves the read-only terminal inspector. It is internal, not a public SDK execution method. The
|
|
3
|
+
This authenticated coordinator operation serves the read-only terminal inspector. It is internal, not a public SDK execution method. The overview snapshot remains small and advertises `taskDetails: true` alongside its existing `history: true` and `grouping: true` capability markers. `taskDetails` covers the task-screen `DashboardDetail.agentName` and optional `model` fields.
|
|
4
4
|
|
|
5
5
|
The POST request is `{command: "dashboard-detail", id: string, includePrompt?: boolean, knownResponseId?: string}`. `id` identifies a retained task. `includePrompt` defaults to true; false omits the original prompt. `knownResponseId` optionally identifies a response already cached by this client. Unknown tasks return `UNKNOWN_TASK`; invalid field types return `INVALID_ARGUMENT`.
|
|
6
6
|
|
|
7
|
-
The response is `DashboardDetail`: `{version: 1, type: "dashboard-detail", task: DashboardRow, prompt?: string, response?: {responseId: string, text?: string}, error?: {code: string, message: string}, children: DashboardRelatedTask[], queue: {paused: boolean, tasks: DashboardRelatedTask[]}, stopUnconfirmed: boolean}`. `DashboardRow` is the same task projection used by the list. `DashboardRelatedTask` is `{taskId: string, sessionId: string, harness: DashboardHarness, title: string, state: TaskState}`. Related titles use the same 120 Unicode code-point bound as list titles. Children are direct managed children in admission order; queue tasks are pending follow-ups in dispatch order. Queue context is the session's current queue even when inspecting an older task; it does not imply those queued tasks belong to the historical task.
|
|
7
|
+
The response is `DashboardDetail`: `{version: 1, type: "dashboard-detail", task: DashboardRow, agentName: string, model?: string, prompt?: string, response?: {responseId: string, text?: string}, error?: {code: string, message: string}, children: DashboardRelatedTask[], queue: {paused: boolean, tasks: DashboardRelatedTask[]}, stopUnconfirmed: boolean}`. `DashboardRow` is the same task projection used by the list. `DashboardRelatedTask` is `{taskId: string, sessionId: string, harness: DashboardHarness, title: string, state: TaskState}`. Related titles use the same 120 Unicode code-point bound as list titles. Children are direct managed children in admission order; queue tasks are pending follow-ups in dispatch order. Queue context is the session's current queue even when inspecting an older task; it does not imply those queued tasks belong to the historical task.
|
|
8
8
|
|
|
9
|
-
The
|
|
9
|
+
The task screen uses `agentName` from the captured specialist definition, or the direct harness target name. If captured display metadata supplies an empty agent name, the projection uses the selected harness name when known; an unresolved harness leaves the value empty and the renderer treats it as unknown. `model` is the selected native model when known; it is absent until resolved and never guessed from alternatives. Both display fields are capped at 256 UTF-8 bytes, truncated at valid code-point boundaries with a visible truncation marker, and sanitized on display. This display limit does not change the selected native model identifier. Existing task fields supply harness, workspace, state and timing. These display fields contain no loaded definition or configuration object.
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The latest complete response is present only when one exists. Its `text` is omitted exactly when its identifier equals `knownResponseId`; otherwise full text is returned. An absent response means no response exists, not unchanged content. Prompt is the full original admitted prompt and is included unless `includePrompt` is false. The task screen keeps the original prompt separate from its summarized agent/task header. Error and stop confirmation are task-scoped. The error code and message are the same retained task error exposed by `status`; the inspector does not add native stderr or diagnostic logs. The response excludes native/internal tokens, environment, loaded definitions and access settings.
|
|
12
12
|
|
|
13
|
-
The client
|
|
13
|
+
The client fetches full content when a task screen opens, retains it only for that screen, and refreshes it with `includePrompt: false` and the cached response identifier. A changed response replaces the cached latest response. Each full prompt and response is already bounded by task admission and native response limits; there is no unbounded transcript transfer. Reads do not acknowledge descendant results, alter timestamps, start execution, or mutate queues. Snapshot/context assembly must remain coherent across asynchronous workspace resolution.
|
|
14
|
+
|
|
15
|
+
Before requesting task-screen details, the client requires the overview snapshot's `taskDetails: true` marker. An absent or false `taskDetails` marker keeps the dashboard running; the task screen preserves and refreshes the selected request row's known header facts, shows `COORDINATOR_OUTDATED` instead of task details, omits the unknown request, and shows `Response unavailable` without a loading label. Missing `history` or `grouping` markers instead end the dashboard with `COORDINATOR_OUTDATED` and exit `1`. Restarting only the dashboard does not reload coordinator code; coordinator restart discards retained history. The client does not misclassify an older coordinator's lack of these fields as malformed data. A nonboolean marker is malformed. With the capability present, the client validates identity, structure, lifecycle state, workspace paths, agent/model bounds, timestamps, error and content omission semantics before displaying a record. A malformed, failed or timed-out read exits with `COORDINATOR_UNAVAILABLE` after terminal cleanup. The exact legacy unknown-operation response for this operation reports `COORDINATOR_OUTDATED` with restart guidance. A coordinator that supports the existing overview but lacks inspection can show its list until Enter requests inspection. It is never restarted automatically.
|
|
14
16
|
|
|
15
17
|
## Agent-session history transport
|
|
16
18
|
|
|
@@ -22,4 +24,10 @@ Sub-agents are direct managed child sessions referenced by any retained task in
|
|
|
22
24
|
|
|
23
25
|
The projection is coherent across asynchronous workspace discovery and does not mutate recency, acknowledge responses or transfer full prompts/responses, credentials, environment or native transcript content. The client validates identity, unique task IDs and ordinals, exact request ordering, lifecycle fields, related session uniqueness and bounded titles before rendering. The exact legacy unknown-operation error maps to `COORDINATOR_OUTDATED`; malformed records, other errors, failed HTTP responses and timeouts map to `COORDINATOR_UNAVAILABLE`.
|
|
24
26
|
|
|
25
|
-
The existing `dashboard-detail` operation remains task-scoped and supplies content only for
|
|
27
|
+
The existing `dashboard-detail` operation remains task-scoped and supplies content only for the open task screen. Its prompt and response omission rules remain unchanged. The dashboard does not render that operation's legacy child and queue sections because the history projection supplies the session-wide footer and queued request rows.
|
|
28
|
+
|
|
29
|
+
## Live observation boundary
|
|
30
|
+
|
|
31
|
+
Neither projection carries assistant deltas, reasoning or tool streams. The dashboard itself opens a task-scoped subscription through the public [live event API](../events.md) when the task screen opens, renders arriving turns/steps, and closes the subscription when leaving. Private inspection supplies the original request, task error and latest complete response; it does not populate earlier steps. Earlier content appears only when the native route itself later supplies it in a snapshot; adapters keep no extra content for later observation. For mid-item joins on chunk-only `fx-acp` and `cursor-acp`, turn-boundary snapshots cover only content normalized since registration and use item state `"incomplete"`. Only the selected task's steps are shown; managed descendants have their own task screens. Approval request/resolution events render `Approval` rows with `pending`, `answered` or `withdrawn` state and the observed request message; session errors render inline notice rows. These rows count toward the same bound as item steps. The open task screen keeps at most 500 steps, dropping the oldest with a visible omission notice; this is a dashboard display-state limit, not a private projection or event-delivery limit. User extensions are supervised separately by the coordinator and are not loaded by the dashboard.
|
|
32
|
+
|
|
33
|
+
Private reads and event subscriptions neither acknowledge managed child responses nor alter execution recency. Missing `session-events-v1` support displays `COORDINATOR_OUTDATED` and the same restart guidance in place of live steps, while core inspection remains usable. Other live-stream failures produce safe task-screen diagnostics. Event consumption updates display state independently of rendering. On `EVENT_BACKPRESSURE`, the screen reports that some steps were missed and follows the [bounded retry policy](dashboard-design.md#refresh-and-compatibility): at most one reopen every 2 seconds, stopping after 3 consecutive failures within 60 seconds, with failed reopens counted. It then shows “Live steps paused; reopen the task to retry.” Past events remain unavailable. The task screen does not display extension diagnostics or extension log contents; the dashboard neither loads nor hosts extensions. Missing/malformed required inspection data retains the compatibility/failure rules above. Switching tasks aborts old detail reads and closes old live subscriptions; late results are ignored by task/view identity.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Extension commands
|
|
2
|
+
|
|
3
|
+
Extensions are optional, user-developed event handlers supervised by the coordinator. [User extensions](../extensions.md) defines their API, manifest and process lifetime. Management commands read manifests and `~/.subharness/extensions.json`; they never import extension modules or start an agent.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
subharness extensions --help
|
|
7
|
+
subharness extensions list
|
|
8
|
+
subharness extensions enable <global:id|repo:id>
|
|
9
|
+
subharness extensions disable <global:id|repo:id>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`subharness extensions` without a subcommand prints the extensions usage to stderr and exits `2`. `subharness extensions --help` prints that usage to stdout and exits `0`. All subcommands accept `--help`; no other options or extra arguments are accepted. Repository scope resolves the command's directory to its canonical worktree root, or to that directory outside Git. Run repository commands in the checkout being managed. Enable/disable require qualified references, so an installation never silently shadows another. Instance identity is the qualified reference plus the canonical checkout for repository extensions; global instances have no checkout component. Failure state, eligibility and re-enablement are scoped to that identity. Enabling `repo:<id>` in one checkout affects only its instance, even when another checkout has the same extension ID.
|
|
13
|
+
|
|
14
|
+
`list` reads `~/.subharness/extensions/<id>/extension.json` and `<worktree>/.subharness/extensions/<id>/extension.json`. It shows qualified ID, version, location, enabled/disabled consent, static validation status, the actual instance log path under the selected coordinator's state directory, each applicable instance's `running`, `idle` or `disabled` runtime state, and its diagnostics. Enabled consent is not proof a process is running. After an instance fails, that instance identity is ineligible for newly admitted sessions until explicit re-enablement or coordinator restart resets its runtime restriction. Other checkouts' instances retain their own failure and eligibility state. Runtime status reflects only that coordinator; commands do not start a coordinator merely to obtain it. An absent coordinator is reported as no active coordinator status. Discovery or consent-read failures that occurred during session admission appear in a separate admission-diagnostics section because they may not identify an instance. Session admission remains successful without extension delivery.
|
|
15
|
+
|
|
16
|
+
List and the coordinator's extension-status operation each report at most 256 instances. When more instances exist, list states exactly how many additional instances were omitted. Each instance shows at most its eight most recent diagnostics. The separate admission-diagnostics section shows at most the 16 most recent entries.
|
|
17
|
+
|
|
18
|
+
A reachable coordinator that does not support the extension-status operation produces a line stating that the coordinator does not report extension status and suggesting a restart; list still exits `0`. Listing never evaluates modules, fetches packages or invokes models.
|
|
19
|
+
|
|
20
|
+
`enable` validates the static manifest and entry location, then stores the current user's consent in the owner-only `~/.subharness/extensions.json` file using the [documented schema](../config.md#extension-consent-and-logs). Global enablement applies to newly admitted coordinator sessions across workspaces; repository enablement applies to new sessions in that canonical checkout. CLI and connected SDK creation use this same admission-time selection. The confirmation identifies the qualified installation and directory and states that the code executes with the supervised process's Node.js permissions. It does not import the entry to test it. A running instance keeps its loaded code; consent persists after checkout edits.
|
|
21
|
+
|
|
22
|
+
After saving consent, enable notifies a running coordinator. If the selected instance identity has a failed process, successful notification makes a replacement eligible for newly admitted sessions and a new process starts at the first matching admission; sessions assigned to the failed instance are not reassigned. Repeating enable for an already eligible instance identity leaves its running process unchanged. Enabling never attaches to previously admitted sessions. With no running coordinator nothing else is needed. An unsupported extension-status operation on a reachable coordinator is a failed notification. If notification fails, consent stays saved; the command prints a warning that the failure state clears on coordinator restart and exits `0`. It does not claim the running coordinator accepted the reset.
|
|
23
|
+
|
|
24
|
+
`disable` removes eligibility for newly admitted sessions. Sessions already assigned to the running instance keep their delivery, and the instance remains coordinator-owned until shutdown or failure. It can remove consent even when files are missing or invalid. Repeating disable for a disabled reference is harmless. Neither enable nor disable cancels work or changes native permissions.
|
|
25
|
+
|
|
26
|
+
Global and repository installations are independent qualified sources. All enabled global installations and enabled repository installations for a session's checkout receive that session. Disabling a global reference affects new session eligibility across workspaces for the current user. Other users are not enabled by committed repository files or by this consent file. State-directory selection follows the [execution rule](../execution.md#ownership-and-transport-boundaries): explicit `ConnectOptions.stateDirectory`, then `AGENT_STATE_DIR`, then `~/.subharness/state/shared`; CLI commands use the environment/default rule.
|
|
27
|
+
|
|
28
|
+
## Directory installation
|
|
29
|
+
|
|
30
|
+
An installation contains a static `extension.json`, compiled ESM entry and any required packaged dependencies. Its JavaScript must not import Subharness at runtime. There is no package installation command. See the [complete tool-result logger](../extensions.md#complete-tool-result-logger) for self-contained source, manifest, compilation and enablement commands.
|
|
31
|
+
|
|
32
|
+
Each `extension.json` is at most 16 KiB, and any `package.json` read from an extension directory is at most 64 KiB. The consent file is at most 256 KiB, with at most 1,024 repository entries and 256 IDs per scope: 256 global IDs and 256 IDs for each repository entry.
|
|
33
|
+
|
|
34
|
+
Copy a trusted prepared artifact into `~/.subharness/extensions/<id>/` or `<worktree>/.subharness/extensions/<id>/`, then explicitly enable the qualified ID. Copying files does not itself enable code for any user. Discovery/enablement never installs dependencies, runs lifecycle scripts or builds TypeScript.
|
|
35
|
+
|
|
36
|
+
## Output and failures
|
|
37
|
+
|
|
38
|
+
The exit codes on this page govern all `subharness extensions` commands and take precedence over the general CLI configuration exit codes.
|
|
39
|
+
|
|
40
|
+
Every extensions command rejects an existing `~/.subharness/extensions.json` that is not owner-only, exits `1`, and gives guidance to restrict its permissions with `chmod 600 ~/.subharness/extensions.json`. No command repairs permissions.
|
|
41
|
+
|
|
42
|
+
These commands use human-readable text only and do not accept `--format`. Successful list/enable/disable exits `0`. Invalid arguments, missing enable targets, invalid manifests and incompatible requested versions exit `2`; consent-file/discovery I/O or coordinator communication failure exits `1`, except for the documented unsupported extension-status response to list and enable notification failure after consent is saved, both of which exit `0`. Errors are safe text on stderr. List can succeed while reporting an invalid installation or a failed runtime instance; failure of that extension is data, not failure of the list operation.
|
|
43
|
+
|
|
44
|
+
Handler errors, timeouts, crashes and backpressure disable the affected instance for the rest of the owning coordinator's lifetime; it is not automatically restarted. Its failure remains visible through list for that lifetime, including after explicit re-enablement starts a new instance. Restarting the coordinator resets runtime failure state. A stopped or unavailable coordinator cannot supply retained runtime diagnostics. Static discovery remains distinct from runtime status; uncertain communication is reported instead of presented as a healthy process. The CLI displays `EXTENSION_*` codes and their safe messages only through list; they also remain available through the coordinator's existing safe diagnostics. The dashboard does not display extension diagnostics. An unexpected extension-process exit uses `EXTENSION_EXITED` and disables the instance like other failures. Runtime diagnostics never expose event content, raw child output, thrown messages, stacks or credentials. List shows the actual log path: `<stateDirectory>/extensions/global-<id>.log` for a global instance or `<stateDirectory>/extensions/repo-<id>-<checkout-hash>.log` for a repository instance. `<checkout-hash>` is the first 12 hex characters of the SHA-256 of the canonical checkout path, so filenames contain no colons. Log contents are never copied into command output, diagnostics or the dashboard. The owner-private log is compacted after it exceeds 1.5 MiB and is trimmed to the most recent 1 MiB of stdout/stderr. Log open, write or close failures do not stop the instance: output that cannot be written is discarded, and list shows `EXTENSION_LOG_UNAVAILABLE` as an informational diagnostic. [CLI output](output.md) defines the separate execution-command records.
|
package/sdk/cli/index.md
CHANGED
|
@@ -5,6 +5,10 @@ The CLI is the primary execution interface for an everyday coding assistant. The
|
|
|
5
5
|
```sh
|
|
6
6
|
subharness list [--cwd <directory>]
|
|
7
7
|
subharness dashboard
|
|
8
|
+
subharness extensions --help
|
|
9
|
+
subharness extensions list
|
|
10
|
+
subharness extensions enable <global:id|repo:id>
|
|
11
|
+
subharness extensions disable <global:id|repo:id>
|
|
8
12
|
subharness check <target> [--cwd <directory>] [--format text|jsonl]
|
|
9
13
|
subharness check <harness> [--cwd <directory>] [--model <model>] [--effort <effort>] [--format text|jsonl]
|
|
10
14
|
subharness run <target> [--cwd <directory>] [--detach] <prompt>
|
|
@@ -21,10 +25,11 @@ subharness respond <request-id> --content <json>
|
|
|
21
25
|
subharness respond <request-id> --content-file <path|->
|
|
22
26
|
subharness queue <session-id>
|
|
23
27
|
subharness cancel <task-id>
|
|
28
|
+
subharness close <session-id> [--format text|jsonl]
|
|
24
29
|
subharness resume <session-id>
|
|
25
30
|
```
|
|
26
31
|
|
|
27
|
-
Execution commands accept `--format text|jsonl`; text is the default. `--help` and `--version` are plain-text information modes without a `--format` option. `subharness --help` and `<command> --help` show usage without requiring execution arguments or starting execution. Direct harness help includes that harness’s options; other command help shows the general usage. [Output records and exit codes](output.md) define the integration format.
|
|
32
|
+
Execution commands accept `--format text|jsonl`; text is the default. `--help` and `--version` are plain-text information modes without a `--format` option. `subharness --help` and `<command> --help` show usage without requiring execution arguments or starting execution. Direct harness help includes that harness’s options; extension help shows extensions usage; other command help shows the general usage. [Output records and exit codes](output.md) define the integration format.
|
|
28
33
|
|
|
29
34
|
`list` includes the built-in harness targets and discovered definitions without starting harnesses or calling models. Inclusion is not a claim that an executable, eligible account, or particular model is available. Definition loading retains its existing validation and trust requirements. `check` performs the selected target's native startup checks in an isolated worker, closes the temporary native session, confirms that the worker and adapter-owned native processes have stopped, and returns without submitting a turn or admitting a task. Cleanup or unconfirmed termination is a failed check, not a readiness result. `run` starts a new session and its first task, immediately prints their identities, and waits for one complete response, pending permission request, or terminal outcome. It returns control even if that task still has delegated work. A response contains a response identifier and task state; an approval observation contains request identifiers and schemas.
|
|
30
35
|
|
|
@@ -32,6 +37,20 @@ Readiness means only that startup checks for the selected target passed at that
|
|
|
32
37
|
|
|
33
38
|
`run --detach` instead returns immediately after successful admission with only the same `started` record.
|
|
34
39
|
|
|
40
|
+
## Close a session
|
|
41
|
+
|
|
42
|
+
`subharness close <session-id>` stops new admission to the session, cancels its active and queued tasks and their recorded descendants with confirmed-stop semantics, and then closes the native harness resources. The harness therefore performs cleanup for tool processes that it tracks as part of the native session. The closed session and its retained task records remain inspectable. Closing an already closed session succeeds.
|
|
43
|
+
|
|
44
|
+
Session identifiers resolve coordinator-wide; `close` is not restricted by managed parent lineage. Callers must close only sessions whose lifecycle they own and no longer need.
|
|
45
|
+
|
|
46
|
+
`close` attaches to the selected existing coordinator and never starts one. An unknown session is `UNKNOWN_SESSION`. A running coordinator that predates this operation returns `COORDINATOR_OUTDATED` with guidance to stop that coordinator after active work ends and start a new run. Cancellation and cleanup failures retain their safe `CANCEL_FAILED` or native-cleanup diagnostics. See [CLI output](output.md) for records and exit codes.
|
|
47
|
+
|
|
48
|
+
Task cancellation and interrupt stop the agent's active native turn, including recorded descendant work and admitted callbacks. A tool process that the native harness intentionally tracks across turns can continue after cancellation or task completion. Examples include a yielded Codex background terminal and a Claude Code `run_in_background` shell. `subharness close`, SDK `session.close()`, and coordinator shutdown close the native session, allowing the harness to terminate those tracked tool processes. A command that deliberately detaches a process outside the harness's tracking, such as a daemon that escapes with `setsid`, is outside both Subharness and harness ownership and can survive every one of these boundaries.
|
|
49
|
+
|
|
50
|
+
Verification scope is limited to live Codex 0.157.0 and Claude Code 2.1.288 sessions plus fx 0.0.12 source inspection. The fx evidence is source-only because that installed version could not create a live session during verification. OpenCode, GitHub Copilot, and Cursor have no equivalent verified tool-process evidence; their adapter close contract still applies.
|
|
51
|
+
|
|
52
|
+
[Extension commands](extensions.md) discover static manifests and manage explicit per-user consent in the owner-only `~/.subharness/extensions.json` file. `subharness extensions` without a subcommand prints extensions usage to stderr and exits `2`; `subharness extensions --help` prints it to stdout and exits `0`. These commands use text output, never import extension modules, and do not accept `--format`. The coordinator supervises each applicable extension in a separate child process when its first matching session is admitted. Newly admitted CLI and connected SDK sessions are assigned to enabled global extensions and enabled repository extensions for their checkout. The dashboard and embedded runners do not load extension code.
|
|
53
|
+
|
|
35
54
|
## Live dashboard
|
|
36
55
|
|
|
37
56
|
`subharness dashboard` opens a read-only live terminal display for the current local coordinator, covering all of its managed directories, with the calling checkout pinned first when it has displayed runs. It includes direct harness sessions, specialists, and delegated agents managed by that coordinator. It does not discover unmanaged native processes or coordinators belonging to other installations or state directories.
|
|
@@ -50,11 +69,11 @@ The harness label is `codex`, `claude`, `fx`, `opencode`, `copilot`, or `cursor`
|
|
|
50
69
|
|
|
51
70
|
Time is elapsed wall time since that task first dispatched, including waiting and recovery. A queued task shows `00:00`. Completed, cancelled, and interrupted tasks freeze their elapsed time when that outcome is reached. Failed tasks freeze their elapsed time at failure and resume counting from the original start if explicitly recovered. Tasks cancelled before first dispatch show `00:00`. Repeated observation or cancellation that leaves a settled terminal outcome unchanged does not change its recorded finish time. If stopping previously unconfirmed execution reaches a new outcome, timing records that new outcome. Durations use `MM:SS` below one hour and `H:MM:SS` thereafter. State and elapsed time occupy separate aligned columns. Finished rows include completion age when space permits, as defined in [Dashboard presentation](dashboard-design.md). Narrow terminals truncate titles by display width without splitting grapheme clusters; when the fixed fields alone do not fit, the row is clipped to the available columns.
|
|
52
71
|
|
|
53
|
-
The overview contains compact group labels and agent rows: no application heading, border, footer, spinner, key hints, or empty-state message. A leading `›` identifies the selected task. It uses the alternate screen and restores the normal screen and cursor on exit. When stdin is a terminal, keyboard echo is suppressed and Up/Down, Enter, Escape and inspector scrolling keys are handled; the previous input mode is restored on exit. Non-terminal stdin is not consumed. Overview rows do not wrap; selection scrolls the list to reach runs outside the viewport. Current work takes precedence over finished history within each group. Enter opens the selected task's agent-session history with queued requests first and remaining requests newest first. Up/Down select requests; Enter
|
|
72
|
+
The overview contains compact group labels and agent rows: no application heading, border, footer, spinner, key hints, or empty-state message. A leading `›` identifies the selected task. It uses the alternate screen and restores the normal screen and cursor on exit. When stdin is a terminal, keyboard echo is suppressed and Up/Down, Enter, Escape and inspector scrolling keys are handled; the previous input mode is restored on exit. Non-terminal stdin is not consumed. Overview rows do not wrap; selection scrolls the list to reach runs outside the viewport. Current work takes precedence over finished history within each group. Enter opens the selected task's agent-session history with queued requests first and remaining requests newest first. Up/Down select requests; Enter opens a dedicated task screen with agent name, known harness/model, state, workspace, elapsed time, original request, error and latest response. The core task screen subscribes to live events and renders selectable arriving steps: Up/Down moves through them, Enter expands/collapses bounded details, and PageUp/PageDown/Home/End scroll. A compact Sub-agents footer summarizes direct child sessions. Completed states are green when color is enabled. Escape returns from the task screen to the request list, then from that list to the overview. The detailed navigation and presentation rules are defined in [Dashboard presentation](dashboard-design.md#task-screen). Dashboard inspection is read-only and does not load user extensions. Ctrl+C exits with code `130`; SIGTERM exits with code `143`. Exiting never cancels agents.
|
|
54
73
|
|
|
55
|
-
Snapshots refresh once per second without overlapping requests. Resizing redraws the current
|
|
74
|
+
Snapshots refresh once per second without overlapping requests. Opening a task screen also opens the public [live event subscription](../events.md) scoped to that task; leaving closes it. Only events accepted after registration populate turns and steps. Past events are not loaded; the existing request, task error and latest complete response remain available. Content produced before registration appears only if the native route itself later supplies it in a snapshot. For mid-item joins on chunk-only fx and Cursor ACP routes, turn-boundary snapshots include only content normalized since registration and use item state `"incomplete"`. Only the selected task's own steps are displayed. Approval events add `Approval` rows with `pending`, `answered` or `withdrawn` state and the observed request message; session errors add inline notice rows. The dashboard display keeps at most 500 steps including those rows, dropping the oldest with a visible notice that earlier steps were omitted. User extensions are supervised independently by the coordinator and have no dashboard UI. Event consumption is independent of rendering speed. If `EVENT_BACKPRESSURE` occurs, the screen shows a missed-steps notice and reopens at most once every 2 seconds. After 3 consecutive backpressure failures within 60 seconds, counting failed reopens, retries stop with “Live steps paused; reopen the task to retry.” Missing `session-events-v1` support shows `COORDINATOR_OUTDATED` with coordinator restart guidance in place of live steps while core content remains available. Other event-stream failures show safe diagnostics while core inspection remains available. Extension diagnostics are shown only by `subharness extensions list`, not on the task screen. Resizing redraws the current view immediately. Unchanged visible rows are not rewritten. Rendering uses native Node streams and terminal escape sequences with a focused Unicode width utility. Slow output does not accumulate unbounded redraws.
|
|
56
75
|
|
|
57
|
-
The command requires terminal stdout and a terminal supporting cursor control; non-terminal output and `TERM=dumb` fail with `INVALID_ARGUMENT` and exit `2` before connecting or emitting terminal escapes. It accepts no positional arguments or options except `--help`, which follows general command help behavior. In particular, it has no `--format` or `--cwd` option. Errors use ordinary text stderr after restoring the terminal. It does not load agent definitions, start a coordinator, start a harness, or submit work. If no coordinator is initially reachable, the list stays blank and checks again once per second so agents started later can appear. After a successful connection, a failed, invalid, or timed-out snapshot exits with an error instead of presenting stale data. The snapshot
|
|
76
|
+
The command requires terminal stdout and a terminal supporting cursor control; non-terminal output and `TERM=dumb` fail with `INVALID_ARGUMENT` and exit `2` before connecting or emitting terminal escapes. It accepts no positional arguments or options except `--help`, which follows general command help behavior. In particular, it has no `--format` or `--cwd` option. Errors use ordinary text stderr after restoring the terminal. It does not load agent definitions, start a coordinator, start a harness, or submit work. If no coordinator is initially reachable, the list stays blank and checks again once per second so agents started later can appear. After a successful connection, a failed, invalid, or timed-out snapshot exits with an error instead of presenting stale data. The snapshot identifies finished-run history with `history: true`, grouped checkout context with `grouping: true`, and the expanded task-detail fields with `taskDetails: true`. An absent or false `taskDetails` marker keeps the dashboard running; opening a task screen shows `COORDINATOR_OUTDATED` with restart guidance instead of task details. Among these markers, only missing `history` or `grouping` ends the dashboard with `COORDINATOR_OUTDATED` and exit `1`. The legacy unknown-operation error for `dashboard` has the same exit behavior. The error identifies the coordinator process and directs the user to stop it after active work ends and start a new run. Restarting only the dashboard does not reload coordinator code. Coordinator restart discards retained in-memory history; the dashboard never restarts it automatically. Snapshot requests have a five-second timeout.
|
|
58
77
|
|
|
59
78
|
## Direct harnesses and specialists
|
|
60
79
|
|
|
@@ -91,6 +110,10 @@ Direct-harness help for `run` and `check` describes the relevant options and acc
|
|
|
91
110
|
|
|
92
111
|
`run` and `send` require exactly one prompt source: one positional text argument, `--prompt <text>`, or `--prompt-file <path|->`. Quote a positional prompt containing spaces; extra positional arguments are errors rather than implicitly joined text. `--` ends option parsing and allows a positional prompt beginning with a dash. It never introduces native harness arguments.
|
|
93
112
|
|
|
113
|
+
Callers that generate long or multiline prompts should use `--prompt-file <path>` with an owner-private temporary file. Owner-private means that only the owner can access it; on POSIX systems, use mode `0600` inside a mode-`0700` temporary directory. Remove the file after a `started` or `accepted` record, or command exit, confirms that the CLI has read it. When the host owns standard input, callers may instead use `--prompt-file -`.
|
|
114
|
+
|
|
115
|
+
Generated long or multiline prompts should not be passed through `--prompt` or a positional argument. Large argument vectors increase process-launch cost, and a host argument limit can reject process launch with an explicit host error. Keeping the prompt payload out of the argument vector does not eliminate unrelated host resource pressure. If the host instead kills the CLI before admission, no task exists and the command prints nothing.
|
|
116
|
+
|
|
94
117
|
`--prompt-file -` reads standard input to EOF. It is explicit: piped stdin is not read or appended when another prompt source is supplied. Interactive terminal stdin is rejected instead of waiting for a conversation. Missing, empty, invalid UTF-8, and oversized input fail before session admission. File and stdin diagnostics distinguish read failures from invalid UTF-8 content. Files and stdin are bounded while reading to 1 MiB. File paths resolve relative to the calling command's directory, independently of `--cwd`. Omitted `--cwd` uses the calling directory. Follow-ups retain their session's execution directory.
|
|
95
118
|
|
|
96
119
|
`send` defaults to `queue`, creating a new task that waits for the active task's full completion boundary. `steer` targets whichever task is active when handled. If that task is between native turns, steering starts a continuation of the same task. If an actively generating harness lacks steering, the operation follows `interrupt` semantics and reports the effective mode. `interrupt` cancels affected work, waits for stop confirmation, and starts a replacement before independently queued tasks. See [message delivery](../message-delivery.md).
|
package/sdk/cli/output.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[Error diagnostics](../diagnostics.md) defines safe process and coordinator communication details. These details enrich message text without changing the error record shape or command exit-code rules.
|
|
4
4
|
|
|
5
|
-
`dashboard` is a terminal-only live view, not an execution-record command. It accepts no `--format` option and emits no text/JSONL records on success. Its
|
|
5
|
+
`dashboard` is a terminal-only live view, not an execution-record command. It accepts no `--format` option and emits no text/JSONL records on success. Its overview, request list, task screen, empty state and terminal lifecycle are defined in the [CLI contract](index.md#live-dashboard).
|
|
6
|
+
|
|
7
|
+
[Extension management commands](extensions.md) use plain text and the exit codes defined on that page; they do not accept `--format`. Supervised extension diagnostics are visible through `subharness extensions list`; extension output never interleaves with execution-command records or dashboard rendering. The public [live event subscription](../events.md) is a separate SDK stream, not another `run`/`wait` output mode.
|
|
6
8
|
|
|
7
9
|
Execution commands accept `--format text|jsonl`; `text` is the default. Both formats report the same operations. JSONL contains complete records separated by newlines, never native token streams or tool transcripts. All records include `version: 1` and a `type` discriminator. Identifiers are opaque strings prefixed with `ses_`, `tsk_`, `rsp_`, or `req_` and are not paths or process identifiers.
|
|
8
10
|
|
|
@@ -39,10 +41,20 @@ The identifiers above are illustrative. A `response` contains `sessionId`, `task
|
|
|
39
41
|
|
|
40
42
|
An `accepted` record contains `sessionId`, `taskId`, `delivery: "steer"`. A successful `cancel` emits a `cancelled` record with the targeted task identity and final state, after affected native execution has stopped. Already-terminal tasks retain their existing state. `resume` emits `started` for the existing task with `resumed: true`, then its next response or terminal outcome.
|
|
41
43
|
|
|
44
|
+
A successful `close` emits exactly one record after session cleanup completes:
|
|
45
|
+
|
|
46
|
+
```jsonl
|
|
47
|
+
{"version":1,"type":"closed","sessionId":"ses_123"}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Text output is `Closed session ses_123.`. Repeated close of an already closed session has the same successful output.
|
|
51
|
+
|
|
42
52
|
Errors use `{ "version": 1, "type": "error", "error": { "code": "INVALID_ARGUMENT", "message": "..." } }` with task/session identifiers when known. JSONL errors appear on stdout; text errors appear on stderr. Native stderr and credentials are not forwarded. Text responses show identifiers and state above the complete response text, with a `wait --after` hint only while the task is pending. Text layout is intended for reading; integrations should use JSONL.
|
|
43
53
|
|
|
44
54
|
Exit code `0` means the command succeeded or a response was returned; it does not mean the agent fulfilled the objective. For `check`, it means only that the selected target's startup checks passed at that moment. For `run --detach` and detached task-creating sends, it means admission succeeded, not that native startup or execution succeeded. Admission errors retain their existing error records and exit codes; later failures are available through `wait` or `status`. Code `1` means execution, access, or capability failure; `2` means invalid input, configuration, or unknown identifiers; and `130` means an observation ended in cancellation or interruption. Successful `cancel` itself exits `0`. Combining `--detach` with `--delivery steer` is an `INVALID_ARGUMENT` error and exits `2`.
|
|
45
55
|
|
|
56
|
+
Successful `close` exits `0`. An unknown session returns `UNKNOWN_SESSION` and exits `2`. An unavailable coordinator returns `COORDINATOR_UNAVAILABLE` and exits `1` without starting one. A coordinator that does not support session close returns `COORDINATOR_OUTDATED` with restart guidance and exits `1`. Cancellation or native cleanup failure retains the safe `CANCEL_FAILED` or cleanup diagnostic and exits `1`. When cancellation and native cleanup both fail in one close attempt, the native-cleanup diagnostic takes precedence because native resource retirement remains unconfirmed.
|
|
57
|
+
|
|
46
58
|
`status` snapshots retain the observed task’s outcome in their exit code: queued, running, waiting, awaiting_approval, and completed states exit `0`; cancelled or interrupted states exit `130`; failed states use `1` or `2` according to the stored error. A retrieval error uses its own error code.
|
|
47
59
|
|
|
48
60
|
Standard CLI `--help` and `--version` produce plain text, do not accept `--format`, and do not start the coordinator or harnesses. Command-level `--help` is also available without execution arguments. Unsupported options and extra positional arguments are errors.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Responses and Task Completion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The [execution SDK](execution.md) provides complete-response cursors and task snapshot observation directly to application code. Its separate [session events API](events.md) provides bounded normalized assistant/reasoning content and tool previews where the native route supports them. Only events accepted after subscription registration are delivered; they do not replace complete-response retention or acknowledge child-result delivery. UI disconnects detach observers. Embedded runner lifetime is application-owned; shared coordinator work survives connected-client disconnect.
|
|
4
|
+
|
|
5
|
+
Returning a response, completing a task, and starting another caller model turn are separate operations. The CLI returns control after each complete native response from the requested agent. It includes task/session identity, response identity, and the task state. Execution commands do not interleave live events or descendants' transcripts with their response records. The dashboard renders arriving steps from the separate public event source. [User extensions](extensions.md) execute independently in coordinator-supervised child processes.
|
|
4
6
|
|
|
5
7
|
The adapter captures complete responses automatically. Agents do not need a reporting tool, special JSON format, or a classifier that recognizes questions. A question is delivered through the same response mechanism as any other text.
|
|
6
8
|
|
package/sdk/config.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent Discovery
|
|
2
2
|
|
|
3
|
-
Repository agents live in `.subharness/agents/` at the Git worktree root. Global agents live in `~/.subharness/agents/`. The `.subharness/` directory holds subharness configuration
|
|
3
|
+
Repository agents live in `.subharness/agents/` at the Git worktree root. Global agents live in `~/.subharness/agents/`. The `.subharness/` directory holds subharness configuration, agent definitions, shared modules and optional extension installations. Cross-harness skills conventionally remain in `.agents/skills/`, which subharness does not read.
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
6
|
project/
|
|
@@ -10,12 +10,19 @@ project/
|
|
|
10
10
|
reviewer.ts
|
|
11
11
|
tools/
|
|
12
12
|
uppercaseTool.ts
|
|
13
|
+
extensions/
|
|
14
|
+
tool-result-logger/
|
|
15
|
+
extension.json
|
|
16
|
+
dist/
|
|
17
|
+
index.mjs
|
|
13
18
|
agents.local.json
|
|
14
19
|
```
|
|
15
20
|
|
|
16
21
|
Every `.ts` file under `agents/`, including files in nested directories, is a catalog entry that default-exports one `AgentDefinition`. Type declaration files ending in `.d.ts` are ignored. Other extensions are ignored. The file name does not determine the agent's name. There is no registry file or registration command. Symlink directories are not traversed. An invalid entry fails discovery with its source filename; it is not silently skipped.
|
|
17
22
|
|
|
18
|
-
Shared code such as custom tools, instruction fragments, and constants belongs outside `agents/`, for example in `.subharness/tools/`. Definitions import these modules with ordinary relative imports.
|
|
23
|
+
Shared code such as custom tools, instruction fragments, and constants belongs outside `agents/`, for example in `.subharness/tools/`. Definitions import these modules with ordinary relative imports. Agent discovery selects entries only under `agents/`; shared modules are loaded only through definition imports, and `tools/` is a convention rather than a discovered directory. A helper module placed inside `agents/` is treated as a definition and fails discovery when it does not default-export one.
|
|
24
|
+
|
|
25
|
+
Extension installations under `.subharness/extensions/<id>/` or `~/.subharness/extensions/<id>/` are separate from the agent catalog. Extension discovery reads static manifests only. Their compiled entries are executable code loaded only by a coordinator-supervised extension process after explicit per-user enablement. Agent discovery does not import extension entries. See [User extensions](extensions.md) and [extension commands](cli/extensions.md).
|
|
19
26
|
|
|
20
27
|
A definition imports shared modules and other definitions, such as a declared subagent, with relative paths:
|
|
21
28
|
|
|
@@ -51,6 +58,28 @@ An omitted `--cwd` uses the calling command's directory. Inside nested repositor
|
|
|
51
58
|
|
|
52
59
|
`check` resolves direct harnesses, repository and global specialists, unambiguous bare names, and declared children under the same rules as `run`. Direct harness checks bypass catalog discovery. Specialist checks evaluate the selected definition in an isolated worker, so they retain the same trust requirement and use the selected directory for definition loading and native startup. A check covers only that selected definition, not its declared children.
|
|
53
60
|
|
|
61
|
+
## Extension consent and logs
|
|
62
|
+
|
|
63
|
+
Extension consent is stored in `~/.subharness/extensions.json` with owner-only permissions. It uses this schema:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"version": 1,
|
|
68
|
+
"global": ["<id>"],
|
|
69
|
+
"repositories": {
|
|
70
|
+
"<canonical checkout path>": ["<id>"]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Enable and disable updates are serialized through the owner-private `~/.subharness/extensions.lock.sqlite` coordination file. The lock file contains no consent data. Each update re-reads `extensions.json` while it owns the lock before writing the replacement.
|
|
76
|
+
|
|
77
|
+
`global` contains enabled global extension IDs. Each `repositories` key is a canonical checkout path whose array contains enabled repository extension IDs. Repository consent is per checkout and never written into repository files. An instance is identified by its qualified reference plus its canonical checkout for repository extensions, or by its qualified reference alone for global extensions. Failure state, eligibility and re-enablement apply per instance; enabling in one checkout does not reset or enable another checkout's instance. The [extension commands](cli/extensions.md) read and update this file; discovery alone does not grant consent.
|
|
78
|
+
|
|
79
|
+
The consent file is at most 256 KiB. `repositories` contains at most 1,024 checkout entries. Each scope contains at most 256 IDs: the `global` array and each repository array have that limit independently. Every extensions command rejects an existing consent file that is not owner-only, exits `1`, and directs the user to restrict its permissions with `chmod 600 ~/.subharness/extensions.json`. No command repairs permissions. The [extension-command exit codes](cli/extensions.md#output-and-failures) take precedence over general CLI configuration exit codes for these commands.
|
|
80
|
+
|
|
81
|
+
Global instances write stdout/stderr to `<stateDirectory>/extensions/global-<id>.log`. Repository instances use `<stateDirectory>/extensions/repo-<id>-<checkout-hash>.log`, where `<checkout-hash>` is the first 12 hex characters of the SHA-256 of the canonical checkout path. Filenames contain no colons. The log uses owner-only access. It is compacted after it exceeds 1.5 MiB and trimmed to the most recent 1 MiB. The selected coordinator's state directory follows [execution discovery](execution.md#ownership-and-transport-boundaries): explicit `ConnectOptions.stateDirectory`, then `AGENT_STATE_DIR`, then `~/.subharness/state/shared`; CLI commands use the environment/default rule. Consent remains in `~/.subharness/extensions.json` regardless of the selected coordinator state directory. `subharness extensions list` shows each instance's actual log path, never its contents.
|
|
82
|
+
|
|
54
83
|
## Personal access and worktrees
|
|
55
84
|
|
|
56
85
|
The optional [access file](access-config.md) is `.subharness/agents.local.json` in the repository's main checkout, shared by its linked worktrees. This means the local checkout associated with those worktrees, not a branch named `main` or another clone of the same remote. Worktree agent definitions and execution directories still come from the selected worktree.
|