subharness 0.0.7 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -9
- package/dist/adapters/claude-events.d.ts +71 -0
- package/dist/adapters/claude-events.js +860 -0
- package/dist/adapters/claude-events.js.map +1 -0
- package/dist/adapters/claude-worker-client.d.ts +11 -0
- package/dist/adapters/claude-worker-client.js +219 -5
- package/dist/adapters/claude-worker-client.js.map +1 -1
- package/dist/adapters/claude-worker-protocol.d.ts +58 -0
- package/dist/adapters/claude-worker-protocol.js.map +1 -1
- package/dist/adapters/claude-worker.js +48 -3
- package/dist/adapters/claude-worker.js.map +1 -1
- package/dist/adapters/claude.d.ts +5 -1
- package/dist/adapters/claude.js +14 -2
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex-events.d.ts +52 -0
- package/dist/adapters/codex-events.js +672 -0
- package/dist/adapters/codex-events.js.map +1 -0
- package/dist/adapters/codex-turn-failure.d.ts +2 -0
- package/dist/adapters/codex-turn-failure.js +116 -0
- package/dist/adapters/codex-turn-failure.js.map +1 -0
- package/dist/adapters/codex.js +44 -7
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/copilot-events.d.ts +68 -0
- package/dist/adapters/copilot-events.js +650 -0
- package/dist/adapters/copilot-events.js.map +1 -0
- package/dist/adapters/copilot.js +24 -4
- package/dist/adapters/copilot.js.map +1 -1
- package/dist/adapters/cursor-acp-events.d.ts +36 -0
- package/dist/adapters/cursor-acp-events.js +251 -0
- package/dist/adapters/cursor-acp-events.js.map +1 -0
- package/dist/adapters/cursor-cli-session.d.ts +1 -0
- package/dist/adapters/cursor-cli-session.js +26 -5
- package/dist/adapters/cursor-cli-session.js.map +1 -1
- package/dist/adapters/cursor-cli.js +5 -0
- package/dist/adapters/cursor-cli.js.map +1 -1
- package/dist/adapters/cursor-sdk-events.d.ts +30 -0
- package/dist/adapters/cursor-sdk-events.js +233 -0
- package/dist/adapters/cursor-sdk-events.js.map +1 -0
- package/dist/adapters/cursor-session.js +56 -7
- package/dist/adapters/cursor-session.js.map +1 -1
- package/dist/adapters/cursor-startup.js +8 -2
- package/dist/adapters/cursor-startup.js.map +1 -1
- package/dist/adapters/event-normalizer.d.ts +57 -0
- package/dist/adapters/event-normalizer.js +143 -0
- package/dist/adapters/event-normalizer.js.map +1 -0
- package/dist/adapters/event-secrets.d.ts +17 -0
- package/dist/adapters/event-secrets.js +28 -0
- package/dist/adapters/event-secrets.js.map +1 -0
- package/dist/adapters/event-types.d.ts +58 -0
- package/dist/adapters/event-types.js +2 -0
- package/dist/adapters/event-types.js.map +1 -0
- package/dist/adapters/fx-events.d.ts +37 -0
- package/dist/adapters/fx-events.js +393 -0
- package/dist/adapters/fx-events.js.map +1 -0
- package/dist/adapters/fx-rpc.d.ts +2 -0
- package/dist/adapters/fx-rpc.js +11 -5
- package/dist/adapters/fx-rpc.js.map +1 -1
- package/dist/adapters/fx.js +73 -8
- package/dist/adapters/fx.js.map +1 -1
- package/dist/adapters/opencode-events.d.ts +58 -0
- package/dist/adapters/opencode-events.js +653 -0
- package/dist/adapters/opencode-events.js.map +1 -0
- package/dist/adapters/opencode-http.d.ts +1 -0
- package/dist/adapters/opencode-http.js +8 -7
- package/dist/adapters/opencode-http.js.map +1 -1
- package/dist/adapters/opencode.js +50 -9
- package/dist/adapters/opencode.js.map +1 -1
- package/dist/adapters/rpc.d.ts +2 -0
- package/dist/adapters/rpc.js +11 -5
- package/dist/adapters/rpc.js.map +1 -1
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/cli/args.d.ts +6 -1
- package/dist/cli/args.js +63 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/catalog-worker.js +3 -2
- package/dist/cli/catalog-worker.js.map +1 -1
- package/dist/cli/dashboard-client.d.ts +1 -0
- package/dist/cli/dashboard-client.js +13 -1
- package/dist/cli/dashboard-client.js.map +1 -1
- package/dist/cli/dashboard-controller.js +6 -7
- package/dist/cli/dashboard-controller.js.map +1 -1
- package/dist/cli/dashboard-detail-view.d.ts +14 -8
- package/dist/cli/dashboard-detail-view.js +15 -44
- package/dist/cli/dashboard-detail-view.js.map +1 -1
- package/dist/cli/dashboard-history-view.d.ts +3 -12
- package/dist/cli/dashboard-history-view.js +18 -82
- package/dist/cli/dashboard-history-view.js.map +1 -1
- package/dist/cli/dashboard-live.d.ts +32 -0
- package/dist/cli/dashboard-live.js +177 -0
- package/dist/cli/dashboard-live.js.map +1 -0
- package/dist/cli/dashboard-renderer.d.ts +21 -1
- package/dist/cli/dashboard-renderer.js +85 -21
- package/dist/cli/dashboard-renderer.js.map +1 -1
- package/dist/cli/dashboard-steps.d.ts +53 -0
- package/dist/cli/dashboard-steps.js +157 -0
- package/dist/cli/dashboard-steps.js.map +1 -0
- package/dist/cli/dashboard-task-format.d.ts +15 -0
- package/dist/cli/dashboard-task-format.js +119 -0
- package/dist/cli/dashboard-task-format.js.map +1 -0
- package/dist/cli/dashboard-task-view.d.ts +66 -0
- package/dist/cli/dashboard-task-view.js +325 -0
- package/dist/cli/dashboard-task-view.js.map +1 -0
- package/dist/cli/dashboard.d.ts +2 -0
- package/dist/cli/dashboard.js +71 -6
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/extensions-client.d.ts +23 -0
- package/dist/cli/extensions-client.js +147 -0
- package/dist/cli/extensions-client.js.map +1 -0
- package/dist/cli/extensions.d.ts +15 -0
- package/dist/cli/extensions.js +187 -0
- package/dist/cli/extensions.js.map +1 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +34 -6
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +100 -10
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output.js +5 -1
- package/dist/cli/output.js.map +1 -1
- package/dist/config/access.d.ts +2 -1
- package/dist/config/access.js +18 -7
- package/dist/config/access.js.map +1 -1
- package/dist/config/loader.d.ts +2 -0
- package/dist/config/loader.js +20 -6
- package/dist/config/loader.js.map +1 -1
- package/dist/config/project-context.d.ts +9 -0
- package/dist/config/project-context.js +41 -0
- package/dist/config/project-context.js.map +1 -0
- package/dist/config/resolve-access.d.ts +2 -1
- package/dist/config/resolve-access.js +5 -2
- package/dist/config/resolve-access.js.map +1 -1
- package/dist/events/content.d.ts +43 -0
- package/dist/events/content.js +249 -0
- package/dist/events/content.js.map +1 -0
- package/dist/events/queue.d.ts +59 -0
- package/dist/events/queue.js +144 -0
- package/dist/events/queue.js.map +1 -0
- package/dist/events/validate.d.ts +22 -0
- package/dist/events/validate.js +542 -0
- package/dist/events/validate.js.map +1 -0
- package/dist/extensions/catalog.d.ts +34 -0
- package/dist/extensions/catalog.js +103 -0
- package/dist/extensions/catalog.js.map +1 -0
- package/dist/extensions/child-protocol.d.ts +38 -0
- package/dist/extensions/child-protocol.js +2 -0
- package/dist/extensions/child-protocol.js.map +1 -0
- package/dist/extensions/child.d.ts +1 -0
- package/dist/extensions/child.js +125 -0
- package/dist/extensions/child.js.map +1 -0
- package/dist/extensions/consent.d.ts +13 -0
- package/dist/extensions/consent.js +204 -0
- package/dist/extensions/consent.js.map +1 -0
- package/dist/extensions/environment.d.ts +1 -0
- package/dist/extensions/environment.js +12 -0
- package/dist/extensions/environment.js.map +1 -0
- package/dist/extensions/identity.d.ts +9 -0
- package/dist/extensions/identity.js +28 -0
- package/dist/extensions/identity.js.map +1 -0
- package/dist/extensions/log.d.ts +5 -0
- package/dist/extensions/log.js +80 -0
- package/dist/extensions/log.js.map +1 -0
- package/dist/extensions/manifest.d.ts +7 -0
- package/dist/extensions/manifest.js +213 -0
- package/dist/extensions/manifest.js.map +1 -0
- package/dist/extensions/types.d.ts +24 -0
- package/dist/extensions/types.js +2 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/extensions.d.ts +5 -0
- package/dist/extensions.js +2 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/approval-registry.d.ts +6 -2
- package/dist/runtime/approval-registry.js +31 -3
- package/dist/runtime/approval-registry.js.map +1 -1
- package/dist/runtime/capture.d.ts +4 -4
- package/dist/runtime/capture.js +59 -15
- package/dist/runtime/capture.js.map +1 -1
- package/dist/runtime/catalog.d.ts +6 -1
- package/dist/runtime/catalog.js +1 -1
- package/dist/runtime/catalog.js.map +1 -1
- package/dist/runtime/coordinator.d.ts +9 -4
- package/dist/runtime/coordinator.js +130 -27
- package/dist/runtime/coordinator.js.map +1 -1
- package/dist/runtime/daemon.js +9 -1
- package/dist/runtime/daemon.js.map +1 -1
- package/dist/runtime/dashboard.d.ts +4 -0
- package/dist/runtime/dashboard.js +8 -0
- package/dist/runtime/dashboard.js.map +1 -1
- package/dist/runtime/definition.d.ts +1 -1
- package/dist/runtime/definition.js +2 -2
- package/dist/runtime/definition.js.map +1 -1
- package/dist/runtime/event-operation.d.ts +41 -0
- package/dist/runtime/event-operation.js +290 -0
- package/dist/runtime/event-operation.js.map +1 -0
- package/dist/runtime/event-owner.d.ts +94 -0
- package/dist/runtime/event-owner.js +429 -0
- package/dist/runtime/event-owner.js.map +1 -0
- package/dist/runtime/event-source.d.ts +39 -0
- package/dist/runtime/event-source.js +344 -0
- package/dist/runtime/event-source.js.map +1 -0
- package/dist/runtime/extension-instance.d.ts +61 -0
- package/dist/runtime/extension-instance.js +356 -0
- package/dist/runtime/extension-instance.js.map +1 -0
- package/dist/runtime/extension-protocol.d.ts +47 -0
- package/dist/runtime/extension-protocol.js +33 -0
- package/dist/runtime/extension-protocol.js.map +1 -0
- package/dist/runtime/extension-service.d.ts +10 -0
- package/dist/runtime/extension-service.js +35 -0
- package/dist/runtime/extension-service.js.map +1 -0
- package/dist/runtime/extension-supervisor.d.ts +33 -0
- package/dist/runtime/extension-supervisor.js +254 -0
- package/dist/runtime/extension-supervisor.js.map +1 -0
- package/dist/runtime/select-native.d.ts +3 -1
- package/dist/runtime/select-native.js +32 -5
- package/dist/runtime/select-native.js.map +1 -1
- package/dist/runtime/service.d.ts +5 -0
- package/dist/runtime/service.js +113 -15
- package/dist/runtime/service.js.map +1 -1
- package/dist/runtime/session-event-wire.d.ts +29 -0
- package/dist/runtime/session-event-wire.js +2 -0
- package/dist/runtime/session-event-wire.js.map +1 -0
- package/dist/runtime/session-events-service.d.ts +8 -0
- package/dist/runtime/session-events-service.js +124 -0
- package/dist/runtime/session-events-service.js.map +1 -0
- package/dist/runtime/session-events-transport.d.ts +8 -0
- package/dist/runtime/session-events-transport.js +142 -0
- package/dist/runtime/session-events-transport.js.map +1 -0
- package/dist/runtime/startup-lock.d.ts +2 -0
- package/dist/runtime/startup-lock.js +49 -5
- package/dist/runtime/startup-lock.js.map +1 -1
- package/dist/runtime/state.d.ts +2 -1
- package/dist/runtime/state.js +4 -0
- package/dist/runtime/state.js.map +1 -1
- package/dist/runtime/transport.d.ts +1 -0
- package/dist/runtime/transport.js +2 -0
- package/dist/runtime/transport.js.map +1 -1
- package/dist/runtime/types.d.ts +24 -0
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/worker-client.js +42 -13
- package/dist/runtime/worker-client.js.map +1 -1
- package/dist/runtime/worker-event-channel.d.ts +30 -0
- package/dist/runtime/worker-event-channel.js +141 -0
- package/dist/runtime/worker-event-channel.js.map +1 -0
- package/dist/runtime/worker-event-protocol.d.ts +88 -0
- package/dist/runtime/worker-event-protocol.js +114 -0
- package/dist/runtime/worker-event-protocol.js.map +1 -0
- package/dist/runtime/worker-events.d.ts +73 -0
- package/dist/runtime/worker-events.js +704 -0
- package/dist/runtime/worker-events.js.map +1 -0
- package/dist/runtime/worker-server.d.ts +3 -1
- package/dist/runtime/worker-server.js +64 -9
- package/dist/runtime/worker-server.js.map +1 -1
- package/dist/sdk/connected-events.d.ts +3 -0
- package/dist/sdk/connected-events.js +259 -0
- package/dist/sdk/connected-events.js.map +1 -0
- package/dist/sdk/connected-types.d.ts +2 -0
- package/dist/sdk/connected-types.js.map +1 -1
- package/dist/sdk/connected.js +3 -0
- package/dist/sdk/connected.js.map +1 -1
- package/dist/sdk/event-types.d.ts +182 -0
- package/dist/sdk/event-types.js +2 -0
- package/dist/sdk/event-types.js.map +1 -0
- package/dist/sdk/execution-driver.js +1 -1
- package/dist/sdk/execution-driver.js.map +1 -1
- package/dist/sdk/execution-types.d.ts +2 -0
- package/dist/sdk/execution-types.js.map +1 -1
- package/dist/sdk/runner.js +2 -0
- package/dist/sdk/runner.js.map +1 -1
- package/package.json +5 -1
- package/sdk/access-config.md +9 -7
- package/sdk/adapter-contract.md +25 -3
- package/sdk/agent-skill.md +8 -5
- package/sdk/cli/dashboard-design.md +37 -9
- package/sdk/cli/dashboard-inspection.md +14 -6
- package/sdk/cli/extensions.md +44 -0
- package/sdk/cli/index.md +53 -14
- package/sdk/cli/output.md +14 -2
- package/sdk/completion-notifications.md +2 -2
- package/sdk/config.md +65 -11
- package/sdk/copilot.md +1 -1
- package/sdk/cursor.md +2 -2
- package/sdk/diagnostics.md +68 -0
- package/sdk/distribution.md +13 -3
- package/sdk/events.md +339 -0
- package/sdk/execution.md +32 -10
- package/sdk/extensions.md +189 -0
- package/sdk/fx.md +4 -2
- package/sdk/harnesses.md +1 -1
- package/sdk/index.md +4 -0
- package/sdk/message-delivery.md +2 -0
- package/sdk/opencode.md +1 -1
- package/sdk/plugins/sub-agents.md +3 -1
- package/sdk/project-root.md +97 -0
- package/sdk/project-team.md +10 -4
- package/sdk/sessions.md +4 -0
- package/sdk/v1-runtime.md +22 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.js","sourceRoot":"","sources":["../../src/sdk/event-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ErrorInfo } from \"../errors.js\";\nimport type {\n SdkApprovalRequest as ApprovalRequest,\n TaskState,\n} from \"../runtime/task-data.js\";\nimport type { HarnessKind } from \"./types.js\";\n\nexport type NativeRoute =\n | \"codex-app-server\"\n | \"claude-agent-sdk\"\n | \"fx-acp\"\n | \"opencode-http\"\n | \"copilot-sdk\"\n | \"cursor-acp\"\n | \"cursor-sdk\";\n\nexport interface NativeCorrelation {\n readonly sessionId?: string;\n readonly turnId?: string;\n readonly messageId?: string;\n readonly itemId?: string;\n readonly toolCallId?: string;\n readonly agentId?: string;\n readonly parentToolCallId?: string;\n}\n\nexport interface EventBase {\n readonly version: 1;\n readonly eventId: string;\n readonly ownerId: string;\n readonly sequence: number;\n readonly observedAt: number;\n readonly sessionId: string;\n readonly harness?: HarnessKind;\n readonly route?: NativeRoute;\n readonly origin: \"owner\" | \"adapter\";\n readonly native?: NativeCorrelation;\n}\n\nexport interface TaskEventBase extends EventBase {\n readonly taskId: string;\n readonly parentTaskId?: string;\n}\n\nexport interface TurnEventBase extends TaskEventBase {\n readonly turnId: string;\n readonly turnOrdinal: number;\n}\n\nexport interface EventContent {\n readonly format: \"text\" | \"json\";\n readonly text: string;\n readonly status: \"complete\" | \"truncated\" | \"redacted\" | \"unavailable\";\n readonly originalBytes?: number;\n}\n\nexport interface ItemBase {\n readonly itemId: string;\n readonly itemOrdinal: number;\n readonly revision: number;\n readonly identity: \"native\" | \"synthetic\";\n readonly native?: NativeCorrelation;\n}\n\nexport interface AssistantItem extends ItemBase {\n readonly kind: \"assistant\";\n readonly state: \"streaming\" | \"completed\" | \"interrupted\" | \"incomplete\";\n readonly phase: \"progress\" | \"final\" | \"unspecified\";\n readonly body: EventContent;\n}\n\nexport interface ReasoningItem extends ItemBase {\n readonly kind: \"reasoning\";\n readonly state: \"streaming\" | \"completed\" | \"interrupted\" | \"incomplete\";\n readonly visibility: \"summary\" | \"text\" | \"unavailable\";\n readonly body: EventContent;\n}\n\nexport interface ToolItem extends ItemBase {\n readonly kind: \"tool\";\n readonly name: string;\n readonly state: \"pending\" | \"running\" | \"succeeded\" | \"failed\" | \"cancelled\" | \"unknown\";\n readonly input: EventContent;\n readonly output: EventContent;\n readonly exitCode?: number;\n readonly durationMs?: number;\n}\n\nexport type SessionItem = AssistantItem | ReasoningItem | ToolItem;\n\nexport interface SessionStateEvent extends EventBase {\n readonly type: \"session.state\";\n readonly state: \"open\" | \"closing\" | \"closed\";\n}\n\nexport interface SessionCapabilitiesEvent extends EventBase {\n readonly type: \"session.capabilities\";\n readonly capabilities: SessionEventCapabilities;\n}\n\nexport interface TaskStateEvent extends TaskEventBase {\n readonly type: \"task.state\";\n readonly state: TaskState;\n readonly stopUnconfirmed: boolean;\n}\n\nexport interface TurnStartedEvent extends TurnEventBase {\n readonly type: \"turn.started\";\n readonly cause: \"prompt\" | \"child-results\" | \"steer-continuation\" | \"recovery\";\n}\n\nexport interface TurnCompletedEvent extends TurnEventBase {\n readonly type: \"turn.completed\";\n readonly outcome: \"completed\" | \"failed\" | \"cancelled\" | \"interrupted\";\n readonly responseId?: string;\n readonly finalItemId?: string;\n}\n\nexport interface ItemStartedEvent extends TurnEventBase {\n readonly type: \"item.started\";\n readonly item: SessionItem;\n}\n\nexport interface ItemUpdatedEvent extends TurnEventBase {\n readonly type: \"item.updated\";\n readonly item: SessionItem;\n}\n\nexport type ItemDeltaHeader = {\n readonly itemId: string;\n readonly itemOrdinal: number;\n readonly identity: \"native\" | \"synthetic\";\n} & (\n | { readonly kind: \"assistant\"; readonly state: AssistantItem[\"state\"] }\n | { readonly kind: \"reasoning\"; readonly state: ReasoningItem[\"state\"] }\n | { readonly kind: \"tool\"; readonly state: ToolItem[\"state\"]; readonly name: string }\n);\n\nexport interface ItemDeltaEvent extends TurnEventBase {\n readonly type: \"item.delta\";\n readonly item: ItemDeltaHeader;\n readonly baseRevision: number;\n readonly revision: number;\n readonly field: \"body\" | \"output\";\n readonly text: string;\n}\n\nexport interface ItemCompletedEvent extends TurnEventBase {\n readonly type: \"item.completed\";\n readonly item: SessionItem;\n readonly completion: \"native\" | \"turn-boundary\" | \"interrupted\";\n}\n\nexport interface ApprovalRequestedEvent extends TurnEventBase {\n readonly type: \"approval.requested\";\n readonly request: ApprovalRequest;\n readonly itemId?: string;\n}\n\nexport interface ApprovalResolvedEvent extends TurnEventBase {\n readonly type: \"approval.resolved\";\n readonly requestId: string;\n readonly itemId?: string;\n readonly resolution: \"answered\" | \"withdrawn\";\n readonly actionId?: string;\n}\n\nexport interface SessionErrorEvent extends EventBase {\n readonly type: \"session.error\";\n readonly taskId?: string;\n readonly turnId?: string;\n readonly category: \"execution\" | \"capture\";\n readonly error: ErrorInfo;\n readonly fatal: boolean;\n}\n\nexport type SessionEvent =\n | SessionStateEvent\n | SessionCapabilitiesEvent\n | TaskStateEvent\n | TurnStartedEvent\n | TurnCompletedEvent\n | ItemStartedEvent\n | ItemUpdatedEvent\n | ItemDeltaEvent\n | ItemCompletedEvent\n | ApprovalRequestedEvent\n | ApprovalResolvedEvent\n | SessionErrorEvent;\n\nexport interface EventFeature {\n readonly support: \"available\" | \"unsupported\" | \"unverified\";\n readonly delivery: readonly (\"delta\" | \"snapshot\")[];\n readonly note?: string;\n}\n\nexport interface SessionEventCapabilities {\n readonly route: NativeRoute;\n readonly nativeVersion?: string;\n readonly assistant: EventFeature;\n readonly reasoning: EventFeature;\n readonly tools: EventFeature;\n readonly approvals: EventFeature;\n}\n\nexport type EventScope =\n | { readonly kind: \"all\" }\n | { readonly kind: \"session\"; readonly sessionId: string }\n | { readonly kind: \"task\"; readonly sessionId: string; readonly taskId: string };\n\nexport interface EventOpenOptions {\n readonly scope: EventScope;\n readonly signal?: AbortSignal;\n}\n\nexport type EventSubscription = AsyncIterable<SessionEvent> & {\n close(): Promise<void>;\n};\n\nexport interface SessionEventSource {\n open(options: EventOpenOptions): Promise<EventSubscription>;\n capabilities(sessionId: string): Promise<SessionEventCapabilities | undefined>;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ export function executionDriver(coordinator, access, open) {
|
|
|
11
11
|
let native;
|
|
12
12
|
try {
|
|
13
13
|
const { selectNative } = await import("../runtime/select-native.js");
|
|
14
|
-
native = await selectNative(definition, input.cwd, input.env, access, open, kind => { selectedHarness = kind; }, input.onApproval, { origin: "sdk" });
|
|
14
|
+
native = await selectNative(definition, input.cwd, input.env, access, open, kind => { selectedHarness = kind; }, input.onApproval, { origin: "sdk" }, input.events);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
throw safeDriverError(error, "HARNESS_FAILED", "Native session startup failed.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-driver.js","sourceRoot":"","sources":["../../src/sdk/execution-driver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,UAAU,eAAe,CAC7B,WAAwB,EACxB,MAAoB,EACpB,IAAmB;IAEnB,OAAO,KAAK,EAAC,KAAK,EAAC,EAAE;QACnB,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtE,MAAM,IAAI,UAAU,CAAC,oBAAoB,EAAE,6DAA6D,CAAC,CAAC;QAC5G,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACpF,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,eAAwC,CAAC;QAC7C,IAAI,MAAqB,CAAC;QAC1B,IAAI,CAAC;YACH,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;YACrE,MAAM,GAAG,MAAM,YAAY,CACzB,UAAU,EACV,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,GAAG,EACT,MAAM,EACN,IAAI,EACJ,IAAI,CAAC,EAAE,GAAG,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC,EACnC,KAAK,CAAC,UAAU,EAChB,EAAE,MAAM,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"execution-driver.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,KAAK,EAAE,gBAAgB,EAAE,yBAAyB,CAAC,CAAC;YAAC,CAAC;oBACpF,CAAC;gBAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;YAAC,CAAC;QACxC,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC1B,IAAI,CAAC;gBAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YAAC,CAAC;YAC7B,OAAO,KAAK,EAAE,CAAC;gBAAC,MAAM,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,gDAAgD,CAAC,CAAC;YAAC,CAAC;oBAC3G,CAAC;gBAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,IAAY,EAAE,OAAe;IACpE,OAAO,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { AdapterOptions, NativeSession } from \"../adapters/types.js\";\nimport type { AccessConfig } from \"../config/access.js\";\nimport { AgentError } from \"../errors.js\";\nimport type { Coordinator } from \"../runtime/coordinator.js\";\nimport type { DriverFactory, ManagedNativeSession } from \"../runtime/types.js\";\nimport type { HarnessKind } from \"./types.js\";\nimport { HostedDelegation } from \"./hosted.js\";\n\nexport type NativeOpener = (options: AdapterOptions) => Promise<NativeSession>;\n\nexport function executionDriver(\n coordinator: Coordinator,\n access: AccessConfig,\n open?: NativeOpener,\n): DriverFactory {\n return async input => {\n if (!(\"kind\" in input.reference) || input.reference.kind !== \"inline\") {\n throw new AgentError(\"INVALID_DEFINITION\", \"The application runner requires an inline agent definition.\");\n }\n const hosted = new HostedDelegation(coordinator, input, input.reference.definition);\n const definition = hosted.prepare();\n let selectedHarness: HarnessKind | undefined;\n let native: NativeSession;\n try {\n const { selectNative } = await import(\"../runtime/select-native.js\");\n native = await selectNative(\n definition,\n input.cwd,\n input.env,\n access,\n open,\n kind => { selectedHarness = kind; },\n input.onApproval,\n { origin: \"sdk\" },\n input.events,\n );\n } catch (error) {\n throw safeDriverError(error, \"HARNESS_FAILED\", \"Native session startup failed.\");\n }\n return wrapNative(native, hosted, selectedHarness!);\n };\n}\n\nfunction wrapNative(native: NativeSession, hosted: HostedDelegation, selectedHarness: HarnessKind): ManagedNativeSession {\n return {\n selectedHarness,\n async turn(prompt) {\n hosted.beginTurn();\n try { return await native.turn(prompt); }\n catch (error) { throw safeDriverError(error, \"HARNESS_FAILED\", \"Native execution failed.\"); }\n finally { await hosted.finishTurn(); }\n },\n async steer(prompt) {\n try { await native.steer(prompt); }\n catch (error) { throw safeDriverError(error, \"HARNESS_FAILED\", \"Native steering failed.\"); }\n },\n async interrupt() {\n hosted.stopManagedWaits();\n try { await native.interrupt(); }\n catch (error) { throw safeDriverError(error, \"CANCEL_FAILED\", \"Native interruption could not be confirmed.\"); }\n finally { await hosted.drain(); }\n },\n async resume() {\n hosted.beginTurn();\n try { return await native.resume(); }\n catch (error) { throw safeDriverError(error, \"HARNESS_FAILED\", \"Native recovery failed.\"); }\n finally { await hosted.finishTurn(); }\n },\n async close() {\n hosted.stopManagedWaits();\n try { await native.close(); }\n catch (error) { throw safeDriverError(error, \"HARNESS_FAILED\", \"Native session cleanup could not be confirmed.\"); }\n finally { await hosted.drain(); }\n },\n };\n}\n\nfunction safeDriverError(error: unknown, code: string, message: string): AgentError {\n return error instanceof AgentError ? error : new AgentError(code, message);\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentDefinition, HarnessKind } from './types.js';
|
|
2
2
|
import type { CompleteResponse, Page, PageOptions, SdkSessionSnapshot as SessionSnapshot, SdkSessionSummary as SessionSummary, SdkTaskDetails as TaskDetails, SdkTaskSnapshot as TaskSnapshot, SdkTaskSummary as TaskSummary, TaskResult, WorkspaceInfo } from '../runtime/snapshots.js';
|
|
3
3
|
import type { ApprovalAction, ApprovalGrant, ApprovalResponse, ApprovalScope, SdkApprovalRequest as ApprovalRequest, TaskState } from '../runtime/task-data.js';
|
|
4
|
+
import type { SessionEventSource } from './event-types.js';
|
|
4
5
|
export interface RunnerOptions {
|
|
5
6
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
6
7
|
readonly access?: AccessSelection;
|
|
@@ -30,6 +31,7 @@ export type AccessConnection = {
|
|
|
30
31
|
};
|
|
31
32
|
export type Delivery = 'queue' | 'steer' | 'interrupt';
|
|
32
33
|
export interface Runner {
|
|
34
|
+
readonly events: SessionEventSource;
|
|
33
35
|
createSession(definition: AgentDefinition, options: {
|
|
34
36
|
readonly cwd: string;
|
|
35
37
|
}): Promise<SessionHandle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-types.js","sourceRoot":"","sources":["../../src/sdk/execution-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AgentDefinition, HarnessKind } from './types.js';\nimport type {\n CompleteResponse, Page, PageOptions, SdkSessionSnapshot as SessionSnapshot,\n SdkSessionSummary as SessionSummary, SdkTaskDetails as TaskDetails,\n SdkTaskSnapshot as TaskSnapshot, SdkTaskSummary as TaskSummary, TaskResult, WorkspaceInfo,\n} from '../runtime/snapshots.js';\nimport type {\n ApprovalAction, ApprovalGrant, ApprovalResponse, ApprovalScope, SdkApprovalRequest as ApprovalRequest, TaskState,\n} from '../runtime/task-data.js';\n\nexport interface RunnerOptions {\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly access?: AccessSelection;\n}\nexport type AccessSelection = Readonly<Partial<Record<HarnessKind, readonly AccessConnection[]>>>;\nexport type AccessConnection =\n | { readonly type:'subscription'; readonly provider?:string }\n | { readonly type:'api-key'; readonly provider?:string; readonly env?:string; readonly envFile?:string;\n readonly baseUrl?:string; readonly wireApi?:'completions'|'responses'; readonly apiVersion?:string; readonly wireModel?:string }\n | { readonly type:'vercel-api-key'; readonly env?:string; readonly envFile?:string }\n | { readonly type:'vercel-oidc'; readonly env?:string; readonly envFile?:string; readonly project?:string };\n\nexport type Delivery = 'queue' | 'steer' | 'interrupt';\nexport interface Runner {\n createSession(definition: AgentDefinition, options: {readonly cwd:string}): Promise<SessionHandle>;\n session(id:string): SessionHandle;\n task(id:string): TaskHandle;\n respond(requestId:string,response:ApprovalResponse): Promise<void>;\n close(): Promise<void>;\n}\nexport interface SessionHandle {\n readonly id:string;\n prompt(text:string,options?:{readonly delivery?:Delivery}): Promise<PromptReceipt>;\n snapshot(): Promise<SessionSnapshot>;\n close(): Promise<void>;\n}\nexport interface PromptReceipt {\n readonly task:TaskHandle;\n readonly requestedDelivery:Delivery;\n readonly effectiveDelivery:Delivery;\n readonly paused?:true;\n readonly blockedByTaskId?:string;\n}\nexport interface TaskHandle {\n readonly id:string;\n readonly sessionId:string;\n readonly result:Promise<TaskResult>;\n snapshot():Promise<TaskSnapshot>;\n inspect():Promise<TaskDetails>;\n watch(options?:{readonly signal?:AbortSignal}):AsyncIterable<TaskSnapshot>;\n responses(options?:{readonly after?:string;readonly signal?:AbortSignal}):AsyncIterable<CompleteResponse>;\n cancel():Promise<TaskSnapshot>;\n}\n\nexport type TerminalState='completed'|'failed'|'cancelled'|'interrupted';\nexport type { ApprovalAction, ApprovalGrant, ApprovalRequest, ApprovalResponse, ApprovalScope, CompleteResponse, Page, PageOptions,\n SessionSnapshot, SessionSummary, TaskDetails, TaskResult, TaskSnapshot, TaskState, TaskSummary, WorkspaceInfo };\n"]}
|
|
1
|
+
{"version":3,"file":"execution-types.js","sourceRoot":"","sources":["../../src/sdk/execution-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AgentDefinition, HarnessKind } from './types.js';\nimport type {\n CompleteResponse, Page, PageOptions, SdkSessionSnapshot as SessionSnapshot,\n SdkSessionSummary as SessionSummary, SdkTaskDetails as TaskDetails,\n SdkTaskSnapshot as TaskSnapshot, SdkTaskSummary as TaskSummary, TaskResult, WorkspaceInfo,\n} from '../runtime/snapshots.js';\nimport type {\n ApprovalAction, ApprovalGrant, ApprovalResponse, ApprovalScope, SdkApprovalRequest as ApprovalRequest, TaskState,\n} from '../runtime/task-data.js';\nimport type { SessionEventSource } from './event-types.js';\n\nexport interface RunnerOptions {\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly access?: AccessSelection;\n}\nexport type AccessSelection = Readonly<Partial<Record<HarnessKind, readonly AccessConnection[]>>>;\nexport type AccessConnection =\n | { readonly type:'subscription'; readonly provider?:string }\n | { readonly type:'api-key'; readonly provider?:string; readonly env?:string; readonly envFile?:string;\n readonly baseUrl?:string; readonly wireApi?:'completions'|'responses'; readonly apiVersion?:string; readonly wireModel?:string }\n | { readonly type:'vercel-api-key'; readonly env?:string; readonly envFile?:string }\n | { readonly type:'vercel-oidc'; readonly env?:string; readonly envFile?:string; readonly project?:string };\n\nexport type Delivery = 'queue' | 'steer' | 'interrupt';\nexport interface Runner {\n readonly events: SessionEventSource;\n createSession(definition: AgentDefinition, options: {readonly cwd:string}): Promise<SessionHandle>;\n session(id:string): SessionHandle;\n task(id:string): TaskHandle;\n respond(requestId:string,response:ApprovalResponse): Promise<void>;\n close(): Promise<void>;\n}\nexport interface SessionHandle {\n readonly id:string;\n prompt(text:string,options?:{readonly delivery?:Delivery}): Promise<PromptReceipt>;\n snapshot(): Promise<SessionSnapshot>;\n close(): Promise<void>;\n}\nexport interface PromptReceipt {\n readonly task:TaskHandle;\n readonly requestedDelivery:Delivery;\n readonly effectiveDelivery:Delivery;\n readonly paused?:true;\n readonly blockedByTaskId?:string;\n}\nexport interface TaskHandle {\n readonly id:string;\n readonly sessionId:string;\n readonly result:Promise<TaskResult>;\n snapshot():Promise<TaskSnapshot>;\n inspect():Promise<TaskDetails>;\n watch(options?:{readonly signal?:AbortSignal}):AsyncIterable<TaskSnapshot>;\n responses(options?:{readonly after?:string;readonly signal?:AbortSignal}):AsyncIterable<CompleteResponse>;\n cancel():Promise<TaskSnapshot>;\n}\n\nexport type TerminalState='completed'|'failed'|'cancelled'|'interrupted';\nexport type { ApprovalAction, ApprovalGrant, ApprovalRequest, ApprovalResponse, ApprovalScope, CompleteResponse, Page, PageOptions,\n SessionSnapshot, SessionSummary, TaskDetails, TaskResult, TaskSnapshot, TaskState, TaskSummary, WorkspaceInfo };\n"]}
|
package/dist/sdk/runner.js
CHANGED
|
@@ -18,9 +18,11 @@ class ApplicationRunner {
|
|
|
18
18
|
coordinator;
|
|
19
19
|
env;
|
|
20
20
|
accepting = true;
|
|
21
|
+
events;
|
|
21
22
|
constructor(coordinator, env) {
|
|
22
23
|
this.coordinator = coordinator;
|
|
23
24
|
this.env = env;
|
|
25
|
+
this.events = coordinator.events;
|
|
24
26
|
}
|
|
25
27
|
async createSession(definition, options) {
|
|
26
28
|
this.assertAccepting();
|
package/dist/sdk/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/sdk/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAqB,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/sdk/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAqB,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C,QAAQ,EAAE,CAAC,CAAC,CAAC;CACzG","sourcesContent":["import { AgentError } from '../errors.js';\nimport { Coordinator } from '../runtime/coordinator.js';\nimport type { ApprovalResponse } from '../runtime/task-data.js';\nimport type { TaskSnapshot } from './execution-types.js';\nimport { captureDefinition } from './execution-definition.js';\nimport { executionDriver, type NativeOpener } from './execution-driver.js';\nimport { delivery, observeOptions, runCwd, runnerConfiguration, validateCwd, validatePrompt, watchOptions } from './execution-options.js';\nimport type { Delivery, PromptReceipt, Runner, RunnerOptions, SessionHandle, TaskHandle } from './execution-types.js';\nimport type { AgentDefinition } from './types.js';\nimport type { SessionEventSource } from './event-types.js';\n\nexport function createRunner(options?:RunnerOptions):Runner { return createApplicationRunner(options); }\n/** Internal test seam replacing only the external native adapter boundary. */\nexport function createRunnerWithNativeOpener(options:RunnerOptions|undefined,open:NativeOpener):Runner {\n return createApplicationRunner(options,open);\n}\n\nfunction createApplicationRunner(options?:RunnerOptions,open?:NativeOpener):Runner {\n const configuration=runnerConfiguration(options);\n let coordinator!:Coordinator;\n coordinator=new Coordinator(input=>executionDriver(coordinator,configuration.access,open)(input));\n return new ApplicationRunner(coordinator,configuration.env);\n}\n\nclass ApplicationRunner implements Runner {\n private accepting=true;\n readonly events:SessionEventSource;\n constructor(private readonly coordinator:Coordinator,private readonly env:NodeJS.ProcessEnv) {\n this.events=coordinator.events;\n }\n\n async createSession(definition:AgentDefinition,options:{readonly cwd:string}):Promise<SessionHandle> {\n this.assertAccepting();\n const captured=captureDefinition(definition);\n const cwd=await validateCwd(runCwd(options));\n this.assertAccepting();\n const id=this.coordinator.createSession({reference:{kind:'inline',definition:captured},cwd,env:{...this.env}});\n return this.session(id);\n }\n session(id:string):SessionHandle {\n this.coordinator.sessionSnapshot(id);\n return new ApplicationSession(this,this.coordinator,id);\n }\n task(id:string):TaskHandle {\n const snapshot=this.coordinator.snapshot(id);\n return new ApplicationTask(this.coordinator,snapshot.taskId,snapshot.sessionId);\n }\n async respond(requestId:string,response:ApprovalResponse):Promise<void> {\n this.assertAccepting(); this.coordinator.respondSdk(requestId,response);\n }\n async close():Promise<void> { this.accepting=false; await this.coordinator.close(); }\n assertAccepting() { if (!this.accepting) throw new AgentError('RUNNER_CLOSED','The application runner is closing or closed.'); }\n}\n\nclass ApplicationSession implements SessionHandle {\n constructor(private readonly runner:ApplicationRunner,private readonly coordinator:Coordinator,readonly id:string) {}\n async prompt(text:string,options?:{readonly delivery?:Delivery}):Promise<PromptReceipt> {\n this.runner.assertAccepting(); validatePrompt(text);\n const requestedDelivery=delivery(options);\n let receipt;\n try { receipt=await this.coordinator.send(this.id,text,requestedDelivery); }\n catch(error) {\n if (error instanceof AgentError && error.code === 'COORDINATOR_UNAVAILABLE')\n throw new AgentError('RUNNER_CLOSED','The application runner is closing or closed.');\n throw error;\n }\n return {task:new ApplicationTask(this.coordinator,receipt.taskId,receipt.sessionId),requestedDelivery,\n effectiveDelivery:receipt.delivery ?? requestedDelivery,\n ...(receipt.paused ? {paused:true as const,blockedByTaskId:receipt.blockedByTaskId!} : {})};\n }\n snapshot() { return this.coordinator.sdkSessionSnapshot(this.id); }\n async close() { await this.coordinator.closeSession(this.id); }\n}\n\nclass ApplicationTask implements TaskHandle {\n private resultPromise?:Promise<import('./execution-types.js').TaskResult>;\n constructor(private readonly coordinator:Coordinator,readonly id:string,readonly sessionId:string) {}\n get result() {\n if (!this.resultPromise) {\n this.resultPromise=this.coordinator.taskResult(this.id);\n void this.resultPromise.catch(()=>undefined);\n }\n return this.resultPromise;\n }\n async snapshot() { return this.coordinator.sdkTaskSnapshot(this.id); }\n async inspect() { return this.coordinator.taskDetails(this.id); }\n watch(options?:{readonly signal?:AbortSignal}) {\n const selected=watchOptions(options); return this.coordinator.watchTask(this.id,selected.signal);\n }\n responses(options?:{readonly after?:string;readonly signal?:AbortSignal}) {\n const selected=observeOptions(options); return this.coordinator.taskResponses(this.id,selected.after,selected.signal);\n }\n async cancel():Promise<TaskSnapshot> { await this.coordinator.cancel(this.id); return this.snapshot(); }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "subharness",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.18.0"
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./extensions": {
|
|
14
|
+
"types": "./dist/extensions.d.ts",
|
|
15
|
+
"import": "./dist/extensions.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"bin": {
|
package/sdk/access-config.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Personal Access Configuration
|
|
2
2
|
|
|
3
|
-
Embedded [execution SDK](execution.md) runners accept explicit `RunnerOptions.access` and an environment snapshot. They use the connection rules here without implicitly loading personal settings or modifying Git excludes. Connected
|
|
3
|
+
Embedded [execution SDK](execution.md) runners accept explicit `RunnerOptions.access` and an environment snapshot. They use the connection rules here without implicitly loading personal settings or modifying Git excludes. Connected SDK creation/check uses the CLI's default project-based personal settings discovery, with the caller's captured environment. SDK clients can also continue CLI-created sessions with their retained project selection.
|
|
4
4
|
|
|
5
|
-
The optional `.subharness/agents.local.json` file selects access independently of versioned agent definitions.
|
|
5
|
+
The optional `.subharness/agents.local.json` file selects access independently of versioned agent definitions. By default, it is read from the Git main checkout root, or from the execution directory outside Git. CLI [logical project selection](project-root.md) with `--root` instead reads it from the corresponding project directory in the main checkout, or from the selected root outside Git. This directory is the **access root**. Global and direct harness targets use the same selected project's preferences; no enclosing settings are merged or used as a fallback.
|
|
6
6
|
|
|
7
7
|
```json
|
|
8
8
|
{
|
|
@@ -71,7 +71,7 @@ For Copilot API keys, default variables are respectively `COPILOT_GITHUB_TOKEN`,
|
|
|
71
71
|
|
|
72
72
|
Gateway connection shapes and billing behavior are unchanged; they do not accept provider overrides. `vercel-oidc` accepts `project`, defaulting to `.`. Unknown or inapplicable fields and missing required provider/source selections fail before native startup. Variable names match `[A-Za-z_][A-Za-z0-9_]*`. Tokens and API keys must never appear directly in this file. Native logins are completed through each harness's own login command, outside Subharness.
|
|
73
73
|
|
|
74
|
-
Without `envFile`, the named variable is read from the invoking environment. With `envFile`, only that variable is read from that explicit UTF-8 dotenv file; its other values are not imported, and the process environment does not override the selected file.
|
|
74
|
+
Without `envFile`, the named variable is read from the invoking environment. With `envFile`, only that variable is read from that explicit UTF-8 dotenv file; its other values are not imported, and the process environment does not override the selected file. Relative file and project paths resolve from the access root, including OIDC's default project `.`; absolute paths keep their supplied locations. With `--root ./apps/my-app`, `.env.local` and `.` therefore refer to that app's main-checkout counterpart, independently of execution `--cwd`. Without `--root`, the base remains the main checkout root, or execution directory outside Git. Embedded runner references retain that default base. Shell expansion and command execution in dotenv values are not supported. Sources are read at native session startup; changing a file does not refresh a token already supplied to a running harness.
|
|
75
75
|
|
|
76
76
|
Omitting `codex` or `claudeCode` retains native subscription discovery. A nonempty array replaces discovery with the listed connections in order. An empty array disables that harness. Supported keys are `codex`, `claudeCode`, `fx`, `opencode`, `copilot`, and `cursor`. The last four require an explicit connection; omission enables no access, even when a native login or ambient key exists. fx, OpenCode, and Copilot accept their documented native login, direct-key, and Gateway routes. Cursor accepts native CLI login or Cursor SDK API-key access and rejects Gateway connections. Each connection selects one billing route without implicit substitution. See [fx](fx.md), [OpenCode](opencode.md), [Copilot](copilot.md), and [Cursor](cursor.md).
|
|
77
77
|
|
|
@@ -85,7 +85,7 @@ Schema validation locations and distinct OIDC temporal errors are defined in [er
|
|
|
85
85
|
|
|
86
86
|
When a connection fails during native startup, `check` and `run` include the harness and attempted connection type in the diagnostic. They retain the original error code and fallback rules. A model configuration failure reported by an already opened session also includes its selected connection context. This context describes the connection attempted by Subharness; it does not claim that the native harness authenticated successfully through that connection.
|
|
87
87
|
|
|
88
|
-
Diagnostics distinguish explicitly configured connections from default native subscription discovery. For settings loaded from disk, they identify the absolute personal settings path
|
|
88
|
+
Diagnostics distinguish explicitly configured connections from default native subscription discovery. For settings loaded from disk, they identify the absolute personal settings path under the selected access root. If the file is absent, the diagnostic says that native subscription discovery was used because no personal access settings were found there. If the file exists but omits the harness's access entry, the diagnostic says that the entry is omitted. An explicit connection identifies its type and its position in the configured list, so multiple connections of the same type remain distinguishable.
|
|
89
89
|
|
|
90
90
|
When the current personal settings file is absent and an entry exists at the former `.agents/agents.local.json` location, the diagnostic also identifies that legacy path and explains that it is not read. Detecting the legacy entry does not read its contents, migrate it, or change connection selection. Failure to inspect the legacy location does not replace the original startup error. Settings presence and selection context are captured when access settings are loaded, so a later file change does not rewrite the explanation for an existing session.
|
|
91
91
|
|
|
@@ -117,7 +117,7 @@ node /path/to/installed/subharness/scripts/refresh-vercel-oidc.mjs \
|
|
|
117
117
|
--org-id team_expected
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
`--env-file` and `--project-dir` are required absolute paths. Resolve the selected connection's `envFile` and `project`
|
|
120
|
+
`--env-file` and `--project-dir` are required absolute paths. Resolve the selected connection's relative `envFile` and `project` from its access root: the main checkout root by default, the corresponding main-checkout app directory with `--root`, or the selected project directory outside Git. Do not assume the current worktree or execution `--cwd` owns the credential source. For an app selected as `--root ./apps/my-app`, the example's absolute arguments would point to `/absolute/main-checkout/apps/my-app/.env.local` and `/absolute/main-checkout/apps/my-app`. The helper's interface is unchanged. `--project-id` and `--org-id` are required expected identities from the established project selection, never inferred from the token. Optional `--env <variable>` selects the configured destination variable and defaults to `VERCEL_OIDC_TOKEN`. Unknown, duplicate, or missing arguments are errors. `--help` prints usage without reading credentials or invoking Vercel. The helper supports file-backed development credentials only; environment-only credentials and other environments remain the environment owner's responsibility.
|
|
121
121
|
|
|
122
122
|
Before invoking Vercel, the helper checks the existing project's `.vercel/project.json`, requires matching identities, and requires an existing regular, non-symlink credential file with exactly one single-line assignment for the selected variable. Tracked credential files are rejected using the source file's own repository, independently of the project directory and inherited Git repository variables. A source outside Git has no tracked-file restriction. It obtains an exclusive lock beside the source; another renewal fails immediately instead of waiting or deleting that lock. Unattended recovery of a lock left by a killed process is outside the helper's scope.
|
|
123
123
|
|
|
@@ -129,10 +129,12 @@ Success exits `0` and prints one JSON record with `type: "oidc_refreshed"`, the
|
|
|
129
129
|
|
|
130
130
|
If cleanup fails after atomic replacement, the helper exits `1` but retains the `oidc_refreshed` record and its safe identity/expiry metadata, adding `code: "OIDC_CLEANUP_FAILED"`, `cleanup: "incomplete"`, and a safe message stating that the credential was refreshed and cleanup needs resolution. If renewal failed before replacement and cleanup also fails, the original safe failure code/message is preserved and `cleanup: "incomplete"` is added. Neither outcome exposes raw filesystem/provider errors. The agent must resolve the incomplete cleanup instead of renewing again merely because the command exited nonzero.
|
|
131
131
|
|
|
132
|
-
After renewal, `subharness check <target>` can verify startup without submitting a model task. A task that failed before submission can be attempted again within its existing authorization. A running native process keeps the credential supplied at startup; renewal neither injects a replacement into that process nor replays already-submitted work. Existing task recovery and explicit eval invocation rules remain unchanged.
|
|
132
|
+
After renewal, `subharness check <target>` can verify startup without submitting a model task. A top-level check for a root-selected session repeats its `--root <directory>`; managed checks inherit that selection and cannot supply the flag. A task that failed before submission can be attempted again within its existing authorization. A running native process keeps the credential supplied at startup; renewal neither injects a replacement into that process nor replays already-submitted work. Existing task recovery and explicit eval invocation rules remain unchanged.
|
|
133
133
|
|
|
134
134
|
## Local file management
|
|
135
135
|
|
|
136
|
-
The file can be edited directly; no library login wizard is required. Before using an existing personal settings file in Git, the CLI ensures
|
|
136
|
+
The file can be edited directly; no library login wizard is required. Before using an existing personal settings file in Git, the CLI rejects it if tracked with guidance to remove it from the index, then ensures its exact repository-relative path is excluded through the owning repository's local Git exclude file. The default pattern remains `/.subharness/agents.local.json`; an app selection excludes only that app's settings path, with Git pattern characters escaped. This can update local excludes during `run` or `check`, but never untracks a file or modifies a committed `.gitignore`. See [personal access and worktrees](project-root.md#personal-access-and-worktrees) for counterpart validation and Git ownership. The library never copies secrets or personal settings into worktrees. A file left at the former `.agents/agents.local.json` location is not read.
|
|
137
137
|
|
|
138
138
|
Native login remains external: the CLI reports which harness needs login when no eligible access exists. It never extracts a subscription token for use by another harness. Explicit API/Gateway startup prevents ambient credentials from silently selecting a competing billing route. Native subscription access and accelerated modes remain subject to provider eligibility and spending controls; the library is not a spending cap.
|
|
139
|
+
|
|
140
|
+
Existing settings files whose repository-relative paths contain line feeds or carriage returns fail with `INVALID_CONFIG` before local exclude changes, because Git's line-based exclude file cannot safely represent their exact paths. Settings outside Git do not need an exclude entry.
|
package/sdk/adapter-contract.md
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
# Native Adapter Contract
|
|
2
2
|
|
|
3
|
-
The [execution SDK](execution.md) reuses native adapters. Embedded runners use an in-process session driver and host-owned custom tools; connected clients use coordinator-owned captured definitions and native sessions. It exposes complete responses
|
|
3
|
+
The [execution SDK](execution.md) reuses native adapters. Embedded runners use an in-process session driver and host-owned custom tools; connected clients use coordinator-owned captured definitions and native sessions. It exposes complete responses, task snapshots and normalized [live session events](events.md). Event content is a bounded, redacted preview whose capabilities depend on the selected native route.
|
|
4
4
|
|
|
5
5
|
Adapters create native Codex, Claude Code, fx, OpenCode, GitHub Copilot, or Cursor conversations in the caller-supplied directory. Their implementation interface is internal and is not an SDK extension API. A session supplies `turn(prompt)`, `steer(prompt)`, `interrupt()`, `resume()`, and `close()`. A turn resolves with its complete text; machine-reported execution failures reject with a stable error code. The Cursor subscription ACP route has the documented limitation that some native backend failures arrive only as assistant text. Interrupt resolves only when active execution has stopped. Unsupported operations return explicit capability errors. Harness-specific contracts are defined for [fx](fx.md), [OpenCode](opencode.md), [Copilot](copilot.md), and [Cursor](cursor.md).
|
|
6
6
|
|
|
7
|
-
[Error diagnostics](diagnostics.md) defines startup failure classification, safe native failure categories, and process termination context. Unexpected Claude account-inspection or model-catalog exceptions are harness failures, not evidence that another access route should be tried.
|
|
7
|
+
[Error diagnostics](diagnostics.md) defines startup failure classification, safe native failure categories, and process termination context. A failed Codex terminal turn is classified from its terminal App Server error category, including the harness-neutral `CONTEXT_WINDOW_EXCEEDED` code; retrying native error notifications do not fail a turn, and freeform native error text is not exposed. Unexpected Claude account-inspection or model-catalog exceptions are harness failures, not evidence that another access route should be tried.
|
|
8
8
|
|
|
9
9
|
Adapter startup receives the selected harness configuration, loaded agent definition, execution directory, environment, and resolved personal access. Startup verifies compatibility and access before submitting any task. A direct CLI harness target supplies no specialist instructions, custom tools, or declared children. Codex, Claude Code, and fx may request a verifiable native default model internally; OpenCode, Copilot, and Cursor require an explicit CLI model. Public SDK constructors always require a model. Default resolution happens before the first prompt, within the authorized access route, and the resolved model is retained for follow-ups. An unavailable or unverifiable default fails with guidance to supply `--model`, without probing it through a paid generation. Explicit model and effort validation remains effective. `HARNESS_UNAVAILABLE` and `ACCESS_UNAVAILABLE` permit trying another declared alternative before submission. Invalid configuration and unsupported explicit options do not. No adapter performs automatic fallback after turn submission.
|
|
10
10
|
|
|
11
11
|
The CLI readiness check uses this same startup and pre-submission fallback path in an isolated worker, then closes the native session without calling `turn`. It therefore verifies only capabilities observable during startup. It does not probe quota with generation, exercise native tools, or establish shell and child-launch permissions. Startup may create an empty native conversation and private temporary files; normal close removes library-owned temporary files under the adapter lifecycle rules.
|
|
12
12
|
|
|
13
|
-
A readiness check reports success only after the isolated worker has exited and every adapter-owned native process has confirmed termination. Native close first permits graceful shutdown and then uses bounded termination when required. If native termination cannot be confirmed, or worker cleanup fails, the check emits an error instead of a readiness record. A failed worker close preserves its cleanup diagnostic while forcibly ending the isolated worker; it does not leave the CLI waiting indefinitely for that worker.
|
|
13
|
+
A readiness check reports success only after the isolated worker has exited and every adapter-owned native process has confirmed termination. Native close first permits graceful shutdown and then uses bounded termination when required. The Codex RPC, fx RPC, and OpenCode native-process owners allow five seconds after `SIGTERM` before escalating to `SIGKILL`; their native-close sequences keep every other step and bound unchanged. If native termination cannot be confirmed, or worker cleanup fails, the check emits an error instead of a readiness record. A failed worker close preserves its cleanup diagnostic while forcibly ending the isolated worker; it does not leave the CLI waiting indefinitely for that worker.
|
|
14
|
+
|
|
15
|
+
Task cancellation and interrupt stop the active native turn without closing the retained native session. Native tool processes that a harness tracks across turns can therefore remain alive after cancellation or task completion. Session close retires native resources, allowing the harness to terminate the tool processes it tracks. Processes deliberately detached outside native tracking are outside both ownership layers and can survive close.
|
|
16
|
+
|
|
17
|
+
Verified evidence covers live Codex 0.157.0 background terminals, live Claude Code 2.1.288 `run_in_background` shells, and source inspection of fx 0.0.12 managed-process cleanup. The fx source also confirms that a deliberately detached daemon released from fx tracking can survive. OpenCode, GitHub Copilot, and Cursor have no equivalent verified tool-process evidence; the general close contract still applies.
|
|
14
18
|
|
|
15
19
|
Agent instructions supplement native instructions. The adapter exposes declared tools without implementing its own model loop. Tool input is validated before the function runs, and returned text or JSON data is encoded as a native text result. Explicit `toolResult` values preserve their text and image blocks through the native protocol, as defined in [custom tools](tools.md). Declared subagents authorize delegation. The Claude adapter translates that authorization into session-only native allow rules for the exact session launcher, declared child invocations, and documented coordination commands. The Codex adapter does not install equivalent launcher rules. Explicit constructor options select the session's native sandbox, network, and approval policy as defined in [Native Permissions](permissions.md); omission preserves native settings. The installed native harness and execution environment continue to enforce their restrictions. Supported active-turn native approvals use the [structured approval flow](approvals.md), keeping the original operation pending until a valid caller answer or native withdrawal. Unsupported interactive input and startup-time requests fail with `INPUT_REQUIRED`; no adapter grants them automatically.
|
|
16
20
|
|
|
@@ -45,3 +49,21 @@ When every eligible connection or declared harness is unavailable, selection rep
|
|
|
45
49
|
An adapter may create a private temporary native configuration file outside the repository to pass explicit API/Gateway credentials without putting secrets in process arguments. The directory uses owner-only access and the file uses mode `0600`. Startup failures and normal session close remove the file. Project settings and coordinator endpoint records never contain those credentials, and subscription tokens are never extracted. Abrupt environment termination does not guarantee cleanup of native temporary files.
|
|
46
50
|
|
|
47
51
|
Cancellation waits for custom tool callbacks already admitted to settle before reporting execution stopped. `execute(input)` has no cancellation signal. The library cannot undo their completed side effects or truthfully report a still-running callback as cancelled.
|
|
52
|
+
|
|
53
|
+
## Normalized observation
|
|
54
|
+
|
|
55
|
+
An adapter's internal event sink receives the owning operation/turn context and emits the normalized event families defined in [Session events](events.md). Its complete-string turn result and stop-confirmation semantics remain unchanged. Native item snapshots, safe text deltas, tool state/results, provider-exposed reasoning and supported approval/error events are correlated before transfer. Known native IDs deduplicate streamed items and complete/tool callback observations; uncertain late frames are never assigned to whichever task is current. No raw native payload is public.
|
|
56
|
+
|
|
57
|
+
Items still open when a turn ends without native completion, including turn failure, transport loss, an invalid native terminal result or interruption, close with `item.completed` and `completion: "interrupted"`. Assistant and reasoning items use state `"interrupted"`; tool items use state `"unknown"`. When native stop remains unconfirmed, open items stay open until the session is retired and then close the same way. Retirement does not invent `turn.completed` for an unconfirmed stop.
|
|
58
|
+
|
|
59
|
+
Each adapter keeps normalization state for at most 1,024 open items per session. Items beyond that bound are not forwarded, and the adapter raises one `session.error` with `category: "capture"` and `origin: "adapter"` per turn that overflows. Effective capabilities may include `SessionEventCapabilities.nativeVersion` only when it is at most 64 bytes of printable ASCII (characters `0x20` through `0x7E`); otherwise the optional field is omitted.
|
|
60
|
+
|
|
61
|
+
The Codex, Claude Code, fx, Copilot and Cursor SDK adapters also track at most 1,024 distinct item identities per turn. After that bound is reached, later new identities are not forwarded and the adapter raises one capture error for the turn. Previously admitted identities may still complete. Identity-bound capture errors do not change the execution outcome.
|
|
62
|
+
|
|
63
|
+
The Copilot SDK route omits `SessionEventCapabilities.nativeVersion`. Its pinned SDK package version is not the native runtime version, and the adapter does not expose a verified runtime version through this capability.
|
|
64
|
+
|
|
65
|
+
Adapters normalize and forward events only while at least one subscriber matches their session. With no subscriber they skip normalization and event IPC while retaining required native execution/protocol handling. Native partial-message options that must be selected at startup, including Claude `includePartialMessages` and Copilot `streaming`, are enabled for every session. This allows late subscribers to receive subsequent supported deltas without reconfiguring or restarting native execution. A delta carries item ID, ordinal, native/synthetic identity, kind, state and tool name when applicable so it can be displayed when its start was not observed. Adapters keep no extra content for later observation. Content from before registration appears only if the native route later supplies it in a snapshot, such as Codex `item/completed` or a Claude assistant message. On chunk-only `fx-acp` and `cursor-acp`, a mid-item turn-boundary snapshot includes only content normalized since registration and uses item state `"incomplete"`. Effective capabilities remain per route; generic ACP variants do not establish vendor emission.
|
|
66
|
+
|
|
67
|
+
Final-response selection, error classification, tool callbacks, approval ownership and native persistence/deletion retain their existing rules. Normalization/redaction occur before event IPC. The owner validates lease/operation identity, ordering and content size. Event-processing failures detected by the owner itself, such as a dropped invalid adapter draft, are `session.error` events with `category: "capture"` and `origin: "owner"`. Owner-raised errors may have category `"execution"` or `"capture"`; adapter-raised errors are capture only. Pending delivery is bounded; a subscriber that falls behind fails with `EVENT_BACKPRESSURE` rather than delaying cancellation, approval replies or complete turn results. Event content is not retained for later observers.
|
|
68
|
+
|
|
69
|
+
Claude's SDK worker and captured definition graphs preserve callback/credential isolation. Execution workers do not import extension code. The coordinator supervises user extensions in separate child processes and delivers only events for their admission-selected sessions; the CLI dashboard consumes live events itself. Embedded runners serve explicit application subscriptions without loading user extensions.
|
package/sdk/agent-skill.md
CHANGED
|
@@ -14,7 +14,7 @@ The installer reads the source repository, so installation requires access to [v
|
|
|
14
14
|
|
|
15
15
|
## Location and discovery
|
|
16
16
|
|
|
17
|
-
The skill's entry point is `skills/subharness/SKILL.md` at the repository root, with its credential helper in `skills/subharness/scripts/refresh-vercel-oidc.mjs`. Its frontmatter `name` is `subharness`, and its `description` states that the skill applies when the human asks the agent to delegate, parallelize, or hand off work to Codex, Claude Code, fx, OpenCode, GitHub Copilot, or Cursor, or to follow up on, check, or
|
|
17
|
+
The skill's entry point is `skills/subharness/SKILL.md` at the repository root, with its credential helper in `skills/subharness/scripts/refresh-vercel-oidc.mjs`. Its frontmatter `name` is `subharness`, and its `description` states that the skill applies when the human asks the agent to delegate, parallelize, or hand off work to Codex, Claude Code, fx, OpenCode, GitHub Copilot, or Cursor, or to follow up on, check, cancel, or close delegated work.
|
|
18
18
|
|
|
19
19
|
`npx skills add vercel-labs/subharness` offers only this skill. The repository's development skills under `.agents/skills/` set `metadata.internal: true` in their frontmatter, which the installer hides by default. That field does not change how native harnesses read those skills.
|
|
20
20
|
|
|
@@ -22,20 +22,23 @@ The skill is not part of the npm package. [Package Distribution](distribution.md
|
|
|
22
22
|
|
|
23
23
|
## Content
|
|
24
24
|
|
|
25
|
-
The skill is concise, task-oriented guidance for the main agent. It agrees with the [CLI](cli/index.md), [Output](cli/output.md), [Message delivery](message-delivery.md),
|
|
25
|
+
The skill is concise, task-oriented guidance for the main agent. It agrees with the [CLI](cli/index.md), [Output](cli/output.md), [Message delivery](message-delivery.md), [Sessions](sessions.md), [Logical project roots](project-root.md), and [Responding to Native Permission Requests](approvals.md) references and introduces no commands, flags, defaults, or behavior they do not document. It covers:
|
|
26
26
|
|
|
27
27
|
- When to delegate: independent, well-scoped work that can run while the conversation continues, and when the human names a harness.
|
|
28
28
|
- Choosing a target: the reserved `codex`, `claude`, `fx`, `opencode`, `copilot`, and `cursor` direct targets, and `subharness list` for discovered specialists.
|
|
29
|
-
-
|
|
29
|
+
- Selecting an app with `--root <directory>` for top-level list/check/run, defaulting execution cwd to that root while permitting an independent `--cwd`. The project owns its agents, access, and extension scope; personal access uses the corresponding main-checkout app directory. Managed children inherit the selection; managed list/run/check calls cannot supply `--root`.
|
|
30
|
+
- Selecting an explicit `.ts` definition file for `run` or `check`, including definitions kept alongside monorepo apps. Relative paths resolve from the invoking directory independently of `--cwd` and `--root`; only that definition and its imports load. Managed callers still use their declared `subagent:` targets.
|
|
31
|
+
- Starting work with `subharness run <target> [--root <directory>] [--cwd <directory>] <prompt>`, `--prompt`, or `--prompt-file`, including quoting a positional prompt and giving the child explicit task context, because children do not receive the main conversation's transcript or loaded skills.
|
|
32
|
+
- Using `--prompt-file <path>` for generated long or multiline prompts, with an owner-private file (`0600` inside a `0700` directory on POSIX), removing it after a `started` or `accepted` record or command exit confirms the CLI read it, and using `--prompt-file -` only when the host owns standard input. The guidance keeps generated prompt payloads out of large argument vectors while noting that unrelated host pressure can still prevent admission.
|
|
30
33
|
- Preferring a single `subharness run <target> <prompt>` through the host's background-task controls when that capability is known to be available. The caller collects that hosted command's output later; a separate `--detach` and `wait` sequence is unnecessary for its first response.
|
|
31
34
|
- Using `subharness run <target> --detach <prompt>` when background-command support is unavailable or uncertain, returning after admission and retaining the task identifier. `wait` returns or awaits the first response and runs only after useful independent work, when the caller is ready to wait. The minimal example contains only `run --detach` and `wait`; `status` is a separate optional nonblocking snapshot, not an unconditional step before or after `wait`.
|
|
32
35
|
- Noting that background execution, process survival, and completion notifications depend on the host; detached admission alone does not provide them.
|
|
33
36
|
- Reading results: the returned session, task, and response identifiers; `subharness wait <task-id>` for the first response; `subharness wait <task-id> --after <response-id>` for the next response; and `subharness status <task-id> --full` for the complete latest response.
|
|
34
37
|
- Answering `approval_required` requests by inspecting the actual action, authorization scope, and request-specific schema. Examples cover an authorized single-use choice, an offered denial, and a grant selection with an explicit duration; examples never establish universal decision values. The caller uses `respond --content` or `--content-file`, then observes the original task with its existing response cursor. Acknowledging an answer does not imply task completion.
|
|
35
38
|
- Distinguishing native denial from task cancellation, validating request ownership, correcting invalid content without replaying the task, and reporting expired requests or hard permission failures without broadening policy.
|
|
36
|
-
- Following up with `subharness send <session-id>` and its `queue`, `steer`, and `interrupt` delivery modes; inspecting work with `subharness queue <session-id>`;
|
|
39
|
+
- Following up with `subharness send <session-id>` and its `queue`, `steer`, and `interrupt` delivery modes; inspecting work with `subharness queue <session-id>`; stopping it with `subharness cancel <task-id>`; and closing sessions that are no longer needed with `subharness close <session-id>`.
|
|
37
40
|
- Reporting results back to the human in the main conversation, rather than relaying raw output.
|
|
38
|
-
- Recovering an expired file-backed development OIDC credential through the lead agent's existing authenticated Vercel CLI for the established project, using the bundled helper without changing other settings, exposing credentials, or replaying submitted work.
|
|
41
|
+
- Recovering an expired file-backed development OIDC credential through the lead agent's existing authenticated Vercel CLI for the established project, using the bundled helper with absolute paths resolved from the selected access root and repeating `--root` on a subsequent top-level check, without changing other settings, exposing credentials, or replaying submitted work.
|
|
39
42
|
- Limits: subharness does not create worktrees or sandboxes, the caller supplies an existing working directory, native authentication stays with each harness, and records do not survive coordinator loss.
|
|
40
43
|
|
|
41
44
|
`subharness --help` and `subharness run <harness> --help` remain the authoritative usage reference; the skill points the agent to them for options it does not cover.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Dashboard presentation
|
|
2
2
|
|
|
3
|
-
This document defines the grouped
|
|
3
|
+
This document defines the grouped overview, agent request list and dedicated task screen. Command lifecycle and history retention are defined in [Live dashboard](index.md#live-dashboard).
|
|
4
4
|
|
|
5
5
|
The dashboard groups agent rows by repository and worktree. Each group has one compact `repository / worktree` label. A repository with multiple worktrees has a separate group for each checkout rather than a shared enclosing section.
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ A session captures its checkout context when admitted. Git subdirectories resolv
|
|
|
29
29
|
|
|
30
30
|
Labels use repository and checkout directory names, not branch names. Ambiguous short labels include a distinguishing parent path. All labels and task titles are sanitized before terminal output.
|
|
31
31
|
|
|
32
|
-
Each task records its latest coordinator-observed update: admission, dispatch or continuation, a selected-harness change, accepted steering, creation or retirement of a native permission request, a complete native response, or a settled lifecycle outcome.
|
|
32
|
+
Each task records its latest coordinator-observed update: admission, dispatch or continuation, a selected-harness change, accepted steering, creation or retirement of a native permission request, a complete native response, or a settled lifecycle outcome. Live text, reasoning and tool events update an open task screen without advancing task/group recency. Snapshot reads, response reads, and cancelling an already settled task do not advance recency. A queued follow-up that has no displayed row does not affect group ordering until displayed. Equal group update times preserve the group's first-observed order in the open dashboard.
|
|
33
33
|
|
|
34
34
|
## Row presentation
|
|
35
35
|
|
|
@@ -53,11 +53,33 @@ The compact fixed header contains the repository/worktree label, the session's o
|
|
|
53
53
|
|
|
54
54
|
The body begins with `Requests`. A paused session queue is explicitly labelled beside it. Queued requests are first, newest admitted first; remaining requests follow newest admitted first. The original one-based admission ordinal is stable and displayed even though rows are reversed. State updates do not otherwise reorder requests. Each row shows ordinal, title, explicit state and execution duration; an undispatched request shows `—` for duration. An unconfirmed stop is explicitly labelled on its request. Selection tracks task identity through reordering and refreshes.
|
|
55
55
|
|
|
56
|
-
Up/Down selects the previous/next request
|
|
56
|
+
Up/Down selects the previous/next request. Enter opens a dedicated task screen for that request; it never expands content inline. Escape from the request list returns to the overview. Selection and scroll context survive returning from a task screen.
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
PageUp/PageDown move request selection by the visible body height; Home/End select the first/last request. The header and footer remain fixed. Selecting a request scrolls its row into view. Narrow and short terminals retain at least one body row.
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
## Task screen
|
|
61
|
+
|
|
62
|
+
The task screen is core CLI behavior. Its fixed header summarizes the agent name, selected harness and model when known, task state, workspace and elapsed execution time. It uses the selected request row immediately and refreshes those row facts while task details are pending or unavailable, so state and finished duration do not regress or keep advancing. A specialist uses its captured definition name; a direct target uses its harness name. An empty captured display name is unknown and falls back to the selected harness name when that harness is known. Other unknown harness/model values are omitted rather than guessed from an unselected alternative. Queued work shows `—` for elapsed execution time. Finished duration remains fixed; unconfirmed stop remains explicit. The original task title can supplement this identity and remains visible when the agent name is not yet known, without filling the missing agent field.
|
|
63
|
+
|
|
64
|
+
The scrolling body contains the original `Request`, live turns and steps, and the latest complete `Response` or `No response yet` once task inspection establishes those facts. During a supported initial detail read, the request section says `Loading task details…` and the response section is omitted. When task details are unavailable, the unknown request is omitted and the response section says `Response unavailable`; it never claims that no response exists. Errors and unconfirmed cancellation remain clearly visible when supplied by task inspection. Opening a task screen starts a task-scoped subscription through the public [live event API](../events.md). Leaving closes it. Only the selected task's own steps are shown; managed descendants appear in their own task screens. The dashboard does not load user extensions or depend on their enablement.
|
|
65
|
+
|
|
66
|
+
Only events accepted after the screen's subscription is registered are displayed as turns and steps. The request, task error and latest complete response remain available through ordinary task inspection. Past events are not loaded into the steps list. Earlier content appears only when the native route itself supplies it in a later snapshot. Adapters keep no extra observation content for late subscribers. The screen labels its live scope so an empty list is not mistaken for a task with no prior activity. Reopening a task begins a new live view. A completed task can show its request/error/latest response with no live steps.
|
|
67
|
+
|
|
68
|
+
Assistant text, provider-exposed reasoning and tools have selectable rows showing a label, explicit state and summary. A tool row uses `Tool · <tool name>`, where `<tool name>` is the normalized event tool name such as `shell` or `read_file`. Its collapsed summary is a one-line preview of the bounded tool input. For the supported shell-command names `shell`, `command`, `Bash` and `shell.run`, matched case-insensitively, a structured input with a non-blank string `command` previews that command; other inputs preview their bounded text. Missing input is labelled `No tool input`. Tool output is not shown in the collapsed summary. Enter expands the selected row's full bounded details. Expanded tool details show the full bounded input and output where delivered, followed by the exit code and duration in milliseconds when present. Assistant and reasoning summaries retain their content previews.
|
|
69
|
+
|
|
70
|
+
The task-screen selection cursor is `›` in the first column. Every expandable row uses `▸` in the next column while collapsed and `▾` while expanded, so the cursor and disclosure marker never repeat the same glyph. `NO_COLOR` preserves these glyphs while disabling only styling.
|
|
71
|
+
|
|
72
|
+
Content follows the [event bounds and redaction](../events.md#content-bounds-and-redaction). A self-describing delta can create a row when the subscription joined mid-item; that row initially shows text received from the join point and is labelled as a partial view. A later native `item.updated` or `item.completed` snapshot replaces the partial view with the content supplied by that route. On chunk-only `fx-acp` and `cursor-acp`, a mid-item turn-boundary snapshot covers only content normalized since registration and uses item state `"incomplete"`. Missing tool results, unavailable reasoning, unknown states and truncation remain explicit. A terminal item update does not by itself establish task completion.
|
|
73
|
+
|
|
74
|
+
An `approval.requested` event creates an `Approval` step row showing the request message and state `pending`. `approval.resolved` creates or updates that request's row with state `answered` or `withdrawn`. The row uses the message received with `approval.requested`; a resolution received without that request shows its state but cannot supply the missing message. A `session.error` event appears as an inline notice row with its safe code and message. Approval rows and session-error notice rows count toward the display bound.
|
|
75
|
+
|
|
76
|
+
The open task screen displays at most 500 steps. As more steps arrive, it drops the oldest and shows a visible notice that earlier steps were omitted. This limit applies only to the dashboard process's display state; it does not change event delivery or other subscribers' state.
|
|
77
|
+
|
|
78
|
+
Up/Down selects previous/next step rows, stops at the ends and scrolls selection into view. Initial selection is the first step when one exists. Enter expands or collapses its details, keyed by turn/item identity for item rows and request identity for Approval rows; moving selection preserves expansion state. Without step rows, Up/Down scrolls the body by one line and Enter has no effect. PageUp/PageDown scroll by available body height; Home/End scroll to the beginning/end. Escape closes the subscription and discards this screen's live display state, returning to the request list with task selection and scroll position preserved. A second Escape returns to the overview. Ctrl+C exits without cancelling agents.
|
|
79
|
+
|
|
80
|
+
New events and response updates preserve reading position and selection. If a selected row disappears, selection moves to the nearest remaining row by its previous position. Explicit End follows the body's end until the user scrolls away or moves selection. The fixed header stays visible; short terminals reduce it to a clipped identity line while preserving at least one body row. A one-row terminal prioritizes selected content. The request list's Sub-agents footer is not repeated here.
|
|
81
|
+
|
|
82
|
+
Prose wraps at up to 100 terminal cells, preferring whitespace and preserving indentation and line breaks. Long unbroken text wraps by grapheme width. Content, labels, states and errors are sanitized before measurement and rendering; native terminal controls are never executed. `NO_COLOR` applies to the whole screen. The CLI owns all layout and input handling. There is no usage/cost report or file attribution. Quiet work is not labelled stalled, waiting does not imply human intervention, and completion does not claim independent verification of success.
|
|
61
83
|
|
|
62
84
|
## Sub-agents footer
|
|
63
85
|
|
|
@@ -67,14 +89,20 @@ The footer is a read-only summary, independent of request selection. It uses at
|
|
|
67
89
|
|
|
68
90
|
## Refresh and compatibility
|
|
69
91
|
|
|
70
|
-
The overview remains a small snapshot. An open
|
|
92
|
+
The overview remains a small snapshot. An open request list requests only that session's metadata. Full prompt/response content is fetched only for the open task screen and retained only for that screen, omitting unchanged content on refresh. Polling is serialized, with each read bounded by a five-second timeout. Changing view/task aborts obsolete reads and ignores late results. Wrapping is reused while text and width are unchanged. Rendering retains bounded pending state under output backpressure and does not redraw unchanged lines.
|
|
93
|
+
|
|
94
|
+
The live subscription is separate from serialized metadata/detail polling. Event consumption updates the bounded display state independently of terminal rendering, so rendering speed never causes subscription backpressure. It supplies only events accepted after registration; the CLI can query current route capabilities separately when needed. Closing or switching task screens closes the previous subscription and ignores its late delivery. When a stream ends normally, steps already displayed remain until the screen closes.
|
|
95
|
+
|
|
96
|
+
If the subscription fails with `EVENT_BACKPRESSURE`, the screen shows its code and safe message and a notice that some steps were missed, then reopens the task-scoped subscription while the screen remains open. Reopen attempts occur at most once every 2 seconds. After 3 consecutive backpressure failures within 60 seconds, including any failed reopen as a failure, automatic retries stop and the screen shows “Live steps paused; reopen the task to retry.” Reopening the task starts a new observation and retry interval. Each subscription receives only subsequent events; it does not recover missed activity. Other event-stream failures show a safe live-observation error while core task inspection remains available.
|
|
97
|
+
|
|
98
|
+
A coordinator lacking `session-events-v1` can still supply core task inspection. In place of live steps, the task screen shows `COORDINATOR_OUTDATED` with guidance to stop the coordinator after active work ends and start a new run, while preserving the header, request, error and latest complete response. Restarting only the dashboard does not reload coordinator code; coordinator restart discards retained history. The SDK event operation still uses `COORDINATOR_INCOMPATIBLE`; this is the dashboard's compatibility presentation. Extension diagnostics are shown only by `subharness extensions list` and remain available through the coordinator's existing safe diagnostics. The dashboard neither loads nor hosts extensions; its task screen displays neither extension diagnostics nor extension log contents.
|
|
71
99
|
|
|
72
100
|
Inspection never sends prompts, steers, cancels, resumes or acknowledges work, starts execution, or restarts the coordinator. The private transport is defined in [Inspection transport](dashboard-inspection.md).
|
|
73
101
|
|
|
74
|
-
Snapshots require finished
|
|
102
|
+
Snapshots require the `history: true` and `grouping: true` markers for finished history and grouped context. Opening a task screen additionally requires the snapshot marker `taskDetails: true`, which covers `DashboardDetail.agentName` and `model`. An absent or false `taskDetails` marker keeps the dashboard running; opening a task screen preserves and refreshes the known request-row header, shows `COORDINATOR_OUTDATED` with the same restart guidance instead of task details, omits the unavailable request, and labels the response `Response unavailable`. It does not retain a loading label when no detail read is active and is not a malformed-detail error. Among these markers, only missing `history` or `grouping` ends the dashboard with `COORDINATOR_OUTDATED` and exit `1`; the exact legacy unknown-operation response for the overview has the same exit behavior. Opening the request list against a coordinator without the history operation reports the same error rather than presenting incomplete history. Other malformed or failed reads report `COORDINATOR_UNAVAILABLE` after terminal cleanup. Restarting a coordinator discards retained history and is never performed automatically.
|
|
75
103
|
|
|
76
104
|
## Shared presentation boundary
|
|
77
105
|
|
|
78
|
-
The terminal command and website demonstration reuse the internal ANSI renderer, layout,
|
|
106
|
+
The terminal command and website demonstration reuse the internal ANSI renderer, overview/request/task layout, live turn/step formatting, text sanitization, input decoding and key-action dispatch. Presentation code accepts explicit dimensions, data and time; it does not discover workspaces, access credentials, read files or contact the coordinator. This boundary adds no public SDK method. The terminal command preserves its existing process lifecycle, serialized reads and backpressure behavior. The website supplies fictional read-only projections and owns its browser terminal lifecycle.
|
|
79
107
|
|
|
80
|
-
The internal `dispatchDashboardKey(renderer, key)` function in `src/cli/dashboard-controller.ts` applies a `DashboardKey` to a `DashboardRenderer` and returns `{ interrupt: boolean; refreshInspection: boolean }`. Interrupt requests process exit only in the CLI host; the browser host instead releases focus. `refreshInspection` is true when
|
|
108
|
+
The internal `dispatchDashboardKey(renderer, key)` function in `src/cli/dashboard-controller.ts` applies a `DashboardKey` to a `DashboardRenderer` and returns `{ interrupt: boolean; refreshInspection: boolean }`. Interrupt requests process exit only in the CLI host; the browser host instead releases focus. `refreshInspection` is true when entering or leaving a request list or task screen invalidates the current inspection scope. After that signal, hosts read the renderer's current view and inspected session/task identity. The CLI host uses that state to cancel obsolete reads and open or close the task-scoped subscription. The website host supplies the corresponding fictional projection and live steps without a coordinator. Moving among request rows, selecting/expanding live step rows, and scrolling within one task screen do not fetch another task's full content. The dispatcher never fetches data, loads user code or schedules timers.
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# Private dashboard inspection transport
|
|
2
2
|
|
|
3
|
-
This authenticated coordinator operation serves the read-only terminal inspector. It is internal, not a public SDK execution method. The
|
|
3
|
+
This authenticated coordinator operation serves the read-only terminal inspector. It is internal, not a public SDK execution method. The overview snapshot remains small and advertises `taskDetails: true` alongside its existing `history: true` and `grouping: true` capability markers. `taskDetails` covers the task-screen `DashboardDetail.agentName` and optional `model` fields.
|
|
4
4
|
|
|
5
5
|
The POST request is `{command: "dashboard-detail", id: string, includePrompt?: boolean, knownResponseId?: string}`. `id` identifies a retained task. `includePrompt` defaults to true; false omits the original prompt. `knownResponseId` optionally identifies a response already cached by this client. Unknown tasks return `UNKNOWN_TASK`; invalid field types return `INVALID_ARGUMENT`.
|
|
6
6
|
|
|
7
|
-
The response is `DashboardDetail`: `{version: 1, type: "dashboard-detail", task: DashboardRow, prompt?: string, response?: {responseId: string, text?: string}, error?: {code: string, message: string}, children: DashboardRelatedTask[], queue: {paused: boolean, tasks: DashboardRelatedTask[]}, stopUnconfirmed: boolean}`. `DashboardRow` is the same task projection used by the list. `DashboardRelatedTask` is `{taskId: string, sessionId: string, harness: DashboardHarness, title: string, state: TaskState}`. Related titles use the same 120 Unicode code-point bound as list titles. Children are direct managed children in admission order; queue tasks are pending follow-ups in dispatch order. Queue context is the session's current queue even when inspecting an older task; it does not imply those queued tasks belong to the historical task.
|
|
7
|
+
The response is `DashboardDetail`: `{version: 1, type: "dashboard-detail", task: DashboardRow, agentName: string, model?: string, prompt?: string, response?: {responseId: string, text?: string}, error?: {code: string, message: string}, children: DashboardRelatedTask[], queue: {paused: boolean, tasks: DashboardRelatedTask[]}, stopUnconfirmed: boolean}`. `DashboardRow` is the same task projection used by the list. `DashboardRelatedTask` is `{taskId: string, sessionId: string, harness: DashboardHarness, title: string, state: TaskState}`. Related titles use the same 120 Unicode code-point bound as list titles. Children are direct managed children in admission order; queue tasks are pending follow-ups in dispatch order. Queue context is the session's current queue even when inspecting an older task; it does not imply those queued tasks belong to the historical task.
|
|
8
8
|
|
|
9
|
-
The
|
|
9
|
+
The task screen uses `agentName` from the captured specialist definition, or the direct harness target name. If captured display metadata supplies an empty agent name, the projection uses the selected harness name when known; an unresolved harness leaves the value empty and the renderer treats it as unknown. `model` is the selected native model when known; it is absent until resolved and never guessed from alternatives. Both display fields are capped at 256 UTF-8 bytes, truncated at valid code-point boundaries with a visible truncation marker, and sanitized on display. This display limit does not change the selected native model identifier. Existing task fields supply harness, workspace, state and timing. These display fields contain no loaded definition or configuration object.
|
|
10
10
|
|
|
11
|
-
The
|
|
11
|
+
The latest complete response is present only when one exists. Its `text` is omitted exactly when its identifier equals `knownResponseId`; otherwise full text is returned. An absent response means no response exists, not unchanged content. Prompt is the full original admitted prompt and is included unless `includePrompt` is false. The task screen keeps the original prompt separate from its summarized agent/task header. Error and stop confirmation are task-scoped. The error code and message are the same retained task error exposed by `status`; the inspector does not add native stderr or diagnostic logs. The response excludes native/internal tokens, environment, loaded definitions and access settings.
|
|
12
12
|
|
|
13
|
-
The client
|
|
13
|
+
The client fetches full content when a task screen opens, retains it only for that screen, and refreshes it with `includePrompt: false` and the cached response identifier. A changed response replaces the cached latest response. Each full prompt and response is already bounded by task admission and native response limits; there is no unbounded transcript transfer. Reads do not acknowledge descendant results, alter timestamps, start execution, or mutate queues. Snapshot/context assembly must remain coherent across asynchronous workspace resolution.
|
|
14
|
+
|
|
15
|
+
Before requesting task-screen details, the client requires the overview snapshot's `taskDetails: true` marker. An absent or false `taskDetails` marker keeps the dashboard running; the task screen preserves and refreshes the selected request row's known header facts, shows `COORDINATOR_OUTDATED` instead of task details, omits the unknown request, and shows `Response unavailable` without a loading label. Missing `history` or `grouping` markers instead end the dashboard with `COORDINATOR_OUTDATED` and exit `1`. Restarting only the dashboard does not reload coordinator code; coordinator restart discards retained history. The client does not misclassify an older coordinator's lack of these fields as malformed data. A nonboolean marker is malformed. With the capability present, the client validates identity, structure, lifecycle state, workspace paths, agent/model bounds, timestamps, error and content omission semantics before displaying a record. A malformed, failed or timed-out read exits with `COORDINATOR_UNAVAILABLE` after terminal cleanup. The exact legacy unknown-operation response for this operation reports `COORDINATOR_OUTDATED` with restart guidance. A coordinator that supports the existing overview but lacks inspection can show its list until Enter requests inspection. It is never restarted automatically.
|
|
14
16
|
|
|
15
17
|
## Agent-session history transport
|
|
16
18
|
|
|
@@ -22,4 +24,10 @@ Sub-agents are direct managed child sessions referenced by any retained task in
|
|
|
22
24
|
|
|
23
25
|
The projection is coherent across asynchronous workspace discovery and does not mutate recency, acknowledge responses or transfer full prompts/responses, credentials, environment or native transcript content. The client validates identity, unique task IDs and ordinals, exact request ordering, lifecycle fields, related session uniqueness and bounded titles before rendering. The exact legacy unknown-operation error maps to `COORDINATOR_OUTDATED`; malformed records, other errors, failed HTTP responses and timeouts map to `COORDINATOR_UNAVAILABLE`.
|
|
24
26
|
|
|
25
|
-
The existing `dashboard-detail` operation remains task-scoped and supplies content only for
|
|
27
|
+
The existing `dashboard-detail` operation remains task-scoped and supplies content only for the open task screen. Its prompt and response omission rules remain unchanged. The dashboard does not render that operation's legacy child and queue sections because the history projection supplies the session-wide footer and queued request rows.
|
|
28
|
+
|
|
29
|
+
## Live observation boundary
|
|
30
|
+
|
|
31
|
+
Neither projection carries assistant deltas, reasoning or tool streams. The dashboard itself opens a task-scoped subscription through the public [live event API](../events.md) when the task screen opens, renders arriving turns/steps, and closes the subscription when leaving. Private inspection supplies the original request, task error and latest complete response; it does not populate earlier steps. Earlier content appears only when the native route itself later supplies it in a snapshot; adapters keep no extra content for later observation. For mid-item joins on chunk-only `fx-acp` and `cursor-acp`, turn-boundary snapshots cover only content normalized since registration and use item state `"incomplete"`. Only the selected task's steps are shown; managed descendants have their own task screens. Approval request/resolution events render `Approval` rows with `pending`, `answered` or `withdrawn` state and the observed request message; session errors render inline notice rows. These rows count toward the same bound as item steps. The open task screen keeps at most 500 steps, dropping the oldest with a visible omission notice; this is a dashboard display-state limit, not a private projection or event-delivery limit. User extensions are supervised separately by the coordinator and are not loaded by the dashboard.
|
|
32
|
+
|
|
33
|
+
Private reads and event subscriptions neither acknowledge managed child responses nor alter execution recency. Missing `session-events-v1` support displays `COORDINATOR_OUTDATED` and the same restart guidance in place of live steps, while core inspection remains usable. Other live-stream failures produce safe task-screen diagnostics. Event consumption updates display state independently of rendering. On `EVENT_BACKPRESSURE`, the screen reports that some steps were missed and follows the [bounded retry policy](dashboard-design.md#refresh-and-compatibility): at most one reopen every 2 seconds, stopping after 3 consecutive failures within 60 seconds, with failed reopens counted. It then shows “Live steps paused; reopen the task to retry.” Past events remain unavailable. The task screen does not display extension diagnostics or extension log contents; the dashboard neither loads nor hosts extensions. Missing/malformed required inspection data retains the compatibility/failure rules above. Switching tasks aborts old detail reads and closes old live subscriptions; late results are ignored by task/view identity.
|