firedrill-run 2.2.4 → 3.0.0

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 (392) hide show
  1. package/README.md +178 -22
  2. package/bin/firedrill.mjs +29 -5
  3. package/dist/assembly.json +13 -0
  4. package/dist/cli/runtime/candidate_copy.py +395 -0
  5. package/dist/cli/runtime/source_snapshot.py +391 -0
  6. package/dist/cli/src/administration.js +295 -0
  7. package/dist/cli/src/agent-changes.js +496 -0
  8. package/dist/cli/src/assessment-requests.js +67 -0
  9. package/dist/cli/src/auth.js +465 -0
  10. package/dist/cli/src/billing-commerce-contracts.js +1 -0
  11. package/dist/cli/src/billing-usage.js +227 -0
  12. package/dist/cli/src/billing-wallet-contracts.js +1 -0
  13. package/dist/cli/src/billing.js +170 -0
  14. package/dist/cli/src/bootstrap-process-lock.js +136 -0
  15. package/dist/cli/src/browser-links.js +14 -0
  16. package/dist/cli/src/campaign-controls.js +122 -0
  17. package/dist/cli/src/campaign-diagnoses.js +118 -0
  18. package/dist/cli/src/campaign-reports.js +1215 -0
  19. package/dist/cli/src/campaign-world.js +156 -0
  20. package/dist/cli/src/candidate-copy.js +376 -0
  21. package/dist/cli/src/catalog-contracts.js +1 -0
  22. package/dist/cli/src/ci-access-contracts.js +1 -0
  23. package/dist/cli/src/ci-configuration-contracts.js +1 -0
  24. package/dist/cli/src/ci-coverage.js +64 -0
  25. package/dist/cli/src/ci-delivery-contracts.js +1 -0
  26. package/dist/cli/src/ci-result-contracts.js +1 -0
  27. package/dist/cli/src/ci-run-contracts.js +1 -0
  28. package/dist/cli/src/ci-setup-proposals.js +52 -0
  29. package/dist/cli/src/company-policies.js +229 -0
  30. package/dist/cli/src/completion.js +79 -0
  31. package/dist/cli/src/configuration-intents.js +277 -0
  32. package/dist/cli/src/configuration.js +369 -0
  33. package/dist/cli/src/continuous-simulation.js +277 -0
  34. package/dist/cli/src/coordinated-checkpoints.js +133 -0
  35. package/dist/cli/src/credential-mode.js +139 -0
  36. package/dist/cli/src/credentials.js +331 -0
  37. package/dist/cli/src/credit-format.js +8 -0
  38. package/dist/cli/src/dataset-contracts.js +1 -0
  39. package/dist/cli/src/dataset-export.js +154 -0
  40. package/dist/cli/src/dataset-reads.js +37 -0
  41. package/dist/cli/src/dependency-preparation.js +239 -0
  42. package/dist/cli/src/director-tool-setup.js +104 -0
  43. package/dist/cli/src/driver-review.js +225 -0
  44. package/dist/cli/src/evaluation-authoring.js +315 -0
  45. package/dist/cli/src/evidence-bundles.js +367 -0
  46. package/dist/cli/src/execution-proposals.js +36 -0
  47. package/dist/cli/src/http.js +302 -0
  48. package/dist/cli/src/local-container-boundary.js +38 -0
  49. package/dist/cli/src/local-container-policy.js +201 -0
  50. package/dist/cli/src/local-execution-setup.js +81 -0
  51. package/dist/cli/src/local-source-basis.js +73 -0
  52. package/dist/cli/src/local-source.js +66 -0
  53. package/dist/cli/src/local-value-store.js +91 -0
  54. package/dist/cli/src/local-values.js +163 -0
  55. package/dist/cli/src/login-organizations.js +70 -0
  56. package/dist/cli/src/main.js +1622 -0
  57. package/dist/cli/src/mcp-connection.js +109 -0
  58. package/dist/cli/src/native/bindings.js +137 -0
  59. package/dist/cli/src/native/canonical.js +370 -0
  60. package/dist/cli/src/native/cloud-resources.js +942 -0
  61. package/dist/cli/src/native/companion-channel.js +421 -0
  62. package/dist/cli/src/native/companion-ipc.js +473 -0
  63. package/dist/cli/src/native/contracts.js +218 -0
  64. package/dist/cli/src/native/control-plane.js +1354 -0
  65. package/dist/cli/src/native/credit-approval.js +15 -0
  66. package/dist/cli/src/native/dependency-proxy.js +1006 -0
  67. package/dist/cli/src/native/drill-cleanup.js +115 -0
  68. package/dist/cli/src/native/drill-runner.js +1562 -0
  69. package/dist/cli/src/native/drivers/action-trace.js +210 -0
  70. package/dist/cli/src/native/drivers/function-wrapper.js +152 -0
  71. package/dist/cli/src/native/drivers/http.js +442 -0
  72. package/dist/cli/src/native/drivers/index.js +47 -0
  73. package/dist/cli/src/native/drivers/jsonl-process.js +538 -0
  74. package/dist/cli/src/native/drivers/playwright.js +600 -0
  75. package/dist/cli/src/native/drivers/signed-event.js +244 -0
  76. package/dist/cli/src/native/drivers/types.js +578 -0
  77. package/dist/cli/src/native/evidence-filter.js +255 -0
  78. package/dist/cli/src/native/isolated-access.js +241 -0
  79. package/dist/cli/src/native/library-sharing.js +220 -0
  80. package/dist/cli/src/native/local-run.js +667 -0
  81. package/dist/cli/src/native/local-secrets.js +19 -0
  82. package/dist/cli/src/native/mcp-config.js +123 -0
  83. package/dist/cli/src/native/metadata-requests.js +120 -0
  84. package/dist/cli/src/native/observations.js +1159 -0
  85. package/dist/cli/src/native/owned-groups.js +46 -0
  86. package/dist/cli/src/native/plan.js +594 -0
  87. package/dist/cli/src/native/png.js +159 -0
  88. package/dist/cli/src/native/ports.js +43 -0
  89. package/dist/cli/src/native/readiness.js +139 -0
  90. package/dist/cli/src/native/reassessments.js +206 -0
  91. package/dist/cli/src/native/redaction.js +235 -0
  92. package/dist/cli/src/native/registration.js +155 -0
  93. package/dist/cli/src/native/roots.js +110 -0
  94. package/dist/cli/src/native/run-cleanup.js +199 -0
  95. package/dist/cli/src/native/scratch.js +117 -0
  96. package/dist/cli/src/native/screenshots.js +60 -0
  97. package/dist/cli/src/native/session.js +556 -0
  98. package/dist/cli/src/native/standalone-proxy.js +580 -0
  99. package/dist/cli/src/native/standalone-renewals.js +183 -0
  100. package/dist/cli/src/native/standalone-state.js +193 -0
  101. package/dist/cli/src/native/standalone-tools.js +187 -0
  102. package/dist/cli/src/native/supervisor.js +831 -0
  103. package/dist/cli/src/native/target-auth.js +161 -0
  104. package/dist/cli/src/native/target-state.js +330 -0
  105. package/dist/cli/src/native/tool-reuse.js +364 -0
  106. package/dist/cli/src/native/tool-setups.js +336 -0
  107. package/dist/cli/src/native/world-reuse.js +288 -0
  108. package/dist/cli/src/onboarding.js +23 -0
  109. package/dist/cli/src/priority-requests.js +70 -0
  110. package/dist/cli/src/priority.js +223 -0
  111. package/dist/cli/src/prompts.js +184 -0
  112. package/dist/cli/src/real-operations.js +221 -0
  113. package/dist/cli/src/recipe-intents.js +58 -0
  114. package/dist/cli/src/recorded-context-intents.js +59 -0
  115. package/dist/cli/src/recorded-context.js +248 -0
  116. package/dist/cli/src/recordings.js +69 -0
  117. package/dist/cli/src/registration-guide.js +39 -0
  118. package/dist/cli/src/report-exports.js +213 -0
  119. package/dist/cli/src/request-input.js +47 -0
  120. package/dist/cli/src/resource-lifecycle.js +141 -0
  121. package/dist/cli/src/revision-requests.js +55 -0
  122. package/dist/cli/src/runner-abandon.js +53 -0
  123. package/dist/cli/src/runner-campaign-controls.js +262 -0
  124. package/dist/cli/src/runner-claim-reads.js +36 -0
  125. package/dist/cli/src/runner-completion.js +65 -0
  126. package/dist/cli/src/runner-configuration.js +546 -0
  127. package/dist/cli/src/runner-container.js +794 -0
  128. package/dist/cli/src/runner-evidence-erasure.js +351 -0
  129. package/dist/cli/src/runner-evidence-privacy.js +37 -0
  130. package/dist/cli/src/runner-evidence-retention.js +161 -0
  131. package/dist/cli/src/runner-evidence.js +326 -0
  132. package/dist/cli/src/runner-execute.js +92 -0
  133. package/dist/cli/src/runner-execution-deadline.js +25 -0
  134. package/dist/cli/src/runner-grants.js +307 -0
  135. package/dist/cli/src/runner-identity.js +615 -0
  136. package/dist/cli/src/runner-inputs.js +308 -0
  137. package/dist/cli/src/runner-jobs.js +49 -0
  138. package/dist/cli/src/runner-model-transport.js +392 -0
  139. package/dist/cli/src/runner-ownership.js +332 -0
  140. package/dist/cli/src/runner-process-lock.js +175 -0
  141. package/dist/cli/src/runner-runtime.js +396 -0
  142. package/dist/cli/src/runner-session-channel.js +377 -0
  143. package/dist/cli/src/runner-trial-completion.js +34 -0
  144. package/dist/cli/src/runner-trial-journal.js +358 -0
  145. package/dist/cli/src/runner-trial-live.js +393 -0
  146. package/dist/cli/src/runner-trial-protocol.js +289 -0
  147. package/dist/cli/src/runner-trial-sync.js +110 -0
  148. package/dist/cli/src/runner-trial-transfer.js +107 -0
  149. package/dist/cli/src/runner-voice.js +40 -0
  150. package/dist/cli/src/runner-world-claim.js +21 -0
  151. package/dist/cli/src/runner-world-collector.js +159 -0
  152. package/dist/cli/src/runner-world-command-evidence.js +487 -0
  153. package/dist/cli/src/runner-world-commands.js +268 -0
  154. package/dist/cli/src/runner-world-completion.js +76 -0
  155. package/dist/cli/src/runner-world-erasure.js +95 -0
  156. package/dist/cli/src/runner-world-evidence-sync.js +91 -0
  157. package/dist/cli/src/runner-world-journal.js +510 -0
  158. package/dist/cli/src/runner-world-native-filters.js +134 -0
  159. package/dist/cli/src/runner-world-observations.js +50 -0
  160. package/dist/cli/src/runner-world-session-protocol.js +134 -0
  161. package/dist/cli/src/saved-records.js +40 -0
  162. package/dist/cli/src/scenario-authoring.js +212 -0
  163. package/dist/cli/src/scenario-discovery.js +216 -0
  164. package/dist/cli/src/scenario-paths.js +68 -0
  165. package/dist/cli/src/scenario-requests.js +4 -0
  166. package/dist/cli/src/service-receipts.js +105 -0
  167. package/dist/cli/src/simple/authoring.js +270 -0
  168. package/dist/cli/src/simple/credit-approval.js +16 -0
  169. package/dist/cli/src/simple/help.js +98 -0
  170. package/dist/cli/src/simple/init.js +61 -0
  171. package/dist/cli/src/simple/library-sharing.js +414 -0
  172. package/dist/cli/src/simple/metadata-requests.js +46 -0
  173. package/dist/cli/src/simple/native-report.js +841 -0
  174. package/dist/cli/src/simple/native-tools.js +780 -0
  175. package/dist/cli/src/simple/plan-apply.js +506 -0
  176. package/dist/cli/src/simple/reassessment.js +323 -0
  177. package/dist/cli/src/simple/register.js +123 -0
  178. package/dist/cli/src/simple/run.js +122 -0
  179. package/dist/cli/src/simple/status.js +49 -0
  180. package/dist/cli/src/simple/tool-renewal.js +308 -0
  181. package/dist/cli/src/simple/tool-reuse.js +526 -0
  182. package/dist/cli/src/simple/tool-start-catalog.js +100 -0
  183. package/dist/cli/src/simple/tool-state.js +426 -0
  184. package/dist/cli/src/simple/tools-author.js +222 -0
  185. package/dist/cli/src/simple/watch.js +28 -0
  186. package/dist/cli/src/simple/world-reuse.js +586 -0
  187. package/dist/cli/src/simulation-intents.js +406 -0
  188. package/dist/cli/src/simulation-run.js +1058 -0
  189. package/dist/cli/src/source-batch.js +322 -0
  190. package/dist/cli/src/source-connection.js +451 -0
  191. package/dist/cli/src/source-runtime.js +346 -0
  192. package/dist/cli/src/source-selection-intents.js +75 -0
  193. package/dist/cli/src/source-sets.js +214 -0
  194. package/dist/cli/src/target-models.js +109 -0
  195. package/dist/cli/src/tool-catalog.js +224 -0
  196. package/dist/cli/src/tool-command-contracts.js +1 -0
  197. package/dist/cli/src/tool-command-export.js +245 -0
  198. package/dist/cli/src/tool-connection-contracts.js +1 -0
  199. package/dist/cli/src/tool-connection-reads.js +23 -0
  200. package/dist/cli/src/tool-contributions.js +58 -0
  201. package/dist/cli/src/tool-data.js +116 -0
  202. package/dist/cli/src/tool-datasets.js +176 -0
  203. package/dist/cli/src/tool-group-contracts.js +1 -0
  204. package/dist/cli/src/tool-group-reads.js +26 -0
  205. package/dist/cli/src/tool-group-state.js +147 -0
  206. package/dist/cli/src/tool-groups.js +311 -0
  207. package/dist/cli/src/tool-instances.js +186 -0
  208. package/dist/cli/src/tool-lifecycle-contracts.js +1 -0
  209. package/dist/cli/src/tool-lifecycle-reads.js +30 -0
  210. package/dist/cli/src/tool-lifecycle.js +323 -0
  211. package/dist/cli/src/tool-package-contracts.js +1 -0
  212. package/dist/cli/src/tool-package-reads.js +41 -0
  213. package/dist/cli/src/tool-records.js +53 -0
  214. package/dist/cli/src/tool-runtime.js +96 -0
  215. package/dist/cli/src/tool-state-contracts.js +1 -0
  216. package/dist/cli/src/tool-state-reads.js +31 -0
  217. package/dist/cli/src/tools.js +306 -0
  218. package/dist/cli/src/trial-actions.js +93 -0
  219. package/dist/cli/src/trial-checkpoints.js +133 -0
  220. package/dist/cli/src/trial-checks.js +70 -0
  221. package/dist/cli/src/trial-state.js +197 -0
  222. package/dist/cli/src/vault.js +266 -0
  223. package/dist/cli/src/workspace-registration.js +383 -0
  224. package/dist/cli/src/workspace-team-contracts.js +1 -0
  225. package/dist/cli/src/world-access.js +231 -0
  226. package/dist/cli/src/world-agent.js +4 -0
  227. package/dist/cli/src/world-checkpoint-scopes.js +15 -0
  228. package/dist/cli/src/world-contracts.js +6 -0
  229. package/dist/cli/src/world-creation.js +201 -0
  230. package/dist/cli/src/world-datasets.js +207 -0
  231. package/dist/cli/src/world-inspection.js +257 -0
  232. package/dist/cli/src/world-recipes.js +103 -0
  233. package/dist/cli/src/world-requests.js +241 -0
  234. package/dist/cli/src/world-session-checkpoints.js +196 -0
  235. package/dist/cli/src/world-session-lifecycle.js +207 -0
  236. package/dist/cli/src/world-session-requests.js +215 -0
  237. package/dist/cli/src/world-session-state.js +145 -0
  238. package/dist/cli/src/world-session-voice.js +66 -0
  239. package/dist/cli/src/world-sessions.js +288 -0
  240. package/dist/cli/src/world-stream.js +99 -0
  241. package/dist/cli/src/world-time-report.js +58 -0
  242. package/dist/contracts/agent-change-contracts.js +75 -0
  243. package/dist/contracts/agent-execution-contracts.js +38 -0
  244. package/dist/contracts/application-state-contracts.js +26 -0
  245. package/dist/contracts/assessment-aggregate-contracts.js +15 -0
  246. package/dist/contracts/assessment-contracts.js +74 -0
  247. package/dist/contracts/billing-commerce-contracts.js +107 -0
  248. package/dist/contracts/billing-wallet-contracts.js +43 -0
  249. package/dist/contracts/campaign-lifecycle.js +1 -0
  250. package/dist/contracts/campaign-world-contracts.js +80 -0
  251. package/dist/contracts/catalog-contracts.js +73 -0
  252. package/dist/contracts/ci-access-contracts.js +68 -0
  253. package/dist/contracts/ci-configuration-contracts.js +88 -0
  254. package/dist/contracts/ci-coverage-contracts.js +65 -0
  255. package/dist/contracts/ci-coverage-labels.js +25 -0
  256. package/dist/contracts/ci-delivery-contracts.js +61 -0
  257. package/dist/contracts/ci-result-contracts.js +103 -0
  258. package/dist/contracts/ci-run-contracts.js +51 -0
  259. package/dist/contracts/ci-setup-contracts.js +88 -0
  260. package/dist/contracts/clip-contracts.js +32 -0
  261. package/dist/contracts/comparison-contracts.js +53 -0
  262. package/dist/contracts/composite-contracts.js +34 -0
  263. package/dist/contracts/context-contracts.js +76 -0
  264. package/dist/contracts/continuation-report-contracts.js +1 -0
  265. package/dist/contracts/continuity-requirements.js +8 -0
  266. package/dist/contracts/coordinated-checkpoint-contracts.js +34 -0
  267. package/dist/contracts/dataset-contracts.js +88 -0
  268. package/dist/contracts/dependency-decision-contracts.js +36 -0
  269. package/dist/contracts/dependency-protocol-contracts.js +43 -0
  270. package/dist/contracts/director-execution.js +51 -0
  271. package/dist/contracts/driver-review-contracts.js +99 -0
  272. package/dist/contracts/evidence-contracts.js +65 -0
  273. package/dist/contracts/evidence-coverage-contracts.js +10 -0
  274. package/dist/contracts/export-contracts.js +44 -0
  275. package/dist/contracts/github-directory-contracts.js +96 -0
  276. package/dist/contracts/insight-contracts.js +11 -0
  277. package/dist/contracts/inspection-contracts.js +1 -0
  278. package/dist/contracts/local-claim-contracts.js +39 -0
  279. package/dist/contracts/local-configuration-contracts.js +7 -0
  280. package/dist/contracts/local-evidence-contracts.js +32 -0
  281. package/dist/contracts/local-grant-contracts.js +83 -0
  282. package/dist/contracts/local-input-contracts.js +19 -0
  283. package/dist/contracts/local-runner-contracts.js +42 -0
  284. package/dist/contracts/local-trial-live-contracts.js +16 -0
  285. package/dist/contracts/local-value-source-contracts.js +92 -0
  286. package/dist/contracts/local-world-native-contracts.js +8 -0
  287. package/dist/contracts/mcp-contracts.js +42 -0
  288. package/dist/contracts/media-contracts.js +28 -0
  289. package/dist/contracts/native-check-contracts.js +31 -0
  290. package/dist/contracts/native-identity-contracts.js +52 -0
  291. package/dist/contracts/onboarding-contracts.js +32 -0
  292. package/dist/contracts/performance-contracts.js +85 -0
  293. package/dist/contracts/planning-contracts.js +81 -0
  294. package/dist/contracts/real-operation-contracts.js +30 -0
  295. package/dist/contracts/recommendation-contracts.js +54 -0
  296. package/dist/contracts/report-contracts.js +1 -0
  297. package/dist/contracts/resource-lifecycle-contracts.js +57 -0
  298. package/dist/contracts/revision-contracts.js +12 -0
  299. package/dist/contracts/revision-request-contracts.js +39 -0
  300. package/dist/contracts/saved-record-contracts.js +76 -0
  301. package/dist/contracts/scenario-draft-comparison.js +91 -0
  302. package/dist/contracts/scenario-world-contracts.js +14 -0
  303. package/dist/contracts/service-contracts.js +1 -0
  304. package/dist/contracts/session-command-contracts.js +56 -0
  305. package/dist/contracts/session-contracts.js +65 -0
  306. package/dist/contracts/session-state-contracts.js +67 -0
  307. package/dist/contracts/session-voice-contracts.js +45 -0
  308. package/dist/contracts/source-set-contracts.js +26 -0
  309. package/dist/contracts/source-upload-contracts.js +22 -0
  310. package/dist/contracts/tool-command-contracts.js +57 -0
  311. package/dist/contracts/tool-connection-contracts.js +87 -0
  312. package/dist/contracts/tool-contribution-contracts.js +35 -0
  313. package/dist/contracts/tool-group-contracts.js +53 -0
  314. package/dist/contracts/tool-group-state-contracts.js +63 -0
  315. package/dist/contracts/tool-lifecycle-contracts.js +94 -0
  316. package/dist/contracts/tool-package-contracts.js +91 -0
  317. package/dist/contracts/tool-protocol-contracts.js +71 -0
  318. package/dist/contracts/tool-runtime-billing-contracts.js +28 -0
  319. package/dist/contracts/tool-setup-proposal.js +59 -0
  320. package/dist/contracts/tool-state-contracts.js +79 -0
  321. package/dist/contracts/trial-state-contracts.js +30 -0
  322. package/dist/contracts/typescript/agent-change.js +1 -0
  323. package/dist/contracts/typescript/assessment-aggregate.js +1 -0
  324. package/dist/contracts/typescript/assessment.js +1 -0
  325. package/dist/contracts/typescript/billing-commerce.js +1 -0
  326. package/dist/contracts/typescript/campaigns.js +1 -0
  327. package/dist/contracts/typescript/catalog.js +1 -0
  328. package/dist/contracts/typescript/ci-access.js +1 -0
  329. package/dist/contracts/typescript/ci-configuration.js +1 -0
  330. package/dist/contracts/typescript/ci-delivery.js +1 -0
  331. package/dist/contracts/typescript/ci-result.js +1 -0
  332. package/dist/contracts/typescript/ci-runs.js +1 -0
  333. package/dist/contracts/typescript/clips.js +1 -0
  334. package/dist/contracts/typescript/comparison.js +1 -0
  335. package/dist/contracts/typescript/composite.js +1 -0
  336. package/dist/contracts/typescript/connections.js +1 -0
  337. package/dist/contracts/typescript/context.js +1 -0
  338. package/dist/contracts/typescript/datasets.js +1 -0
  339. package/dist/contracts/typescript/evidence-coverage.js +1 -0
  340. package/dist/contracts/typescript/export.js +1 -0
  341. package/dist/contracts/typescript/github-directory.js +1 -0
  342. package/dist/contracts/typescript/insight.js +1 -0
  343. package/dist/contracts/typescript/inspection.js +1 -0
  344. package/dist/contracts/typescript/intake.js +1 -0
  345. package/dist/contracts/typescript/local-claim.js +1 -0
  346. package/dist/contracts/typescript/local-configuration.js +1 -0
  347. package/dist/contracts/typescript/local-evidence.js +1 -0
  348. package/dist/contracts/typescript/local-grant.js +1 -0
  349. package/dist/contracts/typescript/local-input.js +1 -0
  350. package/dist/contracts/typescript/local-runner.js +1 -0
  351. package/dist/contracts/typescript/local-trial-live.js +1 -0
  352. package/dist/contracts/typescript/local-value-source.js +1 -0
  353. package/dist/contracts/typescript/local-world-native.js +1 -0
  354. package/dist/contracts/typescript/mcp.js +1 -0
  355. package/dist/contracts/typescript/media.js +1 -0
  356. package/dist/contracts/typescript/native-check.js +1 -0
  357. package/dist/contracts/typescript/native-identity.js +1 -0
  358. package/dist/contracts/typescript/onboarding.js +1 -0
  359. package/dist/contracts/typescript/performance.js +1 -0
  360. package/dist/contracts/typescript/planning.js +1 -0
  361. package/dist/contracts/typescript/preparation.js +1 -0
  362. package/dist/contracts/typescript/real-operation.js +1 -0
  363. package/dist/contracts/typescript/recommendation.js +1 -0
  364. package/dist/contracts/typescript/reports.js +1 -0
  365. package/dist/contracts/typescript/resource-lifecycle.js +1 -0
  366. package/dist/contracts/typescript/saved-record.js +1 -0
  367. package/dist/contracts/typescript/scenarios.js +1 -0
  368. package/dist/contracts/typescript/services.js +1 -0
  369. package/dist/contracts/typescript/session-command.js +1 -0
  370. package/dist/contracts/typescript/session-state.js +1 -0
  371. package/dist/contracts/typescript/session-voice.js +1 -0
  372. package/dist/contracts/typescript/session.js +1 -0
  373. package/dist/contracts/typescript/tool-command.js +1 -0
  374. package/dist/contracts/typescript/tool-connection.js +1 -0
  375. package/dist/contracts/typescript/tool-contribution.js +1 -0
  376. package/dist/contracts/typescript/tool-groups.js +1 -0
  377. package/dist/contracts/typescript/tool-lifecycle.js +1 -0
  378. package/dist/contracts/typescript/tool-package.js +1 -0
  379. package/dist/contracts/typescript/tool-state.js +1 -0
  380. package/dist/contracts/typescript/trial-state.js +1 -0
  381. package/dist/contracts/typescript/vault.js +1 -0
  382. package/dist/contracts/typescript/workspace-team.js +1 -0
  383. package/dist/contracts/typescript/world-stream.js +1 -0
  384. package/dist/contracts/workspace-team-contracts.js +55 -0
  385. package/dist/contracts/world-command.js +65 -0
  386. package/dist/contracts/world-lifetime-contracts.js +74 -0
  387. package/dist/contracts/world-recipe-contracts.js +27 -0
  388. package/dist/contracts/world-stream-contracts.js +27 -0
  389. package/dist/package.json +1 -0
  390. package/package.json +16 -16
  391. package/LICENSE.md +0 -23
  392. package/PACKAGING.json +0 -50
@@ -0,0 +1,538 @@
1
+ /**
2
+ * jsonl-process.v1 driver and the shared JSON-lines channel (Plan20 spec 3.3).
3
+ *
4
+ * Protocol (one JSON object per line, UTF-8, `\n` terminated):
5
+ * request -> stdin : {"id": string, "session": string, "kind": "message"|"task", "input": <payload>}
6
+ * response <- stdout: {"id": string, "output": <any>} or {"id": string, "error": <any>}
7
+ * `input` is the step's target-visible payload only (message text or task input).
8
+ *
9
+ * Process ownership: the protocol needs the service's stdin/stdout, which an
10
+ * already-running (attach) process cannot provide, so the plan service named by
11
+ * `service_alias` must be a `launch` service. The supervisor deliberately
12
+ * skips this service, so the driver owns it: it starts it in prepare() (spawn,
13
+ * shell:false, approved argv, cwd inside the approved root, env = ctx.env
14
+ * exactly) and stops its process group in dispose(). Readiness supports `none`
15
+ * and `stdout` patterns. A service handle from any other owner is refused.
16
+ * One channel per driver instance (driverFor() returns a new instance per drill).
17
+ *
18
+ * Requests are serialized per process (one in flight) so every malformed or
19
+ * oversized line is attributed to the in-flight step, which fails explicitly.
20
+ * The process is never killed by name or port; only the group this driver
21
+ * created is signalled (POSIX), or the child pid (Windows, no process groups).
22
+ */
23
+ import { spawn } from 'node:child_process';
24
+ import { randomUUID } from 'node:crypto';
25
+ import { CliError } from '../../http.js';
26
+ import { NATIVE_ERRORS, nativeError } from '../contracts.js';
27
+ import { sha256Hex } from '../canonical.js';
28
+ import { insideRoot } from '../roots.js';
29
+ import { ownGroup, sweepGroup } from '../owned-groups.js';
30
+ import { identityHeaders } from '../target-auth.js';
31
+ import { DRIVER_ERRORS, OutputTail, StepRecorder, driverBounds, driverPlanFor, emit, planError, precheck, rootPath, stepAbort, stepInput, stepTimeoutMs, unattested, } from './types.js';
32
+ export class ChannelFailure extends Error {
33
+ kind;
34
+ written;
35
+ constructor(kind, written) {
36
+ super(`The JSON-lines exchange did not complete (${kind}).`);
37
+ this.kind = kind;
38
+ this.written = written;
39
+ }
40
+ }
41
+ const MAX_ABANDONED = 256;
42
+ export class JsonLinesProcess {
43
+ ctx;
44
+ label;
45
+ bounds;
46
+ io;
47
+ /** Present only when this channel spawned the process (driver-owned). */
48
+ owned;
49
+ stderr;
50
+ preReady;
51
+ partial = [];
52
+ partialSize = 0;
53
+ discarding = false;
54
+ ready = false;
55
+ /** SHA-256 of the UTF-8 stdout line that carried the approved readiness text; null without stdout readiness. */
56
+ readyLineSha256 = null;
57
+ readyPattern = null;
58
+ readyWaiter = null;
59
+ pending = null;
60
+ abandoned = new Set();
61
+ queue = Promise.resolve();
62
+ exitState = null;
63
+ exitPromise;
64
+ stopping = false;
65
+ onData = (chunk) => this.onStdout(chunk);
66
+ constructor(ctx, label, io, exited, owned) {
67
+ this.ctx = ctx;
68
+ this.label = label;
69
+ this.io = io;
70
+ this.owned = owned;
71
+ this.bounds = driverBounds(ctx);
72
+ this.stderr = new OutputTail(this.bounds.stderrTailBytes);
73
+ this.preReady = new OutputTail(4096);
74
+ io.stdin.on('error', () => undefined);
75
+ io.stdout.on('data', this.onData);
76
+ io.stdout.once('close', () => this.failAfterExit());
77
+ io.stderr?.on('data', (chunk) => this.stderr.push(chunk));
78
+ this.exitPromise = exited.then((info) => {
79
+ const record = (info && typeof info === 'object' ? info : {});
80
+ this.exitState = {
81
+ code: typeof record.code === 'number' ? record.code : null,
82
+ signal: typeof record.signal === 'string' ? record.signal : null,
83
+ };
84
+ // Give stdout a moment to drain a final response line, then fail what is left.
85
+ setTimeout(() => this.failAfterExit(), 500).unref();
86
+ }, () => { this.exitState = { code: null, signal: null }; this.failAfterExit(); });
87
+ }
88
+ /** Spawn the approved command (argv only, shell:false) and wait for readiness. */
89
+ static async start(ctx, launch) {
90
+ // Literal substring, matching the supervisor and the approval text ("output contains").
91
+ const pattern = launch.readiness.kind === 'stdout' ? launch.readiness.pattern : null;
92
+ if (launch.readiness.kind === 'stdout') {
93
+ if (!pattern)
94
+ throw planError(`The readiness text for ${launch.label} is empty, so the process was not started.`);
95
+ }
96
+ else if (launch.readiness.kind !== 'none') {
97
+ throw planError(`A driver-owned JSON-lines process (${launch.label}) supports only "none" or "stdout" readiness, so it was not started.`);
98
+ }
99
+ const posix = process.platform !== 'win32';
100
+ let child;
101
+ try {
102
+ child = spawn(launch.executable, launch.args, {
103
+ cwd: launch.cwd, env: { ...launch.env }, shell: false, detached: posix,
104
+ stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true,
105
+ });
106
+ }
107
+ catch {
108
+ throw nativeError('process_exited', `The ${launch.label} process could not be started, so no step was sent to it.`);
109
+ }
110
+ child.once('spawn', () => { if (posix)
111
+ ownGroup(child.pid); });
112
+ child.once('exit', () => { if (posix)
113
+ sweepGroup(child.pid); });
114
+ if (!child.stdin || !child.stdout) {
115
+ child.on('error', () => undefined);
116
+ child.once('spawn', () => {
117
+ if (posix)
118
+ sweepGroup(child.pid);
119
+ else {
120
+ try {
121
+ child.kill('SIGKILL');
122
+ }
123
+ catch { /* already gone */ }
124
+ }
125
+ });
126
+ throw nativeError('process_exited', `The ${launch.label} process has no protocol pipes, so no step was sent to it.`);
127
+ }
128
+ const exited = new Promise((resolve) => {
129
+ child.once('exit', (code, signal) => resolve({ code, signal }));
130
+ });
131
+ const channel = new JsonLinesProcess(ctx, launch.label, { stdin: child.stdin, stdout: child.stdout, stderr: child.stderr }, exited, { child, ownsGroup: posix, stopTimeoutMs: launch.stopTimeoutMs });
132
+ try {
133
+ await channel.waitSpawned(child);
134
+ launch.onSpawned?.(channel);
135
+ if (pattern)
136
+ await channel.waitReady(pattern, launch.readinessTimeoutMs);
137
+ else
138
+ channel.ready = true;
139
+ }
140
+ catch (error) {
141
+ await channel.stop();
142
+ throw error;
143
+ }
144
+ emit(ctx, 'action.observed', { type: 'process.started', label: launch.label, pid: child.pid ?? null, process_group: posix });
145
+ return channel;
146
+ }
147
+ get exited() { return this.exitState !== null; }
148
+ /** Unique per launch, reported in the drill's signed close. */
149
+ launchId = randomUUID();
150
+ /** How the owned process ended, once it has; null while running (or when this channel does not own it). */
151
+ get exit() { return this.owned ? this.exitState : null; }
152
+ waitSpawned(child) {
153
+ return new Promise((resolve, reject) => {
154
+ const onError = () => {
155
+ child.off('spawn', onSpawn);
156
+ this.exitState ??= { code: null, signal: null };
157
+ reject(nativeError('process_exited', `The ${this.label} process could not be started, so no step was sent to it.`));
158
+ };
159
+ const onSpawn = () => { child.off('error', onError); child.on('error', () => undefined); resolve(); };
160
+ child.once('error', onError);
161
+ child.once('spawn', onSpawn);
162
+ });
163
+ }
164
+ async waitReady(pattern, timeoutMs) {
165
+ this.readyPattern = pattern;
166
+ const ready = new Promise((resolve, reject) => { this.readyWaiter = { resolve, reject }; });
167
+ const timer = setTimeout(() => this.readyWaiter?.reject(nativeError('readiness_timeout', `The ${this.label} process did not report readiness in time, so no step was sent to it.`)), Math.max(1, timeoutMs));
168
+ try {
169
+ await ready;
170
+ }
171
+ catch (error) {
172
+ emit(this.ctx, 'driver.failed', { type: 'process.not_ready', label: this.label,
173
+ stdout_tail: this.preReady.text(this.ctx.secrets), stderr_tail: this.stderr.text(this.ctx.secrets) });
174
+ await this.stop();
175
+ throw error;
176
+ }
177
+ finally {
178
+ clearTimeout(timer);
179
+ this.readyWaiter = null;
180
+ }
181
+ }
182
+ // -- stdout framing -------------------------------------------------------
183
+ onStdout(chunk) {
184
+ let start = 0;
185
+ while (start < chunk.length) {
186
+ const newline = chunk.indexOf(10, start);
187
+ if (newline === -1) {
188
+ this.appendPartial(chunk.subarray(start));
189
+ return;
190
+ }
191
+ this.appendPartial(chunk.subarray(start, newline));
192
+ start = newline + 1;
193
+ if (this.discarding) {
194
+ this.discarding = false;
195
+ continue;
196
+ }
197
+ const line = Buffer.concat(this.partial).toString('utf8');
198
+ this.partial = [];
199
+ this.partialSize = 0;
200
+ this.onLine(line);
201
+ }
202
+ }
203
+ appendPartial(piece) {
204
+ if (this.discarding || !piece.length)
205
+ return;
206
+ if (this.partialSize + piece.length > this.bounds.maxLineBytes) {
207
+ this.partial = [];
208
+ this.partialSize = 0;
209
+ this.discarding = true;
210
+ this.lineFault('oversized');
211
+ return;
212
+ }
213
+ this.partial.push(piece);
214
+ this.partialSize += piece.length;
215
+ }
216
+ onLine(line) {
217
+ if (!this.ready) {
218
+ this.preReady.push(Buffer.from(`${line}\n`, 'utf8'));
219
+ if (this.readyPattern !== null && line.includes(this.readyPattern)) {
220
+ // The exact line, UTF-8, without its terminator (a CRLF's carriage return included).
221
+ this.ready = true;
222
+ this.readyLineSha256 = sha256Hex(Buffer.from(line.endsWith('\r') ? line.slice(0, -1) : line, 'utf8'));
223
+ this.readyWaiter?.resolve();
224
+ }
225
+ return;
226
+ }
227
+ const trimmed = line.trim();
228
+ if (!trimmed)
229
+ return;
230
+ let message;
231
+ try {
232
+ message = JSON.parse(trimmed);
233
+ }
234
+ catch {
235
+ this.lineFault('malformed');
236
+ return;
237
+ }
238
+ if (!message || typeof message !== 'object' || Array.isArray(message) || typeof message.id !== 'string') {
239
+ this.lineFault('malformed');
240
+ return;
241
+ }
242
+ const record = message;
243
+ const id = record.id;
244
+ const hasOutput = Object.prototype.hasOwnProperty.call(record, 'output');
245
+ const hasError = Object.prototype.hasOwnProperty.call(record, 'error');
246
+ if (this.pending && this.pending.id === id) {
247
+ const pending = this.pending;
248
+ if (hasOutput === hasError)
249
+ pending.reject(new ChannelFailure('malformed', true));
250
+ else if (hasOutput)
251
+ pending.resolve({ ok: true, output: record.output });
252
+ else
253
+ pending.resolve({ ok: false, error: record.error });
254
+ return;
255
+ }
256
+ if (this.abandoned.delete(id)) {
257
+ emit(this.ctx, 'action.observed', { type: 'protocol.late_response', label: this.label, request_id: id,
258
+ output: hasOutput ? record.output : null, error: hasError ? record.error : null });
259
+ return;
260
+ }
261
+ emit(this.ctx, 'action.observed', { type: 'protocol.unsolicited_line', label: this.label, content: record });
262
+ }
263
+ lineFault(kind) {
264
+ if (!this.ready)
265
+ return;
266
+ // A faulty line carries no usable id. While an abandoned request may still be
267
+ // answering late, it could belong to that request, so it is not blamed on the
268
+ // in-flight step (which then ends by its own reply or its timeout).
269
+ if (this.pending && this.abandoned.size === 0) {
270
+ this.pending.reject(new ChannelFailure(kind, true));
271
+ return;
272
+ }
273
+ emit(this.ctx, 'action.observed', { type: 'protocol.fault', label: this.label, fault: kind,
274
+ attribution: this.pending ? 'ambiguous_after_abandoned_request' : 'no_request_in_flight' });
275
+ }
276
+ failAfterExit() {
277
+ if (!this.exitState)
278
+ return;
279
+ if (this.pending)
280
+ this.pending.reject(new ChannelFailure('exited', true));
281
+ if (this.readyWaiter)
282
+ this.readyWaiter.reject(nativeError('process_exited', `The ${this.label} process exited before it was ready, so no step was sent to it.`));
283
+ if (!this.stopping && this.exitState) {
284
+ const state = this.exitState;
285
+ this.stopping = true; // report once
286
+ emit(this.ctx, 'driver.failed', { type: 'process.exited', label: this.label, code: state.code, signal: state.signal,
287
+ stderr_tail: this.stderr.text(this.ctx.secrets) });
288
+ }
289
+ }
290
+ // -- requests -------------------------------------------------------------
291
+ /** Send one serialized request line; one request is in flight at a time. */
292
+ request(id, line, signal) {
293
+ const run = () => this.send(id, line, signal);
294
+ const result = this.queue.then(run, run);
295
+ this.queue = result.catch(() => undefined);
296
+ return result;
297
+ }
298
+ send(id, line, signal) {
299
+ return new Promise((resolve, reject) => {
300
+ if (signal.aborted) {
301
+ reject(new ChannelFailure('aborted', false));
302
+ return;
303
+ }
304
+ const stdin = this.io.stdin;
305
+ if (this.exitState || this.stopping || stdin.destroyed || !stdin.writable) {
306
+ reject(new ChannelFailure('exited', false));
307
+ return;
308
+ }
309
+ const cleanup = () => {
310
+ signal.removeEventListener('abort', onAbort);
311
+ if (this.pending?.id === id)
312
+ this.pending = null;
313
+ };
314
+ const onAbort = () => {
315
+ cleanup();
316
+ this.abandoned.add(id);
317
+ if (this.abandoned.size > MAX_ABANDONED)
318
+ this.abandoned.delete(this.abandoned.values().next().value);
319
+ reject(new ChannelFailure('aborted', true));
320
+ };
321
+ this.pending = {
322
+ id,
323
+ resolve: (reply) => { cleanup(); resolve(reply); },
324
+ reject: (failure) => { cleanup(); reject(failure); },
325
+ };
326
+ signal.addEventListener('abort', onAbort, { once: true });
327
+ // From here on the request may have reached the target.
328
+ stdin.write(line);
329
+ });
330
+ }
331
+ /**
332
+ * Driver-owned: signal only the group this channel created, then escalate after
333
+ * the grace period. Supervisor-owned: stop using the pipes; the supervisor stops
334
+ * the process.
335
+ */
336
+ async stop() {
337
+ this.stopping = true;
338
+ const owned = this.owned;
339
+ if (!owned) {
340
+ this.pending?.reject(new ChannelFailure('aborted', true));
341
+ this.io.stdout.off('data', this.onData);
342
+ return;
343
+ }
344
+ if (!this.exitState) {
345
+ try {
346
+ this.io.stdin.end();
347
+ }
348
+ catch { /* already closed */ }
349
+ this.signal('SIGTERM');
350
+ if (!(await this.waitExit(Math.max(1, owned.stopTimeoutMs))) && !this.exitState) {
351
+ this.signal('SIGKILL');
352
+ await this.waitExit(2_000);
353
+ }
354
+ }
355
+ // The exit handler swept the group; never let a descendant holding a pipe
356
+ // keep the companion alive.
357
+ this.pending?.reject(new ChannelFailure('exited', true));
358
+ for (const stream of [this.io.stdin, this.io.stdout, this.io.stderr]) {
359
+ try {
360
+ stream?.destroy();
361
+ }
362
+ catch { /* already closed */ }
363
+ }
364
+ }
365
+ /** Resolve true if the owned leader exits within `ms`; the timer never outlives the wait. */
366
+ async waitExit(ms) {
367
+ let timer;
368
+ try {
369
+ return await Promise.race([this.exitPromise.then(() => true),
370
+ new Promise((resolve) => { timer = setTimeout(() => resolve(false), ms); })]);
371
+ }
372
+ finally {
373
+ if (timer)
374
+ clearTimeout(timer);
375
+ }
376
+ }
377
+ signal(name) {
378
+ const owned = this.owned;
379
+ const pid = owned?.child.pid;
380
+ if (!owned || this.exitState || pid === undefined || owned.child.exitCode !== null || owned.child.signalCode !== null)
381
+ return;
382
+ try {
383
+ if (owned.ownsGroup)
384
+ process.kill(-pid, name);
385
+ else
386
+ owned.child.kill(name);
387
+ }
388
+ catch { /* already gone */ }
389
+ }
390
+ }
391
+ // ---------------------------------------------------------------------------
392
+ // Session shared by jsonl-process.v1 and function-wrapper.v1.
393
+ export class JsonLinesSession {
394
+ sessionKey;
395
+ ctx;
396
+ channel;
397
+ onClose;
398
+ counter = 0;
399
+ closed = false;
400
+ constructor(ctx, sessionKey, channel, onClose) {
401
+ this.ctx = ctx;
402
+ this.sessionKey = sessionKey;
403
+ this.channel = channel;
404
+ this.onClose = onClose;
405
+ }
406
+ async invoke(step, signal) {
407
+ const { ctx } = this;
408
+ const bounds = driverBounds(ctx);
409
+ const recorder = new StepRecorder(ctx, step);
410
+ if (this.closed)
411
+ return recorder.finish('failed', null, DRIVER_ERRORS.session_closed);
412
+ const refused = precheck(step, this.sessionKey, ['message', 'task']);
413
+ if (refused)
414
+ return recorder.finish('failed', null, refused);
415
+ const input = stepInput(step);
416
+ this.counter += 1;
417
+ const id = `${step.step_id}.${this.counter}`;
418
+ let line;
419
+ try {
420
+ // A synthetic-session grant travels in the line's `headers` object under its
421
+ // declared header name (the line is never recorded; only `input` is observed).
422
+ const headers = identityHeaders(ctx.identity);
423
+ line = JSON.stringify({ id, session: this.sessionKey, kind: input.kind, input: input.input,
424
+ ...(Object.keys(headers).length ? { headers } : {}) });
425
+ }
426
+ catch (error) {
427
+ return recorder.finish('failed', null, error instanceof CliError ? error.code : DRIVER_ERRORS.step_unsupported);
428
+ }
429
+ if (Buffer.byteLength(line, 'utf8') + 1 > bounds.maxLineBytes)
430
+ return recorder.finish('failed', null, DRIVER_ERRORS.step_unsupported);
431
+ let channel;
432
+ try {
433
+ channel = await this.channel();
434
+ }
435
+ catch (error) {
436
+ return recorder.finish('failed', null, error instanceof CliError ? error.code : NATIVE_ERRORS.process_exited);
437
+ }
438
+ recorder.record('action.observed', { type: 'target.exchange',
439
+ direction: 'to_target', kind: input.kind, session_key: this.sessionKey, request_id: id, content: input.input,
440
+ });
441
+ const abort = stepAbort(ctx, signal, stepTimeoutMs(step, bounds));
442
+ try {
443
+ const reply = await channel.request(id, `${line}\n`, abort.signal);
444
+ if (reply.ok) {
445
+ recorder.record('action.observed', { type: 'target.exchange', direction: 'from_target', request_id: id, content: reply.output });
446
+ return recorder.finish('completed', reply.output, null);
447
+ }
448
+ recorder.record('action.observed', { type: 'target.exchange', direction: 'from_target', request_id: id, error: reply.error });
449
+ return recorder.finish('failed', { error: reply.error }, DRIVER_ERRORS.target_error);
450
+ }
451
+ catch (error) {
452
+ if (error instanceof ChannelFailure)
453
+ return recorder.interrupted(error.kind === 'aborted' ? (abort.cause() ?? 'cancelled') : error.kind, error.written);
454
+ return recorder.interrupted('thrown', true);
455
+ }
456
+ finally {
457
+ abort.dispose();
458
+ }
459
+ }
460
+ async close() {
461
+ if (this.closed)
462
+ return;
463
+ this.closed = true;
464
+ this.onClose();
465
+ }
466
+ }
467
+ // ---------------------------------------------------------------------------
468
+ // jsonl-process.v1 driver.
469
+ export class JsonlProcessDriver {
470
+ profile = 'jsonl-process.v1';
471
+ process = null;
472
+ /** The process this driver launched for the drill, kept after dispose so the close can report how it ended. */
473
+ launched = null;
474
+ sessions = new Set();
475
+ async describe() {
476
+ return { available: true, reason: null };
477
+ }
478
+ async prepare(ctx) {
479
+ const plan = driverPlanFor(ctx, 'jsonl-process.v1');
480
+ if (this.process)
481
+ throw planError('The JSON-lines driver is already prepared; a second process was not started.');
482
+ const service = ctx.plan.services.find((entry) => entry.alias === plan.service_alias);
483
+ if (!service)
484
+ throw planError(`The approved plan has no service "${plan.service_alias}", so the JSON-lines driver was not prepared.`);
485
+ if (service.mode !== 'launch' || !service.command)
486
+ throw planError(`The JSON-lines service "${service.alias}" must be a launch service: the driver owns its standard input and output, which an already running process cannot provide. Nothing was started.`);
487
+ const handle = ctx.services.get(service.alias);
488
+ // The supervisor skips this service (see supervisor.ts); a handle here means
489
+ // something else started it, and its stdio is not ours to speak over.
490
+ if (handle)
491
+ throw planError(`The JSON-lines service "${service.alias}" was started by another owner, so the driver cannot use its standard input and output. Nothing was sent.`);
492
+ const cwd = await insideRoot(rootPath(ctx, service.root_alias), service.cwd);
493
+ this.process = await JsonLinesProcess.start(ctx, {
494
+ label: `service "${service.alias}"`,
495
+ executable: service.command.executable, args: [...service.command.args], cwd, env: ctx.env,
496
+ readiness: service.readiness, readinessTimeoutMs: service.readiness_timeout_ms,
497
+ stopTimeoutMs: service.stop_timeout_ms || driverBounds(ctx).stopTimeoutMs,
498
+ // Recorded on spawn, so a process that failed readiness is still reported as launched and reaped.
499
+ onSpawned: (channel) => { this.launched = { alias: service.alias, channel }; },
500
+ });
501
+ }
502
+ /** SHA-256 of the stdout line in which the driver-owned process announced readiness. */
503
+ async readinessProbe(ctx) {
504
+ const digest = this.process?.readyLineSha256 ?? null;
505
+ if (!digest) {
506
+ const plan = driverPlanFor(ctx, 'jsonl-process.v1');
507
+ throw unattested(`The JSON-lines service "${plan.service_alias}" needs stdout readiness text in the approved plan before the service can admit the drill. Nothing was claimed.`);
508
+ }
509
+ return { kind: 'jsonl_handshake', response_sha256: digest };
510
+ }
511
+ ownedProcesses() {
512
+ const launched = this.launched;
513
+ return launched ? [{ alias: launched.alias, launch_id: launched.channel.launchId, exit: launched.channel.exit }] : [];
514
+ }
515
+ async openSession(ctx, sessionKey) {
516
+ if (!this.process)
517
+ throw new CliError(DRIVER_ERRORS.session_failed, 'The JSON-lines driver was not prepared, so no session was opened.');
518
+ if (!sessionKey)
519
+ throw new CliError(DRIVER_ERRORS.session_failed, 'The session key is empty, so no session was opened.');
520
+ const channel = async () => {
521
+ const current = this.process;
522
+ if (!current || current.exited)
523
+ throw nativeError('process_exited', 'The JSON-lines service is no longer running, so the step was not sent. It is not restarted automatically.');
524
+ return current;
525
+ };
526
+ const session = new JsonLinesSession(ctx, sessionKey, channel, () => this.sessions.delete(session));
527
+ this.sessions.add(session);
528
+ emit(ctx, 'action.observed', { type: 'session.opened', profile: this.profile, session_key: sessionKey });
529
+ return session;
530
+ }
531
+ async dispose() {
532
+ for (const session of [...this.sessions])
533
+ await session.close();
534
+ const current = this.process;
535
+ this.process = null;
536
+ await current?.stop();
537
+ }
538
+ }