subharness 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/README.md +18 -6
  2. package/dist/adapters/claude-events.d.ts +71 -0
  3. package/dist/adapters/claude-events.js +860 -0
  4. package/dist/adapters/claude-events.js.map +1 -0
  5. package/dist/adapters/claude-worker-client.d.ts +11 -0
  6. package/dist/adapters/claude-worker-client.js +219 -5
  7. package/dist/adapters/claude-worker-client.js.map +1 -1
  8. package/dist/adapters/claude-worker-protocol.d.ts +58 -0
  9. package/dist/adapters/claude-worker-protocol.js.map +1 -1
  10. package/dist/adapters/claude-worker.js +48 -3
  11. package/dist/adapters/claude-worker.js.map +1 -1
  12. package/dist/adapters/claude.d.ts +5 -1
  13. package/dist/adapters/claude.js +14 -2
  14. package/dist/adapters/claude.js.map +1 -1
  15. package/dist/adapters/codex-events.d.ts +52 -0
  16. package/dist/adapters/codex-events.js +672 -0
  17. package/dist/adapters/codex-events.js.map +1 -0
  18. package/dist/adapters/codex-turn-failure.d.ts +2 -0
  19. package/dist/adapters/codex-turn-failure.js +116 -0
  20. package/dist/adapters/codex-turn-failure.js.map +1 -0
  21. package/dist/adapters/codex.js +44 -7
  22. package/dist/adapters/codex.js.map +1 -1
  23. package/dist/adapters/copilot-events.d.ts +68 -0
  24. package/dist/adapters/copilot-events.js +650 -0
  25. package/dist/adapters/copilot-events.js.map +1 -0
  26. package/dist/adapters/copilot.js +24 -4
  27. package/dist/adapters/copilot.js.map +1 -1
  28. package/dist/adapters/cursor-acp-events.d.ts +36 -0
  29. package/dist/adapters/cursor-acp-events.js +251 -0
  30. package/dist/adapters/cursor-acp-events.js.map +1 -0
  31. package/dist/adapters/cursor-cli-session.d.ts +1 -0
  32. package/dist/adapters/cursor-cli-session.js +26 -5
  33. package/dist/adapters/cursor-cli-session.js.map +1 -1
  34. package/dist/adapters/cursor-cli.js +5 -0
  35. package/dist/adapters/cursor-cli.js.map +1 -1
  36. package/dist/adapters/cursor-sdk-events.d.ts +30 -0
  37. package/dist/adapters/cursor-sdk-events.js +233 -0
  38. package/dist/adapters/cursor-sdk-events.js.map +1 -0
  39. package/dist/adapters/cursor-session.js +56 -7
  40. package/dist/adapters/cursor-session.js.map +1 -1
  41. package/dist/adapters/cursor-startup.js +8 -2
  42. package/dist/adapters/cursor-startup.js.map +1 -1
  43. package/dist/adapters/event-normalizer.d.ts +57 -0
  44. package/dist/adapters/event-normalizer.js +143 -0
  45. package/dist/adapters/event-normalizer.js.map +1 -0
  46. package/dist/adapters/event-secrets.d.ts +17 -0
  47. package/dist/adapters/event-secrets.js +28 -0
  48. package/dist/adapters/event-secrets.js.map +1 -0
  49. package/dist/adapters/event-types.d.ts +58 -0
  50. package/dist/adapters/event-types.js +2 -0
  51. package/dist/adapters/event-types.js.map +1 -0
  52. package/dist/adapters/fx-events.d.ts +37 -0
  53. package/dist/adapters/fx-events.js +393 -0
  54. package/dist/adapters/fx-events.js.map +1 -0
  55. package/dist/adapters/fx-rpc.d.ts +2 -0
  56. package/dist/adapters/fx-rpc.js +11 -5
  57. package/dist/adapters/fx-rpc.js.map +1 -1
  58. package/dist/adapters/fx.js +73 -8
  59. package/dist/adapters/fx.js.map +1 -1
  60. package/dist/adapters/opencode-events.d.ts +58 -0
  61. package/dist/adapters/opencode-events.js +653 -0
  62. package/dist/adapters/opencode-events.js.map +1 -0
  63. package/dist/adapters/opencode-http.d.ts +1 -0
  64. package/dist/adapters/opencode-http.js +8 -7
  65. package/dist/adapters/opencode-http.js.map +1 -1
  66. package/dist/adapters/opencode.js +50 -9
  67. package/dist/adapters/opencode.js.map +1 -1
  68. package/dist/adapters/rpc.d.ts +2 -0
  69. package/dist/adapters/rpc.js +11 -5
  70. package/dist/adapters/rpc.js.map +1 -1
  71. package/dist/adapters/types.d.ts +2 -0
  72. package/dist/adapters/types.js.map +1 -1
  73. package/dist/cli/args.d.ts +3 -1
  74. package/dist/cli/args.js +25 -1
  75. package/dist/cli/args.js.map +1 -1
  76. package/dist/cli/dashboard-client.d.ts +1 -0
  77. package/dist/cli/dashboard-client.js +13 -1
  78. package/dist/cli/dashboard-client.js.map +1 -1
  79. package/dist/cli/dashboard-controller.js +6 -7
  80. package/dist/cli/dashboard-controller.js.map +1 -1
  81. package/dist/cli/dashboard-detail-view.d.ts +14 -8
  82. package/dist/cli/dashboard-detail-view.js +15 -44
  83. package/dist/cli/dashboard-detail-view.js.map +1 -1
  84. package/dist/cli/dashboard-history-view.d.ts +3 -12
  85. package/dist/cli/dashboard-history-view.js +18 -82
  86. package/dist/cli/dashboard-history-view.js.map +1 -1
  87. package/dist/cli/dashboard-live.d.ts +32 -0
  88. package/dist/cli/dashboard-live.js +177 -0
  89. package/dist/cli/dashboard-live.js.map +1 -0
  90. package/dist/cli/dashboard-renderer.d.ts +21 -1
  91. package/dist/cli/dashboard-renderer.js +85 -21
  92. package/dist/cli/dashboard-renderer.js.map +1 -1
  93. package/dist/cli/dashboard-steps.d.ts +53 -0
  94. package/dist/cli/dashboard-steps.js +157 -0
  95. package/dist/cli/dashboard-steps.js.map +1 -0
  96. package/dist/cli/dashboard-task-format.d.ts +15 -0
  97. package/dist/cli/dashboard-task-format.js +119 -0
  98. package/dist/cli/dashboard-task-format.js.map +1 -0
  99. package/dist/cli/dashboard-task-view.d.ts +66 -0
  100. package/dist/cli/dashboard-task-view.js +325 -0
  101. package/dist/cli/dashboard-task-view.js.map +1 -0
  102. package/dist/cli/dashboard.d.ts +2 -0
  103. package/dist/cli/dashboard.js +71 -6
  104. package/dist/cli/dashboard.js.map +1 -1
  105. package/dist/cli/extensions-client.d.ts +23 -0
  106. package/dist/cli/extensions-client.js +147 -0
  107. package/dist/cli/extensions-client.js.map +1 -0
  108. package/dist/cli/extensions.d.ts +14 -0
  109. package/dist/cli/extensions.js +181 -0
  110. package/dist/cli/extensions.js.map +1 -0
  111. package/dist/cli/help.d.ts +1 -0
  112. package/dist/cli/help.js +21 -0
  113. package/dist/cli/help.js.map +1 -1
  114. package/dist/cli/main.js +54 -2
  115. package/dist/cli/main.js.map +1 -1
  116. package/dist/cli/output.js +1 -0
  117. package/dist/cli/output.js.map +1 -1
  118. package/dist/events/content.d.ts +43 -0
  119. package/dist/events/content.js +249 -0
  120. package/dist/events/content.js.map +1 -0
  121. package/dist/events/queue.d.ts +59 -0
  122. package/dist/events/queue.js +144 -0
  123. package/dist/events/queue.js.map +1 -0
  124. package/dist/events/validate.d.ts +22 -0
  125. package/dist/events/validate.js +542 -0
  126. package/dist/events/validate.js.map +1 -0
  127. package/dist/extensions/catalog.d.ts +33 -0
  128. package/dist/extensions/catalog.js +101 -0
  129. package/dist/extensions/catalog.js.map +1 -0
  130. package/dist/extensions/child-protocol.d.ts +38 -0
  131. package/dist/extensions/child-protocol.js +2 -0
  132. package/dist/extensions/child-protocol.js.map +1 -0
  133. package/dist/extensions/child.d.ts +1 -0
  134. package/dist/extensions/child.js +125 -0
  135. package/dist/extensions/child.js.map +1 -0
  136. package/dist/extensions/consent.d.ts +13 -0
  137. package/dist/extensions/consent.js +204 -0
  138. package/dist/extensions/consent.js.map +1 -0
  139. package/dist/extensions/environment.d.ts +1 -0
  140. package/dist/extensions/environment.js +12 -0
  141. package/dist/extensions/environment.js.map +1 -0
  142. package/dist/extensions/identity.d.ts +9 -0
  143. package/dist/extensions/identity.js +28 -0
  144. package/dist/extensions/identity.js.map +1 -0
  145. package/dist/extensions/log.d.ts +5 -0
  146. package/dist/extensions/log.js +80 -0
  147. package/dist/extensions/log.js.map +1 -0
  148. package/dist/extensions/manifest.d.ts +7 -0
  149. package/dist/extensions/manifest.js +213 -0
  150. package/dist/extensions/manifest.js.map +1 -0
  151. package/dist/extensions/types.d.ts +24 -0
  152. package/dist/extensions/types.js +2 -0
  153. package/dist/extensions/types.js.map +1 -0
  154. package/dist/extensions.d.ts +5 -0
  155. package/dist/extensions.js +2 -0
  156. package/dist/extensions.js.map +1 -0
  157. package/dist/index.d.ts +1 -0
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime/approval-registry.d.ts +6 -2
  160. package/dist/runtime/approval-registry.js +31 -3
  161. package/dist/runtime/approval-registry.js.map +1 -1
  162. package/dist/runtime/capture.js +45 -13
  163. package/dist/runtime/capture.js.map +1 -1
  164. package/dist/runtime/coordinator.d.ts +8 -4
  165. package/dist/runtime/coordinator.js +128 -26
  166. package/dist/runtime/coordinator.js.map +1 -1
  167. package/dist/runtime/daemon.js +9 -1
  168. package/dist/runtime/daemon.js.map +1 -1
  169. package/dist/runtime/dashboard.d.ts +4 -0
  170. package/dist/runtime/dashboard.js +8 -0
  171. package/dist/runtime/dashboard.js.map +1 -1
  172. package/dist/runtime/event-operation.d.ts +41 -0
  173. package/dist/runtime/event-operation.js +290 -0
  174. package/dist/runtime/event-operation.js.map +1 -0
  175. package/dist/runtime/event-owner.d.ts +94 -0
  176. package/dist/runtime/event-owner.js +429 -0
  177. package/dist/runtime/event-owner.js.map +1 -0
  178. package/dist/runtime/event-source.d.ts +39 -0
  179. package/dist/runtime/event-source.js +344 -0
  180. package/dist/runtime/event-source.js.map +1 -0
  181. package/dist/runtime/extension-instance.d.ts +61 -0
  182. package/dist/runtime/extension-instance.js +356 -0
  183. package/dist/runtime/extension-instance.js.map +1 -0
  184. package/dist/runtime/extension-protocol.d.ts +47 -0
  185. package/dist/runtime/extension-protocol.js +33 -0
  186. package/dist/runtime/extension-protocol.js.map +1 -0
  187. package/dist/runtime/extension-service.d.ts +10 -0
  188. package/dist/runtime/extension-service.js +35 -0
  189. package/dist/runtime/extension-service.js.map +1 -0
  190. package/dist/runtime/extension-supervisor.d.ts +33 -0
  191. package/dist/runtime/extension-supervisor.js +251 -0
  192. package/dist/runtime/extension-supervisor.js.map +1 -0
  193. package/dist/runtime/select-native.d.ts +2 -1
  194. package/dist/runtime/select-native.js +26 -2
  195. package/dist/runtime/select-native.js.map +1 -1
  196. package/dist/runtime/service.d.ts +5 -0
  197. package/dist/runtime/service.js +83 -9
  198. package/dist/runtime/service.js.map +1 -1
  199. package/dist/runtime/session-event-wire.d.ts +29 -0
  200. package/dist/runtime/session-event-wire.js +2 -0
  201. package/dist/runtime/session-event-wire.js.map +1 -0
  202. package/dist/runtime/session-events-service.d.ts +8 -0
  203. package/dist/runtime/session-events-service.js +124 -0
  204. package/dist/runtime/session-events-service.js.map +1 -0
  205. package/dist/runtime/session-events-transport.d.ts +8 -0
  206. package/dist/runtime/session-events-transport.js +142 -0
  207. package/dist/runtime/session-events-transport.js.map +1 -0
  208. package/dist/runtime/startup-lock.d.ts +2 -0
  209. package/dist/runtime/startup-lock.js +49 -5
  210. package/dist/runtime/startup-lock.js.map +1 -1
  211. package/dist/runtime/state.d.ts +2 -1
  212. package/dist/runtime/state.js +4 -0
  213. package/dist/runtime/state.js.map +1 -1
  214. package/dist/runtime/transport.d.ts +1 -0
  215. package/dist/runtime/transport.js +2 -0
  216. package/dist/runtime/transport.js.map +1 -1
  217. package/dist/runtime/types.d.ts +22 -0
  218. package/dist/runtime/types.js.map +1 -1
  219. package/dist/runtime/worker-client.js +42 -13
  220. package/dist/runtime/worker-client.js.map +1 -1
  221. package/dist/runtime/worker-event-channel.d.ts +30 -0
  222. package/dist/runtime/worker-event-channel.js +141 -0
  223. package/dist/runtime/worker-event-channel.js.map +1 -0
  224. package/dist/runtime/worker-event-protocol.d.ts +88 -0
  225. package/dist/runtime/worker-event-protocol.js +114 -0
  226. package/dist/runtime/worker-event-protocol.js.map +1 -0
  227. package/dist/runtime/worker-events.d.ts +73 -0
  228. package/dist/runtime/worker-events.js +704 -0
  229. package/dist/runtime/worker-events.js.map +1 -0
  230. package/dist/runtime/worker-server.d.ts +3 -1
  231. package/dist/runtime/worker-server.js +63 -8
  232. package/dist/runtime/worker-server.js.map +1 -1
  233. package/dist/sdk/connected-events.d.ts +3 -0
  234. package/dist/sdk/connected-events.js +259 -0
  235. package/dist/sdk/connected-events.js.map +1 -0
  236. package/dist/sdk/connected-types.d.ts +2 -0
  237. package/dist/sdk/connected-types.js.map +1 -1
  238. package/dist/sdk/connected.js +3 -0
  239. package/dist/sdk/connected.js.map +1 -1
  240. package/dist/sdk/event-types.d.ts +182 -0
  241. package/dist/sdk/event-types.js +2 -0
  242. package/dist/sdk/event-types.js.map +1 -0
  243. package/dist/sdk/execution-driver.js +1 -1
  244. package/dist/sdk/execution-driver.js.map +1 -1
  245. package/dist/sdk/execution-types.d.ts +2 -0
  246. package/dist/sdk/execution-types.js.map +1 -1
  247. package/dist/sdk/runner.js +2 -0
  248. package/dist/sdk/runner.js.map +1 -1
  249. package/package.json +5 -1
  250. package/sdk/adapter-contract.md +25 -3
  251. package/sdk/agent-skill.md +3 -2
  252. package/sdk/cli/dashboard-design.md +37 -9
  253. package/sdk/cli/dashboard-inspection.md +14 -6
  254. package/sdk/cli/extensions.md +44 -0
  255. package/sdk/cli/index.md +27 -4
  256. package/sdk/cli/output.md +13 -1
  257. package/sdk/completion-notifications.md +2 -2
  258. package/sdk/config.md +31 -2
  259. package/sdk/copilot.md +1 -1
  260. package/sdk/cursor.md +2 -2
  261. package/sdk/diagnostics.md +68 -0
  262. package/sdk/distribution.md +13 -3
  263. package/sdk/events.md +339 -0
  264. package/sdk/execution.md +26 -7
  265. package/sdk/extensions.md +181 -0
  266. package/sdk/fx.md +4 -2
  267. package/sdk/harnesses.md +1 -1
  268. package/sdk/index.md +3 -0
  269. package/sdk/message-delivery.md +2 -0
  270. package/sdk/opencode.md +1 -1
  271. package/sdk/project-team.md +10 -4
  272. package/sdk/sessions.md +4 -0
  273. package/sdk/v1-runtime.md +14 -4
@@ -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,CAClB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MA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E,CAAC;YACnB,IAAI,CAAC;gBAAC,OAAO,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;YAAC,CAAC;YACrC,OAAO,KAAK,EAAE,CAAC;gBAAC,MAAM,eAAe,CAAC,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 );\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
+ {"version":3,"file":"execution-driver.js","sourceRoot":"","sources":["../../src/sdk/execution-driver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAA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BAAC,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"]}
@@ -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();
@@ -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;AAI1I,MAAM,UAAU,YAAY,CAAC,OAAsB,IAAW,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACxG,8EAA8E;AAC9E,MAAM,UAAU,4BAA4B,CAAC,OAA+B,EAAC,IAAiB;IAC5F,OAAO,uBAAuB,CAAC,OAAO,EAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAsB,EAAC,IAAkB;IACxE,MAAM,aAAa,GAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,WAAwB,CAAC;IAC7B,WAAW,GAAC,IAAI,WAAW,CAAC,KAAK,CAAA,EAAE,CAAA,eAAe,CAAC,WAAW,EAAC,aAAa,CAAC,MAAM,EAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAClG,OAAO,IAAI,iBAAiB,CAAC,WAAW,EAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED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AI,CAAC,EAAE,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnG,CAAC;IACD,SAAS,CAAC,OAA8D;QACtE,MAAM,QAAQ,GAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAAC,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAC,QAAQ,CAAC,KAAK,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxH,CAAC;IACD,KAAK,CAAC,MAAM,KAA2B,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,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';\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 constructor(private readonly coordinator:Coordinator,private readonly env:NodeJS.ProcessEnv) {}\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"]}
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;AAK1I,MAAM,UAAU,YAAY,CAAC,OAAsB,IAAW,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACxG,8EAA8E;AAC9E,MAAM,UAAU,4BAA4B,CAAC,OAA+B,EAAC,IAAiB;IAC5F,OAAO,uBAAuB,CAAC,OAAO,EAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAsB,EAAC,IAAkB;IACxE,MAAM,aAAa,GAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,WAAwB,CAAC;IAC7B,WAAW,GAAC,IAAI,WAAW,CAAC,KAAK,CAAA,EAAE,CAAA,eAAe,CAAC,WAAW,EAAC,aAAa,CAAC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OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACjE,KAAK,CAAC,OAAuC;QAC3C,MAAM,QAAQ,GAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAAC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnG,CAAC;IACD,SAAS,CAAC,OAA8D;QACtE,MAAM,QAAQ,GAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAAC,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAC,QAAQ,CAAC,KAAK,EAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxH,CAAC;IACD,KAAK,CAAC,MAAM,KAA2B,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,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.7",
3
+ "version": "0.0.9",
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": {
@@ -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 and task snapshots, without promising a native token/tool-progress stream.
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.
@@ -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 cancel delegated work.
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
 
@@ -27,13 +27,14 @@ The skill is concise, task-oriented guidance for the main agent. It agrees with
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
  - Starting work with `subharness run <target> [--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.
30
+ - 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
31
  - 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
32
  - 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
33
  - Noting that background execution, process survival, and completion notifications depend on the host; detached admission alone does not provide them.
33
34
  - 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
35
  - 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
36
  - 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>`; and stopping it with `subharness cancel <task-id>`.
37
+ - 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
38
  - Reporting results back to the human in the main conversation, rather than relaying raw output.
38
39
  - 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.
39
40
  - 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.
@@ -1,6 +1,6 @@
1
1
  # Dashboard presentation
2
2
 
3
- This document defines the grouped dashboard presentation. Command lifecycle and history retention are defined in [Live dashboard](index.md#live-dashboard).
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. Token streaming and internal tool activity are not observed by this display. 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.
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 and collapses any expanded content when selection changes. Enter toggles the selected request's inline details. Only one request can be expanded. Its indented content contains an error first when present, `Request` with the original prompt, and `Response` with its latest complete response or `No response yet`. Unconfirmed cancellation is explicitly identified. Enter collapses the request again; Escape always returns to the overview.
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
- With no expansion, PageUp/PageDown move selection by the visible body height, and Home/End select the first/last request. With expansion, PageUp/PageDown scroll the body and Home/End scroll to the start/end of the expanded request's content. The header and footer remain fixed. Response updates preserve the reading offset; explicit End enables following the expanded content's end until the user scrolls away or changes selection. Selecting a request scrolls its row into view. Narrow and short terminals retain at least one body row.
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
- Expanded prose wraps at up to 100 terminal cells, preferring whitespace boundaries and preserving original indentation and line breaks. Long unbroken text wraps by grapheme display width. All content and errors are sanitized before display; native terminal control sequences are never executed. The screen does not show a native transcript, tool stream, model reasoning, 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.
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 history requests only metadata for that session; full prompt/response content is fetched only for the expanded request. Polling is serialized, with each read bounded by a five-second timeout. Changing view or expanded request aborts obsolete reads and ignores late results. Prompt and response text are cached only for the current expansion, and unchanged content is not retransmitted. Wrapping is reused while text and width remain unchanged. Rendering retains bounded pending state under output backpressure and does not redraw unchanged lines.
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-history and grouped-context capabilities. A missing capability or the exact legacy unknown-operation response reports `COORDINATOR_OUTDATED` with restart guidance. Opening history 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.
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, history/detail 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.
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 a successful open, toggle, leave or selected-request change invalidates the previous inspection read, including collapsing an expanded request by changing selection. Hosts cancel obsolete reads or load their local sample projection after that signal. Overview movement and scrolling an unchanged expansion do not request new detail reads. The dispatcher never fetches data or schedules timers.
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 general snapshot remains small and unchanged.
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 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 inspector derives an untruncated first-line title from that cached prompt. 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.
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 client fetches full content when a request is expanded, retains it only for that expansion, 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.
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 validates identity, structure, lifecycle state, workspace paths, 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.
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 an expanded history request. 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.
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.
@@ -0,0 +1,44 @@
1
+ # Extension commands
2
+
3
+ Extensions are optional, user-developed event handlers supervised by the coordinator. [User extensions](../extensions.md) defines their API, manifest and process lifetime. Management commands read manifests and `~/.subharness/extensions.json`; they never import extension modules or start an agent.
4
+
5
+ ```sh
6
+ subharness extensions --help
7
+ subharness extensions list
8
+ subharness extensions enable <global:id|repo:id>
9
+ subharness extensions disable <global:id|repo:id>
10
+ ```
11
+
12
+ `subharness extensions` without a subcommand prints the extensions usage to stderr and exits `2`. `subharness extensions --help` prints that usage to stdout and exits `0`. All subcommands accept `--help`; no other options or extra arguments are accepted. Repository scope resolves the command's directory to its canonical worktree root, or to that directory outside Git. Run repository commands in the checkout being managed. Enable/disable require qualified references, so an installation never silently shadows another. Instance identity is the qualified reference plus the canonical checkout for repository extensions; global instances have no checkout component. Failure state, eligibility and re-enablement are scoped to that identity. Enabling `repo:<id>` in one checkout affects only its instance, even when another checkout has the same extension ID.
13
+
14
+ `list` reads `~/.subharness/extensions/<id>/extension.json` and `<worktree>/.subharness/extensions/<id>/extension.json`. It shows qualified ID, version, location, enabled/disabled consent, static validation status, the actual instance log path under the selected coordinator's state directory, each applicable instance's `running`, `idle` or `disabled` runtime state, and its diagnostics. Enabled consent is not proof a process is running. After an instance fails, that instance identity is ineligible for newly admitted sessions until explicit re-enablement or coordinator restart resets its runtime restriction. Other checkouts' instances retain their own failure and eligibility state. Runtime status reflects only that coordinator; commands do not start a coordinator merely to obtain it. An absent coordinator is reported as no active coordinator status. Discovery or consent-read failures that occurred during session admission appear in a separate admission-diagnostics section because they may not identify an instance. Session admission remains successful without extension delivery.
15
+
16
+ List and the coordinator's extension-status operation each report at most 256 instances. When more instances exist, list states exactly how many additional instances were omitted. Each instance shows at most its eight most recent diagnostics. The separate admission-diagnostics section shows at most the 16 most recent entries.
17
+
18
+ A reachable coordinator that does not support the extension-status operation produces a line stating that the coordinator does not report extension status and suggesting a restart; list still exits `0`. Listing never evaluates modules, fetches packages or invokes models.
19
+
20
+ `enable` validates the static manifest and entry location, then stores the current user's consent in the owner-only `~/.subharness/extensions.json` file using the [documented schema](../config.md#extension-consent-and-logs). Global enablement applies to newly admitted coordinator sessions across workspaces; repository enablement applies to new sessions in that canonical checkout. CLI and connected SDK creation use this same admission-time selection. The confirmation identifies the qualified installation and directory and states that the code executes with the supervised process's Node.js permissions. It does not import the entry to test it. A running instance keeps its loaded code; consent persists after checkout edits.
21
+
22
+ After saving consent, enable notifies a running coordinator. If the selected instance identity has a failed process, successful notification makes a replacement eligible for newly admitted sessions and a new process starts at the first matching admission; sessions assigned to the failed instance are not reassigned. Repeating enable for an already eligible instance identity leaves its running process unchanged. Enabling never attaches to previously admitted sessions. With no running coordinator nothing else is needed. An unsupported extension-status operation on a reachable coordinator is a failed notification. If notification fails, consent stays saved; the command prints a warning that the failure state clears on coordinator restart and exits `0`. It does not claim the running coordinator accepted the reset.
23
+
24
+ `disable` removes eligibility for newly admitted sessions. Sessions already assigned to the running instance keep their delivery, and the instance remains coordinator-owned until shutdown or failure. It can remove consent even when files are missing or invalid. Repeating disable for a disabled reference is harmless. Neither enable nor disable cancels work or changes native permissions.
25
+
26
+ Global and repository installations are independent qualified sources. All enabled global installations and enabled repository installations for a session's checkout receive that session. Disabling a global reference affects new session eligibility across workspaces for the current user. Other users are not enabled by committed repository files or by this consent file. State-directory selection follows the [execution rule](../execution.md#ownership-and-transport-boundaries): explicit `ConnectOptions.stateDirectory`, then `AGENT_STATE_DIR`, then `~/.subharness/state/shared`; CLI commands use the environment/default rule.
27
+
28
+ ## Directory installation
29
+
30
+ An installation contains a static `extension.json`, compiled ESM entry and any required packaged dependencies. Its JavaScript must not import Subharness at runtime. There is no package installation command. See the [complete tool-result logger](../extensions.md#complete-tool-result-logger) for self-contained source, manifest, compilation and enablement commands.
31
+
32
+ Each `extension.json` is at most 16 KiB, and any `package.json` read from an extension directory is at most 64 KiB. The consent file is at most 256 KiB, with at most 1,024 repository entries and 256 IDs per scope: 256 global IDs and 256 IDs for each repository entry.
33
+
34
+ Copy a trusted prepared artifact into `~/.subharness/extensions/<id>/` or `<worktree>/.subharness/extensions/<id>/`, then explicitly enable the qualified ID. Copying files does not itself enable code for any user. Discovery/enablement never installs dependencies, runs lifecycle scripts or builds TypeScript.
35
+
36
+ ## Output and failures
37
+
38
+ The exit codes on this page govern all `subharness extensions` commands and take precedence over the general CLI configuration exit codes.
39
+
40
+ Every extensions command rejects an existing `~/.subharness/extensions.json` that is not owner-only, exits `1`, and gives guidance to restrict its permissions with `chmod 600 ~/.subharness/extensions.json`. No command repairs permissions.
41
+
42
+ These commands use human-readable text only and do not accept `--format`. Successful list/enable/disable exits `0`. Invalid arguments, missing enable targets, invalid manifests and incompatible requested versions exit `2`; consent-file/discovery I/O or coordinator communication failure exits `1`, except for the documented unsupported extension-status response to list and enable notification failure after consent is saved, both of which exit `0`. Errors are safe text on stderr. List can succeed while reporting an invalid installation or a failed runtime instance; failure of that extension is data, not failure of the list operation.
43
+
44
+ Handler errors, timeouts, crashes and backpressure disable the affected instance for the rest of the owning coordinator's lifetime; it is not automatically restarted. Its failure remains visible through list for that lifetime, including after explicit re-enablement starts a new instance. Restarting the coordinator resets runtime failure state. A stopped or unavailable coordinator cannot supply retained runtime diagnostics. Static discovery remains distinct from runtime status; uncertain communication is reported instead of presented as a healthy process. The CLI displays `EXTENSION_*` codes and their safe messages only through list; they also remain available through the coordinator's existing safe diagnostics. The dashboard does not display extension diagnostics. An unexpected extension-process exit uses `EXTENSION_EXITED` and disables the instance like other failures. Runtime diagnostics never expose event content, raw child output, thrown messages, stacks or credentials. List shows the actual log path: `<stateDirectory>/extensions/global-<id>.log` for a global instance or `<stateDirectory>/extensions/repo-<id>-<checkout-hash>.log` for a repository instance. `<checkout-hash>` is the first 12 hex characters of the SHA-256 of the canonical checkout path, so filenames contain no colons. Log contents are never copied into command output, diagnostics or the dashboard. The owner-private log is compacted after it exceeds 1.5 MiB and is trimmed to the most recent 1 MiB of stdout/stderr. Log open, write or close failures do not stop the instance: output that cannot be written is discarded, and list shows `EXTENSION_LOG_UNAVAILABLE` as an informational diagnostic. [CLI output](output.md) defines the separate execution-command records.