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
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# User extensions
|
|
2
|
+
|
|
3
|
+
Extensions are user-developed functionality that observes [live session events](events.md). The coordinator supervises a separate child process for each enabled extension instance. The CLI dashboard and embedded runners do not load extension modules. SDK applications implement their own behavior by consuming `runner.events.open` or `client.events.open` directly.
|
|
4
|
+
|
|
5
|
+
Extensions have no UI, terminal renderer, dashboard access or execution-control hooks. They cannot block, modify or approve native operations through this API. They may use their own code and services to handle delivered events, including explicitly storing data in a location selected by the user.
|
|
6
|
+
|
|
7
|
+
## Definition API
|
|
8
|
+
|
|
9
|
+
The `subharness/extensions` subpath supplies authoring types. A module default-exports a plain object conforming to `ExtensionDefinition`; its Subharness imports are type-only and disappear from compiled JavaScript.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import type { SessionEvent } from "subharness/extensions";
|
|
13
|
+
|
|
14
|
+
export interface ExtensionContext {
|
|
15
|
+
readonly extensionId: string;
|
|
16
|
+
readonly reference: string;
|
|
17
|
+
readonly workspace?: string;
|
|
18
|
+
readonly signal: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
export interface ExtensionInstance {
|
|
21
|
+
onEvent(event: SessionEvent): void | Promise<void>;
|
|
22
|
+
dispose?(): void | Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface ExtensionDefinition {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly apiVersion: 1;
|
|
27
|
+
setup(context: ExtensionContext): ExtensionInstance | Promise<ExtensionInstance>;
|
|
28
|
+
}
|
|
29
|
+
export interface ExtensionManifest {
|
|
30
|
+
readonly manifestVersion: 1;
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly version: string;
|
|
33
|
+
readonly apiVersion: 1;
|
|
34
|
+
readonly eventVersion: 1;
|
|
35
|
+
readonly entry: string;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`id` matches `[a-zA-Z][a-zA-Z0-9_-]{0,63}` and agrees with the manifest and installation directory. `context.extensionId` is that ID. `context.reference` is its qualified `"global:id"` or `"repo:id"` reference. `context.workspace` is the canonical checkout for a repository extension and is absent for a global extension. `signal` represents the extension instance's lifetime; aborting it does not cancel an agent. The context contains no CLI/dashboard handle, native session, execution controls, credentials or tool registry. Every authoring type, including `SessionEvent` and the types it references, is importable from `subharness/extensions`, without requiring a runtime import by the extension. Every event, subscription and capability type is exported from `subharness` and re-exported as a type from `subharness/extensions`.
|
|
40
|
+
|
|
41
|
+
`setup` allocates the instance's resources. `onEvent` receives `SessionEvent` objects directly, narrowed by their `type` discriminator. Calls are serial in delivery order within one instance, and the host awaits each returned promise before calling that instance again. Return values do not modify execution or consume events away from other subscribers. Separate processes have independent queues and handlers. `dispose` releases the instance's resources. These are the only extension hooks.
|
|
42
|
+
|
|
43
|
+
## Coordinator ownership and delivery
|
|
44
|
+
|
|
45
|
+
Within a coordinator, an extension instance is identified by its qualified reference and, for a repository extension, its canonical checkout. Global instances have no checkout component. Failure state, admission eligibility and re-enablement are tracked separately for each instance identity. Repository instances with the same `repo:id` in different checkouts are independent; enabling in one checkout affects only that checkout's instance.
|
|
46
|
+
|
|
47
|
+
Enablement is resolved when a coordinator session is admitted, for both CLI and connected SDK creation. Every enabled global extension receives that session's events; enabled repository extensions receive only sessions admitted in their canonical checkout. Sessions keep that admission-time selection. Enabling an extension does not attach it to already admitted sessions, and disabling stops its eligibility for newly admitted sessions. It does not cancel agents or withdraw delivery for sessions already assigned to the running instance.
|
|
48
|
+
|
|
49
|
+
Extension admission is fail-open. Extension discovery or consent-read failures never block session admission or change the agent's task outcome. The session is admitted without extension delivery, and the coordinator retains a safe admission diagnostic for `subharness extensions list`. Admission diagnostics are separate from instance diagnostics because these failures may occur before an extension identity is known.
|
|
50
|
+
|
|
51
|
+
An extension process starts when its first matching session is admitted. Subscription registration is part of session admission, before that session's initial events are accepted; subsequent matching sessions are delivered to the applicable running instance. No agent waits for an extension handler. Startup/setup queues obey the same delivery bounds, so slow initialization cannot delay native execution. The instance remains owned by the coordinator until coordinator close, unless failure disables it. It does not stop merely because a dashboard exits, an SDK client disconnects, or one session finishes. Embedded runners never discover or start user extensions.
|
|
52
|
+
|
|
53
|
+
A failed instance stays disabled for the rest of its coordinator's lifetime and is never automatically restarted. Running `subharness extensions enable <global:id|repo:id>` again saves consent and notifies a running coordinator to make a replacement for that instance identity eligible for newly admitted sessions; a new process starts at its first matching admission. With no running coordinator, saving consent is sufficient. If notification fails, consent remains saved, the command warns that the failure state clears on coordinator restart, and exits `0`; it does not claim the running coordinator accepted the reset. Sessions assigned to the failed instance are not reassigned. The failed instance's diagnostic remains visible through `subharness extensions list` for that coordinator's lifetime. Restarting the coordinator resets runtime failure state.
|
|
54
|
+
|
|
55
|
+
The coordinator supervises the child and forwards only normalized, redacted events for its assigned sessions over a private, bounded IPC channel. Execution workers do not import extension code. Crashes, synchronous hangs, rejected handlers, timeouts and backpressure are isolated to the affected child; they do not block agents, coordinator control operations or other extensions. Extension code is trusted user-privileged Node.js code, not a security sandbox. Process supervision isolates delivery/execution lifetimes but does not grant protection from arbitrary filesystem or network side effects of explicitly enabled code.
|
|
56
|
+
|
|
57
|
+
The child runs with the extension directory as its working directory and a minimal environment containing only `PATH`, `HOME`, `TMPDIR` and locale variables. `NODE_OPTIONS`, the coordinator token, all `AGENT_*` variables, provider credentials, Gateway or OIDC tokens, and dotenv values are excluded. Its stdin is closed. Stdout and stderr go to an owner-private log for that instance. The coordinator compacts the log after it exceeds 1.5 MiB, trimming it back to the most recent 1 MiB. Global instances use `<stateDirectory>/extensions/global-<id>.log`. Repository instances use `<stateDirectory>/extensions/repo-<id>-<checkout-hash>.log`, where `<checkout-hash>` is the first 12 hex characters of the SHA-256 of the canonical checkout path. These filenames contain no colons. The selected coordinator's state directory follows the existing [selection rule](execution.md#ownership-and-transport-boundaries): explicit `ConnectOptions.stateDirectory`, then `AGENT_STATE_DIR`, then `~/.subharness/state/shared`. CLI commands use the environment/default selection rule. `subharness extensions list` shows the actual log path for each instance. Log contents never enter execution output, safe diagnostics or the dashboard. Failure to open, write or close this log never stops the extension instance. Unwritable output is discarded, and the instance reports the informational `EXTENSION_LOG_UNAVAILABLE` diagnostic.
|
|
58
|
+
|
|
59
|
+
## Bounds, shutdown and diagnostics
|
|
60
|
+
|
|
61
|
+
Setup and each handler have a five-second deadline. At most 128 events or 1 MiB of serialized event data may wait for an instance, whichever bound is reached first. Exceeding the delivery bound disables that instance with `EXTENSION_BACKPRESSURE`. A throw/rejection uses `EXTENSION_HANDLER_FAILED`; an asynchronous or synchronous deadline failure uses `EXTENSION_TIMEOUT`. The supervisor can stop a blocked child without waiting for its JavaScript event loop.
|
|
62
|
+
|
|
63
|
+
On shutdown or disablement caused by failure, delivery stops and pending undelivered events are released. The child lifetime signal aborts and `dispose` is called once when the process can cooperate, with a one-second budget. The coordinator terminates an unresponsive child; a crash or forced termination cannot guarantee disposal or completion of a file write. Side effects already performed are not rolled back, and delivery is not an exactly-once transaction. A successful shutdown confirms the supervised process has stopped; cleanup failures are explicit.
|
|
64
|
+
|
|
65
|
+
Manifest/module/export/dependency failures use `EXTENSION_LOAD_FAILED`, and API/event-version mismatches use `EXTENSION_INCOMPATIBLE`. Disposal failures use `EXTENSION_DISPOSE_FAILED`. An unexpected extension-process exit uses `EXTENSION_EXITED` and disables the instance under the same failed-instance lifetime and re-enablement rules as other failures. Messages identify the qualified reference, repository checkout when applicable, and failure phase, contain at most 1 KiB of safe text, and omit event content, raw exception messages/stacks, credentials and raw stdout/stderr. The CLI displays `EXTENSION_*` codes with their safe messages only through `subharness extensions list`. These failures also remain available through the coordinator's existing safe diagnostics. The dashboard neither loads nor hosts extensions and does not display extension diagnostics. Extension output never enters execution-command output, these diagnostics or the dashboard. Runtime failures remain visible through `subharness extensions list` for the owning coordinator's lifetime; they disable that runtime instance without changing stored consent and are not task failures. Runtime status reports each instance as `running`, `idle` or `disabled` and retains at most its eight most recent diagnostics. Each diagnostic records whether it disabled the instance and when it occurred.
|
|
66
|
+
|
|
67
|
+
`subharness extensions list` and the coordinator's extension-status operation each report at most 256 instances. When more instances exist, each reports the exact number omitted. The status operation also retains at most the 16 most recent admission diagnostics, separately from instance diagnostics. An admission diagnostic includes a workspace when one was resolved safely.
|
|
68
|
+
|
|
69
|
+
## Manifest, discovery and consent
|
|
70
|
+
|
|
71
|
+
Install a compiled extension in one of these directories:
|
|
72
|
+
|
|
73
|
+
- `~/.subharness/extensions/<id>/` for a global installation.
|
|
74
|
+
- `<worktree>/.subharness/extensions/<id>/` for a repository installation.
|
|
75
|
+
|
|
76
|
+
Each directory contains `extension.json`, a compiled ESM entry and any packaged dependencies. A compiled extension is self-contained: it must not require a runtime import of Subharness. A `.mjs` entry can use Node's ESM loading directly; a `.js` entry requires suitable ESM package metadata. There is no TypeScript evaluation or build during discovery or activation.
|
|
77
|
+
|
|
78
|
+
Discovery reads static manifests only, without importing agent or extension modules. Repository scope uses the nearest canonical Git worktree root; outside Git, it uses the command's directory. Linked worktrees are separate repository scopes. Discovery does not traverse symlink directories or search parent repositories. Each `extension.json` is at most 16 KiB, and any `package.json` read from an extension directory is at most 64 KiB. Unknown fields, invalid IDs/versions, unsupported schema versions, missing entries and entry paths escaping the installation directory fail validation. `version` is the extension artifact's semantic version. Manifest/API/event versions are independent of the core package's npm version. `eventVersion` names the `SessionEvent` schema version and must equal `EventBase.version`. `apiVersion` gates the `ExtensionDefinition` contract. A mismatch of either version uses `EXTENSION_INCOMPATIBLE`.
|
|
79
|
+
|
|
80
|
+
Nothing executes merely because a repository contains extension files. The current user explicitly enables an installation with `subharness extensions enable <global:id|repo:id>`. Consent is stored in `~/.subharness/extensions.json` with owner-only permissions, using the [extension consent schema](config.md#extension-consent-and-logs). Repository enablement is keyed by canonical checkout and never stored in repository files. Enabled repository code is the checkout's current code when the supervised process loads it. Consent persists after edits; a running process does not hot-reload its module. Installation sources do not silently replace one another: global and repository references remain qualified and independently enabled.
|
|
81
|
+
|
|
82
|
+
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. 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 its permissions.
|
|
83
|
+
|
|
84
|
+
The coordinator validates compatibility before starting the child, and the child validates the default export before setup. Node.js 22.18 or newer is required. Missing dependencies and invalid modules fail safely; no automatic installation is performed. Discovery/enablement can report static compatibility, but cannot prove module initialization will succeed without executing it. [Extension commands](cli/extensions.md) define management output and failure reporting.
|
|
85
|
+
|
|
86
|
+
## Complete tool-result logger
|
|
87
|
+
|
|
88
|
+
This extension records completed tool-call observations as JSONL. Set `outputDirectory` to an absolute directory chosen by the user before compiling. The code uses only Node built-ins at runtime. The log contains the bounded, redacted previews supplied by events, not unrestricted native payloads. The extension owns this persistence and its file lifecycle.
|
|
89
|
+
|
|
90
|
+
Save this TypeScript module as `index.mts` in the extension's source project and compile it to `dist/index.mjs`:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import type { ExtensionDefinition } from "subharness/extensions";
|
|
94
|
+
import { mkdir, open } from "node:fs/promises";
|
|
95
|
+
import { isAbsolute, join } from "node:path";
|
|
96
|
+
|
|
97
|
+
// Choose this path when preparing the extension, independently of process cwd.
|
|
98
|
+
const outputDirectory = "/absolute/path/chosen/by/the/user";
|
|
99
|
+
|
|
100
|
+
const extension = {
|
|
101
|
+
id: "tool-result-logger",
|
|
102
|
+
apiVersion: 1,
|
|
103
|
+
async setup({ extensionId, reference, workspace, signal }) {
|
|
104
|
+
if (!isAbsolute(outputDirectory)) throw new Error("An absolute output directory is required");
|
|
105
|
+
await mkdir(outputDirectory, { recursive: true, mode: 0o700 });
|
|
106
|
+
// A separate file per process prevents independent instances sharing a writer.
|
|
107
|
+
const filename = join(outputDirectory, `${extensionId}-${process.pid}.jsonl`);
|
|
108
|
+
const file = await open(filename, "a", 0o600);
|
|
109
|
+
return {
|
|
110
|
+
async onEvent(event) {
|
|
111
|
+
if (signal.aborted || event.type !== "item.completed" || event.item.kind !== "tool") return;
|
|
112
|
+
const item = event.item;
|
|
113
|
+
await file.appendFile(JSON.stringify({
|
|
114
|
+
version: 1,
|
|
115
|
+
reference,
|
|
116
|
+
workspace,
|
|
117
|
+
eventId: event.eventId,
|
|
118
|
+
ownerId: event.ownerId,
|
|
119
|
+
sequence: event.sequence,
|
|
120
|
+
observedAt: event.observedAt,
|
|
121
|
+
sessionId: event.sessionId,
|
|
122
|
+
taskId: event.taskId,
|
|
123
|
+
turnId: event.turnId,
|
|
124
|
+
itemId: item.itemId,
|
|
125
|
+
name: item.name,
|
|
126
|
+
state: item.state,
|
|
127
|
+
completion: event.completion,
|
|
128
|
+
input: item.input,
|
|
129
|
+
output: item.output,
|
|
130
|
+
exitCode: item.exitCode,
|
|
131
|
+
durationMs: item.durationMs,
|
|
132
|
+
}) + "\n", "utf8");
|
|
133
|
+
},
|
|
134
|
+
async dispose() {
|
|
135
|
+
await file.close();
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
} satisfies ExtensionDefinition;
|
|
140
|
+
|
|
141
|
+
export default extension;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Use this `extension.json` beside the `dist/` directory:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"manifestVersion": 1,
|
|
149
|
+
"id": "tool-result-logger",
|
|
150
|
+
"version": "1.0.0",
|
|
151
|
+
"apiVersion": 1,
|
|
152
|
+
"eventVersion": 1,
|
|
153
|
+
"entry": "./dist/index.mjs"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
TypeScript and Subharness types are development dependencies of the source project. For example, with a compatible local TypeScript compiler, Node types and Subharness declarations installed, compile using:
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
npx --no-install tsc index.mts --outDir dist --target ES2022 --module NodeNext --moduleResolution NodeNext --strict --skipLibCheck
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The installed artifact needs only `extension.json` and `dist/index.mjs` for this example; its type-only import is erased. Copy that prepared artifact into an absent destination, then enable it:
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
mkdir -p ~/.subharness/extensions
|
|
167
|
+
cp -R /path/to/compiled-tool-result-logger ~/.subharness/extensions/tool-result-logger
|
|
168
|
+
subharness extensions enable global:tool-result-logger
|
|
169
|
+
subharness extensions list
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
For repository scope, run from the worktree root:
|
|
173
|
+
|
|
174
|
+
```sh
|
|
175
|
+
mkdir -p .subharness/extensions
|
|
176
|
+
cp -R /path/to/compiled-tool-result-logger .subharness/extensions/tool-result-logger
|
|
177
|
+
subharness extensions enable repo:tool-result-logger
|
|
178
|
+
subharness extensions list
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Enable only the installation(s) whose logging behavior is wanted. The first newly admitted matching coordinator session starts the extension. Its `item.completed` observations include succeeded, failed, cancelled or unknown tool outcomes without inferring success. Logs can contain source code and paths; the user owns their storage, permissions, retention and deletion. Directory/file mode arguments apply when this example creates them and do not tighten permissions on an existing path. A handler failure or slow storage disables the extension instance with a safe list diagnostic, without delaying the agent. An abrupt child exit can leave a partial final line; consumers must tolerate that outcome.
|
package/sdk/fx.md
CHANGED
|
@@ -108,10 +108,12 @@ Native permissions remain authoritative. fx ACP does not expose scoped allow rul
|
|
|
108
108
|
|
|
109
109
|
## Session lifecycle
|
|
110
110
|
|
|
111
|
-
Each library session owns one native ACP conversation. Successful follow-ups reuse its session identifier. The
|
|
111
|
+
Each library session owns one native ACP conversation. Successful follow-ups reuse its session identifier. The complete-response result selects text from the last native message identifier in the completed prompt, excluding thinking, earlier progress messages, tool traffic and protocol diagnostics from that result. Separate [live session events](events.md#effective-route-capabilities) expose bounded assistant and tool previews; native reasoning emission remains unverified. Live observation does not change final-response selection. Native ACP uses the same message type for assistant responses and operational notices, so the last message can be a native notice. Responses retain the library's size limit. Only `end_turn` is successful; native errors and other stop reasons reject the task instead of returning a successful empty response.
|
|
112
|
+
|
|
113
|
+
Malformed optional live-event data emits at most one nonfatal adapter capture error per turn with code `CAPTURE_FAILED`. The capture error does not change the task's execution outcome.
|
|
112
114
|
|
|
113
115
|
Native auxiliary calls, such as title generation or permission classification, can use models selected by fx and consume Gateway usage. They do not change the requested task model and are not library fallback. The adapter preserves native preferences for those operations.
|
|
114
116
|
|
|
115
|
-
The coordinator owns FIFO task queuing. This adapter reports native steering as unsupported before changing execution; the coordinator applies the existing `steer`-to-`interrupt` behavior. Interruption sends native cancellation and waits for the active prompt and admitted tool callbacks to stop. Unconfirmed cancellation fails explicitly and keeps queued dispatch paused. Prompt-free recovery returns `RECOVERY_UNSUPPORTED`; no task is silently replayed.
|
|
117
|
+
The coordinator owns FIFO task queuing. This adapter reports native steering as unsupported before changing execution; the coordinator applies the existing `steer`-to-`interrupt` behavior. Interruption sends native cancellation and waits for the active prompt and admitted tool callbacks to stop. If a transport failure has started native process retirement, the adapter waits at most six seconds for that retirement to confirm the stop, covering the five-second graceful termination window plus confirmation margin. Unconfirmed cancellation fails explicitly and keeps queued dispatch paused. Prompt-free recovery returns `RECOVERY_UNSUPPORTED`; no task is silently replayed.
|
|
116
118
|
|
|
117
119
|
Closing a session stops the native process and its local tool endpoint. Native diagnostic output is not forwarded because it can contain credentials. Errors identify the affected operation without exposing credentials or raw provider responses.
|
package/sdk/harnesses.md
CHANGED
|
@@ -10,7 +10,7 @@ An agent declares one harness configuration or a nonempty ordered array through
|
|
|
10
10
|
|
|
11
11
|
Before submitting work, known unavailability, such as a missing executable or missing eligible login, permits trying the next enabled connection or alternative. Invalid configuration, unsupported explicit options, and uncertain failures are errors. API keys or Gateway tokens present in the environment are not implicitly enabled.
|
|
12
12
|
|
|
13
|
-
Automatic fallback ends at task submission. Execution failure, allowance exhaustion, or an uncertain submission outcome never automatically replays work or migrates a conversation. Partial file and tool effects remain in the execution environment. The caller can inspect progress and explicitly create other work.
|
|
13
|
+
Automatic fallback ends at task submission. Execution failure, allowance exhaustion, or an uncertain submission outcome never automatically replays work or migrates a conversation. Partial file and tool effects remain in the execution environment. The caller can inspect progress and explicitly create other work. Codex terminal turn failures use the safe category mapping in [Error diagnostics](diagnostics.md), including `CONTEXT_WINDOW_EXCEEDED` for reported context-window exhaustion; this classification does not change queue or recovery behavior.
|
|
14
14
|
|
|
15
15
|
`subharness check` applies the same selection and fallback rules while opening and closing a temporary native session without submitting work. A successful result means startup checks passed for the selected target at that moment. It is not a quota probe or a guarantee that a later task, shell command, declared child launch, or provider request will succeed.
|
|
16
16
|
|
package/sdk/index.md
CHANGED
|
@@ -1,26 +1,53 @@
|
|
|
1
|
-
# SDK and CLI
|
|
1
|
+
# SDK and CLI reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This index is the entry point to the authoritative subharness contracts. The TypeScript SDK supports application-owned execution and connections to the shared local coordinator. The CLI lets a coding agent or developer run native harnesses directly, reuse specialists, and coordinate sessions, queues, responses, and approvals.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## SDK API
|
|
6
|
+
|
|
7
|
+
- [Connected and embedded execution](execution.md): client and runner ownership, sessions, tasks, complete responses, approvals, and hosted delegation.
|
|
8
|
+
- [Live session events](events.md): normalized content, route capabilities, live scopes, flow control and redaction.
|
|
9
|
+
- [User extensions](extensions.md): plain-object definitions, supervised coordinator processes, per-user consent and a tool-result logger.
|
|
10
|
+
- [Agent definitions](agent.md): package exports, fields, harness options, and definition examples.
|
|
11
|
+
- [Custom tools](tools.md): validated application functions exposed through native harness integrations.
|
|
12
|
+
- [Subagents](plugins/sub-agents.md): nested delegation, lineage, context, and result-delivery boundaries.
|
|
13
|
+
|
|
14
|
+
## CLI
|
|
15
|
+
|
|
16
|
+
- [CLI](cli/index.md): commands, input, admission, waiting, follow-ups, control, and native permission responses.
|
|
17
|
+
- [CLI output](cli/output.md): compact text, typed JSONL records, states, and exit codes.
|
|
18
|
+
- [Dashboard presentation](cli/dashboard-design.md): the read-only live terminal hierarchy and interaction contract.
|
|
19
|
+
- [Extension commands](cli/extensions.md): manifest discovery, directory installation and explicit per-user enablement.
|
|
20
|
+
- [Agent discovery](config.md): repository and global definitions, naming, and personal worktree settings.
|
|
6
21
|
- [Agent skill](agent-skill.md): the installable skill that teaches a coding agent to delegate with the CLI.
|
|
7
|
-
- [Agent definitions](agent.md): package exports, fields, harness options, and examples.
|
|
8
|
-
- [Custom tools](tools.md): validated tool functions exposed through native harness integrations.
|
|
9
|
-
- [Discovery](config.md): repository/global definitions and personal worktree settings.
|
|
10
|
-
- [Personal access](access-config.md): subscription discovery, explicit API keys, and project OIDC.
|
|
11
|
-
- [Native permissions](permissions.md): session permission options, native limits, and background delegation.
|
|
12
|
-
- [Permission requests](approvals.md): request-specific schemas, structured answers, and approval lifecycle.
|
|
13
|
-
- [Harnesses](harnesses.md): selection, capabilities, and fallback boundaries.
|
|
14
|
-
- [CLI](cli/index.md): commands and response waiting.
|
|
15
|
-
- [Output](cli/output.md): compact text and typed JSONL records.
|
|
16
|
-
- [Error diagnostics](diagnostics.md): failure categories, safe context, and recovery guidance.
|
|
17
|
-
- [Sessions](sessions.md): task identity, state, and recovery.
|
|
18
|
-
- [Message delivery](message-delivery.md): queue, steer, interrupt, and cancellation.
|
|
19
|
-
- [Subagents](plugins/sub-agents.md): nested delegation and context boundaries.
|
|
20
|
-
- [Response delivery](completion-notifications.md): return points and parent continuation.
|
|
21
|
-
- [Runtime](v1-runtime.md): execution ownership, loading, limits, and failure handling.
|
|
22
|
-
- [Native adapters](adapter-contract.md): integration behavior and capability limits.
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
## Lifecycle and access
|
|
24
|
+
|
|
25
|
+
- [Sessions](sessions.md): task identity, state, queue ownership, and recovery boundaries.
|
|
26
|
+
- [Message delivery](message-delivery.md): queue, steer, interrupt, cancellation, and failure handling.
|
|
27
|
+
- [Response delivery](completion-notifications.md): complete responses, return points, and parent continuation.
|
|
28
|
+
- [Permission requests](approvals.md): request-specific CLI schemas, structured SDK actions, ownership, and lifecycle.
|
|
29
|
+
- [Authentication](authentication.md): native credentials, subscriptions, billing, and trust boundaries.
|
|
30
|
+
- [Personal access configuration](access-config.md): subscription discovery, explicit API keys, project OIDC, and local renewal.
|
|
31
|
+
- [Native permissions](permissions.md): session policies, native limits, and background delegation.
|
|
32
|
+
- [Error diagnostics](diagnostics.md): safe failure context and recovery guidance.
|
|
33
|
+
- [Distribution](distribution.md): package identity, installation, verification, and release boundaries.
|
|
34
|
+
- [Harness selection](harnesses.md): supported targets, capabilities, and fallback boundaries.
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
## Harness details
|
|
37
|
+
|
|
38
|
+
- [Additional native harnesses](additional-harnesses.md): shared configuration for OpenCode, GitHub Copilot, and Cursor.
|
|
39
|
+
- [fx](fx.md): fx ACP behavior, tools, access, permissions, and lifecycle.
|
|
40
|
+
- [OpenCode](opencode.md): OpenCode integration and supported access routes.
|
|
41
|
+
- [GitHub Copilot](copilot.md): Copilot integration and supported access routes.
|
|
42
|
+
- [Cursor](cursor.md): Cursor subscription and API-key integration boundaries.
|
|
43
|
+
|
|
44
|
+
## Maintainer internals
|
|
45
|
+
|
|
46
|
+
- [Native adapter contract](adapter-contract.md): integration behavior and capability limits.
|
|
47
|
+
- [v1 runtime](v1-runtime.md): execution ownership, loading, limits, and failure handling.
|
|
48
|
+
- [Dashboard inspection](cli/dashboard-inspection.md): coordinator projection used by the terminal dashboard.
|
|
49
|
+
- [Evaluations](evals.md): maintained evaluation inputs and scoring boundaries.
|
|
50
|
+
- [Repository agent team](project-team.md): reusable roles used to develop this project.
|
|
51
|
+
- [PR integration](pr-integration.md): reviewed-head and integration requirements.
|
|
52
|
+
|
|
53
|
+
These documents describe the v1 contract. They do not authorize automatic conversation migration, a custom model harness, sandbox provisioning, or a separate pipeline-definition API.
|
package/sdk/message-delivery.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Message Delivery
|
|
2
2
|
|
|
3
|
+
The [execution SDK](execution.md) binds these queue, steer, interrupt, and cancellation semantics to session/task handles. Observer abortion detaches observation; it does not cancel work. Session or embedded-runner close stops owned execution explicitly; connected-client disconnect does not.
|
|
4
|
+
|
|
3
5
|
`subharness send <session-id> --delivery <queue|steer|interrupt> [--detach] --prompt <text>` controls delivery. `queue` is the default. Each session has one active library task and a FIFO queue; a library task can contain multiple native turns while coordinating descendants.
|
|
4
6
|
|
|
5
7
|
| Mode | Effect |
|
|
@@ -36,6 +38,8 @@ Cancellation applies recursively to recorded delegation relationships. Pending d
|
|
|
36
38
|
|
|
37
39
|
`cancel` returns after affected work has stopped. Repeated cancellation of already-settled work returns its state. An unconfirmed stop reports a cancellation error and keeps dispatch paused; it does not authorize starting replacement or queued work. Invalid replacement input is rejected before existing work is cancelled.
|
|
38
40
|
|
|
41
|
+
For cancellation and interrupt, "stopped" means that the active native turn, recorded descendant work, and admitted callbacks have reached their confirmed stop boundary. It does not retire the native session. A harness can keep its own background tool processes alive across turns, so those processes can continue after cancellation or task completion. Close the session with `subharness close` or `session.close()` to invoke the harness's tracked-process cleanup. Processes deliberately detached outside native harness tracking are not owned by either the harness or Subharness and can survive session close.
|
|
42
|
+
|
|
39
43
|
## Resume after an execution error
|
|
40
44
|
|
|
41
45
|
`subharness resume <session-id>` addresses the existing failed task and requires no new prompt. It does not replay the original task, migrate to another harness, or skip the failure to release the queue. An unavailable native recovery operation returns `RECOVERY_UNSUPPORTED`. A session without failed work returns an error.
|
package/sdk/opencode.md
CHANGED
|
@@ -50,7 +50,7 @@ Native permissions are configured to ask. Active native permission requests use
|
|
|
50
50
|
|
|
51
51
|
## Lifecycle
|
|
52
52
|
|
|
53
|
-
Each Subharness session owns one native conversation and one native server. Follow-up tasks retain that conversation. Every prompt pins the requested provider/model; detectable changes are errors without replay.
|
|
53
|
+
Each Subharness session owns one native conversation and one native server. Follow-up tasks retain that conversation. Every prompt pins the requested provider/model; detectable changes are errors without replay. The complete-response result returns final assistant text only after successful native completion. [Live session events](events.md#effective-route-capabilities) separately expose bounded live text, reasoning and tool previews; they do not establish task completion and are delivered only to current subscribers. Native errors, unfinished responses, and malformed terminal data cannot count as success. The final text limit is 1 MiB.
|
|
54
54
|
|
|
55
55
|
Interruption requests native abort and confirms the active work stopped; an accepted HTTP abort request alone is insufficient. It also drains admitted tools and retires outstanding approvals, including when native work ended before interruption began. Native stop confirmation is bounded; that deadline does not limit already-admitted host callbacks, which must settle before interruption completes. Failure to confirm native termination produces `CANCELLATION_FAILED`, and no replacement prompt is admitted to still-running work. Steering uses the shared interrupt behavior; prompt-free recovery is unsupported.
|
|
56
56
|
|
package/sdk/permissions.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Native Permissions
|
|
2
2
|
|
|
3
|
+
The [execution SDK](execution.md) uses the same native permission options. Embedded SDK-hosted declared-child tools receive native custom-tool permissions; they do not install CLI launcher shell rules. Host callbacks are trusted application code and are not confined by a native sandbox.
|
|
4
|
+
|
|
3
5
|
The Codex, Claude Code, and fx constructors accept optional native permission settings directly alongside model options. These settings configure the native session without modifying persistent native settings or creating a Subharness sandbox. OpenCode instead uses its isolated native ask policy, Copilot uses native manual permission mode, and neither exposes a public permission selector. Cursor exposes its documented SDK `sandboxMode` for API-key access; subscription ACP access rejects explicit sandbox settings and supports the documented once-only native approvals. Supported native tool approvals are surfaced to the caller through the [structured approval flow](approvals.md); an explicit valid caller decision is required before authorization. The installed harness evaluates the selected policy, and the external execution environment enforces its remaining restrictions.
|
|
4
6
|
|
|
5
7
|
Omitted settings preserve native configuration. Explicit settings remain fixed for session follow-ups. A child uses its own definition and native configuration; it does not inherit the parent's explicit permission options. Invalid definitions fail before execution. Unsupported or observably rejected explicit settings fail without fallback to another harness or permission policy.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Subagents
|
|
2
2
|
|
|
3
|
+
The invocation rules below describe CLI-hosted sessions. The [execution SDK](../execution.md) also supports in-memory definitions through explicitly hosted delegation tools, with private parent binding and the same task lineage/completion semantics. Embedded SDK sessions do not create or require the CLI launcher, its shell grants, or a coordinator service. Native adapter transport and permission limits still apply.
|
|
4
|
+
|
|
3
5
|
An agent's optional `subagents` map declares and authorizes the agents it can invoke. Values are ordinary `AgentDefinition` objects; children can have their own subagents. Declaration alone does not execute them or register them in a repository/global catalog.
|
|
4
6
|
|
|
5
7
|
```ts
|
|
@@ -29,9 +31,9 @@ The launcher restores its coordinator location and parent context before invokin
|
|
|
29
31
|
|
|
30
32
|
For Claude Code, declaring at least one subagent adds native permission rules for the current session's exact launcher. Equivalent quoted or unquoted spellings are allowed only when they identify the same literal executable. These rules authorize `run subagent:<name>` for the declared names, plus the CLI's `list`, `--help`, `send`, `wait`, `status`, `queue`, `cancel`, and `resume` operations. They do not authorize launching repository or global agents through `run`, another executable, or arbitrary shell commands. Follow-up and observation commands retain their documented identifier-based behavior; the permission rules do not introduce a new task-access policy.
|
|
31
33
|
|
|
32
|
-
The adapter combines these rules with declared custom-tool permissions. Those rules do not write user/project permission settings or change the native permission mode; explicit constructor options independently select session permission settings as defined in [Native Permissions](../permissions.md). Native deny rules, explicit approval requirements, managed policy, and sandbox restrictions remain authoritative.
|
|
34
|
+
The adapter combines these rules with declared custom-tool permissions. Those rules do not write user/project permission settings or change the native permission mode; explicit constructor options independently select session permission settings as defined in [Native Permissions](../permissions.md). Native deny rules, explicit approval requirements, managed policy, and sandbox restrictions remain authoritative. Supported permission requests during an active turn use the [structured approval flow](../approvals.md); unsupported interactive input and startup-time requests fail with `INPUT_REQUIRED`. Each child starts with its own native tool permissions; permission to launch it does not grant permission for its edits or shell commands. A session without declared subagents receives no delegation rules. If a launcher path cannot be represented as a literal command in the native permission syntax, startup fails with `INVALID_CONFIG` rather than adding a broader rule.
|
|
33
35
|
|
|
34
|
-
Codex receives the same declared-child instructions and private launcher, but the adapter does not add native allow rules for them. Codex must already have effective permission to execute the launcher, read the files needed by that execution, and contact the coordinator. Native behavior differs across Codex versions, managed policies, sandbox configurations, and host environments. In some combinations, commands that access protected locations such as `.subharness/`, execute the private launcher, or use loopback networking can require approval or remain unavailable; this is an environment-dependent limitation, not a universal Codex rule.
|
|
36
|
+
Codex receives the same declared-child instructions and private launcher, but the adapter does not add native allow rules for them. Codex must already have effective permission to execute the launcher, read the files needed by that execution, and contact the coordinator. Native behavior differs across Codex versions, managed policies, sandbox configurations, and host environments. In some combinations, commands that access protected locations such as `.subharness/`, execute the private launcher, or use loopback networking can require approval or remain unavailable; this is an environment-dependent limitation, not a universal Codex rule. Supported permission requests during an active turn use the [structured approval flow](../approvals.md), including requests to launch an authorized declared child; unsupported interactive input and startup-time requests fail with `INPUT_REQUIRED`. The library does not automatically approve the request, disable sandboxing, or replace shell delegation with another transport.
|
|
35
37
|
|
|
36
38
|
For every harness, the native execution environment must allow the CLI to read its private launcher and contact the coordinator over loopback HTTP. A native sandbox that blocks local networking also blocks CLI delegation. The library does not relax that policy automatically; the caller supplies explicit native permission options, native settings, or an external execution environment. A lead can instead own independent review outside a managed agent's native delegation flow when the environment cannot grant these prerequisites.
|
|
37
39
|
|
package/sdk/project-team.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Repository Agent Team
|
|
2
2
|
|
|
3
|
-
This repository keeps
|
|
3
|
+
This repository keeps ten reusable agents in `.subharness/agents/`. An agent defines a stable responsibility, model, and tool access. A skill supplies task-specific instructions that the agent reads when relevant. Adding a technique or library does not require another agent definition.
|
|
4
4
|
|
|
5
5
|
## Roles
|
|
6
6
|
|
|
@@ -9,6 +9,10 @@ This repository keeps six reusable agents in `.subharness/agents/`. An agent def
|
|
|
9
9
|
| `architect` | Codex, `gpt-6-astra`, high effort | Evaluate architecture and API decisions; develop requested design concepts and assets; perform independent visual review when assigned. |
|
|
10
10
|
| `developer` | Codex, `gpt-5.6-sol`, high effort | Implement documented behavior and application structure with focused TDD and independent review. |
|
|
11
11
|
| `visual-engineer` | fx, `anthropic/claude-fable-5.1`, native default effort | Implement approved interface styling and native vgpu/WGSL effects using the relevant skill. |
|
|
12
|
+
| `api-researcher` | Codex, `gpt-5.6-luna`, medium effort | Collect primary-source API evidence: signatures, defaults, events, errors, and lifecycle rules. |
|
|
13
|
+
| `systems-researcher` | Codex, `gpt-5.6-luna`, low effort | Collect evidence from related systems, including job queues, process runners, event streams, actors, and UI state synchronization. |
|
|
14
|
+
| `planner` | Codex, `gpt-6-astra`, high effort | Turn settled contracts into bounded implementation assignments and verification criteria in ignored scratch files. |
|
|
15
|
+
| `get-context` | fx, `anthropic/claude-sonnet-5.5`, native default effort | Perform one quick orientation pass when the lead receives a new request whose affected repository areas it has not explored, and report relevant files and observed facts. |
|
|
12
16
|
| `researcher` | fx, `google/gemini-3.8-flash`, native default effort | Answer a bounded technical or design question with primary-source evidence. |
|
|
13
17
|
| `reviewer` | Claude Code, `claude-opus-5[1m]`, high effort | Independently review correctness, lifecycle, credential routing, and contract compliance without editing files. |
|
|
14
18
|
| `integrator` | Codex, `gpt-5.6-sol`, high effort | Merge only the exact PRs and reviewed heads explicitly authorized by the lead for the current assignment, following [PR integration](pr-integration.md). |
|
|
@@ -23,6 +27,20 @@ The repository's Codex roles explicitly select `approvalPolicy: "never"`, `sandb
|
|
|
23
27
|
|
|
24
28
|
Implementation roles return unstaged working-tree changes and verification evidence. Local Git staging and commits belong to the lead unless the assignment explicitly authorizes them. When an implementation task requires moving or deleting ordinary files, roles use filesystem operations; subsequent Git staging records the renames. By default, Codex workspace-write protects `.git`, `.agents`, and `.codex` inside the writable workspace. It also protects the Git directory named by a `.git` pointer file, even when that directory is inside the workspace; for a linked worktree, that directory is in the main checkout's Git directory and holds the worktree's index. A required change under those protected paths is reported with the exact operation, affected paths, and partial effects for lead-managed execution. A copied replacement does not complete a move while the original remains.
|
|
25
29
|
|
|
30
|
+
## Assigning work by complexity
|
|
31
|
+
|
|
32
|
+
Use `get-context` only for the initial orientation pass: when the lead receives a new request whose affected repository areas it has not explored. Another role can call it only when that role declares it as a subagent; no current role does. It maps relevant documentation, source files, tests, and observed facts quickly and writes a Markdown report to the caller-named file under `.context/research/`, or to `.context/research/get-context-<short-topic>.md` when the caller names none. The report keeps observed facts separate from any explicitly labeled unverified inferences about possible approaches. Apart from that report, it does not edit files. This is an instruction: the fx roles' `permissionMode: "auto"` leaves native write and shell tools available. It does not choose approaches, settle contracts, or delegate. Follow-up questions, targeted lookups, and evidence research use the lead's own tools or the research roles instead of repeated orientation passes.
|
|
33
|
+
|
|
34
|
+
Use `api-researcher` for bounded source searches and API inventories. Use `systems-researcher` for related problems outside agent orchestration. Both use the explicitly selected Codex model, read `.agents/skills/source-research/SKILL.md`, and write only the caller-named files under `.context/research/`. Their output records source URLs or paths, retrieval dates, revisions, observed behavior, and uncertainty. `api-researcher` separates native capabilities from current adapter usage, inspects complete exported type and event inventories, may use probes that cannot start a model turn, and records the sources searched before reporting that something does not exist. It reads external repositories from shallow clones under `.context/research/sources/` without installing or running them. They distinguish facts from inference, do not rank architectural alternatives or settle contracts, and return missing evidence to the lead. The existing fx `researcher` remains available for general technical and visual evidence tasks. The two research roles have different standing evidence responsibilities: `api-researcher` inventories caller-visible interfaces, while `systems-researcher` investigates ownership, failure handling, delivery, and retention across related domains. Keeping those lenses explicit helps a design survey cover both interface conventions and operational behavior. Individual libraries and technologies remain task inputs, not additional permanent roles.
|
|
35
|
+
|
|
36
|
+
Use `architect` for reasoning across that evidence, including API alternatives with concrete signatures and usage examples, lifecycle ownership, cancellation, errors, compatibility, and misuse cases. Recommendations do not authorize implementation. The lead settles clear choices under `AGENTS.md` and asks the human only for unresolved product tradeoffs or signatures outside delegated authority.
|
|
37
|
+
|
|
38
|
+
Use `planner` only after the relevant decisions are settled in repository documentation. It reads the actual affected implementation and writes only the caller-named files under `.context/research/`. Its assignments identify the governing contracts, owned files, dependencies, behavior-focused failing tests, validation commands, and acceptance criteria. It reports missing decisions instead of choosing public behavior. Plans and progress records are scratch artifacts; they never replace repository contracts, authorize implementation, or become public documentation. The lead validates the assignments and owns task boundaries and implementation authorization.
|
|
39
|
+
|
|
40
|
+
Use `developer` for implementation and bounded review fixes, and `reviewer` for independent review. Documentation work uses the existing developer or architect with an explicit file scope; it does not need another permanent role. Graphics-specific research uses the existing researcher with the graphics skill when relevant. The `get-context`, `api-researcher`, `systems-researcher`, and `planner` return results to the lead without delegation. The lead supplies bounded questions, sources or search angles, output paths, and stopping criteria so economical evidence collection does not turn into unbounded design work.
|
|
41
|
+
|
|
42
|
+
These assignments express task complexity, not a guaranteed price or model benchmark. Models are fixed in definitions; there is no automatic routing based on a guessed task difficulty, silent fallback, or credential change. When the selected model or capability is unavailable, report that limitation to the lead. A follow-up can narrow an unanswered research question in the same session; a new independent angle gets a separate session.
|
|
43
|
+
|
|
26
44
|
## Skills and task context
|
|
27
45
|
|
|
28
46
|
Repository skills live in `.agents/skills/<name>/SKILL.md`. The short index in `AGENTS.md` explains when each skill applies. Agents read only the relevant skill and supporting references for their current task. Skill contents are not concatenated into every agent's instructions.
|
|
@@ -31,12 +49,18 @@ These files are ordinary instructions consumed through the native harness. Each
|
|
|
31
49
|
|
|
32
50
|
The caller provides one bounded deliverable, governing contracts, input artifacts, working directory, and relevant skill paths. Each child receives its own task and instructions; it does not inherit the parent's transcript or previously loaded skills. A handoff therefore names required skills again.
|
|
33
51
|
|
|
52
|
+
The inline prompts below are short literal examples. A real handoff that generates a long or multiline prompt supplies it through `--prompt-file <path>` using a temporary file accessible only by its owner, or through `--prompt-file -` when the host owns standard input. On POSIX systems, the file uses mode `0600` inside a mode-`0700` temporary directory. A `started` or `accepted` record, or command exit, confirms that the CLI has read the file and it can be removed.
|
|
53
|
+
|
|
34
54
|
```sh
|
|
35
55
|
subharness list
|
|
36
56
|
subharness run repo:architect --prompt "Read website/design.md and .agents/skills/design-exploration/SKILL.md. Evaluate the supplied hero reference and report a composition recommendation."
|
|
37
57
|
subharness run repo:visual-engineer --prompt "Use .agents/skills/web-interface/SKILL.md. Implement the hero layout documented in website/design.md. Limit changes to the hero styles."
|
|
38
58
|
subharness run repo:developer --prompt "Use .agents/skills/web-interface/SKILL.md. Read website/design.md. Check the hero's semantic HTML and keyboard behavior without changing styles."
|
|
39
59
|
subharness run repo:developer --prompt "Use .agents/skills/webgpu-graphics/SKILL.md. Read website/graphics.md. Verify the mascot camera's documented framing with focused tests."
|
|
60
|
+
subharness run repo:get-context --prompt "New request: add task filtering to the CLI dashboard. Map the relevant files and write the report to .context/research/get-context-dashboard-filtering.md."
|
|
61
|
+
subharness run repo:api-researcher --prompt "Use .agents/skills/source-research/SKILL.md. Read sdk/sessions.md. Record official SDK cancellation signatures in .context/research/sdk-cancellation.md."
|
|
62
|
+
subharness run repo:systems-researcher --prompt "Use .agents/skills/source-research/SKILL.md. Read sdk/message-delivery.md. Record queue and observer lifecycle evidence in .context/research/queue-lifecycle.md."
|
|
63
|
+
subharness run repo:planner --prompt "Read sdk/sessions.md and sdk/message-delivery.md. Inspect src/runtime/coordinator.ts. Write bounded verification assignments for those settled contracts to .context/research/session-verification-plan.md."
|
|
40
64
|
subharness run repo:researcher --prompt "Use .agents/skills/source-research/SKILL.md. Read sdk/fx.md and src/adapters/fx.ts. Explain cancellation behavior with file references."
|
|
41
65
|
subharness run repo:reviewer --prompt "Review the mascot camera changes against website/graphics.md. Report actionable findings without editing files."
|
|
42
66
|
```
|
|
@@ -45,6 +69,10 @@ The website's illustrative conversation shows tasks delegated to Claude Code and
|
|
|
45
69
|
|
|
46
70
|
## Delegation and review
|
|
47
71
|
|
|
72
|
+
Every implementation handoff and final PR review includes a file-purpose audit against the target branch. The planner includes this in acceptance criteria, the developer removes temporary artifacts from its changes, and the reviewer inspects the complete added and changed file inventory, including documentation and supporting files. Findings identify the file and why it has no lasting repository purpose. The lead verifies the final inventory before declaring the PR ready. A bounded review states its coverage; it does not establish that the whole PR has passed this audit.
|
|
73
|
+
|
|
74
|
+
Temporary proposals, plans, progress logs, research notes, one-off diagnostics, and review output belong in ignored `.context/` files. Settled decisions belong in canonical documentation; superseded proposals and purposeless redirect stubs are removed. Intentional regression fixtures, maintained examples, evaluation tools, and product documentation remain repository assets. File purpose, rather than its name alone, determines whether it belongs in the final changes.
|
|
75
|
+
|
|
48
76
|
CLI and runtime work uses the existing architect, developer, and reviewer roles. Separate developer sessions can own independent modules; scope and governing contracts distinguish their assignments without adding permanent roles. The architect evaluates native protocol constraints, the developer implements and integrates behavior with TDD, and the reviewer independently checks user-facing behavior, lifecycle, and credential routing. The lead coordinates contracts, assignments, and final verification. Implementation and fixes run through repository agents whenever supported, so follow-ups, queues, and review cycles exercise subharness itself. Reproducible coordination failures are evidence for library improvements under the same contract and review rules.
|
|
49
77
|
|
|
50
78
|
Repository role instructions follow the same delegation preference as the public skill and managed child instructions: use one attached `run` through known host background-command controls, continue independent work, and collect its output. Use `--detach` followed later by `wait` when those controls are unavailable or uncertain. A hosted `run` already observes the first response and does not require a redundant `wait` or unconditional `status`. This preference does not authorize undeclared children or override a role's delegation restrictions.
|
package/sdk/sessions.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Sessions and Tasks
|
|
2
2
|
|
|
3
|
+
Applications can use the [execution SDK](execution.md) through an embedded runner or a connected client. Embedded records belong to the runner; connected records belong to the same shared coordinator as CLI records. Session close stops owned execution, while client disconnect releases observation without cancelling work.
|
|
4
|
+
|
|
3
5
|
An agent definition describes reusable behavior. A session is one native conversation in a fixed execution directory. A task is a unit of work within that session. Tasks and sessions have separate opaque identifiers and are not shell process IDs.
|
|
4
6
|
|
|
5
7
|
Each `run` creates a new session; `send` creates follow-up tasks or steers the active task. A session retains native conversation state and its loaded instructions, tools, and harness configuration between tasks. The external harness owns its context and compaction.
|
|
@@ -23,6 +25,8 @@ Every complete response receives a response identifier and returns control to it
|
|
|
23
25
|
|
|
24
26
|
`wait` observes the first retained response without creating another task. `wait --after <response-id>` observes later responses from an explicit cursor. `status` reports current state independently of earlier response snapshots. Completing a task does not delete its conversation. Returning a command does not cancel the task or descendants. `--detach` on a task-creating command ends only that command's observation after admission; it is not stored on the session and does not alter later `send`, `wait`, or `status` behavior.
|
|
25
27
|
|
|
28
|
+
Cancellation and interrupt stop the agent's active native turn. A native harness can retain a tool process as session-owned background work across turns, so such a process can continue after cancellation or task completion. Closing the session with `subharness close` or `session.close()`, or shutting down the coordinator, closes native resources and lets the harness terminate the tool processes it tracks. A process deliberately detached outside the harness's tracking is outside both Subharness and harness ownership and can survive.
|
|
29
|
+
|
|
26
30
|
## Lifetime and recovery
|
|
27
31
|
|
|
28
32
|
The on-demand coordinator retains task records and native session workers beyond individual command exits. Task IDs resolve from other working directories using that coordinator. Task records remain available for its lifetime; they are not silently evicted. Settled permission-request records have a separate bounded retention policy defined in [Responding to Native Permission Requests](approvals.md).
|
|
@@ -32,3 +36,5 @@ Restarting the coordinator does not restore queues or automatically replay tasks
|
|
|
32
36
|
Cancellation, interrupt propagation, and queue behavior are defined in [Message Delivery](message-delivery.md). The detailed ownership and bounds are defined in the [runtime contract](v1-runtime.md).
|
|
33
37
|
|
|
34
38
|
Supported native permission requests follow [Responding to Native Permission Requests](approvals.md). Observing an approval returns control without completing or restarting the task.
|
|
39
|
+
|
|
40
|
+
`subharness close <session-id>` and SDK `session.close()` share the same close path. Close stops new admission, cancels active and queued tasks and their recorded descendants with confirmed-stop semantics, and then closes native resources. Closed sessions remain inspectable, and repeated successful close is idempotent. Cleanup failure leaves admission closed and retains ownership for a later retry.
|
package/sdk/tools.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Custom Tools
|
|
2
2
|
|
|
3
|
+
With the embedded [execution SDK](execution.md), inline tool closures execute in the application process with its unchanged cwd and environment, rather than the CLI session worker. Captured application state remains live; callbacks may be shared across sessions. SDK cancellation drains admitted callbacks and does not force-stop arbitrary JavaScript.
|
|
4
|
+
|
|
3
5
|
`tool({ description, inputSchema, execute })` defines a function that a native harness can invoke. The map key in `agent.tools` is its public name. Declaring a tool does not execute it.
|
|
4
6
|
|
|
5
7
|
```ts
|
|
@@ -27,7 +29,7 @@ All three fields are required. `description` is a nonempty string. `inputSchema`
|
|
|
27
29
|
|
|
28
30
|
Validation runs before execution; invalid arguments never reach the function. Unsupported schemas fail during definition validation. Non-serializable or oversized outputs and thrown exceptions become tool errors. Tool results are limited to 1 MiB. Errors do not masquerade as successful outputs.
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
Connected and CLI-hosted tools run in the retained definition graph owner's creation directory and environment. Managed children share that captured callback context even when their native harness uses a different requested directory; use explicit paths or arguments for child-specific operations. Embedded SDK-hosted closures use the application context described above. The adapter registers them in a native namespace without replacing the harness's native tools or model loop. Declaring a custom tool authorizes that agent to invoke it. Native tool permission policies remain with the harness.
|
|
31
33
|
|
|
32
34
|
## Image results
|
|
33
35
|
|