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/copilot.md
CHANGED
|
@@ -44,7 +44,7 @@ Enterprise managed-policy self-fetch is enabled for explicit GitHub-token access
|
|
|
44
44
|
|
|
45
45
|
## Lifecycle
|
|
46
46
|
|
|
47
|
-
Follow-ups reuse the native session. Events are correlated to the active turn; a final assistant message alone is not successful completion. A session-idle event is accepted in any native session mode after evidence that the submitted turn started, and only when no native work remains. A stale idle event cannot complete a newly submitted task. The adapter reports native shutdown or transport loss as an execution failure and limits final response text to 1 MiB. Model or endpoint substitutions fail without replay. Turn completion withdraws remaining approval requests.
|
|
47
|
+
Follow-ups reuse the native session. Events are correlated to the active turn; a final assistant message alone is not successful completion. [Live session events](events.md#effective-route-capabilities) expose bounded text/reasoning and tool previews separately from the final response. Their effective capabilities omit `nativeVersion` because the pinned SDK package version is not the native runtime version and the adapter does not expose a verified runtime version. Native streaming is enabled at every session startup so later subscribers receive subsequent deltas. With no subscriber, event normalization and event IPC are skipped. A session-idle event is accepted in any native session mode after evidence that the submitted turn started, and only when no native work remains. A stale idle event cannot complete a newly submitted task. The adapter reports native shutdown or transport loss as an execution failure and limits final response text to 1 MiB. Model or endpoint substitutions fail without replay. Turn completion withdraws remaining approval requests.
|
|
48
48
|
|
|
49
49
|
Interruption stops tool admission, withdraws pending approvals, requests native abort, confirms no native work remains, and waits for admitted callbacks. An abort acknowledgement alone does not prove the native process stopped. Native cancellation requests and status checks are bounded; a cancellation that cannot establish idle/termination returns `CANCELLATION_FAILED`. Already-admitted host callbacks are drained without imposing that native cancellation deadline on their execution. Steering uses the coordinator's interrupt behavior, and prompt-free recovery returns `RECOVERY_UNSUPPORTED`.
|
|
50
50
|
|
package/sdk/cursor.md
CHANGED
|
@@ -41,7 +41,7 @@ For API-key access, the selected key is passed explicitly to the SDK. Subscripti
|
|
|
41
41
|
|
|
42
42
|
Successive tasks use the same native agent. Specialist instructions supplement the native harness instructions in the first user turn; they do not replace Cursor's system prompt. Declared tools use native SDK custom tools, validate inputs, preserve text and image results, and stop admitting calls when the task stops. Cancellation and close wait for admitted callbacks to settle.
|
|
43
43
|
|
|
44
|
-
Active steering returns `UNSUPPORTED_DELIVERY`; the coordinator applies its documented interrupt-and-replace behavior. Interruption cancels the active native run and waits for terminal completion. Failure to confirm native stop returns `CANCELLATION_FAILED`, fails the active turn, and prevents further tasks in that session. Tool admission remains closed; close must still dispose the native agent and drain admitted callbacks. Prompt-free recovery returns `RECOVERY_UNSUPPORTED`. A turn succeeds only with a successful terminal result and returns its final text. Responses are limited to 1 MiB.
|
|
44
|
+
Active steering returns `UNSUPPORTED_DELIVERY`; the coordinator applies its documented interrupt-and-replace behavior. Interruption cancels the active native run and waits for terminal completion. Failure to confirm native stop returns `CANCELLATION_FAILED`, fails the active turn, and prevents further tasks in that session. Tool admission remains closed; close must still dispose the native agent and drain admitted callbacks. Prompt-free recovery returns `RECOVERY_UNSUPPORTED`. A turn succeeds only with a successful terminal result and returns its final text. [Live session events](events.md#effective-route-capabilities) are separate bounded previews: the `cursor-sdk` route declares assistant support `"available"` with delivery `["snapshot"]` for final responses, reasoning support `"unverified"` with delivery `[]`, and tool snapshots where supported. Unverified reasoning may or may not arrive and callers must not depend on it. Interactive approvals remain unavailable. Responses are limited to 1 MiB.
|
|
45
45
|
|
|
46
46
|
The SDK's headless permission decisions remain native. This SDK version exposes no supported interactive approval or input channel to the adapter. Its `request` message records a backend request identifier and is not an approval request. Native run failures produce a sanitized execution error; the adapter does not invent an `INPUT_REQUIRED` mapping from undocumented error codes. Close disposes the native agent and drains custom tools. `check cursor` verifies credential/model discovery, local agent creation, and disposal without submitting a prompt; it does not prove quota or that a later shell command will be permitted.
|
|
47
47
|
|
|
@@ -65,4 +65,4 @@ For subscription access, either explicit `sandboxMode` value fails with `UNSUPPO
|
|
|
65
65
|
|
|
66
66
|
Declared tools use a uniquely named private MCP server supplied in `session/new`. The adapter verifies that the native client initializes the server before admitting prompts; a skipped or failed native MCP connection is a startup error. MCP request bodies are limited to 16 MiB and headers to 16 KiB. Text and image results retain their MCP content types and shared tool-result limits. Native approval rules still apply. Active `session/request_permission` requests expose only the offered allow-once and reject-once choices through the shared approval flow with `harness: "cursor"`; persistent allow-always/reject-always choices are not exposed. Original native option IDs are retained. Unsupported or malformed interactive requests, including questions and plan approval, fail with `INPUT_REQUIRED` and cancel the native turn. Startup-time interactive requests are unsupported. Withdrawal, terminal completion, cancellation, and close retire pending requests; late answers never grant permission.
|
|
67
67
|
|
|
68
|
-
A terminal ACP `end_turn` returns the accumulated assistant text. `cancelled` is interruption; refusal or exhausted-limit terminal reasons and RPC/transport failures reject with a sanitized execution error. This CLI release can render some backend failures as ordinary assistant text followed by `end_turn`, without a separate failure signal. Such text is returned as native output; a completed Subharness task on this route means the native turn ended, not that every backend operation succeeded. The adapter does not guess error status from prose. Raw transport diagnostics remain private. This capability limit is specific to the subscription ACP route; the API-key SDK route retains its typed native results.
|
|
68
|
+
A terminal ACP `end_turn` returns the accumulated assistant text. [Live session events](events.md#effective-route-capabilities) can also capture assistant chunks; vendor reasoning and tool update emission on this route remain unverified. Only currently subscribed observers receive these events. `cancelled` is interruption; refusal or exhausted-limit terminal reasons and RPC/transport failures reject with a sanitized execution error. This CLI release can render some backend failures as ordinary assistant text followed by `end_turn`, without a separate failure signal. Such text is returned as native output; a completed Subharness task on this route means the native turn ended, not that every backend operation succeeded. The adapter does not guess error status from prose. Raw transport diagnostics remain private. This capability limit is specific to the subscription ACP route; the API-key SDK route retains its typed native results.
|
package/sdk/diagnostics.md
CHANGED
|
@@ -2,12 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
Error records retain their existing `{ code, message }` shape. Messages describe the operation that failed and include safe, observed context that helps callers identify the cause. The diagnostics described here never include raw native stderr, SDK exception text, HTTP response bodies, RPC error messages or data, prompts, credential values, or configuration contents. Unknown native values receive a fixed generic explanation rather than being echoed. Paths included in these diagnostic cases are quoted with C0, C1, DEL, and Unicode line separators escaped.
|
|
4
4
|
|
|
5
|
+
## Context-exhaustion error code
|
|
6
|
+
|
|
7
|
+
This harness-neutral terminal-classification code lets callers handle context exhaustion without parsing message text. This is not a complete index of public error codes.
|
|
8
|
+
|
|
9
|
+
| Code | Meaning |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `CONTEXT_WINDOW_EXCEEDED` | The native harness reported that the turn exhausted its context window. The Codex adapter currently produces this code. |
|
|
12
|
+
|
|
5
13
|
## Claude startup and turn failures
|
|
6
14
|
|
|
7
15
|
Claude startup distinguishes native account inspection, model catalog retrieval, and model settings validation. An unexpected exception from account inspection or model catalog retrieval is `HARNESS_FAILED`, with the failed phase identified. Unexpected exceptions after successful access verification are also harness failures identified by the current startup phase. They do not establish unavailable access and do not permit connection or harness fallback. A completed account inspection that demonstrates unavailable or incompatible access retains `ACCESS_UNAVAILABLE` and its existing eligible fallback behavior. Existing explicit configuration, settings capability, model, and effort errors retain their codes and guidance, including `--model` guidance for an unverifiable native default. Cleanup and no-prompt-before-verification rules remain unchanged.
|
|
8
16
|
|
|
9
17
|
Claude terminal result failures retain `HARNESS_ERROR`. Recognized result subtypes distinguish a native turn limit, a native budget limit, exhausted structured-output retries, and an error during execution. Messages describe the reported category without claiming an unobserved provider cause, quoting native error text, or promising that Subharness exposes configuration for every native limit. Unknown subtypes and unsuccessful results without a recognized category receive a fixed generic turn-failure message. A reported execution failure is never automatically retried or replayed.
|
|
10
18
|
|
|
19
|
+
## Codex turn failures
|
|
20
|
+
|
|
21
|
+
When Codex completes a turn with status `failed`, the adapter classifies the terminal turn's `error.codexErrorInfo` against the installed App Server schema categories below. The terminal record is authoritative. An earlier `error` notification with `willRetry: true` does not fail the turn or determine its classification.
|
|
22
|
+
|
|
23
|
+
| Codex category | Error code | Fixed message |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `contextWindowExceeded` | `CONTEXT_WINDOW_EXCEEDED` | Codex reported context-window exhaustion. The turn was not replayed. Cancel the failed task to release queued work, then continue in a new session or submit a smaller task. |
|
|
26
|
+
| `sessionBudgetExceeded` | `HARNESS_FAILED` | Codex reported that the session budget was exhausted. The turn was not replayed. Cancel the failed task to release queued work, then continue in a new session. |
|
|
27
|
+
| `usageLimitExceeded` | `HARNESS_FAILED` | Codex reported that the account usage limit was exhausted. The turn was not replayed. Cancel the failed task to release queued work, then try again after usage is available. |
|
|
28
|
+
| `rateLimitExceeded` | `HARNESS_FAILED` | Codex reported a provider rate limit. The turn was not replayed. Cancel the failed task to release queued work, then try again after the rate limit resets. |
|
|
29
|
+
| `serverOverloaded` | `HARNESS_FAILED` | Codex reported that the provider was overloaded. The turn was not replayed. Cancel the failed task to release queued work, then try again later. |
|
|
30
|
+
| `cyberPolicy` | `HARNESS_FAILED` | Codex reported that its cyber-safety policy blocked the turn. The turn was not replayed. Cancel the failed task to release queued work, then revise the task before creating new work. |
|
|
31
|
+
| `misalignmentPolicyViolation` | `HARNESS_FAILED` | Codex reported that its safety policy blocked the turn for misalignment. The turn was not replayed. Cancel the failed task to release queued work, then revise the task before creating new work. |
|
|
32
|
+
| `httpConnectionFailed` | `HARNESS_FAILED` | Codex reported that its provider HTTP connection failed. The turn was not replayed. Cancel the failed task to release queued work, then verify connectivity before creating new work. |
|
|
33
|
+
| `responseStreamConnectionFailed` | `HARNESS_FAILED` | Codex reported that its provider response-stream connection failed. The turn was not replayed. Cancel the failed task to release queued work, then verify connectivity before creating new work. |
|
|
34
|
+
| `internalServerError` | `HARNESS_FAILED` | Codex reported an internal provider error. The turn was not replayed. Cancel the failed task to release queued work, then try again later. |
|
|
35
|
+
| `unauthorized` | `HARNESS_FAILED` | Codex reported that the provider rejected authorization. The turn was not replayed. Cancel the failed task to release queued work, then verify Codex authentication before creating new work. |
|
|
36
|
+
| `badRequest` | `HARNESS_FAILED` | Codex reported that the provider rejected the request as invalid. The turn was not replayed. Cancel the failed task to release queued work, then verify the model and provider configuration before creating new work. |
|
|
37
|
+
| `threadRollbackFailed` | `HARNESS_FAILED` | Codex reported that it could not roll back the native thread after a failure. The turn was not replayed. Cancel the failed task to release queued work, then continue in a new session. |
|
|
38
|
+
| `sandboxError` | `HARNESS_FAILED` | Codex reported a native sandbox failure. The turn was not replayed. Cancel the failed task to release queued work, then verify the sandbox configuration and permissions before creating new work. |
|
|
39
|
+
| `responseStreamDisconnected` | `HARNESS_FAILED` | Codex reported that the provider response stream disconnected. The turn was not replayed. Cancel the failed task to release queued work, then verify connectivity before creating new work. |
|
|
40
|
+
| `responseTooManyFailedAttempts` | `HARNESS_FAILED` | Codex reported that the provider response failed after repeated attempts. The turn was not replayed. Cancel the failed task to release queued work, then try again later. |
|
|
41
|
+
| `activeTurnNotSteerable` | `HARNESS_FAILED` | Codex reported that the active native turn could not be steered. The turn was not replayed. Cancel the failed task to release queued work, then submit the correction as new work. |
|
|
42
|
+
| `other` | `HARNESS_FAILED` | Codex reported another classified native turn failure. The turn was not replayed. Cancel the failed task to release queued work, then inspect the failed task before creating new work. |
|
|
43
|
+
|
|
44
|
+
The object-shaped connection and stream categories require `httpStatusCode` to be `null` or an unsigned 16-bit integer. The steering category requires `turnKind` to be `review` or `compact`. Additive fields do not change a recognized category and are never exposed. Missing, unknown, or malformed categories use `HARNESS_FAILED` with `Codex did not complete the turn successfully.` Native `message`, `additionalDetails`, HTTP status, steering kind, misalignment details, and all other native text or metadata are never included. `INTERRUPTED` and `PROTOCOL_ERROR` classification is unchanged.
|
|
45
|
+
|
|
11
46
|
## Native protocol and process failures
|
|
12
47
|
|
|
13
48
|
Codex and fx RPC rejection messages identify the requested native method and include the native error code only when it is a safe integer. Known JSON-RPC codes use fixed categories: `-32700` is a parse error, `-32600` an invalid request, `-32601` an unavailable method, `-32602` invalid parameters, and `-32603` an internal error. Other safe integer codes remain numeric without an invented interpretation. Missing or malformed codes are not printed. A generic rejection does not claim that authentication or native configuration caused the error. Existing steering and session-option capability classifications retain their Subharness error codes and useful recovery guidance. Freeform native messages and error data are never forwarded.
|
|
@@ -20,6 +55,39 @@ Worker failures identify the pending operation when available, such as startup,
|
|
|
20
55
|
|
|
21
56
|
Coordinator communication failures retain `COORDINATOR_UNAVAILABLE`. A non-success HTTP response identifies its numeric status and a recognized requested operation, when available. A successful response with no body is distinguished from HTTP rejection. Invalid JSON records, an incomplete final record, and an interrupted response stream have distinct fixed explanations. Transport failures retain the statement that the task was not automatically retried. These diagnostics do not expose endpoint tokens, raw request or response contents, or arbitrary operation names. They do not infer whether a task completed from an HTTP or transport failure and do not automatically replay it.
|
|
22
57
|
|
|
58
|
+
## Live events and extensions
|
|
59
|
+
|
|
60
|
+
Live event subscriptions and capability reads use these safe error codes:
|
|
61
|
+
|
|
62
|
+
| Code | Meaning |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `EVENT_BACKPRESSURE` | The subscriber exceeded its 128-event or 1 MiB pending-delivery bound. Its stream rejects; execution and other subscribers are unaffected. |
|
|
65
|
+
| `OBSERVATION_CLOSED` | An already aborted signal rejects `events.open` without registration; abort after registration rejects a pending read. Failed embedded runner close also rejects pending subscription reads with this code. It ends observation only. |
|
|
66
|
+
| `COORDINATOR_UNAVAILABLE` | Connected disconnect or failed coordinator close rejects pending subscription reads with this code. |
|
|
67
|
+
| `COORDINATOR_INCOMPATIBLE` | The event operation requires `session-events-v1`, which the coordinator does not advertise. Supported execution and inspection remain usable. |
|
|
68
|
+
| `UNKNOWN_SESSION` | Subscription or capability lookup names an unknown session. `capabilities(sessionId)` resolves `undefined` only for a known session before harness selection. |
|
|
69
|
+
| `UNKNOWN_TASK` | A task-scoped subscription names an unknown task. |
|
|
70
|
+
|
|
71
|
+
`session.error` events with `category: "capture"` report live-event processing failures, not execution failures. Their `error.code` is `CAPTURE_FAILED` for invalid or undeliverable observation data detected by an adapter or by the owner's worker lane, or a more specific existing code where a route documents one. A capture error never changes the task's execution outcome.
|
|
72
|
+
|
|
73
|
+
If closing an execution owner fails, every open subscription of that owner ends, regardless of scope. Pending reads reject with `OBSERVATION_CLOSED` for embedded runner subscriptions and `COORDINATOR_UNAVAILABLE` for connected subscriptions.
|
|
74
|
+
|
|
75
|
+
Event-processing failures detected by the owner itself, such as dropping an invalid adapter draft, use `session.error` with `category: "capture"` and `origin: "owner"`. Owner-raised session errors may have category `"execution"` or `"capture"`; adapter-raised session errors have category `"capture"` only. 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 capture error per turn that overflows. Capture errors do not change execution outcomes.
|
|
76
|
+
|
|
77
|
+
The Codex, Claude Code, fx, Copilot and Cursor SDK adapters also track at most 1,024 distinct item identities per turn. Later new identities are not forwarded after that bound is reached, and the adapter raises one capture error for the turn. Previously admitted identities may still complete. This bound does not change execution outcomes.
|
|
78
|
+
|
|
79
|
+
Codex, fx, Copilot and Cursor SDK emit at most one adapter capture error per turn for malformed optional live-event data. Codex, fx and Cursor SDK use `CAPTURE_FAILED`; Copilot retains `PROTOCOL_ERROR`. Cursor SDK capture failures are distinct from `NATIVE_ERROR` execution failures.
|
|
80
|
+
|
|
81
|
+
The dashboard maps missing `session-events-v1` support to `COORDINATOR_OUTDATED` with coordinator restart guidance in place of live steps; core task content remains visible. An absent or false `taskDetails` marker on the dashboard snapshot keeps the dashboard running and displays `COORDINATOR_OUTDATED` with restart guidance instead of task details when the task screen opens. Missing `history` or `grouping` markers end the dashboard with `COORDINATOR_OUTDATED` and exit `1`. These presentation rules do not change the SDK event error code.
|
|
82
|
+
|
|
83
|
+
The CLI displays `EXTENSION_*` codes with their safe messages only through `subharness extensions list`; they also remain available through the coordinator's existing safe diagnostics. The dashboard does not display extension diagnostics. [User extensions](extensions.md#bounds-shutdown-and-diagnostics) defines `EXTENSION_LOAD_FAILED`, `EXTENSION_INCOMPATIBLE`, `EXTENSION_HANDLER_FAILED`, `EXTENSION_TIMEOUT`, `EXTENSION_BACKPRESSURE`, `EXTENSION_DISPOSE_FAILED`, `EXTENSION_EXITED` and `EXTENSION_LOG_UNAVAILABLE`. An unexpected extension-process exit uses `EXTENSION_EXITED` and disables that instance under the same failure and recovery rules as other extension failures. `EXTENSION_LOG_UNAVAILABLE` is informational: a log open, write or close failure discards unwritable output and never stops the instance. These diagnostics identify the qualified reference and canonical checkout for repository instances without exposing raw exception messages, stacks, event content or child output. They do not change the agent's task outcome.
|
|
84
|
+
|
|
85
|
+
Extension discovery and consent-read failures during session admission are fail-open. The session is admitted without extension delivery, and the problem is retained as a separate admission diagnostic for `subharness extensions list`; it is not attributed to an instance when no identity is known. The coordinator retains at most the 16 most recent admission diagnostics. Each instance separately retains at most its eight most recent diagnostics, including whether each one disabled the instance and when it occurred.
|
|
86
|
+
|
|
87
|
+
Extension stdout/stderr is kept only in its owner-private bounded log: `<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. The filenames contain no colons. Logs are located using the selected coordinator's [state-directory selection rule](execution.md#ownership-and-transport-boundaries). A log is compacted after it exceeds 1.5 MiB and is trimmed to the most recent 1 MiB. List shows the actual instance log path; log contents are never included in execution output, safe diagnostics or the dashboard. If enable saves consent but cannot notify a running coordinator, it warns that the failure state clears on coordinator restart and exits `0`; it does not roll back consent or claim successful notification.
|
|
88
|
+
|
|
89
|
+
`subharness extensions list` and the coordinator's extension-status operation each report at most 256 instances and report the exact number of additional instances omitted. Every extensions command rejects an existing consent file that is not owner-only with exit `1` and guidance to run `chmod 600 ~/.subharness/extensions.json`; no command repairs permissions. The [extension-command exit codes](cli/extensions.md#output-and-failures) govern these commands and take precedence over general CLI configuration exit codes.
|
|
90
|
+
|
|
23
91
|
## Access configuration and OIDC
|
|
24
92
|
|
|
25
93
|
Personal-access schema errors retain `INVALID_CONFIG` and identify their structural location: the root object, `access`, a recognized harness entry such as `access.claudeCode`, or a zero-based connection location such as `access.claudeCode[0]`. A known invalid connection property may extend that location, for example `access.claudeCode[0].env`. Unknown property names or harness names are not echoed because arbitrary keys can contain sensitive values. An unknown connection property identifies its containing connection. Errors raised while loading a file also identify its absolute, safely quoted main-checkout path, or execution-project path outside Git. Invalid JSON and file-read errors identify the same safely quoted path. Validation happens before any connection is attempted; it does not fabricate attempted-access context.
|
package/sdk/distribution.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Package Distribution
|
|
2
2
|
|
|
3
|
-
The npm package name is `subharness`. One package provides the TypeScript SDK and the `subharness` executable and its `agent` compatibility alias. Agent definitions import public helpers from `subharness`. The website workspace remains private and is not part of the npm package.
|
|
3
|
+
The npm package name is `subharness`. One package provides the TypeScript SDK and the `subharness` executable and its `agent` compatibility alias. Agent definitions import public helpers from `subharness`. Every event, subscription and capability type is exported from that root and re-exported as a type from `subharness/extensions`; extension authoring types use the `subharness/extensions` subpath. Compiled extension modules use no Subharness runtime import. The website workspace remains private and is not part of the npm package.
|
|
4
4
|
|
|
5
5
|
The source repository is [vercel-labs/subharness](https://github.com/vercel-labs/subharness). Its GitHub visibility is internal, so cloning requires repository access. The product name is subharness. The primary CLI command is `subharness`; `agent` remains an identical compatibility alias. Agent discovery and personal configuration live under `.subharness/`.
|
|
6
6
|
|
|
@@ -10,7 +10,9 @@ Node.js 22.18 or newer is required. The SDK is ESM and includes TypeScript decla
|
|
|
10
10
|
|
|
11
11
|
The public npm package is `subharness`, with an initial release version of `0.0.1`. Install the CLI globally with `npm install --global subharness`, or run it without a global installation using `npx subharness`. Registry installation does not require access to the internal source repository. The root package is publishable; the documentation workspace remains private.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Application backends install `subharness` with `npm install subharness` and import the [execution SDK](execution.md). Native executables remain external dependencies; the package does not require a globally installed Subharness CLI for SDK execution.
|
|
14
|
+
|
|
15
|
+
For project-local CLI use, install `subharness` with `npm install --save-dev subharness` and invoke its CLI with `npx subharness`. This also makes SDK imports resolve from repository agent definitions. A global CLI installation alone does not make SDK imports resolve from project-local definitions. Global definitions need an SDK dependency reachable from their own directory under normal Node package resolution.
|
|
14
16
|
|
|
15
17
|
Source development uses pnpm 11.20.0, pinned in the root `packageManager` field. `pnpm-workspace.yaml` includes the root SDK and `apps/docs`, with one committed `pnpm-lock.yaml`. Run `pnpm install --frozen-lockfile` from the repository root, then `pnpm run build`. Run the local CLI with `node dist/cli/main.js`; this requires no global link. Direct harness targets do not need a consumer SDK dependency. For use in another project, build a tarball with `pnpm pack` and install that tarball in the consumer so its agent definitions can resolve SDK imports.
|
|
16
18
|
|
|
@@ -18,11 +20,21 @@ Repository scripts use pnpm, including workspace command forwarding and content-
|
|
|
18
20
|
|
|
19
21
|
A tarball built from a source checkout can differ from the registry release with the same version. The current package version is `0.0.3`, producing `subharness-0.0.3.tgz`. Install a local tarball with `npm install --save-dev /absolute/path/to/subharness-0.0.3.tgz`. Run the project's local executable with `npx subharness`.
|
|
20
22
|
|
|
23
|
+
## Extension directories and authoring types
|
|
24
|
+
|
|
25
|
+
The core package contains live event normalization/transport, manifest discovery, per-user consent in `~/.subharness/extensions.json` and coordinator supervision of extension children. `subharness/extensions` supplies TypeScript authoring declarations. User modules default-export a plain definition object and import its type with `import type`; their compiled ESM does not require Subharness as a runtime dependency. Embedded SDK applications consume events directly through the root package's event API.
|
|
26
|
+
|
|
27
|
+
An extension distribution contains `extension.json`, its compiled ESM entry and any required packaged dependencies. It is installed as a self-contained directory in the user's global or repository extension location. The coordinator starts a separate supervised child for an enabled installation when its first matching session is admitted; that child loads the entry. Listing and discovery inspect only static manifests, never import code, install packages or build TypeScript. User extension code and dependencies are not part of the core package or bundle.
|
|
28
|
+
|
|
29
|
+
The CLI task screen's renderer belongs to the core package and consumes live events directly. It does not load extension code. See [User extensions](extensions.md) for the type-only definition API and self-contained logger, and [extension commands](cli/extensions.md) for directory placement and explicit enablement.
|
|
30
|
+
|
|
31
|
+
The existing native SDK dependencies and native executable requirements are unchanged. Core release publishing follows the procedure below and does not publish user extension directories.
|
|
32
|
+
|
|
21
33
|
## Package contents and release checks
|
|
22
34
|
|
|
23
|
-
Packages built from this source contain the built JavaScript, declaration files and source maps under `dist/`, SDK Markdown documentation under `sdk/`, the README, the Apache License 2.0, and package metadata. Source maps embed the original TypeScript so debuggers can display it without a separate source checkout. Website code, development agents, skills, source assets, tests, `.context`,
|
|
35
|
+
Packages built from this source contain the built JavaScript, declaration files and source maps under `dist/`, SDK Markdown documentation under `sdk/`, the README, the Apache License 2.0, and package metadata. Package metadata exports `.` for the root SDK and `./extensions` for the `subharness/extensions` authoring declarations. The subpath supplies `ExtensionDefinition`, `ExtensionContext`, `ExtensionInstance` and `ExtensionManifest`, and re-exports every event, subscription and capability type from `subharness` as a type. Compiled extension code requires no runtime import from that subpath. Source maps embed the original TypeScript so debuggers can display it without a separate source checkout. Website code, development agents, skills, source assets, tests, `.context`, access configuration, extension consent files and logs, and environment files are excluded.
|
|
24
36
|
|
|
25
|
-
Packing builds the SDK from the current source before assembling its files. The CLI's `--version` output matches the package version. A clean consumer must be able to import the SDK and discover a TypeScript agent definition using the installed executable without access to the source checkout or a paid model call. `pnpm run check:package` packs with pnpm and verifies this clean-consumer behavior and the packaged file boundary without running a coding model. It requires network access to install dependencies from the public npm registry and disables install lifecycle scripts in the temporary consumer.
|
|
37
|
+
Packing builds the SDK from the current source before assembling its files. The CLI's `--version` output matches the package version. A clean consumer must be able to import the execution SDK, resolve the packaged `./extensions` subpath, type-check a definition and `SessionEvent` import from `subharness/extensions`, compile it without a Subharness runtime import, run an inline definition against a controlled native protocol fixture, and discover a TypeScript agent definition using the installed executable without access to the source checkout or a paid model call. `pnpm run check:package` packs with pnpm and verifies this clean-consumer behavior and the packaged file boundary without running a coding model. It requires network access to install dependencies from the public npm registry and disables install lifecycle scripts in the temporary consumer.
|
|
26
38
|
|
|
27
39
|
The committed lockfile pins dependency content with integrity hashes and does not embed company registry URLs. pnpm resolves packages through the configured registry, which defaults to the public npm registry. Installation and package verification do not change the developer's global npm registry configuration. Registry authentication remains with npm.
|
|
28
40
|
|
package/sdk/events.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Live session events
|
|
2
|
+
|
|
3
|
+
The [execution SDK](execution.md) exposes normalized live events through `runner.events` and `client.events`. Applications can build agent interfaces and decide whether and where to persist events. Subharness forwards events to current subscribers without retaining event or chat content for later observation. Existing task metadata, original requests and complete responses keep their separate [execution contracts](execution.md).
|
|
4
|
+
|
|
5
|
+
Events include session, task and turn lifecycle, assistant text, provider-exposed reasoning, tool calls and results, approvals, and safe errors. Content is bounded and redacted, and coverage depends on the selected native route. The CLI task screen consumes this public event API directly. [User extensions](extensions.md) receive live events through coordinator-supervised processes. Observing never controls execution or acknowledges a managed child's result.
|
|
6
|
+
|
|
7
|
+
## Identity and ordering
|
|
8
|
+
|
|
9
|
+
A session is one native conversation. A task is an admitted request and its managed continuations. A turn is one adapter invocation, including its native tool loop. An item is an assistant content block, exposed reasoning block, or tool call. A task can contain several turns. In-flight native steering stays within its turn; steering a waiting task starts another turn in that task. Interrupt-and-replace creates another task.
|
|
10
|
+
|
|
11
|
+
The execution owner assigns opaque event, turn and item identifiers. `ownerId` identifies the embedded runner or coordinator instance. `sessionId`, `taskId` and `responseId` reuse execution identities. `turnOrdinal` increases within a task; `itemOrdinal` increases within a turn. Both start at one. Item revisions increase on published mutations. An item is keyed by owner, session, task, turn and item ID. Native IDs are optional correlation data, never authorization capabilities. Native child-agent IDs do not create managed `parentTaskId` lineage.
|
|
12
|
+
|
|
13
|
+
`sequence` is a positive, increasing safe integer assigned across an owner's accepted events in receive order. Each subscription delivers events in increasing `sequence` order. `eventId` identifies one event. Filtering and intervals without a subscriber can skip sequence numbers; consecutive numbers are not promised. `observedAt` is Unix milliseconds for display, not an ordering key. Neither timestamps nor identifiers let a subscriber retrieve prior events.
|
|
14
|
+
|
|
15
|
+
## Event types
|
|
16
|
+
|
|
17
|
+
Every event, subscription and capability type documented on this page is exported from `subharness` and re-exported as a type from `subharness/extensions`. `HarnessKind`, `TaskState`, `ApprovalRequest` and `ErrorInfo` are the existing SDK types.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
export type NativeRoute =
|
|
21
|
+
| "codex-app-server" | "claude-agent-sdk" | "fx-acp"
|
|
22
|
+
| "opencode-http" | "copilot-sdk" | "cursor-acp" | "cursor-sdk";
|
|
23
|
+
|
|
24
|
+
export interface NativeCorrelation {
|
|
25
|
+
readonly sessionId?: string;
|
|
26
|
+
readonly turnId?: string;
|
|
27
|
+
readonly messageId?: string;
|
|
28
|
+
readonly itemId?: string;
|
|
29
|
+
readonly toolCallId?: string;
|
|
30
|
+
readonly agentId?: string;
|
|
31
|
+
readonly parentToolCallId?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface EventBase {
|
|
34
|
+
readonly version: 1;
|
|
35
|
+
readonly eventId: string;
|
|
36
|
+
readonly ownerId: string;
|
|
37
|
+
readonly sequence: number;
|
|
38
|
+
readonly observedAt: number;
|
|
39
|
+
readonly sessionId: string;
|
|
40
|
+
readonly harness?: HarnessKind; // Absent until selection succeeds.
|
|
41
|
+
readonly route?: NativeRoute;
|
|
42
|
+
readonly origin: "owner" | "adapter"; // Owner is the coordinator or embedded runner that admitted the session.
|
|
43
|
+
readonly native?: NativeCorrelation;
|
|
44
|
+
}
|
|
45
|
+
export interface TaskEventBase extends EventBase {
|
|
46
|
+
readonly taskId: string;
|
|
47
|
+
readonly parentTaskId?: string; // Managed lineage only.
|
|
48
|
+
}
|
|
49
|
+
export interface TurnEventBase extends TaskEventBase {
|
|
50
|
+
readonly turnId: string;
|
|
51
|
+
readonly turnOrdinal: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Content is display data, not a tool invocation or a replacement tool result.
|
|
55
|
+
export interface EventContent {
|
|
56
|
+
readonly format: "text" | "json";
|
|
57
|
+
readonly text: string;
|
|
58
|
+
readonly status: "complete" | "truncated" | "redacted" | "unavailable";
|
|
59
|
+
readonly originalBytes?: number; // Only when actually known.
|
|
60
|
+
}
|
|
61
|
+
export interface ItemBase {
|
|
62
|
+
readonly itemId: string;
|
|
63
|
+
readonly itemOrdinal: number;
|
|
64
|
+
readonly revision: number; // Starts at 1; increases for published item mutations.
|
|
65
|
+
readonly identity: "native" | "synthetic";
|
|
66
|
+
readonly native?: NativeCorrelation;
|
|
67
|
+
}
|
|
68
|
+
export interface AssistantItem extends ItemBase {
|
|
69
|
+
readonly kind: "assistant";
|
|
70
|
+
readonly state: "streaming" | "completed" | "interrupted" | "incomplete";
|
|
71
|
+
readonly phase: "progress" | "final" | "unspecified";
|
|
72
|
+
readonly body: EventContent;
|
|
73
|
+
}
|
|
74
|
+
export interface ReasoningItem extends ItemBase {
|
|
75
|
+
readonly kind: "reasoning";
|
|
76
|
+
readonly state: "streaming" | "completed" | "interrupted" | "incomplete";
|
|
77
|
+
readonly visibility: "summary" | "text" | "unavailable";
|
|
78
|
+
readonly body: EventContent;
|
|
79
|
+
}
|
|
80
|
+
export interface ToolItem extends ItemBase {
|
|
81
|
+
readonly kind: "tool";
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly state: "pending" | "running" | "succeeded" | "failed" | "cancelled" | "unknown";
|
|
84
|
+
readonly input: EventContent;
|
|
85
|
+
readonly output: EventContent;
|
|
86
|
+
readonly exitCode?: number;
|
|
87
|
+
readonly durationMs?: number;
|
|
88
|
+
}
|
|
89
|
+
export type SessionItem = AssistantItem | ReasoningItem | ToolItem;
|
|
90
|
+
|
|
91
|
+
export interface SessionStateEvent extends EventBase {
|
|
92
|
+
readonly type: "session.state";
|
|
93
|
+
readonly state: "open" | "closing" | "closed";
|
|
94
|
+
}
|
|
95
|
+
export interface SessionCapabilitiesEvent extends EventBase {
|
|
96
|
+
readonly type: "session.capabilities";
|
|
97
|
+
readonly capabilities: SessionEventCapabilities;
|
|
98
|
+
}
|
|
99
|
+
export interface TaskStateEvent extends TaskEventBase {
|
|
100
|
+
readonly type: "task.state";
|
|
101
|
+
readonly state: TaskState;
|
|
102
|
+
readonly stopUnconfirmed: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface TurnStartedEvent extends TurnEventBase {
|
|
105
|
+
readonly type: "turn.started";
|
|
106
|
+
readonly cause: "prompt" | "child-results" | "steer-continuation" | "recovery";
|
|
107
|
+
}
|
|
108
|
+
export interface TurnCompletedEvent extends TurnEventBase {
|
|
109
|
+
readonly type: "turn.completed";
|
|
110
|
+
readonly outcome: "completed" | "failed" | "cancelled" | "interrupted";
|
|
111
|
+
readonly responseId?: string; // Existing rsp_ identity, when a response exists.
|
|
112
|
+
readonly finalItemId?: string; // Only if reliably mapped to that response.
|
|
113
|
+
}
|
|
114
|
+
export interface ItemStartedEvent extends TurnEventBase {
|
|
115
|
+
readonly type: "item.started";
|
|
116
|
+
readonly item: SessionItem;
|
|
117
|
+
}
|
|
118
|
+
export interface ItemUpdatedEvent extends TurnEventBase {
|
|
119
|
+
readonly type: "item.updated";
|
|
120
|
+
readonly item: SessionItem; // Full bounded replacement, not a patch.
|
|
121
|
+
}
|
|
122
|
+
export type ItemDeltaHeader = {
|
|
123
|
+
readonly itemId: string;
|
|
124
|
+
readonly itemOrdinal: number;
|
|
125
|
+
readonly identity: "native" | "synthetic";
|
|
126
|
+
} & (
|
|
127
|
+
| { readonly kind: "assistant"; readonly state: AssistantItem["state"] }
|
|
128
|
+
| { readonly kind: "reasoning"; readonly state: ReasoningItem["state"] }
|
|
129
|
+
| { readonly kind: "tool"; readonly state: ToolItem["state"]; readonly name: string }
|
|
130
|
+
);
|
|
131
|
+
export interface ItemDeltaEvent extends TurnEventBase {
|
|
132
|
+
readonly type: "item.delta";
|
|
133
|
+
readonly item: ItemDeltaHeader;
|
|
134
|
+
readonly baseRevision: number;
|
|
135
|
+
readonly revision: number;
|
|
136
|
+
readonly field: "body" | "output"; // Only fields whose EventContent.format is "text".
|
|
137
|
+
readonly text: string; // Append only this newly delivered text, never JSON-patch.
|
|
138
|
+
}
|
|
139
|
+
export interface ItemCompletedEvent extends TurnEventBase {
|
|
140
|
+
readonly type: "item.completed";
|
|
141
|
+
readonly item: SessionItem; // Bounded replacement; chunk-only mid-item turn-boundary views remain incomplete.
|
|
142
|
+
readonly completion: "native" | "turn-boundary" | "interrupted";
|
|
143
|
+
}
|
|
144
|
+
export interface ApprovalRequestedEvent extends TurnEventBase {
|
|
145
|
+
readonly type: "approval.requested";
|
|
146
|
+
readonly request: ApprovalRequest; // Same registry ID/actions, bounded context.
|
|
147
|
+
readonly itemId?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface ApprovalResolvedEvent extends TurnEventBase {
|
|
150
|
+
readonly type: "approval.resolved";
|
|
151
|
+
readonly requestId: string;
|
|
152
|
+
readonly itemId?: string;
|
|
153
|
+
readonly resolution: "answered" | "withdrawn";
|
|
154
|
+
readonly actionId?: string; // Answer submission, not operation success.
|
|
155
|
+
}
|
|
156
|
+
export interface SessionErrorEvent extends EventBase {
|
|
157
|
+
readonly type: "session.error";
|
|
158
|
+
readonly taskId?: string;
|
|
159
|
+
readonly turnId?: string;
|
|
160
|
+
readonly category: "execution" | "capture";
|
|
161
|
+
readonly error: ErrorInfo; // Existing safe diagnostic policy.
|
|
162
|
+
readonly fatal: boolean; // Fatal to the indicated category, not an inference.
|
|
163
|
+
}
|
|
164
|
+
export type SessionEvent = SessionStateEvent | SessionCapabilitiesEvent
|
|
165
|
+
| TaskStateEvent | TurnStartedEvent | TurnCompletedEvent
|
|
166
|
+
| ItemStartedEvent | ItemUpdatedEvent | ItemDeltaEvent | ItemCompletedEvent
|
|
167
|
+
| ApprovalRequestedEvent | ApprovalResolvedEvent | SessionErrorEvent;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`item.started`, `item.updated` and `item.completed` are bounded item snapshots. They replace an observed snapshot rather than being appended as additional text. Adapters begin normalizing when a matching subscriber registers and keep no extra content for later observation. Content produced before registration appears only if the native route itself later supplies it in a snapshot, such as Codex `item/completed` or a Claude assistant message. Subscribers display that native snapshot as received, with the existing bounds and redaction; adapters do not reconstruct earlier content. `item.delta` is self-describing: its `item` header carries item ID, ordinal, native/synthetic identity, kind and state, plus a tool name for tools. It does not require an earlier `item.started` to make the new text displayable. Tool names are bounded display labels; unavailable native names must be identified as unknown rather than guessed.
|
|
171
|
+
|
|
172
|
+
A subscriber joining mid-item whose first event is a delta starts with the text delivered from that point. It does not invent an empty earlier snapshot or treat the visible suffix as the whole item. A later native snapshot replaces that partial view and includes earlier content only when the native route supplies it. On chunk-only routes (`fx-acp` and `cursor-acp`), a mid-item subscriber's turn-boundary snapshot covers only content normalized since registration and has item state `"incomplete"`. `baseRevision` and `revision` relate successive updates; the first received delta can have a base the subscriber never saw. Subsequent deltas append in delivery order for that item, and duplicate/older revisions are ignored. Deltas apply only to body or output fields whose `EventContent.format` is `"text"`. Fields with `format: "json"` change only through full snapshots; no JSON-format field receives a delta. Native chunk boundaries are not a public guarantee.
|
|
173
|
+
|
|
174
|
+
`origin` identifies the component that raises the normalized event. `owner` means the coordinator or embedded runner that admitted the session; approvals remain owner events even when a native adapter initiates the permission flow. Adapters raise `session.error` only with `category: "capture"` and `origin: "adapter"`. Execution failures use `category: "execution"` and are reported by the owner with `origin: "owner"`, including native transport failures surfaced by an adapter. Event-processing failures detected by the owner itself, such as dropping an invalid adapter draft, use `session.error` with `category: "capture"` and `origin: "owner"`.
|
|
175
|
+
|
|
176
|
+
| Event type | `origin` |
|
|
177
|
+
| --- | --- |
|
|
178
|
+
| `session.state` | `"owner"` |
|
|
179
|
+
| `session.capabilities` | `"owner"` |
|
|
180
|
+
| `task.state` | `"owner"` |
|
|
181
|
+
| `turn.started` | `"owner"` |
|
|
182
|
+
| `turn.completed` | `"owner"` |
|
|
183
|
+
| `item.started`, `item.delta`, `item.updated`, `item.completed` | `"adapter"` |
|
|
184
|
+
| `approval.requested`, `approval.resolved` | `"owner"` |
|
|
185
|
+
| Adapter-raised `session.error` with `category: "capture"` | `"adapter"` |
|
|
186
|
+
| Owner-raised `session.error` with `category: "execution"` or `category: "capture"` | `"owner"` |
|
|
187
|
+
|
|
188
|
+
Content status or format changes require a snapshot. Retraction/supersession replaces affected content with unavailable content and incomplete/unknown state. A completed item is not task completion. Text ending at a native prompt boundary can use `completion: "turn-boundary"`; a tool without a terminal native result closes as `unknown`, never inferred `succeeded`. 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"`. This closure rule also applies to partial views on chunk-only routes. Custom-tool and streamed observations are deduplicated only through reliable native identity. Unattributable late frames are never assigned to whichever task happens to be active.
|
|
189
|
+
|
|
190
|
+
`phase: "final"` and `finalItemId` are supplied only when reliably associated with the adapter's selected complete response. Intermediate messages do not change `task.result`. `turn.completed` follows native completion or confirmed stop and callback draining. Failed stop confirmation produces failed task state with `stopUnconfirmed: true`. When native stop remains unconfirmed, open items stay open until the session is retired, then close with the same `completion: "interrupted"` and interrupted/unknown states defined above; no `turn.completed` is invented for that unconfirmed stop. For a confirmed turn end, accepted item frames, including item closures, precede turn completion and its corresponding terminal task event. This is producer ordering, never a wait for a subscriber or extension handler.
|
|
191
|
+
|
|
192
|
+
Approval events reuse the existing request IDs/actions. Resolution reports answer submission or withdrawal, not tool success; answers use the separate approval API. Session errors use safe library codes and messages. The `capture` error category describes live event processing; it does not change execution outcomes. Native nested attribution is included only when reliably bound to the owning turn. Observation does not enable otherwise-hidden native subagent text.
|
|
193
|
+
|
|
194
|
+
## Effective route capabilities
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
export interface EventFeature {
|
|
198
|
+
readonly support: "available" | "unsupported" | "unverified";
|
|
199
|
+
readonly delivery: readonly ("delta" | "snapshot")[];
|
|
200
|
+
readonly note?: string;
|
|
201
|
+
}
|
|
202
|
+
export interface SessionEventCapabilities {
|
|
203
|
+
readonly route: NativeRoute;
|
|
204
|
+
readonly nativeVersion?: string;
|
|
205
|
+
readonly assistant: EventFeature;
|
|
206
|
+
readonly reasoning: EventFeature;
|
|
207
|
+
readonly tools: EventFeature;
|
|
208
|
+
readonly approvals: EventFeature;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`capabilities(sessionId)` returns the selected route's current effective capabilities. It rejects with `UNKNOWN_SESSION` for an unknown session and resolves `undefined` only before harness selection for a known session. It never starts a harness. Changes publish `session.capabilities` to matching subscribers. `available` means a supported normalized format is exposed, not that every model emits it. `unsupported` means known unavailable. `unverified` means the adapter cannot confirm that the route emits that feature: events of that kind may or may not arrive, and callers must not depend on them. Unsupported and unverified features have empty delivery lists. Available approvals always declare `delivery: ["snapshot"]`; approval requests and resolutions are complete records, never deltas. All routes supply execution-owner lifecycle and safe execution errors.
|
|
213
|
+
|
|
214
|
+
`SessionEventCapabilities.nativeVersion` is optional. When present, it contains at most 64 bytes of printable ASCII (characters `0x20` through `0x7E`). An unavailable version or one that does not meet these bounds is omitted.
|
|
215
|
+
|
|
216
|
+
The `copilot-sdk` route omits `nativeVersion`. The pinned SDK package version is not the native runtime version, and the adapter does not expose a verified runtime version through this capability.
|
|
217
|
+
|
|
218
|
+
Startup-only output options are enabled for every native session, including Claude `includePartialMessages` and Copilot `streaming`. A later subscriber therefore receives supported deltas without restarting or reconfiguring the native session. When no subscriber matches, adapters still perform required native protocol/execution work but skip event normalization and event IPC.
|
|
219
|
+
|
|
220
|
+
Snapshot delivery includes item starts, replacements and completion; deltas are additional incremental text. Installed versions can reduce coverage; the effective declaration is authoritative.
|
|
221
|
+
|
|
222
|
+
| Route | Assistant | Exposed reasoning | Tools | Approvals and limits |
|
|
223
|
+
| --- | --- | --- | --- | --- |
|
|
224
|
+
| `codex-app-server` | Delta and snapshot | Summary/text delta and snapshot | Snapshots of command, file-change, MCP and dynamic calls; command output deltas | Supported command/file and grant requests. Reasoning summary and exposed text remain distinguishable. |
|
|
225
|
+
| `claude-agent-sdk` | Delta and snapshot | Text delta and snapshot; opaque thinking unavailable | Tool-use/result snapshots correlated by tool-use ID; valid input snapshots only | Existing `canUseTool` flow. Result messages close turns. Native nested text visibility can be partial. |
|
|
226
|
+
| `fx-acp` | Chunk deltas and turn-boundary snapshots | Unverified | ACP call/update snapshots with input/output previews | Offered ACP permissions. Stable native message IDs distinguish progress from the last selected response. Reasoning emission is unverified. |
|
|
227
|
+
| `opencode-http` | Message/part deltas and snapshots | Part deltas and snapshots | Call-ID snapshots of pending/running/completed/error state and input/output | Existing once/reject permissions. Native idle alone does not establish successful completion. Coverage follows the pinned 1.18.32 route. |
|
|
228
|
+
| `copilot-sdk` | Deltas and complete snapshots | Deltas and complete snapshots | Call-ID start/progress/partial-result/completion snapshots | Existing approve-once/reject flow. Native idle confirmation retains its execution meaning. |
|
|
229
|
+
| `cursor-acp` | Chunk deltas and turn-boundary snapshots | Unverified | Unverified | Offered once-only permissions. Some backend failures appear only as assistant text; no error classifier infers failure from prose. |
|
|
230
|
+
| `cursor-sdk` | Available; `["snapshot"]` (final responses) | Unverified; `[]` | Call-ID running/completed/error snapshots with args/results and native truncation preserved | Interactive approvals unsupported. Native request identifiers are not approval requests. |
|
|
231
|
+
|
|
232
|
+
The table defines normalized route coverage. For `cursor-sdk`, assistant support is `"available"` with delivery `["snapshot"]`; reasoning support is `"unverified"` with delivery `[]`. For `fx-acp` and `cursor-acp`, mid-item turn-boundary assistant snapshots retain only content normalized since registration and use state `"incomplete"`. Native persistence settings and close-time deletion behavior are unchanged.
|
|
233
|
+
|
|
234
|
+
There is no raw native payload in this event union. Usage/cost, plans, file attribution, auth/account events, opaque thinking, arbitrary metadata and unsupported native variants are excluded. Malformed required execution protocol data keeps its existing failure behavior.
|
|
235
|
+
|
|
236
|
+
## Subscription API
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
export type EventScope =
|
|
240
|
+
| { readonly kind: "all" }
|
|
241
|
+
| { readonly kind: "session"; readonly sessionId: string }
|
|
242
|
+
| { readonly kind: "task"; readonly sessionId: string; readonly taskId: string };
|
|
243
|
+
export interface EventOpenOptions {
|
|
244
|
+
readonly scope: EventScope;
|
|
245
|
+
readonly signal?: AbortSignal;
|
|
246
|
+
}
|
|
247
|
+
export type EventSubscription = AsyncIterable<SessionEvent> & {
|
|
248
|
+
close(): Promise<void>;
|
|
249
|
+
};
|
|
250
|
+
export interface SessionEventSource {
|
|
251
|
+
open(options: EventOpenOptions): Promise<EventSubscription>;
|
|
252
|
+
capabilities(sessionId: string): Promise<SessionEventCapabilities | undefined>;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Both `Runner` and `Client` expose `readonly events: SessionEventSource`. `scope` is required. `all` covers the execution owner's sessions, including future ones; session scope covers that conversation; task scope checks both IDs and excludes managed descendants. Task scope also includes its containing session's state/capability events while the subscription is open. Applications authorize and filter events before forwarding them to browser users.
|
|
257
|
+
|
|
258
|
+
The `open` promise resolves after registration. Only events accepted after that registration boundary are delivered. Past events are not replayed. Earlier content can appear only in a snapshot later supplied by the native route; chunk-only mid-item turn-boundary views retain the incomplete-state rule above. Await it before submitting a prompt to observe that prompt's initial events. Values are detached read-only `SessionEvent` objects directly; opening does not synthesize an initial state or emit control records. One subscriber cannot mutate another subscriber's view through a shared event object. Query task/session snapshots and `capabilities` separately when current metadata is needed. Opening another subscription begins another live observation and never supplies events missed while detached.
|
|
259
|
+
|
|
260
|
+
`close()` and iterator `return()` are idempotent; they end only observation and release pending delivery. `open()` with an already aborted signal rejects with `OBSERVATION_CLOSED` without registering. A later explicit signal abort rejects a pending read with `OBSERVATION_CLOSED`. No observation operation cancels a task or acknowledges child results. A task subscription drains accepted events and ends at the current or next terminal outcome; one opened on an already terminal task ends without earlier events. A session subscription ends on session close; `all` ends on owner close. Ended iterators do not reopen for private recovery. Connected disconnect rejects affected streams with `COORDINATOR_UNAVAILABLE` and leaves agents running. The event source does not reconnect automatically.
|
|
261
|
+
|
|
262
|
+
If closing an execution owner fails, every open subscription of that owner ends, regardless of scope. Embedded runner subscriptions reject pending reads with `OBSERVATION_CLOSED`; connected subscriptions reject pending reads with `COORDINATOR_UNAVAILABLE`.
|
|
263
|
+
|
|
264
|
+
## Forwarding and flow control
|
|
265
|
+
|
|
266
|
+
Adapters normalize and forward only while at least one subscriber matches the session. Extensions subscribe through their supervised child processes for their admission-selected sessions; an open dashboard task screen counts as a task subscriber. Embedded runners serve explicit application subscriptions and do not load extensions. Closing the last matching subscriber stops event normalization and event IPC; it does not stop native execution.
|
|
267
|
+
|
|
268
|
+
There is no event-content store. Only bounded in-flight delivery/redaction data and metadata needed to identify live operations are used. After forwarding, event content is not retained for another observation. A dashboard owns the text currently displayed on its open screen; applications/extensions explicitly own any content they choose to keep. Required native execution state and the existing complete-response records are separate from the event API.
|
|
269
|
+
|
|
270
|
+
Each adapter keeps normalization state for at most 1,024 open items per session. Items beyond that bound are not forwarded. The adapter raises one `session.error` with `category: "capture"` and `origin: "adapter"` per turn that overflows, without changing the execution outcome.
|
|
271
|
+
|
|
272
|
+
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.
|
|
273
|
+
|
|
274
|
+
Each subscriber has at most 128 events or 1 MiB of pending serialized event data, whichever limit is reached first. A subscriber that exceeds either bound has its stream rejected with `EVENT_BACKPRESSURE`; its queued delivery is released. Event delivery never waits for a consumer or applies backpressure to native execution. One slow subscriber does not delay other subscribers. Execution replies, approvals and cancellation have an independent control path. No dropped-content recovery is attempted by the event source.
|
|
275
|
+
|
|
276
|
+
Worker frames bind lease, operation and source sequence to the owning turn. Identity, schema and content limits are validated before forwarding. Claude's private SDK worker retains its existing environment/callback isolation. Connected events use a separate bounded stream on the authenticated, loopback, instance-bound SDK transport with the `session-events-v1` capability. Private dashboard projections and execution-command JSONL do not carry live steps. Missing support rejects the SDK event operation with `COORDINATOR_INCOMPATIBLE` while core execution/inspection remains usable. The CLI task screen maps missing `session-events-v1` support to `COORDINATOR_OUTDATED` with restart guidance in place of live steps, while retaining its core content. Observing never launches a native harness or replaces a coordinator.
|
|
277
|
+
|
|
278
|
+
## Content bounds and redaction
|
|
279
|
+
|
|
280
|
+
All sizes below use UTF-8 bytes. Previews are display data; they never replace actual tool arguments, results or final responses. The existing 1 MiB complete-response/text-tool limits and rich-tool limits remain effective.
|
|
281
|
+
|
|
282
|
+
| Content | Limit |
|
|
283
|
+
| --- | --- |
|
|
284
|
+
| Serialized event | 128 KiB, including the existing bounded approval request |
|
|
285
|
+
| Delta text | 8 KiB |
|
|
286
|
+
| Assistant or reasoning body | 16 KiB per item |
|
|
287
|
+
| Tool input / output | 8 KiB / 32 KiB per item |
|
|
288
|
+
| Native ID or tool label | 256 bytes |
|
|
289
|
+
| Optional native version | 64 bytes of printable ASCII; omitted otherwise |
|
|
290
|
+
| Safe diagnostic or capability note | 1 KiB |
|
|
291
|
+
| Structured traversal | Depth 16 and 1,000 entries |
|
|
292
|
+
|
|
293
|
+
Truncation preserves valid UTF-8, marks `status: "truncated"`, and supplies `originalBytes` only when known. Redacted spans use explicit placeholders. If content is both redacted and truncated, the status is `truncated` and the redaction placeholders remain visible; `redacted` means redaction without truncation. `unavailable` supplies a fixed explanation without source content. Oversized native correlation IDs are omitted rather than truncated into ambiguous identities; normalized synthetic identity remains stable. Tool labels may be visibly truncated. Binary/image/audio blocks use unavailable descriptions, never base64. Truncated JSON previews retain `format: "json"` but must not be parsed as complete arguments.
|
|
294
|
+
|
|
295
|
+
Only allowlisted content fields cross the producer boundary. Environment/configuration blobs, credentials, coordinator/launcher tokens, native stderr, exception objects, HTTP/RPC error bodies, auth events, encrypted reasoning, signatures and arbitrary metadata are excluded. Known resolved secret values are scrubbed; structured authorization/password/secret/token/api-key keys and normalized equivalents are recursively redacted before serialization. Split deltas cannot release parts of a known secret: producers use only bounded in-flight redaction state and release a stable safe prefix. That transient state is discarded when it is no longer needed for delivery; it is not retained for another subscriber. Unknown arbitrary secrets in source code or prose cannot be guaranteed detectable. No raw/unredacted bypass exists.
|
|
296
|
+
|
|
297
|
+
Reasoning means only provider-exposed text or summaries. Opaque thinking is unavailable and is never reconstructed. The coordinator revalidates event bounds. Terminal controls in retained content remain untrusted text: the CLI sanitizes before measuring or adding its own ANSI; SDK applications escape for their own output surface. Applications and enabled extensions remain responsible for any data they store or transmit.
|
|
298
|
+
|
|
299
|
+
## Errors and an application example
|
|
300
|
+
|
|
301
|
+
Invalid option shapes reject with `INVALID_ARGUMENT`; unknown sessions/tasks use `UNKNOWN_SESSION`/`UNKNOWN_TASK`. Backpressure, abort and transport failures use the codes above with safe `AgentError` messages. Native execution failure is event data and task state, not automatically a subscription failure. An event-processing failure does not rewrite a successful native result.
|
|
302
|
+
|
|
303
|
+
SDK applications implement custom behavior by consuming `events.open` directly. This example observes before admitting work and lets the application decide how to handle each event. A separate application component handles pending approvals.
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
import { createRunner, type AgentDefinition, type EventSubscription, type SessionEvent } from "subharness";
|
|
307
|
+
|
|
308
|
+
async function observe(
|
|
309
|
+
definition: AgentDefinition,
|
|
310
|
+
cwd: string,
|
|
311
|
+
consume: (event: SessionEvent) => Promise<void>,
|
|
312
|
+
): Promise<string> {
|
|
313
|
+
const runner = createRunner();
|
|
314
|
+
let subscription: EventSubscription | undefined;
|
|
315
|
+
let reading: Promise<void> | undefined;
|
|
316
|
+
try {
|
|
317
|
+
const session = await runner.createSession(definition, { cwd });
|
|
318
|
+
subscription = await runner.events.open({
|
|
319
|
+
scope: { kind: "session", sessionId: session.id },
|
|
320
|
+
});
|
|
321
|
+
reading = (async () => {
|
|
322
|
+
for await (const event of subscription!) await consume(event);
|
|
323
|
+
})();
|
|
324
|
+
// Observe failures again below without an unhandled rejection while work runs.
|
|
325
|
+
void reading.catch(() => {});
|
|
326
|
+
const { task } = await session.prompt("Review the current diff.");
|
|
327
|
+
const result = await task.result;
|
|
328
|
+
await session.close();
|
|
329
|
+
await reading;
|
|
330
|
+
return result.text;
|
|
331
|
+
} finally {
|
|
332
|
+
await subscription?.close();
|
|
333
|
+
await reading?.catch(() => {});
|
|
334
|
+
await runner.close();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
A connected application uses `client.events` with the same types and registration semantics. Its own handlers run in that application; installed user extensions instead execute in coordinator-supervised child processes under the [extension contract](extensions.md). Disconnecting a connected application leaves the coordinator and its agents/extensions running.
|