openpond 0.2.65 → 0.2.67
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.
- package/dist/app-server.d.ts +23 -0
- package/dist/app-server.js +1 -1
- package/dist/chunks/{acp-PHMBLRCV.js → acp-NASAJV5E.js} +1 -1
- package/dist/chunks/{acp-agent-A7GK2VSH.js → acp-agent-C3CRF6DT.js} +1 -1
- package/dist/chunks/{actions-command-VLKMHCMI.js → actions-command-BYPLSGZL.js} +1 -1
- package/dist/chunks/{app-layer-J66CQ2QN.js → app-layer-XIEZ6ALX.js} +1 -1
- package/dist/chunks/{app-server-evaluations-V6LRWDUF.js → app-server-evaluations-5YZUFXQ2.js} +1 -1
- package/dist/chunks/{app-server-harness-services-6ZRLA3YD.js → app-server-harness-services-N5F5QVZI.js} +1 -1
- package/dist/chunks/{app-server-runtime-OMR2VE6L.js → app-server-runtime-HJ2N57DL.js} +1 -1
- package/dist/chunks/{apps-IHUFERZO.js → apps-WJTW64NW.js} +1 -1
- package/dist/chunks/{chunk-ZWW227M3.js → chunk-263WS3TB.js} +1 -1
- package/dist/chunks/{chunk-HX6GXMDK.js → chunk-26ID6A5C.js} +1 -1
- package/dist/chunks/{chunk-DSJZS77R.js → chunk-2RSGVLZT.js} +4 -4
- package/dist/chunks/{chunk-L4EJ5R3B.js → chunk-2UZHLO2V.js} +1 -1
- package/dist/chunks/{chunk-QYQZQVVN.js → chunk-375PADDM.js} +1 -1
- package/dist/chunks/{chunk-FUFI4THX.js → chunk-43QYVOYA.js} +1 -1
- package/dist/chunks/{chunk-H5ML7735.js → chunk-46RMTR2Z.js} +1 -1
- package/dist/chunks/{chunk-Z2TOBS3P.js → chunk-4B7EGNYX.js} +1 -1
- package/dist/chunks/{chunk-2GJD23CM.js → chunk-4EZI4KCT.js} +1 -1
- package/dist/chunks/{chunk-DMO3UIS7.js → chunk-4JJ4RYIB.js} +1 -1
- package/dist/chunks/{chunk-UM6EQOT2.js → chunk-4NN5OLKW.js} +2 -2
- package/dist/chunks/{chunk-66HFW4OU.js → chunk-4VZJQRQI.js} +1 -1
- package/dist/chunks/{chunk-7PKTCMZ6.js → chunk-543QHE3D.js} +1 -1
- package/dist/chunks/{chunk-TVDZXDQW.js → chunk-5QOFUGYQ.js} +1 -1
- package/dist/chunks/{chunk-6S2MWJVD.js → chunk-5TPYBXWM.js} +1 -1
- package/dist/chunks/{chunk-WLZJOCLA.js → chunk-5ZNE43XC.js} +1 -1
- package/dist/chunks/{chunk-KOKBDIGR.js → chunk-6HQUIKC5.js} +1 -1
- package/dist/chunks/{chunk-3BJ7LPE3.js → chunk-6IS5OLI5.js} +1 -1
- package/dist/chunks/{chunk-VS3AMJEK.js → chunk-6LFTQBXP.js} +1 -1
- package/dist/chunks/{chunk-VD2TQCMH.js → chunk-7HAGSE7L.js} +1 -1
- package/dist/chunks/{chunk-NTM3KQ25.js → chunk-ADOCQA4D.js} +1 -1
- package/dist/chunks/{chunk-4D3CICBG.js → chunk-ATFV2NA4.js} +1 -1
- package/dist/chunks/{chunk-YU4JYWCA.js → chunk-AXO6OHJB.js} +1 -1
- package/dist/chunks/{chunk-5KJMFK65.js → chunk-AXYAEWWA.js} +1 -1
- package/dist/chunks/{chunk-Q4AXZY2P.js → chunk-B2K5WQZE.js} +1 -1
- package/dist/chunks/{chunk-ANG2YMMD.js → chunk-B7XJBP4U.js} +1 -1
- package/dist/chunks/{chunk-E2S2EMYQ.js → chunk-BBIA24GD.js} +6 -6
- package/dist/chunks/{chunk-CYQLXS2U.js → chunk-BUZ7CBJC.js} +1 -1
- package/dist/chunks/{chunk-MVPKU72J.js → chunk-CJDGLPNX.js} +1 -1
- package/dist/chunks/{chunk-ZU3YBRXS.js → chunk-CSU7RDA5.js} +1 -1
- package/dist/chunks/{chunk-JLW5BQVO.js → chunk-CWAQOFLP.js} +1 -1
- package/dist/chunks/{chunk-WKHGXLJD.js → chunk-CX7HKSQ4.js} +2 -2
- package/dist/chunks/{chunk-M5QPL5NO.js → chunk-D5OFN47Z.js} +1 -1
- package/dist/chunks/{chunk-QCJY6FTC.js → chunk-FCXDPVGJ.js} +1 -1
- package/dist/chunks/{chunk-FEQ7HNJR.js → chunk-FE2ENE3U.js} +1 -1
- package/dist/chunks/{chunk-6TRVEA3T.js → chunk-FVK4W27G.js} +1 -1
- package/dist/chunks/{chunk-7FBWUVX7.js → chunk-GC6RJBRZ.js} +1 -1
- package/dist/chunks/{chunk-5Z3AU5CL.js → chunk-H2XG5N7D.js} +1 -1
- package/dist/chunks/chunk-H6EUFJJK.js +2 -0
- package/dist/chunks/{chunk-V3S2B6WU.js → chunk-IDILAYCW.js} +1 -1
- package/dist/chunks/{chunk-KGUPAPGR.js → chunk-IF5A3XWP.js} +1 -1
- package/dist/chunks/chunk-IHAEZ73V.js +2 -0
- package/dist/chunks/{chunk-GDJ4X2ZN.js → chunk-IR2Y2VQY.js} +1 -1
- package/dist/chunks/{chunk-WBO6FQHR.js → chunk-IXZ5ZGIL.js} +1 -1
- package/dist/chunks/{chunk-67HXM6AL.js → chunk-K3LS5SK7.js} +1 -1
- package/dist/chunks/{chunk-4MQHIFZL.js → chunk-K6DB5QWG.js} +1 -1
- package/dist/chunks/{chunk-QJJNHKLT.js → chunk-KQD36SBJ.js} +1 -1
- package/dist/chunks/{chunk-LXZLLTYQ.js → chunk-LI56PPCN.js} +1 -1
- package/dist/chunks/{chunk-KAWXVMHI.js → chunk-MX7KV5DA.js} +1 -1
- package/dist/chunks/{chunk-LARJARMS.js → chunk-N54CPLVD.js} +1 -1
- package/dist/chunks/{chunk-JRGECNP3.js → chunk-OE2OOWEQ.js} +1 -1
- package/dist/chunks/{chunk-B32CW3NT.js → chunk-OY4B7Y3T.js} +1 -1
- package/dist/chunks/chunk-OYIFH2OM.js +2 -0
- package/dist/chunks/{chunk-C5B3FMV3.js → chunk-P6NQYXN6.js} +1 -1
- package/dist/chunks/{chunk-D7R2AAX2.js → chunk-QFL2VQKX.js} +1 -1
- package/dist/chunks/{chunk-Y3B6ZUE6.js → chunk-QOUOU7FE.js} +1 -1
- package/dist/chunks/{chunk-GIU3Z45P.js → chunk-QQLS5FB7.js} +1 -1
- package/dist/chunks/chunk-R5GRESW3.js +2 -0
- package/dist/chunks/{chunk-6ZTP6CUJ.js → chunk-R6MMWEH4.js} +1 -1
- package/dist/chunks/{chunk-XHBMK6LC.js → chunk-R6VI7MX5.js} +1 -1
- package/dist/chunks/{chunk-GFAI2MCJ.js → chunk-RS526BG7.js} +1 -1
- package/dist/chunks/{chunk-EVQISX7M.js → chunk-RWRKUO5D.js} +1 -1
- package/dist/chunks/{chunk-DXA2UHBE.js → chunk-SD2XDZQW.js} +1 -1
- package/dist/chunks/{chunk-S6UCVXBC.js → chunk-SODAOLAP.js} +1 -1
- package/dist/chunks/{chunk-UK5LGSGT.js → chunk-SVNEPXU3.js} +1 -1
- package/dist/chunks/{chunk-5WPMI6QX.js → chunk-TERKCK4I.js} +1 -1
- package/dist/chunks/{chunk-OKEC2EIE.js → chunk-TS5HNRZB.js} +1 -1
- package/dist/chunks/{chunk-5KWKSR4P.js → chunk-TSQ2I6XV.js} +1 -1
- package/dist/chunks/{chunk-YRDPVTEI.js → chunk-TV2LE2BD.js} +1 -1
- package/dist/chunks/chunk-U3MVH2YT.js +2 -0
- package/dist/chunks/{chunk-FS2VKOT7.js → chunk-UBTP3QWI.js} +1 -1
- package/dist/chunks/{chunk-7XOUM6RK.js → chunk-UKSSFB4Q.js} +1 -1
- package/dist/chunks/{chunk-W7NXFRHN.js → chunk-UNE52L3Y.js} +1 -1
- package/dist/chunks/{chunk-ZUT4EM64.js → chunk-UXO33ST5.js} +1 -1
- package/dist/chunks/{chunk-FHLSLOKH.js → chunk-V3ILZQER.js} +1 -1
- package/dist/chunks/chunk-V3T2OJBZ.js +33 -0
- package/dist/chunks/{chunk-QAEZNFAM.js → chunk-V5AOM5MZ.js} +1 -1
- package/dist/chunks/{chunk-LI3FTPAH.js → chunk-VEXJV5H5.js} +1 -1
- package/dist/chunks/{chunk-AF3AVDPP.js → chunk-VPAEFG7X.js} +1 -1
- package/dist/chunks/{chunk-FGOTSCSE.js → chunk-W3ZILZUL.js} +1 -1
- package/dist/chunks/{chunk-U2BD545L.js → chunk-WD6ANOLL.js} +1 -1
- package/dist/chunks/{chunk-OTUS7NTQ.js → chunk-WDKZMXIU.js} +1 -1
- package/dist/chunks/chunk-WGISITX6.js +4 -0
- package/dist/chunks/{chunk-55Q64WWF.js → chunk-XD4ZIQZ2.js} +1 -1
- package/dist/chunks/{chunk-W22KWKF6.js → chunk-XDFXKRTI.js} +1 -1
- package/dist/chunks/{chunk-GRLQHYAU.js → chunk-XEU4J4GJ.js} +1 -1
- package/dist/chunks/{chunk-IEVJLG3V.js → chunk-XGJG2ZKE.js} +1 -1
- package/dist/chunks/chunk-XHU4BZQY.js +13 -0
- package/dist/chunks/{chunk-DIDQHTAX.js → chunk-XKZ4PFMQ.js} +1 -1
- package/dist/chunks/{chunk-B666Z2NS.js → chunk-XT5WUQGT.js} +1 -1
- package/dist/chunks/{chunk-N2AV7PHV.js → chunk-YKTJPCYZ.js} +3 -3
- package/dist/chunks/{chunk-5AU5Y6KS.js → chunk-YMCF5GR2.js} +1 -1
- package/dist/chunks/{chunk-LYVHYT3L.js → chunk-YONDU5TN.js} +1 -1
- package/dist/chunks/{chunk-BTJACFU3.js → chunk-YQBL5P6R.js} +1 -1
- package/dist/chunks/{chunk-SAZTOGX6.js → chunk-YR5URT73.js} +1 -1
- package/dist/chunks/{chunk-OXRVILDW.js → chunk-ZVMQLIRA.js} +1 -1
- package/dist/chunks/{chunk-MHPCVQOE.js → chunk-ZWEY66RT.js} +1 -1
- package/dist/chunks/cli-HV32F7HD.js +2 -0
- package/dist/chunks/command-NWOZXU57.js +58 -0
- package/dist/chunks/{configuration-command-465ODYTC.js → configuration-command-ZEIBQKB3.js} +1 -1
- package/dist/chunks/{connected-app-executor-7DYMZCD7.js → connected-app-executor-DFHWNMRM.js} +1 -1
- package/dist/chunks/{connected-evidence-XPAZQRFQ.js → connected-evidence-WOM6N5HO.js} +1 -1
- package/dist/chunks/{connected-starting-assets-2YX3QVDB.js → connected-starting-assets-66Y46ZPM.js} +1 -1
- package/dist/chunks/{continual-HQCFY7GN.js → continual-TNPTWTKK.js} +1 -1
- package/dist/chunks/{core-commands-PJOGRBHJ.js → core-commands-GWRHH53F.js} +1 -1
- package/dist/chunks/{dataset-preparation-authoring-KWRTMKN6.js → dataset-preparation-authoring-WJ2XEUO7.js} +1 -1
- package/dist/chunks/{datasets-OTE2I4VT.js → datasets-XIMF54QN.js} +1 -1
- package/dist/chunks/{desktop-test-Q6REQJ7K.js → desktop-test-HF42V2EP.js} +1 -1
- package/dist/chunks/dist-T6ES2TSM.js +2 -0
- package/dist/chunks/{evaluation-coordination-KRCY2H4C.js → evaluation-coordination-WZT6FDMS.js} +1 -1
- package/dist/chunks/{experiment-improvements-7MI2VYBR.js → experiment-improvements-H35VS6XZ.js} +1 -1
- package/dist/chunks/{experiments-CNUQKJZE.js → experiments-F54C32EE.js} +1 -1
- package/dist/chunks/{experiments-signal-4N344D4Y.js → experiments-signal-ONIGTGYR.js} +1 -1
- package/dist/chunks/{help-ZUKVY6RO.js → help-O53DTZGN.js} +1 -1
- package/dist/chunks/host-profile-evaluation-tools-LMCJ3MDJ.js +2 -0
- package/dist/chunks/{host-profile-external-dataset-YRKG2GL5.js → host-profile-external-dataset-4HOXANWK.js} +1 -1
- package/dist/chunks/{hosted-app-server-composition-DWSU6ASL.js → hosted-app-server-composition-Y64A2A2B.js} +1 -1
- package/dist/chunks/{hosted-experiment-improvement-NZTPZTDH.js → hosted-experiment-improvement-B2V2WIUI.js} +1 -1
- package/dist/chunks/hosted-harness-runtime-C7I4KSDK.js +2 -0
- package/dist/chunks/{hosted-profile-candidate-3CAT3XBI.js → hosted-profile-candidate-CXPVEEYQ.js} +1 -1
- package/dist/chunks/{hosted-profile-compiler-RXU626Q6.js → hosted-profile-compiler-FGCI2VRW.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-control-CBDRKJ5J.js → hosted-profile-evaluation-control-INNUYMBD.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-inspection-CHYKDYUQ.js → hosted-profile-evaluation-inspection-UPTBRYMS.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-preparation-H5S7JZMD.js → hosted-profile-evaluation-preparation-TIQSVKLQ.js} +1 -1
- package/dist/chunks/{hosted-tasksets-AMGDDB2R.js → hosted-tasksets-7VMYOTIO.js} +1 -1
- package/dist/chunks/{human-review-HOBGC6RC.js → human-review-7XC77NQP.js} +1 -1
- package/dist/chunks/{import-Q3YRFVY7.js → import-OBAKUJPM.js} +1 -1
- package/dist/chunks/javascript-isolate-process-source-YAT3GPW4.js +2 -0
- package/dist/chunks/javascript-verifier-worker-source-LGRP74W4.js +2 -0
- package/dist/chunks/learning-3XDGIYUL.js +2 -0
- package/dist/chunks/{learning-XTY5VOTK.js → learning-CRR6NRPN.js} +1 -1
- package/dist/chunks/{local-harness-improvement-runtime-XEA73RGS.js → local-harness-improvement-runtime-UIKQSAMM.js} +1 -1
- package/dist/chunks/{local-harness-taskset-review-SW35G4DM.js → local-harness-taskset-review-6KJN3EQL.js} +1 -1
- package/dist/chunks/{model-projects-GHWCKDON.js → model-projects-HP4DELCP.js} +1 -1
- package/dist/chunks/{opchat-2LLDIWEJ.js → opchat-NWYWWIA7.js} +1 -1
- package/dist/chunks/{opchat-bounded-chat-FLDS36LU.js → opchat-bounded-chat-ICURZM6R.js} +1 -1
- package/dist/chunks/{organizations-VIFSOY6P.js → organizations-7DBQGCCV.js} +1 -1
- package/dist/chunks/{profile-KIHMW2WB.js → profile-3WZJ65CT.js} +1 -1
- package/dist/chunks/{project-action-payload-2G57RL74.js → project-action-payload-7DRABTHY.js} +1 -1
- package/dist/chunks/{project-agent-TJLQNMLA.js → project-agent-AXJOWXRU.js} +1 -1
- package/dist/chunks/{published-experiment-source-D3C2AWQD.js → published-experiment-source-YBBPLNF2.js} +1 -1
- package/dist/chunks/{refiner-profile-service-PPGGNVOV.js → refiner-profile-service-ATEFPF5O.js} +1 -1
- package/dist/chunks/{runtime-VSOOPNYN.js → runtime-XP4DEGR3.js} +1 -1
- package/dist/chunks/{sandbox-command-CQO6BEMQ.js → sandbox-command-CF2PJCFX.js} +1 -1
- package/dist/chunks/{sandbox-template-MU33IILL.js → sandbox-template-YFMHEMUQ.js} +1 -1
- package/dist/chunks/{saved-work-LAVTNKPT.js → saved-work-3OAVRBH3.js} +1 -1
- package/dist/chunks/setup-RHIMFI2Y.js +2 -0
- package/dist/chunks/{src-662QOKNP.js → src-GQPWOPYA.js} +1 -1
- package/dist/chunks/{src-CHQVWHV7.js → src-V236S6MV.js} +112 -112
- package/dist/chunks/{standalone-experiment-turn-owner-KKYIGGPF.js → standalone-experiment-turn-owner-CDRMGLWW.js} +1 -1
- package/dist/chunks/{store-chat-resources-ZWDYMDJF.js → store-chat-resources-P4EKCLSY.js} +1 -1
- package/dist/chunks/{store-continual-support-reviews-7PDLGRWF.js → store-continual-support-reviews-VVRQO2JK.js} +1 -1
- package/dist/chunks/{store-conversation-serving-WRT4N7N2.js → store-conversation-serving-YFEZYQD3.js} +1 -1
- package/dist/chunks/{store-create-improve-G46KIUVT.js → store-create-improve-2XI36AET.js} +1 -1
- package/dist/chunks/{store-datasets-O67F75BL.js → store-datasets-UFY422NG.js} +1 -1
- package/dist/chunks/{store-evaluation-results-BEPR4LVD.js → store-evaluation-results-VBH4R2U7.js} +1 -1
- package/dist/chunks/{store-harness-workspaces-PJJQ74G6.js → store-harness-workspaces-SGUEYDO2.js} +1 -1
- package/dist/chunks/{store-human-review-HJ3D7ZFA.js → store-human-review-RFCVZ3HP.js} +1 -1
- package/dist/chunks/{store-learned-preference-migration-validation-EXNRDHCO.js → store-learned-preference-migration-validation-FNBGGZU6.js} +1 -1
- package/dist/chunks/{store-learning-6P6IS7GH.js → store-learning-BFOT4QVT.js} +1 -1
- package/dist/chunks/{store-learning-credentials-EGJ2WTZI.js → store-learning-credentials-DYTMWQTC.js} +1 -1
- package/dist/chunks/{store-local-experiments-CBJA56X2.js → store-local-experiments-XPXGYXNM.js} +1 -1
- package/dist/chunks/{store-model-batch-review-YIVD7T2T.js → store-model-batch-review-J2L5JQV2.js} +1 -1
- package/dist/chunks/{store-model-configuration-T6XJJDAB.js → store-model-configuration-NJFWSYSA.js} +1 -1
- package/dist/chunks/{store-model-project-preparation-WWU5CJTV.js → store-model-project-preparation-OCLIFKI2.js} +1 -1
- package/dist/chunks/{store-preference-comparison-XQFTLMGH.js → store-preference-comparison-MZAYONCK.js} +1 -1
- package/dist/chunks/{store-task-inbox-VVXZUJIO.js → store-task-inbox-3BREANOX.js} +1 -1
- package/dist/chunks/{store-task-inventory-MQX44AI6.js → store-task-inventory-5HRZCDUT.js} +1 -1
- package/dist/chunks/{store-taskset-drafts-G3WFVN4M.js → store-taskset-drafts-BNKUVHPA.js} +1 -1
- package/dist/chunks/{store-training-DUVIDYK5.js → store-training-S3FXWLT6.js} +1 -1
- package/dist/chunks/{store-training-jobs-HHFH3V5O.js → store-training-jobs-2LCXPA7G.js} +1 -1
- package/dist/chunks/{store-training-models-C7UUZDTO.js → store-training-models-7AMKS7ZW.js} +1 -1
- package/dist/chunks/{taskset-7FQCJ55X.js → taskset-PLKWRT4X.js} +1 -1
- package/dist/chunks/{taskset-packages-NRRPON7B.js → taskset-packages-SXBLYHSP.js} +1 -1
- package/dist/chunks/{taskset-packages-RW4SFGDU.js → taskset-packages-V5T4V7YN.js} +1 -1
- package/dist/chunks/{teams-bot-D3LWA4S5.js → teams-bot-VQXUA7U4.js} +1 -1
- package/dist/chunks/{tool-learning-NGO7QHYK.js → tool-learning-47XQKELE.js} +1 -1
- package/dist/chunks/{training-XFM3OOPN.js → training-7VQNCOGH.js} +1 -1
- package/dist/chunks/{training-XILDD5RG.js → training-VKLPNCMC.js} +1 -1
- package/dist/chunks/{training-hosted-6BX2IASC.js → training-hosted-NNE6BP6S.js} +1 -1
- package/dist/chunks/training-hosted-checkpoint-evaluation-2X7RSOLC.js +2 -0
- package/dist/chunks/{training-hosted-learning-YN5VD3PW.js → training-hosted-learning-WQ2IP5FP.js} +1 -1
- package/dist/chunks/training-hosted-report-T633TNJG.js +2 -0
- package/dist/chunks/training-hosted-serving-report-VZ4SMLMG.js +2 -0
- package/dist/chunks/training-hosted-workers-Y2PO5IOA.js +2 -0
- package/dist/chunks/{training-model-start-E5MP3URL.js → training-model-start-G7YDZ7ZG.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/skills/manifest.json +1 -1
- package/dist/web/assets/App-DmEA-Lia.js +53 -0
- package/dist/web/assets/{AppDialog-BILEK4np.js → AppDialog-BvskhHE9.js} +1 -1
- package/dist/web/assets/AppTerminalPanel-ScQKJV4z.js +2 -0
- package/dist/web/assets/{AppToastContext-C-FsCKXW.js → AppToastContext-D2788RqX.js} +1 -1
- package/dist/web/assets/AppsView-B1uNg9IQ.js +1 -0
- package/dist/web/assets/{AppsView-DNHWzJb2.css → AppsView-D3vVesNd.css} +1 -1
- package/dist/web/assets/{AttachmentTypeIcon-Bh7Ft_UL.js → AttachmentTypeIcon-DVluUHuc.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-BG2MLJ9I.js → BrowserSidebar-DfVQoJHn.js} +1 -1
- package/dist/web/assets/{CartesianChart-CS6ES_XT.js → CartesianChart-DdBZ69lI.js} +1 -1
- package/dist/web/assets/{ChatTimelineEntry-Dr5X_XyN.js → ChatTimelineEntry-Bbc6HRks.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-CPJ2w67F.js → CollaborationTabs-ba6WupeJ.js} +1 -1
- package/dist/web/assets/{CommandMenu-Fe1V7NJd.js → CommandMenu-D7wTaEgl.js} +1 -1
- package/dist/web/assets/{CommunityView-DHTcmOnI.js → CommunityView-mO58f2B0.js} +1 -1
- package/dist/web/assets/{ComposerAttachments-Ck9VWD6o.js → ComposerAttachments-aO90qXYz.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-yiXO7cf8.js → ComposerCreateImproveStrip-BPUJBSyS.js} +1 -1
- package/dist/web/assets/{ConversationImportsSettings-_VLzUnHQ.js → ConversationImportsSettings-Bo836wKJ.js} +1 -1
- package/dist/web/assets/{FilePagePreview-BpcM1DfE.js → FilePagePreview-C6wIp6uX.js} +2 -2
- package/dist/web/assets/{GetStartedView-BH-WJ-rW.js → GetStartedView-CxMv8q-h.js} +1 -1
- package/dist/web/assets/{GettingStartedDialog-CdQfj7RA.js → GettingStartedDialog-CEb0cS-o.js} +1 -1
- package/dist/web/assets/{HostedModelLearningReview-C3GsOlu9.js → HostedModelLearningReview-BQIS7hkd.js} +1 -1
- package/dist/web/assets/HostedModelLearningSettings-BQ-YeFMT.js +1 -0
- package/dist/web/assets/{HtmlVisual-CH0tb3fv.js → HtmlVisual-CCuUkYT8.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-J2t9yILv.js → LabModelVersionDetailPage-BkHeVbAx.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-DdDYvfj2.js → LabSkillSidebar-CFROlATQ.js} +1 -1
- package/dist/web/assets/LabsRoute-YA9YckKj.js +101 -0
- package/dist/web/assets/MainChatThread-DpyPgGKW.js +2 -0
- package/dist/web/assets/{MainPane-Dje-hfUM.css → MainPane-BOWkynGB.css} +1 -1
- package/dist/web/assets/MainPane-WOeodByM.js +10 -0
- package/dist/web/assets/NativeSetupTerminal-fmG2c65K.js +2 -0
- package/dist/web/assets/{NativeSkillSidebar-DPYavzau.js → NativeSkillSidebar-MAJWS4mL.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-BtmvE9Sp.js → NewProjectDialog-MQiUBVx3.js} +1 -1
- package/dist/web/assets/{OutputsPage-BMRY7RK2.js → OutputsPage-DpF-aRTu.js} +1 -1
- package/dist/web/assets/{PageChrome-5VRxH6Rp.js → PageChrome-8gH2hyDb.js} +1 -1
- package/dist/web/assets/{ProjectsPage-1LHqxOMo.js → ProjectsPage-BQ98oGyu.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-D_7KgExz.js → RightChatPanelStack-Bs7A4dLs.js} +1 -1
- package/dist/web/assets/RightSidebarHomePanel-C-D4kba2.js +1 -0
- package/dist/web/assets/{ScheduledWorkPage-Dtz4zJ0T.js → ScheduledWorkPage-CGCqZz_H.js} +1 -1
- package/dist/web/assets/{SettingsView-BeDYNPcD.js → SettingsView-CqpMFLxy.js} +3 -3
- package/dist/web/assets/{TasksetDraftEditorPrimitives-CcvKO3YA.js → TasksetDraftEditorPrimitives-DJvIvzBb.js} +1 -1
- package/dist/web/assets/{TeamChatView-DaXxOkTe.js → TeamChatView-DjmIaLO1.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-CF8uB4qA.js → TerminalOverlay-D--M876l.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-DmMO7x5T.js → TrainingCreationPanel-DDUoHQHU.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-DCHbXjSx.js → TrainingDraftPanel-CwLXn3Z7.js} +1 -1
- package/dist/web/assets/{TrainingRunLineage-CwisTWs_.js → TrainingRunLineage-CtYe1KGX.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-Drt7gwRb.js → UsageSettingsSection-CGwPregx.js} +1 -1
- package/dist/web/assets/WorkSidebarPanel-C6wWuo7U.js +1 -0
- package/dist/web/assets/{WorkspaceDiffPanel-Dmbrg0-y.js → WorkspaceDiffPanel-JDOUmrC-.js} +3 -3
- package/dist/web/assets/{WorkspaceEnvironmentMenu-KEZm1gdb.js → WorkspaceEnvironmentMenu-sfL5LZeB.js} +1 -1
- package/dist/web/assets/{WorkspaceFileLocation-ChbOKrPO.js → WorkspaceFileLocation-D-ctFM4d.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-BS2JQKNQ.js → WorkspaceGitDialogs-CQ28j3R7.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-CN1hE_C4.js → WorkspaceMonacoEditor-BrZs6-EW.js} +3 -3
- package/dist/web/assets/{WorkspacePdfPreview-Clb4m0le.js → WorkspacePdfPreview-CU6PSjjN.js} +2 -2
- package/dist/web/assets/{WorkspacePresentationPreview-CwQsdvAR.js → WorkspacePresentationPreview-IjXVXpIy.js} +1 -1
- package/dist/web/assets/{app-models-Cz3yxq4x.js → app-models-CKXrDTEU.js} +1 -1
- package/dist/web/assets/{bot-BNFltD5O.js → bot-Cd761lRF.js} +1 -1
- package/dist/web/assets/{browser-sidebar-links-ZyYiYBBd.js → browser-sidebar-links-D9v2cyJa.js} +1 -1
- package/dist/web/assets/chat-resources-BUDXdoG0.js +1 -0
- package/dist/web/assets/{chevron-down-BnnT0tnM.js → chevron-down-DEbd6Ek-.js} +1 -1
- package/dist/web/assets/chevron-right-DLYNg_Oq.js +1 -0
- package/dist/web/assets/{chevron-up-BAnwJJN3.js → chevron-up-DFJJccDl.js} +1 -1
- package/dist/web/assets/chunk-GHPCQXG5-DKDBSd8H.js +9 -0
- package/dist/web/assets/chunk-GJRXJL6G-luaxRTYI.js +1 -0
- package/dist/web/assets/chunk-H3JZ3P5T-CzpTARDY.js +2 -0
- package/dist/web/assets/chunk-JDQVAG3R-C0-rh1aR.js +1 -0
- package/dist/web/assets/chunk-TLSP5JKG-BrrVo5rJ.js +1 -0
- package/dist/web/assets/chunk-XMVSQIK4-BBU7r_NH.js +1 -0
- package/dist/web/assets/client-BNjO4Xi8.js +1 -0
- package/dist/web/assets/{client-choice-storage-Iuzoszas.js → client-choice-storage-DUWsS4X0.js} +1 -1
- package/dist/web/assets/{cloud-upload-CdSXJ7ms.js → cloud-upload-CoM1FGeB.js} +1 -1
- package/dist/web/assets/{common-BMjyKlX-.js → common-CFsO2ppZ.js} +1 -1
- package/dist/web/assets/{copy-CBFg6m0d.js → copy-BGOhV6Pk.js} +1 -1
- package/dist/web/assets/{create-pipeline-CyUZrbbO.js → create-pipeline-DRR0Qeec.js} +1 -1
- package/dist/web/assets/{createLucideIcon-DF2VR6WA.js → createLucideIcon-Bv-_eGcE.js} +1 -1
- package/dist/web/assets/{cssMode-BSQUZhUO.js → cssMode-SclUkqPt.js} +1 -1
- package/dist/web/assets/{external-link-Cql9bKdv.js → external-link-CVXsNeO3.js} +1 -1
- package/dist/web/assets/{folder-open-BXdVB5J1.js → folder-open-MnOmh19D.js} +1 -1
- package/dist/web/assets/{folder-plus-Cma2HulC.js → folder-plus-BRddLBtO.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-eF--16ps.js → git-commit-horizontal-Bm4rkXug.js} +1 -1
- package/dist/web/assets/{htmlMode-aLPlQtyU.js → htmlMode-X3mQtOeh.js} +1 -1
- package/dist/web/assets/icons-CZxmQtZs.js +1 -0
- package/dist/web/assets/{image-CqKPwnBn.js → image-BViGUAiq.js} +1 -1
- package/dist/web/assets/{index-CM0IRu1U.js → index-LXNhSUEL.js} +2 -2
- package/dist/web/assets/{info-CqeYEqG0.js → info-DYPIbKKD.js} +1 -1
- package/dist/web/assets/intake-contracts-wCkD2ErR.js +1 -0
- package/dist/web/assets/{jsonMode-fu7bEcHB.js → jsonMode-BoKiIdHd.js} +1 -1
- package/dist/web/assets/loader-circle-JFgFNsP5.js +1 -0
- package/dist/web/assets/{lspLanguageFeatures-DraXQA4w.js → lspLanguageFeatures-CO2mzpy1.js} +1 -1
- package/dist/web/assets/{maximize-2-yMp8X9ts.js → maximize-2-DXZCQO0b.js} +1 -1
- package/dist/web/assets/{message-square-DbIMQqfj.js → message-square-cOCAL8J1.js} +1 -1
- package/dist/web/assets/{monaco.contribution-BQhp1CJs.js → monaco.contribution-C7CAQIKF.js} +2 -2
- package/dist/web/assets/{monaco.contribution-Bd8EqYGR.js → monaco.contribution-CVe3mWSY.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CYWKnVxQ.js → monaco.contribution-hrusiaZi.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CmbWO0tB.js → monaco.contribution-wacA5FjV.js} +2 -2
- package/dist/web/assets/{monitor-DFE2fTkT.js → monitor-B35XSAvn.js} +1 -1
- package/dist/web/assets/{paperclip-D_qsKbVs.js → paperclip-CKgDxioG.js} +1 -1
- package/dist/web/assets/{pdf-DkQRsi4n.js → pdf-Ct3M2mVw.js} +1 -1
- package/dist/web/assets/play-DzqLr7fM.js +1 -0
- package/dist/web/assets/plus-Ddp1vXnw.js +1 -0
- package/dist/web/assets/{ponder-desktop-Dm7tOkKo.js → ponder-desktop-D-zB6X4L.js} +1 -1
- package/dist/web/assets/{presentation-BN_kIBPL.js → presentation-B0S9v7ib.js} +1 -1
- package/dist/web/assets/{profile-ref-DSNkG6Ol.js → profile-ref-CCxrOCio.js} +1 -1
- package/dist/web/assets/{python-DB9pj5Hr.js → python-C0-pUUAU.js} +1 -1
- package/dist/web/assets/{refresh-cw-B27ohHfn.js → refresh-cw-D45mW-vs.js} +1 -1
- package/dist/web/assets/{requests-BCbaFiqV.js → requests-DjSt-duM.js} +1 -1
- package/dist/web/assets/{reward-checks-Bcq9ETCA.js → reward-checks-D139zwha.js} +2 -2
- package/dist/web/assets/{save-D-rwjKop.js → save-Gu4R_82E.js} +1 -1
- package/dist/web/assets/schemas-C9IwV7NS.js +64 -0
- package/dist/web/assets/{settings-D7C-Auyi.js → settings-DdonLCIN.js} +1 -1
- package/dist/web/assets/settings-lists-CFHFtO0D.js +5 -0
- package/dist/web/assets/square-Dqduqyyu.js +1 -0
- package/dist/web/assets/{square-terminal-CeoK51wH.js → square-terminal-DS3zwi6X.js} +1 -1
- package/dist/web/assets/{submit-issue-command-DZNW7Evj.js → submit-issue-command-Gk3RKrY-.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-Bs8L1gx0.js → toggleHighContrast-BnYUBgZB.js} +1 -1
- package/dist/web/assets/training-QBuGBGJd.js +2 -0
- package/dist/web/assets/{training-model-data-wHvE7xL1.js → training-model-data-CxR3xpmK.js} +1 -1
- package/dist/web/assets/{tsMode-C7EqshxC.js → tsMode-BVNyOY8h.js} +1 -1
- package/dist/web/assets/{upload-BWgjC2Jf.js → upload-ABSJxuUM.js} +1 -1
- package/dist/web/assets/{useAccountSettings-Dva1MpsJ.js → useAccountSettings-4_XfwJQi.js} +1 -1
- package/dist/web/assets/{useAgentInventory-CrjIOmvb.js → useAgentInventory-CVuamyT3.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-P-UaUKMb.js → useLocalAgentSchedules-CmwN4ohy.js} +1 -1
- package/dist/web/assets/{useQuery-Bn3KqR4r.js → useQuery-CCjwL8VI.js} +1 -1
- package/dist/web/assets/{wifi-off--mKrSPFc.js → wifi-off-DGJH7Pke.js} +1 -1
- package/dist/web/assets/{work-outputs-CK0nHe4g.js → work-outputs-CnbRtTLg.js} +1 -1
- package/dist/web/assets/{workers-p0Kn2KMK.js → workers-CjtQ2aBD.js} +1 -1
- package/dist/web/assets/x-B-_zJVOZ.js +1 -0
- package/dist/web/assets/{yaml-BeIdC4tu.js → yaml-N1KUjBZ8.js} +1 -1
- package/dist/web/index.html +1 -1
- package/docs/command-reference.md +7 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-3MVKXAH7.js +0 -2
- package/dist/chunks/chunk-G4E3WGLM.js +0 -13
- package/dist/chunks/chunk-I3NYYOSS.js +0 -2
- package/dist/chunks/chunk-JBFPTEVE.js +0 -2
- package/dist/chunks/chunk-LOIYNRBC.js +0 -33
- package/dist/chunks/chunk-MMJU6PZV.js +0 -2
- package/dist/chunks/chunk-OW3EOC5Q.js +0 -4
- package/dist/chunks/chunk-YBKDEEEH.js +0 -2
- package/dist/chunks/cli-TE7RP5H7.js +0 -2
- package/dist/chunks/command-NDHFZAKA.js +0 -13
- package/dist/chunks/dist-J4KHAVO3.js +0 -2
- package/dist/chunks/host-profile-evaluation-tools-75EPCRSZ.js +0 -2
- package/dist/chunks/hosted-harness-runtime-3AJGEIFD.js +0 -2
- package/dist/chunks/javascript-isolate-process-source-ZPQKKLR4.js +0 -2
- package/dist/chunks/javascript-verifier-worker-source-F3LSGPOY.js +0 -2
- package/dist/chunks/learning-NJLTGZFQ.js +0 -2
- package/dist/chunks/setup-HSRCZ3WR.js +0 -2
- package/dist/chunks/training-hosted-checkpoint-evaluation-UXFW33QL.js +0 -2
- package/dist/chunks/training-hosted-report-UVGTPDOK.js +0 -2
- package/dist/chunks/training-hosted-serving-report-J4YOZLRP.js +0 -2
- package/dist/chunks/training-hosted-workers-6JTDCCWA.js +0 -2
- package/dist/web/assets/App-BZuSv1XM.js +0 -53
- package/dist/web/assets/AppTerminalPanel-BvxZ8bwD.js +0 -2
- package/dist/web/assets/AppsView-BMaq5oxx.js +0 -1
- package/dist/web/assets/HostedModelLearningSettings-SSMst6dl.js +0 -1
- package/dist/web/assets/LabsRoute-MJwIjSKg.js +0 -101
- package/dist/web/assets/MainChatThread-BcwtaTDZ.js +0 -2
- package/dist/web/assets/MainPane-DDO6diPt.js +0 -10
- package/dist/web/assets/NativeSetupTerminal-BPSUFpRm.js +0 -2
- package/dist/web/assets/RightSidebarHomePanel-iznJwDMf.js +0 -1
- package/dist/web/assets/WorkSidebarPanel-BrIIRtGW.js +0 -1
- package/dist/web/assets/chat-resources-CTN4f6KC.js +0 -1
- package/dist/web/assets/chevron-right-C8K5PZj7.js +0 -1
- package/dist/web/assets/chunk-GJRXJL6G-pJp1DyJd.js +0 -9
- package/dist/web/assets/chunk-H3JZ3P5T-B0SCoPw4.js +0 -2
- package/dist/web/assets/chunk-TLSP5JKG-DZmxtX-4.js +0 -1
- package/dist/web/assets/contracts-BLiqJxBv.js +0 -1
- package/dist/web/assets/icons-c3vt7y6n.js +0 -1
- package/dist/web/assets/intake-contracts-BW0Y0C2R.js +0 -1
- package/dist/web/assets/loader-circle-pxp89T5x.js +0 -1
- package/dist/web/assets/play-BtlX2stU.js +0 -1
- package/dist/web/assets/plus-DbASL_gy.js +0 -1
- package/dist/web/assets/schemas-lO3MoWQr.js +0 -64
- package/dist/web/assets/settings-lists-DgSaJQA4.js +0 -5
- package/dist/web/assets/square-C2caJ3NG.js +0 -1
- package/dist/web/assets/training-DCdoHJ0Y.js +0 -2
- package/dist/web/assets/x-D9GTV9ke.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as Me,b as Be}from"./chunk-
|
|
2
|
+
import{a as Me,b as Be}from"./chunk-AXO6OHJB.js";import{b as Te}from"./chunk-4EZI4KCT.js";import{c as Le}from"./chunk-AN525SPP.js";import{a as te,c as ae}from"./chunk-R6VI7MX5.js";import{a as _e,b as De}from"./chunk-KQD36SBJ.js";import{b as Oe}from"./chunk-YU3C6U5V.js";import{g as Ie,j as ne}from"./chunk-4V73I4OL.js";import{q as ee,r as xe,s as Pe,t as qe}from"./chunk-LE75SVEL.js";import{d as Se,f as Ae,h as Ce}from"./chunk-AJXWJLZA.js";import{n as D}from"./chunk-RCT3O3HQ.js";import{A as C}from"./chunk-X2J2P5ZT.js";import{a as o}from"./chunk-FTQLQJQV.js";function ze(e){let t=new Map,s=new Map,r=new Map,i=new Map(e.triggers.map(a=>[L(a),a])),u=new Map(e.observations.map(a=>[L(a),a])),c=new Map(e.outcomes.map(a=>[L(a.trigger),a]));return async a=>{let[p,f,R]=await Promise.all([d(a.runRef),m(a.runRef),e.store.getSession(a.runRef)]),A=f.slice().sort((S,x)=>S.startedAt.localeCompare(x.startedAt)),w=A.find(S=>S.id===a.turnId)??await e.store.getTurn(a.turnId),T=A.findIndex(S=>S.id===a.turnId),M=T>0?A.slice(0,T):[],F=M.slice(-e.limits.maxPrecedingTurns),$=tt(F,p,e.limits.maxConversationChars),W=p.filter(S=>S.turnId===a.turnId).filter(S=>["tool.completed","validation.completed","workspace_action_result"].includes(S.name)).filter(S=>S.status==="failed"||["validation.completed","workspace_action_result"].includes(S.name)),O=r.get(a.runRef);O||(O=await Me(R?.cwd),r.set(a.runRef,O));let g=e.sourcePolicies.get(a.runRef)??null,v=H(a),_=b(a),I=_.results,E={schemaVersion:"openpond.localHarnessDeepReviewContext.v1",binding:{ownerScope:e.workspace.ownerScope,workspaceId:e.workspace.id,sourceRef:a.runRef,sourceTurn:a.turnId,admittedHarness:a.harnessRelease,observation:Q(a),refinerOutcome:v?Q(v):null,sourcePolicy:g?{policy:g.policy,state:g.state,checkedAt:g.checkedAt}:null},conversation:{precedingTurns:$,currentTurn:w?We(w,p,2e3,6e3):null},artifactDiagnostics:O.slice(0,e.limits.maxArtifactDiagnostics),events:W.slice(-e.limits.maxContextEvents).map(nt),currentResult:v?l(v):null,laterResults:I,truncation:{availablePrecedingTurns:M.length,includedPrecedingTurns:$.length,precedingTurnsTruncated:M.length>$.length,conversationChars:rt($),availableContextEvents:W.length,includedContextEvents:Math.min(W.length,e.limits.maxContextEvents),availableArtifactDiagnostics:O.length,includedArtifactDiagnostics:Math.min(O.length,e.limits.maxArtifactDiagnostics),availableLaterResults:_.total,includedLaterResults:I.length,laterResultsTruncated:_.total>I.length,sessionMissing:R===null,turnMissing:w===null}};return{...E,contentHash:D(E)}};async function d(a){let p=t.get(a);if(p)return p;let f=await e.store.runtimeEventsForSession(a);return t.set(a,f),f}async function m(a){let p=s.get(a);if(p)return p;let f=await e.store.turnsForSession(a,500);return s.set(a,f),f}function H(a){for(let p of e.triggers)if(p.observations.some(f=>L(f)===L(a)))return c.get(L(p))??null;return null}function b(a){if(!a.deterministicClass)return{results:[],total:0};let f=e.outcomes.flatMap(R=>R.createdAt<=a.createdAt?[]:(i.get(L(R.trigger))?.observations.map(T=>u.get(L(T))).filter(T=>!!T)??[]).some(T=>T.deterministicClass===a.deterministicClass)?[l(R)]:[]).sort((R,A)=>String(R.createdAt).localeCompare(String(A.createdAt)));return{results:f.slice(0,e.limits.maxLaterResults),total:f.length}}function l(a){let p=a.proposal?e.applyReceipts.filter(w=>L(w.proposal)===L(a.proposal)):[],f=a.proposal?e.advanceReceipts.filter(w=>w.proposal&&L(w.proposal)===L(a.proposal)):[],R=new Set(f.map(w=>L(w))),A=e.advanceReceipts.filter(w=>w.rollbackOf&&R.has(L(w.rollbackOf)));return{outcome:Q(a),decision:a.decision,reason:N(a.reason,1500),proposal:a.proposal,createdAt:a.createdAt,applyReceipts:p.map(w=>({...Q(w),decision:w.decision,createdAt:w.createdAt})),advanceReceipts:f.map(w=>({...Q(w),decision:w.decision,previousRelease:w.previousRelease,nextRelease:w.nextRelease,createdAt:w.createdAt})),rollbackReceipts:A.map(w=>({...Q(w),decision:w.decision,rollbackOf:w.rollbackOf,nextRelease:w.nextRelease,createdAt:w.createdAt}))}}}o(ze,"createLocalHarnessDeepReviewContextLoader");function tt(e,t,s){if(!e.length||s<=0)return[];let r=Math.max(1,Math.floor(s/(e.length*2)));return e.map(i=>We(i,t,r,r))}o(tt,"boundedConversationTurns");function We(e,t,s,r){return{id:e.id,startedAt:e.startedAt,completedAt:e.completedAt,status:e.status,error:N(e.error??"",1e3),prompt:N(e.prompt,s),assistantOutput:N(st(t,e.id),r)}}o(We,"boundedTurn");function st(e,t){return e.filter(s=>s.turnId===t&&s.name==="assistant.delta").map(s=>s.output??"").join("")}o(st,"assistantOutputForTurn");function rt(e){return e.reduce((t,s)=>t+(typeof s.prompt=="string"?s.prompt.length:0)+(typeof s.assistantOutput=="string"?s.assistantOutput.length:0),0)}o(rt,"conversationCharacterCount");function nt(e){let t=$e(e.data),s=$e(t.result);return{id:e.id,name:e.name,action:e.action??(typeof t.tool=="string"?t.tool:null),status:e.status??null,error:N(e.error??"",750),output:N(typeof s.output=="string"?s.output:e.output??"",750),stderr:N(typeof s.stderr=="string"?s.stderr:"",750),exitCode:typeof s.exitCode=="number"?s.exitCode:null,timedOut:s.timedOut===!0}}o(nt,"boundedReviewEvent");function N(e,t){if(!e||t<=0)return null;let s=e.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,"Bearer [redacted]").replace(/\b(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]");if(s.length<=t)return s;let r=`
|
|
3
3
|
[... middle omitted ...]
|
|
4
4
|
`;if(r.length>=t)return s.slice(0,t);let i=Math.max(0,t-r.length),u=Math.ceil(i/2),c=Math.floor(i/2);return`${s.slice(0,u)}${r}${s.slice(-c)}`}o(N,"boundedReviewText");function Q(e){return{id:e.id,contentHash:e.contentHash}}o(Q,"artifactRef");function L(e){return`${e.id}:${e.contentHash}`}o(L,"artifactKey");function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}o($e,"asRecord");var at=2160*60*60*1e3;async function fe(e){let t=[],s=await e.store.listHarnessRefinementCandidates(e.workspace.id),r=e.upsertReviewClaim!==!1&&e.review.classification==="harness_maintenance"?e.review.claim?.fingerprint??null:null;for(let c of s){if(c.fingerprint===r)continue;let d=ot({...e,candidate:c});d&&(await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.workspace.id,...d}),t.push(d.receipt))}let i=null;if(e.upsertReviewClaim!==!1&&e.review.classification==="harness_maintenance"&&e.review.claim){let c=await e.store.getHarnessRefinementCandidateByFingerprint(e.workspace.id,e.review.claim.fingerprint),d=it({...e,candidate:c});d?(await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.workspace.id,...d}),t.push(d.receipt),i=d.candidate):i=c}let u=await e.store.listHarnessRefinementCandidates(e.workspace.id);return e.upsertReviewClaim===!1&&(i=u.find(c=>c.status==="confirmed"&&c.sourceReviews.some(d=>d.id===e.review.id&&d.contentHash===e.review.contentHash))??null),{activeCandidate:i,candidates:u,lifecycleReceipts:t}}o(fe,"reconcileLocalHarnessRefinementCandidates");async function Ue(e){if(!["unresolved","confirmed"].includes(e.candidate.status))return e.candidate;let t=ee({...we(e.candidate),sourceReviews:V([...e.candidate.sourceReviews,z(e.review)]),relatedHarnessReleases:V([...e.candidate.relatedHarnessReleases,...e.relatedHarnessRelease?[e.relatedHarnessRelease]:[]]),lastReviewedAt:e.now,updatedAt:e.now,resolution:null}),s=ie({before:e.candidate,candidate:t,review:e.review,decision:"merged",addedEvidence:[],removedEvidence:[],reason:e.reason,now:e.now});return await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.candidate.workspaceRef,...s}),t}o(Ue,"recordAppliedLocalHarnessRefinementCandidate");async function Fe(e){if(e.candidate.status!=="confirmed")throw new Error("Later-success resolution requires a confirmed candidate.");let t=e.review.harnessRelease,s=e.candidate.relatedHarnessReleases.at(-1);if(e.candidate.relatedHarnessReleases.length<2||!s||s.id!==t.id||s.contentHash!==t.contentHash)throw new Error("Later-success evidence is not bound to the candidate's applied Harness release.");let r=new Set(e.candidate.occurrences.map(d=>d.sourceRef)),i=e.evidence.filter(d=>!r.has(d.sourceRef));if(i.length===0)throw new Error("Later-success resolution requires evidence from an independent work source.");let u=ee({...we(e.candidate),status:"resolved",sourceReviews:V([...e.candidate.sourceReviews,z(e.review)]),lastReviewedAt:e.now,updatedAt:e.now,resolution:{kind:"later_success",reason:e.reason,evidenceRefs:V(i.map(d=>d.evidence)),resolvedAt:e.now}}),c=ie({before:e.candidate,candidate:u,review:e.review,decision:"resolved",addedEvidence:i,removedEvidence:[],reason:e.reason,now:e.now});return await e.store.saveHarnessRefinementCandidateTransition({workspaceId:e.candidate.workspaceRef,...c}),u}o(Fe,"resolveLocalHarnessRefinementCandidateFromLaterSuccess");function ot(e){if(!["unresolved","confirmed"].includes(e.candidate.status))return null;let t=[],s=oe(e.candidate.occurrences,e.sourcePolicies,t),r=oe(e.candidate.counterevidence,e.sourcePolicies,t),i=V([...e.candidate.sourceReviews,z(e.review)]),u=Date.parse(e.candidate.expiresAt)<=Date.parse(e.now),c=s.length===0,d=c?"rejected":u?"expired":t.length>0?"unresolved":e.candidate.status,m=c?"rejected":u?"expired":"merged";if(!(t.length>0||e.candidate.lastReviewedAt!==e.now||e.candidate.sourceReviews.length!==i.length)&&!u)return null;let b=c?"All supporting occurrences were revoked, deleted, expired, or unavailable at review time.":u?"The bounded candidate lifetime elapsed without sufficient confirming evidence.":"Candidate evidence was reauthorized against the current source policy set.",l=ee({...we(e.candidate),status:d,occurrences:s,counterevidence:r,sourceReviews:i,lastReviewedAt:e.now,updatedAt:e.now,expiresAt:u?e.now:e.candidate.expiresAt,resolution:c||u?{kind:c?"source_revoked":"expired",reason:b,evidenceRefs:t.map(a=>a.evidence),resolvedAt:e.now}:null});return ie({before:e.candidate,candidate:l,review:e.review,decision:m,addedEvidence:[],removedEvidence:t.map(a=>a.evidence),reason:b,now:e.now})}o(ot,"reauthorizeOrExpireCandidate");function it(e){let t=e.review.claim,s=e.candidate,r=[],i=s?oe(s.occurrences,e.sourcePolicies,r):[],u=s?oe(s.counterevidence,e.sourcePolicies,r):[],c=new Set(s&&["unresolved","confirmed"].includes(s.status)?i.map(f=>f.occurrenceKey):[]),d=e.review.selectedEvidence.filter(f=>!c.has(f.occurrenceKey));if(s&&d.length===0&&r.length===0&&["unresolved","confirmed"].includes(s.status))return null;let m=ct([...i,...e.review.selectedEvidence]),H=t.candidateDisposition==="confirm"?"confirmed":"unresolved",b=m.map(f=>f.occurredAt).sort()[0],l=m.map(f=>f.occurredAt).sort().at(-1),a=ee({schemaVersion:"openpond.harnessRefinementCandidate.v1",id:s?.id??`refinement-candidate-${t.fingerprint.slice(0,24)}`,ownerScope:e.workspace.ownerScope,workspaceRef:e.workspace.id,fingerprint:t.fingerprint,recurrenceFamily:t.recurrenceFamily,statement:t.statement,status:H,occurrences:m,counterevidence:u,sourceReviews:V([...s?.sourceReviews??[],z(e.review)]),relatedHarnessReleases:V([...s?.relatedHarnessReleases??[],e.review.harnessRelease]),firstSeenAt:b,lastSeenAt:l,lastReviewedAt:e.now,expiresAt:new Date(Date.parse(e.now)+at).toISOString(),resolution:null,createdAt:s?.createdAt??e.now,updatedAt:e.now}),p=s?["resolved","rejected","expired"].includes(s.status)?"reopened":"merged":"created";return ie({before:s,candidate:a,review:e.review,decision:p,addedEvidence:d,removedEvidence:r.map(f=>f.evidence),reason:p==="created"?"Created a bounded candidate from an authorized cross-Work Harness claim.":p==="reopened"?"New authorized evidence reopened the prior candidate.":"Merged new authorized evidence into the existing candidate.",now:e.now})}o(it,"upsertCandidateFromReview");function ie(e){let t=xe({schemaVersion:"openpond.harnessRefinementCandidateLifecycleReceipt.v1",id:`candidate-lifecycle-${D({candidate:z(e.candidate),review:z(e.review),decision:e.decision}).slice(0,24)}`,candidateId:e.candidate.id,decision:e.decision,beforeCandidate:e.before?z(e.before):null,afterCandidate:z(e.candidate),review:z(e.review),addedEvidence:e.addedEvidence,removedEvidence:e.removedEvidence,reason:e.reason,createdAt:e.now});return{candidate:e.candidate,receipt:t}}o(ie,"transition");function oe(e,t,s){return e.flatMap(r=>{let i=t.get(r.sourceRef);return!i||i.state!=="authorized"?(s.push(r),[]):[{...r,sourcePolicy:i}]})}o(oe,"reauthorizedEvidence");function ct(e){return[...new Map(e.map(t=>[t.occurrenceKey,t])).values()].sort((t,s)=>t.occurredAt.localeCompare(s.occurredAt)||t.occurrenceKey.localeCompare(s.occurrenceKey))}o(ct,"uniqueEvidence");function V(e){return[...new Map(e.map(t=>[`${t.id}:${t.contentHash}`,t])).values()]}o(V,"uniqueRefs");function z(e){return{id:e.id,contentHash:e.contentHash}}o(z,"artifactRef");function we(e){let{contentHash:t,...s}=e;return s}o(we,"withoutHash");var dt={memory:!0,prompt:!0,skill:!0,agent:!1};async function je(e){if(e.candidate.status!=="confirmed")return null;if(e.review.classification!=="harness_maintenance"||e.review.contentHash!==e.candidate.sourceReviews.at(-1)?.contentHash)throw new Error("Cross-run continuation requires the candidate's confirming Harness review.");let t=await e.store.getHarnessWorkspace(e.candidate.workspaceRef),s=t?.currentChannel.release??null;if(!t||t.location!=="local"||!s)throw new Error("Cross-run continuation requires an active Local Harness release.");let r=Pe({workspaceRef:t.id,candidateFingerprint:e.candidate.fingerprint,admittedHarness:s}),i=(e.now??(()=>new Date().toISOString()))(),u=qe({schemaVersion:"openpond.harnessCrossRunRefinementRequest.v1",id:`cross-run-refinement-${r.slice(0,24)}`,ownerScope:t.ownerScope,workspaceRef:t.id,candidate:ce(e.candidate),candidateFingerprint:e.candidate.fingerprint,review:ce(e.review),admittedHarness:s,evidence:e.candidate.occurrences,capabilities:dt,deduplicationKey:r,createdAt:i}),c=await e.store.saveHarnessCrossRunRefinementRequestIfAbsent({workspaceId:t.id,request:u});if(!c.created)return null;let d=await ut(e.store,t.id,c.request.evidence);if(d.length===0)throw new Error("Confirmed cross-run candidate has no verifiable source observations.");let m=`cross-run-${c.request.deduplicationKey.slice(0,24)}`,H=await Te({store:e.store,runId:m,workspace:t,harnessRelease:c.request.admittedHarness,admittedAt:c.request.createdAt}),b=lt({request:c.request,overlay:H,observations:d});await e.store.saveHarnessImprovementArtifact(t.id,"trigger_decision",b);let l=await Be({store:e.store,storeDir:e.storeDir,trigger:b,additionalEvidence:{reviewScope:"cross_run_candidate",request:c.request,candidate:e.candidate,review:e.review},reviewScope:"cross_run_candidate",stream:e.stream,signal:e.signal,now:e.now}),a=e.candidate;return l.applyReceipt?.decision==="applied"&&(a=await Ue({store:e.store,candidate:a,review:e.review,relatedHarnessRelease:l.workspace.currentChannel.release??null,reason:"The confirmed candidate produced a validated applied Harness change and now awaits independent outcome evidence.",now:(e.now??(()=>new Date().toISOString()))()})),{candidate:a,worker:l}}o(je,"continueConfirmedLocalHarnessCandidate");function lt(e){let t=e.observations.slice(0,100).map(ce);return Ie({schemaVersion:"openpond.refinementTriggerDecision.v1",id:`cross-run-trigger-${e.request.deduplicationKey.slice(0,24)}`,runRef:e.overlay.runId,turnId:`candidate-${e.request.candidate.id}`,harnessRelease:e.request.admittedHarness,overlay:{id:e.overlay.id,revision:e.overlay.revision,contentHash:e.overlay.contentHash},observations:t,decision:"queue_refiner",deterministicRoute:null,suggestedRoutes:[],reason:"A confirmed authorized cross-Work candidate is ready for one bounded Refiner continuation.",deduplicationKey:e.request.deduplicationKey,policy:{schemaVersion:"openpond.refinementTriggerPolicy.v1",maxEstimatedCostUsd:.05,cooldownMs:0,maxPendingPlans:1,maxEvidenceEvents:100,maxProposalEdits:4,maxProposalBytes:2e4},estimatedMaxCostUsd:.05,pendingPlanCount:0,boundary:{kind:"turn_completed",eventSequence:0,occurredAt:e.request.createdAt},cooldownUntil:null,createdAt:e.request.createdAt,metadata:{origin:"cross_run_candidate",crossRunRefinementRequest:ce(e.request),candidate:e.request.candidate}})}o(lt,"createCrossRunTrigger");async function ut(e,t,s){let[r,i,u,c]=await Promise.all([e.listHarnessImprovementArtifacts(t,"observation",1e3),e.listHarnessImprovementArtifacts(t,"trigger_decision",1e3),e.listHarnessImprovementArtifacts(t,"route_decision",1e3),e.listHarnessImprovementArtifacts(t,"refiner_outcome",1e3)]),d=new Map(r.map(a=>[B(a),a])),m=new Map(i.map(a=>[B(a),a])),H=new Map(u.map(a=>[B(a),a])),b=new Map(c.map(a=>[B(a),a])),l=new Map;for(let a of s){if(a.kind==="observation"){let R=d.get(B(a.evidence));R&&l.set(B(R),R);continue}let p=a.kind==="route_decision"?H.get(B(a.evidence))?.trigger:a.kind==="refiner_outcome"?b.get(B(a.evidence))?.trigger:null,f=p?m.get(B(p)):null;for(let R of f?.observations??[]){let A=d.get(B(R));A&&l.set(B(A),A)}}return[...l.values()].sort((a,p)=>a.createdAt.localeCompare(p.createdAt)||a.id.localeCompare(p.id))}o(ut,"resolveCandidateObservations");function ce(e){return{id:e.id,contentHash:e.contentHash}}o(ce,"artifactRef");function B(e){return`${e.id}:${e.contentHash}`}o(B,"artifactKey");var mt=C.object({sourceRef:C.string().trim().min(1),policy:C.object({id:C.string().trim().min(1),contentHash:C.string().regex(/^[a-f0-9]{64}$/)}).strict(),state:C.enum(["authorized","revoked","deleted","expired"]),checkedAt:C.string().datetime()}).strict(),vt=C.object({previousWatermark:Se.nullable().optional(),sourcePolicies:C.array(mt).max(1e4).default([]),limits:C.object({maxEvidence:C.number().int().min(1).max(1e3).default(200),maxTokens:C.number().int().min(1).max(1e6).default(5e4),maxDurationMs:C.number().int().min(1).max(3e5).default(24e4),maxEstimatedCostUsd:C.number().finite().nonnegative().default(.1),maxPrecedingTurns:C.number().int().min(0).max(10).default(3),maxConversationChars:C.number().int().min(0).max(1e5).default(12e3),maxContextEvents:C.number().int().min(1).max(100).default(12),maxArtifactDiagnostics:C.number().int().min(0).max(100).default(20),maxLaterResults:C.number().int().min(0).max(50).default(8)}).strict().default({maxEvidence:200,maxTokens:5e4,maxDurationMs:24e4,maxEstimatedCostUsd:.1,maxPrecedingTurns:3,maxConversationChars:12e3,maxContextEvents:12,maxArtifactDiagnostics:20,maxLaterResults:8})}).strict(),de=new WeakMap;function Qe(e){let t=de.get(e.store);if(t)return t;let s=pt(e).finally(()=>{de.get(e.store)===s&&de.delete(e.store)});return de.set(e.store,s),s}o(Qe,"reviewSelectedLocalHarnessEvaluation");async function pt(e){let t=vt.parse(e.request??{}),s=performance.now(),r=await ae(e.store);if(!r)throw new Error("No Local Harness release is selected for evaluation review.");let i=await e.store.getHarnessWorkspace(r.workspaceId);if(!i)throw new Error(`Selected Harness workspace ${r.workspaceId} does not exist.`);let[u,c,d,m,H,b,l,a]=await Promise.all([e.store.listHarnessImprovementArtifacts(i.id,"evaluation_review",1e3),e.store.listHarnessImprovementArtifacts(i.id,"route_decision",1e3),e.store.listHarnessImprovementArtifacts(i.id,"trigger_decision",1e3),e.store.listHarnessImprovementArtifacts(i.id,"observation",1e3),e.store.listHarnessImprovementArtifacts(i.id,"apply_receipt",1e3),e.store.listHarnessImprovementArtifacts(i.id,"refiner_outcome",1e3),e.store.listHarnessAdvanceReceipts(i.id),e.store.listHarnessRefinementCandidates(i.id)]),p=u[0]??null,f=t.previousWatermark??p?.nextWatermark??null,R=c,A=d,w=m,T=H,M=b,F=[...R,...w,...M];if(t.previousWatermark===void 0&&p&&!F.some(n=>n.createdAt>p.nextWatermark.throughCreatedAt)){let n=(e.now??(()=>new Date().toISOString()))(),y=await fe({store:e.store,workspace:i,review:p,sourcePolicies:new Map(t.sourcePolicies.map(k=>[k.sourceRef,J(k)])),now:n,upsertReviewClaim:!1});return await Ke({...e,candidate:y.activeCandidate,review:p}),p}let $=new Map(A.map(n=>[P(n),n])),Y=new Set(A.filter(n=>n.metadata.origin==="cross_run_candidate").map(P)),W=new Map(w.map(n=>[P(n),n])),O=new Map(t.sourcePolicies.map(n=>[n.sourceRef,n])),g=ze({store:e.store,workspace:i,sourcePolicies:O,observations:w,triggers:A,outcomes:M,applyReceipts:T,advanceReceipts:l,limits:{maxPrecedingTurns:t.limits.maxPrecedingTurns,maxConversationChars:t.limits.maxConversationChars,maxContextEvents:t.limits.maxContextEvents,maxArtifactDiagnostics:t.limits.maxArtifactDiagnostics,maxLaterResults:t.limits.maxLaterResults}}),v=[],_=[],I=new Set,E=new Set(R.map(n=>P(n.trigger)));for(let n of R){let y=$.get(P(n.trigger));if(!y){v.push({evidence:q(n),sourcePolicy:null,reason:"unverified"});continue}if(Y.has(P(y))){v.push({evidence:q(n),sourcePolicy:null,reason:"resolved"});continue}let k=y.observations.map(j=>W.get(P(j))).filter(j=>!!j);for(let j of k)I.add(P(j));_.push({id:`route_decision:${n.id}`,artifact:n,kind:"route_decision",sourceRef:k[0]?.runRef??y.runRef,payload:{routeDecision:n,trigger:y,observations:k,turnContexts:await Ve(k,g)}})}for(let n of M){if(E.has(P(n.trigger)))continue;let y=$.get(P(n.trigger));if(!y){v.push({evidence:q(n),sourcePolicy:null,reason:"unverified"});continue}if(Y.has(P(y))){v.push({evidence:q(n),sourcePolicy:null,reason:"resolved"});continue}let k=y.observations.map(K=>W.get(P(K))).filter(K=>!!K);for(let K of k)I.add(P(K));let j=n.proposal?T.filter(K=>P(K.proposal)===P(n.proposal)):[];_.push({id:`refiner_outcome:${n.id}`,artifact:n,kind:"refiner_outcome",sourceRef:k[0]?.runRef??y.runRef,payload:{outcome:n,trigger:y,observations:k,turnContexts:await Ve(k,g),applyReceipts:j}})}for(let n of w)I.has(P(n))||_.push({id:`observation:${n.id}`,artifact:n,kind:"observation",sourceRef:n.runRef,payload:{observation:n,turnContext:await g(n)}});let S=[],x=[],Z=0,ue=0;for(let n of _.slice().sort((y,k)=>y.artifact.createdAt.localeCompare(k.artifact.createdAt)||y.id.localeCompare(k.id))){if(performance.now()-s>=t.limits.maxDurationMs){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"budget"});continue}if(f&&n.artifact.createdAt<=f.throughCreatedAt){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"before_watermark"});continue}if(Z>=t.limits.maxEvidence){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"budget"});continue}Z+=1;let y=Math.ceil(JSON.stringify(n.payload).length/4);if(ue+y>t.limits.maxTokens){v.push({evidence:q(n.artifact),sourcePolicy:null,reason:"budget"});continue}ue+=y,x.push(n.artifact);let k=O.get(n.sourceRef);if(!k||k.state!=="authorized"){v.push({evidence:q(n.artifact),sourcePolicy:k?J(k):null,reason:k&&k.state!=="authorized"?k.state:"unverified"});continue}S.push(n)}let h={schemaVersion:"openpond.harnessEvaluationReviewModelDecision.v2",decision:"no_action",reason:"No authorized unresolved evidence qualified for model review.",ignoredEvidence:[]},G={promptTokens:0,completionTokens:0,totalTokens:0},se={selectedIds:null};if(S.length>0&&t.limits.maxEstimatedCostUsd===0){for(let n of S)v.push({evidence:q(n.artifact),sourcePolicy:J(O.get(n.sourceRef)),reason:"budget"});h={schemaVersion:"openpond.harnessEvaluationReviewModelDecision.v2",decision:"no_action",reason:"Continuous review is disabled by a zero model-cost ceiling.",ignoredEvidence:S.map(n=>({id:n.id,reason:"The configured model-cost ceiling is zero."}))}}else if(S.length>0){if(!e.stream)throw new Error("Harness continuous review requires a model stream.");h=await Ce({evidence:S.map(n=>({id:n.id,evidence:q(n.artifact),kind:n.kind,sourceRef:n.sourceRef,occurredAt:n.artifact.createdAt,payload:n.payload})),harnessRelease:q(r.harnessRelease),previousReviews:u.slice(0,20),candidates:a.map(n=>({id:n.id,fingerprint:n.fingerprint,statement:n.statement,status:n.status,occurrences:n.occurrences,relatedHarnessReleases:n.relatedHarnessReleases,resolution:n.resolution})),stream:o(async function*(n){let y=null;for await(let k of e.stream(n))k.usage&&(y=k.usage),yield k;y&&(G={promptTokens:G.promptTokens+y.promptTokens,completionTokens:G.completionTokens+y.completionTokens,totalTokens:G.totalTokens+y.totalTokens})},"stream"),signal:e.signal??new AbortController().signal,timeoutMs:t.limits.maxDurationMs,onNavigation:o(n=>{se.selectedIds=new Set(n.selectedEvidenceIds)},"onNavigation")})}let He=se.selectedIds?S.filter(n=>!se.selectedIds.has(n.id)):[];for(let n of He)v.push({evidence:q(n.artifact),sourcePolicy:J(O.get(n.sourceRef)),reason:"budget"});let me=h.decision==="review"||h.decision==="resolve_candidate"?h.selectedEvidenceIds.map(n=>{let y=S.find(k=>k.id===n);if(!y)throw new Error(`Review selected unavailable evidence ${n}.`);return y}):[],ve=h.decision==="review"?h.classification:"no_action",pe=me.map(n=>ft(n,O.get(n.sourceRef))),re=(e.now??(()=>new Date().toISOString()))(),Xe=new Set(He.map(n=>P(n.artifact))),he=x.filter(n=>!Xe.has(P(n))),ye=he.map(n=>n.createdAt).sort().at(-1),ke=ye?Ne(f?.throughCreatedAt,ye):Ne(f?.throughCreatedAt,re),Ee=D({previousCursor:f?.cursor??null,throughCreatedAt:ke,examined:he.map(q)}),et=`evaluation-review-${D({workspaceId:i.id,harnessRelease:r.harnessRelease,previousWatermark:f,cursor:Ee}).slice(0,24)}`,X=Ae({schemaVersion:"openpond.harnessEvaluationReviewReceipt.v1",id:et,ownerScope:i.ownerScope,workspaceRef:i.id,harnessRelease:q(r.harnessRelease),previousWatermark:f,nextWatermark:{cursor:Ee,throughCreatedAt:ke},selectedEvidence:pe,excludedEvidence:v,claim:h.decision==="review"?{fingerprint:D({schemaVersion:"openpond.harnessRefinementCandidateFingerprint.v1",classification:ve,triageLayer:h.triageLayer,recurrenceFamily:Rt(h.recurrenceFamily)}),recurrenceFamily:h.recurrenceFamily,statement:h.statement,...h.classification==="harness_maintenance"?{candidateDisposition:h.candidateDisposition}:{},independentOccurrences:new Set(me.map(n=>n.sourceRef)).size,unresolvedOccurrences:new Set(me.map(n=>n.sourceRef)).size}:null,classification:ve,triage:h.decision==="review"?[{layer:h.triageLayer,status:"unresolved",reason:h.reason,evidenceRefs:pe.map(n=>n.evidence)}]:[],reason:h.reason,nextAuthority:wt(ve),maxEstimatedCostUsd:t.limits.maxEstimatedCostUsd,tasksetProposal:null,evaluation:null,trainingQualification:null,policyVersion:"public-model-driven-harness-review-v1",createdAt:re,metadata:{examinedEvidence:Z,fullyReviewedEvidence:se.selectedIds?.size??S.length,estimatedTokens:ue,elapsedMs:performance.now()-s,explicitInvocation:!0,modelDecision:h.decision,modelConfidence:h.decision==="review"||h.decision==="resolve_candidate"?h.confidence:null,counterevidence:h.decision==="review"?h.counterevidence:null,expectedOutcome:h.decision==="review"?h.expectedOutcome:null,ignoredEvidence:h.ignoredEvidence,modelUsage:G}});await e.store.saveHarnessImprovementArtifact(i.id,"evaluation_review",X);let be=await fe({store:e.store,workspace:i,review:X,sourcePolicies:new Map(t.sourcePolicies.map(n=>[n.sourceRef,J(n)])),now:re});if(h.decision==="resolve_candidate"){let n=be.candidates.find(y=>y.id===h.candidateId&&y.fingerprint===h.candidateFingerprint);if(!n)throw new Error("Later-success decision referenced an unavailable candidate.");await Fe({store:e.store,candidate:n,review:X,evidence:pe,reason:h.reason,now:re})}return await Ke({...e,candidate:be.activeCandidate,review:X}),X}o(pt,"runSelectedLocalHarnessEvaluation");async function Ke(e){!e.continuation||e.candidate?.status!=="confirmed"||await je({store:e.store,storeDir:e.continuation.storeDir,candidate:e.candidate,review:e.review,stream:e.continuation.stream,signal:e.signal??new AbortController().signal,now:e.now})}o(Ke,"continueCandidateIfEnabled");function q(e){return{id:e.id,contentHash:e.contentHash}}o(q,"artifactRef");function P(e){return`${e.id}:${e.contentHash}`}o(P,"artifactKey");function J(e){return{policy:e.policy,state:e.state,checkedAt:e.checkedAt}}o(J,"sourcePolicyRef");function ft(e,t){return{evidence:q(e.artifact),kind:e.kind,sourceRef:e.sourceRef,sourcePolicy:J(t),occurrenceKey:D({evidence:q(e.artifact),sourceRef:e.sourceRef}),occurredAt:e.artifact.createdAt}}o(ft,"evidenceRef");function wt(e){return e==="runtime"?"runtime_service":e==="product"?"product_team":e==="taskset"||e==="harness_maintenance"?"human_review":e==="model_improvement"?"training_system":"none"}o(wt,"nextAuthority");function Ne(...e){return e.filter(t=>!!t).sort().at(-1)}o(Ne,"maxTimestamp");function Rt(e){return e.trim().toLocaleLowerCase("en-US").replace(/\s+/g," ")}o(Rt,"normalizeRecurrenceFamily");async function Ve(e,t){let s=new Map;for(let r of e)s.set(`${r.runRef}:${r.turnId}`,r);return Promise.all([...s.values()].map(t))}o(Ve,"uniqueTurnContexts");var Je="local-personal-work-v1";async function le(e){let t=await ae(e.store);if(!t||t.workspaceId!==e.workspaceId)throw new Error("Evaluation review requires the selected Personal Local Harness.");let s=await e.store.getHarnessWorkspace(e.workspaceId);if(!s||s.ownerScope.kind!=="personal"||s.location!=="local")throw new Error("Evaluation review requires the selected Personal Local Harness.");let[r,i]=await Promise.all([e.store.listHarnessImprovementArtifacts(e.workspaceId,"observation",1e4),e.store.listHarnessImprovementArtifacts(e.workspaceId,"trigger_decision",1e4)]),u=new Set([...r.map(m=>m.runRef),...i.map(m=>m.runRef)]),c=(e.now??(()=>new Date().toISOString()))(),d=await Promise.all([...u].sort().map(async m=>{let H=await e.store.getSession(m);return{sourceRef:m,policy:{id:`source-policy-${D({workspaceId:e.workspaceId,sourceRef:m,policyVersion:Je}).slice(0,24)}`,contentHash:D({workspaceId:e.workspaceId,sourceRef:m,policyVersion:Je})},state:H?"authorized":"deleted",checkedAt:c}}));return Qe({store:e.store,request:{sourcePolicies:d,limits:{maxEvidence:200,maxTokens:5e4,maxDurationMs:24e4,maxEstimatedCostUsd:e.maxEstimatedCostUsd}},stream:e.stream,signal:e.signal,now:e.now,continuation:e.stream?{storeDir:e.storeDir,stream:e.stream}:void 0})}o(le,"reviewSelectedLocalHarnessEvaluationFromHost");var gt=15e3;function Re(e,t){if(e==="manual")return null;let s=new Date(t);return s.setUTCDate(s.getUTCDate()+(e==="daily"?1:7)),s.toISOString()}o(Re,"nextHarnessEvaluationReviewRunAt");function us(e){let t=null,s=null,r=e.now??(()=>new Date().toISOString());async function i(){return s||(s=(async()=>{let u=await e.store.getSelectedHarnessWorkspace({ownerKind:"personal",ownerId:te});if(!u)return null;let c=await e.store.getHarnessEvaluationReviewSettings(u.id),d=r();if(!c.enabled&&!c.activityEnabled)return null;let m=c.enabled&&c.cadence!=="manual"&&!!c.nextRunAt&&c.nextRunAt<=d,H=c.activityEnabled&&await Ht({store:e.store,workspaceId:u.id,batchSize:c.activityBatchSize});if(!m&&!H)return null;let b={...c,nextRunAt:m?Re(c.cadence,d):c.nextRunAt,lastRunAt:d,lastError:null,updatedAt:d};await e.store.setHarnessEvaluationReviewSettings({workspaceId:u.id,settings:b});try{let l=await le({store:e.store,storeDir:e.storeDir,workspaceId:u.id,maxEstimatedCostUsd:c.maxEstimatedCostUsd,stream:e.stream,now:r});return await e.store.setHarnessEvaluationReviewSettings({workspaceId:u.id,settings:{...b,lastResult:{id:l.id,contentHash:l.contentHash,classification:l.classification},updatedAt:r()}}),e.logger?.info("Harness evaluation review schedule completed",{workspaceId:u.id,reviewId:l.id,classification:l.classification}),l}catch(l){let a=l instanceof Error?l.message:String(l);return await e.store.setHarnessEvaluationReviewSettings({workspaceId:u.id,settings:{...b,lastError:a,updatedAt:r()}}),e.logger?.warn("Harness evaluation review schedule failed",{workspaceId:u.id,error:a}),null}})().finally(()=>{s=null}),s)}return o(i,"runDueNow"),{start(){t||(t=setInterval(()=>{e.isClosing()||i()},e.tickMs??gt),t.unref?.(),i())},async stop(){t&&clearInterval(t),t=null,await s},runDueNow:i}}o(us,"createLocalHarnessEvaluationReviewScheduler");async function Ht(e){let[t,s]=await Promise.all([e.store.listHarnessImprovementArtifacts(e.workspaceId,"refiner_outcome",e.batchSize),e.store.listHarnessImprovementArtifacts(e.workspaceId,"evaluation_review",1)]),r=s[0]?.nextWatermark.throughCreatedAt??null;return t.filter(i=>!r||i.createdAt>r).length>=e.batchSize}o(Ht,"hasEventDrivenReviewBatch");import ge from"node:path";function Us(e){return{harnessHistoryPayload:o(()=>U(e.store),"harnessHistoryPayload"),updateHarnessBackgroundReviewPayload:o(t=>It({store:e.store,request:kt(t)}),"updateHarnessBackgroundReviewPayload"),reviewHarnessEvaluationPayload:o(t=>At({store:e.store,storeDir:e.storeDir,stream:e.evaluationReviewStream,request:ht(t)}),"reviewHarnessEvaluationPayload"),updateHarnessEvaluationReviewSchedulePayload:o(t=>Ct({store:e.store,request:yt(t)}),"updateHarnessEvaluationReviewSchedulePayload"),harnessDiffPayload:o(t=>qt({...e,request:Et(t)}),"harnessDiffPayload"),rollbackHarnessPayload:o(t=>_t({...e,request:bt(t)}),"rollbackHarnessPayload"),reviewHarnessProposalPayload:o(t=>Dt({...e,request:St(t)}),"reviewHarnessProposalPayload")}}o(Us,"createLocalHarnessSettingsRoutePayloads");function ht(e){if(!e||typeof e!="object")throw new Error("Harness evaluation review requires a workspace.");let t=e;if(typeof t.workspaceId!="string")throw new Error("Harness evaluation review requires a workspace.");if(t.maxEstimatedCostUsd!==void 0&&(typeof t.maxEstimatedCostUsd!="number"||!Number.isFinite(t.maxEstimatedCostUsd)||t.maxEstimatedCostUsd<0))throw new Error("Harness evaluation review cost must be a non-negative number.");return{workspaceId:t.workspaceId,maxEstimatedCostUsd:t.maxEstimatedCostUsd}}o(ht,"parseHarnessEvaluationReviewRequest");function yt(e){if(!e||typeof e!="object")throw new Error("Harness evaluation review schedule requires a workspace and cadence.");let t=e;if(typeof t.workspaceId!="string"||typeof t.enabled!="boolean"||typeof t.activityEnabled!="boolean"||typeof t.activityBatchSize!="number"||!Number.isInteger(t.activityBatchSize)||t.activityBatchSize<1||t.activityBatchSize>100||t.cadence!=="manual"&&t.cadence!=="daily"&&t.cadence!=="weekly"||typeof t.maxEstimatedCostUsd!="number"||!Number.isFinite(t.maxEstimatedCostUsd)||t.maxEstimatedCostUsd<0)throw new Error("Harness evaluation review schedule requires a valid workspace, cadence, and cost limit.");return{workspaceId:t.workspaceId,enabled:t.enabled,activityEnabled:t.activityEnabled,activityBatchSize:t.activityBatchSize,cadence:t.cadence,maxEstimatedCostUsd:t.maxEstimatedCostUsd}}o(yt,"parseHarnessEvaluationReviewScheduleRequest");function kt(e){if(!e||typeof e!="object")throw new Error("Harness background review requires a workspace and enabled state.");let t=e;if(typeof t.workspaceId!="string"||typeof t.enabled!="boolean")throw new Error("Harness background review requires a workspace and enabled state.");return{workspaceId:t.workspaceId,enabled:t.enabled}}o(kt,"parseHarnessBackgroundReviewRequest");function Ye(e,t){if(!e||typeof e!="object")throw new Error(`${t} requires an id and content hash.`);let s=e;if(typeof s.id!="string"||typeof s.contentHash!="string")throw new Error(`${t} requires an id and content hash.`);return{id:s.id,contentHash:s.contentHash}}o(Ye,"parseHarnessReleaseRef");function Et(e){if(!e||typeof e!="object")throw new Error("Harness release diff requires a workspace and target release.");let t=e;if(typeof t.workspaceId!="string")throw new Error("Harness release diff requires a workspace and target release.");return{workspaceId:t.workspaceId,baseRelease:t.baseRelease===null?null:Ye(t.baseRelease,"Harness base release"),targetRelease:Ye(t.targetRelease,"Harness target release")}}o(Et,"parseHarnessReleaseDiffRequest");function bt(e){if(!e||typeof e!="object")throw new Error("Harness rollback requires a workspace and target release.");let t=e,s=t.targetRelease;if(typeof t.workspaceId!="string"||!s||typeof s!="object")throw new Error("Harness rollback requires a workspace and target release.");let r=s;if(typeof r.id!="string"||typeof r.contentHash!="string")throw new Error("Harness rollback target requires an id and content hash.");return{workspaceId:t.workspaceId,targetRelease:{id:r.id,contentHash:r.contentHash}}}o(bt,"parseHarnessRollbackRequest");function St(e){if(!e||typeof e!="object")throw new Error("Harness review requires a workspace, proposal, and decision.");let t=e,s=t.proposal;if(typeof t.workspaceId!="string"||t.decision!=="approve"&&t.decision!=="decline"||!s||typeof s!="object")throw new Error("Harness review requires a workspace, proposal, and decision.");let r=s;if(typeof r.id!="string"||typeof r.contentHash!="string")throw new Error("Harness proposal review requires an id and content hash.");return{workspaceId:t.workspaceId,proposal:{id:r.id,contentHash:r.contentHash},decision:t.decision}}o(St,"parseHarnessProposalReviewRequest");async function U(e){let t=await e.getSelectedHarnessWorkspace({ownerKind:"personal",ownerId:te});if(!t)return{workspace:null,backgroundReview:{enabled:!1,updatedAt:null},evaluationReviewSchedule:{enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:0,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},releases:[],changes:[],routes:[],evaluationReviews:[],refinementCandidates:[],modelImprovementQualifications:[],pendingReviews:[],memories:[]};let[s,r,i,u,c,d,m,H,b,l,a,p,f]=await Promise.all([e.getHarnessBackgroundReviewSettings(t.id),e.getHarnessEvaluationReviewSettings(t.id),e.listHarnessReleaseRecords(t.id),e.listHarnessAdvanceReceipts(t.id),e.listHarnessImprovementArtifacts(t.id,"proposal",1e3),e.listHarnessImprovementArtifacts(t.id,"targeted_validation",1e3),e.listHarnessImprovementArtifacts(t.id,"route_decision",1e3),e.listHarnessImprovementArtifacts(t.id,"evaluation_review",1e3),e.listHarnessRefinementCandidates(t.id),e.listHarnessImprovementArtifacts(t.id,"training_qualification",1e3),e.listHarnessImprovementArtifacts(t.id,"apply_receipt",1e3),e.listHarnessImprovementArtifacts(t.id,"refiner_outcome",1e3),e.listHarnessImprovementArtifacts(t.id,"trigger_decision",1e3)]),R=c,A=d,w=m,T=a,M=p,F=f,$=u.slice().reverse().map(g=>{let v=g.proposal?R.find(E=>E.id===g.proposal.id&&E.contentHash===g.proposal.contentHash)??null:null,_=v?M.find(E=>E.proposal?.id===v.id&&E.proposal.contentHash===v.contentHash)??null:null,I=_?F.find(E=>E.id===_.trigger.id&&E.contentHash===_.trigger.contentHash)??null:null;return{receipt:g,proposal:v,validations:v?A.filter(E=>E.proposal.id===v.id&&E.proposal.contentHash===v.contentHash):[],routeDecision:v?w.find(E=>E.metadata.proposalId===v.id)??null:null,applyReceipt:v?T.find(E=>E.proposal.id===v.id&&E.proposal.contentHash===v.contentHash)??null:null,outcome:_,trigger:I}}),Y=new Set($.flatMap(g=>g.routeDecision?[g.routeDecision.id]:[])),W=w.filter(g=>!Y.has(g.id)).map(g=>{let v=F.find(I=>I.id===g.trigger.id&&I.contentHash===g.trigger.contentHash)??null,_=M.find(I=>I.trigger.id===g.trigger.id&&I.trigger.contentHash===g.trigger.contentHash)??null;return{decision:g,trigger:v,outcome:_}}),O=R.reduce((g,v)=>{let I=T.filter(x=>x.proposal.id===v.id&&x.proposal.contentHash===v.contentHash).sort((x,Z)=>Z.createdAt.localeCompare(x.createdAt))[0]??null;if(!I||I.decision!=="retained")return g;let E=M.find(x=>x.proposal?.id===v.id&&x.proposal.contentHash===v.contentHash)??null,S=E?F.find(x=>x.id===E.trigger.id&&x.contentHash===E.trigger.contentHash)??null:null;return g.push({proposal:v,validations:A.filter(x=>x.proposal.id===v.id&&x.proposal.contentHash===v.contentHash),applyReceipt:I,outcome:E,trigger:S}),g},[]);return{workspace:t,backgroundReview:s,evaluationReviewSchedule:r,releases:i.map(g=>({id:g.harnessRelease.id,contentHash:g.harnessRelease.contentHash,sourceRevision:g.sourceRevision,createdAt:g.createdAt,current:t.currentChannel.release?.contentHash===g.harnessRelease.contentHash,files:g.harnessRelease.files.map(v=>({id:v.id,path:v.path,contentHash:v.contentHash,sizeBytes:v.sizeBytes,mediaType:v.mediaType}))})),changes:$,routes:W,evaluationReviews:H,refinementCandidates:b,modelImprovementQualifications:l,pendingReviews:O,memories:await e.listHarnessMemories(t.id)}}o(U,"localHarnessHistoryPayload");async function At(e){let t=await e.store.getHarnessEvaluationReviewSettings(e.request.workspaceId),s=await le({store:e.store,storeDir:e.storeDir,workspaceId:e.request.workspaceId,maxEstimatedCostUsd:e.request.maxEstimatedCostUsd??t.maxEstimatedCostUsd,stream:e.stream}),r=new Date().toISOString();return await e.store.setHarnessEvaluationReviewSettings({workspaceId:e.request.workspaceId,settings:{...t,lastRunAt:r,lastResult:{id:s.id,contentHash:s.contentHash,classification:s.classification},lastError:null,updatedAt:r}}),{receipt:s,history:await U(e.store)}}o(At,"reviewLocalHarnessEvaluationFromSettings");async function Ct(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t||t.ownerScope.kind!=="personal"||t.location!=="local")throw new Error("Evaluation review schedule requires the selected Personal Local Harness.");if((await e.store.getSelectedHarnessWorkspace({ownerKind:"personal",ownerId:te}))?.id!==t.id)throw new Error("Evaluation review schedule requires the selected Personal Local Harness.");let r=await e.store.getHarnessEvaluationReviewSettings(t.id),i=new Date().toISOString(),u=e.request.enabled&&e.request.cadence!=="manual";return await e.store.setHarnessEvaluationReviewSettings({workspaceId:t.id,settings:{...r,enabled:u,activityEnabled:e.request.activityEnabled,activityBatchSize:e.request.activityBatchSize,cadence:e.request.cadence,maxEstimatedCostUsd:e.request.maxEstimatedCostUsd,nextRunAt:u?Re(e.request.cadence,i):null,lastError:null,updatedAt:i}}),{history:await U(e.store)}}o(Ct,"updateLocalHarnessEvaluationReviewScheduleFromSettings");async function It(e){let t=await e.store.getHarnessWorkspace(e.request.workspaceId);if(!t||t.ownerScope.kind!=="personal"||t.location!=="local")throw new Error("Background review settings require the selected Personal Local Harness.");return await e.store.setHarnessBackgroundReviewSettings({workspaceId:t.id,enabled:e.request.enabled,updatedAt:new Date().toISOString()}),{history:await U(e.store)}}o(It,"updateLocalHarnessBackgroundReviewFromSettings");async function Ze(e){let t=await e.store.getHarnessReleaseRecord(e.release.contentHash);if(!t||t.workspaceId!==e.workspaceId||t.harnessRelease.id!==e.release.id||t.harnessRelease.contentHash!==e.release.contentHash)throw new Error(`${e.label} is unavailable or hash-mismatched.`);return t}o(Ze,"requireHarnessReleaseRecord");function Ge(e,t){let s=ge.resolve(e.bundlePath,"source"),r=ge.resolve(s,...t.split("/"));if(r!==s&&!r.startsWith(`${s}${ge.sep}`))throw new Error(`Harness release contains an unsafe file path: ${t}.`);return r}o(Ge,"releaseSourcePath");function xt(e){return e.patch.split(`
|
|
5
5
|
`).map(t=>t.startsWith("diff --git ")?`diff --git a/${e.filePath} b/${e.filePath}`:t.startsWith("--- ")?e.baseExists?`--- a/${e.filePath}`:"--- /dev/null":t.startsWith("+++ ")?e.targetExists?`+++ b/${e.filePath}`:"+++ /dev/null":t).join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as L,c as u,d as S,e as v,f as C,g as x}from"./chunk-
|
|
2
|
+
import{a as L,c as u,d as S,e as v,f as C,g as x}from"./chunk-BUZ7CBJC.js";import{Bb as f,Cb as b,Db as c,Eb as _,Fb as q,L as p,lb as m,vb as w,zb as y}from"./chunk-XHU4BZQY.js";import{v as h}from"./chunk-ZY32SZ2P.js";import{A as a}from"./chunk-X2J2P5ZT.js";import{a as d}from"./chunk-FTQLQJQV.js";var i=class extends Error{static{d(this,"OpenPondLearningError")}constructor(e,t,r,s){super(r),this.status=e,this.code=t,this.details=s,this.name="OpenPondLearningError"}status;code;details};var I=a.object({batchId:a.string().trim().min(1).max(500),modelProjectId:a.string().trim().min(1).max(500)}).strict(),P=a.object({batchId:a.string().min(1),projectId:a.string().min(1),tasksetId:a.string().min(1),releaseId:a.string().min(1),revision:a.number().int().positive(),contentHash:a.string().regex(/^[a-f0-9]{64}$/)}).strict(),U=class{static{d(this,"OpenPondLearningClient")}#e;constructor(e){if(!e.apiKey.trim()||!e.scope.trim())throw new Error("Learning API key and scope are required.");let t=new URL(e.baseUrl);if(!["http:","https:"].includes(t.protocol)||t.username||t.password||t.search||t.hash)throw new Error("Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.");this.#e={...e,baseUrl:t.toString().replace(/\/+$/,"")}}async command(e,t={}){f(e);let r=b.parse({scope:this.#e.scope,command:e}),s=q.parse(await this.#t("commands",r,t));if(s.operationId!==e.operationId)throw new i(502,"operation_identity_mismatch","Learning response did not match the submitted operation.",null);return s}submitExample(e,t={}){return this.command({action:"submit_example",operationId:e.idempotencyKey,example:e},t)}submitFeedback(e,t={}){return this.command({action:"submit_feedback",operationId:e.idempotencyKey,feedback:e},t)}async get(e,t,r,s={}){let n=c.parse({action:"get",scope:this.#e.scope,kind:e,id:t,...r===void 0?{}:{revision:r}});return m[e].parse(await this.#t("read",n,s))}async inspectEvidence(e,t={}){let r=c.parse({action:"inspect_evidence",scope:this.#e.scope,evidence:e}),s=_.parse(await this.#t("read",r,t));if(!p(s.evidence,e))throw new i(502,"evidence_identity_mismatch","Inspection did not match the requested evidence release.",null);return s}async inspectTaskQueue(e=null,t={}){let r=c.parse({action:"inspect_task_queue",scope:this.#e.scope,modelProjectId:e}),s=y.parse(await this.#t("read",r,t));if(s.modelProjectId!==e)throw new i(502,"model_identity_mismatch","Task queue did not match the requested Model.",null);return s}async inspectPolicy(e,t={}){let r=c.parse({action:"inspect_policy",scope:this.#e.scope,policy:e}),s=w.parse(await this.#t("read",r,t));if(!p(s.policy,e))throw new i(502,"policy_identity_mismatch","Inspection did not match the requested policy release.",null);return s}async createSourceCredential(e,t={}){let r=u.parse({...e,action:"create",scope:this.#e.scope}),s=S.parse(await this.#t("credentials",r,t));if(this.#s(s.credential,e.sourceId),s.apiKey!==e.apiKey||!e.apiKey.startsWith(`${s.credential.keyPrefix}_`))throw new i(502,"credential_identity_mismatch","Credential response did not match the prepared credential.",null);return s}async listSourceCredentials(e,t={},r={}){let s=u.parse({...t,action:"list",scope:this.#e.scope,sourceId:e}),n=v.parse(await this.#t("credentials",s,r));if(n.items.length>(t.limit??30))throw new i(502,"credential_page_invalid","Credential response exceeded the requested page size.",null);for(let o of n.items)this.#s(o,e);return n}async revokeSourceCredential(e,t,r={}){let s=u.parse({action:"revoke",scope:this.#e.scope,sourceId:e,id:t}),n=L.parse(await this.#t("credentials",s,r));if(this.#s(n,e),n.id!==t||n.revokedAt===null)throw new i(502,"credential_revocation_mismatch","Credential revocation did not match the requested credential.",null);return n}async sourceConfiguration(e,t={}){let r=C.parse({scope:this.#e.scope,sourceId:e}),s=x.parse(await this.#t("source-config",r,t));if(s.scope!==this.#e.scope||s.source.id!==e)throw new i(502,"source_identity_mismatch","Source configuration did not match the requested source.",null);return s}#s(e,t){if(e.scope!==this.#e.scope||e.sourceId!==t)throw new i(502,"credential_scope_mismatch","Credential response did not match the requested source.",null)}async list(e,t={},r={}){let s=c.parse({action:"list",scope:this.#e.scope,kind:e,...t});return a.object({items:a.array(m[e]).max(100),nextCursor:a.string().nullable()}).strict().parse(await this.#t("read",s,r))}async publishBatch(e,t={}){let r=I.parse(e),s=P.parse(await this.#t("publish-batch",{...r,scope:this.#e.scope},t));if(s.batchId!==r.batchId)throw new i(502,"batch_identity_mismatch","Published batch response did not match the requested batch.",null);return s}async#t(e,t,r){h(t,16777216);let s=await(this.#e.fetch??globalThis.fetch)(`${this.#e.baseUrl}/v1/learning/${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.#e.apiKey}`,"Content-Type":"application/json",Accept:"application/json","X-OpenPond-Team-Id":this.#e.scope},body:JSON.stringify(t),signal:r.signal,redirect:"error"}),n=await R(s);if(!s.ok){let o=a.object({code:a.string().optional(),error:a.string().optional()}).passthrough().safeParse(n);throw new i(s.status,o.success?o.data.code??"learning_request_failed":"learning_request_failed",o.success?o.data.error??`Learning request failed (${s.status}).`:`Learning request failed (${s.status}).`,n)}return n}};async function R(e){let r=e.body?.getReader();if(!r)throw new i(e.status,"empty_response","Learning response was empty.",null);let s=new TextDecoder,n=0,o="";try{for(;;){let l=await r.read();if(l.done)break;if(n+=l.value.byteLength,n>16777216)throw new i(e.status,"response_too_large","Learning response exceeded 16 MiB; request a smaller page.",null);o+=s.decode(l.value,{stream:!0})}o+=s.decode();let g=JSON.parse(o);return h(g,16777216),g}finally{await r.cancel(),r.releaseLock()}}d(R,"readBoundedLearningResponse");export{i as a,U as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{l as o}from"./chunk-
|
|
2
|
+
import{l as o}from"./chunk-XHU4BZQY.js";import{W as c}from"./chunk-ZY32SZ2P.js";import{c as t}from"./chunk-RCT3O3HQ.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{a as n}from"./chunk-FTQLQJQV.js";var m=e.object({id:t,scope:t,sourceId:t,name:e.string().trim().min(1).max(100),keyPrefix:e.string().min(1).max(100),createdAt:e.iso.datetime(),expiresAt:e.iso.datetime(),revokedAt:e.iso.datetime().nullable()}).strict(),p=e.string().regex(/^opk_key_[A-Za-z0-9]{16}_[A-Za-z0-9]{48}$/),x=e.discriminatedUnion("action",[e.object({action:e.literal("create"),scope:t,sourceId:t,name:e.string().trim().min(1).max(100),expiresAt:e.iso.datetime(),operationId:t,apiKey:p}).strict(),e.object({action:e.literal("list"),scope:t,sourceId:t,afterId:t.optional(),limit:e.number().int().min(1).max(100).default(30)}).strict(),e.object({action:e.literal("revoke"),scope:t,sourceId:t,id:t}).strict()]),f=e.object({credential:m,apiKey:p}).strict(),y=e.object({items:e.array(m).max(100),nextCursor:t.nullable()}).strict(),h=e.object({scope:t,sourceId:t}).strict(),b=e.object({scope:t,source:o,taskDefinition:o,enabled:e.boolean(),allowedSplits:e.array(c).min(1).max(4)}).strict();function C(i){return{...i,operationId:crypto.randomUUID(),apiKey:`opk_key_${s(16)}_${s(48)}`}}n(C,"createSourceCredentialRequest");function s(i){let d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r="";for(;r.length<i;)for(let a of crypto.getRandomValues(new Uint8Array(64)))if(a<248&&(r+=d[a%62]),r.length===i)return r;return r}n(s,"randomToken");export{m as a,p as b,x as c,f as d,y as e,h as f,b as g,C as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{sc as a,vc as u,wc as h}from"./chunk-XHU4BZQY.js";import{Ra as l}from"./chunk-ZY32SZ2P.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{a as p}from"./chunk-FTQLQJQV.js";var o=e.string().trim().min(1).max(240),S=e.object({projectId:o.optional(),search:e.string().max(300).optional(),kind:e.string().max(100).optional(),sort:e.enum(["name","type","version","projects","datasets","runs"]).optional(),direction:e.enum(["asc","desc"]).optional(),after:e.string().max(3e3).optional(),limit:e.number().int().min(1).max(100).default(30)}).strict(),v=e.object({teamId:o,items:e.array(e.object({reward:l,projects:e.number().int().nonnegative(),datasets:e.number().int().nonnegative(),runs:e.number().int().nonnegative()}).strict()).max(100),nextCursor:e.string().nullable()}).strict(),b=e.object({teamId:o,id:o,items:e.array(l).max(100),nextRevision:e.number().int().positive().nullable()}).strict(),g=e.object({section:e.enum(["projects","datasets","runs"]),after:o.optional(),limit:e.number().int().min(1).max(100).default(25)}).strict(),I=e.object({teamId:o,id:o,section:g.shape.section,items:e.array(e.union([e.object({id:o,name:e.string(),graderRevisions:e.array(e.number().int().positive()),archived:e.boolean()}).strict(),e.object({id:o,name:e.string(),revision:e.number().int().positive(),graderRevisions:e.array(e.number().int().positive())}).strict(),e.object({id:o,name:e.string(),status:e.string()}).strict()])).max(100),nextCursor:o.nullable()}).strict(),V=class{static{p(this,"OpenPondGraderInspectionClient")}constructor(n){this.options=n;let i=new URL(n.baseUrl);if(!["http:","https:"].includes(i.protocol)||i.username||i.password||i.search||i.hash||!n.apiKey.trim()||!n.teamId.trim())throw new Error("A clean API origin and workspace credentials are required.");this.baseUrl=i.toString().replace(/\/+$/,"")}options;baseUrl;async catalog(n={},i){let c=S.parse(n),t=v.parse(await this.read("",c,i));if(t.teamId!==this.options.teamId||t.items.length>c.limit||new Set(t.items.map(r=>r.reward.id)).size!==t.items.length)throw new Error("Grader catalog differs from its requested workspace or bounds.");return t}async versions(n,i={},c){let t=e.object({beforeRevision:e.number().int().positive().optional(),limit:e.number().int().min(1).max(100).default(25)}).strict().parse(i),r=b.parse(await this.read(`/${encodeURIComponent(o.parse(n))}/versions`,t,c));if(r.teamId!==this.options.teamId||r.id!==n||r.items.length>t.limit||r.items.some((d,m)=>d.id!==n||t.beforeRevision&&d.revision>=t.beforeRevision||m>0&&d.revision>=r.items[m-1].revision))throw new Error("Grader versions differ from their requested identity or revision order.");return r}async usage(n,i,c){let t=g.parse(i),r=I.parse(await this.read(`/${encodeURIComponent(o.parse(n))}/usage`,t,c));if(r.teamId!==this.options.teamId||r.id!==n||r.section!==t.section||r.items.length>t.limit)throw new Error("Grader usage differs from its requested workspace, identity or bounds.");return r}async read(n,i,c){let t=new URLSearchParams(Object.entries(i).filter(([,m])=>m!==void 0).map(([m,f])=>[m,String(f)])),r=await(this.options.fetch??fetch)(`${this.baseUrl}/v1/learning/read/graders${n}?${t}`,{signal:c,redirect:"error",headers:{Authorization:`Bearer ${this.options.apiKey}`,"X-OpenPond-Team-Id":this.options.teamId,Accept:"application/json"}}),d=await r.json();if(!r.ok)throw new Error(e.object({error:e.string()}).parse(d).error);return d}};var s=e.string().trim().min(1).max(500),w=e.object({id:s,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),N=e.object({teamId:s,modelId:s,runId:s.optional(),from:e.string().datetime().optional(),to:e.string().datetime().optional()}).strict(),F=e.discriminatedUnion("action",[e.object({action:e.literal("declare_verification"),teamId:s,operationId:s,plan:e.object({modelId:a.shape.modelId,classification:a.shape.classification,feedback:a.shape.feedback,evidence:a.shape.evidence,trainingJobId:a.shape.trainingJobId,checkpoint:a.shape.checkpoint,artifact:a.shape.artifact,taskset:a.shape.taskset,checks:a.shape.checks,baselineOperationId:a.shape.baselineOperationId,candidateOperationId:a.shape.candidateOperationId,criterion:a.shape.criterion}).strict()}).strict(),e.object({action:e.literal("link_live_opportunity"),teamId:s,operationId:s,correction:w,inferenceRequestId:s,grade:e.object({id:s,revision:e.number().int().positive()}).strict(),checkIds:e.array(s).min(1).max(1e3)}).strict()]),Q=e.object({summary:h.nullable(),observations:e.array(u).max(1e3)}).strict();export{S as a,g as b,V as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{j as sr,v as Bt}from"./chunk-
|
|
2
|
+
import{j as sr,v as Bt}from"./chunk-VEXJV5H5.js";import{a as or}from"./chunk-Q3WXB465.js";import{a as nr}from"./chunk-FEAKTSRS.js";import{a as et}from"./chunk-TPOAAJKA.js";import{a as tt}from"./chunk-WLQEONBF.js";import{b as at}from"./chunk-AXO6OHJB.js";import{d as Ze}from"./chunk-FE2ENE3U.js";import{b as Ye}from"./chunk-4EZI4KCT.js";import{a as tr,e as ar,f as rr}from"./chunk-RWRKUO5D.js";import{a as Ga}from"./chunk-46RMTR2Z.js";import{c as Za,e as He}from"./chunk-R6VI7MX5.js";import{a as Mt}from"./chunk-IZ6DLEVY.js";import{a as Ka,b as _e,c as Xa,d as Oe,g as Xe,l as Qe,m as se,n as Ya}from"./chunk-CSU7RDA5.js";import{a as er}from"./chunk-7KWD2I6W.js";import{c as Sa,y as Ha}from"./chunk-4TTXNVCE.js";import{d as he}from"./chunk-BJXPQIVD.js";import{e as wa}from"./chunk-LZPCA6DH.js";import{b as Ia}from"./chunk-L3KS6MOV.js";import{a as Qa}from"./chunk-G4747MOW.js";import{x as Be}from"./chunk-CJDGLPNX.js";import{a as Ct}from"./chunk-BL3CZWWD.js";import{A as F,B as Ke,u as Ja,y as Ge}from"./chunk-FCXDPVGJ.js";import{a as za,c as Se,d as Je,f as Ua,l as La,p as Va,r as Wa}from"./chunk-5TPYBXWM.js";import{b as la,d as ma,e as ua}from"./chunk-4V73I4OL.js";import{a as Le,e as sa,f as ia,g as da,h as ca}from"./chunk-LE75SVEL.js";import{f as $a}from"./chunk-6LFTQBXP.js";import{Ca as Tt,Fa,aa as Na,ja as Da,wa as Me}from"./chunk-5ZNE43XC.js";import{f as qa}from"./chunk-LK77GI6M.js";import{k as pa}from"./chunk-HVM2GUM3.js";import{D as Ta,E as Ca,F as Ma,P as Ba,U as _a,ba as Oa,da as ja,e as Ea,f as Ve,n as Aa,s as We,t as xa,x as Pa}from"./chunk-QAFXQHHG.js";import{Eb as Ie,Fb as ka,b as ga,ga as va}from"./chunk-ZY32SZ2P.js";import{r as fa,s as ha}from"./chunk-OTDDXEQ6.js";import{Z as ya}from"./chunk-SH7POUVX.js";import{M as Ra}from"./chunk-2MEOUS24.js";import{i as oa,l as re,m as fe,n as v}from"./chunk-RCT3O3HQ.js";import{A as M}from"./chunk-X2J2P5ZT.js";import{m as ba}from"./chunk-UGOK7VTC.js";import{a as h}from"./chunk-FTQLQJQV.js";import{execFile as Wr}from"node:child_process";import{readFile as Jr}from"node:fs/promises";import{promisify as Gr}from"node:util";var Kr=5,Xr=20*1024*1024,ir=4e4,Ot=Gr(Wr);function Zn(e){return async({grader:t,task:a,attempt:n})=>{let s=[],o=0,i=await Qr({store:e.store,attempt:n}),d=n.modelRef?.providerId===t.judge.providerId&&n.modelRef.modelId===t.judge.modelId?sr(n.metadata.hostedTokenPricing)??void 0:void 0,g=await e.modelText({model:t.judge,hostedTokenPricing:d,signal:new AbortController().signal,requestId:`task-judge:${n.id}:${t.id}`,onUsage:h((m,r)=>{s.push(m),typeof r=="number"&&Number.isFinite(r)&&r>=0&&(o+=r)},"onUsage"),messages:[{role:"system",content:`Apply this rubric and return JSON only with score (0..1), passed, and feedback.
|
|
3
3
|
|
|
4
4
|
${t.rubric}`},{role:"user",content:JSON.stringify({input:a.input,expectedOutput:a.expectedOutput,output:n.output,artifactEvidence:i})}]}),f=rr(g);if(!f)throw new Error("Model judge returned invalid structured output.");return{...f,usage:s,...o>0?{costUsd:o}:{}}}}h(Zn,"createTaskAttemptModelJudge");async function Qr(e){let t=(await e.store.listTaskAttemptArtifacts({attemptId:e.attempt.id})).filter(a=>a.kind==="output_artifact").slice(0,Kr);return Promise.all(t.map(async a=>{let n={artifactId:a.id,mediaType:a.mediaType??null,sha256:a.sha256,sizeBytes:a.sizeBytes,requiredOutputPath:typeof a.metadata.requiredOutputPath=="string"?a.metadata.requiredOutputPath:null};if(a.sizeBytes>Xr)return{...n,extraction:"omitted",reason:"artifact exceeds inspection bound"};try{if(a.mediaType==="application/pdf"){let{stdout:s}=await Ot("pdftotext",[a.path,"-"],{env:{...process.env,PATH:Mt()},maxBuffer:8388608,timeout:15e3});return{...n,extraction:"pdf_text",content:_t(s)}}if(Zr(a.mediaType)){let s=await en(a.path,a.mediaType);return{...n,extraction:"open_xml_text",content:_t(s.content),structure:s.structure}}return Yr(a.mediaType)?{...n,extraction:"text",content:_t(await Jr(a.path,"utf8"))}:{...n,extraction:"metadata_only"}}catch(s){return{...n,extraction:"unavailable",reason:s instanceof Error?s.message.slice(0,500):String(s).slice(0,500)}}}))}h(Qr,"loadTaskAttemptGraderEvidence");function Yr(e){return!!(e?.startsWith("text/")||e==="application/json"||e==="application/javascript"||e==="application/sql"||e==="application/xml"||e==="application/yaml")}h(Yr,"isTextArtifact");function Zr(e){return e==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"||e==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"||e==="application/vnd.openxmlformats-officedocument.presentationml.presentation"}h(Zr,"isOpenXmlArtifact");async function en(e,t){let a={env:{...process.env,PATH:Mt()},maxBuffer:16777216,timeout:15e3},{stdout:n}=await Ot("unzip",["-Z1",e],a),s=n.split(/\r?\n/).filter(Boolean),o=tn(s,t).slice(0,250),i=[];for(let d of o){let{stdout:g}=await Ot("unzip",["-p",e,d],a),f=rn(g);f&&i.push(`[${d}]
|
|
5
5
|
${f}`)}return{content:i.join(`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{b as oe}from"./chunk-BUZ7CBJC.js";import{b as be}from"./chunk-O6ZYDHEJ.js";import{f as J}from"./chunk-TS5HNRZB.js";import{m as L}from"./chunk-HIQPGYVH.js";import{l as ye}from"./chunk-263WS3TB.js";import{l as W}from"./chunk-XHU4BZQY.js";import{v as B}from"./chunk-ZY32SZ2P.js";import{I as Ee,K as Te}from"./chunk-SH7POUVX.js";import{c as M,d as z,e as ve,n as y}from"./chunk-RCT3O3HQ.js";import{A as e}from"./chunk-X2J2P5ZT.js";import{f as Ie}from"./chunk-UGOK7VTC.js";import{a as u}from"./chunk-FTQLQJQV.js";var c=Object.freeze({eventBytes:65536,actionBytes:16384,resultBytes:8192,stateBytes:8192,eventsPerAppend:32,eventsPerEpisode:256,episodeBytes:2097152,assetBytes:1048576,assetsPerEpisode:16,queueBytes:52428800,queueEvents:5e3,queueAgeSeconds:86400,capabilities:32,consultationRounds:3,consultationBytes:65536,manifestSeconds:300}),s=M,g=z,w=ve,K=e.enum(["codex","claude_code","opencode","openpond"]),h=e.object({id:M,contentHash:z}).strict(),C=e.object({teamId:M,projectId:M}).strict();function T(n,t){return e.preprocess((o,i)=>{try{B(o,t)}catch{return i.addIssue({code:"custom",message:"Tool learning data exceeds its JSON boundary."}),e.NEVER}return o},n)}u(T,"boundedToolLearningSchema");function x(n){return e.string().max(n).refine(t=>new TextEncoder().encode(t).byteLength<=n,"Tool learning text exceeds its UTF-8 byte limit.")}u(x,"toolLearningText");var ze=T(e.record(e.string().min(1).max(120),e.union([x(2e3),e.number().finite(),e.boolean(),e.null()])).refine(n=>Object.keys(n).length<=32,"Use at most 32 explicit state fields."),c.stateBytes),j=e.object({application:e.string().trim().min(1).max(200),version:e.string().trim().min(1).max(200),state:ze,fingerprint:z}).strict(),Y=e.object({id:M,contentHash:z,mediaType:e.enum(["text/plain","application/json","text/x-python","text/x-diff"]),sizeBytes:e.number().int().nonnegative().max(c.assetBytes),purpose:e.enum(["action","result","state","verification"])}).strict(),Le=e.object({policyRevision:e.number().int().positive(),policyHash:z,redactedFields:e.number().int().nonnegative().max(1e4),omittedFields:e.number().int().nonnegative().max(1e4),truncated:e.boolean()}).strict();function E(n,t=c.eventBytes){return B(n,t),y(n)}u(E,"toolLearningContentHash");var Q=x(c.actionBytes),xe=e.string().min(1).max(1e3).refine(n=>!n.startsWith("/")&&!n.includes("\\")&&!/^[A-Za-z]:/u.test(n)&&n.split("/").every(t=>t!==""&&t!=="."&&t!==".."),"Use a workspace-relative artifact path."),P=T(e.discriminatedUnion("kind",[e.object({kind:e.literal("python"),code:Q}).strict(),e.object({kind:e.literal("shell"),command:Q,shell:e.string().min(1).max(120)}).strict(),e.object({kind:e.literal("tool_arguments"),arguments:e.record(e.string().min(1).max(200),e.json())}).strict(),e.object({kind:e.literal("edit"),patch:Q,baseFiles:e.array(e.object({path:xe,contentHash:g.nullable()}).strict()).min(1).max(32)}).strict()]),c.actionBytes),yt=e.discriminatedUnion("kind",[e.object({kind:e.literal("replacement"),expectedActionHash:g,environmentFingerprint:g,action:P}).strict(),e.object({kind:e.literal("patch"),expectedActionHash:g,environmentFingerprint:g,files:e.array(e.object({path:xe,expectedContentHash:g,patch:Q}).strict()).min(1).max(16)}).strict()]);var Ve=e.object({intent:x(2e3),tool:e.object({name:e.string().min(1).max(200),version:e.string().max(200).nullable(),server:e.string().max(200).nullable()}).strict(),action:P,actionHash:g,environment:j,contextAssets:e.array(Y).max(c.assetsPerEpisode),selection:e.discriminatedUnion("kind",[e.object({kind:e.literal("eligible_attempt")}).strict(),e.object({kind:e.literal("unchanged_control"),numerator:e.number().int().positive(),denominator:e.number().int().positive(),policyHash:g}).strict()])}).strict().superRefine((n,t)=>{E(n.action)!==n.actionHash&&t.addIssue({code:"custom",path:["actionHash"],message:"Action bytes differ from their hash."}),n.selection.kind==="unchanged_control"&&n.selection.numerator>n.selection.denominator&&t.addIssue({code:"custom",path:["selection"],message:"Sampling probability cannot exceed one."})}),Ke=e.enum(["validation_failure","execution_failure","process_failure","timeout","cancelled","infrastructure_failure","authorization_denied","outcome_failure","unknown_failure"]),ie={attempt:h,actionHash:g,execution:e.enum(["not_executed","executed","unknown"]),sideEffects:e.enum(["none","possible","observed","unknown"]),resultExcerpt:x(c.resultBytes),resultHash:g.nullable(),assets:e.array(Y).max(c.assetsPerEpisode)},$e=e.discriminatedUnion("outcome",[e.object({...ie,outcome:e.literal("succeeded"),exitCode:e.literal(0).nullable()}).strict(),e.object({...ie,outcome:e.literal("failed"),classification:Ke,errorCode:e.string().min(1).max(200),message:x(2e3),exitCode:e.number().int().min(-255).max(255).nullable()}).strict(),e.object({...ie,outcome:e.literal("incomplete"),reason:e.enum(["completion_not_observed","observer_restarted","transport_interrupted","coverage_gap"])}).strict()]).superRefine((n,t)=>{n.execution==="not_executed"&&n.sideEffects!=="none"&&t.addIssue({code:"custom",path:["sideEffects"],message:"An unexecuted action cannot claim tool effects."}),n.outcome==="succeeded"&&n.execution!=="executed"&&t.addIssue({code:"custom",path:["execution"],message:"Successful execution requires an observed execution."}),n.outcome==="failed"&&(n.classification==="validation_failure"&&n.execution!=="not_executed"&&t.addIssue({code:"custom",path:["execution"],message:"Pre-execution validation failure must be unexecuted."}),n.classification==="process_failure"&&(n.execution!=="executed"||n.exitCode===null||n.exitCode===0)&&t.addIssue({code:"custom",path:["exitCode"],message:"Process failure requires a nonzero observed exit."}))}),Xe=e.object({failedAttempt:h,failedObservation:h,replacementAttempt:h,goalId:s,basis:e.enum(["explicit_relation","artifact_lineage","unverified"]),attributionEvidence:e.array(h).max(16)}).strict().superRefine((n,t)=>{n.failedAttempt.id===n.replacementAttempt.id&&t.addIssue({code:"custom",message:"A recovery must reference a different attempt."}),n.basis!=="unverified"&&n.attributionEvidence.length===0&&t.addIssue({code:"custom",path:["attributionEvidence"],message:"Recovery attribution needs retained evidence."})}),Ge=e.object({attempt:h,actionHash:g,outcome:e.enum(["passed","failed","unknown"]),verifierRelease:h.nullable(),verifierReceipt:h.nullable(),environmentFingerprint:g,resetStateHash:g.nullable(),outputArtifacts:e.array(Y).max(c.assetsPerEpisode),reason:x(2e3)}).strict().superRefine((n,t)=>{n.outcome!=="unknown"&&(!n.verifierRelease||!n.verifierReceipt)&&t.addIssue({code:"custom",message:"A verification outcome requires an exact verifier and execution receipt."})}),$=e.object({schemaVersion:e.literal("openpond.toolEpisodeEvent.v1"),operationId:s,installationId:s,episodeId:s,eventId:s,sessionId:s,parentSessionId:s.nullable(),turnId:s.nullable(),callId:s,occurredAt:w,sequence:e.number().int().nonnegative(),adapterVersion:e.string().min(1).max(200),sanitization:Le,contentHash:g}).strict(),R=T(e.discriminatedUnion("eventKind",[$.extend({eventKind:e.literal("attempt"),payload:Ve}).strict(),$.extend({eventKind:e.literal("observation"),payload:$e}).strict(),$.extend({eventKind:e.literal("recovery_link"),payload:Xe}).strict(),$.extend({eventKind:e.literal("verification"),payload:Ge}).strict(),$.extend({eventKind:e.literal("lineage"),payload:e.object({relation:e.enum(["fork","split","reopen"]),parentEpisode:h,parentSessionId:s,reason:x(1e3)}).strict()}).strict()]).superRefine((n,t)=>{let{contentHash:o,...i}=n;E(i)!==o&&t.addIssue({code:"custom",path:["contentHash"],message:"Episode event content hash mismatch."})}),c.eventBytes);function ae(n){let t=E(n);if(!n||typeof n!="object"||Array.isArray(n)||Object.hasOwn(n,"contentHash"))throw new Error("tool_episode_unsigned_envelope_required");return R.parse({...n,contentHash:t})}u(ae,"sealToolEpisodeEvent");var Se=T(e.object({schemaVersion:e.literal("openpond.toolEpisodeAppend.v1"),operationId:s,installationId:s,events:e.array(R).min(1).max(c.eventsPerAppend)}).strict().superRefine((n,t)=>{n.events.some(o=>o.installationId!==n.installationId)&&t.addIssue({code:"custom",path:["events"],message:"Append events must belong to the exact installation."}),new Set(n.events.map(o=>o.eventId)).size!==n.events.length&&t.addIssue({code:"custom",path:["events"],message:"Append event IDs must be unique."})}),c.eventBytes*c.eventsPerAppend),Re=e.object({schemaVersion:e.literal("openpond.toolEpisodeAppendReceipt.v1"),operationId:s,requestHash:g,installationId:s,teamId:s,projectId:s,receivedAt:w,events:e.array(e.object({eventId:s,contentHash:g,state:e.enum(["retained","already_retained","privacy_rejected"]),receiptId:s,reason:e.string().max(200).nullable()}).strict()).min(1).max(c.eventsPerAppend),learningEnrollment:e.literal(!1)}).strict();var V=e.object({revision:e.number().int().positive(),permittedTools:e.array(e.string().min(1).max(200)).min(1).max(100),workspaceRootHashes:e.array(g).min(1).max(32),permittedFields:e.array(e.enum(["action","intent","state","result_excerpt","artifact_reference"])).min(1).max(5),unchangedControls:e.object({numerator:e.number().int().nonnegative(),denominator:e.number().int().positive()}).strict(),maximumEventBytes:e.number().int().positive().max(c.eventBytes),maximumEpisodeBytes:e.number().int().positive().max(c.episodeBytes),maximumEpisodeEvents:e.number().int().positive().max(c.eventsPerEpisode),maximumQueueBytes:e.number().int().positive().max(c.queueBytes),maximumQueueEvents:e.number().int().positive().max(c.queueEvents),maximumQueueAgeSeconds:e.number().int().positive().max(c.queueAgeSeconds),rawRetentionDays:e.number().int().min(1).max(30),purposes:e.array(e.enum(["capture","consultation"])).min(1).max(2),modelUpdates:e.literal("requires_separate_review"),variantGeneration:e.literal("disabled")}).strict().superRefine((n,t)=>{n.unchangedControls.numerator>n.unchangedControls.denominator&&t.addIssue({code:"custom",path:["unchangedControls"],message:"Sampling probability cannot exceed one."});for(let o of["permittedTools","workspaceRootHashes","permittedFields","purposes"])new Set(n[o]).size!==n[o].length&&t.addIssue({code:"custom",path:[o],message:"Policy entries must be unique."});(n.maximumEpisodeBytes<n.maximumEventBytes||n.maximumQueueBytes<n.maximumEventBytes)&&t.addIssue({code:"custom",message:"Episode and queue capacities must fit one permitted event."})}),We=e.object({receipt:h.nullable(),start:e.enum(["observed","documented","unsupported","unqualified"]),resume:e.enum(["observed","documented","unsupported","unqualified"]),compaction:e.enum(["observed","documented","unsupported","unqualified"]),executionFailure:e.enum(["observed","documented","unsupported","unqualified"]),processFailure:e.enum(["observed","documented","unsupported","unqualified"]),validationFailure:e.enum(["observed","documented","unsupported","unqualified"]),nestedCalls:e.enum(["observed","documented","unsupported","unqualified"]),contextRefresh:e.enum(["session_start","start_resume","start_resume_compaction","revision_aware_turn","unqualified"]),gaps:e.array(e.string().min(1).max(500)).max(32)}).strict().superRefine((n,t)=>{Object.values(n).includes("observed")&&!n.receipt&&t.addIssue({code:"custom",path:["receipt"],message:"Observed coverage requires a qualification receipt."})}),we=T(e.object({schemaVersion:e.literal("openpond.toolLearningRegistration.v1"),operationId:s,installationId:s,projectId:s,machineSourceId:s,client:K,clientVersion:e.string().min(1).max(200),adapterRelease:h,collectionPolicy:V}).strict(),c.eventBytes),H=e.object({schemaVersion:e.literal("openpond.toolLearningInstallation.v1"),id:s,revision:e.number().int().positive(),scope:C,ownerUserId:s,machineSourceId:s,client:K,clientVersion:e.string().min(1).max(200),adapterRelease:h,state:e.enum(["pending_client_trust","enabled","disabled","revoked"]),collectionPolicy:V,collectionPolicyHash:g,coverage:We,credential:e.object({id:s,expiresAt:w,revokedAt:w.nullable(),capabilities:e.array(e.enum(["episode_append","manifest_read","consultation_submit","consultation_read"])).min(1).max(4)}).strict().nullable(),createdAt:w,updatedAt:w}).strict(),Ne=e.object({operationId:s,expectedRevision:e.number().int().positive(),state:e.enum(["enabled","disabled","revoked"])}).strict(),Ct=e.object({schemaVersion:e.literal("openpond.toolEpisodeOrigin.v1"),installationId:s,projectId:s,ownerUserId:s,episode:h,event:h,appendReceipt:h,purpose:e.literal("private_dataset_evidence"),trainingConsent:e.literal("not_granted")}).strict();import{DatabaseSync as Qe}from"node:sqlite";import{chmodSync as Ce,closeSync as Ze,existsSync as je,lstatSync as ce,mkdirSync as et,openSync as tt}from"node:fs";import{join as He}from"node:path";var Z=e.object({id:s,application:e.string().min(1).max(200),versions:e.array(e.string().min(1).max(200)).min(1).max(32),tools:e.array(e.string().min(1).max(200)).min(1).max(32),mode:e.literal("recovery"),routingInstruction:x(2e3),qualification:e.discriminatedUnion("kind",[e.object({kind:e.literal("integration"),receipt:h}).strict(),e.object({kind:e.literal("learned"),receipt:h,trainingRun:h,adapter:h,evaluation:h,activation:h}).strict()])}).strict(),Je=e.object({schemaVersion:e.literal("openpond.toolLearningManifest.v1"),installationId:s,scope:C,revision:e.number().int().positive(),contentHash:g,issuedAt:w,expiresAt:w,modelRelease:h,responseSchema:e.literal("openpond.toolLearningDecision.v1"),capabilities:e.array(Z).max(c.capabilities)}).strict().superRefine((n,t)=>{let{contentHash:o,...i}=n;E(i)!==o&&t.addIssue({code:"custom",path:["contentHash"],message:"Manifest content hash mismatch."});let a=Date.parse(n.expiresAt)-Date.parse(n.issuedAt);(a<=0||a>c.manifestSeconds*1e3)&&t.addIssue({code:"custom",path:["expiresAt"],message:"Manifest expiry exceeds the supported lifetime."}),new Set(n.capabilities.map(l=>l.id)).size!==n.capabilities.length&&t.addIssue({code:"custom",path:["capabilities"],message:"Capability IDs must be unique."})}),Oe=T(Je,c.consultationBytes),O=T(e.object({schemaVersion:e.literal("openpond.toolLearningConsultation.v1"),operationId:s,installationId:s,scope:C,sessionId:s,callId:s,capabilityId:s,manifestHash:g,modelRelease:h,mode:e.literal("recovery"),intent:x(2e3),action:P,actionHash:g,environment:j,contextHash:g,failure:e.object({message:x(c.resultBytes),observation:h}).strict(),round:e.number().int().min(1).max(c.consultationRounds)}).strict().superRefine((n,t)=>{E(n.action)!==n.actionHash&&t.addIssue({code:"custom",path:["actionHash"],message:"Consultation action hash mismatch."}),E({intent:n.intent,environment:n.environment,failure:n.failure})!==n.contextHash&&t.addIssue({code:"custom",path:["contextHash"],message:"Consultation context hash mismatch."})}),c.consultationBytes),se=e.discriminatedUnion("decision",[e.object({decision:e.literal("proceed")}).strict(),e.object({decision:e.literal("revise"),issues:e.array(e.object({category:e.string().min(1).max(120),feedback:x(2e3)}).strict()).min(1).max(8)}).strict(),e.object({decision:e.literal("needs_context"),missing:e.array(e.object({field:e.string().min(1).max(120),reason:x(500)}).strict()).min(1).max(8)}).strict()]),Ae={operationId:s,installationId:s,capabilityId:s,manifestHash:g,modelRelease:h,actionHash:g,contextHash:g},Ye=T(e.discriminatedUnion("state",[e.object({schemaVersion:e.literal("openpond.toolLearningDecision.v1"),...Ae,state:e.literal("completed"),decision:se,usageReceipt:h,completedAt:w}).strict(),e.object({schemaVersion:e.literal("openpond.toolLearningDecision.v1"),...Ae,state:e.literal("unavailable"),reason:e.enum(["disabled","revoked","expired_manifest","unsupported_scope","budget_exhausted","timeout","invalid_output","cancelled","dispatch_uncertain"]),usageReceipt:h.nullable()}).strict()]),c.consultationBytes);function re(n,t){let o=O.parse(n),i=Ye.parse(t);for(let a of["operationId","installationId","capabilityId","manifestHash","actionHash","contextHash"])if(o[a]!==i[a])throw new Error(`tool_learning_consultation_${a}_mismatch`);if(o.modelRelease.id!==i.modelRelease.id||o.modelRelease.contentHash!==i.modelRelease.contentHash)throw new Error("tool_learning_consultation_model_mismatch");return i}u(re,"assertToolLearningConsultationResponse");function le(n,t){let o=R.parse(n),i=V.parse(t);if(!i.purposes.includes("capture"))throw new Error("tool_learning_capture_not_enabled");if(o.sanitization.policyRevision!==i.revision||o.sanitization.policyHash!==E(i))throw new Error("tool_learning_capture_policy_changed");if(new TextEncoder().encode(JSON.stringify(o)).byteLength>i.maximumEventBytes)throw new Error("tool_learning_event_policy_limit");let a=u(l=>i.permittedFields.includes(l),"permits");if(o.eventKind==="attempt"){if(!i.permittedTools.includes(o.payload.tool.name))throw new Error("tool_learning_tool_outside_collection_policy");if(!a("action")||!a("intent")&&o.payload.intent!==""||!a("state")&&Object.keys(o.payload.environment.state).length>0||!a("artifact_reference")&&o.payload.contextAssets.length>0)throw new Error("tool_learning_attempt_field_outside_collection_policy")}if(o.eventKind==="observation"&&(!a("result_excerpt")&&(o.payload.resultExcerpt!==""||o.payload.outcome==="failed"&&o.payload.message!=="")||!a("artifact_reference")&&o.payload.assets.length>0))throw new Error("tool_learning_result_field_outside_collection_policy");if(o.eventKind==="verification"&&(!a("result_excerpt")&&o.payload.reason!==""||!a("artifact_reference")&&o.payload.outputArtifacts.length>0))throw new Error("tool_learning_verification_field_outside_collection_policy");if(o.eventKind==="lineage"&&!a("intent")&&o.payload.reason!=="")throw new Error("tool_learning_lineage_field_outside_collection_policy")}u(le,"assertToolEpisodeCapturePolicy");var de=e.object({schemaVersion:e.literal("openpond.localToolLearningInstallation.v1"),id:s,teamId:s,projectId:s,client:K,workspaceRoot:e.string().min(1).max(4e3),enabled:e.boolean(),policy:V,createdAt:e.iso.datetime({offset:!0})}).strict(),X=class{static{u(this,"ToolLearningLocalStore")}db;constructor(n){let t=He(n,"tool-learning");if(je(t)&&ce(t).isSymbolicLink())throw new Error("tool_learning_directory_symlink_forbidden");et(t,{recursive:!0,mode:448}),Ce(t,448);let o=He(t,"queue.sqlite");if(je(o)){if(!ce(o).isFile()||ce(o).isSymbolicLink())throw new Error("tool_learning_queue_file_invalid")}else Ze(tt(o,"wx",384));Ce(o,384),this.db=new Qe(o),this.db.exec("PRAGMA busy_timeout = 3000; PRAGMA journal_mode = WAL; PRAGMA synchronous = FULL;"),this.db.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS installations (id TEXT PRIMARY KEY, payload TEXT NOT NULL);
|
|
4
|
+
CREATE TABLE IF NOT EXISTS events (
|
|
5
|
+
id TEXT PRIMARY KEY, installation_id TEXT NOT NULL, episode_id TEXT NOT NULL,
|
|
6
|
+
policy_hash TEXT NOT NULL, content_hash TEXT NOT NULL,
|
|
7
|
+
payload TEXT NOT NULL, size_bytes INTEGER NOT NULL, received_at INTEGER NOT NULL
|
|
8
|
+
);
|
|
9
|
+
CREATE INDEX IF NOT EXISTS events_installation ON events(installation_id, received_at, id);
|
|
10
|
+
CREATE INDEX IF NOT EXISTS events_episode ON events(installation_id, episode_id);
|
|
11
|
+
CREATE INDEX IF NOT EXISTS events_policy ON events(installation_id, policy_hash, received_at, id);
|
|
12
|
+
CREATE TABLE IF NOT EXISTS counters (
|
|
13
|
+
installation_id TEXT PRIMARY KEY, dropped INTEGER NOT NULL DEFAULT 0, expired INTEGER NOT NULL DEFAULT 0
|
|
14
|
+
);
|
|
15
|
+
CREATE TABLE IF NOT EXISTS capture_boundaries (
|
|
16
|
+
installation_id TEXT NOT NULL, session_id TEXT NOT NULL, call_id TEXT NOT NULL,
|
|
17
|
+
phase TEXT NOT NULL, payload TEXT NOT NULL, size_bytes INTEGER NOT NULL,
|
|
18
|
+
expires_at INTEGER NOT NULL,
|
|
19
|
+
PRIMARY KEY(installation_id, session_id, call_id, phase)
|
|
20
|
+
);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS capture_boundaries_expiry ON capture_boundaries(expires_at);
|
|
22
|
+
CREATE TABLE IF NOT EXISTS client_observations (
|
|
23
|
+
installation_id TEXT NOT NULL, event_name TEXT NOT NULL,
|
|
24
|
+
observed_at TEXT NOT NULL, count INTEGER NOT NULL,
|
|
25
|
+
PRIMARY KEY(installation_id, event_name)
|
|
26
|
+
);
|
|
27
|
+
CREATE TABLE IF NOT EXISTS consultation_requests (
|
|
28
|
+
installation_id TEXT NOT NULL, operation_id TEXT NOT NULL,
|
|
29
|
+
payload TEXT NOT NULL, size_bytes INTEGER NOT NULL, expires_at INTEGER NOT NULL,
|
|
30
|
+
PRIMARY KEY(installation_id, operation_id)
|
|
31
|
+
);
|
|
32
|
+
CREATE INDEX IF NOT EXISTS consultation_requests_expiry ON consultation_requests(expires_at);
|
|
33
|
+
`),this.expireCaptureBoundaries(),this.db.prepare("DELETE FROM consultation_requests WHERE expires_at <= ?").run(Date.now())}close(){this.db.close()}captureBoundary(n,t,o,i){this.expireCaptureBoundaries();let a=this.db.prepare("SELECT payload FROM capture_boundaries WHERE installation_id = ? AND session_id = ? AND call_id = ? AND phase = ?").get(n,t,o,i);if(!a)return null;let l=R.parse(JSON.parse(String(a.payload))),p=this.installation(n);return!p?.enabled||l.sanitization.policyHash!==E(p.policy)?null:l}retainCaptureBoundary(n,t=Date.now()){let o=R.parse(n);if(o.eventKind!=="attempt"&&o.eventKind!=="observation")throw new Error("tool_learning_capture_boundary_kind");return this.transaction(()=>{this.expireCaptureBoundaries(t);let i=this.installation(o.installationId);if(!i?.enabled)return null;le(o,i.policy);let a=this.captureBoundary(o.installationId,o.sessionId,o.callId,o.eventKind);if(a)return a;let l=JSON.stringify(o),p=Buffer.byteLength(l),d=this.retainedUsage(),I=this.retainedUsage(i.id);return Number(d.count)>=c.queueEvents||Number(I.count)>=i.policy.maximumQueueEvents||Number(I.bytes)+p>i.policy.maximumQueueBytes||Number(d.bytes)+p>c.queueBytes?(this.recordDropped(o.installationId),null):(this.db.prepare("INSERT INTO capture_boundaries VALUES (?, ?, ?, ?, ?, ?, ?)").run(o.installationId,o.sessionId,o.callId,o.eventKind,l,p,t+i.policy.maximumQueueAgeSeconds*1e3),o)})}recordDropped(n){this.db.prepare("INSERT INTO counters(installation_id, dropped) VALUES (?, 1) ON CONFLICT(installation_id) DO UPDATE SET dropped = dropped + 1").run(n)}recordClientObservation(n,t){if(!["start","resume","compact","turn_context","pre_tool","post_tool","failure"].includes(t))throw new Error("tool_learning_unknown_client_observation");this.installation(n)?.enabled&&this.db.prepare("INSERT INTO client_observations VALUES (?, ?, ?, 1) ON CONFLICT(installation_id, event_name) DO UPDATE SET observed_at = excluded.observed_at, count = count + 1").run(n,t,new Date().toISOString())}hasRecoveryCandidateContext(n,t,o=Date.now()){return this.db.prepare("SELECT payload FROM capture_boundaries WHERE installation_id = ? AND session_id = ? AND phase = 'observation' AND expires_at > ? ORDER BY json_extract(payload, '$.occurredAt') DESC LIMIT 33").all(n,t,o).slice(0,32).some(a=>{let l=R.parse(JSON.parse(a.payload));return l.eventKind==="observation"&&l.payload.outcome==="failed"&&Date.parse(l.occurredAt)>=o-6e5})}clientObservations(n){return this.db.prepare("SELECT event_name AS event, observed_at AS observedAt, count FROM client_observations WHERE installation_id = ? ORDER BY event_name").all(n)}consultationRequest(n,t){this.db.prepare("DELETE FROM consultation_requests WHERE expires_at <= ?").run(Date.now());let o=this.db.prepare("SELECT payload FROM consultation_requests WHERE installation_id = ? AND operation_id = ?").get(n,t);return o?O.parse(JSON.parse(String(o.payload))):null}consultationForCall(n,t,o){this.db.prepare("DELETE FROM consultation_requests WHERE expires_at <= ?").run(Date.now());let i=this.db.prepare("SELECT payload FROM consultation_requests WHERE installation_id = ? AND json_extract(payload, '$.sessionId') = ? AND json_extract(payload, '$.callId') = ? ORDER BY expires_at DESC LIMIT 1").get(n,t,o);return i?O.parse(JSON.parse(String(i.payload))):null}retainConsultationRequest(n){let t=O.parse(n);return this.transaction(()=>{let o=this.consultationRequest(t.installationId,t.operationId);if(o){if(E(o)!==E(t))throw new Error("tool_learning_consultation_identity_conflict");return o}let i=this.installation(t.installationId);if(!i?.enabled||i.teamId!==t.scope.teamId||i.projectId!==t.scope.projectId||!i.policy.purposes.includes("consultation"))throw new Error("tool_learning_consultation_disabled");let a=JSON.stringify(t),l=Buffer.byteLength(a),p=this.retainedUsage(),d=this.retainedUsage(i.id);if(Number(p.count)>=c.queueEvents||Number(d.count)>=i.policy.maximumQueueEvents||Number(d.bytes)+l>i.policy.maximumQueueBytes||Number(p.bytes)+l>c.queueBytes)throw new Error("tool_learning_consultation_capacity_reached");return this.db.prepare("INSERT INTO consultation_requests VALUES (?, ?, ?, ?, ?)").run(t.installationId,t.operationId,a,l,Date.now()+i.policy.maximumQueueAgeSeconds*1e3),t})}retainedUsage(n){let o=`SELECT COUNT(*) AS count, COALESCE(SUM(size_bytes), 0) AS bytes FROM (SELECT installation_id, size_bytes FROM events UNION ALL SELECT installation_id, size_bytes FROM capture_boundaries UNION ALL SELECT installation_id, size_bytes FROM consultation_requests)${n===void 0?"":" WHERE installation_id = ?"}`;return n===void 0?this.db.prepare(o).get():this.db.prepare(o).get(n)}expireCaptureBoundaries(n=Date.now()){this.db.prepare("DELETE FROM capture_boundaries WHERE expires_at <= ?").run(n)}installation(n){let t=this.db.prepare("SELECT payload FROM installations WHERE id = ?").get(n);return t?de.parse(JSON.parse(String(t.payload))):null}installations(){return this.db.prepare("SELECT payload FROM installations ORDER BY id").all().map(n=>de.parse(JSON.parse(String(n.payload))))}configure(n){let t=de.parse(n);return this.transaction(()=>{let o=this.installation(t.id);if(o&&["teamId","projectId","client","workspaceRoot"].some(i=>o[i]!==t[i]))throw new Error("tool_learning_installation_scope_immutable");if(o&&(t.policy.revision<o.policy.revision||t.policy.revision===o.policy.revision&&E(t.policy)!==E(o.policy)))throw new Error("tool_learning_capture_policy_revision_conflict");this.db.prepare("INSERT INTO installations VALUES (?, ?) ON CONFLICT(id) DO UPDATE SET payload = excluded.payload").run(t.id,JSON.stringify(t))}),t}append(n,t=Date.now()){let o=R.parse(n),i=JSON.stringify(o),a=Buffer.byteLength(i);return this.transaction(()=>{let l=this.installation(o.installationId);if(!l?.enabled)return"disabled";let p=l.policy;if(!p.purposes.includes("capture"))return"disabled";le(o,p);let d=this.db.prepare("SELECT content_hash, installation_id FROM events WHERE id = ?").get(o.eventId);if(d){if(d.content_hash!==o.contentHash||d.installation_id!==o.installationId)throw new Error("tool_learning_event_identity_conflict");return"already_retained"}this.db.prepare("INSERT INTO counters(installation_id) VALUES (?) ON CONFLICT DO NOTHING").run(l.id);let I=t-p.maximumQueueAgeSeconds*1e3,f=this.db.prepare("DELETE FROM events WHERE installation_id = ? AND received_at < ?").run(l.id,I).changes;if(this.db.prepare("UPDATE counters SET expired = expired + ? WHERE installation_id = ?").run(f,l.id),Date.parse(o.occurredAt)<I||Date.parse(o.occurredAt)>t+3e5)return this.db.prepare("UPDATE counters SET expired = expired + 1 WHERE installation_id = ?").run(l.id),"expired";let r=this.retainedUsage(),m=this.retainedUsage(l.id),_=this.db.prepare("SELECT COUNT(*) AS count, COALESCE(SUM(size_bytes), 0) AS bytes FROM events WHERE installation_id = ? AND episode_id = ?").get(l.id,o.episodeId);return Number(r.count)>=c.queueEvents||Number(r.bytes)+a>c.queueBytes||Number(m.count)>=p.maximumQueueEvents||Number(m.bytes)+a>p.maximumQueueBytes||Number(_.count)>=p.maximumEpisodeEvents||Number(_.bytes)+a>p.maximumEpisodeBytes?(this.db.prepare("UPDATE counters SET dropped = dropped + 1 WHERE installation_id = ?").run(l.id),"queue_full"):(this.db.prepare("INSERT INTO events VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(o.eventId,l.id,o.episodeId,o.sanitization.policyHash,o.contentHash,i,a,t),"retained")})}pending(n,t=c.eventsPerAppend){if(!Number.isInteger(t)||t<1||t>c.eventsPerAppend)throw new Error("tool_learning_queue_page_limit");this.expire(n);let o=this.installation(n);return!o?.enabled||!o.policy.purposes.includes("capture")?[]:this.db.prepare("SELECT payload FROM events WHERE installation_id = ? AND policy_hash = ? ORDER BY received_at, id LIMIT ?").all(n,E(o.policy),t).map(i=>R.parse(JSON.parse(String(i.payload))))}acknowledge(n,t){if(t.length>c.eventsPerAppend)throw new Error("tool_learning_ack_limit");this.transaction(()=>{for(let o of t){let i=this.db.prepare("DELETE FROM events WHERE installation_id = ? AND id = ? AND content_hash = ?").run(n,o.eventId,o.contentHash);o.state==="privacy_rejected"&&Number(i.changes)>0&&this.db.prepare("INSERT INTO counters(installation_id, dropped) VALUES (?, ?) ON CONFLICT(installation_id) DO UPDATE SET dropped = dropped + excluded.dropped").run(n,i.changes)}})}status(n){this.expire(n);let t=this.installation(n),o=this.db.prepare("SELECT COUNT(*) AS events, COALESCE(SUM(size_bytes), 0) AS bytes FROM events WHERE installation_id = ?").get(n),i=this.db.prepare("SELECT dropped, expired FROM counters WHERE installation_id = ?").get(n),a=t?.enabled&&t.policy.purposes.includes("capture")?Number(this.db.prepare("SELECT COUNT(*) AS count FROM events WHERE installation_id = ? AND policy_hash = ?").get(n,E(t.policy)).count):0;return{pendingEvents:Number(o.events),pendingBytes:Number(o.bytes),droppedEvents:Number(i?.dropped??0),expiredEvents:Number(i?.expired??0),blockedByPolicyEvents:Number(o.events)-a}}transaction(n){this.db.exec("BEGIN IMMEDIATE");try{let t=n();return this.db.exec("COMMIT"),t}catch(t){throw this.db.exec("ROLLBACK"),t}}expire(n){let t=this.installation(n);t&&this.transaction(()=>{let o=this.db.prepare("DELETE FROM events WHERE installation_id = ? AND received_at < ?").run(n,Date.now()-t.policy.maximumQueueAgeSeconds*1e3).changes;this.db.prepare("INSERT INTO counters(installation_id, expired) VALUES (?, ?) ON CONFLICT(installation_id) DO UPDATE SET expired = expired + excluded.expired").run(n,o)})}};var pe=e.object({state:e.enum(["incomplete","ambiguous","awaiting_owner_review"]),issues:e.array(e.enum(["missing_attempt","missing_observation","completion_not_observed","conflicting_observations","reference_mismatch","lineage_mismatch","mixed_scope","conflicting_event"])).max(8),groups:e.array(e.object({key:g,application:e.string().min(1).max(200),applicationVersion:e.string().min(1).max(200),tool:e.object({name:e.string().min(1).max(200),version:e.string().max(200).nullable(),server:e.string().max(200).nullable()}).strict(),environmentFingerprints:e.array(g).max(c.eventsPerEpisode),attempts:e.array(h).max(c.eventsPerEpisode)}).strict()).max(c.eventsPerEpisode)}).strict();function nt(n){let t=e.array(R).max(c.eventsPerEpisode).parse(n),o=new Set,i=new Set,a=new Map,l=t[0];for(let r of t){l&&(r.installationId!==l.installationId||r.episodeId!==l.episodeId)&&i.add("mixed_scope"),r.parentSessionId===r.sessionId&&i.add("lineage_mismatch");let m=a.get(r.eventId);m&&m.contentHash!==r.contentHash?i.add("conflicting_event"):a.set(r.eventId,r)}let p=[...a.values()].filter(r=>r.eventKind==="attempt"),d=new Map,I=new Map;p.length||o.add("missing_attempt");for(let r of a.values()){if(r.eventKind!=="observation")continue;let m=a.get(r.payload.attempt.id);m?m.eventKind!=="attempt"||m.contentHash!==r.payload.attempt.contentHash||m.payload.actionHash!==r.payload.actionHash?i.add("reference_mismatch"):(m.sessionId!==r.sessionId||m.callId!==r.callId||m.parentSessionId&&r.parentSessionId&&m.parentSessionId!==r.parentSessionId||m.turnId&&r.turnId&&m.turnId!==r.turnId)&&i.add("lineage_mismatch"):o.add("missing_attempt");let _=d.get(r.payload.attempt.id)??[];_.push(r),d.set(r.payload.attempt.id,_)}let f=new Map;for(let r of p){let m=JSON.stringify([r.sessionId,r.callId]),_=I.get(m);_&&_!==r.contentHash&&i.add("lineage_mismatch"),I.set(m,r.contentHash);let v=d.get(r.eventId)??[];if(!v.length)o.add("missing_observation");else{let N=v.filter(A=>A.payload.outcome!=="incomplete");N.length||o.add("completion_not_observed"),new Set(N.map(A=>L(A.payload))).size>1&&i.add("conflicting_observations")}let{environment:S,tool:b}=r.payload,U=L([S.application,S.version,b.name,b.version,b.server]),D=f.get(U)??{application:S.application,applicationVersion:S.version,tool:b,fingerprints:new Set,attempts:[]};D.fingerprints.add(S.fingerprint),D.attempts.push({id:r.eventId,contentHash:r.contentHash}),f.set(U,D)}return pe.parse({state:i.size?"ambiguous":o.size?"incomplete":"awaiting_owner_review",issues:[...new Set([...i,...o])].sort(),groups:[...f].sort(([r],[m])=>r.localeCompare(m)).map(([r,m])=>({key:r,application:m.application,applicationVersion:m.applicationVersion,tool:m.tool,environmentFingerprints:[...m.fingerprints].sort(),attempts:m.attempts.sort((_,v)=>_.id.localeCompare(v.id))}))})}u(nt,"assembleToolLearningEpisode");var ot=e.object({installation:H,apiKey:oe}).strict(),it=e.object({items:e.array(H).max(30),nextCursor:s.nullable()}).strict(),at=e.object({installationId:s,scope:C,items:e.array(e.object({episodeId:s,eventCount:e.number().int().positive(),lastReceivedAt:e.iso.datetime()}).strict()).max(30),nextCursor:s.nullable(),learningEnrollment:e.literal(!1)}).strict(),st=e.object({installationId:s,episodeId:s,scope:C,events:e.array(R).max(c.eventsPerEpisode),state:pe.shape.state,assembly:pe,verificationAuthority:e.literal("not_granted"),learningEnrollment:e.literal(!1)}).strict(),rt=e.object({operationId:s,expectedRevision:e.number().int().positive()}).strict(),lt=e.object({installationId:s,operationId:s,purgedEvents:e.number().int().nonnegative(),learningEnrollment:e.literal(!1)}).strict(),ue=T(e.object({registration:we,credential:e.object({apiKey:oe,expiresAt:e.iso.datetime()}).strict()}).strict(),c.eventBytes),ct=T(e.object({operationId:s,expectedRevision:e.number().int().positive(),episodeId:s,failure:h,recovery:h,taskDefinition:W,familyKey:s,split:e.literal("train"),proposedTarget:se,saveToPrivateDataset:e.literal(!0),targetApproval:e.literal("pending_owner_review")}).strict(),c.eventBytes),dt=T(e.object({installationId:s,projectId:s,operationId:s,source:W,evidence:W,originHash:e.string().regex(/^[a-f0-9]{64}$/),requestHash:e.string().regex(/^[a-f0-9]{64}$/),projectedAt:e.iso.datetime(),targetApproval:e.literal("pending_owner_review"),learningEnrollment:e.literal(!1)}).strict(),c.eventBytes),Ue=T(e.object({operationId:s,expectedRevision:e.number().int().nonnegative(),state:e.enum(["enabled","disabled"]),modelId:s,qualification:e.discriminatedUnion("kind",[e.object({kind:e.literal("integration"),evaluationRunId:s}).strict(),e.object({kind:e.literal("learned"),evaluationRunId:s,baselineRunId:s,trainingRunId:s}).strict()]),capabilities:e.array(Z.omit({qualification:!0})).min(1).max(16),limits:e.object({maxOutputTokens:e.number().int().min(128).max(2048),maximumCallUsd:e.number().positive().max(1),maximumDayUsd:e.number().positive().max(10),maximumSessionCalls:e.number().int().min(1).max(20),maximumDayCalls:e.number().int().min(1).max(200)}).strict()}).strict(),c.eventBytes),pt=T(e.object({installationId:s,scope:e.object({teamId:s,projectId:s}).strict(),revision:e.number().int().positive(),operationId:s,requestHash:e.string().regex(/^[a-f0-9]{64}$/),configuration:Ue,modelRelease:h,policySystemPrompt:e.string().min(1).max(16384),capabilities:e.array(Z).max(16),updatedAt:e.iso.datetime()}).strict(),c.eventBytes);var q=class extends Error{static{u(this,"OpenPondToolLearningError")}constructor(n,t){super(`Tool learning request failed (${n}): ${t}`),this.status=n,this.code=t,this.name="OpenPondToolLearningError"}status;code},De=class{static{u(this,"OpenPondToolLearningClient")}#o;#e;constructor(n){this.#e={...n};let t=new URL(n.baseUrl);if(!["https:","http:"].includes(t.protocol)||t.username||t.password||t.search||t.hash||!n.apiKey.trim()||!n.teamId.trim()||!n.projectId.trim())throw new Error("tool_learning_client_scope_required");this.#o=t.toString().replace(/\/+$/,"")}async register(n,t){let o=ue.parse(n);if(o.registration.projectId!==this.#e.projectId)throw new Error("tool_learning_project_mismatch");let i=ot.parse(await this.#t("installations","POST",o,t));if(this.#n(i.installation,o.registration.installationId),i.apiKey!==o.credential.apiKey)throw new Error("tool_learning_credential_mismatch");let a=i.installation;if(a.client!==o.registration.client||a.clientVersion!==o.registration.clientVersion||a.machineSourceId!==o.registration.machineSourceId||L(a.adapterRelease)!==L(o.registration.adapterRelease)||L(a.collectionPolicy)!==L(o.registration.collectionPolicy)||a.collectionPolicyHash!==L(o.registration.collectionPolicy)||a.credential?.expiresAt!==o.credential.expiresAt)throw new Error("tool_learning_registration_receipt_mismatch");return i}async installation(n,t){let o=H.parse(await this.#t(`installations/${encodeURIComponent(n)}`,"GET",void 0,t));return this.#n(o,n),o}async installations(n,t){let o=it.parse(await this.#t(`installations?projectId=${encodeURIComponent(this.#e.projectId)}${n?`&after=${encodeURIComponent(n)}`:""}`,"GET",void 0,t));for(let i of o.items)this.#n(i,i.id);if(o.nextCursor!==null&&o.nextCursor!==o.items.at(-1)?.id)throw new Error("tool_learning_installation_cursor_mismatch");return o}async episodes(n,t,o){let i=at.parse(await this.#t(`installations/${encodeURIComponent(n)}/episodes${t?`?after=${encodeURIComponent(t)}`:""}`,"GET",void 0,o));if(i.installationId!==n||i.scope.teamId!==this.#e.teamId||i.scope.projectId!==this.#e.projectId||i.nextCursor!==null&&i.nextCursor!==i.items.at(-1)?.episodeId)throw new Error("tool_learning_episode_page_mismatch");return i}async episode(n,t,o){let i=st.parse(await this.#t(`installations/${encodeURIComponent(n)}/episodes/${encodeURIComponent(t)}`,"GET",void 0,o));if(i.installationId!==n||i.episodeId!==t||i.scope.teamId!==this.#e.teamId||i.scope.projectId!==this.#e.projectId||i.events.some(a=>a.installationId!==n||a.episodeId!==t))throw new Error("tool_learning_episode_scope_mismatch");if(i.state!==i.assembly.state||L(nt(i.events))!==L(i.assembly))throw new Error("tool_learning_episode_assembly_mismatch");return i}async purge(n,t,o){let i=rt.parse(t),a=lt.parse(await this.#t(`installations/${encodeURIComponent(n)}/purge`,"POST",i,o));if(a.installationId!==n||a.operationId!==i.operationId)throw new Error("tool_learning_purge_scope_mismatch");return a}async project(n,t,o){let i=ct.parse(t),a=dt.parse(await this.#t(`installations/${encodeURIComponent(n)}/project`,"POST",i,o));if(a.installationId!==n||a.projectId!==this.#e.projectId||a.operationId!==i.operationId||a.requestHash!==L(i))throw new Error("tool_learning_projection_scope_mismatch");return a}async setState(n,t,o){let i=Ne.parse(t),a=H.parse(await this.#t(`installations/${encodeURIComponent(n)}`,"PATCH",i,o));if(this.#n(a,n),a.state!==i.state)throw new Error("tool_learning_state_mismatch");return a}async append(n,t){let o=Se.parse(n),i=Re.parse(await this.#t("episodes","POST",o,t));if(i.operationId!==o.operationId||i.installationId!==o.installationId||i.teamId!==this.#e.teamId||i.projectId!==this.#e.projectId||i.requestHash!==L(o)||i.events.length!==o.events.length||new Set(i.events.map(a=>a.eventId)).size!==i.events.length)throw new Error("tool_learning_append_receipt_mismatch");for(let a of i.events){let l=o.events.find(p=>p.eventId===a.eventId);if(!l||l.contentHash!==a.contentHash)throw new Error("tool_learning_append_event_mismatch")}return i}async routing(n,t){return this.#i(n,await this.#t(`installations/${encodeURIComponent(n)}/routing`,"GET",void 0,t))}async configureRouting(n,t,o){let i=Ue.parse(t),a=this.#i(n,await this.#t(`installations/${encodeURIComponent(n)}/routing`,"POST",i,o));if(a.operationId!==i.operationId||a.requestHash!==L(i)||L(a.configuration)!==L(i))throw new Error("tool_learning_routing_receipt_mismatch");return a}#i(n,t){let o=pt.parse(t);if(o.installationId!==n||o.scope.teamId!==this.#e.teamId||o.scope.projectId!==this.#e.projectId)throw new Error("tool_learning_routing_scope_mismatch");return o}async manifest(n,t){let o=Oe.parse(await this.#t(`installations/${encodeURIComponent(n)}/manifest`,"GET",void 0,t));if(o.installationId!==n||o.scope.teamId!==this.#e.teamId||o.scope.projectId!==this.#e.projectId)throw new Error("tool_learning_manifest_scope_mismatch");if(Date.parse(o.expiresAt)<=Date.now()||Date.parse(o.issuedAt)>Date.now()+3e4)throw new Error("tool_learning_manifest_expired");return o}async consult(n,t){let o=O.parse(n);if(o.scope.teamId!==this.#e.teamId||o.scope.projectId!==this.#e.projectId)throw new Error("tool_learning_consultation_scope_mismatch");return re(o,await this.#t("consultations","POST",o,t))}async consultation(n,t){let o=O.parse(n);if(o.scope.teamId!==this.#e.teamId||o.scope.projectId!==this.#e.projectId)throw new Error("tool_learning_consultation_scope_mismatch");return re(o,await this.#t(`installations/${encodeURIComponent(o.installationId)}/consultations/${encodeURIComponent(o.operationId)}`,"GET",void 0,t))}#n(n,t){if(n.id!==t||n.scope.teamId!==this.#e.teamId||n.scope.projectId!==this.#e.projectId)throw new Error("tool_learning_installation_scope_mismatch")}async#t(n,t,o,i){o!==void 0&&B(o,c.eventBytes*c.eventsPerAppend);let a=AbortSignal.timeout(3e4),l=await(this.#e.fetch??globalThis.fetch)(`${this.#o}/v1/tool-learning/${n}`,{method:t,redirect:"error",signal:i?AbortSignal.any([i,a]):a,headers:{Authorization:`Bearer ${this.#e.apiKey}`,"X-OpenPond-Team-Id":this.#e.teamId,Accept:"application/json",...o===void 0?{}:{"Content-Type":"application/json"}},...o===void 0?{}:{body:JSON.stringify(o)}}),p=await ye(l,c.eventBytes*c.eventsPerAppend,"Tool learning response");if(!l.ok){let d=e.object({code:e.string().regex(/^[a-z0-9_]+$/).max(200)}).passthrough().safeParse(p);throw new q(l.status,d.success?d.data.code:"tool_learning_request_failed")}return p}};var vn=u(()=>be,"nativeToolLearningClientVersion"),ut=u((n,t)=>typeof n[t]=="string"?n[t].trim():"","optionString"),Be=e.object({schemaVersion:e.literal("openpond.toolLearningLocalCredential.v1"),apiOrigin:e.string().url().refine(n=>new URL(n).origin===n),teamId:s,projectId:s,ownerAccount:e.string().nullable(),workspaceRoot:e.string().min(1),locallyEnabled:e.boolean(),environment:j.nullable().default(null),prepared:ue,installation:H.nullable()}).strict(),Tn=u(n=>Ie({home:ut(n,"home")||void 0}),"toolLearningHome"),Pe=u(n=>`tool-learning:installation:${s.parse(n)}`,"toolLearningCredentialId");async function k(n,t){let o=await Ee(n,Pe(t));if(!o)throw new Error("Tool learning installation is not configured in this OpenPond home.");let i=Be.parse(o.value);if(i.prepared.registration.installationId!==t||i.prepared.registration.projectId!==i.projectId)throw new Error("Tool learning credential scope does not match its installation.");return{...o,value:i}}u(k,"loadToolLearningCredential");async function qe(n,t,o){let i=Be.parse(t);return Te(n,Pe(i.prepared.registration.installationId),i,o)}u(qe,"saveToolLearningCredential");function G(n){return new De({baseUrl:n.apiOrigin,apiKey:n.prepared.credential.apiKey,teamId:n.teamId,projectId:n.projectId})}u(G,"toolLearningProducer");function F(n,t,o){let i=t.prepared.registration;if(!["openpond","claude_code","opencode","codex"].includes(i.client))throw new Error("This client has not been qualified for installation.");return n.configure({schemaVersion:"openpond.localToolLearningInstallation.v1",id:i.installationId,teamId:t.teamId,projectId:t.projectId,client:i.client,workspaceRoot:t.workspaceRoot,enabled:t.locallyEnabled&&o?.state==="enabled",policy:i.collectionPolicy,createdAt:o?.createdAt??new Date().toISOString()})}u(F,"configureLocalToolLearning");async function ee(n,t,o,i){let a=G(o),l=o.prepared.registration.installationId;if(!o.locallyEnabled)return F(t,o,null),{installationId:l,deliveredEvents:0,rejectedEvents:0,local:t.status(l),learningEnrollment:!1};let p=u(async()=>{F(t,o,null);let r=await k(n,l);r.value.locallyEnabled&&await qe(n,{...r.value,locallyEnabled:!1},r.revision)},"suspend"),d;try{d=await a.installation(l,i)}catch(r){throw r instanceof q&&[401,403].includes(r.status)&&await p(),r}if(d.state!=="enabled"&&await p(),d.collectionPolicyHash!==E(o.prepared.registration.collectionPolicy))throw await p(),new Error("Tool learning collection policy changed. Reconfigure this installation before uploading.");F(t,o,d);let I=0,f=0;for(let r=0;r<16;r++){let m=t.pending(l);if(!m.length)break;let _=await a.append({schemaVersion:"openpond.toolEpisodeAppend.v1",installationId:l,operationId:`tool-append-${y([l,m.map(v=>[v.eventId,v.contentHash])])}`,events:m},i).catch(async v=>{throw v instanceof q&&[401,403].includes(v.status)&&await p(),v});t.acknowledge(l,_.events),I+=_.events.filter(v=>v.state!=="privacy_rejected").length,f+=_.events.filter(v=>v.state==="privacy_rejected").length}return{installationId:l,deliveredEvents:I,rejectedEvents:f,local:t.status(l),learningEnrollment:!1}}u(ee,"flushToolLearning");import{realpath as mt}from"node:fs/promises";function ht(n,t){let o=Buffer.from(n),i=Math.min(o.length,t);for(;i<o.length&&(o[i]&192)===128;)i--;return o.subarray(0,i).toString("utf8")}u(ht,"boundedExcerpt");function ke(n){try{B(n,32768)}catch{return!0}let t=JSON.stringify(n);if(/(?:^|[\s/\\'"=])\.env(?:[.\s/\\'";]|$)/u.test(t))return!0;let o=J(t);return o.secretStatus!=="passed"||o.piiStatus!=="passed"}u(ke,"privatePayload");async function Bn(n,t){let o=await mt(t.workspaceRoot),i=new X(n),a=[],l=AbortSignal.timeout(2e3);try{let p=i.installations().filter(d=>d.enabled&&d.client===t.client&&d.workspaceRoot===o&&(!t.installationId||d.id===t.installationId)&&d.policy.permittedTools.includes(t.tool));for(let d of p){let I=await k(n,d.id),f=I.value;if(!f.locallyEnabled||f.prepared.registration.clientVersion!==t.clientVersion||f.workspaceRoot!==o||f.installation?.state!=="enabled"||t.accountScope&&(f.apiOrigin!==t.accountScope.apiOrigin||f.ownerAccount!==t.accountScope.accountHandle||f.installation.ownerUserId!==t.accountScope.ownerUserId||t.accountScope.teamId&&t.accountScope.teamId!==f.teamId))continue;F(i,f,f.installation);let r=d.policy,m=y(r);if(!r.purposes.includes("capture")||!r.workspaceRootHashes.includes(y(o)))continue;let _=u(ne=>r.permittedFields.includes(ne),"permits"),v=`tool-boundary-${y([d.id,t.sessionId,t.callId,t.phase])}`,S={schemaVersion:"openpond.toolEpisodeEvent.v1",operationId:v,installationId:d.id,episodeId:`tool-episode-${y([d.id,t.sessionId,t.callId])}`,eventId:v,sessionId:t.sessionId,parentSessionId:t.parentSessionId??null,turnId:t.turnId??null,callId:t.callId,occurredAt:new Date().toISOString(),sequence:t.phase==="attempt"?0:1,adapterVersion:f.prepared.registration.adapterRelease.id,sanitization:{policyRevision:r.revision,policyHash:m,redactedFields:0,omittedFields:0,truncated:!1}};if(t.phase==="attempt"){if(!_("action"))continue;let ne=t.invalidArguments===void 0?{kind:"tool_arguments",arguments:t.arguments}:{kind:"tool_arguments",arguments:{invalidArguments:t.invalidArguments}},me=P.safeParse(ne);if(!me.success){i.recordDropped(d.id);continue}let he=me.data,ge=t.environment??f.environment??{application:t.tool,version:t.clientVersion,state:{workspaceRootHash:y(o)},fingerprint:y([t.tool,t.clientVersion,o])},Me=j.parse(_("state")?ge:{...ge,state:{}}),fe={intent:_("intent")?t.intent??"":"",tool:{name:t.tool,version:t.clientVersion,server:null},action:he,actionHash:y(he),environment:Me,contextAssets:[],selection:{kind:"eligible_attempt"}};if(ke(fe)){i.recordDropped(d.id);continue}let _e=i.retainCaptureBoundary(ae({...S,eventKind:"attempt",payload:fe}));_e&&a.push({installationId:d.id,event:_e});continue}let b=i.captureBoundary(d.id,t.sessionId,t.callId,"attempt");if(!b||b.eventKind!=="attempt"||!t.result)continue;let U=r.unchangedControls;if(!(t.result.outcome!=="succeeded"||i.hasRecoveryCandidateContext(d.id,t.sessionId)||parseInt(y([d.id,t.sessionId,t.callId]).slice(0,8),16)/4294967296<U.numerator/U.denominator))continue;if((!t.result.text||Buffer.byteLength(t.result.text)>8192)&&Buffer.byteLength(t.result.text)>8192){i.recordDropped(d.id);continue}let N={attempt:{id:b.eventId,contentHash:b.contentHash},actionHash:b.payload.actionHash,execution:t.result.execution,sideEffects:t.result.sideEffects,resultExcerpt:_("result_excerpt")?t.result.text:"",resultHash:_("result_excerpt")?y(t.result.text):null,assets:[]},A=t.result.outcome==="succeeded"?{...N,outcome:"succeeded",exitCode:t.result.exitCode??null}:t.result.outcome==="incomplete"?{...N,outcome:"incomplete",reason:"completion_not_observed"}:{...N,outcome:"failed",classification:t.result.classification??"unknown_failure",errorCode:t.result.classification??"unknown_failure",message:_("result_excerpt")?ht(t.result.text,2e3):"",exitCode:t.result.exitCode??null};if(ke(A)){i.recordDropped(d.id);continue}let te=i.retainCaptureBoundary(ae({...S,episodeId:b.episodeId,eventKind:"observation",payload:A}));if(te){i.append(b),i.append(te),a.push({installationId:d.id,event:te});try{await ee(n,i,f,l)}catch{}}}return a.map(d=>({installationId:d.installationId,eventId:d.event.eventId,contentHash:d.event.contentHash}))}finally{i.close()}}u(Bn,"captureLocalToolBoundary");var gt=e.object({sessionId:e.string().min(1).max(200),failedCallId:e.string().min(1).max(200),capabilityId:e.string().min(1).max(200),intent:e.string().max(2e3)}).strict();async function Xn(n,t,o,i){let a=gt.parse(o),{value:l}=await k(n,t);if(!l.locallyEnabled||l.installation?.state!=="enabled")throw new Error("tool_learning_consultation_disabled");let p=new X(n);try{F(p,l,l.installation);let d=p.captureBoundary(t,a.sessionId,a.failedCallId,"attempt"),I=p.captureBoundary(t,a.sessionId,a.failedCallId,"observation");if(!d||d.eventKind!=="attempt"||!I||I.eventKind!=="observation"||I.payload.outcome!=="failed")throw new Error("tool_learning_observed_failure_required");let f=J(a.intent);if(f.secretStatus!=="passed"||f.piiStatus!=="passed")throw new Error("tool_learning_consultation_privacy_blocked");let r=G(l),m={message:I.payload.message,observation:{id:I.eventId,contentHash:I.contentHash}},_=y({intent:a.intent,environment:d.payload.environment,failure:m}),v=p.consultationForCall(t,a.sessionId,a.failedCallId);if(v){let N=v.operationId;if(v.contextHash!==_||v.capabilityId!==a.capabilityId)return{operationId:N,response:{state:"unavailable",reason:"failure_already_submitted"},recovery:"Read the original consultation with openpond_consult_status. Changing context or capability does not authorize another paid call."};try{return{operationId:N,response:await r.consultation(v,i)}}catch(A){if(!(A instanceof q)||A.status!==404||A.code!=="tool_learning_consultation_not_found")throw A;return Fe(r,v,i)}}let S=await r.manifest(t,i),b=S.capabilities.find(N=>N.id===a.capabilityId);if(!b||b.application!==d.payload.environment.application||!b.versions.includes(d.payload.environment.version)||!b.tools.includes(d.payload.tool.name))throw new Error("tool_learning_consultation_scope_unsupported");let U=`tool-consult-${y([t,a.sessionId,a.failedCallId,a.capabilityId,d.payload.actionHash,_,S.modelRelease])}`,D=O.parse({schemaVersion:"openpond.toolLearningConsultation.v1",operationId:U,installationId:t,scope:S.scope,sessionId:a.sessionId,callId:a.failedCallId,capabilityId:a.capabilityId,manifestHash:S.contentHash,modelRelease:S.modelRelease,mode:"recovery",intent:a.intent,action:d.payload.action,actionHash:d.payload.actionHash,environment:d.payload.environment,contextHash:_,failure:m,round:1});return p.retainConsultationRequest(D),await ee(n,p,l,i),Fe(r,D,i)}finally{p.close()}}u(Xn,"consultLocalToolLearning");async function Gn(n,t,o,i){let{value:a}=await k(n,t);if(!a.locallyEnabled)throw new Error("tool_learning_consultation_disabled");let l=new X(n);try{let p=l.consultationRequest(t,o);if(!p)throw new Error("tool_learning_consultation_request_not_retained");return{operationId:o,response:await G(a).consultation(p,i)}}finally{l.close()}}u(Gn,"readLocalToolConsultation");async function Fe(n,t,o){try{return{operationId:t.operationId,response:await n.consult(t,o)}}catch(i){let a=i instanceof q&&i.status>=400&&i.status<500&&i.status!==408;return{operationId:t.operationId,response:{state:"unavailable",reason:a?i.code:"dispatch_uncertain"},recovery:a?"Resolve the reported admission error. Keep this original operation ID; do not create a replacement paid request.":"Use openpond_consult_status with this operationId; do not create a replacement request."}}}u(Fe,"submitLocalToolConsultation");export{c as a,s as b,g as c,h as d,C as e,T as f,j as g,R as h,Se as i,Re as j,we as k,H as l,Ne as m,Z as n,Oe as o,O as p,se as q,re as r,X as s,De as t,vn as u,Be as v,Tn as w,Pe as x,k as y,qe as z,G as A,F as B,ee as C,Bn as D,gt as E,Xn as F,Gn as G};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b}from"./chunk-EICS777E.js";import{b as P}from"./chunk-
|
|
2
|
+
import{b}from"./chunk-EICS777E.js";import{b as P}from"./chunk-4EZI4KCT.js";import{a as T}from"./chunk-UOFDKMRU.js";import{d as q,e as I}from"./chunk-R6VI7MX5.js";import{fb as k,ob as R}from"./chunk-ZY32SZ2P.js";import{r as y}from"./chunk-OTDDXEQ6.js";import{n as i}from"./chunk-RCT3O3HQ.js";import{a as d}from"./chunk-FTQLQJQV.js";import{readFile as B}from"node:fs/promises";import A from"node:path";async function O(t){let o=k.parse(t.source),s;if(t.authorizeWorkspace){let r=await t.store.getHarnessReleaseRecord(o.harnessRelease.contentHash),m=r&&await t.store.getHarnessWorkspace(r.workspaceId);if(!r||!m||r.harnessRelease.id!==o.harnessRelease.id)throw new Error("The selected immutable Harness has no persisted owning workspace.");await t.authorizeWorkspace(o,m),s=await I({workspace:m,release:r})}else s=await q(t.store,o.harnessRelease);if(!s)throw new Error("The selected immutable Harness is unavailable.");let n=s.release;if(i(o.agentSnapshot)!==i({id:n.agentSnapshot.id,contentHash:n.agentSnapshot.contentHash}))throw new Error("The selected Harness differs from its admitted Agent snapshot.");let e=A.join(n.bundlePath,"source"),p=new Map;for(let r of n.harnessRelease.files)p.set(r.path,await B(A.join(e,...r.path.split("/"))));let l=y({agentSnapshot:n.agentSnapshot,harnessRelease:n.harnessRelease,files:p});if(l.contentHash!==o.sourcePackageHash)throw new Error("The selected Harness source bytes differ from the admitted package.");let c=T(n);return b({sourcePackage:l,expectedRelease:o.harnessRelease,baseSystemPrompt:"",runtimeId:"openpond.native-standalone-experiment.v1",tools:c.map(r=>({name:r.name,inputSchema:r.inputSchema,definition:{type:"function",function:{name:r.name,description:r.description,parameters:r.inputSchema}}})),maxContextCharacters:262144}),{runtime:s,sourcePackage:l}}d(O,"resolveStandaloneExperimentSource");function C(t){if(!t.turn.completedAt)throw new Error("Native Experiment receipt requires a settled turn.");let o=Buffer.byteLength(t.output,"utf8")>t.maxOutputBytes,s=t.cancelled?"cancelled":t.timedOut?"timed_out":t.turn.status==="interrupted"?"cancelled":t.turn.status==="completed"&&!o?"completed":"policy_failure",n=s==="completed"?null:o?"Native Harness output exceeded its admitted byte limit.":s==="timed_out"?"Native Harness case timed out.":s==="cancelled"?"Native Harness case was cancelled.":"Native Harness case failed; inspect its retained turn evidence.",e={schemaVersion:"openpond.nativeHarnessExperimentAttempt.v1",taskId:t.request.taskId,status:s,output:s==="completed"?t.output:null,error:n,messages:[{role:"user",text:JSON.stringify({instructions:t.request.instructions,input:t.request.input,policyVisibleContext:t.request.policyVisibleContext})},...s==="completed"?[{role:"assistant",text:t.output,toolCalls:[]}]:[]],collected:s==="completed",environmentCleanupComplete:!0,snapshot:null,native:{sessionId:t.turn.sessionId,turnId:t.turn.id,source:t.source,admissionHash:t.request.admissionHash,modelConfigurationHash:t.request.model.configurationHash,traceHash:t.traceHash,runtimeEventRefs:t.runtimeEventRefs,startedAt:t.turn.startedAt,completedAt:t.turn.completedAt,outputHash:i(t.output),partialOutputAvailable:s!=="completed"&&t.output.length>0}};return R(e)}d(C,"sealStandaloneExperimentReceipt");function ee(t){let o=new Map;async function s(e,p){let l=e.metadata?.standaloneExperiment;if(l===void 0)return null;let c=o.get(e.id);if(!c||i(l)!==i(c.binding)||e.currentProfile||e.profileComponentBinding||e.profileWorkflowBinding||p.sessionId!==e.id||p.profileSnapshot)throw new Error("Standalone Experiment turn has no matching active execution owner.");return c.stream}d(s,"resolveSessionModelStream");async function n(e){if(!Number.isSafeInteger(e.maxOutputBytes)||e.maxOutputBytes<1||e.maxOutputBytes>8388608)throw new Error("Native Experiment requires a bounded positive output limit.");if(!e.request.harness||i(e.request.harness)!==i(e.source))throw new Error("Native Experiment source differs from its admitted case.");if(e.request.environment.kind!=="text")throw new Error("Standalone native Harness execution requires a compatible text Dataset.");if(e.request.model.messages.length)throw new Error("Standalone Harness cases use released instructions; additional raw prompt messages are not qualified.");e.signal.throwIfAborted();let{runtime:p}=await O({store:t.store,source:e.source,authorizeWorkspace:t.authorizeWorkspace}),l={executionId:e.executionId,caseId:e.request.id,admissionHash:e.request.admissionHash,source:e.source,modelConfigurationHash:e.request.model.configurationHash},c={providerId:e.request.model.providerId,modelId:e.request.model.modelId},r=await t.createSession({provider:c.providerId,modelRef:c,currentProfile:null,hiddenFromDefaultSidebar:!0,metadata:{standaloneExperiment:l}});if(r.currentProfile||r.profileComponentBinding||r.profileWorkflowBinding)throw new Error("Standalone Experiment session acquired an unrelated Profile.");await P({store:t.store,runId:r.id,workspace:p.workspace,harnessRelease:e.source.harnessRelease,admittedAt:r.createdAt});let m=AbortSignal.any([e.signal,AbortSignal.timeout(e.request.timeoutMs)]),N=d(async function*(u){if(u.model!==c.modelId)throw new Error("Native Experiment requested a different model.");for await(let a of e.stream({...u,maxTokens:e.request.model.maxOutputTokens,temperature:e.request.model.temperature,topP:e.request.model.topP,signal:u.signal?AbortSignal.any([m,u.signal]):m}))yield a},"stream");o.set(r.id,{binding:l,stream:N});let h,x=d(()=>{h??=t.interruptSessionTurn(r.id,"Standalone Experiment case cancelled or timed out."),h.catch(()=>{})},"onAbort");m.addEventListener("abort",x,{once:!0});let w=!1,g=!1;try{m.throwIfAborted();let u=[e.request.instructions,JSON.stringify({input:e.request.input,policyVisibleContext:e.request.policyVisibleContext})].filter(Boolean).join(`
|
|
3
3
|
|
|
4
4
|
`);w=!0;let a=await t.sendTurn(r.id,{prompt:u,modelRef:c,approvalPolicy:"on-request"});if(h&&await h,!a.completedAt||a.status==="in_progress")throw new Error("Native Experiment turn did not settle.");if(g=!0,a.profileSnapshot||!a.harnessSnapshot||i(a.harnessSnapshot.harnessRelease)!==i(e.source.harnessRelease)||i(a.modelRef)!==i(c))throw new Error("Native Experiment turn differs from its admitted model or standalone Harness.");let S=await t.store.runtimeEventsForTurn(a.id);if(S.some(f=>f.sessionId!==r.id||f.turnId!==a.id))throw new Error("Native Experiment trace contains evidence from another case.");let W=S.filter(f=>f.name==="assistant.delta"&&typeof f.output=="string").map(f=>f.output).join(""),H=i(S),E=M(S),v=C({request:e.request,source:e.source,turn:a,output:W,traceHash:H,runtimeEventRefs:E,cancelled:e.signal.aborted,timedOut:m.aborted&&!e.signal.aborted,maxOutputBytes:e.maxOutputBytes});return{sessionId:r.id,turn:a,output:v.output,traceHash:H,runtimeEventRefs:E,cleanupComplete:!0,attempt:v}}catch(u){if(w&&!g){let a=await(h??t.interruptSessionTurn(r.id,"Standalone Experiment execution failed."));if(a.status==="in_progress"||!a.completedAt)throw new Error("Standalone Experiment cleanup remains unconfirmed.",{cause:u})}throw u}finally{m.removeEventListener("abort",x),o.delete(r.id)}}return d(n,"execute"),{execute:n,resolveSessionModelStream:s}}d(ee,"createStandaloneExperimentTurnOwner");function M(t){let o=-1;for(let n=t.length-1;n>=0;n--)if(t[n]?.name.endsWith(".delta")){o=n;break}let s=t.flatMap((n,e)=>n.name.endsWith(".delta")&&e!==o?[]:[n.id]);if(s.length>1e4)throw new Error("Native Experiment trace exceeds its evidence-reference limit.");return s}d(M,"retainedEventRefs");export{O as a,ee as b};
|