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,57 @@
1
+ const object = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
2
+ const uuid = (value) => typeof value === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(value);
3
+ const integer = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
4
+ const date = (value) => typeof value === 'string' && Number.isFinite(Date.parse(value));
5
+ const kinds = (value) => value === 'agents' || value === 'worlds';
6
+ const canonicalBody = (value) => JSON.stringify([value.kind, value.id, value.action, value.basis, value.confirm_name, value.retain_saved_data]);
7
+ export function resourceLifecycleBodyMatches(value) {
8
+ return object(value) && Object.keys(value).sort().join(',') === 'action,basis,confirm_name,id,kind,retain_saved_data'
9
+ && kinds(value.kind) && uuid(value.id) && ['archive', 'restore', 'remove'].includes(String(value.action))
10
+ && integer(value.basis) && value.basis > 0 && value.basis < Number.MAX_SAFE_INTEGER
11
+ && typeof value.confirm_name === 'string' && value.confirm_name.length <= 120 && value.retain_saved_data === true;
12
+ }
13
+ export function resourceLifecycleMetadataMatches(value, selected) {
14
+ return !!value && value.actor_id === selected.actor && value.workspace_id === selected.workspace
15
+ && value.id === selected.id && uuid(value.id) && value.kind === selected.kind && kinds(value.kind)
16
+ && typeof value.name === 'string' && value.name.length <= 120 && integer(value.revision) && value.revision > 0
17
+ && (value.archived_at === null || date(value.archived_at)) && typeof value.removed === 'boolean'
18
+ && typeof value.can_write === 'boolean' && typeof value.can_remove === 'boolean';
19
+ }
20
+ /** Whole original receipt, never just a returned record ID or current visibility.
21
+ * An absent receipt does not cancel an in-flight action; withdrawal is distinct. */
22
+ export function resourceLifecycleReceiptMatches(value, selected, original) {
23
+ if (!value || value.schema !== 'firedrill.resource-lifecycle.v1' || value.actor_id !== selected.actor
24
+ || value.workspace_id !== selected.workspace || value.request_key !== original.key || !uuid(value.request_key))
25
+ return false;
26
+ if (value.state === 'not_received')
27
+ return value.body === null && value.result === null && value.created_at === null;
28
+ if (!date(value.created_at))
29
+ return false;
30
+ if (value.state === 'withdrawn')
31
+ return value.body === null && value.result === null;
32
+ if (value.state !== 'accepted' || !resourceLifecycleBodyMatches(value.body) || !value.result
33
+ || original.kind !== undefined && value.body.kind !== original.kind
34
+ || original.body !== undefined && canonicalBody(value.body) !== canonicalBody(original.body))
35
+ return false;
36
+ const body = value.body, result = value.result;
37
+ return result.id === body.id && result.kind === body.kind && result.name === body.confirm_name
38
+ && integer(result.revision) && result.revision === body.basis + 1 && result.removed === (body.action === 'remove')
39
+ && (body.action === 'restore' ? result.archived_at === null : date(result.archived_at));
40
+ }
41
+ export function resourceLifecycleReceiptSame(left, right) {
42
+ const immutable = (value) => JSON.stringify([value.schema, value.workspace_id, value.actor_id,
43
+ value.request_key, value.state, value.body === null ? null : canonicalBody(value.body), value.result === null ? null
44
+ : [value.result.kind, value.result.id, value.result.name, value.result.revision, value.result.archived_at, value.result.removed], value.created_at]);
45
+ return immutable(left) === immutable(right);
46
+ }
47
+ export function resourceLifecyclePageMatches(value, selected, requested) {
48
+ return !!value && value.actor_id === selected.actor && value.workspace_id === selected.workspace
49
+ && value.kind === requested.kind && value.query === requested.query.trim() && value.state === requested.state
50
+ && integer(value.count) && integer(value.page) && value.page === requested.page
51
+ && integer(value.page_size) && value.page_size > 0 && value.page_size <= 100 && Array.isArray(value.results)
52
+ && value.results.length <= value.page_size && value.results.length <= value.count
53
+ && (value.next === null || typeof value.next === 'string') && (value.previous === null || typeof value.previous === 'string')
54
+ && value.results.every(row => !!row && row.state !== 'not_received' && (!requested.state || row.state === requested.state)
55
+ && resourceLifecycleReceiptMatches(row, selected, { key: row.request_key,
56
+ ...(kinds(requested.kind) ? { kind: requested.kind } : {}) }));
57
+ }
@@ -0,0 +1,12 @@
1
+ export function memoryProbeMatches(a, b) {
2
+ const points = (probe) => {
3
+ if (probe.checkpoint)
4
+ return [probe.exposures, probe.checkpoint];
5
+ return [probe.exposure_turns.map(turn => ({ kind: 'turn', turn })), { kind: 'turn', turn: probe.checkpoint_turn }];
6
+ };
7
+ const same = (x, y) => x.kind === y.kind && (x.kind === 'turn'
8
+ ? y.kind === 'turn' && x.turn === y.turn : y.kind === 'world_event' && x.event_key === y.event_key);
9
+ const [ax, ac] = points(a), [bx, bc] = points(b);
10
+ return a.key === b.key && a.kind === b.kind && a.expectation === b.expectation && same(ac, bc)
11
+ && ax.length === bx.length && ax.every((point, index) => same(point, bx[index]));
12
+ }
@@ -0,0 +1,39 @@
1
+ const uuid = (value) => typeof value === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(value);
2
+ export function revisionRequestMatches(value, scope, key) {
3
+ if (!value || typeof value !== 'object' || Array.isArray(value))
4
+ return false;
5
+ const row = value;
6
+ return row.schema === 'firedrill.revision-request-receipt.v1' && row.kind === scope.kind
7
+ && row.actor_id === scope.actor && row.workspace_id === scope.workspace && row.world_id === scope.world
8
+ && row.parent_id === scope.parent && uuid(row.request_key) && row.request_key === key
9
+ && (row.state === 'not_received' ? row.resource_available === false && row.resource_id === null && row.created_at === null
10
+ : ['accepted', 'unavailable'].includes(row.state) && typeof row.created_at === 'string' && Number.isFinite(Date.parse(row.created_at))
11
+ && (row.state === 'accepted' ? row.resource_available === true && uuid(row.resource_id)
12
+ : row.resource_available === false && row.resource_id === null));
13
+ }
14
+ export function revisionRequestPath(scope, key) {
15
+ return `/${scope.kind === 'scenario_draft' ? 'scenario-drafts' : 'execution-proposals'}/${scope.parent}/requests/${key}`;
16
+ }
17
+ /** Stable request comparison only. The returned private text must never be persisted or logged. */
18
+ export function revisionRequestCanonical(body) {
19
+ if (new TextEncoder().encode(body).length > 512 * 1024)
20
+ throw new Error('The revision exceeds the supported request size.');
21
+ const value = JSON.parse(body);
22
+ if (!value || typeof value !== 'object' || Array.isArray(value))
23
+ throw new Error('Use a revision request object.');
24
+ let count = 0;
25
+ function encode(one, depth) {
26
+ if (depth > 64 || ++count > 100000)
27
+ throw new Error('The revision exceeds the supported request complexity.');
28
+ if (Array.isArray(one))
29
+ return '[' + one.map(item => encode(item, depth + 1)).join(',') + ']';
30
+ if (one && typeof one === 'object')
31
+ return '{' + Object.keys(one).sort().map(key => JSON.stringify(key) + ':'
32
+ + encode(one[key], depth + 1)).join(',') + '}';
33
+ const encoded = JSON.stringify(one);
34
+ if (encoded === undefined)
35
+ throw new Error('Use a complete revision request.');
36
+ return encoded;
37
+ }
38
+ return encode(value, 0);
39
+ }
@@ -0,0 +1,76 @@
1
+ const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
2
+ const hash = /^[a-f0-9]{64}$/;
3
+ const count = (value) => Number.isSafeInteger(value) && value >= 0;
4
+ const timestamp = (value) => typeof value === 'string' && Number.isFinite(Date.parse(value));
5
+ export function savedRecordSelection(prefix, workspace, observation) {
6
+ const parts = prefix.split('/');
7
+ if (!uuid.test(workspace) || !uuid.test(observation) || parts[0] !== '' || parts[1] !== 'api'
8
+ || parts[2] !== 'workspaces' || parts[3] !== workspace)
9
+ return null;
10
+ const base = { workspace_id: workspace, observation_id: observation, world_id: null, session_id: null, instance_id: null };
11
+ if (parts[4] === 'worlds' && uuid.test(parts[5] ?? '')) {
12
+ if (parts.length === 6)
13
+ return { ...base, world_id: parts[5], scope: 'starting_data' };
14
+ if (parts.length === 10 && parts[6] === 'runtime-sessions' && uuid.test(parts[7] ?? '') && parts[8] === 'observations'
15
+ && parts[9] === observation)
16
+ return { ...base, world_id: parts[5], session_id: parts[7], scope: 'session_sql' };
17
+ }
18
+ return parts.length === 9 && parts[4] === 'tools' && parts[5] === 'instances' && uuid.test(parts[6] ?? '')
19
+ && parts[7] === 'checkpoints' && parts[8] === observation ? { ...base, instance_id: parts[6], scope: 'tool_checkpoint' } : null;
20
+ }
21
+ export function savedRecordSelectionMatches(value, selected) {
22
+ return !!value && !!selected && value.workspace_id === selected.workspace_id && value.world_id === selected.world_id
23
+ && value.session_id === selected.session_id && value.instance_id === selected.instance_id
24
+ && value.observation_id === selected.observation_id && value.scope === selected.scope;
25
+ }
26
+ function headerMatches(value) {
27
+ return !!value && hash.test(value.key) && typeof value.name === 'string' && value.name.length > 0
28
+ && (value.store === null || typeof value.store === 'string') && count(value.row_count) && timestamp(value.observed_at)
29
+ && (value.column_count === null || count(value.column_count)) && value.schema_included === false;
30
+ }
31
+ export function savedCollectionMatches(value, key) {
32
+ return !!value && hash.test(value.key) && value.key === key && !!value.name && count(value.row_count) && timestamp(value.observed_at)
33
+ && (value.store === undefined || value.store === null || typeof value.store === 'string') && Array.isArray(value.columns)
34
+ && value.columns.every(one => !!one.name && typeof one.type === 'string' && typeof one.nullable === 'boolean')
35
+ && Array.isArray(value.primary_key) && value.primary_key.every(name => value.columns.some(one => one.name === name));
36
+ }
37
+ export function savedCollectionsPageMatches(value, selected, query = '') {
38
+ return !!value && savedRecordSelectionMatches(value.selection, selected) && value.query === query.trim()
39
+ && (value.observation === undefined || value.observation.id === selected.observation_id && value.observation.scope === selected.scope)
40
+ && (value.checkpoint === undefined || value.checkpoint.id === selected.observation_id && selected.scope === 'tool_checkpoint')
41
+ && value.results.every(headerMatches);
42
+ }
43
+ export function savedCollectionDetailMatches(value, selected, key) {
44
+ return !!value && savedRecordSelectionMatches(value.selection, selected) && savedCollectionMatches(value, key);
45
+ }
46
+ export function savedStateCellMatches(value, depth = 0) {
47
+ if (!value || depth > 24)
48
+ return false;
49
+ if (value.type === 'null' || value.type === 'redacted')
50
+ return true;
51
+ if (value.type === 'boolean')
52
+ return typeof value.value === 'boolean';
53
+ if (value.type === 'float')
54
+ return typeof value.value === 'number' ? Number.isFinite(value.value) : ['nan', 'inf', '-inf'].includes(value.value);
55
+ if (value.type === 'array')
56
+ return 'value' in value ? Array.isArray(value.value) && value.value.every(one => savedStateCellMatches(one, depth + 1)) : count(value.size);
57
+ if (value.type === 'object')
58
+ return 'value' in value ? !!value.value && typeof value.value === 'object' && !Array.isArray(value.value)
59
+ && Object.values(value.value).every(one => savedStateCellMatches(one, depth + 1)) : count(value.size);
60
+ if (value.type === 'binary')
61
+ return !('value' in value) || value.encoding === 'base64' && typeof value.value === 'string';
62
+ return ['string', 'integer', 'decimal', 'datetime', 'date', 'time', 'uuid'].includes(value.type) && typeof value.value === 'string';
63
+ }
64
+ function rowMatches(value) {
65
+ return !!value && count(value.position) && !!value.values && typeof value.values === 'object' && !Array.isArray(value.values)
66
+ && Object.values(value.values).every(one => savedStateCellMatches(one));
67
+ }
68
+ export function savedRecordsPageMatches(value, selected, key, query = '') {
69
+ return !!value && savedRecordSelectionMatches(value.selection, selected) && value.query === query.trim()
70
+ && savedCollectionMatches(value.collection, key) && value.results.every(rowMatches);
71
+ }
72
+ export function savedRecordDetailMatches(value, selected, key, position) {
73
+ return !!value && savedRecordSelectionMatches(value.selection, selected) && value.scope === selected.scope
74
+ && (value.checkpoint_id === undefined || selected.scope === 'tool_checkpoint' && value.checkpoint_id === selected.observation_id)
75
+ && savedCollectionMatches(value.collection, key) && value.position === position && rowMatches(value);
76
+ }
@@ -0,0 +1,91 @@
1
+ const id = (value) => typeof value === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(value);
2
+ const record = (value) => Boolean(value && typeof value === 'object' && !Array.isArray(value));
3
+ const integer = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 1;
4
+ const hash = (value) => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
5
+ const owns = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
6
+ const MAX_BYTES = 768 * 1024; // Existing 512KiB definition plus bounded grounding/metadata.
7
+ const DISPLAY_CHARACTERS = 2048;
8
+ const labels = { instruction: 'Task', setup_code: 'Starting state setup', ready_code: 'Readiness check',
9
+ fixture: 'Initial data and events', persona: 'Synthetic user', sub_goals: 'Required checks', max_turns: 'Turn limit',
10
+ variables: 'Variables', coverage: 'Coverage links', use_case: 'Use case', branch: 'Branch' };
11
+ function canonical(value) {
12
+ let nodes = 0;
13
+ const seen = new WeakSet();
14
+ function visit(one, depth) {
15
+ if (++nodes > 50000 || depth > 28)
16
+ throw new Error('comparison_capacity');
17
+ if (one === null || typeof one === 'string' || typeof one === 'boolean')
18
+ return one;
19
+ if (typeof one === 'number' && Number.isFinite(one))
20
+ return one;
21
+ if (!one || typeof one !== 'object' || seen.has(one))
22
+ throw new Error('comparison_value');
23
+ seen.add(one);
24
+ if (Array.isArray(one))
25
+ return one.map(value => visit(value, depth + 1));
26
+ if (Object.getPrototypeOf(one) !== Object.prototype && Object.getPrototypeOf(one) !== null)
27
+ throw new Error('comparison_value');
28
+ const result = Object.create(null);
29
+ for (const key of Object.keys(one).sort())
30
+ result[key] = visit(one[key], depth + 1);
31
+ return result;
32
+ }
33
+ const result = JSON.stringify(visit(value, 0));
34
+ if (typeof result !== 'string' || new TextEncoder().encode(result).byteLength > MAX_BYTES)
35
+ throw new Error('comparison_capacity');
36
+ return result;
37
+ }
38
+ export function scenarioDraftReviewMatches(value, expectedId) {
39
+ if (!record(value) || value.schema !== 'firedrill.scenario-draft.v1' || !id(value.id)
40
+ || expectedId !== undefined && value.id !== expectedId || !(value.parent_id === null || id(value.parent_id) && value.parent_id !== value.id)
41
+ || !id(value.actor_id) || !id(value.source_id) || !integer(value.world_revision) || !integer(value.configuration_revision)
42
+ || !hash(value.fingerprint) || !record(value.draft))
43
+ return false;
44
+ const draft = value.draft;
45
+ if (Object.keys(draft).some(key => !['title', 'definition', 'grounds', 'family', 'variation', 'unresolved'].includes(key))
46
+ || typeof draft.title !== 'string' || !draft.title.trim() || draft.title.length > 255 || !record(draft.definition)
47
+ || Object.keys(draft.definition).length > 64 || !Array.isArray(draft.grounds) || draft.grounds.length < 1 || draft.grounds.length > 24
48
+ || !draft.grounds.every(record) || ['family', 'variation'].some(key => owns(draft, key) && (typeof draft[key] !== 'string' || draft[key].length > 255))
49
+ || owns(draft, 'unresolved') && (!Array.isArray(draft.unresolved) || draft.unresolved.length > 24
50
+ || !draft.unresolved.every(one => typeof one === 'string' && one.length <= 1000)))
51
+ return false;
52
+ try {
53
+ canonical(draft);
54
+ return true;
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
60
+ export function sameScenarioDraft(left, right) {
61
+ if (!scenarioDraftReviewMatches(left) || !scenarioDraftReviewMatches(right))
62
+ return false;
63
+ return left.id === right.id && left.parent_id === right.parent_id && left.actor_id === right.actor_id && left.source_id === right.source_id
64
+ && left.world_revision === right.world_revision && left.configuration_revision === right.configuration_revision
65
+ && left.fingerprint === right.fingerprint && canonical(left.draft) === canonical(right.draft);
66
+ }
67
+ function presentation(value, present) {
68
+ if (!present)
69
+ return { present: false, text: 'Not present', truncated: false, characters: 0 };
70
+ const text = typeof value === 'string' ? value : canonical(value);
71
+ return { present: true, text: text.slice(0, DISPLAY_CHARACTERS), truncated: text.length > DISPLAY_CHARACTERS, characters: text.length };
72
+ }
73
+ export function compareScenarioDrafts(parent, child) {
74
+ if (!scenarioDraftReviewMatches(child) || !scenarioDraftReviewMatches(parent, child.parent_id ?? '')
75
+ || child.actor_id !== parent.actor_id || child.source_id !== parent.source_id
76
+ || child.world_revision !== parent.world_revision || child.configuration_revision !== parent.configuration_revision)
77
+ return null;
78
+ const differences = [];
79
+ function compare(field, title, before, after, key) {
80
+ const wasPresent = owns(before, key), isPresent = owns(after, key);
81
+ if (wasPresent === isPresent && (!wasPresent || canonical(before[key]) === canonical(after[key])))
82
+ return;
83
+ differences.push({ field, label: title, before: presentation(before[key], wasPresent), after: presentation(after[key], isPresent) });
84
+ }
85
+ for (const name of ['title', 'family', 'variation', 'grounds', 'unresolved'])
86
+ compare(name, { title: 'Name', family: 'Family', variation: 'Variation', grounds: 'Source grounding', unresolved: 'Unresolved choices' }[name], parent.draft, child.draft, name);
87
+ for (const name of [...new Set([...Object.keys(parent.draft.definition), ...Object.keys(child.draft.definition)])].sort())
88
+ compare('definition.' + name, labels[name] ?? name.replaceAll('_', ' '), parent.draft.definition, child.draft.definition, name);
89
+ return { parent_id: parent.id, draft_id: child.id, parent_fingerprint: parent.fingerprint,
90
+ draft_fingerprint: child.fingerprint, differences };
91
+ }
@@ -0,0 +1,14 @@
1
+ export function scenarioWorldEventsMatch(value, definition) {
2
+ const count = (one, min = 0) => typeof one === 'number' && Number.isSafeInteger(one) && one >= min;
3
+ const name = (one) => typeof one === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(one);
4
+ return !!value && value.definition_digest === definition && /^[a-f0-9]{64}$/.test(definition)
5
+ && count(value.count) && count(value.page, 1) && count(value.page_size, 1) && value.page_size <= 100
6
+ && Array.isArray(value.results) && value.results.length <= value.page_size && new Set(value.results.map(one => one.id)).size === value.results.length
7
+ && value.results.every(one => name(one.id) && ['record', 'operation', 'ingress', 'message'].includes(one.kind)
8
+ && typeof one.after_ms === 'string' && /^(0|[1-9][0-9]{0,9})$/.test(one.after_ms)
9
+ && Array.isArray(one.depends_on) && one.depends_on.length <= 100 && one.depends_on.every(name)
10
+ && (one.repeat === null || !!one.repeat && count(one.repeat.count, 1) && one.repeat.count <= 10000 && count(one.repeat.interval_ms, 1))
11
+ && [one.collection, one.action, one.variable, one.operation, one.method, one.path, one.tool, one.text_preview]
12
+ .every(child => child === null || typeof child === 'string')
13
+ && [null, 'http', 'mcp'].includes(one.protocol) && typeof one.conditional === 'boolean' && typeof one.text_shortened === 'boolean');
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
2
+ const states = new Set(['publishing', 'queued', 'accepted', 'observed', 'not_dispatched', 'unknown', 'stop_requested']);
3
+ const sequence = /^(?:0|[1-9][0-9]{0,18})$/;
4
+ const key = /^[A-Za-z0-9._:-]{8,128}$/;
5
+ export function callableOperationMatches(value) {
6
+ return !!value && !!value.name && value.name.length <= 255 && typeof value.route === 'string'
7
+ && value.route.startsWith('/') && !value.route.startsWith('//')
8
+ && (value.protocol === 'http' ? ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'].includes(value.method ?? '')
9
+ : value.protocol === 'mcp' && value.method === 'POST' && typeof value.mcp_tool === 'string' && value.mcp_tool.length > 0 && value.mcp_tool.length <= 128);
10
+ }
11
+ export function callableOperationsPageMatches(value, service, protocol) {
12
+ return !!value && value.coverage.id === service && value.results.every(row => callableOperationMatches(row) && (!protocol || row.protocol === protocol));
13
+ }
14
+ function scopeMatches(value, scope) {
15
+ return value.workspace_id === scope.workspace && value.world_id === scope.world && value.session_id === scope.session;
16
+ }
17
+ export function sessionCommandMatches(value, scope, selected) {
18
+ if (!value || !scopeMatches(value, scope) || !uuid.test(value.id) || !uuid.test(value.actor_id) || !uuid.test(value.service_id)
19
+ || !key.test(value.request_key) || !states.has(value.state) || !['http', 'mcp'].includes(value.protocol)
20
+ || !sequence.test(value.sequence) || value.sequence === '0' || BigInt(value.sequence) > 9223372036854775807n
21
+ || value.reset_count !== null && (!sequence.test(value.reset_count) || BigInt(value.reset_count) > 9223372036854775807n)
22
+ || value.origin !== (value.protocol === 'mcp' ? 'manual_session_mcp' : 'manual_session_http')
23
+ || !Number.isSafeInteger(value.request_bytes) || value.request_bytes < 0 || value.request_bytes > 8 * 1024 ** 2
24
+ || selected?.id && value.id !== selected.id || selected?.key && (value.request_key !== selected.key || value.actor_id !== scope.actor)
25
+ || selected?.service && value.service_id !== selected.service || selected?.operation && value.operation !== selected.operation
26
+ || selected?.variable && value.variable !== selected.variable || selected?.protocol && value.protocol !== selected.protocol)
27
+ return false;
28
+ const response = value.response;
29
+ if (!response)
30
+ return true;
31
+ if (value.state !== 'observed' || !Number.isSafeInteger(response.body_size) || response.body_size < 0 || response.body_size > 16 * 1024 ** 2)
32
+ return false;
33
+ return value.protocol === 'mcp' ? response.http_status === null && typeof response.mcp_is_error === 'boolean'
34
+ && ['matched', 'mismatch', 'missing_structured', 'not_declared'].includes(response.schema_status ?? '')
35
+ : Number.isInteger(response.http_status) && response.http_status >= 100 && response.http_status <= 599
36
+ && response.mcp_is_error === null && response.schema_status === null;
37
+ }
38
+ export function sessionCommandsPageMatches(value, scope, query = '', service = null) {
39
+ return !!value && scopeMatches(value, scope) && value.query === query.trim() && value.service_filter === service
40
+ && value.results.every(row => sessionCommandMatches(row, scope, service ? { service } : undefined));
41
+ }
42
+ export function sessionCommandRequestMatches(value, scope, original) {
43
+ return !!value && scopeMatches(value, scope) && value.actor_id === scope.actor && value.request_key === original
44
+ && (value.state === 'not_observed' ? value.request === null
45
+ : value.state === 'observed' && !!value.request && sessionCommandMatches(value.request, scope, { key: original }));
46
+ }
47
+ export function sessionConnectionsPageMatches(value, scope, selected) {
48
+ return !!value && scopeMatches(value, scope) && value.query === (selected?.query ?? '').trim()
49
+ && value.service_filter === (selected?.service ?? null) && value.protocol_filter === (selected?.protocol ?? null)
50
+ && value.variable_filter === (selected?.variable ?? null) && value.callable_only === (selected?.callable ?? false)
51
+ && value.results.every(row => uuid.test(row.service_id) && /^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(row.variable)
52
+ && ['http', 'mcp', 'postgres', 'redis', 'amqp'].includes(row.protocol)
53
+ && (!value.callable_only || ['http', 'mcp'].includes(row.protocol))
54
+ && (!value.service_filter || row.service_id === value.service_filter) && (!value.protocol_filter || row.protocol === value.protocol_filter)
55
+ && (!value.variable_filter || row.variable === value.variable_filter));
56
+ }
@@ -0,0 +1,65 @@
1
+ const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
2
+ const key = /^[A-Za-z0-9._:-]{8,128}$/;
3
+ const states = new Set(['queued', 'starting', 'active', 'closing', 'reconciling', 'stopped', 'failed', 'canceled']);
4
+ const terminal = new Set(['stopped', 'failed', 'canceled']);
5
+ export function worldSessionOpeningScopeMatches(value) {
6
+ return !!value && uuid.test(value.source_id) && typeof value.source_revision === 'string' && value.source_revision.length > 0
7
+ && value.source_revision.length <= 256 && Number.isSafeInteger(value.world_revision) && value.world_revision > 0
8
+ && Number.isSafeInteger(value.configuration_revision) && value.configuration_revision >= 0
9
+ && Number.isSafeInteger(value.duration_seconds) && value.duration_seconds >= 1 && value.duration_seconds <= 2147483647
10
+ && Number.isSafeInteger(value.max_duration_seconds) && value.max_duration_seconds >= value.duration_seconds
11
+ && value.max_duration_seconds <= 2147483647 && Number.isSafeInteger(value.real_connections_count) && value.real_connections_count >= 0;
12
+ }
13
+ export function worldSessionMatches(value, scope, selected) {
14
+ if (!value || !uuid.test(value.id) || value.workspace_id !== scope.workspace || value.world_id !== scope.world
15
+ || !uuid.test(value.source_id) || !uuid.test(value.actor_id) || !key.test(value.request_key) || !states.has(value.state)
16
+ || selected?.id && value.id !== selected.id || selected?.key && (value.request_key !== selected.key || value.actor_id !== scope.actor)
17
+ || !['managed', 'local'].includes(value.execution_location)
18
+ || value.provenance !== (value.execution_location === 'local' ? 'customer_device' : 'managed_execution')
19
+ || Boolean(value.terminal_at) !== terminal.has(value.state) || !/^[0-9]+$/.test(value.reset_count)
20
+ || value.local_execution && (value.execution_location !== 'local' || value.actor_id !== scope.actor
21
+ || !uuid.test(value.local_execution.job_id) || !uuid.test(value.local_execution.grant_id) || !uuid.test(value.local_execution.device_key))
22
+ || value.external_effects && (value.external_effects.external_reset_supported !== false || value.external_effects.automatic_target_retry !== false
23
+ || !Number.isSafeInteger(value.external_effects.real_connections_count) || value.external_effects.real_connections_count < 1)
24
+ || value.starting_data && value.starting_data.dataset_id !== value.dataset_id)
25
+ return false;
26
+ if (!value.coordinated_checkpoint || typeof value.coordinated_checkpoint.available !== 'boolean'
27
+ || value.coordinated_checkpoint.available && (!value.application_checkpoint?.available || !value.checkpoints_available || value.external_effects !== null))
28
+ return false;
29
+ const application = value.application_checkpoint;
30
+ if (!application || typeof application.available !== 'boolean' || !Array.isArray(application.components) || application.components.length > 1000
31
+ || application.components.some(one => !one || typeof one.name !== 'string' || one.name.length < 1
32
+ || !['application_memory', 'database', 'files', 'queue_cursor', 'conversation', 'scheduled_jobs'].includes(one.kind)
33
+ || !['application_consistent', 'crash_consistent'].includes(one.consistency))
34
+ || !Array.isArray(application.excluded) || application.excluded.length > 1000
35
+ || application.excluded.some(one => typeof one !== 'string' || one.length < 1 || one.length > 256)
36
+ || application.available && (!application.components.length || !application.excluded.length))
37
+ return false;
38
+ const body = selected?.body;
39
+ if (!body)
40
+ return true;
41
+ return value.actor_id === scope.actor && value.world_revision === body.world_revision
42
+ && value.configuration_revision === body.configuration_revision && (!body.source_id || value.source_id === body.source_id)
43
+ && (!body.source_revision || value.source_revision === body.source_revision)
44
+ && value.dataset_id === (body.dataset_id ?? null) && (value.fork?.checkpoint_id ?? null) === (body.checkpoint_id ?? null)
45
+ && value.execution_location === (body.execution?.location ?? 'managed')
46
+ && value.usage_quote_id === (body.usage_quote_id ?? null)
47
+ && value.application_checkpoint_id === (body.application_checkpoint_id ?? null)
48
+ && (body.execution?.location !== 'local' || value.local_execution?.grant_id === body.execution.grant_id)
49
+ && Boolean(value.external_effects) === Boolean(body.real_account_consent);
50
+ }
51
+ export function worldSessionsPageMatches(value, scope, filter = '') {
52
+ return !!value && value.workspace_id === scope.workspace && value.world_id === scope.world && value.state_filter === filter
53
+ && value.results.every(row => worldSessionMatches(row, scope) && (filter === '' || Boolean(row.terminal_at) === (filter === 'closed')))
54
+ && (value.opening_scope === null || worldSessionOpeningScopeMatches(value.opening_scope));
55
+ }
56
+ export function worldSessionRequestMatches(value, scope, original, body) {
57
+ if (!value || value.workspace_id !== scope.workspace || value.world_id !== scope.world || value.actor_id !== scope.actor
58
+ || value.request_key !== original || !['not_observed', 'pending', 'accepted', 'withdrawn'].includes(value.state)
59
+ || typeof value.withdrawn !== 'boolean' || value.state === 'withdrawn' && !value.withdrawn)
60
+ return false;
61
+ if (!('session' in value))
62
+ return value.withdrawn === true;
63
+ return value.state === 'accepted' ? !!value.session && worldSessionMatches(value.session, scope, { key: original, body })
64
+ : value.session === null && (value.state === 'withdrawn' || !value.withdrawn);
65
+ }
@@ -0,0 +1,67 @@
1
+ const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
2
+ const states = new Set(['publishing', 'queued', 'accepted', 'observed', 'not_dispatched', 'unknown', 'stop_requested']);
3
+ export function sessionStateCounter(value) {
4
+ if (typeof value !== 'string' || !/^(0|[1-9][0-9]{0,18})$/.test(value))
5
+ return null;
6
+ const parsed = BigInt(value);
7
+ return parsed <= 9223372036854775807n ? parsed : null;
8
+ }
9
+ function scopeMatches(value, scope) {
10
+ return value.workspace_id === scope.workspace && value.world_id === scope.world && value.session_id === scope.session;
11
+ }
12
+ export function sessionStateActionMatches(value, scope, kind, selected) {
13
+ if (!value || !scopeMatches(value, scope) || !uuid.test(value.id) || !uuid.test(value.actor_id)
14
+ || !/^[A-Za-z0-9._:-]{8,128}$/.test(value.request_key) || !states.has(value.state)
15
+ || sessionStateCounter(value.sequence) === null || value.sequence === '0'
16
+ || selected?.id && value.id !== selected.id || selected?.key && (value.request_key !== selected.key || value.actor_id !== scope.actor))
17
+ return false;
18
+ if (kind === 'capture') {
19
+ if (!('observation' in value) || value.scope !== 'session_sql' || value.reset_count !== null && sessionStateCounter(value.reset_count) === null)
20
+ return false;
21
+ const observed = value.observation;
22
+ return (!selected?.counter || value.reset_count === selected.counter) && (!observed || value.state === 'observed'
23
+ && uuid.test(observed.id) && Number.isSafeInteger(observed.collection_count) && observed.collection_count >= 0
24
+ && Number.isSafeInteger(observed.record_count) && observed.record_count >= 0);
25
+ }
26
+ if (!('expected_reset_count' in value) || value.expected_reset_count !== null && sessionStateCounter(value.expected_reset_count) === null
27
+ || selected?.counter && value.expected_reset_count !== selected.counter)
28
+ return false;
29
+ if (kind === 'reset') {
30
+ if (!('reset_at' in value) || value.reset_count !== null && sessionStateCounter(value.reset_count) === null)
31
+ return false;
32
+ return value.reset_at === null ? value.reset_count === null : value.state === 'observed' && value.reset_count !== null
33
+ && (value.expected_reset_count === null || sessionStateCounter(value.reset_count) === sessionStateCounter(value.expected_reset_count) + 1n);
34
+ }
35
+ return 'kind' in value && value.kind === kind && (!selected?.checkpoint || value.checkpoint_id === selected.checkpoint)
36
+ && (value.checkpoint_id === null || uuid.test(value.checkpoint_id))
37
+ && (kind === 'save' ? value.checkpoint_id === value.id && value.restored_at === null
38
+ && value.checkpoint_available !== null && (!value.checkpoint_available || value.captured && value.state === 'observed')
39
+ : value.checkpoint_available === null && !value.captured && (value.restored_at === null || value.state === 'observed'));
40
+ }
41
+ export function sessionStateRequestMatches(value, scope, key, kind, selected) {
42
+ return !!value && scopeMatches(value, scope) && value.actor_id === scope.actor && value.request_key === key
43
+ && (value.state === 'not_observed' ? value.request === null : value.state === 'observed' && !!value.request
44
+ && sessionStateActionMatches(value.request, scope, kind, { ...selected, key }));
45
+ }
46
+ export function sessionCapturesPageMatches(value, scope) {
47
+ return !!value && scopeMatches(value, scope) && value.results.every(row => sessionStateActionMatches(row, scope, 'capture'));
48
+ }
49
+ export function sessionResetsPageMatches(value, scope) {
50
+ return !!value && scopeMatches(value, scope) && value.results.every(row => sessionStateActionMatches(row, scope, 'reset'));
51
+ }
52
+ export function sessionCheckpointActionsPageMatches(value, scope, query = '') {
53
+ return !!value && scopeMatches(value, scope) && value.query === query.trim()
54
+ && value.results.every(row => sessionStateActionMatches(row, scope, row.kind));
55
+ }
56
+ export function worldCheckpointMatches(value, scope) {
57
+ return !!value && uuid.test(value.id) && value.workspace_id === scope.workspace && value.world_id === scope.world
58
+ && uuid.test(value.session_id) && uuid.test(value.source_id) && uuid.test(value.configuration_id) && uuid.test(value.actor_id)
59
+ && /^[A-Za-z0-9._:-]{8,128}$/.test(value.request_key) && ['pending', 'retained', 'unavailable'].includes(value.state)
60
+ && (value.record_count === null || Number.isSafeInteger(value.record_count) && value.record_count >= 0)
61
+ && (value.collection_count === null || Number.isSafeInteger(value.collection_count) && value.collection_count >= 0)
62
+ && (!value.available || value.state === 'retained' && value.scope !== null) && (!value.compatible || value.available);
63
+ }
64
+ export function sessionCheckpointsPageMatches(value, scope, query = '', checkpoint = null) {
65
+ return !!value && scopeMatches(value, scope) && value.query === query.trim() && value.checkpoint_filter === checkpoint
66
+ && value.results.every(row => worldCheckpointMatches(row, scope) && (!checkpoint || row.id === checkpoint));
67
+ }
@@ -0,0 +1,45 @@
1
+ import { sessionStateCounter } from './session-state-contracts.js';
2
+ const uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
3
+ const states = new Set(['publishing', 'queued', 'accepted', 'observed', 'not_dispatched', 'unknown', 'stop_requested']);
4
+ function scoped(value, scope) {
5
+ return value.workspace_id === scope.workspace && value.world_id === scope.world && value.session_id === scope.session;
6
+ }
7
+ export function manualVoiceTurnMatches(value, scope, selected) {
8
+ if (!value || !scoped(value, scope) || !uuid.test(value.id) || !uuid.test(value.actor_id) || !uuid.test(value.call_id)
9
+ || !/^[A-Za-z0-9._:-]{8,128}$/.test(value.request_key) || !states.has(value.state)
10
+ || !['voice_start', 'voice_audio', 'voice_listen', 'voice_stop'].includes(value.kind)
11
+ || sessionStateCounter(value.sequence) === null || value.sequence === '0'
12
+ || value.expected_reset_count !== null && sessionStateCounter(value.expected_reset_count) === null
13
+ || selected?.id && value.id !== selected.id || selected?.key && (value.request_key !== selected.key || value.actor_id !== scope.actor)
14
+ || value.kind === 'voice_start' && value.call_id !== value.id)
15
+ return false;
16
+ const input = selected?.input;
17
+ if (input && (value.kind !== input.kind || value.expected_reset_count !== input.expected_reset_count || value.record_audio !== input.record_audio
18
+ || value.call_id !== (input.kind === 'voice_start' ? value.id : input.call_id)))
19
+ return false;
20
+ const counts = [value.input_samples, value.received_samples, value.omitted_samples];
21
+ if (counts.some(one => one !== null && (!Number.isSafeInteger(one) || one < 0))
22
+ || value.input_samples !== null && value.input_samples > 48000 * 30
23
+ || value.audio_available !== !!value.audio || value.audio && value.state !== 'observed'
24
+ || value.input_audio_available && (value.kind !== 'voice_audio' || value.state !== 'observed' || !value.record_audio)
25
+ || value.audio_expires_at !== null && !value.audio_available)
26
+ return false;
27
+ const audio = value.audio;
28
+ return !audio || audio.sample_rate === 48000 && audio.channels === 1 && audio.sample_width === 2
29
+ && Number.isSafeInteger(audio.samples) && audio.samples > 0 && audio.samples <= 48000 * 30
30
+ && audio.size > 44 && audio.size <= 48000 * 30 * 2 + 44 && Number.isSafeInteger(audio.size)
31
+ && /^[a-f0-9]{64}$/.test(audio.sha256) && audio.duration_ms === Math.floor(audio.samples * 1000 / 48000)
32
+ && value.received_samples !== null && audio.samples <= value.received_samples && value.audio_recorded;
33
+ }
34
+ export function manualVoicePageMatches(value, scope, call = null) {
35
+ if (!value || !scoped(value, scope) || value.call_filter !== call
36
+ || !value.results.every(row => manualVoiceTurnMatches(row, scope) && (!call || row.call_id === call)))
37
+ return false;
38
+ return !value.call || uuid.test(value.call.id) && uuid.test(value.call.actor_id)
39
+ && value.call.owned === (value.call.actor_id === scope.actor) && ['opening', 'open', 'unknown'].includes(value.call.state);
40
+ }
41
+ export function manualVoiceRequestMatches(value, scope, key, input) {
42
+ return !!value && scoped(value, scope) && value.actor_id === scope.actor && value.request_key === key
43
+ && (value.state === 'not_observed' ? value.request === null : value.state === 'observed' && !!value.request
44
+ && manualVoiceTurnMatches(value.request, scope, { key, input }));
45
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ const sha = z.string().regex(/^[a-f0-9]{64}$/);
3
+ const root = z.object({ alias: z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), source_id: z.string().uuid(),
4
+ revision: z.string(), label: z.string(), directory: z.string() });
5
+ export const sourceSetSchema = z.object({ id: z.string().uuid(), workspace_id: z.string().uuid(), actor_id: z.string().uuid(),
6
+ agent_id: z.string().uuid(), request_key: z.string().uuid(), request_sha256: sha, source_id: z.string().uuid(), previous_source_id: z.string().uuid(),
7
+ state: z.enum(['queued', 'assembling', 'ready', 'failed', 'withdrawn']), source_set_sha256: sha, graph_sha256: sha,
8
+ roots: z.array(root).max(128), graph: z.record(z.string(), z.unknown()), created_at: z.string(), finished_at: z.string().nullable(),
9
+ failure: z.object({ code: z.string(), message: z.string() }).nullable() });
10
+ export const sourceOptionSchema = z.object({ id: z.string().uuid(), agent_id: z.string().uuid(), name: z.string(),
11
+ label: z.string(), revision: z.string(), kind: z.string(), root: z.string() });
12
+ export const sourceSetWithdrawalSchema = z.object({ state: z.literal('withdrawn'), request_key: z.string().uuid(),
13
+ request_sha256: sha, workspace_id: z.string().uuid(), agent_id: z.string().uuid(), actor_id: z.string().uuid() }).strict();
14
+ export function readSourceSetWithdrawal(value, workspace, agent, actor, key, digest) {
15
+ const parsed = sourceSetWithdrawalSchema.parse(value);
16
+ if (parsed.workspace_id !== workspace || parsed.agent_id !== agent || parsed.actor_id !== actor || parsed.request_key !== key
17
+ || digest !== undefined && parsed.request_sha256 !== digest)
18
+ throw new Error('The withdrawn source selection could not be confirmed.');
19
+ return parsed;
20
+ }
21
+ export function readSourceSet(value, workspace, agent, key) {
22
+ const parsed = sourceSetSchema.parse(value);
23
+ if (parsed.workspace_id !== workspace || parsed.agent_id !== agent || key && parsed.request_key !== key)
24
+ throw new Error('The source selection changed. Open its latest details.');
25
+ return parsed;
26
+ }
@@ -0,0 +1,22 @@
1
+ const uuid = (value) => typeof value === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(value);
2
+ const headerNames = ['Content-Type', 'x-goog-if-generation-match', 'x-goog-meta-firedrill-source-artifact', 'x-goog-meta-firedrill-source-upload'];
3
+ export function rawSourceUploadMatches(value, workspace, upload) {
4
+ try {
5
+ if (!value || !uuid(workspace) || !uuid(value.artifact_id) || !uuid(value.upload_id)
6
+ || upload !== undefined && value.upload_id !== upload || value.method !== 'PUT' || !value.headers
7
+ || Object.keys(value.headers).sort().join(',') !== headerNames.join(',')
8
+ || value.headers['Content-Type'] !== 'application/octet-stream' || value.headers['x-goog-if-generation-match'] !== '0'
9
+ || value.headers['x-goog-meta-firedrill-source-artifact'] !== value.artifact_id
10
+ || value.headers['x-goog-meta-firedrill-source-upload'] !== value.upload_id)
11
+ return false;
12
+ const target = new URL(value.upload_url), parts = target.pathname.split('/').slice(1).map(decodeURIComponent);
13
+ return target.origin === 'https://storage.googleapis.com' && !target.username && !target.password && !target.hash
14
+ && parts.length === 6 && !!parts[0] && parts[1] === 'private' && uuid(parts[2]) && parts[3] === workspace
15
+ && parts[4] === 'source' && uuid(parts[5])
16
+ && target.searchParams.getAll('X-Goog-SignedHeaders').length === 1
17
+ && target.searchParams.get('X-Goog-SignedHeaders') === ['content-type', 'host', ...headerNames.slice(1)].join(';');
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }