subharness 0.0.7 → 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 +18 -6
- 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 +3 -1
- package/dist/cli/args.js +25 -1
- package/dist/cli/args.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 +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 +54 -2
- 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/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 +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.js +45 -13
- package/dist/runtime/capture.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +8 -4
- package/dist/runtime/coordinator.js +128 -26
- 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/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/select-native.d.ts +2 -1
- package/dist/runtime/select-native.js +26 -2
- package/dist/runtime/select-native.js.map +1 -1
- package/dist/runtime/service.d.ts +5 -0
- package/dist/runtime/service.js +83 -9
- 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 +22 -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 +63 -8
- 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/adapter-contract.md +25 -3
- package/sdk/agent-skill.md +3 -2
- 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 +2 -2
- 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 +13 -3
- package/sdk/events.md +339 -0
- package/sdk/execution.md +26 -7
- package/sdk/extensions.md +181 -0
- package/sdk/fx.md +4 -2
- package/sdk/harnesses.md +1 -1
- package/sdk/index.md +3 -0
- package/sdk/message-delivery.md +2 -0
- package/sdk/opencode.md +1 -1
- package/sdk/project-team.md +10 -4
- package/sdk/sessions.md +4 -0
- package/sdk/v1-runtime.md +14 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ 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,
|
|
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
14
|
|
|
15
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.
|
|
16
16
|
|
|
@@ -73,7 +73,7 @@ subharness run claude --prompt-file ./review-task.txt
|
|
|
73
73
|
subharness run codex --prompt-file - < ./task.txt
|
|
74
74
|
```
|
|
75
75
|
|
|
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
|
|
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
77
|
|
|
78
78
|
## Run agents from application code
|
|
79
79
|
|
|
@@ -127,7 +127,18 @@ try {
|
|
|
127
127
|
|
|
128
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
129
|
|
|
130
|
-
The SDK exposes complete responses, task states, and
|
|
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).
|
|
131
142
|
|
|
132
143
|
## Define a reusable specialist
|
|
133
144
|
|
|
@@ -165,9 +176,10 @@ subharness send <session-id> --delivery steer --prompt "Keep the existing API co
|
|
|
165
176
|
subharness wait <task-id> [--after <response-id>]
|
|
166
177
|
subharness status <task-id> --full
|
|
167
178
|
subharness cancel <task-id>
|
|
179
|
+
subharness close <session-id>
|
|
168
180
|
```
|
|
169
181
|
|
|
170
|
-
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.
|
|
171
183
|
|
|
172
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.
|
|
173
185
|
|
|
@@ -237,7 +249,7 @@ subharness run subagent:reviewer --cwd /path/to/worktree --prompt "Review the im
|
|
|
237
249
|
|
|
238
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.
|
|
239
251
|
|
|
240
|
-
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.
|
|
241
253
|
|
|
242
254
|
## Boundaries
|
|
243
255
|
|
|
@@ -272,6 +284,6 @@ pnpm run check:package
|
|
|
272
284
|
|
|
273
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.
|
|
274
286
|
|
|
275
|
-
`pnpm run check:package` packs the SDK and verifies installation,
|
|
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.
|
|
276
288
|
|
|
277
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 {};
|