openpond 0.2.54 → 0.2.56

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 (432) hide show
  1. package/dist/app-server.d.ts +10823 -9118
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/actions-command-QU4H53OG.js +2 -0
  4. package/dist/chunks/{app-layer-I7MZYVLL.js → app-layer-NSTE5HIT.js} +1 -1
  5. package/dist/chunks/app-server-connected-apps-JHGWLBXT.js +2 -0
  6. package/dist/chunks/app-server-evaluations-GJPFWIDA.js +2 -0
  7. package/dist/chunks/app-server-harness-services-IH4G6POY.js +2 -0
  8. package/dist/chunks/app-server-runtime-DVKOZ5B6.js +2 -0
  9. package/dist/chunks/apps-BKTOR4F7.js +2 -0
  10. package/dist/chunks/chunk-25MBPJVY.js +2 -0
  11. package/dist/chunks/chunk-2D4Y3HNW.js +2 -0
  12. package/dist/chunks/chunk-2IHO4GDJ.js +2 -0
  13. package/dist/chunks/chunk-2QUCCP6Z.js +2 -0
  14. package/dist/chunks/chunk-3K4VVB7S.js +6 -0
  15. package/dist/chunks/chunk-3QIB5FXI.js +10 -0
  16. package/dist/chunks/chunk-3RCRSMWZ.js +17 -0
  17. package/dist/chunks/chunk-3VUATFZD.js +2 -0
  18. package/dist/chunks/chunk-3Z47M3YY.js +2 -0
  19. package/dist/chunks/{chunk-GXSTZBM6.js → chunk-4D7HWVWD.js} +1 -1
  20. package/dist/chunks/chunk-4EPSHPZL.js +2 -0
  21. package/dist/chunks/chunk-4NESNOK5.js +2 -0
  22. package/dist/chunks/chunk-523TE4BI.js +2 -0
  23. package/dist/chunks/chunk-5MCNZCVQ.js +2 -0
  24. package/dist/chunks/chunk-6QSSIT62.js +2 -0
  25. package/dist/chunks/chunk-6ZFPQYHG.js +2 -0
  26. package/dist/chunks/chunk-74IIXVAE.js +2 -0
  27. package/dist/chunks/chunk-74ZXXBGN.js +6 -0
  28. package/dist/chunks/chunk-773TH7FN.js +2 -0
  29. package/dist/chunks/chunk-7E6T7GP5.js +2 -0
  30. package/dist/chunks/chunk-7ED24PP6.js +2 -0
  31. package/dist/chunks/chunk-7HPDGZOR.js +86 -0
  32. package/dist/chunks/chunk-7KWD2I6W.js +2 -0
  33. package/dist/chunks/chunk-7PXZ4X4P.js +2 -0
  34. package/dist/chunks/chunk-A6USMRWK.js +2 -0
  35. package/dist/chunks/chunk-ABD5M2D2.js +2 -0
  36. package/dist/chunks/chunk-ACYFMLWG.js +10 -0
  37. package/dist/chunks/chunk-AN525SPP.js +6 -0
  38. package/dist/chunks/chunk-APB2STJK.js +2 -0
  39. package/dist/chunks/chunk-AY64VY4E.js +2 -0
  40. package/dist/chunks/{chunk-UJ5EFSEC.js → chunk-B7RFL4N2.js} +1 -1
  41. package/dist/chunks/chunk-BFKYRQMA.js +2 -0
  42. package/dist/chunks/chunk-BLXEAZCQ.js +12 -0
  43. package/dist/chunks/chunk-D74JEERO.js +5 -0
  44. package/dist/chunks/{chunk-PA7XP42P.js → chunk-DARVPBZ4.js} +1 -1
  45. package/dist/chunks/chunk-DBK66CJP.js +8 -0
  46. package/dist/chunks/chunk-DDMZSZFL.js +1 -0
  47. package/dist/chunks/chunk-DIO5CB6U.js +2 -0
  48. package/dist/chunks/chunk-DMFUEUAZ.js +5 -0
  49. package/dist/chunks/chunk-DMVD2RFZ.js +2 -0
  50. package/dist/chunks/chunk-DUURYZOI.js +2 -0
  51. package/dist/chunks/chunk-DZUAT3TP.js +1 -0
  52. package/dist/chunks/chunk-EIEZHFIW.js +6 -0
  53. package/dist/chunks/chunk-EIRYMSEG.js +19 -0
  54. package/dist/chunks/{chunk-JDLAHVAJ.js → chunk-EKM2D7JU.js} +1 -1
  55. package/dist/chunks/chunk-EQFGBL3O.js +2 -0
  56. package/dist/chunks/chunk-EYPCBBMS.js +2 -0
  57. package/dist/chunks/chunk-F4KOGISR.js +10 -0
  58. package/dist/chunks/chunk-F74GBN6K.js +2 -0
  59. package/dist/chunks/chunk-FEAKTSRS.js +2 -0
  60. package/dist/chunks/chunk-FFRFSDBM.js +2 -0
  61. package/dist/chunks/chunk-FTEOCCPB.js +23 -0
  62. package/dist/chunks/chunk-FUOEIDMA.js +8 -0
  63. package/dist/chunks/{chunk-AH22RHPS.js → chunk-FV2R5RUN.js} +2 -2
  64. package/dist/chunks/chunk-FWIPHEVA.js +12 -0
  65. package/dist/chunks/chunk-FY5KHLMW.js +2 -0
  66. package/dist/chunks/chunk-G3RXYI2L.js +6 -0
  67. package/dist/chunks/chunk-GJ2ZJFDD.js +2 -0
  68. package/dist/chunks/chunk-GLDYJM7O.js +1 -0
  69. package/dist/chunks/chunk-GPVCOEUH.js +2 -0
  70. package/dist/chunks/chunk-GW766ZSO.js +5 -0
  71. package/dist/chunks/chunk-GWCHDF2C.js +4 -0
  72. package/dist/chunks/chunk-GZ7M5XBP.js +2 -0
  73. package/dist/chunks/chunk-H6IW2R22.js +140 -0
  74. package/dist/chunks/chunk-HCYX6RHP.js +2 -0
  75. package/dist/chunks/chunk-HDL5YSAA.js +2 -0
  76. package/dist/chunks/chunk-HIOKCIL7.js +2 -0
  77. package/dist/chunks/chunk-HY3GOBFJ.js +58 -0
  78. package/dist/chunks/chunk-HZEIRHEB.js +2 -0
  79. package/dist/chunks/chunk-I2NXNMRZ.js +2 -0
  80. package/dist/chunks/chunk-I7AQMAQI.js +33 -0
  81. package/dist/chunks/chunk-IZ6DLEVY.js +2 -0
  82. package/dist/chunks/chunk-J2TWKFML.js +1871 -0
  83. package/dist/chunks/chunk-JDEEWOD7.js +2 -0
  84. package/dist/chunks/chunk-JFXWI3EN.js +6 -0
  85. package/dist/chunks/chunk-JYKRR7E5.js +5 -0
  86. package/dist/chunks/chunk-KCJVFLBB.js +2 -0
  87. package/dist/chunks/{chunk-5CMKGD43.js → chunk-KG325WTN.js} +1 -1
  88. package/dist/chunks/chunk-KGNCKIFP.js +3 -0
  89. package/dist/chunks/chunk-KUERKVEU.js +3 -0
  90. package/dist/chunks/chunk-KVTBX2UP.js +2 -0
  91. package/dist/chunks/chunk-L6K7ERG5.js +2 -0
  92. package/dist/chunks/{chunk-N5QNXMIS.js → chunk-LQQNBVEB.js} +1 -1
  93. package/dist/chunks/{chunk-YJ4PNAST.js → chunk-M4JWQSV7.js} +1 -1
  94. package/dist/chunks/chunk-MQULU465.js +2 -0
  95. package/dist/chunks/chunk-N4FFQPLR.js +2 -0
  96. package/dist/chunks/chunk-N73MU2C3.js +2 -0
  97. package/dist/chunks/chunk-NHQ36THU.js +3 -0
  98. package/dist/chunks/{chunk-4SHKI3BH.js → chunk-O6ULLQJ6.js} +1 -1
  99. package/dist/chunks/chunk-O72BSKSO.js +2 -0
  100. package/dist/chunks/chunk-OGDADQGH.js +143 -0
  101. package/dist/chunks/chunk-OIUTWU6K.js +2 -0
  102. package/dist/chunks/chunk-OLLLZVHF.js +2 -0
  103. package/dist/chunks/{chunk-XM26DGML.js → chunk-OPNRWESL.js} +1 -1
  104. package/dist/chunks/chunk-OQKJGTTO.js +4 -0
  105. package/dist/chunks/chunk-OQPJ7FJF.js +9 -0
  106. package/dist/chunks/{chunk-R3XFY7VL.js → chunk-OS3LO5J3.js} +1 -1
  107. package/dist/chunks/{chunk-T5LE6R5S.js → chunk-OSIO7PLX.js} +1 -1
  108. package/dist/chunks/chunk-OUVIWDL2.js +2 -0
  109. package/dist/chunks/chunk-PCSIOUHF.js +7 -0
  110. package/dist/chunks/chunk-PF5R6CMP.js +21 -0
  111. package/dist/chunks/chunk-PPAPVGJP.js +3 -0
  112. package/dist/chunks/chunk-PRGBLQVH.js +2 -0
  113. package/dist/chunks/chunk-PSGGOZFM.js +2 -0
  114. package/dist/chunks/chunk-PUZQU66L.js +2 -0
  115. package/dist/chunks/{chunk-WITSXYEW.js → chunk-Q2QL6UWN.js} +1 -1
  116. package/dist/chunks/chunk-Q4TBTRIG.js +2 -0
  117. package/dist/chunks/chunk-Q5LEXXJG.js +16 -0
  118. package/dist/chunks/{chunk-YL6VFJ4P.js → chunk-QDC4OW3S.js} +1 -1
  119. package/dist/chunks/chunk-QEFHOJFE.js +7 -0
  120. package/dist/chunks/chunk-QHWGQ3A4.js +5 -0
  121. package/dist/chunks/chunk-QIKWJ2AA.js +11 -0
  122. package/dist/chunks/chunk-QNG27G3T.js +6 -0
  123. package/dist/chunks/chunk-QOGJAQDO.js +3 -0
  124. package/dist/chunks/chunk-QOTVNQDI.js +4 -0
  125. package/dist/chunks/{chunk-N3DEA6PG.js → chunk-RAXOSUSW.js} +1 -1
  126. package/dist/chunks/chunk-RNIAFXMB.js +50 -0
  127. package/dist/chunks/chunk-S5ESN275.js +42 -0
  128. package/dist/chunks/chunk-SDAUS5PY.js +2 -0
  129. package/dist/chunks/chunk-SDXFLO7J.js +5 -0
  130. package/dist/chunks/chunk-SH5CBAFC.js +2 -0
  131. package/dist/chunks/chunk-SWUEFLOH.js +2 -0
  132. package/dist/chunks/chunk-SYUKES6H.js +3 -0
  133. package/dist/chunks/chunk-T5AACNJI.js +2 -0
  134. package/dist/chunks/chunk-TRQQNFMO.js +4 -0
  135. package/dist/chunks/chunk-TVQAPBLZ.js +2 -0
  136. package/dist/chunks/chunk-UCPGRPWY.js +2 -0
  137. package/dist/chunks/chunk-UGL7WF3W.js +2 -0
  138. package/dist/chunks/chunk-UHFZHBGW.js +2 -0
  139. package/dist/chunks/chunk-UKMA4R6X.js +6 -0
  140. package/dist/chunks/{chunk-7ZG3IT7C.js → chunk-VRIEKBBH.js} +6 -6
  141. package/dist/chunks/chunk-VYLGI3IH.js +13 -0
  142. package/dist/chunks/chunk-W45RKGM6.js +1 -0
  143. package/dist/chunks/chunk-WJ43MJ3F.js +2 -0
  144. package/dist/chunks/chunk-WMKYHXVM.js +3 -0
  145. package/dist/chunks/chunk-WN3V6KDN.js +3 -0
  146. package/dist/chunks/chunk-X4OSOOSU.js +3 -0
  147. package/dist/chunks/chunk-XDQMGUWL.js +2 -0
  148. package/dist/chunks/chunk-XTFPDQMH.js +3 -0
  149. package/dist/chunks/chunk-XVDFJ3ZF.js +2 -0
  150. package/dist/chunks/chunk-XW6HGSIT.js +8 -0
  151. package/dist/chunks/chunk-XXYGGNVM.js +2 -0
  152. package/dist/chunks/chunk-Y4OWBBDD.js +184 -0
  153. package/dist/chunks/chunk-YBT2NB32.js +2 -0
  154. package/dist/chunks/chunk-YCJO3YVD.js +10 -0
  155. package/dist/chunks/{chunk-YD55Z5H3.js → chunk-YOBN7KTF.js} +11 -11
  156. package/dist/chunks/chunk-YOQRYNLP.js +2 -0
  157. package/dist/chunks/chunk-YR5ID2SS.js +2 -0
  158. package/dist/chunks/chunk-YY7LEQGP.js +2 -0
  159. package/dist/chunks/chunk-Z4Z5UOZM.js +22 -0
  160. package/dist/chunks/chunk-Z54O534A.js +3 -0
  161. package/dist/chunks/chunk-ZCHXGRRU.js +2 -0
  162. package/dist/chunks/chunk-ZFSHBFG5.js +40 -0
  163. package/dist/chunks/chunk-ZGTOK7ZK.js +12 -0
  164. package/dist/chunks/{chunk-NAZ26IZL.js → chunk-ZRDGQDZL.js} +1 -1
  165. package/dist/chunks/chunk-ZUJ3XUCP.js +2 -0
  166. package/dist/chunks/chunk-ZZWAQBA2.js +2 -0
  167. package/dist/chunks/cli-X25RSO2X.js +2 -0
  168. package/dist/chunks/configuration-command-6C5UO7GE.js +2 -0
  169. package/dist/chunks/connected-app-executor-IVLGQP65.js +2 -0
  170. package/dist/chunks/connected-evidence-GH2ATNEX.js +2 -0
  171. package/dist/chunks/connection-HTF6CC7M.js +2 -0
  172. package/dist/chunks/{continual-PKK2BOTB.js → continual-6CQAMTTR.js} +3 -3
  173. package/dist/chunks/core-commands-A2DGGIPS.js +2 -0
  174. package/dist/chunks/datasets-7BNMVJOY.js +2 -0
  175. package/dist/chunks/desktop-test-3CUHVLXV.js +3 -0
  176. package/dist/chunks/dist-OMGUJYPD.js +2 -0
  177. package/dist/chunks/{chunk-6VF3Q6QJ.js → dist-SKYG5LZO.js} +2 -4
  178. package/dist/chunks/dist-VYC5VMQB.js +2 -0
  179. package/dist/chunks/dist-ZVJPJLXR.js +2 -0
  180. package/dist/chunks/enclave-QS4BUNDU.js +2 -0
  181. package/dist/chunks/evaluation-coordination-XEF5L7KZ.js +2 -0
  182. package/dist/chunks/experiment-improvements-KRX2DP27.js +2 -0
  183. package/dist/chunks/experiments-DFGQYA4O.js +2 -0
  184. package/dist/chunks/experiments-VFQGE4HC.js +2 -0
  185. package/dist/chunks/extension-XKXXOP5N.js +4 -0
  186. package/dist/chunks/{help-WLKSACLZ.js → help-S7THC6IE.js} +1 -1
  187. package/dist/chunks/host-profile-evaluation-tools-JJQWJUBT.js +2 -0
  188. package/dist/chunks/host-profile-external-dataset-K3ICDHIP.js +2 -0
  189. package/dist/chunks/hosted-app-server-composition-BCOO5ANF.js +2 -0
  190. package/dist/chunks/hosted-experiment-improvement-NFSVS5TU.js +3 -0
  191. package/dist/chunks/hosted-harness-runtime-723S5ZSH.js +2 -0
  192. package/dist/chunks/hosted-profile-candidate-2S5LFUWD.js +3 -0
  193. package/dist/chunks/hosted-profile-compiler-2DQIFSXW.js +2 -0
  194. package/dist/chunks/hosted-profile-evaluation-control-76BTRTYD.js +2 -0
  195. package/dist/chunks/hosted-profile-evaluation-inspection-V6Z3A5XJ.js +3 -0
  196. package/dist/chunks/hosted-profile-evaluation-preparation-IDJYREW3.js +3 -0
  197. package/dist/chunks/hosted-tasksets-ANAE2PIW.js +2 -0
  198. package/dist/chunks/human-review-WR777ODH.js +2 -0
  199. package/dist/chunks/import-MLZUHITH.js +4 -0
  200. package/dist/chunks/javascript-isolate-process-source-ZPQKKLR4.js +2 -0
  201. package/dist/chunks/javascript-verifier-worker-source-F3LSGPOY.js +2 -0
  202. package/dist/chunks/learning-ACEVFL5M.js +2 -0
  203. package/dist/chunks/local-harness-improvement-runtime-JIQ6ZVDW.js +2 -0
  204. package/dist/chunks/local-harness-taskset-review-XVYTGAGK.js +2 -0
  205. package/dist/chunks/local-scope-HVF2GZ5W.js +2 -0
  206. package/dist/chunks/model-projects-QPO22JPA.js +2 -0
  207. package/dist/chunks/opchat-T4QTNEIY.js +3 -0
  208. package/dist/chunks/organizations-75L5DZDV.js +2 -0
  209. package/dist/chunks/profile-TFZMUEDR.js +3 -0
  210. package/dist/chunks/profile-training-source-6GOT7AHM.js +2 -0
  211. package/dist/chunks/project-action-payload-7VGL7OER.js +2 -0
  212. package/dist/chunks/project-agent-6RRO233B.js +2 -0
  213. package/dist/chunks/published-experiment-source-DZFENAQA.js +2 -0
  214. package/dist/chunks/refiner-profile-service-UUIWFJVT.js +2 -0
  215. package/dist/chunks/runtime-A7OZXM43.js +6 -0
  216. package/dist/chunks/sandbox-command-IU5XFTJP.js +2 -0
  217. package/dist/chunks/{sandbox-template-BBGGPJMI.js → sandbox-template-C4V6T36U.js} +1 -1
  218. package/dist/chunks/saved-work-6BMBFP43.js +2 -0
  219. package/dist/chunks/send-turn-XTAIS2JN.js +2 -0
  220. package/dist/chunks/sql-execution-process-source-B4HQM6ZV.js +2 -0
  221. package/dist/chunks/src-CJM6HY5Y.js +326 -0
  222. package/dist/chunks/{src-CR6UZYTX.js → src-LMC3K6LH.js} +1 -1
  223. package/dist/chunks/standalone-experiment-turn-owner-JCY5LL5R.js +2 -0
  224. package/dist/chunks/store-chat-workflows-S72HZXQR.js +18 -0
  225. package/dist/chunks/store-continual-support-reviews-HHA6NX7K.js +7 -0
  226. package/dist/chunks/store-conversation-serving-KPC62UEY.js +2 -0
  227. package/dist/chunks/store-create-improve-QV54XIZW.js +40 -0
  228. package/dist/chunks/store-datasets-RXJ33SUN.js +86 -0
  229. package/dist/chunks/store-evaluation-results-3F3P527G.js +7 -0
  230. package/dist/chunks/store-harness-evaluation-review-settings-I2R3HPO3.js +29 -0
  231. package/dist/chunks/store-harness-memory-VINCZ4GK.js +17 -0
  232. package/dist/chunks/store-harness-refinement-candidates-EA5KFQPH.js +21 -0
  233. package/dist/chunks/store-harness-workspaces-XUM4Z66X.js +2 -0
  234. package/dist/chunks/store-human-review-RAH7WMIP.js +7 -0
  235. package/dist/chunks/store-learned-preference-migration-validation-4CI2IRUF.js +2 -0
  236. package/dist/chunks/store-learning-WLG6KFIO.js +2 -0
  237. package/dist/chunks/store-learning-credentials-WZQJ4HPJ.js +2 -0
  238. package/dist/chunks/store-local-experiments-5LUJR7GI.js +97 -0
  239. package/dist/chunks/store-model-batch-review-YEGX327M.js +2 -0
  240. package/dist/chunks/store-model-configuration-5ZURQATB.js +3 -0
  241. package/dist/chunks/store-preference-comparison-LV32MHVL.js +6 -0
  242. package/dist/chunks/store-schedules-VGTEQVKH.js +53 -0
  243. package/dist/chunks/store-sidebar-file-bookmarks-VB5GTLFY.js +18 -0
  244. package/dist/chunks/store-sidebar-preferences-GWIOG2NH.js +16 -0
  245. package/dist/chunks/store-subagents-T7R2Z6TB.js +67 -0
  246. package/dist/chunks/store-task-inbox-JJTBW76C.js +33 -0
  247. package/dist/chunks/store-task-inventory-OB3F2APC.js +10 -0
  248. package/dist/chunks/store-taskset-drafts-EKQWWFYQ.js +9 -0
  249. package/dist/chunks/store-training-G6YLFSIR.js +70 -0
  250. package/dist/chunks/store-training-jobs-RC46YBF6.js +19 -0
  251. package/dist/chunks/store-training-models-6BA43IPP.js +49 -0
  252. package/dist/chunks/store-usage-IE2U2FD3.js +63 -0
  253. package/dist/chunks/store-work-evidence-QQDKM5AQ.js +8 -0
  254. package/dist/chunks/taskset-EQRFQBYM.js +2 -0
  255. package/dist/chunks/taskset-packages-XC6HEE3K.js +2 -0
  256. package/dist/chunks/{teams-bot-7I4BAUVO.js → teams-bot-EAPGPTHZ.js} +1 -1
  257. package/dist/chunks/training-UF6RPI4T.js +2 -0
  258. package/dist/chunks/web-search-CZ3NCLPY.js +2 -0
  259. package/dist/chunks/workspaces-EKKE5NAC.js +2 -0
  260. package/dist/cli.js +1 -1
  261. package/dist/index.js +1 -1
  262. package/dist/web/assets/App-CaRMZoxo.css +1 -0
  263. package/dist/web/assets/App-s-CJswyt.js +154 -0
  264. package/dist/web/assets/{AppDialog-BdusXgU0.js → AppDialog-t2Fx5tK3.js} +1 -1
  265. package/dist/web/assets/{AppTerminalPanel-C4uRpnBz.js → AppTerminalPanel-Dj1Y32oI.js} +2 -2
  266. package/dist/web/assets/AppsView-BYE5EBDJ.js +1 -0
  267. package/dist/web/assets/{BrowserSidebar-Bl7V6YO2.js → BrowserSidebar-jhWi4rVm.js} +1 -1
  268. package/dist/web/assets/{CartesianChart-BstFbsdn.js → CartesianChart-C1DIx0Ia.js} +1 -1
  269. package/dist/web/assets/{CollaborationTabs-B8YAf0c1.js → CollaborationTabs-Bdr-HmOL.js} +1 -1
  270. package/dist/web/assets/{CommandMenu-DZct7zUJ.js → CommandMenu-Ux2yOHAc.js} +1 -1
  271. package/dist/web/assets/{CommunityView-CR0-W-uG.js → CommunityView-DPEeVKFn.js} +1 -1
  272. package/dist/web/assets/{ComposerCreateImproveStrip-DR-Qo7b4.js → ComposerCreateImproveStrip-CEgh4OtN.js} +1 -1
  273. package/dist/web/assets/{GetStartedView-xqQoMMei.js → GetStartedView-CFHP0AaI.js} +1 -1
  274. package/dist/web/assets/HostedModelLearningReview-D8BGTPVN.js +1 -0
  275. package/dist/web/assets/{HostedModelLearningSettings-De3i9wF4.js → HostedModelLearningSettings-JS1S7vNO.js} +1 -1
  276. package/dist/web/assets/{LabModelVersionDetailPage-DAY1MmqP.js → LabModelVersionDetailPage-Dx5Q3xV2.js} +1 -1
  277. package/dist/web/assets/{LabSkillSidebar-DLnIgnry.js → LabSkillSidebar-BxffN-pN.js} +1 -1
  278. package/dist/web/assets/LabsRoute-CyYF8-dw.js +99 -0
  279. package/dist/web/assets/MainChatThread-DZpcFRFl.js +2 -0
  280. package/dist/web/assets/MainPane-5DTtwVCk.js +65 -0
  281. package/dist/web/assets/MainPane-BIM_UJ3q.css +1 -0
  282. package/dist/web/assets/{MarkdownText-gJMuefaJ.js → MarkdownText-BR4V6lNO.js} +24 -24
  283. package/dist/web/assets/{NativeSkillSidebar-Dlxb8iOC.js → NativeSkillSidebar-DU9IEgIO.js} +1 -1
  284. package/dist/web/assets/{NewExperienceSwitcher-DM-cqJ-K.js → NewExperienceSwitcher-mIy6FzCj.js} +1 -1
  285. package/dist/web/assets/{NewProjectDialog-Cu1q75gq.js → NewProjectDialog-RfTZTHxl.js} +1 -1
  286. package/dist/web/assets/{OutputsPage-DiXMkasl.js → OutputsPage-Cr1Spf7S.js} +1 -1
  287. package/dist/web/assets/{ProjectsPage-DqiBHiCB.js → ProjectsPage-CE6QUB-b.js} +1 -1
  288. package/dist/web/assets/RightChatPanelStack-T6VRWuHo.js +1 -0
  289. package/dist/web/assets/RightSidebarHomePanel-CK0rP3WT.js +1 -0
  290. package/dist/web/assets/ScheduledWorkPage-vOrYv8pp.js +1 -0
  291. package/dist/web/assets/SettingsView-DCKVrfjj.js +5 -0
  292. package/dist/web/assets/SettingsView-Dulr_xlq.css +1 -0
  293. package/dist/web/assets/{TeamChatView-DM0adMtj.js → TeamChatView-Bwrjr-vk.js} +2 -2
  294. package/dist/web/assets/{TerminalOverlay-CFlH51DD.js → TerminalOverlay-DhPoKZAq.js} +1 -1
  295. package/dist/web/assets/TrainingCreationPanel-BXHfohNm.js +1 -0
  296. package/dist/web/assets/{TrainingDraftPanel-Bbo3RRie.js → TrainingDraftPanel-C9cRX5qf.js} +1 -1
  297. package/dist/web/assets/{UsageSettingsSection-CSRjJUSa.js → UsageSettingsSection-CrdcSGeW.js} +1 -1
  298. package/dist/web/assets/{WorkSidebarPanel-DwlEMEoG.js → WorkSidebarPanel-DSSikNFQ.js} +1 -1
  299. package/dist/web/assets/WorkspaceDiffPanel-BAFo0CPN.js +14 -0
  300. package/dist/web/assets/WorkspaceEnvironmentMenu-BVHAhwnJ.js +63 -0
  301. package/dist/web/assets/WorkspaceGitDialogs-CwVoiDQ2.js +1 -0
  302. package/dist/web/assets/{WorkspaceMonacoEditor-BR4qxMgU.js → WorkspaceMonacoEditor-TxLyhzNp.js} +3 -3
  303. package/dist/web/assets/arrow-up-right-C9aE8Mfz.js +1 -0
  304. package/dist/web/assets/chunk-P3BRSSRD-DUGfuKA8.js +1 -0
  305. package/dist/web/assets/{clipboard-BZzZ82Bk.js → clipboard-Dk158Qp4.js} +1 -1
  306. package/dist/web/assets/{cloud-upload-CJPYPVl8.js → cloud-upload-k9eqBsHr.js} +1 -1
  307. package/dist/web/assets/{cssMode-WC4Rg1l-.js → cssMode-CO35ARZp.js} +1 -1
  308. package/dist/web/assets/{folder-open-sLZJxLQy.js → folder-open-sYgceW_f.js} +1 -1
  309. package/dist/web/assets/folder-plus-CS0R49m9.js +1 -0
  310. package/dist/web/assets/{git-commit-horizontal-Cotm7KEC.js → git-commit-horizontal-DrGxH2h4.js} +1 -1
  311. package/dist/web/assets/{htmlMode-C6oZGeaB.js → htmlMode-REMmzdfq.js} +1 -1
  312. package/dist/web/assets/index-3iPNbbER.css +1 -0
  313. package/dist/web/assets/{index-BxWTVKtn.js → index-C8aCGagb.js} +2 -2
  314. package/dist/web/assets/info-DLdbiUrh.js +1 -0
  315. package/dist/web/assets/{jsonMode-BET4LQIn.js → jsonMode-KEdMfkIf.js} +1 -1
  316. package/dist/web/assets/{lspLanguageFeatures-BPxA_-Kg.js → lspLanguageFeatures-5KZwEoxW.js} +1 -1
  317. package/dist/web/assets/minimize-2-CqcI4zcM.js +1 -0
  318. package/dist/web/assets/{monaco.contribution-DFzEyaHi.js → monaco.contribution-BJGj65F9.js} +2 -2
  319. package/dist/web/assets/{monaco.contribution-DXzyQfVi.js → monaco.contribution-Cly9Wt7L.js} +2 -2
  320. package/dist/web/assets/{monaco.contribution-BH6kkO4b.js → monaco.contribution-DO10L0zW.js} +2 -2
  321. package/dist/web/assets/{monaco.contribution-7AUuf2NS.js → monaco.contribution-omszXBEj.js} +2 -2
  322. package/dist/web/assets/monitor-BFVCcbxp.js +1 -0
  323. package/dist/web/assets/play-C469pVZq.js +1 -0
  324. package/dist/web/assets/{python-PzBkTjWx.js → python-Dw0YcVy9.js} +1 -1
  325. package/dist/web/assets/{save-DpezrtH2.js → save-CtSjPydi.js} +1 -1
  326. package/dist/web/assets/square-BuImvLhT.js +1 -0
  327. package/dist/web/assets/{toggleHighContrast-Cto-fOXm.js → toggleHighContrast-DjCO9lIP.js} +1 -1
  328. package/dist/web/assets/{tsMode-BYA4LNc6.js → tsMode-BAOnxKd6.js} +1 -1
  329. package/dist/web/assets/{upload-C5YFNgtS.js → upload-2JkFZo3h.js} +1 -1
  330. package/dist/web/assets/{useLocalAgentSchedules-CnyTsqlf.js → useLocalAgentSchedules-BNqAisfS.js} +1 -1
  331. package/dist/web/assets/useProviderSettings-C4L4wDoh.js +5 -0
  332. package/dist/web/assets/{useProviderSettings-Bw-csWbH.css → useProviderSettings-CmL_BaxP.css} +1 -1
  333. package/dist/web/assets/{useSessionTurnCache-DICuJSJW.js → useSessionTurnCache-BHU2-Jmz.js} +1 -1
  334. package/dist/web/assets/{wifi-off-nzHj7JXp.js → wifi-off-CpOAH62M.js} +1 -1
  335. package/dist/web/assets/{workers-Dboaw6f_.js → workers-0QvlA2T5.js} +1 -1
  336. package/dist/web/assets/{yaml-uuY5JmO8.js → yaml-BK3qxo7D.js} +1 -1
  337. package/dist/web/index.html +2 -2
  338. package/package.json +3 -3
  339. package/dist/chunks/actions-command-DSO6YOEE.js +0 -2
  340. package/dist/chunks/app-server-runtime-7AXV6JZI.js +0 -2
  341. package/dist/chunks/apps-TM74FFQB.js +0 -2
  342. package/dist/chunks/chunk-2JO2KWT3.js +0 -5
  343. package/dist/chunks/chunk-2SPZYBDN.js +0 -16
  344. package/dist/chunks/chunk-37DXASQL.js +0 -191
  345. package/dist/chunks/chunk-4EEH7MEC.js +0 -2
  346. package/dist/chunks/chunk-4TZHH5FC.js +0 -2409
  347. package/dist/chunks/chunk-5TNDPNS3.js +0 -2
  348. package/dist/chunks/chunk-6JAN4RMN.js +0 -42
  349. package/dist/chunks/chunk-7QEE4PBI.js +0 -8
  350. package/dist/chunks/chunk-BX4J2VDU.js +0 -2
  351. package/dist/chunks/chunk-DALJMSJG.js +0 -33
  352. package/dist/chunks/chunk-EMKZVP7Z.js +0 -2
  353. package/dist/chunks/chunk-FPUUZQUP.js +0 -6
  354. package/dist/chunks/chunk-GCOUYYHG.js +0 -5
  355. package/dist/chunks/chunk-GS2NKNKG.js +0 -4
  356. package/dist/chunks/chunk-H2VT22JK.js +0 -2
  357. package/dist/chunks/chunk-HA7EFTPF.js +0 -23
  358. package/dist/chunks/chunk-IKWDL3RB.js +0 -17
  359. package/dist/chunks/chunk-NHFGEVVH.js +0 -518
  360. package/dist/chunks/chunk-NNF6KCHD.js +0 -3
  361. package/dist/chunks/chunk-PJM2G7SG.js +0 -21
  362. package/dist/chunks/chunk-PQHTZ5CP.js +0 -2
  363. package/dist/chunks/chunk-PYABBF53.js +0 -53
  364. package/dist/chunks/chunk-QRWPEW3Z.js +0 -24
  365. package/dist/chunks/chunk-QXVIIM4T.js +0 -2
  366. package/dist/chunks/chunk-SDEDAHV6.js +0 -160
  367. package/dist/chunks/chunk-TGIB24K4.js +0 -22
  368. package/dist/chunks/chunk-UE3DMPGM.js +0 -3
  369. package/dist/chunks/chunk-USKE34VR.js +0 -9
  370. package/dist/chunks/chunk-USMZT5FZ.js +0 -18
  371. package/dist/chunks/chunk-WV2APYWG.js +0 -2
  372. package/dist/chunks/chunk-YIB3J4RC.js +0 -2
  373. package/dist/chunks/chunk-Z3D4C7BG.js +0 -12
  374. package/dist/chunks/cli-JVB345H2.js +0 -2
  375. package/dist/chunks/configuration-command-MATM4XR5.js +0 -2
  376. package/dist/chunks/connected-evidence-YDPGNHLP.js +0 -2
  377. package/dist/chunks/core-commands-MTV4EKXY.js +0 -2
  378. package/dist/chunks/datasets-CP3IT47T.js +0 -2
  379. package/dist/chunks/desktop-test-IAZC5MAH.js +0 -3
  380. package/dist/chunks/dist-4HV2W6V4.js +0 -2
  381. package/dist/chunks/dist-SAABJU5F.js +0 -2
  382. package/dist/chunks/evaluation-coordination-EPHLZXYM.js +0 -2
  383. package/dist/chunks/experiment-improvements-6JTOPA74.js +0 -2
  384. package/dist/chunks/experiments-XHPFGECH.js +0 -2
  385. package/dist/chunks/extension-GX7DLW2X.js +0 -4
  386. package/dist/chunks/hosted-experiment-improvement-HAB3UE6A.js +0 -3
  387. package/dist/chunks/hosted-harness-runtime-YM23QNDK.js +0 -2
  388. package/dist/chunks/hosted-profile-candidate-EOBGKQAS.js +0 -3
  389. package/dist/chunks/hosted-profile-compiler-SCVJI2CP.js +0 -2
  390. package/dist/chunks/hosted-profile-evaluation-control-RJ6XJZCS.js +0 -2
  391. package/dist/chunks/hosted-profile-evaluation-inspection-OC4XNGL2.js +0 -3
  392. package/dist/chunks/hosted-profile-evaluation-preparation-ZD4FM3FD.js +0 -3
  393. package/dist/chunks/human-review-AAVMISBF.js +0 -2
  394. package/dist/chunks/import-V3HUGRHR.js +0 -4
  395. package/dist/chunks/learning-FNBEIAY6.js +0 -2
  396. package/dist/chunks/opchat-QK43DXTY.js +0 -3
  397. package/dist/chunks/organizations-SRPAWKC7.js +0 -2
  398. package/dist/chunks/profile-C6CQNVYE.js +0 -3
  399. package/dist/chunks/project-agent-GZV5HNYI.js +0 -2
  400. package/dist/chunks/sandbox-command-4TJXQTKT.js +0 -2
  401. package/dist/chunks/src-NE6R4XC6.js +0 -329
  402. package/dist/chunks/taskset-LUG3ZU6J.js +0 -2
  403. package/dist/chunks/training-XHE6FVII.js +0 -2
  404. package/dist/chunks/workspaces-MFZ3OO6O.js +0 -2
  405. package/dist/web/assets/App-CO2F717V.css +0 -1
  406. package/dist/web/assets/App-CuhaCsfb.js +0 -235
  407. package/dist/web/assets/AppsView-BS1czXUP.js +0 -1
  408. package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +0 -1
  409. package/dist/web/assets/LabsRoute-CXJRJMhr.js +0 -99
  410. package/dist/web/assets/MainChatThread-BwAla81W.js +0 -2
  411. package/dist/web/assets/MainPane-CakOBCHw.js +0 -19
  412. package/dist/web/assets/MainPane-DOWsSew1.css +0 -1
  413. package/dist/web/assets/RightChatPanelStack-VaOOmxwd.js +0 -1
  414. package/dist/web/assets/RightSidebarHomePanel-CeSFJM5s.js +0 -1
  415. package/dist/web/assets/ScheduledWorkPage-D1jRQxFs.js +0 -1
  416. package/dist/web/assets/SettingsView-BnANbPLS.css +0 -1
  417. package/dist/web/assets/SettingsView-RA9OXgcu.js +0 -5
  418. package/dist/web/assets/TrainingCreationPanel-CgIBVGha.js +0 -1
  419. package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +0 -14
  420. package/dist/web/assets/WorkspaceEnvironmentMenu-Byjngd9V.js +0 -32
  421. package/dist/web/assets/WorkspaceGitDialogs-Dgmg-6XG.js +0 -1
  422. package/dist/web/assets/arrow-up-right-H0pvnH2s.js +0 -1
  423. package/dist/web/assets/chunk-UHVJOMWN-BqXRe639.js +0 -1
  424. package/dist/web/assets/folder-plus-C84wrpt_.js +0 -1
  425. package/dist/web/assets/index-dSmk3FLJ.css +0 -1
  426. package/dist/web/assets/info-Dc81lEfw.js +0 -1
  427. package/dist/web/assets/minimize-2-Bs7MVN3C.js +0 -1
  428. package/dist/web/assets/monitor-DXL019Wf.js +0 -1
  429. package/dist/web/assets/play-CXkxUZeU.js +0 -1
  430. package/dist/web/assets/square-oy7f5Ce6.js +0 -1
  431. package/dist/web/assets/useProviderSettings-B_KeQjE5.js +0 -5
  432. /package/dist/chunks/{chunk-OGPHXXCD.js → chunk-BT5YNE5U.js} +0 -0
@@ -0,0 +1,97 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as y,c as M}from"./chunk-XVDFJ3ZF.js";import{a as N,b as E,c as v,d as m,e as w,f as D,g as P,h as x,i as j}from"./chunk-GWCHDF2C.js";import{a as s}from"./chunk-EQFGBL3O.js";import"./chunk-GZ7M5XBP.js";import"./chunk-F74GBN6K.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{bb as f,eb as h,hb as O,ib as F}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as W}from"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import{la as L}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import{h as R}from"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{m as d}from"./chunk-KGNCKIFP.js";import{b as I}from"./chunk-ES2ISFJC.js";import{a as u}from"./chunk-FTQLQJQV.js";function J(c,e){let t=c.all(`SELECT e.id,e.payload,
3
+ COALESCE(json_extract(c.payload,'$.configuration.request.name'),json_extract(d.payload,'$.configuration.request.name')) AS name,
4
+ count(*) OVER () AS total FROM local_experiment_executions e
5
+ LEFT JOIN local_experiment_configurations c ON c.team_id=e.team_id AND c.execution_id=e.id
6
+ JOIN local_experiment_definitions d ON d.team_id=e.team_id AND d.id=e.definition_id AND d.revision=e.definition_revision
7
+ WHERE e.team_id=? AND json_extract(e.payload,'$.ownerActorId')=?
8
+ AND json_extract(e.payload,'$.status') IN ('queued','running','cancelling')
9
+ ${e.projectId?"AND COALESCE(json_extract(c.payload,'$.configuration.request.project.id'),json_extract(d.payload,'$.configuration.request.project.id'))=?":""}
10
+ ORDER BY json_extract(e.payload,'$.updatedAt') DESC,e.id DESC LIMIT ?`,[e.teamId,e.actorId,...e.projectId?[e.projectId]:[],e.limit]);return{count:Number(t[0]?.total??0),items:t.map(i=>{let n=JSON.parse(i.payload);return{kind:"experiment",location:"local",id:i.id,name:i.name??"Experiment",phase:n.status,updatedAt:n.updatedAt??n.startedAt??n.createdAt}})}}u(J,"readLocalExecutionActivity");var Y=`
11
+ CREATE TABLE IF NOT EXISTS local_experiment_owner (
12
+ singleton INTEGER PRIMARY KEY CHECK(singleton=1), owner_id TEXT NOT NULL,
13
+ pid INTEGER NOT NULL, lease_until INTEGER NOT NULL
14
+ );
15
+ CREATE TABLE IF NOT EXISTS local_experiment_definitions (
16
+ team_id TEXT NOT NULL, id TEXT NOT NULL, revision INTEGER NOT NULL,
17
+ content_hash TEXT NOT NULL, project_id TEXT, payload TEXT NOT NULL, package_payload TEXT NOT NULL,
18
+ PRIMARY KEY (team_id,id,revision)
19
+ );
20
+ CREATE TABLE IF NOT EXISTS local_experiment_operations (
21
+ team_id TEXT NOT NULL, operation_id TEXT NOT NULL, kind TEXT NOT NULL,
22
+ intent_hash TEXT NOT NULL, receipt TEXT NOT NULL, PRIMARY KEY (team_id,operation_id)
23
+ );
24
+ CREATE TABLE IF NOT EXISTS local_experiment_executions (
25
+ team_id TEXT NOT NULL, id TEXT NOT NULL, definition_id TEXT NOT NULL, definition_revision INTEGER NOT NULL,
26
+ owner_id TEXT NOT NULL, payload TEXT NOT NULL, PRIMARY KEY (team_id,id)
27
+ );
28
+ CREATE TABLE IF NOT EXISTS local_experiment_cases (
29
+ team_id TEXT NOT NULL, execution_id TEXT NOT NULL, receipt_id TEXT NOT NULL, ordinal INTEGER NOT NULL,
30
+ status TEXT NOT NULL, admission TEXT NOT NULL, result TEXT, error TEXT,
31
+ PRIMARY KEY (team_id,execution_id,receipt_id), UNIQUE (team_id,execution_id,ordinal),
32
+ FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
33
+ );
34
+ CREATE TABLE IF NOT EXISTS local_experiment_configurations (
35
+ team_id TEXT NOT NULL, execution_id TEXT NOT NULL, payload TEXT NOT NULL, package_payload TEXT NOT NULL,
36
+ PRIMARY KEY(team_id,execution_id),
37
+ FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
38
+ );
39
+ CREATE TABLE IF NOT EXISTS local_experiment_charges (
40
+ team_id TEXT NOT NULL, execution_id TEXT NOT NULL, request_id TEXT NOT NULL, case_id TEXT NOT NULL,
41
+ maximum_usd REAL NOT NULL CHECK(maximum_usd >= 0), cost_usd REAL CHECK(cost_usd >= 0),
42
+ status TEXT NOT NULL, usage TEXT,
43
+ PRIMARY KEY(team_id,execution_id,request_id),
44
+ FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
45
+ );
46
+ CREATE TABLE IF NOT EXISTS local_experiment_scoring_selections (
47
+ team_id TEXT NOT NULL, execution_id TEXT NOT NULL, source_execution_id TEXT NOT NULL,
48
+ package_payload TEXT NOT NULL, graders TEXT NOT NULL,
49
+ PRIMARY KEY(team_id,execution_id),
50
+ FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
51
+ );
52
+ CREATE TABLE IF NOT EXISTS local_experiment_judge_budgets (
53
+ team_id TEXT NOT NULL, execution_id TEXT NOT NULL, calls TEXT NOT NULL,
54
+ PRIMARY KEY(team_id,execution_id),
55
+ FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
56
+ );
57
+ CREATE TABLE IF NOT EXISTS local_experiment_events (
58
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT, team_id TEXT NOT NULL, execution_id TEXT NOT NULL,
59
+ case_id TEXT NOT NULL, type TEXT NOT NULL, payload TEXT NOT NULL,
60
+ FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
61
+ );
62
+ CREATE TABLE IF NOT EXISTS local_experiment_trace_budgets (
63
+ team_id TEXT NOT NULL, execution_id TEXT NOT NULL, event_count INTEGER NOT NULL, byte_count INTEGER NOT NULL,
64
+ PRIMARY KEY(team_id,execution_id), FOREIGN KEY (team_id,execution_id) REFERENCES local_experiment_executions(team_id,id)
65
+ );
66
+ CREATE INDEX IF NOT EXISTS local_experiment_case_events ON local_experiment_events(team_id,execution_id,case_id,sequence);
67
+ CREATE INDEX IF NOT EXISTS local_experiment_definition_project ON local_experiment_definitions(team_id,project_id,id);
68
+ CREATE INDEX IF NOT EXISTS local_experiment_execution_definition ON local_experiment_executions(team_id,definition_id,id);
69
+ `;import{randomUUID as ne}from"node:crypto";var C=I.string().regex(/^[a-f0-9]{64}$/),H=I.object({scopeHash:C,action:I.string().trim().min(1).max(100),intentHash:C}).strict(),B=["advanced-refiner-start","experiment-evaluation-schedule"],$=`CREATE TABLE IF NOT EXISTS evaluation_operation_intents (
70
+ scope_hash TEXT NOT NULL,action TEXT NOT NULL,intent_hash TEXT NOT NULL,
71
+ operation_id TEXT NOT NULL,created_at TEXT NOT NULL,acknowledged_at TEXT,
72
+ PRIMARY KEY(scope_hash,action,intent_hash)
73
+ );
74
+ CREATE TABLE IF NOT EXISTS evaluation_operation_reviewed_payloads (
75
+ scope_hash TEXT NOT NULL,action TEXT NOT NULL,intent_hash TEXT NOT NULL,
76
+ operation_id TEXT NOT NULL,payload TEXT NOT NULL,command TEXT,phase TEXT NOT NULL,
77
+ PRIMARY KEY(scope_hash,action,intent_hash)
78
+ );
79
+ CREATE TABLE IF NOT EXISTS evaluation_operation_acknowledged_history (
80
+ scope_hash TEXT NOT NULL,action TEXT NOT NULL,intent_hash TEXT NOT NULL,
81
+ operation_id TEXT PRIMARY KEY,created_at TEXT NOT NULL,acknowledged_at TEXT NOT NULL,
82
+ payload TEXT,command TEXT,phase TEXT
83
+ );`;function U(c,e){let t=[e.scopeHash,e.action,e.intentHash,e.id];return c.get("SELECT i.operation_id,i.created_at,i.acknowledged_at,p.payload,p.command,p.phase FROM evaluation_operation_intents i LEFT JOIN evaluation_operation_reviewed_payloads p USING(scope_hash,action,intent_hash,operation_id) WHERE i.scope_hash=? AND i.action=? AND i.intent_hash=? AND i.operation_id=?",t)??c.get("SELECT operation_id,created_at,acknowledged_at,payload,command,phase FROM evaluation_operation_acknowledged_history WHERE scope_hash=? AND action=? AND intent_hash=? AND operation_id=?",t)}u(U,"retainedRow");function G(c,e,t){c.run("INSERT OR IGNORE INTO evaluation_operation_acknowledged_history(scope_hash,action,intent_hash,operation_id,created_at,acknowledged_at,payload,command,phase) SELECT i.scope_hash,i.action,i.intent_hash,i.operation_id,i.created_at,i.acknowledged_at,p.payload,p.command,p.phase FROM evaluation_operation_intents i LEFT JOIN evaluation_operation_reviewed_payloads p USING(scope_hash,action,intent_hash,operation_id) WHERE i.scope_hash=? AND i.action=? AND i.intent_hash=? AND i.operation_id=? AND i.acknowledged_at IS NOT NULL",[e.scopeHash,e.action,e.intentHash,t])}u(G,"archiveAcknowledged");function K(c){let e=JSON.stringify(c);if(e===void 0||Buffer.byteLength(e,"utf8")>1048576)throw new Error("Reviewed operation payload exceeds 1 MiB.");return e}u(K,"bounded");function k(c){if(!B.some(e=>e===c))throw new Error("This action does not admit recoverable reviewed payloads.")}u(k,"retainable");function V(c,e){let t=H.parse({scopeHash:e.scopeHash,action:e.action,intentHash:e.intentHash}),i;if(e.reviewedIntent!==void 0){if(k(t.action),d(e.reviewedIntent)!==t.intentHash)throw new Error("Reviewed intent changed its exact hash.");i=K(e.reviewedIntent)}let n=c.get("SELECT operation_id,created_at,acknowledged_at FROM evaluation_operation_intents WHERE scope_hash=? AND action=? AND intent_hash=?",[t.scopeHash,t.action,t.intentHash]);if((!n||n.acknowledged_at)&&B.some(r=>r===t.action)&&c.get("SELECT i.operation_id FROM evaluation_operation_intents i LEFT JOIN evaluation_operation_reviewed_payloads p USING(scope_hash,action,intent_hash,operation_id) WHERE i.scope_hash=? AND i.action=? AND i.acknowledged_at IS NULL AND (p.phase='dispatching' OR p.payload IS NULL) LIMIT 1",[t.scopeHash,t.action]))throw new Error("Recover the original uncertain operation before preparing another reviewed intent.");let a=n&&!n.acknowledged_at?n.operation_id:ne(),o=n&&!n.acknowledged_at?n.created_at:new Date().toISOString();if((!n||n.acknowledged_at)&&(n?.acknowledged_at&&G(c,t,n.operation_id),c.run("INSERT INTO evaluation_operation_intents(scope_hash,action,intent_hash,operation_id,created_at) VALUES(?,?,?,?,?) ON CONFLICT(scope_hash,action,intent_hash) DO UPDATE SET operation_id=excluded.operation_id,created_at=excluded.created_at,acknowledged_at=NULL",[t.scopeHash,t.action,t.intentHash,a,o]),c.run("DELETE FROM evaluation_operation_reviewed_payloads WHERE scope_hash=? AND action=? AND intent_hash=?",[t.scopeHash,t.action,t.intentHash])),i!==void 0){let r=c.get("SELECT operation_id,payload FROM evaluation_operation_reviewed_payloads WHERE scope_hash=? AND action=? AND intent_hash=?",[t.scopeHash,t.action,t.intentHash]);if(r&&(r.operation_id!==a||d(JSON.parse(r.payload))!==t.intentHash))throw new Error("The retained reviewed payload belongs to another exact operation.");r||c.run("INSERT INTO evaluation_operation_reviewed_payloads(scope_hash,action,intent_hash,operation_id,payload,phase) VALUES(?,?,?,?,?,'reviewed')",[t.scopeHash,t.action,t.intentHash,a,i])}return{id:a,createdAt:o}}u(V,"prepareEvaluationOperation");function b(c,e){k(e.action);let t=H.parse({scopeHash:e.scopeHash,action:e.action,intentHash:e.intentHash}),i=K(e.command),n=U(c,{...t,id:e.id});if(!n?.payload||d(JSON.parse(n.payload))!==t.intentHash)throw new Error("The reviewed command requires its exact retained operation.");if(n.command&&d(JSON.parse(n.command))!==d(e.command))throw new Error("The reviewed command is immutable.");if(Buffer.byteLength(n.payload,"utf8")+Buffer.byteLength(i,"utf8")>1048576)throw new Error("Reviewed intent and command exceed 1 MiB.");let a=n.phase==="dispatching"?"dispatching":e.phase;if(n.acknowledged_at){if(!n.command||n.phase!=="dispatching")throw new Error("The original reviewed command was discarded before dispatch.");return{retained:!0,phase:n.phase??a}}return c.run("UPDATE evaluation_operation_reviewed_payloads SET command=?,phase=? WHERE scope_hash=? AND action=? AND intent_hash=? AND operation_id=?",[i,a,t.scopeHash,t.action,t.intentHash,e.id]),{retained:!0,phase:a}}u(b,"retainEvaluationOperation");function Q(c,e){k(e.action);let t=C.parse(e.scopeHash),i=I.number().int().min(1).max(100).parse(e.limit??100),n=c.all("SELECT i.operation_id,i.intent_hash,i.created_at,p.payload,p.command,p.phase FROM evaluation_operation_intents i LEFT JOIN evaluation_operation_reviewed_payloads p USING(scope_hash,action,intent_hash,operation_id) WHERE i.scope_hash=? AND i.action=? AND i.acknowledged_at IS NULL AND i.operation_id>? ORDER BY i.operation_id LIMIT ?",[t,e.action,e.cursor??"",i]);return{items:n.map(a=>({id:a.operation_id,action:e.action,intentHash:a.intent_hash,createdAt:a.created_at,reviewedIntent:a.payload?JSON.parse(a.payload):null,command:a.command?JSON.parse(a.command):null,phase:a.phase,recoveryReady:!!(a.payload&&a.command)})),nextCursor:n.length===i?n.at(-1).operation_id:null}}u(Q,"pendingEvaluationOperations");function z(c,e){let t=U(c,e);if(!t?.payload||!t.phase)throw new Error("The original reviewed operation payload is unavailable; recover its actual canonical receipt.");let i=JSON.parse(t.payload);if(d(i)!==e.intentHash)throw new Error("Retained reviewed intent hash changed.");return{reviewedIntent:i,command:t.command?JSON.parse(t.command):null,phase:t.phase}}u(z,"readPendingEvaluationOperation");function Z(c,e){let t=H.parse({scopeHash:e.scopeHash,action:e.action,intentHash:e.intentHash}),i=U(c,{...t,id:e.id});if(!i)throw new Error("This acknowledgement does not own the retained operation intent.");if(e.expectedPhase&&i.phase!==e.expectedPhase)throw new Error("The reviewed command crossed dispatch; recover its canonical receipt before acknowledgement.");return i.acknowledged_at?{acknowledged:!0}:(c.run("UPDATE evaluation_operation_intents SET acknowledged_at=COALESCE(acknowledged_at,?) WHERE scope_hash=? AND action=? AND intent_hash=? AND operation_id=?",[new Date().toISOString(),t.scopeHash,t.action,t.intentHash,e.id]),G(c,t,e.id),{acknowledged:!0})}u(Z,"acknowledgeEvaluationOperation");function q(c,e){if(e.kind!=="target")throw new s("local_experiment_not_found","This id names a scoring pass, not an Experiment.",404);let t=c.get("SELECT payload,package_payload FROM local_experiment_configurations WHERE team_id=? AND execution_id=?",[e.teamId,e.id]);if(t){let p=O.parse(JSON.parse(t.payload)),T=L(JSON.parse(t.package_payload));if(p.packageHash!==T.contentHash||p.packageHash!==e.packageHash)throw new s("local_package_pin_conflict","The retained Experiment package differs from its admission.");return{snapshot:p,package:T}}let i=N(c,e.teamId,e.definition.id,e.definition.revision),n=i.definition,a=L(i.package),{contentHash:o,...r}=n;if(d(r)!==o)throw new s("local_configuration_pin_conflict","The retained configuration bytes differ from their sealed hash.");if(n.contentHash!==e.definition.contentHash||n.ownerActorId!==e.ownerActorId||n.teamId!==e.teamId||n.packageHash!==e.packageHash||a.contentHash!==e.packageHash)throw new s("local_configuration_pin_conflict","The retained Experiment configuration differs from its owner or immutable admission.");let _=n.configuration,g={configuration:{operationId:e.operationId,request:{..._.request,operationId:e.operationId},maximumCostUsd:_.maximumCostUsd,..._.graders?{graders:_.graders}:{}},model:n.model,packageHash:n.packageHash,graders:n.graders,availableGraders:n.availableGraders,retainedConfigurationHash:n.contentHash},l=O.parse({...g,configurationHash:d(g)});return X(c,e,l,a),{snapshot:l,package:a}}u(q,"localFlatSnapshot");function X(c,e,t,i){c.run("INSERT INTO local_experiment_configurations(team_id,execution_id,payload,package_payload) VALUES(?,?,?,?)",[e.teamId,e.id,JSON.stringify(t),JSON.stringify(i)])}u(X,"writeLocalFlatSnapshot");function S(c,e,t){let i=E(c,e,t),{snapshot:n}=q(c,i),{definition:a,...o}=i;return F.parse({...o,...n})}u(S,"localFlatRecord");var ee=class extends W{static{u(this,"SqliteLocalExperimentStore")}localTablesReady=!1;async localWrite(e){await this.ready;let t=this.writeQueue.then(()=>{let i=this.database;this.localTablesReady||(i.exec(Y),i.exec($),this.localTablesReady=!0),i.exec("BEGIN IMMEDIATE");try{let n=e(i);return i.exec("COMMIT"),n}catch(n){throw i.exec("ROLLBACK"),n}});return this.writeQueue=t.then(()=>{},()=>{}),t}async prepareEvaluationOperation(e){return this.localWrite(t=>V(t,e))}async retainEvaluationOperation(e){return this.localWrite(t=>b(t,e))}async readPendingEvaluationOperation(e){return this.localWrite(t=>z(t,e))}async pendingEvaluationOperations(e){return this.localWrite(t=>Q(t,e))}async acknowledgeEvaluationOperation(e){return this.localWrite(t=>Z(t,e))}async claimLocalExperimentOwner(e,t=process.pid){return this.localWrite(i=>P(i,e,t))}async renewLocalExperimentOwner(e){return this.localWrite(t=>j(t,e))}async releaseLocalExperimentOwner(e){return this.localWrite(t=>t.run("DELETE FROM local_experiment_owner WHERE singleton=1 AND owner_id=?",[e]))}async saveLocalExperiment(e){let t=f.parse(e.definition);return this.localWrite(i=>w(i,t.teamId,e.operationId,"save",e.intentHash,()=>{let n=i.get("SELECT MAX(revision) AS revision FROM local_experiment_definitions WHERE team_id=? AND id=?",[t.teamId,t.id]);if(n?.revision&&N(i,t.teamId,t.id).definition.ownerActorId!==t.ownerActorId)throw new s("local_resource_denied","This local resource belongs to another account.",404);if((n?.revision??0)!==e.expectedRevision||t.revision!==e.expectedRevision+1)throw new s("local_definition_revision_conflict","The Experiment changed. Reload its saved revision before editing.");return D(i,t,e.package),t}))}async readLocalExperiment(e,t,i){return this.localWrite(n=>N(n,e,t,i))}async recoverLocalExperimentOperation(e,t,i,n){return this.localWrite(a=>{let o=a.get("SELECT kind,intent_hash,receipt FROM local_experiment_operations WHERE team_id=? AND operation_id=?",[e,t]);if(!o)return null;if(o.kind!==i||o.intent_hash!==n)throw new s("local_operation_conflict","This operation already owns different immutable inputs.");return JSON.parse(o.receipt)})}async listLocalExperiments(e){return this.localWrite(t=>{let i=t.all(`SELECT d.payload FROM local_experiment_definitions d WHERE d.team_id=? AND json_extract(d.payload,'$.ownerActorId')=?
84
+ AND d.revision=(SELECT MAX(revision) FROM local_experiment_definitions v WHERE v.team_id=d.team_id AND v.id=d.id)
85
+ ${e.projectId?"AND d.project_id=?":""} ${e.afterId?"AND d.id>?":""} ORDER BY d.id LIMIT ?`,[e.teamId,e.ownerActorId,...e.projectId?[e.projectId]:[],...e.afterId?[e.afterId]:[],e.limit+1]),n=i.slice(0,e.limit).map(a=>f.parse(JSON.parse(a.payload)));return{items:n,nextCursor:i.length>e.limit?n.at(-1).id:null}})}async listLocalExecutionHistory(e){return this.localWrite(t=>{let i=t.all(`SELECT e.payload AS execution,d.payload AS definition,e.id FROM local_experiment_executions e
86
+ JOIN local_experiment_definitions d ON d.team_id=e.team_id AND d.id=e.definition_id AND d.revision=e.definition_revision
87
+ WHERE e.team_id=? AND json_extract(e.payload,'$.ownerActorId')=?
88
+ ${e.projectId?"AND d.project_id=?":""} ${e.afterId?"AND e.id>?":""} ORDER BY e.id LIMIT ?`,[e.teamId,e.ownerActorId,...e.projectId?[e.projectId]:[],...e.afterId?[e.afterId]:[],e.limit+1]),n=i.slice(0,e.limit).map(a=>({execution:h.parse(JSON.parse(a.execution)),definition:f.parse(JSON.parse(a.definition))}));return{items:n,nextCursor:i.length>e.limit?n.at(-1).execution.id:null}})}async startLocalExperiment(e){return this.localWrite(t=>w(t,e.execution.teamId,e.operationId,"start",e.intentHash,()=>{x(t,e.ownerId);let i=h.parse(e.execution),n=i.definition,a=N(t,i.teamId,n.id,n.revision).definition;if(a.ownerActorId!==i.ownerActorId)throw new s("local_resource_denied","This local resource belongs to another account.",404);if(a.contentHash!==n.contentHash||a.packageHash!==i.packageHash||a.configuration.maximumCostUsd!==i.maximumCostUsd)throw new s("local_definition_pin_conflict","Execution requires its exact retained definition and package.");if(!e.admissions.length||e.admissions.length!==i.counts.pending||new Set(e.admissions.map(o=>o.receiptId)).size!==e.admissions.length)throw new s("local_population_conflict","Execution admissions must cover the exact unique population.");return t.run("INSERT INTO local_experiment_executions(team_id,id,definition_id,definition_revision,owner_id,payload) VALUES(?,?,?,?,?,?)",[i.teamId,i.id,n.id,n.revision,e.ownerId,JSON.stringify(i)]),e.admissions.forEach((o,r)=>t.run("INSERT INTO local_experiment_cases(team_id,execution_id,receipt_id,ordinal,status,admission) VALUES(?,?,?,?,?,?)",[i.teamId,i.id,o.receiptId,r,"pending",JSON.stringify(o)])),i}))}async admitLocalExperimentRun(e){let t=y(),i=u(n=>w(n,e.execution.teamId,e.execution.operationId,"run",e.intentHash,()=>{x(n,e.ownerId);let a=h.parse(e.execution),o=f.parse(e.definition),r=O.parse(e.snapshot),_=a.definition,g=L(e.package),{contentHash:l,...p}=o,{sourceExperimentId:T,...te}=r.configuration;if(a.kind!=="target"||o.ownerActorId!==a.ownerActorId||o.teamId!==a.teamId||d(p)!==l||d({...te,expectedRevision:0})!==d(o.configuration)||o.id!==_.id||o.revision!==_.revision||o.contentHash!==_.contentHash||g.contentHash!==r.packageHash||r.packageHash!==a.packageHash||r.configuration.maximumCostUsd!==a.maximumCostUsd||r.configuration.operationId!==a.operationId||r.configuration.request.teamId!==a.teamId||d(r.model)!==d(o.model)||d(r.graders)!==d(o.graders))throw new s("local_configuration_pin_conflict","The local run requires its exact sealed configuration and owner.");if(!e.admissions.length||e.admissions.length!==a.counts.pending||new Set(e.admissions.map(A=>A.receiptId)).size!==e.admissions.length)throw new s("local_population_conflict","The run admissions must cover the exact unique population.");return D(n,o,e.package),n.run("INSERT INTO local_experiment_executions(team_id,id,definition_id,definition_revision,owner_id,payload) VALUES(?,?,?,?,?,?)",[a.teamId,a.id,_.id,_.revision,e.ownerId,JSON.stringify(a)]),X(n,a,r,e.package),e.admissions.forEach((A,ie)=>n.run("INSERT INTO local_experiment_cases(team_id,execution_id,receipt_id,ordinal,status,admission) VALUES(?,?,?,?,?,?)",[a.teamId,a.id,A.receiptId,ie,"pending",JSON.stringify(A)])),S(n,a.teamId,a.id)}),"apply");return this.localWrite(n=>{let a=n.get("SELECT receipt FROM local_experiment_operations WHERE team_id=? AND operation_id=? AND kind='run'",[e.execution.teamId,e.execution.operationId]);return t&&!a?t.withAdmission(()=>i(n)):i(n)})}async findLocalExperimentRunOperation(e,t){return this.localWrite(i=>{let n=i.get("SELECT receipt FROM local_experiment_operations WHERE team_id=? AND operation_id=? AND kind='run'",[e,t]);if(!n)return null;let a=JSON.parse(n.receipt);return S(i,e,a.id)})}async readLocalExperimentRecord(e,t){return this.localWrite(i=>S(i,e,t))}async readLocalExperimentSnapshot(e,t){return this.localWrite(i=>q(i,E(i,e,t)))}async readExecutionActivity(e){if(!e.actorId.trim()||!e.teamId.trim())throw new s("local_activity_scope_missing","Activity requires a signed-in workspace owner.",403);return this.localWrite(t=>J(t,{...e,limit:Math.min(100,Math.max(1,e.limit??100))}))}async listLocalExperimentRecords(e){return this.localWrite(t=>{let i=t.all(`SELECT e.id FROM local_experiment_executions e
89
+ LEFT JOIN local_experiment_configurations c ON c.team_id=e.team_id AND c.execution_id=e.id
90
+ JOIN local_experiment_definitions d ON d.team_id=e.team_id AND d.id=e.definition_id AND d.revision=e.definition_revision
91
+ WHERE e.team_id=? AND json_extract(e.payload,'$.ownerActorId')=? AND json_extract(e.payload,'$.kind')='target'
92
+ ${e.projectId?"AND COALESCE(json_extract(c.payload,'$.configuration.request.project.id'),json_extract(d.payload,'$.configuration.request.project.id'))=?":""}
93
+ ${e.status?"AND json_extract(e.payload,'$.status')=?":""}
94
+ ${e.datasetHash?"AND COALESCE(json_extract(c.payload,'$.configuration.request.taskset.contentHash'),json_extract(d.payload,'$.configuration.request.taskset.contentHash'))=?":""}
95
+ ${e.search?"AND instr(lower(COALESCE(json_extract(c.payload,'$.configuration.request.name'),json_extract(d.payload,'$.configuration.request.name'))),lower(?))>0":""}
96
+ ${e.afterId?"AND e.id>?":""} ORDER BY e.id LIMIT ?`,[e.teamId,e.ownerActorId,...e.projectId?[e.projectId]:[],...e.status?[e.status]:[],...e.datasetHash?[e.datasetHash]:[],...e.search?[e.search]:[],...e.afterId?[e.afterId]:[],e.limit+1]),n=i.slice(0,e.limit).map(a=>S(t,e.teamId,a.id));return{items:n,nextCursor:i.length>e.limit?n.at(-1).id:null}})}async readLocalExecution(e,t){return this.localWrite(i=>({execution:E(i,e,t),cases:v(i,e,t)}))}async readLocalExecutionCharges(e,t){return this.localWrite(i=>(E(i,e,t),i.all("SELECT request_id,case_id,status,cost_usd,usage FROM local_experiment_charges WHERE team_id=? AND execution_id=? ORDER BY request_id",[e,t]).map(n=>({requestId:n.request_id,caseId:n.case_id,status:n.status,costUsd:n.cost_usd,usage:n.usage?JSON.parse(n.usage):null}))))}async appendLocalExperimentEvent(e){return this.localWrite(t=>{this.requireLocalOwner(t,e.teamId,e.id,e.ownerId);let i=JSON.stringify(e.payload),n=Buffer.byteLength(i),a=t.get("SELECT event_count,byte_count FROM local_experiment_trace_budgets WHERE team_id=? AND execution_id=?",[e.teamId,e.id]);if(n>2097152||(a?.event_count??0)>=2e4||(a?.byte_count??0)+n>67108864)throw new s("local_trace_limit_exceeded","The execution exceeded its bounded retained trace budget.",422);if(!t.get("SELECT receipt_id FROM local_experiment_cases WHERE team_id=? AND execution_id=? AND receipt_id=?",[e.teamId,e.id,e.caseId]))throw new s("local_trace_case_conflict","Trace evidence must belong to an admitted case.");t.run("INSERT INTO local_experiment_events(team_id,execution_id,case_id,type,payload) VALUES(?,?,?,?,?)",[e.teamId,e.id,e.caseId,e.type,i]),t.run("INSERT INTO local_experiment_trace_budgets(team_id,execution_id,event_count,byte_count) VALUES(?,?,1,?) ON CONFLICT(team_id,execution_id) DO UPDATE SET event_count=event_count+1,byte_count=byte_count+excluded.byte_count",[e.teamId,e.id,n])})}async localExperimentTrace(e){return this.localWrite(t=>{if(E(t,e.teamId,e.id),!t.get("SELECT receipt_id FROM local_experiment_cases WHERE team_id=? AND execution_id=? AND receipt_id=?",[e.teamId,e.id,e.caseId]))throw new s("local_case_not_found","This retained case does not belong to the execution.",404);let n=t.all("SELECT sequence,type,payload FROM local_experiment_events WHERE team_id=? AND execution_id=? AND case_id=? AND sequence>? ORDER BY sequence LIMIT ?",[e.teamId,e.id,e.caseId,e.afterSequence??0,e.limit+1]),a=n.slice(0,e.limit).map(o=>({sequence:o.sequence,type:o.type,payload:JSON.parse(o.payload)}));return{items:a,nextCursor:n.length>e.limit?a.at(-1).sequence:null}})}async startLocalScoringPass(e){return this.localWrite(t=>w(t,e.execution.teamId,e.operationId,"score",e.intentHash,()=>{x(t,e.ownerId);let i=h.parse(e.execution),n=i.sourceExecution;if(i.kind!=="scoring"||!n)throw new s("local_scoring_source_missing","A scoring pass requires an exact original execution.");let a=E(t,i.teamId,n.id);if(a.ownerActorId!==i.ownerActorId)throw new s("local_resource_denied","This local resource belongs to another account.",404);if(a.executionHash!==n.executionHash||a.kind!=="target"||!a.completedAt||!a.cleanupComplete)throw new s("local_scoring_source_unavailable","Retained grading requires a terminal original execution with confirmed cleanup.");if(i.packageHash!==a.packageHash||d(i.definition)!==d(a.definition))throw new s("local_scoring_pin_conflict","The scoring pass changed original execution pins.");let o=v(t,i.teamId,a.id);if(d(e.admissions)!==d(o.map(r=>r.admission)))throw new s("local_scoring_population_conflict","A scoring pass must cover the complete retained original population.");return t.run("INSERT INTO local_experiment_executions(team_id,id,definition_id,definition_revision,owner_id,payload) VALUES(?,?,?,?,?,?)",[i.teamId,i.id,i.definition.id,i.definition.revision,e.ownerId,JSON.stringify(i)]),t.run("INSERT INTO local_experiment_scoring_selections(team_id,execution_id,source_execution_id,package_payload,graders) VALUES(?,?,?,?,?)",[i.teamId,i.id,a.id,JSON.stringify(e.package),JSON.stringify(e.graders)]),e.admissions.forEach((r,_)=>t.run("INSERT INTO local_experiment_cases(team_id,execution_id,receipt_id,ordinal,status,admission) VALUES(?,?,?,?,?,?)",[i.teamId,i.id,r.receiptId,_,"pending",JSON.stringify(r)])),i}))}async readLocalScoringSelection(e,t){return this.localWrite(i=>{E(i,e,t);let n=i.get("SELECT package_payload,graders,source_execution_id FROM local_experiment_scoring_selections WHERE team_id=? AND execution_id=?",[e,t]);if(!n)throw new s("local_scoring_not_found","This execution is not a scoring pass.",404);return{package:JSON.parse(n.package_payload),graders:JSON.parse(n.graders),sourceExecutionId:n.source_execution_id}})}async localJudgeBudgetTransaction(e,t){return this.localWrite(i=>{this.requireLocalOwner(i,e.teamId,e.id,e.ownerId);let n=E(i,e.teamId,e.id);if(e.intent==="dispatch"){this.requireLocalChargeBounds(i,e.teamId,e.id);let l=i.get("SELECT status FROM local_experiment_cases WHERE team_id=? AND execution_id=? AND receipt_id=?",[e.teamId,e.id,e.caseId]);if(n.status!=="running"||l?.status!=="running")throw new s("local_grading_owner_inactive","Only an admitted running grader may reserve a judge call.")}let a=i.get("SELECT calls FROM local_experiment_judge_budgets WHERE team_id=? AND execution_id=?",[e.teamId,e.id]),o=a?R.array().parse(JSON.parse(a.calls)):[],r=i.get(`SELECT COALESCE(SUM(CASE WHEN status='settled' THEN cost_usd WHEN status IN ('reserved','dispatched','unknown') THEN maximum_usd ELSE 0 END),0) AS spent
97
+ FROM local_experiment_charges WHERE team_id=? AND execution_id=? AND request_id NOT IN (SELECT json_extract(value,'$.id') FROM json_each(?))`,[e.teamId,e.id,JSON.stringify(o)]).spent,_=t({maximumSpendUsd:Math.max(0,n.maximumCostUsd-r),calls:o}),g=R.array().parse(_.calls);for(let l of o){let p=g.find(T=>T.id===l.id);if(!p||p.requestHash!==l.requestHash||p.reservedUsd!==l.reservedUsd||l.status!=="reserved"&&d(l)!==d(p))throw new s("local_judge_receipt_conflict","Retained judge reservations and receipts are immutable.")}i.run("INSERT INTO local_experiment_judge_budgets(team_id,execution_id,calls) VALUES(?,?,?) ON CONFLICT(team_id,execution_id) DO UPDATE SET calls=excluded.calls",[e.teamId,e.id,JSON.stringify(g)]);for(let l of g){let p=l.status==="not_dispatched"?"released":l.response?.costUsd!==null&&l.response?.costUsd!==void 0?"settled":"unknown";i.run("INSERT INTO local_experiment_charges(team_id,execution_id,request_id,case_id,maximum_usd,cost_usd,status,usage) VALUES(?,?,?,?,?,?,?,?) ON CONFLICT(team_id,execution_id,request_id) DO UPDATE SET cost_usd=excluded.cost_usd,status=excluded.status,usage=excluded.usage",[e.teamId,e.id,l.id,e.caseId,l.reservedUsd,l.response?.costUsd??null,p,l.response?JSON.stringify(l.response):null])}return m(i,e.teamId,e.id),_.result})}async listLocalExecutions(e,t,i,n){return this.localWrite(a=>{let o=a.all(`SELECT payload FROM local_experiment_executions WHERE team_id=? AND definition_id=? AND json_extract(payload,'$.kind')='target' ${i?"AND id>?":""} ORDER BY id LIMIT ?`,[e,t,...i?[i]:[],n+1]),r=o.slice(0,n).map(_=>h.parse(JSON.parse(_.payload)));return{items:r,nextCursor:o.length>n?r.at(-1).id:null}})}async listLocalScoringPasses(e,t,i,n){return this.localWrite(a=>{let o=a.all(`SELECT e.payload FROM local_experiment_executions e JOIN local_experiment_scoring_selections s ON s.team_id=e.team_id AND s.execution_id=e.id WHERE e.team_id=? AND s.source_execution_id=? ${i?"AND e.id>?":""} ORDER BY e.id LIMIT ?`,[e,t,...i?[i]:[],n+1]),r=o.slice(0,n).map(_=>h.parse(JSON.parse(_.payload)));return{items:r,nextCursor:o.length>n?r.at(-1).id:null}})}async admitLocalCase(e,t,i,n){return this.localWrite(a=>{this.requireLocalOwner(a,e,t,n);let o=E(a,e,t);if(!["queued","running"].includes(o.status))return!1;let r=a.get("SELECT status FROM local_experiment_cases WHERE team_id=? AND execution_id=? AND receipt_id=?",[e,t,i]);return!r||r.status!=="pending"?!1:(a.run("UPDATE local_experiment_cases SET status='running' WHERE team_id=? AND execution_id=? AND receipt_id=?",[e,t,i]),m(a,e,t,{status:"running"}),!0)})}async settleLocalCase(e){return this.localWrite(t=>{if(this.requireLocalOwner(t,e.teamId,e.id,e.ownerId),t.get("SELECT status FROM local_experiment_cases WHERE team_id=? AND execution_id=? AND receipt_id=?",[e.teamId,e.id,e.receiptId])?.status!=="running")throw new s("local_case_not_owned","Only the admitted case owner may seal retained output.");return t.run("UPDATE local_experiment_cases SET status=?,result=?,error=? WHERE team_id=? AND execution_id=? AND receipt_id=?",[e.status,e.result===null?null:JSON.stringify(e.result),e.error,e.teamId,e.id,e.receiptId]),m(t,e.teamId,e.id)})}async cancelLocalExecution(e,t){return this.localWrite(i=>{let n=E(i,e,t);return["queued","running","cancelling"].includes(n.status)?(i.run("UPDATE local_experiment_cases SET status='cancelled' WHERE team_id=? AND execution_id=? AND status='pending'",[e,t]),m(i,e,t,{status:"cancelling"})):n})}async finishLocalExecution(e,t,i,n=null,a=!0){return this.localWrite(o=>{this.requireLocalOwner(o,e,t,i);let r=m(o,e,t);if(r.counts.running)throw new s("local_cleanup_pending","Wait for active case transport cleanup before sealing execution.");return r.counts.pending&&o.run("UPDATE local_experiment_cases SET status='cancelled' WHERE team_id=? AND execution_id=? AND status='pending'",[e,t]),r=m(o,e,t),m(o,e,t,{status:r.status==="cancelling"&&a?"cancelled":n||r.counts.failed||r.counts.unknown||!a?"failed":"completed",completedAt:new Date().toISOString(),cleanupComplete:a,error:n})})}async recoverLocalExperiments(e){return this.localWrite(t=>{x(t,e);let i=t.all("SELECT team_id,id FROM local_experiment_executions WHERE owner_id<>?",[e]),n=[];for(let a of i){let o=E(t,a.team_id,a.id);["queued","running","cancelling"].includes(o.status)&&(t.run("UPDATE local_experiment_cases SET status=CASE WHEN status='running' THEN 'unknown' ELSE 'cancelled' END,error='local_process_interrupted' WHERE team_id=? AND execution_id=? AND status IN ('pending','running')",[a.team_id,a.id]),t.run("UPDATE local_experiment_charges SET status='unknown' WHERE team_id=? AND execution_id=? AND status IN ('reserved','dispatched')",[a.team_id,a.id]),n.push(m(t,a.team_id,a.id,{status:"interrupted",completedAt:new Date().toISOString(),cleanupComplete:!1,error:"The previous process ended. Admitted calls and uncertain charges were retained; start a new execution explicitly."})))}return n})}async reserveLocalCharge(e){return this.localWrite(t=>{if(this.requireLocalOwner(t,e.teamId,e.id,e.ownerId),this.requireLocalChargeBounds(t,e.teamId,e.id),!Number.isFinite(e.maximumUsd)||e.maximumUsd<=0)throw new s("local_charge_bound_unknown","An enforceable positive model charge ceiling is required.",422);let i=m(t,e.teamId,e.id);if(i.status!=="running")throw new s("local_execution_not_running","The execution no longer accepts model dispatch.");if(t.get("SELECT status FROM local_experiment_cases WHERE team_id=? AND execution_id=? AND receipt_id=?",[e.teamId,e.id,e.caseId])?.status!=="running")throw new s("local_case_not_admitted","Model reservation requires an owned running case.");if(t.get("SELECT request_id FROM local_experiment_charges WHERE team_id=? AND execution_id=? AND request_id=?",[e.teamId,e.id,e.requestId]))throw new s("local_dispatch_already_admitted","This target request was already admitted and cannot be replayed.");if(i.usage.knownCostUsd+i.usage.heldUsd+e.maximumUsd>i.maximumCostUsd+1e-12)throw new s("experiment_budget_exhausted","The local ceiling cannot cover this model's maximum accepted request charge.",422);t.run("INSERT INTO local_experiment_charges(team_id,execution_id,request_id,case_id,maximum_usd,status) VALUES(?,?,?,?,?,'reserved')",[e.teamId,e.id,e.requestId,e.caseId,e.maximumUsd]),m(t,e.teamId,e.id)})}async markLocalChargeDispatched(e,t,i,n){let a=y();return this.localWrite(o=>{if(a?.assertExecution(t),this.requireLocalOwner(o,e,t,n),o.get("SELECT status FROM local_experiment_charges WHERE team_id=? AND execution_id=? AND request_id=?",[e,t,i])?.status!=="reserved")throw new s("local_dispatch_not_reserved","Target dispatch requires a fresh durable reservation.");o.run("UPDATE local_experiment_charges SET status='dispatched' WHERE team_id=? AND execution_id=? AND request_id=?",[e,t,i]),m(o,e,t)})}async settleLocalCharge(e){let t=await this.localWrite(i=>{this.requireLocalOwner(i,e.teamId,e.id,e.ownerId);let n=i.get("SELECT status,maximum_usd,cost_usd,usage FROM local_experiment_charges WHERE team_id=? AND execution_id=? AND request_id=?",[e.teamId,e.id,e.requestId]);if(!n)throw new s("local_charge_not_reserved","The charge does not belong to this execution.");if(e.costUsd!==null&&(!Number.isFinite(e.costUsd)||e.costUsd<0))throw new s("local_charge_invalid","Measured charge must be finite and nonnegative.");let a=e.costUsd!==null&&e.costUsd>n.maximum_usd+1e-12,o=e.confirmedTransportNotInvoked instanceof M&&e.confirmedTransportNotInvoked.executionId===e.id&&e.confirmedTransportNotInvoked.requestId===e.requestId&&e.costUsd===null&&e.usage===null&&n.status==="dispatched",r=e.notDispatched&&n.status==="reserved"||o?"released":e.costUsd===null?"unknown":"settled";if(["released","settled"].includes(n.status)){if(n.status!==r||n.cost_usd!==e.costUsd||(n.usage?d(JSON.parse(n.usage)):null)!==(e.usage?d(e.usage):null))throw new s("local_charge_receipt_conflict","A sealed charge receipt is immutable.");return{execution:m(i,e.teamId,e.id),exceedsBound:a}}return i.run("UPDATE local_experiment_charges SET status=?,cost_usd=?,usage=? WHERE team_id=? AND execution_id=? AND request_id=?",[r,e.costUsd,e.usage===null?null:JSON.stringify(e.usage),e.teamId,e.id,e.requestId]),{execution:m(i,e.teamId,e.id),exceedsBound:a}});if(t.exceedsBound)throw new s("local_charge_outside_bound","Measured charge exceeds its authoritative reservation. Its receipt was retained; no further target dispatch is admitted.");return t.execution}requireLocalChargeBounds(e,t,i){if(e.get("SELECT request_id FROM local_experiment_charges WHERE team_id=? AND execution_id=? AND cost_usd>maximum_usd+0.000000000001 LIMIT 1",[t,i]))throw new s("local_charge_outside_bound","A retained provider receipt exceeded its authoritative reservation. Further target and judge dispatch is blocked.")}requireLocalOwner(e,t,i,n){x(e,n);let a=e.get("SELECT owner_id FROM local_experiment_executions WHERE team_id=? AND id=?",[t,i]);if(!a||a.owner_id!==n)throw new s("local_execution_owner_conflict","This process does not own the execution.")}};export{ee as SqliteLocalExperimentStore};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{b as B}from"./chunk-QIKWJ2AA.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as E}from"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import{b as k,l as v,m as y}from"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import{ua as M}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import{x as u}from"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import{O as R,ba as g}from"./chunk-VYLGI3IH.js";import{h as s}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{m as d}from"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import{a as p}from"./chunk-FTQLQJQV.js";var T=class extends E{static{p(this,"SqliteModelBatchReviewStore")}async findModelBatchReview(t,r){return this.modelBatchReviewTransaction(t,r)}async beginModelBatchReview(t,r,o){let e=await this.modelBatchReviewTransaction(t,r,o);if(!e)throw new Error("Model batch review was not created.");return e}async modelBatchReviewTransaction(t,r,o){let e=k.parse(r);await this.ready;let l=this.writeQueue.then(async()=>{let a=this.db;if(!a)throw new Error("Model review store is closed.");a.exec("BEGIN IMMEDIATE");let w=!0,h=B(a,t,()=>{if(!w)throw new Error("Model review transaction is closed.")});try{let i=a.get("SELECT payload FROM model_projects WHERE id = ? AND profile_id = ?",[e.modelId,t]);if(!i)throw new s("model_not_found",404);let n=u.parse(JSON.parse(i.payload)),m=await v(h,e);if(m||!o)return a.exec("COMMIT"),m;if(n.revision!==e.expectedModelRevision||!n.trainingSetup.tasksetRef||!R(n.trainingSetup.tasksetRef,e.tasksetRef))throw new s("model_revision_conflict",409);let f=a.get("SELECT payload FROM taskset_revisions WHERE taskset_id = ? AND revision = ? AND profile_id = ?",[e.tasksetRef.id,e.tasksetRef.revision,t]),c=f?M.parse(JSON.parse(f.payload)):null;if(!c||c.contentHash!==e.tasksetRef.contentHash||d(c.metadata.learning)!==d(g(o.taskset)))throw new s("model_review_package_mismatch",409);let _=await y(h,{scope:t,request:e,package:o,now:new Date().toISOString()});return a.exec("COMMIT"),_}catch(i){throw a.exec("ROLLBACK"),i}finally{w=!1}});return this.writeQueue=l.then(()=>{},()=>{}),l}};export{T as SqliteModelBatchReviewStore};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as Ie,b as Q,c as W,d as ye,e as Te,f as Ee}from"./chunk-SDXFLO7J.js";import"./chunk-GLDYJM7O.js";import{a as Se,d as F,e as C,g as Pe,h as J,j as Me}from"./chunk-HCYX6RHP.js";import{a as ke}from"./chunk-SDAUS5PY.js";import{a as b}from"./chunk-I2NXNMRZ.js";import{d as me,e as he,f as ge,i as we,j as ve,k as B}from"./chunk-O72BSKSO.js";import{b as ce}from"./chunk-DBK66CJP.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as fe}from"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import{B as ne,D as de,d as ae,e as oe,k as se}from"./chunk-FTEOCCPB.js";import{Fb as le,Gb as pe,Ib as ue,O as ee,Q as L,T as te,W as re,ua as ie,xa as x}from"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import{E as Y,K as Z,i as k,n as N,t as X,x as v}from"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import{N as g,O as R,Q as G,d as V,ib as K}from"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import{b as I}from"./chunk-ES2ISFJC.js";import{a as f}from"./chunk-FTQLQJQV.js";import Ae from"node:path";import{createHash as be}from"node:crypto";function j(o){let{request:a,resolved:r}=C(o.request,o.package),{starter:t,...n}=r,e=a.rewardBindingRef&&!R(a.rewardBindingRef,g(r.rewardBinding));if(e&&(!o.rewardSelection||!R(a.rewardBindingRef,g(o.rewardSelection.rewardBinding))))throw new Error("The selected starter Reward is unavailable for package preparation.");let s=re({owner:{scopeId:a.profileId,modelId:a.modelId},source:n,...e?o.rewardSelection:{rewardBinding:n.rewardBinding,rewards:n.rewards,assets:n.assets}}),{taskset:i,taskDefinition:p,rewardBinding:l,rewards:d,assets:h}=s;if(o.source.profileId!==a.profileId||o.source.sourceHash!==t.contentHash)throw new Error("Starter source must belong to this Profile and pin the catalog package.");let u=s.execution!==void 0,y=i.environment.kind==="text"&&i.environment.entrypoint==="openpond.text.v1"&&!i.environment.stateful&&(!i.environmentRelease&&!i.verifierSetRelease||s.executionResources!==void 0)&&!i.capabilities.length&&!i.tools.length;if(!["sft","grpo"].includes(a.method)||p.harness||!y&&!u||i.tasks.some(c=>c.artifactRefs.length)||i.graders.some(c=>c.kind==="model_judge"&&(!c.model||c.calibrationStatus!=="passed")))throw new Error("This starter requires an additional training or environment adapter before preparation.");let w=new Set(o.approvedTrainingTaskIds);if(w.size!==o.approvedTrainingTaskIds.length)throw new Error("Starter training approvals must be unique.");for(let c of w){let P=i.tasks.find(H=>H.id===c);if(!P||P.split!=="train")throw new Error(`Starter approval must reference a training task: ${c}.`);if(a.method==="sft"&&P.expectedOutput===null)throw new Error(`SFT starter approval requires a reviewed target: ${c}.`)}if(a.method==="grpo"&&i.tasks.some(c=>c.split==="train"&&!w.has(c.id)))throw new Error("GRPO starter preparation requires approval of every training task.");for(let c of o.fixtures){if(!i.tasks.some(P=>P.id===c.taskId))throw new Error(`Starter fixture references an unknown task: ${c.taskId}.`);u&&!c.infrastructureError&&ee.parse(c.metadata.toolScript)}let E=i.id,m=ne({profileId:a.profileId,id:`${E}-draft`,name:t.name,now:o.createdAt}),S=[];for(let c of i.graders){if(c.kind!=="custom_verifier")continue;let P=h.find(D=>D.id===c.verifierRef.id);if(!P)throw new Error(`Starter verifier asset is missing: ${c.id}.`);let H=pe(c.verifierRef.contentHash);S.some(D=>D.path===H)||S.push({path:H,role:"verifier",content:V(P,c.verifierRef)})}let _=se.parse({...m,objective:p.instructions,metrics:i.metrics??m.metrics,sourceRefs:[o.source],policy:i.policy,environment:{...m.environment,kind:u?"agent":"chat",entrypoint:i.environment.entrypoint,stateful:i.environment.stateful,toolNames:i.tools.map(c=>c.name),deterministicSeeds:i.environment.deterministicSeeds,defaultTimeoutMs:i.environment.defaultTimeoutMs,networkPolicy:i.environment.networkPolicy,metadata:{portableEnvironment:i.environment,portableTools:i.tools,...s.executionResources?{portableExecutionResources:s.executionResources}:s.execution?{portableExecutionResources:{environment:s.execution.environment,verifierSet:s.execution.verifierSet}}:{}}},output:{mode:"structured_json",jsonSchema:p.outputSchema,renderer:null},capabilities:{...m.capabilities,taskKind:u?"single_agent":"chat",requiresTools:u,requiresState:u,supportedSignals:a.method==="grpo"?["reward"]:["demonstration"],compatibleMethods:[a.method],rewardKinds:[...new Set(i.graders.map(c=>c.kind==="human"?"human":c.kind==="model_judge"?"model_judge":"deterministic"))],requiresPrivilegedGrading:!0,environmentPlacements:["local","remote"]},tasks:i.tasks.map(({artifactRefs:c,...P})=>({...P,schemaVersion:"openpond.taskData.v1",sourceRefs:[o.source.id],metadata:{exampleOrigin:"curated_starter",starter:g(t),portableTaskRecord:{...P,artifactRefs:[]}}})),graders:le(l,d,h),graderFixtures:o.fixtures,learningSignals:{...m.learningSignals,rewards:a.method==="grpo"?i.tasks.filter(c=>w.has(c.id)).map(c=>({kind:"reward",id:`starter-reward-${c.id}`,taskId:c.id,task:p.instructions,rules:[{id:l.id,points:1,condition:"Execute the published Reward binding with its declared normalization, weights and required gates."}],otherwisePoints:0,executable:!0,approved:!0,confidence:1,sourceRefs:[o.source.id],artifactRef:l.id,metadata:{starter:g(t),rewardBinding:g(l),approvalOrigin:"catalog_publication"}})):[],demonstrations:a.method==="sft"?i.tasks.filter(c=>w.has(c.id)).map(c=>({kind:"demonstration",id:`starter-target-${c.id}`,taskId:c.id,sourceRefs:[o.source.id],artifactRef:i.id,approved:!0,confidence:1,prompt:null,response:JSON.stringify(c.expectedOutput),metadata:{starter:g(t),approvalOrigin:"catalog_publication"}})):[]},metadata:{starter:g(t),starterTasksetRelease:g(i),taskDefinition:g(p),rewardBinding:g(l),rewardExecution:{binding:l,rewards:d},portableCapabilities:i.capabilities,derivedPortableMetadata:i.metadata,modelTasksetDerivation:i.metadata.modelTasksetDerivation}}),M=de({draft:_,now:o.createdAt,tasksetId:E,sourcePackageHash:i.contentHash});return M.metrics=i.metrics,M.contentHash=x(M),{draft:_,taskset:M,generatedFiles:S,resources:s}}f(j,"prepareModelStarterTaskset");function O(o,a){let r=F(a),t=o.get("SELECT request_hash, payload FROM model_starter_creation_operations WHERE profile_id = ? AND operation_id = ?",[r.profileId,r.operationId]);if(!t)return null;if(t.request_hash!==je(r))throw new Error("Starter creation operation was already used with different configuration.");return v.parse(JSON.parse(t.payload))}f(O,"findModelStarterCreation");async function Re(o,a){let r=F(a.request);if(r.learning)throw new Error("Create this Model in a hosted workspace to enable continual learning.");let t=O(o,r);if(t)return t;let{taskset:n,resources:e}=j(a),s=Pe(a.package),i=await Y({id:r.modelId,profileId:r.profileId,name:r.name,objective:s.taskDefinition.instructions,defaultBaseModel:r.startingModel,defaultDestinationId:null,trainingSetup:Se({package:e,setup:X.parse({tasksetRef:g(n),rewardBindingRef:g(e.rewardBinding),baseModel:r.startingModel,method:r.method,managedRolloutPlacement:"remote"})})},0);o.exec("BEGIN IMMEDIATE");try{let p=O(o,r);if(p)return o.exec("COMMIT"),p;if(o.get("SELECT id FROM tasksets WHERE id = ?",[n.id])||o.get("SELECT id FROM model_projects WHERE id = ?",[r.modelId]))throw new Error("Starter creation requires a new Model and Taskset identity.");let l=[...e.executionResources??e.execution?[{kind:"asset",resource:te(e.executionResources??e.execution)}]:[],...s.execution?[{kind:"asset",resource:L(s.execution)}]:[],...s.assets.map(u=>({kind:"asset",resource:u})),...s.rewards.map(u=>({kind:"reward",resource:u})),{kind:"binding",resource:s.rewardBinding},{kind:"definition",resource:s.taskDefinition},{kind:"package",resource:s.taskset},...e.taskset.contentHash===s.taskset.contentHash?[]:[{kind:"definition",resource:e.taskDefinition},{kind:"package",resource:e.taskset},...e.execution?[{kind:"asset",resource:L(e.execution)}]:[]]];for(let{kind:u,resource:y}of l)Ie(o,r.profileId,u,y);let d=JSON.stringify(n);o.run("INSERT INTO tasksets (id, profile_id, status, payload, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)",[n.id,n.profileId,n.status,d,n.createdAt,n.updatedAt]),o.run("INSERT INTO taskset_revisions (taskset_id, revision, content_hash, profile_id, status, payload, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",[n.id,n.revision,n.contentHash,n.profileId,n.status,d,n.createdAt,n.updatedAt]);let h=Te(o,i);return o.run("INSERT INTO model_starter_creation_operations (profile_id, operation_id, request_hash, payload) VALUES (?, ?, ?, ?)",[r.profileId,r.operationId,je(r),JSON.stringify(h)]),o.exec("COMMIT"),h}catch(p){throw o.exec("ROLLBACK"),p}}f(Re,"commitModelStarterCreation");function je(o){return be("sha256").update(k(o)).digest("hex")}f(je,"requestHash");function q(o,a,r,t,n){let e=v.parse(r);o.exec("BEGIN IMMEDIATE");try{let s=o.get("SELECT payload FROM model_projects WHERE id = ?",[e.id]),i=s?v.parse(JSON.parse(s.payload)):null;i&&i.profileId!==e.profileId&&T("Model ownership changed during hosted synchronization.");let p;if(t)k(i)!==k(a)&&T("Model changed while its hosted configuration was loading. Refresh before applying it."),p=e;else{(!i||!a||a.id!==e.id||a.profileId!==e.profileId)&&T("Model is no longer available for hosted synchronization."),i.hosted?.teamId!==a.hosted?.teamId&&i.hosted?.teamId!==e.hosted?.teamId&&T("Model hosting team changed during synchronization.");let l=e.hosted,d=i.hosted,h=d;if(l){d?.apiOrigin&&d.apiOrigin!==l.apiOrigin&&T("Model hosting API changed during synchronization.");let u=d?.apiOrigin===l.apiOrigin&&d?.teamId===l.teamId&&d.projectId===l.projectId;u&&d.revision===l.revision&&d.etag!==l.etag&&T("Hosted Model receipts disagree about the same revision."),h={...u&&d.revision>l.revision?d:l,tasksets:u?Oe(d.tasksets,l.tasksets,w=>`${w.localTasksetId}:${w.releaseHash}`,w=>w.syncedAt):l.tasksets}}p=v.parse({...i,hosted:h,tasksetSyncs:Oe(i.tasksetSyncs,e.tasksetSyncs,u=>u.localTasksetId,u=>u.lastAttemptAt)})}return n?.(),o.run(`INSERT INTO model_projects (id, profile_id, payload, created_at, updated_at) VALUES (?, ?, ?, ?, ?)
3
+ ON CONFLICT(id) DO UPDATE SET payload = excluded.payload, updated_at = excluded.updated_at`,[p.id,p.profileId,JSON.stringify(p),p.createdAt,p.updatedAt]),o.exec("COMMIT"),p}catch(s){throw o.exec("ROLLBACK"),s}}f(q,"commitModelProjectHosting");function Oe(o,a,r,t){let n=new Map(o.map(e=>[r(e),e]));for(let e of a){let s=n.get(r(e));(!s||Date.parse(t(e))>=Date.parse(t(s)))&&n.set(r(e),e)}return[...n.values()]}f(Oe,"mergeLatest");function T(o){throw new Z(409,{schemaVersion:"openpond.modelProjectApiError.v2",code:"model_hosting_conflict",message:o,retryable:!1,requestId:null,details:{}})}f(T,"conflict");function z(o,a){let{request:r,resolved:t}=C(a.request,a.package),n=r.rewardBindingRef;if(!n||R(n,g(t.rewardBinding)))return a;function e(l,d){let h=o.get("SELECT payload FROM learning_revisions WHERE scope = ? AND kind = ? AND id = ? AND revision = ?",[r.profileId,l,d.id,d.revision]);if(!h)throw new Error(`The selected starter ${l} is unavailable in this Profile.`);let u=K[l].parse(JSON.parse(h.payload));if(G(u),d.contentHash&&d.contentHash!==u.contentHash)throw new Error("The selected starter Reward differs from its immutable reference.");return u}f(e,"read");let s=e("binding",n),i=[...new Map(s.sources.map(l=>[k(l.reward),e("reward",l.reward)])).values()],p=new Map(t.assets.map(l=>[l.id,l]));for(let l of i){let d=l.implementation;for(let h of[...l.assets,..."verifierRef"in d?[d.verifierRef]:[],..."rubricRef"in d?[d.rubricRef]:[],..."inputContract"in d?[d.inputContract]:[]])p.has(h.id)||p.set(h.id,e("asset",{id:h.id,revision:1}))}return{...a,rewardSelection:{rewardBinding:s,rewards:i,assets:[...p.values()]}}}f(z,"resolveModelStarterSelection");import Ce from"node:path";async function $(o,a,r){let t=r.project.trainingSetup.tasksetRef;if(!t)return;let n=o.get("SELECT payload FROM taskset_revisions WHERE taskset_id = ? AND revision = ?",[t.id,t.revision]);if(!n)return;let e=ie.parse(JSON.parse(n.payload));if(e.profileId!==r.project.profileId||e.contentHash!==t.contentHash)return;let s=o.get("SELECT payload FROM model_projects WHERE id = ?",[r.project.id]),i=s?v.parse(JSON.parse(s.payload)):null;if(i&&(i.profileId!==r.project.profileId||i.revision!==r.expectedRevision))return;let p=i?.hosted?.tasksets.find(m=>m.localTasksetId===e.id&&m.localTasksetHash===e.contentHash),l=typeof e.metadata.importedPackageHash=="string"?e.metadata.importedPackageHash:p?.packageHash;if(!l){if(e.metadata.learning!==void 0||e.metadata.taskDefinition!==void 0||e.metadata.rewardBinding!==void 0)return;let m=r.project.trainingSetup,S=m.baseModel??r.project.defaultBaseModel,_=m.method??(e.authoringProvenance.buildIntent==="verifiable_reward"?"grpo":null);if(!m.rewardBindingRef&&(_!=="grpo"||m.recipe||!S?.revision||!S.tokenizerRevision||!S.chatTemplateHash))return;if(x(e)!==t.contentHash)throw new Error("Selected Taskset differs from its immutable content hash.");let M=ue({taskset:e,adapterId:me(e)});return ke({storeDir:a,taskset:e,content:{schemaVersion:"openpond.tasksetPackage.v1",taskset:M.tasksetRelease,environment:M.environmentRelease,verifierSet:M.verifierSetRelease}})}let d=await ve(a,l);if(d.taskset.id!==(p?.releaseId??t.id)||d.taskset.revision!==(p?.releaseRevision??t.revision))throw new Error("Cached package differs from its selected Taskset revision.");let{files:h,contentHash:u,...y}=d,w=he(d,typeof e.metadata.importedPackageHash=="string"),E=await ge({root:Ce.join(a,"training","tasksets",b(e)),content:y,sources:h.filter(m=>!w.has(m.asset.id)).map(m=>({asset:m.asset,sourcePath:e.tasks.flatMap(S=>S.assets??[]).find(S=>S.id===m.asset.id)?.artifactRef??m.asset.path})),fileOrder:h.map(m=>m.asset.id)});if(E.contentHash!==d.contentHash)throw new Error("Imported package bytes changed before the Reward edit.");return E}f($,"loadModelTasksetPackage");var{package:yt,evaluationPackage:Tt,...qe}=ae.shape,A=I.object({apiOrigin:I.string().url().refine(o=>new URL(o).origin===o),teamId:I.string().min(1),project:v,localTaskset:N,localEvaluation:N.optional(),evaluationPackageHash:I.string().regex(/^[a-f0-9]{64}$/).optional(),packageHash:I.string().regex(/^[a-f0-9]{64}$/),request:I.object(qe).strict()}).strict().refine(o=>!!o.localEvaluation==!!o.evaluationPackageHash,"Evaluation bytes and local identity must be captured together.");function U(o,a){let r=o.get("SELECT payload FROM model_project_package_operations WHERE profile_id = ? AND model_id = ? AND state = 'pending'",[a.profileId,a.modelId]),t=r?A.parse(JSON.parse(r.payload)):null;if(t&&(t.apiOrigin!==a.apiOrigin||t.teamId!==a.teamId))throw new Error("Finish the pending package publication in its original API and workspace before changing hosting.");return t}f(U,"pendingModelPackageOperation");function _e(o,a){let r=A.parse(a);o.exec("BEGIN IMMEDIATE");try{let t=U(o,{profileId:r.project.profileId,modelId:r.project.id,apiOrigin:r.apiOrigin,teamId:r.teamId});if(t)return o.exec("COMMIT"),t;let n=o.get("SELECT payload FROM model_projects WHERE id = ?",[r.project.id]),e=n?v.parse(JSON.parse(n.payload)):null;if(k(e)!==k(r.project))throw new Error("Model changed while its package was being prepared. Retry the push.");let s=o.get("SELECT payload, state FROM model_project_package_operations WHERE operation_id = ?",[r.request.operationId]);if(s){let i=A.parse(JSON.parse(s.payload));if(k({...i,project:r.project})!==k(r))throw new Error("Package operation identity was reused with different publication content.");if(s.state==="committed")return o.exec("COMMIT"),i;o.run("UPDATE model_project_package_operations SET state = 'pending', payload = ? WHERE operation_id = ? AND state = 'rejected'",[JSON.stringify(r),r.request.operationId])}else o.run("INSERT INTO model_project_package_operations (operation_id, profile_id, model_id, api_origin, team_id, state, payload, created_at) VALUES (?, ?, ?, ?, ?, 'pending', ?, ?)",[r.request.operationId,r.project.profileId,r.project.id,r.apiOrigin,r.teamId,JSON.stringify(r),new Date().toISOString()]);return o.exec("COMMIT"),r}catch(t){throw o.exec("ROLLBACK"),t}}f(_e,"prepareModelPackageOperation");function He(o,a,r){let t=oe.parse(r),n=o.get("SELECT payload, receipt FROM model_project_package_operations WHERE operation_id = ?",[a]);if(!n)throw new Error("Package push has no durable local intent.");let e=A.parse(JSON.parse(n.payload));if(n.receipt&&k(JSON.parse(n.receipt))!==k(t))throw new Error("Package push retry returned a different receipt.");if(t.operationId!==a||t.teamId!==e.teamId||t.packageHash!==e.packageHash||t.modelProjectId!==e.request.modelProjectId)throw new Error("Package push receipt differs from its local intent.");if(e.evaluationPackageHash&&(!t.evaluation||t.evaluation.packageHash!==e.evaluationPackageHash||k(t.evaluation.taskset)!==k(e.request.modelConfiguration?.trainingSetup.evaluationTasksetRef)))throw new Error("Evaluation package receipt differs from its local intent.");let s=e.project,i=t.project;if(e.request.selection==="select"&&!i)throw new Error("Selected package receipt is missing Model configuration.");if(!i&&!s.hosted)throw new Error("Historical package receipt has no existing hosted Model.");let p=new Date().toISOString(),l=v.parse({...s,hosted:{schemaVersion:"openpond.hostedModelProjectLink.v1",apiOrigin:e.apiOrigin,teamId:e.teamId,projectId:i?.id??s.hosted.projectId,portableProjectId:s.id,revision:i?.revision??s.hosted.revision,etag:t.projectEtag,syncedSourceRevision:e.request.selection==="select"?s.revision:s.hosted.syncedSourceRevision,syncedAt:p,tasksets:[...(s.hosted?.tasksets??[]).filter(d=>d.releaseHash!==t.taskset.contentHash&&d.releaseHash!==t.evaluation?.taskset.contentHash),{localTasksetId:e.localTaskset.id,localTasksetHash:e.localTaskset.contentHash,releaseId:t.taskset.id,releaseRevision:t.taskset.revision,releaseHash:t.taskset.contentHash,packageHash:t.packageHash,hostedTasksetId:t.hostedTasksetId,syncedAt:p},...e.localEvaluation&&t.evaluation?[{localTasksetId:e.localEvaluation.id,localTasksetHash:e.localEvaluation.contentHash,releaseId:t.evaluation.taskset.id,releaseRevision:t.evaluation.taskset.revision,releaseHash:t.evaluation.taskset.contentHash,packageHash:t.evaluation.packageHash,hostedTasksetId:t.evaluation.hostedTasksetId,syncedAt:p}]:[]]},tasksetSyncs:[...s.tasksetSyncs.filter(d=>d.localTasksetId!==e.localTaskset.id&&d.localTasksetId!==e.localEvaluation?.id),{localTasksetId:e.localTaskset.id,releaseId:t.taskset.id,releaseRevision:t.taskset.revision,releaseHash:t.taskset.contentHash,state:"synced",hostedTasksetId:t.hostedTasksetId,lastAttemptAt:p,syncedAt:p,lastError:null},...e.localEvaluation&&t.evaluation?[{localTasksetId:e.localEvaluation.id,releaseId:t.evaluation.taskset.id,releaseRevision:t.evaluation.taskset.revision,releaseHash:t.evaluation.taskset.contentHash,state:"synced",hostedTasksetId:t.evaluation.hostedTasksetId,lastAttemptAt:p,syncedAt:p,lastError:null}]:[]]});return q(o,s,l,!1,()=>{o.run("UPDATE model_project_package_operations SET state = 'committed', receipt = ? WHERE operation_id = ?",[JSON.stringify(t),a])})}f(He,"completeModelPackageOperation");var xe=class extends fe{static{f(this,"SqliteModelConfigurationStore")}async pendingModelPackagePush(a){if(await this.ready,await this.writeQueue,!this.db)throw new Error("Package push store is closed.");return U(this.db,a)}async prepareModelPackagePush(a){await this.ready;let r=this.writeQueue.then(()=>{if(!this.db)throw new Error("Package push store is closed.");return _e(this.db,a)});return this.writeQueue=r.then(()=>{},()=>{}),r}async completeModelPackagePush(a,r){await this.ready;let t=this.writeQueue.then(()=>{if(!this.db)throw new Error("Package push store is closed.");return He(this.db,a,r)});return this.writeQueue=t.then(()=>{},()=>{}),t}async rejectModelPackagePush(a){await this.ready;let r=this.writeQueue.then(()=>{if(!this.db)throw new Error("Package push store is closed.");this.db.run("UPDATE model_project_package_operations SET state = 'rejected' WHERE operation_id = ? AND state = 'pending'",[a])});return this.writeQueue=r.then(()=>{},()=>{}),r}async findModelProjectConfigurationSave(a){if(await this.ready,await this.writeQueue,!this.db)throw new Error("Model check failed because the local store is closed.");return W(this.db,a)}async saveModelProjectConfiguration(a){await this.ready;let r=this.writeQueue.then(async()=>{if(!this.db)throw new Error("Model save failed because the local store is closed.");let t=W(this.db,a);if(t)return t;let n=await $(this.db,this.home,a),e=Q(this.db,a,!0,n);if(e?.imported)await B({home:this.home,...e.imported});else if(e){let s=Ae.join(this.home,"training","tasksets",b(e.source));await J(this.home,e,e.directoryId,{source:{directory:s,packageHash:await ce(s)},verify:f(i=>Me(i,e.taskset),"verify")}),this.db.run("UPDATE model_project_taskset_preparations SET state = 'materialized' WHERE profile_id = ? AND operation_id = ?",[a.project.profileId,a.operationId])}return ye(this.db,a,e,n?.modelResources?{...n.modelResources,taskset:n.taskset,executionResources:{environment:n.environment,verifierSet:n.verifierSet}}:n)});return this.writeQueue=r.then(()=>{},()=>{}),r}async previewModelProjectTasksetSave(a){if(await this.ready,await this.writeQueue,!this.db)throw new Error("Model check failed because the local store is closed.");return Q(this.db,a,!1,await $(this.db,this.home,a))?.taskset??null}async findModelStarterCreation(a){if(await this.ready,await this.writeQueue,!this.db)throw new Error("Starter lookup failed because the local store is closed.");return O(this.db,a)}async saveModelStarterCreation(a){await this.ready;let r=this.writeQueue.then(async()=>{if(!this.db)throw new Error("Starter creation failed because the local store is closed.");let t=O(this.db,a.request);if(t)return t;let n=z(this.db,a),e=j(n);return await J(this.home,e,e.taskset.id),Re(this.db,n)});return this.writeQueue=r.then(()=>{},()=>{}),r}async prepareModelStarterCreation(a){if(await this.ready,await this.writeQueue,!this.db)throw new Error("Starter check failed because the local store is closed.");return j(z(this.db,a))}async saveModelProjectHosting(a,r,t=!1,n=[]){await this.ready;let e=this.writeQueue.then(async()=>{if(!this.db)throw new Error("Model synchronization failed because the local store is closed.");if(n.length&&!t)throw new Error("Package import requires an atomic Model replacement.");for(let s of n){if(s.taskset.profileId!==r.profileId)throw new Error("Imported package belongs to another Profile.");s.reuseExisting?await we(this.home,s.package):await B({home:this.home,...s})}return q(this.db,a,r,t,()=>{for(let s of n)Ee(this.db,s)})});return this.writeQueue=e.then(()=>{},()=>{}),e}};export{xe as SqliteModelConfigurationStore};
@@ -0,0 +1,6 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as v}from"./chunk-KCJVFLBB.js";import{Ua as y,Wa as C,Ya as h,ab as E}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{qa as P}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import{b as a}from"./chunk-ES2ISFJC.js";import{a as f}from"./chunk-FTQLQJQV.js";var t=a.string().trim().min(1).max(500),m=a.iso.datetime({offset:!0}),d=a.object({schemaVersion:a.literal("openpond.preferenceComparisonReleaseRecord.v1"),id:t,tasksetId:t,tasksetRelease:P,release:y,publishedBy:t,sourceConsent:a.enum(["authorized","revoked"]),retentionUntil:m.nullable(),createdAt:m}).strict(),c=a.object({schemaVersion:a.literal("openpond.preferenceComparisonAssignmentRecord.v1"),id:t,tasksetId:t,assignment:C,state:a.enum(["queued","in_review","submitted","unreviewable","revoked"]),reviewerKey:t.nullable(),unreviewableReason:a.string().trim().min(1).max(2e3).nullable(),createdAt:m,updatedAt:m}).strict().superRefine((i,r)=>{i.state==="unreviewable"&&!i.unreviewableReason&&r.addIssue({code:"custom",path:["unreviewableReason"],message:"Unreviewable assignments require a reason."}),i.state!=="unreviewable"&&i.unreviewableReason&&r.addIssue({code:"custom",path:["unreviewableReason"],message:"Only unreviewable assignments may retain a reason."})}),p=a.object({schemaVersion:a.literal("openpond.preferenceComparisonSubmissionRecord.v1"),id:t,tasksetId:t,assignmentId:t,reviewerKey:t,receipt:h,submittedAt:m}).strict(),u=a.object({schemaVersion:a.literal("openpond.preferenceComparisonCalibrationRecord.v1"),id:t,tasksetId:t,report:E,createdAt:m}).strict();var A=class extends v{static{f(this,"SqlitePreferenceComparisonStore")}async savePreferenceComparisonRelease(r){let e=d.parse(r);if(e.id!==e.release.id)throw new Error("Preference comparison release record ID must match its portable release ID.");let s=await this.getPreferenceComparisonRelease(e.id);if(s){if(s.tasksetId!==e.tasksetId||s.release.contentHash!==e.release.contentHash)throw new Error("A preference comparison release ID is immutable.");if(s.sourceConsent==="revoked"&&e.sourceConsent!=="revoked")throw new Error("Revoked preference-comparison source consent cannot be restored through a release write.")}return await this.upsertPayload(`INSERT INTO preference_comparison_releases (id, taskset_id, content_hash, source_consent, payload, created_at)
3
+ VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET source_consent = excluded.source_consent, payload = excluded.payload`,[e.id,e.tasksetId,e.release.contentHash,e.sourceConsent,JSON.stringify(e),e.createdAt]),e}async getPreferenceComparisonRelease(r){return this.getParsedPayload("SELECT payload FROM preference_comparison_releases WHERE id = ?",[r],d.parse)}async listPreferenceComparisonReleases(r){return this.listParsedPayloads("SELECT payload FROM preference_comparison_releases WHERE taskset_id = ? ORDER BY created_at DESC",[r],d.parse)}async revokePreferenceComparisonRelease(r){let e=await this.getPreferenceComparisonRelease(r.id);if(!e)throw new Error("Preference comparison release was not found.");return this.savePreferenceComparisonRelease({...e,sourceConsent:"revoked",retentionUntil:r.retentionUntil})}async savePreferenceComparisonAssignment(r){let e=c.parse(r);if(e.id!==e.assignment.id)throw new Error("Preference comparison assignment record ID must match its portable assignment ID.");let s=await this.getPreferenceComparisonRelease(e.assignment.comparisonRelease.id);if(!s||s.tasksetId!==e.tasksetId)throw new Error("Preference comparison assignment references an unavailable Taskset release.");if(s.sourceConsent!=="authorized")throw new Error("Preference comparison assignments cannot be created from revoked source consent.");if(s.release.contentHash!==e.assignment.comparisonRelease.contentHash)throw new Error("Preference comparison assignment does not reference the persisted immutable release.");let n=await this.getPreferenceComparisonAssignment(e.id);if(n){if(n.tasksetId!==e.tasksetId||n.assignment.contentHash!==e.assignment.contentHash)throw new Error("A preference comparison assignment is immutable.");if(!b(n.state,e.state))throw new Error("Invalid preference comparison assignment state transition.")}return await this.upsertPayload(`INSERT INTO preference_comparison_assignments (id, taskset_id, release_id, purpose, state, reviewer_key, payload, created_at, updated_at)
4
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET state = excluded.state, reviewer_key = excluded.reviewer_key, payload = excluded.payload, updated_at = excluded.updated_at`,[e.id,e.tasksetId,e.assignment.comparisonRelease.id,e.assignment.purpose,e.state,e.reviewerKey,JSON.stringify(e),e.createdAt,e.updatedAt]),e}async getPreferenceComparisonAssignment(r){return this.getParsedPayload("SELECT payload FROM preference_comparison_assignments WHERE id = ?",[r],c.parse)}async listPreferenceComparisonAssignments(r){let e=r.states?.length?r.states:null,s=e?` AND state IN (${e.map(()=>"?").join(", ")})`:"",n=r.reviewerKey?" AND (reviewer_key IS NULL OR reviewer_key = ?)":"";return this.listParsedPayloads(`SELECT payload FROM preference_comparison_assignments WHERE taskset_id = ?${n}${s} ORDER BY created_at ASC`,[r.tasksetId,...r.reviewerKey?[r.reviewerKey]:[],...e??[]],c.parse)}async claimPreferenceComparisonAssignment(r){let e=await this.claimPreferenceComparisonAssignmentRecord(r);if(!e)throw new Error("Preference comparison assignment is unavailable for this reviewer.");return e}async claimNextPreferenceComparisonAssignment(r){await this.ready;let e=null,s=this.writeQueue.then(async()=>{let n=await this.get(`SELECT payload FROM preference_comparison_assignments WHERE taskset_id = ? AND (state = 'queued' OR (state = 'in_review' AND reviewer_key = ?))
5
+ ORDER BY CASE state WHEN 'in_review' THEN 0 ELSE 1 END, created_at ASC LIMIT 1`,[r.tasksetId,r.reviewerKey]);n&&(e=await this.claimPreferenceComparisonAssignmentRecordInWrite({current:c.parse(JSON.parse(n.payload)),reviewerKey:r.reviewerKey,updatedAt:r.updatedAt}))});return this.writeQueue=s.catch(()=>{}),await s,e}async markPreferenceComparisonUnreviewable(r){let e=await this.claimPreferenceComparisonAssignment(r);return this.savePreferenceComparisonAssignment({...e,state:"unreviewable",reviewerKey:r.reviewerKey,unreviewableReason:r.reason,updatedAt:r.updatedAt})}async savePreferenceComparisonSubmission(r){let e=p.parse(r);await this.ready;let s=null,n=this.writeQueue.then(async()=>{let w=await this.get("SELECT payload FROM preference_comparison_assignments WHERE id = ?",[e.assignmentId]);if(!w)throw new Error("Preference comparison assignment was not found.");let o=c.parse(JSON.parse(w.payload)),R=await this.get("SELECT payload FROM preference_comparison_releases WHERE id = ?",[o.assignment.comparisonRelease.id]);if(!R)throw new Error("Preference comparison release was not found.");if(d.parse(JSON.parse(R.payload)).sourceConsent!=="authorized")throw new Error("Preference comparison submissions cannot use revoked source consent.");if(o.tasksetId!==e.tasksetId)throw new Error("Preference comparison submission Taskset does not match its assignment.");if(e.receipt.assignmentRef.id!==o.assignment.id||e.receipt.assignmentRef.contentHash!==o.assignment.contentHash)throw new Error("Preference comparison receipt does not belong to its assignment.");let g=await this.get("SELECT payload FROM preference_comparison_submissions WHERE assignment_id = ? AND reviewer_key = ?",[e.assignmentId,e.reviewerKey]);if(g){let l=p.parse(JSON.parse(g.payload));if(l.receipt.contentHash!==e.receipt.contentHash)throw new Error("Preference comparison submission is already recorded for this reviewer and assignment.");s=l;return}if(o.state!=="submitted"&&!await this.claimPreferenceComparisonAssignmentRecordInWrite({current:o,reviewerKey:e.reviewerKey,updatedAt:e.submittedAt}))throw new Error("Preference comparison assignment is unavailable for this reviewer.");await this.run("INSERT INTO preference_comparison_submissions (id, taskset_id, assignment_id, reviewer_key, receipt_hash, payload, submitted_at) VALUES (?, ?, ?, ?, ?, ?, ?)",[e.id,e.tasksetId,e.assignmentId,e.reviewerKey,e.receipt.contentHash,JSON.stringify(e),e.submittedAt]),o.state!=="submitted"&&await this.writePreferenceComparisonAssignmentInWrite({...o,state:"submitted",reviewerKey:e.reviewerKey,updatedAt:e.submittedAt}),s=e});if(this.writeQueue=n.catch(()=>{}),await n,!s)throw new Error("Preference comparison submission was not saved.");return s}async getPreferenceComparisonSubmission(r){return this.getParsedPayload("SELECT payload FROM preference_comparison_submissions WHERE assignment_id = ? AND reviewer_key = ?",[r.assignmentId,r.reviewerKey],p.parse)}async listPreferenceComparisonSubmissions(r){return this.listParsedPayloads("SELECT payload FROM preference_comparison_submissions WHERE assignment_id = ? ORDER BY submitted_at ASC",[r],p.parse)}async savePreferenceComparisonCalibration(r){let e=u.parse(r),s=await this.getPreferenceComparisonRelease(e.report.comparisonRelease.id);if(!s||s.tasksetId!==e.tasksetId)throw new Error("Preference calibration report references an unavailable Taskset release.");if(s.release.contentHash!==e.report.comparisonRelease.contentHash)throw new Error("Preference calibration report does not reference the persisted immutable release.");return await this.upsertPayload(`INSERT INTO preference_comparison_calibrations (id, taskset_id, release_id, report_hash, passed, payload, created_at)
6
+ VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET payload = excluded.payload`,[e.id,e.tasksetId,e.report.comparisonRelease.id,e.report.contentHash,e.report.passed?1:0,JSON.stringify(e),e.createdAt]),e}async listPreferenceComparisonCalibrations(r){return this.listParsedPayloads("SELECT payload FROM preference_comparison_calibrations WHERE taskset_id = ? ORDER BY created_at DESC",[r],u.parse)}async claimPreferenceComparisonAssignmentRecord(r){await this.ready;let e=null,s=this.writeQueue.then(async()=>{let n=await this.get("SELECT payload FROM preference_comparison_assignments WHERE id = ?",[r.id]);if(!n)throw new Error("Preference comparison assignment was not found.");e=await this.claimPreferenceComparisonAssignmentRecordInWrite({current:c.parse(JSON.parse(n.payload)),reviewerKey:r.reviewerKey,updatedAt:r.updatedAt})});return this.writeQueue=s.catch(()=>{}),await s,e}async claimPreferenceComparisonAssignmentRecordInWrite(r){if(r.current.state==="in_review"&&r.current.reviewerKey===r.reviewerKey)return r.current;if(r.current.state!=="queued")return null;let e={...r.current,state:"in_review",reviewerKey:r.reviewerKey,updatedAt:r.updatedAt};return await this.writePreferenceComparisonAssignmentInWrite(e),e}async writePreferenceComparisonAssignmentInWrite(r){await this.run("UPDATE preference_comparison_assignments SET state = ?, reviewer_key = ?, payload = ?, updated_at = ? WHERE id = ?",[r.state,r.reviewerKey,JSON.stringify(r),r.updatedAt,r.id])}};function b(i,r){return i===r?!0:i==="queued"?r==="in_review"||r==="unreviewable"||r==="revoked":i==="in_review"?r==="submitted"||r==="unreviewable"||r==="revoked":!1}f(b,"isPreferenceAssignmentTransition");export{A as SqlitePreferenceComparisonStore};
@@ -0,0 +1,53 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as c,f as s,g as u,h as o}from"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-DIO5CB6U.js";import{a as d}from"./chunk-KCJVFLBB.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import{a as i}from"./chunk-FTQLQJQV.js";var r=class extends d{static{i(this,"SqliteScheduleStore")}async listLocalAgentSchedules(e={}){await this.ready,await this.writeQueue;let t=[],a=[];return e.localProjectId&&(t.push("local_project_id = ?"),a.push(e.localProjectId)),e.enabled!==void 0&&e.enabled!==null&&(t.push("enabled = ?"),a.push(e.enabled?1:0)),(await this.all(`SELECT * FROM local_agent_schedules
3
+ ${t.length?`WHERE ${t.join(" AND ")}`:""}
4
+ ORDER BY local_project_id ASC, schedule_name ASC`,a)).map(c)}async listDueLocalAgentSchedules(e,t=25){return await this.ready,await this.writeQueue,(await this.all(`SELECT * FROM local_agent_schedules
5
+ WHERE enabled = 1
6
+ AND next_run_at IS NOT NULL
7
+ AND next_run_at <= ?
8
+ ORDER BY next_run_at ASC
9
+ LIMIT ?`,[e,Math.max(1,Math.min(100,Math.trunc(t)))])).map(c)}async getLocalAgentSchedule(e){await this.ready,await this.writeQueue;let t=await this.get("SELECT * FROM local_agent_schedules WHERE id = ?",[e]);return t?c(t):null}async upsertLocalAgentSchedule(e){await this.ready;let t=this.writeQueue.then(async()=>{await this.run(`INSERT INTO local_agent_schedules (
10
+ id,
11
+ local_project_id,
12
+ schedule_name,
13
+ enabled,
14
+ next_run_at,
15
+ payload,
16
+ created_at,
17
+ updated_at
18
+ )
19
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
20
+ ON CONFLICT(id)
21
+ DO UPDATE SET
22
+ local_project_id = excluded.local_project_id,
23
+ schedule_name = excluded.schedule_name,
24
+ enabled = excluded.enabled,
25
+ next_run_at = excluded.next_run_at,
26
+ payload = excluded.payload,
27
+ updated_at = excluded.updated_at`,s(e))});return this.writeQueue=t.catch(()=>{}),await t,await this.getLocalAgentSchedule(e.id)??e}async deleteLocalAgentSchedulesNotIn(e,t){await this.ready;let a=this.writeQueue.then(async()=>{if(t.length===0){await this.run("DELETE FROM local_agent_schedules WHERE local_project_id = ?",[e]);return}let n=t.map(()=>"?").join(", ");await this.run(`DELETE FROM local_agent_schedules
28
+ WHERE local_project_id = ?
29
+ AND id NOT IN (${n})`,[e,...t])});this.writeQueue=a.catch(()=>{}),await a}async patchLocalAgentSchedule(e,t){await this.ready;let a=null,n=this.writeQueue.then(async()=>{let l=await this.get("SELECT * FROM local_agent_schedules WHERE id = ?",[e]);l&&(a=t(c(l)),await this.run(`UPDATE local_agent_schedules
30
+ SET enabled = ?,
31
+ next_run_at = ?,
32
+ payload = ?,
33
+ updated_at = ?
34
+ WHERE id = ?`,[a.enabled?1:0,a.nextRunAt,JSON.stringify(a),a.updatedAt,e]))});return this.writeQueue=n.catch(()=>{}),await n,a}async insertLocalAgentScheduleRun(e){await this.ready;let t=this.writeQueue.then(async()=>{await this.run(`INSERT INTO local_agent_schedule_runs (
35
+ id,
36
+ schedule_id,
37
+ local_project_id,
38
+ schedule_name,
39
+ scheduled_for,
40
+ trigger,
41
+ status,
42
+ payload,
43
+ created_at,
44
+ updated_at
45
+ )
46
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,o(e))});return this.writeQueue=t.catch(()=>{}),await t,await this.getLocalAgentScheduleRun(e.id)??e}async getLocalAgentScheduleRun(e){await this.ready,await this.writeQueue;let t=await this.get("SELECT * FROM local_agent_schedule_runs WHERE id = ?",[e]);return t?u(t):null}async listLocalAgentScheduleRuns(e,t=25){return await this.ready,await this.writeQueue,(await this.all(`SELECT * FROM local_agent_schedule_runs
47
+ WHERE schedule_id = ?
48
+ ORDER BY created_at DESC
49
+ LIMIT ?`,[e,Math.max(1,Math.min(100,Math.trunc(t)))])).map(u)}async patchLocalAgentScheduleRun(e,t){await this.ready;let a=null,n=this.writeQueue.then(async()=>{let l=await this.get("SELECT * FROM local_agent_schedule_runs WHERE id = ?",[e]);l&&(a=t(u(l)),await this.run(`UPDATE local_agent_schedule_runs
50
+ SET status = ?,
51
+ payload = ?,
52
+ updated_at = ?
53
+ WHERE id = ?`,[a.status,JSON.stringify(a),a.updatedAt,e]))});return this.writeQueue=n.catch(()=>{}),await n,a}};export{r as SqliteScheduleStore};
@@ -0,0 +1,18 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{d as _}from"./chunk-KG325WTN.js";import{d}from"./chunk-T5AACNJI.js";import{a as k}from"./chunk-KCJVFLBB.js";import"./chunk-ES2ISFJC.js";import{a as c}from"./chunk-FTQLQJQV.js";var n=class extends k{static{c(this,"SqliteSidebarFileBookmarkStore")}async listSidebarFileBookmarks(r){return await this.ready,await this.writeQueue,(await this.all(`SELECT workspace_kind, workspace_id, workspace_name, file_path, status, sort_order,
3
+ source_session_id, created_at, updated_at
4
+ FROM sidebar_file_bookmarks
5
+ WHERE scope = ?
6
+ ORDER BY CASE WHEN sort_order IS NULL THEN 1 ELSE 0 END, sort_order, updated_at DESC`,[r])).map(a=>{let o=a.workspace_kind==="sandbox"?"sandbox":"local",t=a.status==="saved_for_later"?"saved_for_later":"pinned";return{id:d({workspaceKind:o,workspaceId:a.workspace_id,path:a.file_path}),workspaceKind:o,workspaceId:a.workspace_id,workspaceName:a.workspace_name,path:a.file_path,status:t,order:a.sort_order,sourceSessionId:a.source_session_id,available:!0,createdAt:a.created_at,updatedAt:a.updated_at}})}async patchSidebarFileBookmark(r,e){if(await this.ready,e.status==="none"){let s=this.writeQueue.then(()=>this.run(`DELETE FROM sidebar_file_bookmarks
7
+ WHERE scope = ? AND workspace_kind = ? AND workspace_id = ? AND file_path = ?`,[r,e.workspaceKind,e.workspaceId,e.path]));return this.writeQueue=s.then(()=>{},()=>{}),await s,null}let a=e.status,o=null,t=this.writeQueue.then(async()=>{let s=_(),i=(await this.get(`SELECT created_at FROM sidebar_file_bookmarks
8
+ WHERE scope = ? AND workspace_kind = ? AND workspace_id = ? AND file_path = ?`,[r,e.workspaceKind,e.workspaceId,e.path]))?.created_at??s;await this.run(`INSERT INTO sidebar_file_bookmarks (
9
+ scope, workspace_kind, workspace_id, workspace_name, file_path, status,
10
+ sort_order, source_session_id, created_at, updated_at
11
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
12
+ ON CONFLICT(scope, workspace_kind, workspace_id, file_path)
13
+ DO UPDATE SET
14
+ workspace_name = excluded.workspace_name,
15
+ status = excluded.status,
16
+ sort_order = excluded.sort_order,
17
+ source_session_id = COALESCE(excluded.source_session_id, sidebar_file_bookmarks.source_session_id),
18
+ updated_at = excluded.updated_at`,[r,e.workspaceKind,e.workspaceId,e.workspaceName,e.path,a,e.order??null,e.sourceSessionId??null,i,s]),o={id:d(e),workspaceKind:e.workspaceKind,workspaceId:e.workspaceId,workspaceName:e.workspaceName,path:e.path,status:a,order:e.order??null,sourceSessionId:e.sourceSessionId??null,available:!0,createdAt:i,updatedAt:s}});return this.writeQueue=t.catch(()=>{}),await t,o}};export{n as SqliteSidebarFileBookmarkStore};
@@ -0,0 +1,16 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import"./chunk-N73MU2C3.js";import{d}from"./chunk-KG325WTN.js";import{a as p}from"./chunk-KCJVFLBB.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import{a as s}from"./chunk-FTQLQJQV.js";function c(a){let r=!!a.pinned,n=r?!1:!!a.archived,t=typeof a.order=="number"&&Number.isFinite(a.order)?a.order:void 0;return{pinned:r,archived:n,...t===void 0?{}:{order:t}}}s(c,"normalizeSidebarAppPreference");var u=class extends p{static{s(this,"SqliteSidebarPreferenceStore")}async getSidebarAppPreferences(r){await this.ready,await this.writeQueue;let n=await this.all(`SELECT app_id, pinned, archived, sort_order
3
+ FROM sidebar_app_preferences
4
+ WHERE scope = ?`,[r]),t={};for(let e of n)t[e.app_id]={pinned:e.pinned===1,archived:e.archived===1,...e.sort_order===null?{}:{order:e.sort_order}};return t}async patchSidebarAppPreference(r,n,t){await this.ready;let e={},i=this.writeQueue.then(async()=>{let o=await this.get(`SELECT app_id, pinned, archived, sort_order
5
+ FROM sidebar_app_preferences
6
+ WHERE scope = ? AND app_id = ?`,[r,n]),f=o?{pinned:o.pinned===1,archived:o.archived===1,...o.sort_order===null?{}:{order:o.sort_order}}:{};e=c({...f,...t}),await this.run(`INSERT INTO sidebar_app_preferences (scope, app_id, pinned, archived, sort_order, updated_at)
7
+ VALUES (?, ?, ?, ?, ?, ?)
8
+ ON CONFLICT(scope, app_id)
9
+ DO UPDATE SET
10
+ pinned = excluded.pinned,
11
+ archived = excluded.archived,
12
+ sort_order = excluded.sort_order,
13
+ updated_at = excluded.updated_at`,[r,n,e.pinned?1:0,e.archived?1:0,e.order??null,d()])});return this.writeQueue=i.catch(()=>{}),await i,e}async reorderSidebarApps(r,n){await this.ready;let t=this.writeQueue.then(async()=>{let e=d();await this.exec("BEGIN IMMEDIATE");try{for(let[i,o]of n.entries())await this.run(`INSERT INTO sidebar_app_preferences (scope, app_id, pinned, archived, sort_order, updated_at)
14
+ VALUES (?, ?, 0, 0, ?, ?)
15
+ ON CONFLICT(scope, app_id)
16
+ DO UPDATE SET sort_order = excluded.sort_order, updated_at = excluded.updated_at`,[r,o,i,e]);await this.exec("COMMIT")}catch(i){throw await this.exec("ROLLBACK"),i}});return this.writeQueue=t.catch(()=>{}),await t,this.getSidebarAppPreferences(r)}};export{u as SqliteSidebarPreferenceStore};
@@ -0,0 +1,67 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{a as o}from"./chunk-7PXZ4X4P.js";import{d}from"./chunk-KG325WTN.js";import{b as u,c as l,d as c,e as _}from"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-DIO5CB6U.js";import{a as h}from"./chunk-KCJVFLBB.js";import{C as g,z as r}from"./chunk-Z4Z5UOZM.js";import"./chunk-FFRFSDBM.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import{a as p}from"./chunk-FTQLQJQV.js";var S=["queued","running","needs_resume"],R=class extends h{static{p(this,"SqliteSubagentStore")}async getPersistedSubagentRun(t){await this.ready;let s=await this.persistedLifecycleRow("SELECT * FROM subagent_runs WHERE id = ?",[t]);return s?u(s):null}async upsertPersistedSubagentRun(t){await this.ready;let s=r.parse(t),n=d(),a=o(this.storePath);try{a.run(`INSERT INTO subagent_runs (
3
+ id,
4
+ parent_session_id,
5
+ parent_turn_id,
6
+ child_session_id,
7
+ role_id,
8
+ status,
9
+ payload,
10
+ created_at,
11
+ updated_at
12
+ )
13
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
14
+ ON CONFLICT(id)
15
+ DO UPDATE SET
16
+ parent_session_id = excluded.parent_session_id,
17
+ parent_turn_id = excluded.parent_turn_id,
18
+ child_session_id = excluded.child_session_id,
19
+ role_id = excluded.role_id,
20
+ status = excluded.status,
21
+ payload = excluded.payload,
22
+ updated_at = excluded.updated_at`,l(s,n))}finally{a.close()}return s}async persistedLifecycleRow(t,s){let n=o(this.storePath);try{return n.get(t,s)}finally{n.close()}}async upsertSubagentRun(t){await this.ready;let s=r.parse(t),n=d(),a=this.writeQueue.then(async()=>{await this.run(`INSERT INTO subagent_runs (
23
+ id,
24
+ parent_session_id,
25
+ parent_turn_id,
26
+ child_session_id,
27
+ role_id,
28
+ status,
29
+ payload,
30
+ created_at,
31
+ updated_at
32
+ )
33
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
34
+ ON CONFLICT(id)
35
+ DO UPDATE SET
36
+ parent_session_id = excluded.parent_session_id,
37
+ parent_turn_id = excluded.parent_turn_id,
38
+ child_session_id = excluded.child_session_id,
39
+ role_id = excluded.role_id,
40
+ status = excluded.status,
41
+ payload = excluded.payload,
42
+ updated_at = excluded.updated_at`,l(s,n))});return this.writeQueue=a.catch(()=>{}),await a,s}async recordRetainedWorkspaceExpiryWarning(t,s){await this.ready;let n=null,a=this.writeQueue.then(async()=>{let i=await this.get("SELECT * FROM subagent_runs WHERE id = ?",[t]);if(!i)return;let e=u(i);n=r.parse({...e,metadata:{...e.metadata??{},retainedWorkspaceExpiryWarning:s}}),await this.run(`UPDATE subagent_runs
43
+ SET payload = ?
44
+ WHERE id = ?`,[JSON.stringify(n),t])});return this.writeQueue=a.catch(()=>{}),await a,n}async getSubagentRun(t){await this.ready,await this.writeQueue;let s=await this.get("SELECT * FROM subagent_runs WHERE id = ?",[t]);return s?u(s):null}async listSubagentRuns(t={}){await this.ready,await this.writeQueue;let s=[],n=[];if(t.parentSessionId&&(s.push("parent_session_id = ?"),n.push(t.parentSessionId)),t.childSessionId&&(s.push("child_session_id = ?"),n.push(t.childSessionId)),t.status){let e=Array.isArray(t.status)?t.status:[t.status];e.length===1?(s.push("status = ?"),n.push(e[0])):e.length>1&&(s.push(`status IN (${e.map(()=>"?").join(", ")})`),n.push(...e))}let a=t.limit===void 0?"":"LIMIT ?";return t.limit!==void 0&&n.push(Math.max(1,Math.min(1e3,Math.trunc(t.limit)))),(await this.all(`SELECT * FROM subagent_runs
45
+ ${s.length?`WHERE ${s.join(" AND ")}`:""}
46
+ ORDER BY updated_at DESC, created_at DESC
47
+ ${a}`,n)).map(u)}async listActiveSubagentRuns(t={}){return this.listSubagentRuns({...t,status:t.status??S})}async listSubagentRunScopes(t={}){await this.ready,await this.writeQueue;let s=[],n=[];if(t.status){let e=Array.isArray(t.status)?t.status:[t.status];e.length===1?(s.push("status = ?"),n.push(e[0])):e.length>1&&(s.push(`status IN (${e.map(()=>"?").join(", ")})`),n.push(...e))}t.updatedAtFrom&&(s.push("updated_at >= ?"),n.push(t.updatedAtFrom));let a=t.limit===void 0?"":"LIMIT ?";return t.limit!==void 0&&n.push(Math.max(1,Math.min(1e3,Math.trunc(t.limit)))),(await this.all(`SELECT parent_session_id
48
+ FROM subagent_runs
49
+ ${s.length?`WHERE ${s.join(" AND ")}`:""}
50
+ GROUP BY parent_session_id
51
+ ORDER BY MAX(updated_at) DESC
52
+ ${a}`,n)).map(e=>({parentSessionId:e.parent_session_id}))}async listStaleSubagentRuns(t){await this.ready,await this.writeQueue;let s=Date.parse(t.nowIso??d()),n=new Date(s-Math.max(0,Math.trunc(t.olderThanMs))).toISOString(),a=["updated_at <= ?"],i=[n];t.parentSessionId&&(a.push("parent_session_id = ?"),i.push(t.parentSessionId)),t.childSessionId&&(a.push("child_session_id = ?"),i.push(t.childSessionId));let e=t.status?Array.isArray(t.status)?t.status:[t.status]:S;e.length===1?(a.push("status = ?"),i.push(e[0])):e.length>1&&(a.push(`status IN (${e.map(()=>"?").join(", ")})`),i.push(...e));let m=t.limit===void 0?"":"LIMIT ?";return t.limit!==void 0&&i.push(Math.max(1,Math.min(1e3,Math.trunc(t.limit)))),(await this.all(`SELECT * FROM subagent_runs
53
+ WHERE ${a.join(" AND ")}
54
+ ORDER BY updated_at ASC, created_at ASC
55
+ ${m}`,i)).map(u)}async appendSubagentMessage(t){await this.ready;let s=g.parse(t),n=this.writeQueue.then(async()=>{await this.run(`INSERT INTO subagent_messages (
56
+ id,
57
+ from_run_id,
58
+ to_run_id,
59
+ to_role,
60
+ kind,
61
+ payload,
62
+ created_at
63
+ )
64
+ VALUES (?, ?, ?, ?, ?, ?, ?)`,_(s))});return this.writeQueue=n.catch(()=>{}),await n,s}async listSubagentMessages(t={}){await this.ready,await this.writeQueue;let s=[],n=[];t.fromRunId&&(s.push("from_run_id = ?"),n.push(t.fromRunId)),t.toRunId&&(s.push("to_run_id = ?"),n.push(t.toRunId)),t.toRole&&(s.push("to_role = ?"),n.push(t.toRole));let a=t.limit===void 0?"":"LIMIT ?";return t.limit!==void 0&&n.push(Math.max(1,Math.min(1e3,Math.trunc(t.limit)))),(await this.all(`SELECT * FROM subagent_messages
65
+ ${s.length?`WHERE ${s.join(" AND ")}`:""}
66
+ ORDER BY created_at ASC
67
+ ${a}`,n)).map(c)}};export{R as SqliteSubagentStore};
@@ -0,0 +1,33 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import{b as J,e as Ee,f as ge,i as he,j as ye}from"./chunk-YY7LEQGP.js";import{A as m,B as ue,D as ce,E as k,F as le,b as W,f as oe,t as H,u as ae,w as de,x as pe}from"./chunk-3RCRSMWZ.js";import{c as _e}from"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import{a as se,c as x}from"./chunk-PSGGOZFM.js";import{Da as C,Ea as g,Fa as F,G as q,H as ee,Sa as ne,Ta as ie,Ua as L,Wa as re,Xa as O,b as A,rb as U,sa as te}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{p as E,q as Z}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as G}from"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import{z as b}from"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import{b as D}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as u}from"./chunk-FTQLQJQV.js";import{createPublicKey as Ae,verify as Ce}from"node:crypto";var me=`CREATE TABLE IF NOT EXISTS remote_device_authority (id INTEGER PRIMARY KEY CHECK(id=1), payload TEXT NOT NULL);
3
+ CREATE TABLE IF NOT EXISTS remote_device_receipts (id TEXT PRIMARY KEY, payload_hash TEXT NOT NULL, command TEXT NOT NULL, receipt TEXT NOT NULL);
4
+ CREATE TABLE IF NOT EXISTS remote_device_approval_claims (approval_id TEXT PRIMARY KEY, command_id TEXT NOT NULL UNIQUE);
5
+ CREATE TABLE IF NOT EXISTS remote_device_cancellations (id TEXT PRIMARY KEY,payload_hash TEXT NOT NULL,device_id TEXT NOT NULL);`;function P(s,e,t){let n=s.get("SELECT payload_hash FROM remote_device_cancellations WHERE id=?",[e.id]);if(n)throw new Error(n.payload_hash===e.payloadHash?"remote_command_cancelled":"remote_command_identity_changed");let i=s.get("SELECT payload FROM remote_device_authority WHERE id=1");if(!i)throw new Error("remote_authority_unavailable");let r=JSON.parse(i.payload),o=Date.now();if(e.actor!=="remote-human"||r.deviceId!==e.deviceId||r.fence!==e.fence||r.grantRevision!==e.grantRevision||!(Date.parse(r.leaseExpiresAt)>o)||!(Date.parse(e.deadline)>o)||!(Date.parse(e.permit.expiresAt)>o))throw new Error("remote_authority_expired_or_changed");let a=se.parse(r.owner);if(q(e.scope)!==q({installationId:a.installationId,profileId:a.profileId,ownerUserId:a.ownerUserId,teamId:a.teamId})||!x(t,a))throw new Error("remote_task_not_owned");let d=r.publicKeys.find(I=>I.keyId===e.permit.keyId),{permit:p,...c}=e;if(!d||!Ce(null,Buffer.from(ee(c,p.expiresAt,p.keyId)),Ae(d.publicKey),Buffer.from(p.signature,"base64")))throw new Error("remote_permit_invalid");if(e.action==="start"){let I=t.metadata?.remoteStarterSourceSessionId,T=typeof I=="string"?s.get("SELECT payload FROM sessions WHERE id=?",[I]):null,l=T?JSON.parse(T.payload):null,N=W(t);if(!l||!x(l,a)||l.archived||l.status==="closed"||e.payload.projectId!==l.localProjectId||e.payload.starterRevision!==J(l)||e.expectedRevision!==J(l)||N?.operationId!==e.id||N.payloadHash!==e.payloadHash)throw new Error("remote_starter_changed");return}let _=s.get("SELECT id FROM turns WHERE session_id=? ORDER BY sort_index DESC LIMIT 1",[t.id]),w=Number.parseInt(H(t,_?.id??null).slice(0,13),16);if(e.localSessionId!==t.id||w!==e.expectedRevision)throw new Error("remote_target_changed")}u(P,"assertRemoteAdmission");import{isDeepStrictEqual as Le}from"node:util";function S(s){return L.parse({...JSON.parse(s.payload),sequence:s.sequence})}u(S,"inputFromRow");function R(s,e){let t=s.get("SELECT sequence, payload FROM task_inputs WHERE id = ?",[e]);return t?S(t):null}u(R,"readTaskInput");function h(s,e){let t=L.parse(e);return s.run("UPDATE task_inputs SET kind = ?, state = ?, turn_id = ?, payload = ? WHERE id = ?",[t.kind,t.state,t.turnId,JSON.stringify(t),t.id]),t}u(h,"writeTaskInput");function y(s,e){return s.get("SELECT * FROM task_inbox_turns WHERE session_id = ?",[e])}u(y,"readInboxOwner");function f(s,e,t,n){let i=y(s,e);if(!i||i.turn_id!==t||i.owner_id!==n||i.lease_until<=Date.now())throw new Error("Task execution ownership was lost. Stop before dispatching more work.");return i}u(f,"requireInboxOwner");function j(s,e,t){let n=y(s,e),i=t?s.get("SELECT status FROM turns WHERE id = ? AND session_id = ?",[t,e]):null;if(!t||!n||n.turn_id!==t||!n.accepting||n.paused||n.lease_until<=Date.now()||i?.status!=="in_progress")throw new Error("The expected turn is no longer accepting input. Your text was not sent to a different turn; send it as a follow-up instead.")}u(j,"assertSteerTarget");function B(s,e){let t=`${e.senderKind}:${e.senderSessionId??"user"}`,n=s.get("SELECT sequence, payload, admission FROM task_inputs WHERE session_id = ? AND sender_key = ? AND idempotency_key = ?",[e.sessionId,t,e.idempotencyKey]);if(n){let _=S(n),w=JSON.parse(n.admission);if(["kind","body","payload","replyTo","expectedTurnId"].some(T=>!Le(w[T],e[T])))throw new Error("This input identity was already used with different content.");return _}let i=s.get("SELECT payload FROM sessions WHERE id = ?",[e.sessionId]),r=i?JSON.parse(i.payload):null;if(!r||r.status==="closed"||r.archived)throw new Error("The recipient task is unavailable.");if(e.payload.remoteDevice!==void 0){if(e.senderKind!=="user"||e.senderSessionId!==null)throw new Error("remote_human_input_required");P(s,e.payload.remoteDevice,r)}if(e.senderKind==="ponder"||e.payload.ponderDesktop!==void 0){let _=s.get("SELECT id FROM turns WHERE session_id = ? ORDER BY sort_index DESC LIMIT 1",[e.sessionId]);le(s,e,r,_?.id??null)}let o=e.payload.localManagedMessage;if(o&&typeof o=="object"){let _=o.targetRevision,w=s.get("SELECT id FROM turns WHERE session_id = ? ORDER BY sort_index DESC LIMIT 1",[e.sessionId]);if(typeof _!="string"||_!==oe(r,w?.id??null))throw new ge("The managed target changed before message admission. Refresh and review the message before sending.")}let a=y(s,e.sessionId);if(e.kind==="steer"&&j(s,e.sessionId,e.expectedTurnId),e.kind==="steer"&&K(s,e.expectedTurnId,e.body),s.get("SELECT count(*) AS count FROM task_inputs WHERE session_id = ? AND state = 'pending'",[e.sessionId]).count>=ne)throw new Error("The task inbox is full. Wait for delivery before sending more input.");let p=new Date().toISOString(),c=L.parse({...e,sequence:0,revision:1,state:"pending",requestIds:[],error:null,payload:{...e.payload,...e.payload.remoteDevice?{remoteDeviceExecution:de(r)}:{}},turnId:e.kind!=="queued"&&e.kind!=="followup"&&a?.accepting&&!a.paused&&a.lease_until>Date.now()?a.turn_id:null,createdAt:p,updatedAt:p});return s.run("INSERT INTO task_inputs (id, session_id, sender_key, idempotency_key, kind, state, turn_id, payload, admission) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",[c.id,c.sessionId,t,c.idempotencyKey,c.kind,c.state,c.turnId,JSON.stringify(c),JSON.stringify(e)]),R(s,c.id)}u(B,"admitTaskInput");function v(s,e,t){return s.all(`SELECT sequence, payload FROM task_inputs WHERE session_id = ? AND state = 'pending'
6
+ AND ((turn_id = ?) OR (turn_id IS NULL AND kind NOT IN ('queued', 'followup', 'steer')))
7
+ ORDER BY sequence`,[e,t]).map(S)}u(v,"pendingTaskInputs");function K(s,e,t){if(s.get(`SELECT COALESCE(SUM(length(json_extract(payload, '$.body'))), 0) AS size
8
+ FROM task_inputs WHERE turn_id = ? AND kind = 'steer' AND state NOT IN ('rejected', 'cancelled')`,[e]).size+t.length>64e3)throw new Error("This turn's correction history is full. Finish it or send the additional instructions in a new turn.")}u(K,"assertCorrectionBudget");function Se(s,e){let t=s.all("SELECT session_id, turn_id FROM task_inbox_turns WHERE owner_id <> ? AND lease_until > 0",[e]),n=new Date().toISOString();for(let i of t){let r=s.get("SELECT status FROM turns WHERE id = ?",[i.turn_id]);s.run("UPDATE task_inbox_turns SET accepting = 0, paused = ?, lease_until = 0 WHERE session_id = ?",[r?1:0,i.session_id]);let o=s.all("SELECT sequence, payload FROM task_inputs WHERE turn_id = ? AND state IN ('pending', 'included')",[i.turn_id]);for(let a of o){let d=S(a);h(s,{...d,updatedAt:n,...d.state==="included"?{error:"Execution owner stopped after inclusion. The provider outcome is uncertain; review before retrying."}:d.kind==="steer"?{state:"rejected",error:"The interrupted execution did not include this correction. Send it as a follow-up."}:{turnId:null}})}s.run("UPDATE task_input_requests SET state = 'failed' WHERE turn_id = ? AND state = 'included'",[i.turn_id]);for(let a of s.all("SELECT id, payload FROM task_waits WHERE turn_id = ? AND state = 'waiting'",[i.turn_id])){let d=O.parse(JSON.parse(a.payload));s.run("UPDATE task_waits SET state = 'unavailable', payload = ? WHERE id = ?",[JSON.stringify({...d,state:"unavailable",updatedAt:n}),a.id])}}return t.map(i=>({sessionId:i.session_id,turnId:i.turn_id}))}u(Se,"recoverTaskInboxOwners");function Te(s,e,t){if(m(e),e.intent.action!=="create"||!e.claimId||e.receipt||!["dispatching","attention"].includes(e.state))return null;let n=ue(e.id),i=s.get("SELECT payload FROM sessions WHERE id = ?",[n]);if(!i||s.get("SELECT id FROM task_inputs WHERE session_id = ? LIMIT 1",[n])||s.get("SELECT id FROM turns WHERE session_id = ? LIMIT 1",[n]))return null;let r=E.parse(JSON.parse(i.payload)),o=W(r),a=s.get("SELECT payload FROM ponder_desktop_authority WHERE id = 1");if(!a||!o||!x(r,t)||r.archived||r.status!=="idle")return null;let d=C.parse(JSON.parse(a.payload));return d.state!=="attached"||Date.parse(d.leaseExpiresAt)<=Date.now()||d.authorizationRevision!==e.origin.authorizationRevision||!Object.entries(e.origin.scope).every(([p,c])=>d.scope[p]===c)||o.operationId!==e.id||o.payloadHash!==e.payloadHash||o.sessionRevision!==H(r,null)||o.executionRevision!==ae(r)?null:te.parse({sessionId:n,creationHash:o.creationHash,sessionRevision:o.sessionRevision,executionRevision:o.executionRevision})}u(Te,"readPonderDesktopReservationResume");var Re=D.object({operation:g,receipt:g.shape.receipt.unwrap()}).strict();function M(s,e){let t=s.get("SELECT payload FROM ponder_desktop_stops WHERE operation_id = ?",[e]);return t?Re.parse(JSON.parse(t.payload)):null}u(M,"readPonderDesktopStop");function Ie(s,e){if(e=g.parse(e),m(e),e.intent.action!=="stop")throw new Error("ponder_desktop_stop_intent_invalid");let t=M(s,e.id);if(t){if(t.operation.payloadHash!==e.payloadHash)throw new Error("ponder_desktop_stop_identity_reused");return t}let n=s.get("SELECT payload FROM sessions WHERE id = ?",[e.intent.targetId]);if(!n)throw new Error("ponder_desktop_stop_target_unavailable");let i=E.parse(JSON.parse(n.payload)),r=s.get("SELECT id FROM turns WHERE session_id = ? ORDER BY sort_index DESC LIMIT 1",[i.id]);k(s,e,i,r?.id??null,e.intent.targetRevision);let o=y(s,i.id),a=s.get("SELECT status FROM turns WHERE id = ? AND session_id = ?",[e.intent.expectedTurnId,i.id]);if(!o||o.turn_id!==e.intent.expectedTurnId||o.lease_until<=Date.now()||a?.status!=="in_progress")throw new Error("ponder_desktop_stop_target_changed");let d=Re.parse({operation:e,receipt:{sessionId:i.id,sessionTitle:i.title,inputId:null,turnId:e.intent.expectedTurnId,state:"stop_requested"}});return s.run("INSERT INTO ponder_desktop_stops (operation_id, payload_hash, payload) VALUES (?, ?, ?)",[e.id,e.payloadHash,JSON.stringify(d)]),d}u(Ie,"admitPonderDesktopStop");function we(s,e,t){let n=M(s,e);if(!n)throw new Error("ponder_desktop_stop_not_found");if(n.receipt.state!=="stop_requested")return n;let i={...n,receipt:{...n.receipt,state:t}};return s.run("UPDATE ponder_desktop_stops SET payload = ? WHERE operation_id = ?",[JSON.stringify(i),e]),i}u(we,"settlePonderDesktopStop");import{createHash as We}from"node:crypto";function Oe(s){return We("sha256").update(A("POST","/ponder/desktop/result",s)).digest("hex")}u(Oe,"hash");function Y(s,e,t){let n=s.get("SELECT payload, payload_hash FROM ponder_desktop_results WHERE operation_id = ? AND turn_id = ?",[e,t]);if(!n)return null;let i=F.parse(JSON.parse(n.payload));if(i.operationId!==e||i.turnId!==t||Oe(i)!==n.payload_hash)throw new Error("ponder_desktop_committed_result_invalid");return i}u(Y,"readPonderDesktopResult");function ke(s,e){let t=F.parse(e),n=Y(s,t.operationId,t.turnId);return n||(s.run("INSERT INTO ponder_desktop_results (operation_id, turn_id, payload_hash, payload) VALUES (?, ?, ?, ?)",[t.operationId,t.turnId,Oe(t),JSON.stringify(t)]),t)}u(ke,"commitPonderDesktopResult");var fe=D.object({operation:g,receipt:g.shape.receipt.unwrap()}).strict();function Q(s,e){let t=s.get("SELECT payload, payload_hash FROM ponder_desktop_observations WHERE operation_id = ?",[e]);if(!t)return null;let n=fe.parse(JSON.parse(t.payload));if(m(n.operation),n.operation.id!==e||n.operation.payloadHash!==t.payload_hash||n.operation.intent.action!=="observe"||n.receipt.turnId!==n.operation.intent.expectedTurnId||n.receipt.sessionId!==n.operation.intent.targetId||n.receipt.inputId!==null)throw new Error("ponder_desktop_observation_record_invalid");return n}u(Q,"readPonderDesktopObservation");function De(s,e){let t=g.parse(e);if(m(t),t.intent.action!=="observe")throw new Error("ponder_desktop_observation_intent_invalid");let n=Q(s,t.id);if(n){if(n.operation.payloadHash!==t.payloadHash)throw new Error("ponder_desktop_observation_identity_reused");return n}let i=s.get("SELECT payload FROM sessions WHERE id = ?",[t.intent.targetId]);if(!i)throw new Error("ponder_desktop_observation_target_unavailable");let r=E.parse(JSON.parse(i.payload)),o=s.get("SELECT id FROM turns WHERE session_id = ? ORDER BY sort_index DESC LIMIT 1",[r.id]);k(s,t,r,o?.id??null,t.intent.targetRevision);let a=s.get("SELECT id FROM turns WHERE id = ? AND session_id = ?",[t.intent.expectedTurnId,r.id]);if(!a||o?.id!==a.id)throw new Error("ponder_desktop_observation_target_changed");let d=fe.parse({operation:t,receipt:{sessionId:r.id,sessionTitle:r.title,inputId:null,turnId:a.id,state:"observing"}});return s.run("INSERT INTO ponder_desktop_observations (operation_id, payload_hash, payload) VALUES (?, ?, ?)",[t.id,t.payloadHash,JSON.stringify(d)]),d}u(De,"admitPonderDesktopObservation");import{createHash as He}from"node:crypto";var ve=D.object({operation:g,receipt:g.shape.receipt.unwrap(),inspection:U}).strict();function Ne(s){return He("sha256").update(A("POST","/ponder/desktop/inspection",s)).digest("hex")}u(Ne,"snapshotHash");function V(s,e){let t=s.get("SELECT payload, payload_hash, snapshot_hash FROM ponder_desktop_inspections WHERE operation_id = ?",[e]);if(!t)return null;let n=ve.parse(JSON.parse(t.payload));m(n.operation);let{operation:i,receipt:r,inspection:o}=n;if(i.intent.action!=="inspect"||i.id!==e||i.payloadHash!==t.payload_hash||Ne(n)!==t.snapshot_hash||o.operationId!==e||o.payloadHash!==i.payloadHash||o.sessionId!==i.intent.targetId||o.turnId!==i.intent.expectedTurnId||r.sessionId!==o.sessionId||r.turnId!==o.turnId||r.inputId!==null||r.state!=="inspected")throw new Error("ponder_desktop_inspection_record_invalid");return n}u(V,"readPonderDesktopInspection");function xe(s,e){let t=g.parse(e);if(m(t),t.intent.action!=="inspect")throw new Error("ponder_desktop_inspection_intent_invalid");let n=V(s,t.id);if(n){if(n.operation.payloadHash!==t.payloadHash)throw new Error("ponder_desktop_inspection_identity_reused");return n}let i=s.get("SELECT payload FROM sessions WHERE id = ?",[t.intent.targetId]);if(!i)throw new Error("ponder_desktop_inspection_target_unavailable");let r=E.parse(JSON.parse(i.payload)),o=r.localProjectId??r.workspaceId??r.cwd;if(r.archived||r.systemKind||r.hiddenFromDefaultSidebar||r.status==="closed"||r.experience==="development"||["sandbox","sandbox_template","sandbox_app"].includes(r.workspaceKind??"")||t.target.kind!=="session"||t.target.id!==r.id||t.target.revision!==t.intent.targetRevision||t.target.workspaceId!==o||t.target.providerId!==r.provider||t.target.modelId!==(r.modelRef?.modelId??null))throw new Error("ponder_desktop_inspection_target_changed");let a=s.get("SELECT id, payload FROM turns WHERE session_id = ? ORDER BY sort_index DESC LIMIT 1",[r.id]);if(k(s,t,r,a?.id??null,t.intent.targetRevision),!a||a.id!==t.intent.expectedTurnId)throw new Error("ponder_desktop_inspection_target_changed");let d=Z.parse(JSON.parse(a.payload));if(d.sessionId!==r.id||d.id!==a.id)throw new Error("ponder_desktop_inspection_turn_invalid");let p=s.all(`
9
+ SELECT sequence, substr(json_extract(payload, '$.id'), 1, 201) AS id,
10
+ substr(json_extract(payload, '$.timestamp'), 1, 101) AS timestamp, name AS kind,
11
+ substr(json_extract(payload, '$.output'), 1, 4001) AS text,
12
+ substr(json_extract(payload, '$.action'), 1, 300) AS action,
13
+ json_extract(payload, '$.status') AS status,
14
+ substr(coalesce(json_extract(payload, '$.data.nativeMessageId'), json_extract(payload, '$.data.itemId')), 1, 300) AS message_id,
15
+ json_extract(payload, '$.data.nativeMessageSnapshot') AS message_snapshot
16
+ FROM events WHERE turn_id = ? AND session_id = ?
17
+ AND name IN ('assistant.delta', 'tool.started', 'tool.completed')
18
+ AND coalesce(json_extract(payload, '$.data.retainedHistory'), 0) <> 1
19
+ AND coalesce(json_extract(payload, '$.data.phase'), '') NOT IN ('reasoning', 'analysis')
20
+ ORDER BY sequence DESC LIMIT 101`,[d.id,r.id]),c=16e3,_=!1,w=p.slice(0,100).map(l=>{let N=l.text??"",$=Math.min(4e3,c),z=N.slice(0,$);return c-=z.length,_||=N.length>$,{id:l.id,sequence:l.sequence,timestamp:l.timestamp,kind:l.kind,text:z,action:l.action,status:l.status,messageId:l.message_id,messageSnapshot:l.message_snapshot===1}}).reverse(),I=U.parse({operationId:t.id,payloadHash:t.payloadHash,sessionId:r.id,sessionTitle:r.title.slice(0,300),turnId:d.id,workspaceId:o,providerId:d.modelRef?.providerId??t.target.providerId,modelId:d.modelRef?.modelId??t.target.modelId,capturedAt:new Date().toISOString(),taskStatus:d.status,taskCompletedAt:d.completedAt?new Date(d.completedAt).toISOString():null,error:d.error?.slice(0,2e3)??null,events:w,coverage:{olderEventsOmitted:p.length>100,textTruncated:_,textLimit:16e3,eventLimit:100}}),T=ve.parse({operation:t,inspection:I,receipt:{sessionId:r.id,sessionTitle:I.sessionTitle,inputId:null,turnId:d.id,state:"inspected"}});return k(s,t,r,a.id,t.intent.targetRevision),s.run("INSERT INTO ponder_desktop_inspections (operation_id, payload_hash, snapshot_hash, payload) VALUES (?, ?, ?, ?)",[t.id,t.payloadHash,Ne(T),JSON.stringify(T)]),T}u(xe,"admitPonderDesktopInspection");var X=9e4,Pe=class extends G{static{u(this,"SqliteTaskInboxStore")}async initializeRemoteDeviceStore(){return this.inboxWrite(e=>{e.exec(me),e.run("DELETE FROM remote_device_authority")})}async setRemoteDeviceAuthority(e){return this.inboxWrite(t=>{e?t.run("INSERT INTO remote_device_authority(id,payload) VALUES(1,?) ON CONFLICT(id) DO UPDATE SET payload=excluded.payload",[JSON.stringify(e)]):t.run("DELETE FROM remote_device_authority")})}async getRemoteDeviceReceipt(e){await this.ready,await this.writeQueue;let t=this.database.get("SELECT receipt FROM remote_device_receipts WHERE id=?",[e]);return t?JSON.parse(t.receipt):null}async getRemoteDeviceCancellation(e){return await this.ready,await this.writeQueue,this.database.get("SELECT payload_hash,device_id FROM remote_device_cancellations WHERE id=?",[e])}async cancelRemoteDeviceCommand(e,t){return this.inboxWrite(n=>{let i=n.get("SELECT payload_hash,receipt FROM remote_device_receipts WHERE id=?",[e]);if(i){if(i.payload_hash!==t)throw new Error("remote_command_identity_changed");return{receipt:JSON.parse(i.receipt),cancelled:!1}}let r=R(n,`remote-input:${e}`);if(r){let p=r.payload.remoteDevice;if(p.payloadHash!==t)throw new Error("remote_command_identity_changed");return{receipt:{id:e,deviceId:p.deviceId,payloadHash:t,action:p.action,targetId:p.targetId,localSessionId:r.sessionId,inputId:r.id,state:"admitted",revision:2,createdAt:r.createdAt,expiresAt:p.deadline},cancelled:!1}}let o=n.get("SELECT payload FROM remote_device_authority WHERE id=1");if(!o)throw new Error("remote_authority_unavailable");let a=JSON.parse(o.payload);if(!(Date.parse(a.leaseExpiresAt)>Date.now()))throw new Error("remote_authority_unavailable");let d=n.get("SELECT payload_hash FROM remote_device_cancellations WHERE id=?",[e]);if(d&&d.payload_hash!==t)throw new Error("remote_command_identity_changed");return n.run("INSERT INTO remote_device_cancellations(id,payload_hash,device_id) VALUES(?,?,?) ON CONFLICT(id) DO NOTHING",[e,t,a.deviceId]),{receipt:null,cancelled:!0}})}async saveRemoteDeviceReceipt(e,t){return this.inboxWrite(n=>{let i=n.get("SELECT payload_hash FROM remote_device_receipts WHERE id=?",[e.id]);if(i&&i.payload_hash!==e.payloadHash)throw new Error("remote_command_identity_changed");n.run("INSERT INTO remote_device_receipts(id,payload_hash,command,receipt) VALUES(?,?,?,?) ON CONFLICT(id) DO UPDATE SET receipt=excluded.receipt",[e.id,e.payloadHash,JSON.stringify(e),JSON.stringify(t)])})}async admitRemoteDeviceStop(e){return this.inboxWrite(t=>{let n=t.get("SELECT payload_hash,receipt FROM remote_device_receipts WHERE id=?",[e.id]);if(n){if(n.payload_hash!==e.payloadHash)throw new Error("remote_command_identity_changed");return JSON.parse(n.receipt)}let i=t.get("SELECT payload FROM sessions WHERE id=?",[e.localSessionId]);if(!i)throw new Error("remote_task_unavailable");let r=E.parse(JSON.parse(i.payload));P(t,e,r);let o=t.get("SELECT id,status FROM turns WHERE session_id=? ORDER BY sort_index DESC LIMIT 1",[e.localSessionId]);if(!e.expectedTurnId||o?.id!==e.expectedTurnId||o.status!=="in_progress")throw new Error("remote_turn_changed");let a={id:e.id,deviceId:e.deviceId,payloadHash:e.payloadHash,action:e.action,targetId:e.targetId,localSessionId:r.id,turnId:o.id,state:"admitted",revision:2,createdAt:new Date().toISOString(),expiresAt:e.deadline};return t.run("INSERT INTO remote_device_receipts(id,payload_hash,command,receipt) VALUES(?,?,?,?)",[e.id,e.payloadHash,JSON.stringify(e),JSON.stringify(a)]),a})}async admitRemoteDeviceApproval(e){return this.inboxWrite(t=>{let n=t.get("SELECT payload_hash,receipt FROM remote_device_receipts WHERE id=?",[e.id]);if(n){if(n.payload_hash!==e.payloadHash)throw new Error("remote_command_identity_changed");return JSON.parse(n.receipt)}let i=t.get("SELECT payload FROM sessions WHERE id=?",[e.localSessionId]);if(!i)throw new Error("remote_task_unavailable");let r=E.parse(JSON.parse(i.payload));P(t,e,r);let o=t.get("SELECT id,payload FROM turns WHERE session_id=? ORDER BY sort_index DESC LIMIT 1",[r.id]),a=o?JSON.parse(o.payload):null;if(!a||a.id!==e.expectedTurnId||a.status!=="in_progress")throw new Error("remote_turn_changed");let d=t.get("SELECT payload FROM approvals WHERE id=?",[e.expectedApprovalId]),p=d?JSON.parse(d.payload):null;if(!p||p.status!=="pending"||p.sessionId!==r.id||!p.turnId||p.turnId!==a.id&&p.turnId!==a.providerTurnId||!Ee(p))throw new Error("remote_approval_changed_or_unsupported");if(t.get("SELECT command_id FROM remote_device_approval_claims WHERE approval_id=?",[p.id]))throw new Error("remote_approval_already_claimed");t.run("INSERT INTO remote_device_approval_claims(approval_id,command_id) VALUES(?,?)",[p.id,e.id]);let _={id:e.id,deviceId:e.deviceId,payloadHash:e.payloadHash,action:e.action,targetId:e.targetId,localSessionId:r.id,approvalId:p.id,turnId:a.id,state:"admitted",revision:2,createdAt:new Date().toISOString(),expiresAt:e.deadline};return t.run("INSERT INTO remote_device_receipts(id,payload_hash,command,receipt) VALUES(?,?,?,?)",[e.id,e.payloadHash,JSON.stringify(e),JSON.stringify(_)]),_})}async admitPonderDesktopInspection(e){return this.inboxWrite(t=>xe(t,e))}async getPonderDesktopInspection(e){return await this.ready,await this.writeQueue,V(this.database,e)}async setPonderProjectSharing(e){return this.inboxWrite(t=>he(t,e))}async readPonderProjectSharing(e){return await this.ready,await this.writeQueue,ye(this.database,e)}async getPonderDesktopReservationResume(e,t){return this.inboxWrite(n=>Te(n,e,t))}async admitPonderDesktopObservation(e){return this.inboxWrite(t=>De(t,e))}async getPonderDesktopObservation(e){return await this.ready,await this.writeQueue,Q(this.database,e)}async getPonderDesktopResult(e,t){return await this.ready,await this.writeQueue,Y(this.database,e,t)}async commitPonderDesktopResult(e){return this.inboxWrite(t=>ke(t,e))}async inboxWrite(e){await this.ready;let t=this.writeQueue.then(()=>{let n=this.database;n.exec("BEGIN IMMEDIATE");try{let i=e(n);return n.exec("COMMIT"),i}catch(i){throw n.exec("ROLLBACK"),i}});return this.writeQueue=t.then(()=>{},()=>{}),t}async setPonderDesktopAuthority(e){let t=C.parse(e);if(t.state!=="attached"||Date.parse(t.leaseExpiresAt)<=Date.now())throw new Error("ponder_desktop_local_authority_invalid");return this.inboxWrite(n=>{n.run("INSERT INTO ponder_desktop_authority (id, runtime_id, payload) VALUES (1, ?, ?) ON CONFLICT(id) DO UPDATE SET runtime_id = excluded.runtime_id, payload = excluded.payload",[t.runtimeId,JSON.stringify(t)])})}async clearPonderDesktopAuthority(e){return this.inboxWrite(t=>{e?t.run("DELETE FROM ponder_desktop_authority WHERE runtime_id = ?",[e]):t.run("DELETE FROM ponder_desktop_authority")})}async admitPonderDesktopStop(e){return this.inboxWrite(t=>Ie(t,e))}async getPonderDesktopStop(e){return await this.ready,await this.writeQueue,M(this.database,e)}async settlePonderDesktopStop(e,t){return this.inboxWrite(n=>we(n,e,t))}async recoverTaskInboxOwners(e){return this.inboxWrite(t=>Se(t,e))}async hasTaskCompletion(e){return await this.ready,await this.writeQueue,!!this.database.get("SELECT turn_id FROM task_completion_outbox WHERE turn_id = ?",[e])}async taskInboxSnapshot(e){await this.ready,await this.writeQueue;let t=y(this.database,e),n=t&&t.lease_until>Date.now()&&this.database.get("SELECT status FROM turns WHERE id = ?",[t.turn_id])?.status==="in_progress",i=this.database.all(`SELECT sequence, payload FROM task_inputs WHERE session_id = ? AND (state IN ('pending', 'included')
21
+ OR sequence IN (SELECT sequence FROM task_inputs WHERE session_id = ? ORDER BY sequence DESC LIMIT 30)) ORDER BY sequence`,[e,e]);return{sessionId:e,activeTurnId:n?t.turn_id:null,acceptingInput:!!(n&&t.accepting&&!t.paused),paused:!!t?.paused,inputs:i.map(S),waits:await this.taskWaitsForSession(e)}}async declareTaskWork(e,t,n,i){return this.inboxWrite(r=>{f(r,e,t,n),r.run("INSERT INTO task_work_claims (session_id, turn_id, work_areas) VALUES (?, ?, ?) ON CONFLICT(session_id) DO UPDATE SET turn_id = excluded.turn_id, work_areas = excluded.work_areas",[e,t,JSON.stringify(i)])})}async taskWorkAreas(e){await this.ready,await this.writeQueue;let t=this.database.get("SELECT c.work_areas FROM task_work_claims c JOIN task_inbox_turns t ON c.session_id = t.session_id AND c.turn_id = t.turn_id WHERE c.session_id = ? AND t.lease_until > ?",[e,Date.now()]);return t?JSON.parse(t.work_areas):[]}async admitTaskInput(e){return this.inboxWrite(t=>B(t,e))}async admitTaskInputs(e){return this.inboxWrite(t=>e.map(n=>B(t,n)))}async rejectTaskInput(e,t,n){return this.inboxWrite(i=>{let r=R(i,e);if(r?.state==="pending"){let o=n&&r.senderKind==="ponder"?i.get("SELECT id FROM turns WHERE id = ? AND session_id = ? AND json_extract(payload, '$.metadata.taskInputId') = ?",[n,r.sessionId,r.id]):null;h(i,{...r,state:"rejected",error:t,...o?{turnId:o.id}:{},updatedAt:new Date().toISOString()})}})}async getTaskInput(e){return await this.ready,await this.writeQueue,R(this.database,e)}async taskInputsForSession(e,t={}){return await this.ready,await this.writeQueue,this.database.all(`SELECT sequence, payload FROM task_inputs WHERE session_id = ? AND sequence > ?
22
+ ${t.pendingOnly?"AND state = 'pending'":""} ORDER BY sequence LIMIT ?`,[e,t.afterSequence??0,Math.max(1,Math.min(500,t.limit??128))]).map(S)}async mutateTaskInput(e,t,n){let i=re.parse(n);return this.inboxWrite(r=>{let o=R(r,t);if(!o||o.sessionId!==e||o.senderKind!=="user")throw new Error("Queued user input not found.");if(o.state!=="pending"||o.revision!==i.expectedRevision||o.turnId)throw new Error("This input changed or has already been admitted. Refresh the queue before editing it.");if(i.action==="resume"){if(o.kind!=="queued")throw new Error("Only the user queue can be resumed here.");let a=y(r,e);if(a&&a.lease_until>Date.now())throw new Error("This task is already running.");r.run("UPDATE task_inbox_turns SET paused = 0 WHERE session_id = ?",[e])}return i.action==="steer"&&(j(r,e,i.expectedTurnId),K(r,i.expectedTurnId,o.body)),h(r,{...o,revision:o.revision+1,updatedAt:new Date().toISOString(),...i.action==="cancel"?{state:"cancelled"}:{},...i.action==="edit"?{body:i.body,payload:{...o.payload,prompt:i.body}}:{},...i.action==="steer"?{kind:"steer",expectedTurnId:i.expectedTurnId,turnId:i.expectedTurnId}:{}})})}async openTaskInboxTurn(e,t,n){return this.inboxWrite(i=>{let r=y(i,e);if(r&&r.lease_until>Date.now()&&(r.turn_id!==t||r.owner_id!==n))throw new Error("A turn is already running for this task.");i.run(`INSERT INTO task_inbox_turns (session_id, turn_id, owner_id, generation, accepting, paused, lease_until)
23
+ VALUES (?, ?, ?, ?, 1, 0, ?) ON CONFLICT(session_id) DO UPDATE SET turn_id = excluded.turn_id,
24
+ owner_id = excluded.owner_id, generation = excluded.generation, accepting = 1, paused = 0, lease_until = excluded.lease_until`,[e,t,n,(r?.generation??0)+1,Date.now()+X])})}async renewTaskInboxTurn(e,t,n){return this.inboxWrite(i=>{f(i,e,t,n),i.run("UPDATE task_inbox_turns SET lease_until = ? WHERE session_id = ?",[Date.now()+X,e])})}async pendingTaskInputs(e,t){return await this.ready,await this.writeQueue,v(this.database,e,t)}async taskAssignmentInputs(e){return await this.ready,await this.writeQueue,this.database.all("SELECT sequence, payload FROM task_inputs WHERE turn_id = ? AND kind = 'steer' AND state IN ('included', 'resolved') ORDER BY sequence",[e]).map(S)}async pauseTaskInboxTurn(e,t,n){return this.inboxWrite(i=>{f(i,e,t,n),i.run("UPDATE task_inbox_turns SET accepting = 0, paused = 1 WHERE session_id = ?",[e])})}async includeTaskInputs(e,t,n,i){return this.inboxWrite(r=>{f(r,e,t,n);let o=r.get("SELECT input_ids FROM task_input_requests WHERE request_id = ?",[i]);if(o)return JSON.parse(o.input_ids).map(p=>R(r,p));let a=ie,d=[];for(let p of v(r,e,t)){if(p.body.length>a||d.length>=32)break;a-=p.body.length,d.push(h(r,{...p,state:"included",turnId:t,requestIds:[...p.requestIds,i],updatedAt:new Date().toISOString()}))}return r.run("INSERT INTO task_input_requests (request_id, session_id, turn_id, input_ids, state, created_at) VALUES (?, ?, ?, ?, 'included', ?)",[i,e,t,JSON.stringify(d.map(p=>p.id)),new Date().toISOString()]),d})}async settleTaskInputRequest(e,t){return this.inboxWrite(n=>{let i=n.get("SELECT input_ids FROM task_input_requests WHERE request_id = ?",[e]);if(i){n.run("UPDATE task_input_requests SET state = ? WHERE request_id = ?",[t,e]);for(let r of JSON.parse(i.input_ids)){let o=R(n,r);!o||o.state!=="included"||h(n,{...o,state:t==="resolved"?"resolved":t==="replaced"?"pending":"included",error:t==="failed"?"Provider request failed after input inclusion; receipt is not evidence of a reply.":null,updatedAt:new Date().toISOString()})}}})}async sealTaskInboxTurn(e,t,n){return this.inboxWrite(i=>(f(i,e,t,n),v(i,e,t).length?!1:(i.run("UPDATE task_inbox_turns SET accepting = 0 WHERE session_id = ?",[e]),!0)))}async sealNativeTaskInboxTurn(e,t,n){return this.inboxWrite(i=>(f(i,e,t,n),i.run("UPDATE task_inbox_turns SET accepting = 0 WHERE session_id = ?",[e]),v(i,e,t).map(r=>h(i,{...r,updatedAt:new Date().toISOString(),...r.kind==="steer"?{state:"rejected",error:"The agent finished before this correction could be dispatched. Send it as a follow-up."}:{turnId:null}}))))}async closeTaskInboxTurn(e,t,n,i){return this.inboxWrite(r=>{let o=y(r,e);if(!(!o||o.turn_id!==t||o.owner_id!==n)){r.run("UPDATE task_inbox_turns SET accepting = 0, paused = CASE WHEN ? = 1 THEN 1 ELSE paused END, lease_until = 0 WHERE session_id = ?",[i==="completed"?0:1,e]);for(let a of v(r,e,t))a.kind==="steer"?h(r,{...a,state:"rejected",error:`Turn ${i} before this correction was included. Send it as a follow-up.`,updatedAt:new Date().toISOString()}):a.turnId===t&&h(r,{...a,turnId:null,updatedAt:new Date().toISOString()})}})}async taskInboxPaused(e){return await this.ready,await this.writeQueue,!!y(this.database,e)?.paused}async reserveTaskFollowup(e,t,n){return this.inboxWrite(i=>{let r=y(i,e);if(r?.paused||r&&r.lease_until>Date.now())return null;let o=i.all("SELECT sequence, payload FROM task_inputs WHERE session_id = ? AND state = 'pending' AND turn_id IS NULL AND kind IN ('queued', 'followup') ORDER BY sequence",[e]),a=null;for(let d of o){let p=S(d);if(p.senderKind==="ponder"||p.payload.remoteDevice!==void 0){let c=i.get("SELECT payload FROM sessions WHERE id = ?",[e]);try{if(!c)throw new Error("The original local task no longer exists.");ce(p,E.parse(JSON.parse(c.payload))),pe(p,E.parse(JSON.parse(c.payload)))}catch(_){return h(i,{...p,state:"rejected",error:String(_),updatedAt:new Date().toISOString()})}}a=p;break}return a?(i.run(`INSERT INTO task_inbox_turns (session_id, turn_id, owner_id, generation, accepting, paused, lease_until)
25
+ VALUES (?, ?, ?, ?, 1, 0, ?) ON CONFLICT(session_id) DO UPDATE SET turn_id = excluded.turn_id,
26
+ owner_id = excluded.owner_id, generation = excluded.generation, accepting = 1, paused = 0, lease_until = excluded.lease_until`,[e,t,n,(r?.generation??0)+1,Date.now()+X]),h(i,{...a,turnId:t,updatedAt:new Date().toISOString()})):null})}async taskInboxWakeTargets(){return await this.ready,await this.writeQueue,this.database.all(`SELECT DISTINCT i.session_id FROM task_inputs i LEFT JOIN task_inbox_turns t ON t.session_id = i.session_id
27
+ WHERE i.state = 'pending' AND i.turn_id IS NULL AND i.kind IN ('queued', 'followup')
28
+ AND COALESCE(t.paused, 0) = 0 AND COALESCE(t.lease_until, 0) <= ?`,[Date.now()]).map(e=>e.session_id)}async createTaskWait(e){let t=O.parse(e);return this.inboxWrite(n=>{let i=n.get("SELECT payload FROM task_waits WHERE id = ?",[t.id]);if(i)return O.parse(JSON.parse(i.payload));if(t.targetSessionId===t.sessionId)throw new Error("A task cannot wait for itself.");if(t.targetSessionId&&n.get(`WITH RECURSIVE dependencies(session_id) AS (
29
+ SELECT target_session_id FROM task_waits WHERE session_id = ? AND state = 'waiting'
30
+ UNION SELECT w.target_session_id FROM task_waits w JOIN dependencies d ON w.session_id = d.session_id WHERE w.state = 'waiting'
31
+ ) SELECT session_id FROM dependencies WHERE session_id = ? LIMIT 1`,[t.targetSessionId,t.sessionId]))throw new Error("This dependency would create a task wait cycle. Coordinate a different order.");return n.run("INSERT INTO task_waits (id, session_id, turn_id, target_session_id, target_turn_id, state, deadline, payload) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",[t.id,t.sessionId,t.turnId,t.targetSessionId,t.targetTurnId,t.state,t.deadline,JSON.stringify(t)]),t})}async settleTaskWait(e,t){return this.inboxWrite(n=>{let i=n.get("SELECT payload FROM task_waits WHERE id = ?",[e]);if(!i)throw new Error("Task wait not found.");let r=O.parse(JSON.parse(i.payload));if(r.state!=="waiting")return r;let o={...r,state:t,updatedAt:new Date().toISOString()};return n.run("UPDATE task_waits SET state = ?, payload = ? WHERE id = ?",[t,JSON.stringify(o),e]),o})}async taskWaitsForSession(e){return await this.ready,await this.writeQueue,this.database.all("SELECT payload FROM task_waits WHERE session_id = ? AND state = 'waiting'",[e]).map(t=>O.parse(JSON.parse(t.payload)))}async commitSubagentCompletion(e,t){let n=b.parse(e);return this.inboxWrite(i=>{let r=new Date().toISOString();i.run(`INSERT INTO subagent_runs (id, parent_session_id, parent_turn_id, child_session_id, role_id, status, payload, created_at, updated_at)
32
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET status = excluded.status,
33
+ payload = excluded.payload, updated_at = excluded.updated_at`,_e(n,r)),i.run("INSERT INTO task_completion_outbox (turn_id, run_id, payload, created_at) VALUES (?, ?, ?, ?) ON CONFLICT(turn_id) DO NOTHING",[t,n.id,JSON.stringify(n),r])})}async pendingTaskCompletions(e=""){return await this.ready,await this.writeQueue,this.database.all("SELECT turn_id, payload FROM task_completion_outbox WHERE input_id IS NULL AND turn_id > ? ORDER BY turn_id LIMIT 100",[e]).map(t=>({turnId:t.turn_id,run:b.parse(JSON.parse(t.payload))}))}async settleTaskCompletion(e,t){return this.inboxWrite(n=>{if(!R(n,t))throw new Error("Completion delivery has no durable input receipt.");n.run("UPDATE task_completion_outbox SET input_id = ? WHERE turn_id = ? AND input_id IS NULL",[t,e])})}};export{Pe as SqliteTaskInboxStore};