firedrill-run 2.2.5 → 3.0.1

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 +176 -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 +506 -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 +1627 -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 +96 -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,322 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { constants } from 'node:fs';
3
+ import { open, realpath } from 'node:fs/promises';
4
+ import { basename, dirname, join, resolve } from 'node:path';
5
+ import { createInterface } from 'node:readline/promises';
6
+ import { setTimeout as sleep } from 'node:timers/promises';
7
+ import { performance } from 'node:perf_hooks';
8
+ import { z } from 'zod';
9
+ import { api } from './auth.js';
10
+ import { privateDirectory } from './credentials.js';
11
+ import { CliError, releaseClosed } from './http.js';
12
+ import { localSource } from './local-source.js';
13
+ import { selectOne, terminalText } from './prompts.js';
14
+ import { identifier } from './world-contracts.js';
15
+ import { selectedWorkspace } from './world-access.js';
16
+ import { withBootstrapProcessLock } from './bootstrap-process-lock.js';
17
+ import { capturedSourceIntent, connectPreparedSource, retainPreparedSource, resumePreparedSource, bindSavedProject, ownedSourceMetadataFile, readSourceMetadata, writeSourceMetadata } from './source-connection.js';
18
+ import { nativeMetadataCanonical, localSourceOriginalMatches } from '../../contracts/local-value-source-contracts.js';
19
+ import { readSourceSet, readSourceSetWithdrawal, sourceSetWithdrawalSchema } from '../../contracts/source-set-contracts.js';
20
+ import { rememberSourceSelection } from './source-selection-intents.js';
21
+ const selectionSchema = z.object({ name: z.string().trim().min(1).max(120).optional(),
22
+ roots: z.array(z.object({ alias: z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), path: z.string().min(1).max(4096) }).strict()).min(1).max(128),
23
+ graph: z.record(z.string(), z.unknown()).optional() }).strict();
24
+ const digest = (value) => createHash('sha256').update(nativeMetadataCanonical(value)).digest('hex');
25
+ const invalid = () => new CliError('source_batch_receipt_invalid', 'The source selection no longer matches this account, workspace or original capture. Nothing was substituted.');
26
+ const pending = (batch, step) => new CliError('source_batch_pending', `${step} Keep this selection and resume with firedrill connect multi-resume ${batch.key}. No capture, upload or execution will be repeated automatically.`);
27
+ const auth = (scope, signal) => ({ actor: scope.owner, workspace: scope.workspace, signal });
28
+ async function pathFor(scope, key) {
29
+ return join(await privateDirectory(), `source-batch-${identifier(scope.owner)}-${identifier(scope.workspace)}-${identifier(key)}.json`);
30
+ }
31
+ async function save(batch) { await writeSourceMetadata(await pathFor(batch, batch.key), batch); }
32
+ async function load(scope, key) {
33
+ const file = await ownedSourceMetadataFile(await pathFor(scope, key), 768 * 1024);
34
+ try {
35
+ const value = await readSourceMetadata(file, 768 * 1024);
36
+ if (value.schema !== 'firedrill.local-source-batch.v1' || value.key !== identifier(key)
37
+ || value.owner !== scope.owner || value.workspace !== scope.workspace || !Array.isArray(value.roots)
38
+ || value.roots.length < 1 || value.roots.length > 128 || typeof value.name !== 'string' || !value.name || value.name.length > 120
39
+ || ![value.compose_key, value.world_key].every(item => identifier(item) === item)
40
+ || ![value.agent_id, value.expected_source_id, value.source_id, value.world_id].every(item => item === null || identifier(item) === item)
41
+ || ![value.compose_dispatched, value.world_dispatched].every(item => typeof item === 'boolean')
42
+ || new Set(value.roots.map(item => item.alias)).size !== value.roots.length
43
+ || new Set(value.roots.map(item => item.path)).size !== value.roots.length)
44
+ throw invalid();
45
+ for (const root of value.roots) {
46
+ const intent = root.intent;
47
+ if (!/^[a-z][a-z0-9_-]{0,63}$/.test(root.alias) || !root.path || typeof root.dispatched !== 'boolean'
48
+ || root.source_id !== null && identifier(root.source_id) !== root.source_id
49
+ || intent.schema !== 'firedrill.source-connect-intent.v1' || intent.owner !== scope.owner || intent.workspace !== scope.workspace
50
+ || identifier(intent.key) !== intent.key || intent.body.defer_world !== true
51
+ || intent.project_key !== createHash('sha256').update(root.path).digest('hex')
52
+ || intent.body.component_agent_id !== undefined && intent.body.component_agent_id !== value.agent_id
53
+ || !/^[a-f0-9]{64}$/.test(intent.body.archive.sha256) || !/^[a-f0-9]{64}$/.test(intent.body.capture.content_digest))
54
+ throw invalid();
55
+ }
56
+ return value;
57
+ }
58
+ catch {
59
+ throw new CliError('source_batch_journal_invalid', 'The original private source selection needs attention. It was not discarded, recaptured or uploaded.');
60
+ }
61
+ finally {
62
+ await file.close();
63
+ }
64
+ }
65
+ async function readSelection(path) {
66
+ const file = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
67
+ try {
68
+ const stat = await file.stat();
69
+ if (!stat.isFile() || stat.size > 128 * 1024)
70
+ throw new Error();
71
+ const bytes = Buffer.alloc(stat.size + 1);
72
+ const result = await file.read(bytes, 0, bytes.length, 0);
73
+ if (result.bytesRead !== stat.size)
74
+ throw new Error();
75
+ const selection = selectionSchema.parse(JSON.parse(new TextDecoder('utf8', { fatal: true }).decode(bytes.subarray(0, result.bytesRead))));
76
+ // Paths are relative only to this explicitly selected declaration file.
77
+ return { ...selection, roots: selection.roots.map(root => ({ ...root, path: resolve(dirname(path), root.path) })) };
78
+ }
79
+ catch {
80
+ throw new CliError('source_batch_input_invalid', 'Use a JSON file with roots [{alias,path}], an optional name and optional service graph. No credentials or source files belong in this file.', 2);
81
+ }
82
+ finally {
83
+ await file.close();
84
+ }
85
+ }
86
+ async function interactiveSelection(signal) {
87
+ const roots = [];
88
+ const prompt = createInterface({ input: process.stdin, output: process.stderr, terminal: false });
89
+ try {
90
+ while (roots.length < 128) {
91
+ const path = (await prompt.question(roots.length ? 'Add source folder (blank to continue): ' : 'Agent source folder (blank for current folder): ', { signal })).trim();
92
+ if (!path && roots.length)
93
+ break;
94
+ const selected = resolve(path || process.cwd());
95
+ const proposed = basename(selected).toLowerCase().replace(/[^a-z0-9_-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 48);
96
+ const defaultAlias = /^[a-z]/.test(proposed) && !roots.some(root => root.alias === proposed) ? proposed : `component-${roots.length + 1}`;
97
+ const alias = (await prompt.question(`Component name (${defaultAlias}): `, { signal })).trim() || defaultAlias;
98
+ if (!/^[a-z][a-z0-9_-]{0,63}$/.test(alias) || roots.some(root => root.alias === alias))
99
+ throw new CliError('source_alias_invalid', 'Use distinct short component names beginning with a letter.', 2);
100
+ roots.push({ alias, path: selected });
101
+ }
102
+ return { roots };
103
+ }
104
+ finally {
105
+ prompt.close();
106
+ }
107
+ }
108
+ function checkedWorld(value, batch) {
109
+ if (!value || value.schema !== 'firedrill.world-creation.v1' || value.actor_id !== batch.owner
110
+ || value.workspace_id !== batch.workspace || value.agent_id !== batch.agent_id || value.source_id !== batch.source_id
111
+ || value.request_key !== batch.world_key || !['not_received', 'accepted', 'withdrawn'].includes(value.state)
112
+ || typeof value.resource_available !== 'boolean' || value.world_id !== null && identifier(value.world_id) !== value.world_id
113
+ || value.resource_available && (value.state !== 'accepted' || !value.world_id || value.detail_url !== `/worlds/${value.world_id}`))
114
+ throw invalid();
115
+ return value;
116
+ }
117
+ async function advance(batch, signal, output) {
118
+ const context = auth(batch, signal);
119
+ for (let index = 0; index < batch.roots.length; index++) {
120
+ const root = batch.roots[index];
121
+ if (root.source_id)
122
+ continue;
123
+ if (index > 0 && !batch.agent_id)
124
+ throw invalid();
125
+ if (!root.dispatched && index > 0)
126
+ root.intent.body.component_agent_id = batch.agent_id;
127
+ let receipt;
128
+ if (root.dispatched)
129
+ receipt = await resumePreparedSource(batch, root.intent.key, signal, output);
130
+ else {
131
+ await retainPreparedSource(root.intent);
132
+ root.dispatched = true;
133
+ await save(batch);
134
+ receipt = await connectPreparedSource(root.intent, signal, output);
135
+ }
136
+ if (receipt.state === 'not_retained' || !localSourceOriginalMatches(receipt, batch, root.intent.key, root.intent.body, digest(root.intent.body)))
137
+ throw invalid();
138
+ if (receipt.state !== 'connected')
139
+ throw pending(batch, `Source component ${root.alias} is ${receipt.state}.`);
140
+ const row = receipt;
141
+ if (!row.defer_world || row.world_id !== null || !row.agent_id || !row.source_id
142
+ || batch.agent_id && row.agent_id !== batch.agent_id)
143
+ throw invalid();
144
+ if (index === 0) {
145
+ batch.agent_id = identifier(row.agent_id);
146
+ batch.expected_source_id = identifier(row.source_id);
147
+ }
148
+ root.source_id = identifier(row.source_id);
149
+ await save(batch);
150
+ }
151
+ const base = `/api/workspaces/${batch.workspace}/agents/${batch.agent_id}`;
152
+ const selection = { expected_source_id: batch.expected_source_id, consent_to_transfer: true,
153
+ roots: batch.roots.map(root => ({ alias: root.alias, source_id: root.source_id })), ...(batch.graph ? { graph: batch.graph } : {}) };
154
+ await rememberSourceSelection(batch, batch.agent_id, batch.compose_key, selection);
155
+ const composition = (value) => {
156
+ if (sourceSetWithdrawalSchema.safeParse(value).success) {
157
+ readSourceSetWithdrawal(value, batch.workspace, batch.agent_id, batch.owner, batch.compose_key, digest({ ...selection, graph: selection.graph ?? {} }));
158
+ throw new CliError('source_set_withdrawn', 'This original source selection was withdrawn. No replacement composition or world was created.');
159
+ }
160
+ return readSourceSet(value, batch.workspace, batch.agent_id, batch.compose_key);
161
+ };
162
+ let raw = await api(`${base}/source-sets/${batch.compose_key}`, context);
163
+ if (raw.state === 'not_received') {
164
+ z.object({ state: z.literal('not_received'), request_key: z.literal(batch.compose_key) }).strict().parse(raw);
165
+ if (batch.compose_dispatched)
166
+ throw pending(batch, `The original source-composition request has no retained receipt yet. Inspect sources status ${batch.compose_key} --agent ${batch.agent_id}; explicitly retry the same sources use --request-key or withdraw that original selection.`);
167
+ batch.compose_dispatched = true;
168
+ await save(batch);
169
+ output('source_set_request', { agent_id: batch.agent_id, request_key: batch.compose_key, batch_key: batch.key }, 'Combining the approved source captures.');
170
+ try {
171
+ raw = await api(`${base}/source-sets`, { ...context, method: 'POST', idempotencyKey: batch.compose_key, body: selection });
172
+ }
173
+ catch (error) {
174
+ if (signal.aborted || releaseClosed(error))
175
+ throw error;
176
+ raw = await api(`${base}/source-sets/${batch.compose_key}`, context);
177
+ if (raw.state === 'not_received')
178
+ throw pending(batch, 'The original composition may still arrive.');
179
+ }
180
+ }
181
+ let composed = composition(raw);
182
+ const deadline = performance.now() + 60000;
183
+ while (true) {
184
+ if (composed.actor_id !== batch.owner || composed.previous_source_id !== batch.expected_source_id
185
+ || composed.request_sha256 !== digest({ ...selection, graph: selection.graph ?? {} })
186
+ || composed.roots.length !== selection.roots.length || selection.roots.some(root => !composed.roots.some(actual => actual.alias === root.alias && actual.source_id === root.source_id)))
187
+ throw invalid();
188
+ if (composed.state === 'ready')
189
+ break;
190
+ if (['failed', 'withdrawn'].includes(composed.state))
191
+ throw new CliError('source_batch_composition_failed', composed.failure?.message ?? 'This source selection could not be composed. Review its saved request.');
192
+ if (performance.now() >= deadline)
193
+ throw pending(batch, 'Source composition is still in progress.');
194
+ await sleep(1500, undefined, { signal });
195
+ composed = composition(await api(`${base}/source-sets/${batch.compose_key}`, context));
196
+ }
197
+ if (batch.source_id && batch.source_id !== composed.source_id)
198
+ throw invalid();
199
+ const sourceId = composed.source_id;
200
+ batch.source_id = sourceId;
201
+ await save(batch);
202
+ const body = { actor_id: batch.owner, source_id: sourceId };
203
+ const status = `${base}/world-requests/${batch.world_key}?${new URLSearchParams(body)}`;
204
+ let world = checkedWorld(await api(status, context), batch);
205
+ if (world.state === 'not_received') {
206
+ if (batch.world_dispatched)
207
+ throw pending(batch, 'The original world request may still arrive.');
208
+ batch.world_dispatched = true;
209
+ await save(batch);
210
+ try {
211
+ world = checkedWorld(await api(`${base}/worlds`, { ...context, method: 'POST', idempotencyKey: batch.world_key, body }), batch);
212
+ }
213
+ catch (error) {
214
+ if (signal.aborted || releaseClosed(error))
215
+ throw error;
216
+ world = checkedWorld(await api(status, context), batch);
217
+ if (world.state === 'not_received')
218
+ throw pending(batch, 'The original world request is not yet confirmed.');
219
+ }
220
+ }
221
+ if (world.state !== 'accepted' || !world.resource_available || !world.world_id)
222
+ throw new CliError('source_batch_world_unavailable', 'The original combined-source world is no longer available. No replacement was created.');
223
+ if (batch.world_id && batch.world_id !== world.world_id)
224
+ throw invalid();
225
+ batch.world_id = world.world_id;
226
+ await save(batch);
227
+ for (const root of batch.roots)
228
+ await bindSavedProject(batch, root.path, { world: batch.world_id,
229
+ agent: batch.agent_id, source: batch.source_id, content_digest: root.intent.body.capture.content_digest, batch_key: batch.key });
230
+ const result = { state: 'connected', request_key: batch.key, world_id: batch.world_id,
231
+ agent_id: batch.agent_id, source_id: batch.source_id, roots: batch.roots.length };
232
+ output('source_batch_connected', result, `${batch.roots.length} source components connected to one agent and one world.\nWorld: ${batch.world_id}\nThe world can use the combined sources. No build or simulation started.`);
233
+ return result;
234
+ }
235
+ /** Read only the exact original private selection and its existing receipts.
236
+ * Never advance, capture, upload or compose while checking execution authority.
237
+ */
238
+ export async function originalLocalSourceBatch(scope, key, world, source, sourceSet, signal) {
239
+ const batch = await load(scope, identifier(key));
240
+ if (batch.world_id !== world || batch.source_id !== source || !batch.agent_id || !batch.expected_source_id
241
+ || !batch.world_dispatched || !batch.compose_dispatched || batch.roots.length !== sourceSet.root_count
242
+ || batch.roots.some(root => !root.dispatched || !root.source_id))
243
+ throw invalid();
244
+ const selection = { expected_source_id: batch.expected_source_id, consent_to_transfer: true,
245
+ roots: batch.roots.map(root => ({ alias: root.alias, source_id: root.source_id })), ...(batch.graph ? { graph: batch.graph } : {}) };
246
+ const composed = readSourceSet(await api(`/api/workspaces/${scope.workspace}/agents/${batch.agent_id}/source-sets/${batch.compose_key}`, auth(scope, signal)), scope.workspace, batch.agent_id, batch.compose_key);
247
+ if (composed.state !== 'ready' || composed.id !== sourceSet.id || composed.actor_id !== scope.owner || composed.source_id !== source
248
+ || composed.previous_source_id !== batch.expected_source_id || composed.source_set_sha256 !== sourceSet.source_set_sha256
249
+ || composed.graph_sha256 !== sourceSet.graph_sha256 || digest(composed.graph) !== sourceSet.graph_sha256
250
+ || composed.request_sha256 !== digest({ ...selection, graph: selection.graph ?? {} })
251
+ || composed.roots.length !== batch.roots.length || batch.roots.some(root => !composed.roots.some(row => row.alias === root.alias && row.source_id === root.source_id)))
252
+ throw invalid();
253
+ const roots = [];
254
+ for (const root of batch.roots) {
255
+ signal.throwIfAborted();
256
+ const receipt = await api(`/api/workspaces/${scope.workspace}/local-sources/${root.intent.key}`, auth(scope, signal));
257
+ if (!localSourceOriginalMatches(receipt, scope, root.intent.key, root.intent.body, digest(root.intent.body))
258
+ || receipt.state !== 'connected' || receipt.source_id !== root.source_id || receipt.agent_id !== batch.agent_id
259
+ || !receipt.defer_world || receipt.world_id !== null)
260
+ throw invalid();
261
+ roots.push({ alias: root.alias, path: root.path, source_id: root.source_id, content_digest: root.intent.body.capture.content_digest });
262
+ }
263
+ return { key: batch.key, roots: roots.sort((left, right) => left.alias < right.alias ? -1 : left.alias > right.alias ? 1 : 0), composition: composed };
264
+ }
265
+ export async function connectSources(options, output, provided) {
266
+ const interactive = !options.json && !!process.stdin.isTTY && !!process.stderr.isTTY;
267
+ if (!interactive && ((!options.file && !provided) || !options.upload))
268
+ throw new CliError('source_transfer_consent_required', 'Use connect multi --file <sources.json> --upload-source to approve exactly the listed source roots.', 2);
269
+ const selection = selectionSchema.parse(provided ?? (options.file ? await readSelection(resolve(options.file)) : await interactiveSelection(options.signal)));
270
+ const scope = await selectedWorkspace({ workspace: options.workspace, expectedOwner: options.expectedOwner,
271
+ interactive, signal: options.signal, openBrowser: options.openBrowser });
272
+ const roots = [], physical = new Set();
273
+ for (const selected of selection.roots) {
274
+ const path = await realpath(resolve(selected.path));
275
+ if (physical.has(path) || roots.some(root => root.alias === selected.alias))
276
+ throw new CliError('source_selection_duplicate', 'Choose distinct physical folders and component names.', 2);
277
+ physical.add(path);
278
+ const capture = await localSource('snapshot', path, options.signal, interactive);
279
+ output('source_component_capture', { alias: selected.alias, files: capture.files.length, bytes: capture.expanded_bytes,
280
+ content_digest: capture.content_digest, base_commit: capture.repository?.base_commit ?? null }, `${terminalText(selected.alias)}: ${capture.files.length} selected files, ${capture.expanded_bytes} bytes. Environment files and values excluded.`);
281
+ roots.push({ alias: selected.alias, path, intent: capturedSourceIntent(scope, path, (options.name ?? selection.name ?? basename(path)).trim(), capture, { deferWorld: true }), dispatched: false, source_id: null });
282
+ }
283
+ const approved = options.upload || interactive && await selectOne('Connect these sources as one agent?', [
284
+ { value: false, label: 'Keep captures local' }, { value: true, label: `Upload ${roots.length} selected components`,
285
+ detail: 'Cloud source processing only. Credentials stay excluded. No agent execution, build or simulation starts.' }
286
+ ], options.signal);
287
+ if (!approved) {
288
+ output('source_batch_local', { uploaded: false, roots: roots.length }, 'Source captures kept locally. No cloud resources created.');
289
+ return null;
290
+ }
291
+ const name = (options.name ?? selection.name ?? basename(roots[0].path)).trim();
292
+ if (!name || name.length > 120 || /[\u0000-\u001f\u007f]/.test(name))
293
+ throw new CliError('agent_name_invalid', 'Choose an agent name up to 120 characters without terminal controls.', 2);
294
+ roots[0].intent.body.name = name;
295
+ const batch = { ...scope, schema: 'firedrill.local-source-batch.v1', key: randomUUID(), name, roots,
296
+ ...(selection.graph ? { graph: selection.graph } : {}), agent_id: null, expected_source_id: null,
297
+ compose_key: randomUUID(), compose_dispatched: false, source_id: null, world_key: randomUUID(), world_dispatched: false,
298
+ world_id: null, created_at: new Date().toISOString() };
299
+ await save(batch);
300
+ output('source_batch_request', { request_key: batch.key, roots: roots.length }, `Source selection ${batch.key}. Recovery: firedrill connect multi-resume ${batch.key}.`);
301
+ return withBootstrapProcessLock(join(await privateDirectory(), `source-batch-lock-${batch.key}`), options.signal, signal => advance(batch, signal, output));
302
+ }
303
+ export async function sourceBatchCommand(args, options, output) {
304
+ const action = args[0] ?? 'multi';
305
+ if (action === 'multi' && args.length <= 1)
306
+ return connectSources(options, output);
307
+ if (!['multi-resume', 'multi-status'].includes(action) || args.length !== 2 || options.file || options.upload || options.name)
308
+ throw new CliError('arguments_invalid', 'Use connect multi [--file sources.json], multi-status <key> or multi-resume <key>. Saved selections cannot change roots or consent.', 2);
309
+ const scope = await selectedWorkspace({ workspace: options.workspace, expectedOwner: options.expectedOwner,
310
+ interactive: !options.json && !!process.stdin.isTTY && !!process.stderr.isTTY, signal: options.signal, openBrowser: options.openBrowser });
311
+ const key = identifier(args[1]);
312
+ return withBootstrapProcessLock(join(await privateDirectory(), `source-batch-lock-${key}`), options.signal, async (signal) => {
313
+ const batch = await load(scope, key);
314
+ if (action === 'multi-status') {
315
+ output('source_batch_status', { request_key: batch.key, roots: batch.roots.map(root => ({ alias: root.alias,
316
+ request_key: root.intent.key, source_id: root.source_id, dispatched: root.dispatched })), agent_id: batch.agent_id,
317
+ source_id: batch.source_id, world_id: batch.world_id }, 'Retained local source selection. Use multi-resume to reconcile original receipts; no source was recaptured or uploaded.');
318
+ return null;
319
+ }
320
+ return advance(batch, signal, output);
321
+ });
322
+ }