subharness 0.0.5 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -5
- package/dist/adapters/claude-events.d.ts +71 -0
- package/dist/adapters/claude-events.js +860 -0
- package/dist/adapters/claude-events.js.map +1 -0
- package/dist/adapters/claude-process.js +8 -1
- package/dist/adapters/claude-process.js.map +1 -1
- package/dist/adapters/claude-tools.d.ts +6 -2
- package/dist/adapters/claude-tools.js +14 -12
- package/dist/adapters/claude-tools.js.map +1 -1
- package/dist/adapters/claude-worker-client.d.ts +60 -0
- package/dist/adapters/claude-worker-client.js +573 -0
- package/dist/adapters/claude-worker-client.js.map +1 -0
- package/dist/adapters/claude-worker-process.d.ts +20 -0
- package/dist/adapters/claude-worker-process.js +76 -0
- package/dist/adapters/claude-worker-process.js.map +1 -0
- package/dist/adapters/claude-worker-protocol.d.ts +96 -0
- package/dist/adapters/claude-worker-protocol.js +2 -0
- package/dist/adapters/claude-worker-protocol.js.map +1 -0
- package/dist/adapters/claude-worker.d.ts +1 -0
- package/dist/adapters/claude-worker.js +171 -0
- package/dist/adapters/claude-worker.js.map +1 -0
- package/dist/adapters/claude.d.ts +20 -6
- package/dist/adapters/claude.js +151 -69
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex-events.d.ts +52 -0
- package/dist/adapters/codex-events.js +672 -0
- package/dist/adapters/codex-events.js.map +1 -0
- package/dist/adapters/codex-turn-failure.d.ts +2 -0
- package/dist/adapters/codex-turn-failure.js +116 -0
- package/dist/adapters/codex-turn-failure.js.map +1 -0
- package/dist/adapters/codex.js +44 -7
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/copilot-events.d.ts +68 -0
- package/dist/adapters/copilot-events.js +650 -0
- package/dist/adapters/copilot-events.js.map +1 -0
- package/dist/adapters/copilot.js +24 -4
- package/dist/adapters/copilot.js.map +1 -1
- package/dist/adapters/cursor-acp-events.d.ts +36 -0
- package/dist/adapters/cursor-acp-events.js +251 -0
- package/dist/adapters/cursor-acp-events.js.map +1 -0
- package/dist/adapters/cursor-cli-session.d.ts +1 -0
- package/dist/adapters/cursor-cli-session.js +26 -5
- package/dist/adapters/cursor-cli-session.js.map +1 -1
- package/dist/adapters/cursor-cli.js +5 -0
- package/dist/adapters/cursor-cli.js.map +1 -1
- package/dist/adapters/cursor-sdk-events.d.ts +30 -0
- package/dist/adapters/cursor-sdk-events.js +233 -0
- package/dist/adapters/cursor-sdk-events.js.map +1 -0
- package/dist/adapters/cursor-session.js +56 -7
- package/dist/adapters/cursor-session.js.map +1 -1
- package/dist/adapters/cursor-startup.js +8 -2
- package/dist/adapters/cursor-startup.js.map +1 -1
- package/dist/adapters/event-normalizer.d.ts +57 -0
- package/dist/adapters/event-normalizer.js +143 -0
- package/dist/adapters/event-normalizer.js.map +1 -0
- package/dist/adapters/event-secrets.d.ts +17 -0
- package/dist/adapters/event-secrets.js +28 -0
- package/dist/adapters/event-secrets.js.map +1 -0
- package/dist/adapters/event-types.d.ts +58 -0
- package/dist/adapters/event-types.js +2 -0
- package/dist/adapters/event-types.js.map +1 -0
- package/dist/adapters/fx-events.d.ts +37 -0
- package/dist/adapters/fx-events.js +393 -0
- package/dist/adapters/fx-events.js.map +1 -0
- package/dist/adapters/fx-rpc.d.ts +2 -0
- package/dist/adapters/fx-rpc.js +11 -5
- package/dist/adapters/fx-rpc.js.map +1 -1
- package/dist/adapters/fx.js +73 -8
- package/dist/adapters/fx.js.map +1 -1
- package/dist/adapters/opencode-events.d.ts +58 -0
- package/dist/adapters/opencode-events.js +653 -0
- package/dist/adapters/opencode-events.js.map +1 -0
- package/dist/adapters/opencode-http.d.ts +1 -0
- package/dist/adapters/opencode-http.js +8 -7
- package/dist/adapters/opencode-http.js.map +1 -1
- package/dist/adapters/opencode.js +50 -9
- package/dist/adapters/opencode.js.map +1 -1
- package/dist/adapters/rpc.d.ts +2 -0
- package/dist/adapters/rpc.js +11 -5
- package/dist/adapters/rpc.js.map +1 -1
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/cli/args.d.ts +3 -1
- package/dist/cli/args.js +25 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/catalog-worker.js.map +1 -1
- package/dist/cli/dashboard-client.d.ts +1 -0
- package/dist/cli/dashboard-client.js +32 -31
- package/dist/cli/dashboard-client.js.map +1 -1
- package/dist/cli/dashboard-controller.js +6 -7
- package/dist/cli/dashboard-controller.js.map +1 -1
- package/dist/cli/dashboard-detail-view.d.ts +14 -8
- package/dist/cli/dashboard-detail-view.js +15 -44
- package/dist/cli/dashboard-detail-view.js.map +1 -1
- package/dist/cli/dashboard-history-view.d.ts +3 -12
- package/dist/cli/dashboard-history-view.js +18 -82
- package/dist/cli/dashboard-history-view.js.map +1 -1
- package/dist/cli/dashboard-live.d.ts +32 -0
- package/dist/cli/dashboard-live.js +177 -0
- package/dist/cli/dashboard-live.js.map +1 -0
- package/dist/cli/dashboard-renderer.d.ts +21 -1
- package/dist/cli/dashboard-renderer.js +85 -21
- package/dist/cli/dashboard-renderer.js.map +1 -1
- package/dist/cli/dashboard-steps.d.ts +53 -0
- package/dist/cli/dashboard-steps.js +157 -0
- package/dist/cli/dashboard-steps.js.map +1 -0
- package/dist/cli/dashboard-task-format.d.ts +15 -0
- package/dist/cli/dashboard-task-format.js +119 -0
- package/dist/cli/dashboard-task-format.js.map +1 -0
- package/dist/cli/dashboard-task-view.d.ts +66 -0
- package/dist/cli/dashboard-task-view.js +325 -0
- package/dist/cli/dashboard-task-view.js.map +1 -0
- package/dist/cli/dashboard.d.ts +2 -0
- package/dist/cli/dashboard.js +71 -6
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/extensions-client.d.ts +23 -0
- package/dist/cli/extensions-client.js +147 -0
- package/dist/cli/extensions-client.js.map +1 -0
- package/dist/cli/extensions.d.ts +14 -0
- package/dist/cli/extensions.js +181 -0
- package/dist/cli/extensions.js.map +1 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +21 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +107 -47
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.js +1 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/events/content.d.ts +43 -0
- package/dist/events/content.js +249 -0
- package/dist/events/content.js.map +1 -0
- package/dist/events/queue.d.ts +59 -0
- package/dist/events/queue.js +144 -0
- package/dist/events/queue.js.map +1 -0
- package/dist/events/validate.d.ts +22 -0
- package/dist/events/validate.js +542 -0
- package/dist/events/validate.js.map +1 -0
- package/dist/extensions/catalog.d.ts +33 -0
- package/dist/extensions/catalog.js +101 -0
- package/dist/extensions/catalog.js.map +1 -0
- package/dist/extensions/child-protocol.d.ts +38 -0
- package/dist/extensions/child-protocol.js +2 -0
- package/dist/extensions/child-protocol.js.map +1 -0
- package/dist/extensions/child.d.ts +1 -0
- package/dist/extensions/child.js +125 -0
- package/dist/extensions/child.js.map +1 -0
- package/dist/extensions/consent.d.ts +13 -0
- package/dist/extensions/consent.js +204 -0
- package/dist/extensions/consent.js.map +1 -0
- package/dist/extensions/environment.d.ts +1 -0
- package/dist/extensions/environment.js +12 -0
- package/dist/extensions/environment.js.map +1 -0
- package/dist/extensions/identity.d.ts +9 -0
- package/dist/extensions/identity.js +28 -0
- package/dist/extensions/identity.js.map +1 -0
- package/dist/extensions/log.d.ts +5 -0
- package/dist/extensions/log.js +80 -0
- package/dist/extensions/log.js.map +1 -0
- package/dist/extensions/manifest.d.ts +7 -0
- package/dist/extensions/manifest.js +213 -0
- package/dist/extensions/manifest.js.map +1 -0
- package/dist/extensions/types.d.ts +24 -0
- package/dist/extensions/types.js +2 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/extensions.d.ts +5 -0
- package/dist/extensions.js +2 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/approval-registry.d.ts +15 -2
- package/dist/runtime/approval-registry.js +173 -6
- package/dist/runtime/approval-registry.js.map +1 -1
- package/dist/runtime/capture.d.ts +22 -0
- package/dist/runtime/capture.js +352 -0
- package/dist/runtime/capture.js.map +1 -0
- package/dist/runtime/catalog.d.ts +39 -0
- package/dist/runtime/catalog.js +84 -0
- package/dist/runtime/catalog.js.map +1 -0
- package/dist/runtime/client.d.ts +2 -1
- package/dist/runtime/client.js +52 -65
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +49 -8
- package/dist/runtime/coordinator.js +380 -44
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/daemon.js +20 -6
- package/dist/runtime/daemon.js.map +1 -1
- package/dist/runtime/dashboard-workspace.js +5 -1
- package/dist/runtime/dashboard-workspace.js.map +1 -1
- package/dist/runtime/dashboard.d.ts +4 -0
- package/dist/runtime/dashboard.js +8 -0
- package/dist/runtime/dashboard.js.map +1 -1
- package/dist/runtime/definition.d.ts +6 -1
- package/dist/runtime/definition.js +31 -1
- package/dist/runtime/definition.js.map +1 -1
- package/dist/runtime/event-operation.d.ts +41 -0
- package/dist/runtime/event-operation.js +290 -0
- package/dist/runtime/event-operation.js.map +1 -0
- package/dist/runtime/event-owner.d.ts +94 -0
- package/dist/runtime/event-owner.js +429 -0
- package/dist/runtime/event-owner.js.map +1 -0
- package/dist/runtime/event-source.d.ts +39 -0
- package/dist/runtime/event-source.js +344 -0
- package/dist/runtime/event-source.js.map +1 -0
- package/dist/runtime/extension-instance.d.ts +61 -0
- package/dist/runtime/extension-instance.js +356 -0
- package/dist/runtime/extension-instance.js.map +1 -0
- package/dist/runtime/extension-protocol.d.ts +47 -0
- package/dist/runtime/extension-protocol.js +33 -0
- package/dist/runtime/extension-protocol.js.map +1 -0
- package/dist/runtime/extension-service.d.ts +10 -0
- package/dist/runtime/extension-service.js +35 -0
- package/dist/runtime/extension-service.js.map +1 -0
- package/dist/runtime/extension-supervisor.d.ts +33 -0
- package/dist/runtime/extension-supervisor.js +251 -0
- package/dist/runtime/extension-supervisor.js.map +1 -0
- package/dist/runtime/native-owner.js +7 -1
- package/dist/runtime/native-owner.js.map +1 -1
- package/dist/runtime/pagination.d.ts +9 -0
- package/dist/runtime/pagination.js +36 -0
- package/dist/runtime/pagination.js.map +1 -0
- package/dist/runtime/sdk-observation.d.ts +8 -0
- package/dist/runtime/sdk-observation.js +75 -0
- package/dist/runtime/sdk-observation.js.map +1 -0
- package/dist/runtime/sdk-projection.d.ts +8 -0
- package/dist/runtime/sdk-projection.js +19 -0
- package/dist/runtime/sdk-projection.js.map +1 -0
- package/dist/runtime/sdk-service.d.ts +11 -0
- package/dist/runtime/sdk-service.js +109 -0
- package/dist/runtime/sdk-service.js.map +1 -0
- package/dist/runtime/select-native.d.ts +5 -1
- package/dist/runtime/select-native.js +39 -18
- package/dist/runtime/select-native.js.map +1 -1
- package/dist/runtime/service.d.ts +16 -1
- package/dist/runtime/service.js +257 -8
- package/dist/runtime/service.js.map +1 -1
- package/dist/runtime/session-event-wire.d.ts +29 -0
- package/dist/runtime/session-event-wire.js +2 -0
- package/dist/runtime/session-event-wire.js.map +1 -0
- package/dist/runtime/session-events-service.d.ts +8 -0
- package/dist/runtime/session-events-service.js +124 -0
- package/dist/runtime/session-events-service.js.map +1 -0
- package/dist/runtime/session-events-transport.d.ts +8 -0
- package/dist/runtime/session-events-transport.js +142 -0
- package/dist/runtime/session-events-transport.js.map +1 -0
- package/dist/runtime/session-launcher.js +1 -1
- package/dist/runtime/session-launcher.js.map +1 -1
- package/dist/runtime/snapshots.d.ts +103 -0
- package/dist/runtime/snapshots.js +124 -0
- package/dist/runtime/snapshots.js.map +1 -0
- package/dist/runtime/startup-lock.d.ts +2 -0
- package/dist/runtime/startup-lock.js +49 -5
- package/dist/runtime/startup-lock.js.map +1 -1
- package/dist/runtime/state.d.ts +27 -0
- package/dist/runtime/state.js +90 -17
- package/dist/runtime/state.js.map +1 -1
- package/dist/runtime/task-data.d.ts +38 -0
- package/dist/runtime/task-data.js +2 -0
- package/dist/runtime/task-data.js.map +1 -0
- package/dist/runtime/transport.d.ts +14 -0
- package/dist/runtime/transport.js +168 -0
- package/dist/runtime/transport.js.map +1 -0
- package/dist/runtime/types.d.ts +50 -9
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/worker-client.js +44 -13
- package/dist/runtime/worker-client.js.map +1 -1
- package/dist/runtime/worker-event-channel.d.ts +30 -0
- package/dist/runtime/worker-event-channel.js +141 -0
- package/dist/runtime/worker-event-channel.js.map +1 -0
- package/dist/runtime/worker-event-protocol.d.ts +88 -0
- package/dist/runtime/worker-event-protocol.js +114 -0
- package/dist/runtime/worker-event-protocol.js.map +1 -0
- package/dist/runtime/worker-events.d.ts +73 -0
- package/dist/runtime/worker-events.js +704 -0
- package/dist/runtime/worker-events.js.map +1 -0
- package/dist/runtime/worker-server.d.ts +3 -1
- package/dist/runtime/worker-server.js +163 -27
- package/dist/runtime/worker-server.js.map +1 -1
- package/dist/sdk/connected-events.d.ts +3 -0
- package/dist/sdk/connected-events.js +259 -0
- package/dist/sdk/connected-events.js.map +1 -0
- package/dist/sdk/connected-types.d.ts +44 -0
- package/dist/sdk/connected-types.js +2 -0
- package/dist/sdk/connected-types.js.map +1 -0
- package/dist/sdk/connected.d.ts +3 -0
- package/dist/sdk/connected.js +235 -0
- package/dist/sdk/connected.js.map +1 -0
- package/dist/sdk/event-types.d.ts +182 -0
- package/dist/sdk/event-types.js +2 -0
- package/dist/sdk/event-types.js.map +1 -0
- package/dist/sdk/execution-definition.d.ts +3 -0
- package/dist/sdk/execution-definition.js +59 -0
- package/dist/sdk/execution-definition.js.map +1 -0
- package/dist/sdk/execution-driver.d.ts +6 -0
- package/dist/sdk/execution-driver.js +86 -0
- package/dist/sdk/execution-driver.js.map +1 -0
- package/dist/sdk/execution-observation.d.ts +3 -0
- package/dist/sdk/execution-observation.js +35 -0
- package/dist/sdk/execution-observation.js.map +1 -0
- package/dist/sdk/execution-options.d.ts +17 -0
- package/dist/sdk/execution-options.js +115 -0
- package/dist/sdk/execution-options.js.map +1 -0
- package/dist/sdk/execution-types.d.ts +74 -0
- package/dist/sdk/execution-types.js +2 -0
- package/dist/sdk/execution-types.js.map +1 -0
- package/dist/sdk/execution.d.ts +3 -0
- package/dist/sdk/execution.js +3 -0
- package/dist/sdk/execution.js.map +1 -0
- package/dist/sdk/hosted-error.d.ts +3 -0
- package/dist/sdk/hosted-error.js +14 -0
- package/dist/sdk/hosted-error.js.map +1 -0
- package/dist/sdk/hosted.d.ts +23 -0
- package/dist/sdk/hosted.js +204 -0
- package/dist/sdk/hosted.js.map +1 -0
- package/dist/sdk/runner.d.ts +5 -0
- package/dist/sdk/runner.js +109 -0
- package/dist/sdk/runner.js.map +1 -0
- package/dist/sdk/tools.js +4 -1
- package/dist/sdk/tools.js.map +1 -1
- package/package.json +7 -3
- package/sdk/access-config.md +2 -0
- package/sdk/adapter-contract.md +32 -2
- package/sdk/agent-skill.md +3 -2
- package/sdk/agent.md +1 -1
- package/sdk/approvals.md +2 -0
- package/sdk/cli/dashboard-design.md +37 -9
- package/sdk/cli/dashboard-inspection.md +14 -6
- package/sdk/cli/extensions.md +44 -0
- package/sdk/cli/index.md +27 -4
- package/sdk/cli/output.md +13 -1
- package/sdk/completion-notifications.md +3 -1
- package/sdk/config.md +31 -2
- package/sdk/copilot.md +1 -1
- package/sdk/cursor.md +2 -2
- package/sdk/diagnostics.md +68 -0
- package/sdk/distribution.md +16 -4
- package/sdk/events.md +339 -0
- package/sdk/examples/chat-tool.ts +126 -0
- package/sdk/execution.md +762 -0
- package/sdk/extensions.md +181 -0
- package/sdk/fx.md +4 -2
- package/sdk/harnesses.md +1 -1
- package/sdk/index.md +48 -21
- package/sdk/message-delivery.md +4 -0
- package/sdk/opencode.md +1 -1
- package/sdk/permissions.md +2 -0
- package/sdk/plugins/sub-agents.md +4 -2
- package/sdk/project-team.md +29 -1
- package/sdk/sessions.md +6 -0
- package/sdk/tools.md +3 -1
- package/sdk/v1-runtime.md +20 -8
- package/dist/cli/catalog.d.ts +0 -26
- package/dist/cli/catalog.js +0 -41
- package/dist/cli/catalog.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ Stay with your favorite coding agent. Ask it to delegate tasks across Codex, Cla
|
|
|
10
10
|
|
|
11
11
|
TypeScript definitions are optional. Add them when your coding agent needs reusable specialists with shared instructions, tools, or harness alternatives. Codex and Claude Code use eligible native subscription logins or explicitly configured API access. fx, OpenCode, and GitHub Copilot accept explicitly configured native logins, direct API keys, or Vercel AI Gateway access. Cursor uses an explicitly configured native CLI login or Cursor API key.
|
|
12
12
|
|
|
13
|
+
Use the Node.js execution SDK to build an agent-running UI or expose a specialist as a tool in an existing chat. The application owns its runner and can observe task states, approval requests, complete responses, and normalized live session events without invoking the Subharness CLI. Applications decide whether and where to persist those events; Subharness does not ship a chat database.
|
|
14
|
+
|
|
13
15
|
The library coordinates sessions, queues, and subagents. Harnesses own model execution, native tools, and context. You supply the working directory and any sandbox or worktree isolation.
|
|
14
16
|
|
|
15
17
|
## Installation
|
|
@@ -71,7 +73,72 @@ subharness run claude --prompt-file ./review-task.txt
|
|
|
71
73
|
subharness run codex --prompt-file - < ./task.txt
|
|
72
74
|
```
|
|
73
75
|
|
|
74
|
-
Use `subharness dashboard` in a terminal to watch agents managed by the local coordinator. The live view groups agents by repository/worktree, pins the checkout containing the launch directory first, and orders other groups by their latest agent update. Each group shows current agents followed by finished runs, with harness, task title, elapsed time, and status. Finished history is retained for the coordinator’s lifetime. Use Up/Down to select a run and Enter to open its agent session’s request history. Queued requests appear first, followed by remaining requests newest first. Enter
|
|
76
|
+
Use `subharness dashboard` in a terminal to watch agents managed by the local coordinator. The live view groups agents by repository/worktree, pins the checkout containing the launch directory first, and orders other groups by their latest agent update. Each group shows current agents followed by finished runs, with harness, task title, elapsed time, and status. Finished history is retained for the coordinator’s lifetime. Use Up/Down to select a run and Enter to open its agent session’s request history. Queued requests appear first, followed by remaining requests newest first. Enter on a request opens a dedicated task screen with the agent/task summary, original request, error and latest response. The screen subscribes to live events and renders arriving text, reasoning, tool and approval steps, with inline error notices; Enter expands a step’s bounded details. Past events are not loaded. Earlier content appears only if the native route later supplies it in a snapshot; chunk-only mid-item views remain incomplete. The screen keeps at most 500 steps, dropping the oldest with a visible omission notice. Leaving closes the subscription. The dashboard does not load user extensions. Escape returns to the request list, then to the overview. Completed statuses are green, and a compact Sub-agents footer summarizes direct child agents. The overview has no application banner or footer. Ctrl+C closes the view without stopping agents.
|
|
77
|
+
|
|
78
|
+
## Run agents from application code
|
|
79
|
+
|
|
80
|
+
Install `subharness` as an application dependency:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
npm install subharness
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Create an application-owned runner and pass an in-memory definition:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { agent, codex, createRunner } from "subharness";
|
|
90
|
+
|
|
91
|
+
const reviewer = agent({
|
|
92
|
+
name: "reviewer",
|
|
93
|
+
description: "Reviews the requested changes.",
|
|
94
|
+
instructions: "Report concrete findings with file references.",
|
|
95
|
+
harness: codex({ model: "CODEX_MODEL_ID" }),
|
|
96
|
+
});
|
|
97
|
+
const runner = createRunner();
|
|
98
|
+
try {
|
|
99
|
+
const session = await runner.createSession(reviewer, { cwd: "/absolute/project/path" });
|
|
100
|
+
const { task } = await session.prompt("Review the current diff.");
|
|
101
|
+
// A separate UI handler must answer any pending approvals.
|
|
102
|
+
console.log((await task.result).text);
|
|
103
|
+
// Reuse session.prompt(...) for follow-ups in the same conversation.
|
|
104
|
+
} finally {
|
|
105
|
+
await runner.close();
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Replace the model placeholder with an available native model. A UI can consume `task.watch({ signal })` for current and changed snapshots. Aborting observation leaves execution running; a Stop action calls `task.cancel()`. Keep the runner for the chat/job lifetime and `await runner.close()` when that scope ends. Native harnesses still need installation and authorized access.
|
|
110
|
+
|
|
111
|
+
Tool functions can close over application services. Embedded sessions keep them in the host process, with its unchanged cwd and environment. Declared subagents use hosted tools instead of CLI launchers. An existing chat app can register a tool whose `execute` calls `session.prompt`, while retaining its own model loop, authorization, and UI transport.
|
|
112
|
+
|
|
113
|
+
To connect a UI backend to agents started by the CLI, use the shared coordinator:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { connect } from "subharness";
|
|
117
|
+
|
|
118
|
+
const client = await connect(); // Connects or starts an empty coordinator.
|
|
119
|
+
try {
|
|
120
|
+
const { items: sessions } = await client.sessions.list();
|
|
121
|
+
console.log(sessions);
|
|
122
|
+
// client.sessions.get(id) retrieves the same conversation used by the CLI.
|
|
123
|
+
} finally {
|
|
124
|
+
await client.disconnect(); // Execution continues in the shared coordinator.
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Use `connect({ start: false })` for strict attachment. Approval requests advertise actions; submit a chosen action with `client.approvals.respond(request.id, { actionId: action.id })`, adding explicitly selected grants when required. Applications can render the supplied labels without provider-specific branches.
|
|
129
|
+
|
|
130
|
+
The SDK exposes complete responses, task states, approvals and [normalized live session events](sdk/events.md), including bounded assistant text, provider-exposed reasoning and tool previews where the native route supports them. Await `events.open({ scope })` before submitting work to observe its initial events. Only events accepted after registration are delivered; applications own any event persistence. Complete-response history keeps its existing execution-owner lifetime. See the [execution API](sdk/execution.md) and [chat-tool example](sdk/examples/chat-tool.ts) for lifecycle details. Embedded access is explicit through `createRunner({ access, env })`; connected sessions use the CLI's project access settings.
|
|
131
|
+
|
|
132
|
+
## Add custom event handlers
|
|
133
|
+
|
|
134
|
+
[User extensions](sdk/extensions.md) are self-contained compiled ESM modules installed under `~/.subharness/extensions/<id>/` or a checkout's `.subharness/extensions/<id>/`. Explicit per-user consent in the owner-only `~/.subharness/extensions.json` file selects which newly admitted coordinator sessions they observe:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
subharness extensions list
|
|
138
|
+
subharness extensions enable global:tool-result-logger
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The coordinator starts each enabled extension in a separate supervised process when its first matching session is admitted. Discovery reads static manifests only. Global extensions receive new coordinator sessions across workspaces; repository extensions receive new sessions in their enabled checkout. This applies to both CLI and connected SDK creation. Embedded runners do not load extensions; application code consumes `events.open` directly. See the [complete logger example](sdk/extensions.md#complete-tool-result-logger) and [extension commands](sdk/cli/extensions.md).
|
|
75
142
|
|
|
76
143
|
## Define a reusable specialist
|
|
77
144
|
|
|
@@ -109,9 +176,10 @@ subharness send <session-id> --delivery steer --prompt "Keep the existing API co
|
|
|
109
176
|
subharness wait <task-id> [--after <response-id>]
|
|
110
177
|
subharness status <task-id> --full
|
|
111
178
|
subharness cancel <task-id>
|
|
179
|
+
subharness close <session-id>
|
|
112
180
|
```
|
|
113
181
|
|
|
114
|
-
Commands print task/session identifiers and return one complete response with its response identifier and task state. `wait` returns or awaits the first retained response when `--after` is omitted, and the next response after that cursor when it is supplied. Pending descendant work can continue after that command exits. Run or wait commands can use your assistant's background-task facilities. Native steering is used when supported; otherwise `steer` behaves as `interrupt`, cancels affected descendants, preserves independently queued tasks, and reports the effective mode.
|
|
182
|
+
Commands print task/session identifiers and return one complete response with its response identifier and task state. `wait` returns or awaits the first retained response when `--after` is omitted, and the next response after that cursor when it is supplied. Pending descendant work can continue after that command exits. Run or wait commands can use your assistant's background-task facilities. Native steering is used when supported; otherwise `steer` behaves as `interrupt`, cancels affected descendants, preserves independently queued tasks, and reports the effective mode. Cancel and interrupt stop the active native turn; close a session when it is no longer needed so the native harness can clean up background tool processes it tracks across turns.
|
|
115
183
|
|
|
116
184
|
Long prompts can use `--prompt-file`. Output is compact text by default; `--format jsonl` selects typed integration records without forwarding native token or tool streams.
|
|
117
185
|
|
|
@@ -181,7 +249,7 @@ subharness run subagent:reviewer --cwd /path/to/worktree --prompt "Review the im
|
|
|
181
249
|
|
|
182
250
|
The library supplies the parent context. Declaring `subagents` authorizes their invocation. Claude Code receives permissions scoped to its session launcher, declared children, and coordination commands; native approval rules and sandbox restrictions still apply. Children receive explicit task context rather than a copy of the parent's transcript. Cancellation propagates through delegated descendants; a parent task completes after child results and its own continuation are handled.
|
|
183
251
|
|
|
184
|
-
This checkout includes
|
|
252
|
+
This checkout includes ten [repository roles](sdk/project-team.md): the Astra `architect` and `planner`; Sol `developer` and `integrator`; Luna `api-researcher` and `systems-researcher`; Opus `reviewer`; and, through fx, Sonnet 5.5 `get-context`, Gemini `researcher`, and Fable 5.1 `visual-engineer`. Reusable techniques live in `.agents/skills/` and are read only when the task needs them; a new technique does not require another agent definition. Discover the roles with `subharness list` and invoke them through `repo:<name>`. Skill loading, native capability limits, and the image-task execution path are documented with the team.
|
|
185
253
|
|
|
186
254
|
## Boundaries
|
|
187
255
|
|
|
@@ -214,8 +282,8 @@ pnpm run check
|
|
|
214
282
|
pnpm run check:package
|
|
215
283
|
```
|
|
216
284
|
|
|
217
|
-
`pnpm run check` builds the current SDK first, then runs TypeScript checking and behavioral tests. Building first lets repository agent definitions import the package's current exports on a clean checkout and prevents tests from exercising stale build output. Tests cover native protocol boundaries, credential selection, worktrees, task queues, cancellation races, nested CLI execution, and process lifetime.
|
|
285
|
+
`pnpm run check` builds the current SDK first, then runs TypeScript checking and behavioral tests. Building first lets repository agent definitions import the package's current exports on a clean checkout and prevents tests from exercising stale build output. Tests cover native protocol boundaries, credential selection, worktrees, task queues, cancellation races, nested CLI execution, and process lifetime. The default suite runs two test files at a time to keep subprocess-heavy protocol fixtures within their timing budgets.
|
|
218
286
|
|
|
219
|
-
`pnpm run check:package` packs the SDK and verifies installation, imports, and CLI agent discovery in a temporary consumer
|
|
287
|
+
`pnpm run check:package` packs the current SDK and verifies the packaged file boundary, installation, execution SDK imports, `./extensions` subpath resolution, definition and `SessionEvent` type imports from `subharness/extensions`, extension compilation without a Subharness runtime import, inline execution against a controlled native protocol fixture, and installed CLI agent discovery in a clean temporary consumer without source-checkout access. It downloads dependencies from the public npm registry with install lifecycle scripts disabled and uses a fake native harness without calling a coding model.
|
|
220
288
|
|
|
221
289
|
The [SDK documentation](sdk/index.md) describes the final contracts. [AGENTS.md](AGENTS.md) defines the project's documentation, TDD, and review workflow. Comparative research and review evidence are kept in the ignored `.context` directory.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { MessagePort } from "node:worker_threads";
|
|
2
|
+
import type { AdapterDraft, AudienceToken } from "./event-types.js";
|
|
3
|
+
import type { SessionEventCapabilities } from "../sdk/event-types.js";
|
|
4
|
+
import type { ClaudeObservationParentMessage } from "./claude-worker-protocol.js";
|
|
5
|
+
export declare const CLAUDE_EVENT_CAPABILITIES: SessionEventCapabilities;
|
|
6
|
+
type DraftSink = (audience: AudienceToken, draft: AdapterDraft) => void;
|
|
7
|
+
export declare class ClaudeEventNormalizer {
|
|
8
|
+
private readonly secrets;
|
|
9
|
+
private readonly sink;
|
|
10
|
+
private operationId?;
|
|
11
|
+
private readonly audiences;
|
|
12
|
+
private readonly delivered;
|
|
13
|
+
private readonly text;
|
|
14
|
+
private readonly openItems;
|
|
15
|
+
private readonly identities;
|
|
16
|
+
private readonly blocks;
|
|
17
|
+
private readonly tools;
|
|
18
|
+
private streamMessageId?;
|
|
19
|
+
private syntheticOrdinal;
|
|
20
|
+
private identityOverflowed;
|
|
21
|
+
private finalCandidate?;
|
|
22
|
+
constructor(secrets: readonly string[], sink: DraftSink);
|
|
23
|
+
setDemand(operationId: string, audiences: readonly AudienceToken[]): void;
|
|
24
|
+
handle(value: unknown): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
private trackStreamMetadata;
|
|
27
|
+
private trackAssistantMetadata;
|
|
28
|
+
private streamBlock;
|
|
29
|
+
private syntheticItemKey;
|
|
30
|
+
private handleStream;
|
|
31
|
+
private handleAssistant;
|
|
32
|
+
complete(value: unknown): string | undefined;
|
|
33
|
+
private completeUnsafe;
|
|
34
|
+
private finishStreamBlock;
|
|
35
|
+
private handleUser;
|
|
36
|
+
private pushDelta;
|
|
37
|
+
private captureError;
|
|
38
|
+
private admitItem;
|
|
39
|
+
private captureIdentityOverflow;
|
|
40
|
+
private emitIdentityOverflow;
|
|
41
|
+
private captureOpenItemOverflow;
|
|
42
|
+
private emit;
|
|
43
|
+
}
|
|
44
|
+
export declare class ClaudeObservationChannel {
|
|
45
|
+
private readonly port;
|
|
46
|
+
private operationId?;
|
|
47
|
+
private generation;
|
|
48
|
+
private readonly audiences;
|
|
49
|
+
private readonly normalizer;
|
|
50
|
+
private readonly drainWaiters;
|
|
51
|
+
private completeAck?;
|
|
52
|
+
constructor(port: MessagePort, secrets: readonly string[]);
|
|
53
|
+
control(message: ClaudeObservationParentMessage): void;
|
|
54
|
+
observe(message: unknown): boolean;
|
|
55
|
+
complete(message: unknown): Promise<void>;
|
|
56
|
+
close(): void;
|
|
57
|
+
private demand;
|
|
58
|
+
private reportInvalidDemand;
|
|
59
|
+
private offer;
|
|
60
|
+
private pump;
|
|
61
|
+
private acknowledge;
|
|
62
|
+
private failAudience;
|
|
63
|
+
private acknowledgeComplete;
|
|
64
|
+
private drained;
|
|
65
|
+
private checkDrained;
|
|
66
|
+
private isDrained;
|
|
67
|
+
private retireAudiences;
|
|
68
|
+
private reset;
|
|
69
|
+
private post;
|
|
70
|
+
}
|
|
71
|
+
export {};
|