subharness 0.0.7 → 0.0.10
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 +40 -9
- 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-worker-client.d.ts +11 -0
- package/dist/adapters/claude-worker-client.js +219 -5
- package/dist/adapters/claude-worker-client.js.map +1 -1
- package/dist/adapters/claude-worker-protocol.d.ts +58 -0
- package/dist/adapters/claude-worker-protocol.js.map +1 -1
- package/dist/adapters/claude-worker.js +48 -3
- package/dist/adapters/claude-worker.js.map +1 -1
- package/dist/adapters/claude.d.ts +5 -1
- package/dist/adapters/claude.js +14 -2
- 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 +6 -1
- package/dist/cli/args.js +63 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/catalog-worker.js +3 -2
- package/dist/cli/catalog-worker.js.map +1 -1
- package/dist/cli/dashboard-client.d.ts +1 -0
- package/dist/cli/dashboard-client.js +13 -1
- 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 +15 -0
- package/dist/cli/extensions.js +187 -0
- package/dist/cli/extensions.js.map +1 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +34 -6
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +100 -10
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.js +5 -1
- package/dist/cli/output.js.map +1 -1
- package/dist/config/access.d.ts +2 -1
- package/dist/config/access.js +18 -7
- package/dist/config/access.js.map +1 -1
- package/dist/config/loader.d.ts +2 -0
- package/dist/config/loader.js +20 -6
- package/dist/config/loader.js.map +1 -1
- package/dist/config/project-context.d.ts +9 -0
- package/dist/config/project-context.js +41 -0
- package/dist/config/project-context.js.map +1 -0
- package/dist/config/resolve-access.d.ts +2 -1
- package/dist/config/resolve-access.js +5 -2
- package/dist/config/resolve-access.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 +34 -0
- package/dist/extensions/catalog.js +103 -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 +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/approval-registry.d.ts +6 -2
- package/dist/runtime/approval-registry.js +31 -3
- package/dist/runtime/approval-registry.js.map +1 -1
- package/dist/runtime/capture.d.ts +4 -4
- package/dist/runtime/capture.js +59 -15
- package/dist/runtime/capture.js.map +1 -1
- package/dist/runtime/catalog.d.ts +6 -1
- package/dist/runtime/catalog.js +1 -1
- package/dist/runtime/catalog.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +9 -4
- package/dist/runtime/coordinator.js +130 -27
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/daemon.js +9 -1
- package/dist/runtime/daemon.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 +1 -1
- package/dist/runtime/definition.js +2 -2
- 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 +254 -0
- package/dist/runtime/extension-supervisor.js.map +1 -0
- package/dist/runtime/select-native.d.ts +3 -1
- package/dist/runtime/select-native.js +32 -5
- package/dist/runtime/select-native.js.map +1 -1
- package/dist/runtime/service.d.ts +5 -0
- package/dist/runtime/service.js +113 -15
- 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/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 +2 -1
- package/dist/runtime/state.js +4 -0
- package/dist/runtime/state.js.map +1 -1
- package/dist/runtime/transport.d.ts +1 -0
- package/dist/runtime/transport.js +2 -0
- package/dist/runtime/transport.js.map +1 -1
- package/dist/runtime/types.d.ts +24 -0
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/worker-client.js +42 -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 +64 -9
- 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 +2 -0
- package/dist/sdk/connected-types.js.map +1 -1
- package/dist/sdk/connected.js +3 -0
- package/dist/sdk/connected.js.map +1 -1
- 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-driver.js +1 -1
- package/dist/sdk/execution-driver.js.map +1 -1
- package/dist/sdk/execution-types.d.ts +2 -0
- package/dist/sdk/execution-types.js.map +1 -1
- package/dist/sdk/runner.js +2 -0
- package/dist/sdk/runner.js.map +1 -1
- package/package.json +5 -1
- package/sdk/access-config.md +9 -7
- package/sdk/adapter-contract.md +25 -3
- package/sdk/agent-skill.md +8 -5
- 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 +53 -14
- package/sdk/cli/output.md +14 -2
- package/sdk/completion-notifications.md +2 -2
- package/sdk/config.md +65 -11
- package/sdk/copilot.md +1 -1
- package/sdk/cursor.md +2 -2
- package/sdk/diagnostics.md +68 -0
- package/sdk/distribution.md +13 -3
- package/sdk/events.md +339 -0
- package/sdk/execution.md +32 -10
- package/sdk/extensions.md +189 -0
- package/sdk/fx.md +4 -2
- package/sdk/harnesses.md +1 -1
- package/sdk/index.md +4 -0
- package/sdk/message-delivery.md +2 -0
- package/sdk/opencode.md +1 -1
- package/sdk/plugins/sub-agents.md +3 -1
- package/sdk/project-root.md +97 -0
- package/sdk/project-team.md +10 -4
- package/sdk/sessions.md +4 -0
- package/sdk/v1-runtime.md +22 -8
|
@@ -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 [--root <directory>]
|
|
8
|
+
subharness extensions enable <global:id|repo:id> [--root <directory>]
|
|
9
|
+
subharness extensions disable <global:id|repo:id> [--root <directory>]
|
|
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` with its existing option-combination restrictions. List, enable, and disable also accept `--root <directory>`; other options and extra arguments are rejected, including `--cwd` and `--format`. Without `--root`, repository scope resolves the command's directory to its canonical worktree root, or to that directory outside Git. With `--root`, it uses the selected canonical directory, resolved from the invoking directory. See [logical project roots](../project-root.md). Extension management selects this scope independently even in a managed environment; it neither inherits nor replaces a running session's retained project selection. Enable/disable require qualified references, so an installation never silently shadows another. Instance identity is the qualified reference plus the canonical project root for repository extensions; global instances have no checkout component. Failure state, eligibility and re-enablement are scoped to that identity. Enabling `repo:<id>` for one project root affects only its instance, even when another project root has the same extension ID.
|
|
13
|
+
|
|
14
|
+
`list` reads `~/.subharness/extensions/<id>/extension.json` and `<project-root>/.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 project roots' 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 selected for that canonical project root, even when execution cwd is elsewhere. CLI and connected SDK creation use this same admission-time selection; public SDK creation retains default cwd-based discovery. App roots require their own consent, without inheriting parent, sibling-app, or linked-worktree consent. 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 edits to that project.
|
|
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 selected project root 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 `<project-root>/.subharness/extensions/<id>/`, then explicitly enable the qualified ID, using the same `--root` for an app installation. 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, invalid or inaccessible `--root` directories, 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>-<root-hash>.log` for a repository instance. `<root-hash>` is the first 12 hex characters of the SHA-256 of the canonical project-root 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
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
The CLI is the primary execution interface for an everyday coding assistant. The assistant can invoke a native harness directly or a reusable specialist defined with the SDK, run commands through its host's background-task controls, and use identifiers for later interactions. `subharness` is the primary executable; `agent` is a compatibility alias with identical behavior.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
subharness list [--cwd <directory>]
|
|
6
|
+
subharness list [--root <directory>] [--cwd <directory>]
|
|
7
7
|
subharness dashboard
|
|
8
|
-
subharness
|
|
9
|
-
subharness
|
|
10
|
-
subharness
|
|
11
|
-
subharness
|
|
12
|
-
subharness
|
|
13
|
-
subharness
|
|
8
|
+
subharness extensions --help
|
|
9
|
+
subharness extensions list [--root <directory>]
|
|
10
|
+
subharness extensions enable <global:id|repo:id> [--root <directory>]
|
|
11
|
+
subharness extensions disable <global:id|repo:id> [--root <directory>]
|
|
12
|
+
subharness check <target> [--root <directory>] [--cwd <directory>] [--format text|jsonl]
|
|
13
|
+
subharness check <definition.ts> [--root <directory>] [--cwd <directory>] [--format text|jsonl]
|
|
14
|
+
subharness check <harness> [--root <directory>] [--cwd <directory>] [--model <model>] [--effort <effort>] [--format text|jsonl]
|
|
15
|
+
subharness run <target> [--root <directory>] [--cwd <directory>] [--detach] <prompt>
|
|
16
|
+
subharness run <definition.ts> [--root <directory>] [--cwd <directory>] [--detach] <prompt>
|
|
17
|
+
subharness run <target> [--root <directory>] [--cwd <directory>] [--detach] --prompt <text>
|
|
18
|
+
subharness run <target> [--root <directory>] [--cwd <directory>] [--detach] --prompt-file <path|->
|
|
19
|
+
subharness run <harness> [--root <directory>] [--cwd <directory>] [--model <model>] [--effort <effort>] <prompt>
|
|
14
20
|
subharness run <harness> --help
|
|
15
21
|
subharness send <session-id> [--delivery queue|steer|interrupt] [--detach] <prompt>
|
|
16
22
|
subharness send <session-id> [--delivery queue|steer|interrupt] [--detach] --prompt <text>
|
|
@@ -21,10 +27,11 @@ subharness respond <request-id> --content <json>
|
|
|
21
27
|
subharness respond <request-id> --content-file <path|->
|
|
22
28
|
subharness queue <session-id>
|
|
23
29
|
subharness cancel <task-id>
|
|
30
|
+
subharness close <session-id> [--format text|jsonl]
|
|
24
31
|
subharness resume <session-id>
|
|
25
32
|
```
|
|
26
33
|
|
|
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.
|
|
34
|
+
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
35
|
|
|
29
36
|
`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
37
|
|
|
@@ -32,6 +39,32 @@ Readiness means only that startup checks for the selected target passed at that
|
|
|
32
39
|
|
|
33
40
|
`run --detach` instead returns immediately after successful admission with only the same `started` record.
|
|
34
41
|
|
|
42
|
+
## Select a project
|
|
43
|
+
|
|
44
|
+
`--root <directory>` selects a [logical project](../project-root.md) for `list`, `check`, `run`, and extension list/enable/disable. Relative roots resolve from the invoking directory. The selected project owns its repository agents, personal access, and extensions; enclosing catalogs and settings are not merged. An omitted `--cwd` defaults to that root. An explicit relative `--cwd` resolves independently from the invoking directory and changes execution only. Without `--root`, execution defaults to the invoking directory and discovery retains its Git-root rules.
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
subharness list --root ./apps/my-app
|
|
48
|
+
subharness check --root ./apps/my-app repo:reviewer
|
|
49
|
+
subharness run --root ./apps/my-app repo:reviewer --prompt "Review this app."
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Linked worktrees share personal access at the corresponding app path in the main checkout. Definitions and extensions stay in the selected worktree app. Explicit-root runs and managed `list`, `check`, or `run` commands supplying `--root` require coordinator capability `cli-root-v1`; an older live coordinator yields `COORDINATOR_OUTDATED` before submission, with no automatic restart or default-root fallback. Top-level `list` and `check` remain coordinator-free. Session-ID commands retain the selected project and do not accept `--root`.
|
|
53
|
+
|
|
54
|
+
## Close a session
|
|
55
|
+
|
|
56
|
+
`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.
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
`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.
|
|
61
|
+
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
[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 selected project root. Without `--root`, this retains the execution checkout scope; root-selected sessions use their logical project even when execution cwd is elsewhere. The dashboard and embedded runners do not load extension code.
|
|
67
|
+
|
|
35
68
|
## Live dashboard
|
|
36
69
|
|
|
37
70
|
`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,14 +83,16 @@ The harness label is `codex`, `claude`, `fx`, `opencode`, `copilot`, or `cursor`
|
|
|
50
83
|
|
|
51
84
|
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
85
|
|
|
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
|
|
86
|
+
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
87
|
|
|
55
|
-
Snapshots refresh once per second without overlapping requests. Resizing redraws the current
|
|
88
|
+
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
89
|
|
|
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
|
|
90
|
+
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
91
|
|
|
59
92
|
## Direct harnesses and specialists
|
|
60
93
|
|
|
94
|
+
`run` and `check` also accept an explicit `.ts` agent definition path, excluding `.d.ts` declarations. Paths resolve from the invoking command's directory, independently of `--cwd` and `--root`, and load only the selected definition and its imports. The definition can live inside a monorepo app without a root catalog entry. See [explicit definition files](../config.md#explicit-definition-files) for target recognition, validation, execution context, and managed-parent restrictions.
|
|
95
|
+
|
|
61
96
|
`codex`, `claude`, `fx`, `opencode`, `copilot`, and `cursor` are reserved, case-sensitive target names for direct harness execution. `claude` selects the Claude Code adapter, whose SDK and access configuration key remains `claudeCode`. Direct execution needs its native runtime and eligible access, but no TypeScript definition, project-local SDK import, or agent catalog evaluation. An invalid specialist file does not block a direct harness run.
|
|
62
97
|
|
|
63
98
|
```sh
|
|
@@ -75,7 +110,7 @@ Replace `provider/model` or `creator/model` with an available Gateway model iden
|
|
|
75
110
|
|
|
76
111
|
Direct harness sessions use native instructions and project context without adding a specialist role, custom tools, or declared children. They preserve the existing authentication, native permission, queue, cancellation, follow-up, and response contracts. They do not broaden the caller's native permissions or automatically authorize additional delegation.
|
|
77
112
|
|
|
78
|
-
`--model` configures direct harness targets only for `run` and `check`, and can be combined with `--cwd
|
|
113
|
+
`--model` configures direct harness targets only for `run` and `check`, and can be combined with `--root`, `--cwd`, and, for `run`, any supported prompt source. `--effort` is additionally available for Codex, Claude Code, and fx. Empty values are errors. Specialist targets reject these overrides and retain their declared harness configurations. `send` retains the session configuration and does not accept model or effort overrides.
|
|
79
114
|
|
|
80
115
|
For Codex, Claude Code, and fx, omitting `--model` requests the native default for the authorized access route at session creation. OpenCode, Copilot, and Cursor require an explicit `--model`; omission fails with `INVALID_CONFIG` and guidance before native startup. The adapter retains the selected model for that conversation. It does not inherit the calling agent's model, rank models, choose a substitute, or change billing routes. An unavailable or unverifiable native default fails with actionable guidance to supply `--model`; it does not submit a prompt merely to discover a default. Explicit model identifiers retain native validation and substitution checks. TypeScript harness constructors continue to require a model.
|
|
81
116
|
|
|
@@ -91,7 +126,11 @@ Direct-harness help for `run` and `check` describes the relevant options and acc
|
|
|
91
126
|
|
|
92
127
|
`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
128
|
|
|
94
|
-
|
|
129
|
+
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 -`.
|
|
130
|
+
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
`--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` and `--root`. Omitted `--cwd` uses an explicitly selected root, or the calling directory otherwise. Follow-ups retain their session's execution directory.
|
|
95
134
|
|
|
96
135
|
`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).
|
|
97
136
|
|
|
@@ -101,7 +140,7 @@ Native steering returns an acceptance acknowledgement. Queued and interrupting s
|
|
|
101
140
|
|
|
102
141
|
## Nested execution
|
|
103
142
|
|
|
104
|
-
A managed agent invokes its own declared children with `subharness run subagent:<name>`. Parent context is supplied internally, not through public flags. Names resolve only against that parent's direct declarations. This invocation
|
|
143
|
+
A managed agent invokes its own declared children with `subharness run subagent:<name>`. Parent context is supplied internally, not through public flags. Names resolve only against that parent's direct declarations in its captured definition graph. This invocation neither reloads the source nor discovers unrelated repository or global entries, so changed source files or an unrelated broken definition do not change a declared child. A generic parent has no declared children and fails this lookup without evaluating a specialist catalog. Missing context or an undeclared child is an error; there is no fallback to another scope. Child execution uses the same commands and lifecycle. An explicit project root and its access root are inherited transitively, independently of child execution cwd. Managed `list`, `run`, and `check` calls cannot supply `--root`, even to repeat the inherited value; after parent validation, it fails with `INVALID_ARGUMENT`. An omitted child `--cwd` keeps the invoking managed command's directory. Parents without an explicit root keep their existing cwd-based discovery rules.
|
|
105
144
|
|
|
106
145
|
The caller supplies an existing working directory. The library does not create worktrees or sandboxes. A local coordinator owns pending execution after an individual response command exits. `--detach` releases only the CLI observation; it does not override process-lifecycle restrictions imposed by the host. Use host-owned background controls when the coordinator and workers must remain reachable after a shell command exits. Pending execution is not guaranteed to survive coordinator or environment exit, and detached admission does not promise automatic reactivation of an external parent chat.
|
|
107
146
|
|
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
|
|
|
@@ -16,7 +18,7 @@ A successful readiness check emits one record and admits no task:
|
|
|
16
18
|
{"version":1,"type":"check","target":"repo:developer","ready":true}
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
Text output is a short line identifying the ready target. A failed check emits the existing `error` record. Access and capability failures exit `1`; invalid arguments, configuration, or targets exit `2`.
|
|
21
|
+
Text output is a short line identifying the ready target. Control characters, DEL, and Unicode line separators in a target are escaped in text output so a file path cannot insert terminal controls or extra lines. The JSONL `target` retains the original argument as a JSON string. A failed check emits the existing `error` record. Access and capability failures exit `1`; invalid arguments, configuration, or targets exit `2`.
|
|
20
22
|
|
|
21
23
|
Quiet tasks keep their local observation connection alive without printing progress messages or extra JSONL records. Transport keepalives are private to the CLI/coordinator connection. A lost observer connection does not cancel or replay its task; callers can retrieve its state and response with `status`.
|
|
22
24
|
|
|
@@ -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,8 +1,8 @@
|
|
|
1
1
|
# Responses and Task Completion
|
|
2
2
|
|
|
3
|
-
The [execution SDK](execution.md) provides complete-response cursors and task snapshot observation directly to application code.
|
|
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
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.
|
|
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.
|
|
6
6
|
|
|
7
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.
|
|
8
8
|
|
package/sdk/config.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent Discovery
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
By default, repository agents live in `.subharness/agents/` at the Git worktree root, or in the execution directory outside Git. [Logical project roots](project-root.md) let `--root <directory>` select an app's `.subharness/` independently of execution `--cwd`. Global agents remain 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
|
|
|
@@ -37,7 +44,29 @@ export default agent({
|
|
|
37
44
|
|
|
38
45
|
The former `.agents/agents/` directory is not read. Definitions moved to `.subharness/agents/` can keep or drop an `.agent` file-name suffix; either way the file is an entry because it is a `.ts` file under `agents/`.
|
|
39
46
|
|
|
40
|
-
Discovery is required for listing and repository/global specialist lookup. Direct harness execution skips it. Declared-child execution
|
|
47
|
+
Discovery is required for listing and repository/global specialist lookup. Direct harness execution skips it. Declared-child execution selects from the parent's captured definition graph and direct child map; unrelated catalog entries are not dependencies of a `subagent:` invocation.
|
|
48
|
+
|
|
49
|
+
## Explicit definition files
|
|
50
|
+
|
|
51
|
+
The CLI accepts a TypeScript definition file as the target of `run` and `check`. The file can live anywhere accessible to the caller, including inside an individual monorepo application or outside the execution repository. It must be a regular `.ts` file, excluding `.d.ts` declarations, and default-export one valid `AgentDefinition`. Ordinary filesystem symlinks to regular files are allowed. Loading evaluates trusted executable code with the same definition validation and import resolution as catalog entries.
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
subharness check ./apps/storefront/.subharness/agents/reviewer.ts
|
|
55
|
+
subharness run ./apps/storefront/.subharness/agents/reviewer.ts \
|
|
56
|
+
--cwd ./apps/storefront --prompt "Review this app."
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Absolute paths and relative paths are accepted. Relative definition paths resolve from the invoking command's directory, independently of `--cwd` and `--root`. A target is a file path when it is absolute, starts with `./` or `../` (or the platform's equivalent), contains a platform path separator, or ends in `.ts`. Reserved harness targets and qualified `repo:`, `global:`, and `subagent:` references retain their existing meaning. A bare `reviewer.ts` selects a file; a bare `reviewer` remains a catalog lookup. There is no fallback from a missing file to catalog discovery.
|
|
60
|
+
|
|
61
|
+
Only the selected definition and its imports are evaluated. Repository and global catalogs are not discovered, so unrelated invalid entries and duplicate catalog names do not block this target. The file is not registered in a catalog, and `list` remains unchanged. An unavailable file, directory target, unsupported extension, or invalid definition fails with `INVALID_DEFINITION`, identifies the selected file safely, and exits with code `2`. Native startup failures retain their existing diagnostics and exit codes.
|
|
62
|
+
|
|
63
|
+
`--cwd` selects the execution directory. It defaults to the selected `--root`, or to the invoking command's directory when no root is selected. Definition evaluation runs in that execution directory; relative module imports follow normal Node resolution from the definition module, using the target directory when the file is a symlink. The definition file's location does not select personal access or extensions: these follow `--root` when supplied and execution-directory discovery otherwise. Workspace identity still describes the actual execution directory and Git worktree. File targets reject `--model` and `--effort` overrides just like catalog specialists. A successful `check` identifies the original target argument in its output.
|
|
64
|
+
|
|
65
|
+
Without `--root`, personal access inside a Git monorepo comes from `.subharness/agents.local.json` at the main checkout root; an app-local definition or `--cwd` alone does not change that. Use `--root ./apps/storefront` to select that app's access settings and extensions, including with an explicit definition file. In a linked worktree, access comes from the corresponding app in the main checkout. No enclosing catalog, settings, or extensions are merged into the selected project.
|
|
66
|
+
|
|
67
|
+
A session captures the loaded definition graph for follow-ups and declared children. New top-level sessions read the current file. Managed agents remain limited to their declared `subagent:` targets; an explicit file path does not bypass parent authorization. The public connected SDK continues to accept catalog references and harness configurations, not file-path strings. Embedded callers can import a definition and pass it to `createRunner().createSession()`.
|
|
68
|
+
|
|
69
|
+
## Catalog identities
|
|
41
70
|
|
|
42
71
|
The declared name determines identity. Duplicate names in the same scope are errors. `repo:reviewer` and `global:reviewer` remain distinct; bare `reviewer` is accepted only when unambiguous. The reserved CLI targets `codex`, `claude`, `fx`, `opencode`, `copilot`, and `cursor` always select native harnesses. Specialists with those names require a `repo:` or `global:` qualifier. Direct harness runs bypass definition discovery entirely, including invalid definition files. Global definitions can execute in any caller-supplied directory. Global and repository files resolve their own imports through normal Node package resolution.
|
|
43
72
|
|
|
@@ -45,22 +74,47 @@ The declared name determines identity. Duplicate names in the same scope are err
|
|
|
45
74
|
subharness list --cwd /repo/worktree
|
|
46
75
|
subharness check repo:developer --cwd /repo/worktree
|
|
47
76
|
subharness run repo:developer --cwd /repo/worktree --prompt "Implement the documented feature."
|
|
77
|
+
subharness run --root ./apps/storefront repo:reviewer --prompt "Review this app."
|
|
48
78
|
```
|
|
49
79
|
|
|
50
|
-
|
|
80
|
+
Without `--root`, an omitted `--cwd` uses the calling command's directory. Discovery uses the nearest Git worktree root, or the execution directory outside Git. With `--root`, discovery uses only that root's repository catalog and the global catalog; omitted `--cwd` uses the root. Explicit relative values for either flag resolve independently from the invoking directory. Bare repositories are not execution directories. Definitions are trusted executable TypeScript: catalog loading evaluates modules.
|
|
51
81
|
|
|
52
82
|
`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
83
|
|
|
84
|
+
## Extension consent and logs
|
|
85
|
+
|
|
86
|
+
Extension consent is stored in `~/.subharness/extensions.json` with owner-only permissions. It uses this schema:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"version": 1,
|
|
91
|
+
"global": ["<id>"],
|
|
92
|
+
"repositories": {
|
|
93
|
+
"<canonical project root>": ["<id>"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
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.
|
|
99
|
+
|
|
100
|
+
`global` contains enabled global extension IDs. Each `repositories` key is a canonical project root whose array contains enabled repository extension IDs. Without `--root`, this is the Git worktree root or the selected directory outside Git. With `--root`, it is the selected directory. Existing checkout keys remain valid; app roots require their own consent, with no inheritance from parents, sibling apps, or other worktrees. Consent is never written into repository files. An instance is identified by its qualified reference plus its project root for repository extensions, or by its qualified reference alone for global extensions. Failure state, eligibility and re-enablement apply per instance. The [extension commands](cli/extensions.md) read and update this file; discovery alone does not grant consent.
|
|
101
|
+
|
|
102
|
+
The consent file is at most 256 KiB. `repositories` contains at most 1,024 project-root 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.
|
|
103
|
+
|
|
104
|
+
Global instances write stdout/stderr to `<stateDirectory>/extensions/global-<id>.log`. Repository instances use `<stateDirectory>/extensions/repo-<id>-<root-hash>.log`, where `<root-hash>` is the first 12 hex characters of the SHA-256 of the canonical project-root path. Default checkout instances retain their existing log paths. 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.
|
|
105
|
+
|
|
54
106
|
## Personal access and worktrees
|
|
55
107
|
|
|
56
|
-
|
|
108
|
+
Without `--root`, the optional [access file](access-config.md) is `.subharness/agents.local.json` at the repository's main checkout root, 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. With `--root`, the access directory is the corresponding app path in that main checkout; definitions and extensions stay in the selected worktree's app. See [personal access and worktrees](project-root.md#personal-access-and-worktrees) for counterpart validation and path anchoring.
|
|
57
109
|
|
|
58
|
-
| Resource |
|
|
59
|
-
| --- | --- |
|
|
60
|
-
| Repository definitions | Execution worktree |
|
|
61
|
-
| Personal access preferences | Main checkout |
|
|
62
|
-
| Native credentials |
|
|
110
|
+
| Resource | Default source | With `--root` |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| Repository definitions | Execution worktree root | Selected project root |
|
|
113
|
+
| Personal access preferences | Main checkout root | Corresponding project root in the main checkout |
|
|
114
|
+
| Native credentials | Captured environment, configured files, and native credential store | Same sources; relative file/project references use the access root |
|
|
63
115
|
|
|
64
116
|
The library does not copy configuration or credentials into worktrees. An inaccessible main checkout is an error. A remote or isolated environment must have its own accessible preferences and credentials.
|
|
65
117
|
|
|
66
|
-
A session retains its loaded instructions, tools, and harness configuration.
|
|
118
|
+
A session retains its loaded instructions, tools, and harness configuration. Declared child sessions use the parent's captured definition graph, including when the source files have changed since the parent was created. New top-level sessions load definitions from the current files. In a managed parent context, `subharness list` shows the direct `subagent:` names from that captured graph. These names do not register the children in the global or repository catalog.
|
|
119
|
+
|
|
120
|
+
An explicitly selected project and its access root are retained for follow-ups and inherited by declared children. Managed `list`, `run`, and `check` calls cannot supply `--root`; child execution `--cwd` does not change the inherited access or extension scope. Settings and credentials are still read at each native session's startup, as defined in [sessions and managed children](project-root.md#sessions-and-managed-children).
|
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 logical project root 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>-<root-hash>.log` for a repository instance. `<root-hash>` is the first 12 hex characters of the SHA-256 of the canonical project-root 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.
|