openpond 0.2.53 → 0.2.55
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 +1514 -100
- package/dist/app-server.js +1 -1
- package/dist/chunks/actions-command-WTFZA7LF.js +2 -0
- package/dist/chunks/{app-layer-I7MZYVLL.js → app-layer-Y2UERCPY.js} +1 -1
- package/dist/chunks/app-server-runtime-2RM3N4I6.js +2 -0
- package/dist/chunks/apps-KDNWYO3G.js +2 -0
- package/dist/chunks/chunk-2DFR7PJ4.js +2460 -0
- package/dist/chunks/chunk-4CRM2ADK.js +2 -0
- package/dist/chunks/{chunk-7ZG3IT7C.js → chunk-4WEUCGJ3.js} +6 -6
- package/dist/chunks/chunk-55G6B54U.js +6 -0
- package/dist/chunks/chunk-73G5UYBB.js +12 -0
- package/dist/chunks/{chunk-DALJMSJG.js → chunk-ARQEJOEK.js} +24 -24
- package/dist/chunks/chunk-B7QDZPNX.js +2 -0
- package/dist/chunks/chunk-BFKYRQMA.js +2 -0
- package/dist/chunks/{chunk-AH22RHPS.js → chunk-BQAF5P7K.js} +2 -2
- package/dist/chunks/{chunk-YJ4PNAST.js → chunk-BTI4N7YO.js} +1 -1
- package/dist/chunks/chunk-C6D4WAYN.js +6 -0
- package/dist/chunks/chunk-CGBI2VYJ.js +2 -0
- package/dist/chunks/chunk-DLVPSCTB.js +2 -0
- package/dist/chunks/{chunk-UJ5EFSEC.js → chunk-G6JMQGX7.js} +1 -1
- package/dist/chunks/chunk-GGIG3XU7.js +3 -0
- package/dist/chunks/chunk-IODUCRBA.js +58 -0
- package/dist/chunks/chunk-JIMU3KDA.js +24 -0
- package/dist/chunks/chunk-JUJSA7KI.js +22 -0
- package/dist/chunks/chunk-K5SBVO3B.js +195 -0
- package/dist/chunks/chunk-KD3QVRIJ.js +21 -0
- package/dist/chunks/chunk-KGNCKIFP.js +3 -0
- package/dist/chunks/chunk-L4235TRQ.js +140 -0
- package/dist/chunks/{chunk-N5QNXMIS.js → chunk-MH3LHSGX.js} +1 -1
- package/dist/chunks/chunk-MVF3F5QS.js +2 -0
- package/dist/chunks/{chunk-N3DEA6PG.js → chunk-NNIRIUSY.js} +1 -1
- package/dist/chunks/{chunk-WITSXYEW.js → chunk-NOTXPD2T.js} +1 -1
- package/dist/chunks/{chunk-T5LE6R5S.js → chunk-OSIO7PLX.js} +1 -1
- package/dist/chunks/chunk-OULAKUIN.js +2 -0
- package/dist/chunks/chunk-OWNLDB2O.js +2 -0
- package/dist/chunks/{chunk-NAZ26IZL.js → chunk-Q7AXHFZV.js} +1 -1
- package/dist/chunks/chunk-QDHMP5FS.js +2 -0
- package/dist/chunks/chunk-QKD5OMDI.js +2 -0
- package/dist/chunks/{chunk-YD55Z5H3.js → chunk-QRAKXZOC.js} +10 -10
- package/dist/chunks/{chunk-JDLAHVAJ.js → chunk-R27YGT77.js} +1 -1
- package/dist/chunks/chunk-R2BSIRYL.js +3 -0
- package/dist/chunks/chunk-SHQOIROR.js +42 -0
- package/dist/chunks/chunk-STDMBJOQ.js +9 -0
- package/dist/chunks/chunk-T4QGDQHP.js +4 -0
- package/dist/chunks/{chunk-R3XFY7VL.js → chunk-TERVLCRG.js} +1 -1
- package/dist/chunks/{chunk-PA7XP42P.js → chunk-U2YMBCX7.js} +1 -1
- package/dist/chunks/{chunk-GXSTZBM6.js → chunk-UA5DA5I2.js} +1 -1
- package/dist/chunks/chunk-VJEZPDBS.js +5 -0
- package/dist/chunks/chunk-WDFLCNRC.js +8 -0
- package/dist/chunks/chunk-WZYRAR7X.js +16 -0
- package/dist/chunks/chunk-YDT7L3VZ.js +24 -0
- package/dist/chunks/chunk-YR5ID2SS.js +2 -0
- package/dist/chunks/chunk-YUPBAWBJ.js +554 -0
- package/dist/chunks/cli-465VC2WP.js +2 -0
- package/dist/chunks/{configuration-command-MATM4XR5.js → configuration-command-LAAP2EXT.js} +1 -1
- package/dist/chunks/connected-evidence-XM626247.js +2 -0
- package/dist/chunks/{continual-PKK2BOTB.js → continual-TTGJ6YTR.js} +1 -1
- package/dist/chunks/core-commands-W7EK552V.js +2 -0
- package/dist/chunks/datasets-QJWYTTQL.js +2 -0
- package/dist/chunks/desktop-test-3B2D34NF.js +3 -0
- package/dist/chunks/dist-FAJX2UBW.js +2 -0
- package/dist/chunks/{dist-4HV2W6V4.js → dist-HUAE2KFZ.js} +1 -1
- package/dist/chunks/{chunk-6VF3Q6QJ.js → dist-SKYG5LZO.js} +2 -4
- package/dist/chunks/evaluation-coordination-2MONR4AX.js +2 -0
- package/dist/chunks/experiment-improvements-WVQ5FK46.js +2 -0
- package/dist/chunks/experiments-S5UQ32QB.js +2 -0
- package/dist/chunks/extension-DWMY6D2R.js +4 -0
- package/dist/chunks/{help-WLKSACLZ.js → help-A72QDRNG.js} +1 -1
- package/dist/chunks/hosted-experiment-improvement-2OWOQLHC.js +3 -0
- package/dist/chunks/hosted-harness-runtime-TGFMAV7W.js +2 -0
- package/dist/chunks/hosted-profile-candidate-WQSI6HZO.js +3 -0
- package/dist/chunks/hosted-profile-compiler-Z2A4TEA6.js +2 -0
- package/dist/chunks/hosted-profile-evaluation-control-FKGARUEE.js +2 -0
- package/dist/chunks/hosted-profile-evaluation-inspection-QOY2JKV4.js +3 -0
- package/dist/chunks/hosted-profile-evaluation-preparation-WVP6CALP.js +3 -0
- package/dist/chunks/human-review-TGHQKXFZ.js +2 -0
- package/dist/chunks/{import-V3HUGRHR.js → import-4UE5XNSG.js} +1 -1
- package/dist/chunks/javascript-isolate-process-source-ZPQKKLR4.js +2 -0
- package/dist/chunks/javascript-verifier-worker-source-F3LSGPOY.js +2 -0
- package/dist/chunks/learning-R2XBMMEM.js +2 -0
- package/dist/chunks/opchat-WULL6CUP.js +3 -0
- package/dist/chunks/organizations-I37HISVX.js +2 -0
- package/dist/chunks/profile-NOZ6TVXL.js +3 -0
- package/dist/chunks/project-agent-T6XKC54C.js +2 -0
- package/dist/chunks/sandbox-command-STB47FRY.js +2 -0
- package/dist/chunks/{sandbox-template-BBGGPJMI.js → sandbox-template-LKGBDVJ4.js} +1 -1
- package/dist/chunks/sql-execution-process-source-B4HQM6ZV.js +2 -0
- package/dist/chunks/src-T3KWWCAH.js +322 -0
- package/dist/chunks/{src-CR6UZYTX.js → src-ZWJ5IO7A.js} +1 -1
- package/dist/chunks/{taskset-LUG3ZU6J.js → taskset-RNYDR4GS.js} +1 -1
- package/dist/chunks/{teams-bot-7I4BAUVO.js → teams-bot-H7XT23XB.js} +1 -1
- package/dist/chunks/{training-XHE6FVII.js → training-M6FAPRSJ.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/web/assets/App-CLFfy_Av.js +154 -0
- package/dist/web/assets/App-CTlAPuCY.css +1 -0
- package/dist/web/assets/{AppDialog-BdusXgU0.js → AppDialog-CPHTPqrx.js} +1 -1
- package/dist/web/assets/{AppTerminalPanel-C4uRpnBz.js → AppTerminalPanel-BVj5Tj93.js} +2 -2
- package/dist/web/assets/AppsView-O69zEBY3.js +1 -0
- package/dist/web/assets/{BrowserSidebar-Bl7V6YO2.js → BrowserSidebar-Pr_Kpe8p.js} +1 -1
- package/dist/web/assets/{CartesianChart-BstFbsdn.js → CartesianChart-JPqo6YOf.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-B8YAf0c1.js → CollaborationTabs-CAJcQFn2.js} +1 -1
- package/dist/web/assets/{CommandMenu-DZct7zUJ.js → CommandMenu-B-w53n9A.js} +1 -1
- package/dist/web/assets/{CommunityView-CR0-W-uG.js → CommunityView-DbZKK8_P.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-DR-Qo7b4.js → ComposerCreateImproveStrip-3_083PF4.js} +1 -1
- package/dist/web/assets/{GetStartedView-xqQoMMei.js → GetStartedView-D7JGm_6c.js} +1 -1
- package/dist/web/assets/HostedModelLearningReview-DwgMfZ7_.js +1 -0
- package/dist/web/assets/{HostedModelLearningSettings-De3i9wF4.js → HostedModelLearningSettings-JRfQadRl.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-DAY1MmqP.js → LabModelVersionDetailPage-BUYflJY_.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-DLnIgnry.js → LabSkillSidebar-BBiqk7Rf.js} +1 -1
- package/dist/web/assets/LabsRoute-Ci6vUnSd.js +99 -0
- package/dist/web/assets/MainChatThread-BQK3oI2N.js +2 -0
- package/dist/web/assets/MainPane-D3ojiN-p.js +18 -0
- package/dist/web/assets/{MarkdownText-gJMuefaJ.js → MarkdownText-DOdOVFXL.js} +25 -25
- package/dist/web/assets/{NativeSkillSidebar-Dlxb8iOC.js → NativeSkillSidebar-CRI_ri8z.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-DM-cqJ-K.js → NewExperienceSwitcher-DhYtfE68.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-Cu1q75gq.js → NewProjectDialog-D8sy1gOz.js} +1 -1
- package/dist/web/assets/{OutputsPage-DiXMkasl.js → OutputsPage-CbWgrhXA.js} +1 -1
- package/dist/web/assets/{ProjectsPage-DqiBHiCB.js → ProjectsPage-DLB67lyA.js} +1 -1
- package/dist/web/assets/RightChatPanelStack-ozSKnDyX.js +1 -0
- package/dist/web/assets/{RightSidebarHomePanel-CeSFJM5s.js → RightSidebarHomePanel-CKs3OwhD.js} +1 -1
- package/dist/web/assets/ScheduledWorkPage-Cafv_QnR.js +1 -0
- package/dist/web/assets/SettingsView-T1vYDPjh.js +5 -0
- package/dist/web/assets/{TeamChatView-DM0adMtj.js → TeamChatView-vIrmXOY_.js} +2 -2
- package/dist/web/assets/{TerminalOverlay-CFlH51DD.js → TerminalOverlay-CAmF__Dq.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-CgIBVGha.js → TrainingCreationPanel-D75K0yk5.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-Bbo3RRie.js → TrainingDraftPanel-D7XZePAk.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-CSRjJUSa.js → UsageSettingsSection-CYTmp7PG.js} +1 -1
- package/dist/web/assets/WorkSidebarPanel-CODMjVHY.js +1 -0
- package/dist/web/assets/WorkspaceDiffPanel-DQGoIjH9.js +14 -0
- package/dist/web/assets/WorkspaceEnvironmentMenu-c1pHDskn.js +63 -0
- package/dist/web/assets/{WorkspaceGitDialogs-Dgmg-6XG.js → WorkspaceGitDialogs-DrVtapQQ.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-BR4qxMgU.js → WorkspaceMonacoEditor-BCKzvSj2.js} +3 -3
- package/dist/web/assets/arrow-up-right-CP4hZdrJ.js +1 -0
- package/dist/web/assets/chunk-NOJECMB7-Bhcms-w5.js +1 -0
- package/dist/web/assets/{clipboard-BZzZ82Bk.js → clipboard-BgrXorn-.js} +1 -1
- package/dist/web/assets/{cloud-upload-CJPYPVl8.js → cloud-upload-B_zYztb6.js} +1 -1
- package/dist/web/assets/{cssMode-WC4Rg1l-.js → cssMode-DanjGgA8.js} +1 -1
- package/dist/web/assets/{folder-open-sLZJxLQy.js → folder-open-CdVKbtGq.js} +1 -1
- package/dist/web/assets/folder-plus-Cc5KElB6.js +1 -0
- package/dist/web/assets/{git-commit-horizontal-Cotm7KEC.js → git-commit-horizontal-CjGIIgRi.js} +1 -1
- package/dist/web/assets/{htmlMode-C6oZGeaB.js → htmlMode-DRGDF_UL.js} +1 -1
- package/dist/web/assets/index-B5re-RJy.css +1 -0
- package/dist/web/assets/{index-BxWTVKtn.js → index-BE-wXZ5R.js} +2 -2
- package/dist/web/assets/info-BLj0RvhA.js +1 -0
- package/dist/web/assets/{jsonMode-BET4LQIn.js → jsonMode-CCu0j2GD.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-BPxA_-Kg.js → lspLanguageFeatures-s_Lhm7P6.js} +1 -1
- package/dist/web/assets/minimize-2-Cyg_zD9z.js +1 -0
- package/dist/web/assets/{monaco.contribution-DXzyQfVi.js → monaco.contribution-CAzXvYkn.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DFzEyaHi.js → monaco.contribution-CY7mRgOB.js} +2 -2
- package/dist/web/assets/{monaco.contribution-7AUuf2NS.js → monaco.contribution-aUeLcBEg.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BH6kkO4b.js → monaco.contribution-mUPNK9ra.js} +2 -2
- package/dist/web/assets/monitor-DZvOs_wC.js +1 -0
- package/dist/web/assets/play-BJPzemuY.js +1 -0
- package/dist/web/assets/{python-PzBkTjWx.js → python-B_qnnVaG.js} +1 -1
- package/dist/web/assets/{save-DpezrtH2.js → save-BDy9tA3E.js} +1 -1
- package/dist/web/assets/square-Cb2c5td4.js +1 -0
- package/dist/web/assets/{toggleHighContrast-Cto-fOXm.js → toggleHighContrast-MhO1JLyR.js} +1 -1
- package/dist/web/assets/{tsMode-BYA4LNc6.js → tsMode-DfBXJb9V.js} +1 -1
- package/dist/web/assets/{upload-C5YFNgtS.js → upload-D56kThRh.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-CnyTsqlf.js → useLocalAgentSchedules-DMnGfswi.js} +1 -1
- package/dist/web/assets/useProviderSettings-Bv5B9eNk.js +5 -0
- package/dist/web/assets/{useSessionTurnCache-DICuJSJW.js → useSessionTurnCache-ClAY8gze.js} +1 -1
- package/dist/web/assets/{wifi-off-nzHj7JXp.js → wifi-off-C9lWJmVm.js} +1 -1
- package/dist/web/assets/{workers-Dboaw6f_.js → workers-BYzrH8by.js} +1 -1
- package/dist/web/assets/{yaml-uuY5JmO8.js → yaml-D3T8UkT3.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +3 -3
- package/dist/chunks/actions-command-DSO6YOEE.js +0 -2
- package/dist/chunks/app-server-runtime-KZP2LB5X.js +0 -2
- package/dist/chunks/apps-TM74FFQB.js +0 -2
- package/dist/chunks/chunk-2JO2KWT3.js +0 -5
- package/dist/chunks/chunk-2SPZYBDN.js +0 -16
- package/dist/chunks/chunk-3LX6RU3C.js +0 -3
- package/dist/chunks/chunk-4SHKI3BH.js +0 -2
- package/dist/chunks/chunk-4TZHH5FC.js +0 -2409
- package/dist/chunks/chunk-5TNDPNS3.js +0 -2
- package/dist/chunks/chunk-6JAN4RMN.js +0 -42
- package/dist/chunks/chunk-7QEE4PBI.js +0 -8
- package/dist/chunks/chunk-AFUDIT36.js +0 -2
- package/dist/chunks/chunk-BX4J2VDU.js +0 -2
- package/dist/chunks/chunk-EMKZVP7Z.js +0 -2
- package/dist/chunks/chunk-FPUUZQUP.js +0 -6
- package/dist/chunks/chunk-GCOUYYHG.js +0 -5
- package/dist/chunks/chunk-GS2NKNKG.js +0 -4
- package/dist/chunks/chunk-H2VT22JK.js +0 -2
- package/dist/chunks/chunk-HA7EFTPF.js +0 -23
- package/dist/chunks/chunk-IKWDL3RB.js +0 -17
- package/dist/chunks/chunk-L3KS6MOV.js +0 -2
- package/dist/chunks/chunk-NHFGEVVH.js +0 -518
- package/dist/chunks/chunk-NNF6KCHD.js +0 -3
- package/dist/chunks/chunk-PJM2G7SG.js +0 -21
- package/dist/chunks/chunk-PQHTZ5CP.js +0 -2
- package/dist/chunks/chunk-PYABBF53.js +0 -53
- package/dist/chunks/chunk-QRWPEW3Z.js +0 -24
- package/dist/chunks/chunk-QXVIIM4T.js +0 -2
- package/dist/chunks/chunk-SDEDAHV6.js +0 -160
- package/dist/chunks/chunk-TGIB24K4.js +0 -22
- package/dist/chunks/chunk-USKE34VR.js +0 -9
- package/dist/chunks/chunk-WV2APYWG.js +0 -2
- package/dist/chunks/chunk-XGE2XI6M.js +0 -191
- package/dist/chunks/chunk-XM26DGML.js +0 -3
- package/dist/chunks/chunk-YIB3J4RC.js +0 -2
- package/dist/chunks/chunk-YL6VFJ4P.js +0 -2
- package/dist/chunks/chunk-Z3D4C7BG.js +0 -12
- package/dist/chunks/cli-JVB345H2.js +0 -2
- package/dist/chunks/connected-evidence-YDPGNHLP.js +0 -2
- package/dist/chunks/core-commands-MTV4EKXY.js +0 -2
- package/dist/chunks/datasets-CP3IT47T.js +0 -2
- package/dist/chunks/desktop-test-IAZC5MAH.js +0 -3
- package/dist/chunks/dist-SAABJU5F.js +0 -2
- package/dist/chunks/evaluation-coordination-EPHLZXYM.js +0 -2
- package/dist/chunks/experiment-improvements-6JTOPA74.js +0 -2
- package/dist/chunks/experiments-XHPFGECH.js +0 -2
- package/dist/chunks/extension-GX7DLW2X.js +0 -4
- package/dist/chunks/hosted-experiment-improvement-HAB3UE6A.js +0 -3
- package/dist/chunks/hosted-harness-runtime-YM23QNDK.js +0 -2
- package/dist/chunks/hosted-profile-candidate-EOBGKQAS.js +0 -3
- package/dist/chunks/hosted-profile-compiler-OZAOZ2ES.js +0 -2
- package/dist/chunks/hosted-profile-evaluation-control-RJ6XJZCS.js +0 -2
- package/dist/chunks/hosted-profile-evaluation-inspection-SJIDXPHI.js +0 -3
- package/dist/chunks/hosted-profile-evaluation-preparation-26EI5LJR.js +0 -3
- package/dist/chunks/human-review-AAVMISBF.js +0 -2
- package/dist/chunks/learning-FNBEIAY6.js +0 -2
- package/dist/chunks/opchat-QK43DXTY.js +0 -3
- package/dist/chunks/organizations-SRPAWKC7.js +0 -2
- package/dist/chunks/profile-C6CQNVYE.js +0 -3
- package/dist/chunks/project-agent-GZV5HNYI.js +0 -2
- package/dist/chunks/sandbox-command-4TJXQTKT.js +0 -2
- package/dist/chunks/src-P3VYLFLI.js +0 -329
- package/dist/web/assets/App-CO2F717V.css +0 -1
- package/dist/web/assets/App-CuhaCsfb.js +0 -235
- package/dist/web/assets/AppsView-BS1czXUP.js +0 -1
- package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +0 -1
- package/dist/web/assets/LabsRoute-CXJRJMhr.js +0 -99
- package/dist/web/assets/MainChatThread-BwAla81W.js +0 -2
- package/dist/web/assets/MainPane-CakOBCHw.js +0 -19
- package/dist/web/assets/RightChatPanelStack-VaOOmxwd.js +0 -1
- package/dist/web/assets/ScheduledWorkPage-D1jRQxFs.js +0 -1
- package/dist/web/assets/SettingsView-RA9OXgcu.js +0 -5
- package/dist/web/assets/WorkSidebarPanel-DwlEMEoG.js +0 -1
- package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +0 -14
- package/dist/web/assets/WorkspaceEnvironmentMenu-Byjngd9V.js +0 -32
- package/dist/web/assets/arrow-up-right-H0pvnH2s.js +0 -1
- package/dist/web/assets/chunk-UHVJOMWN-BqXRe639.js +0 -1
- package/dist/web/assets/folder-plus-C84wrpt_.js +0 -1
- package/dist/web/assets/index-dSmk3FLJ.css +0 -1
- package/dist/web/assets/info-Dc81lEfw.js +0 -1
- package/dist/web/assets/minimize-2-Bs7MVN3C.js +0 -1
- package/dist/web/assets/monitor-DXL019Wf.js +0 -1
- package/dist/web/assets/play-CXkxUZeU.js +0 -1
- package/dist/web/assets/square-oy7f5Ce6.js +0 -1
- package/dist/web/assets/useProviderSettings-B_KeQjE5.js +0 -5
- /package/dist/chunks/{chunk-OGPHXXCD.js → chunk-BT5YNE5U.js} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{b as H}from"./chunk-VJEZPDBS.js";import{a as L}from"./chunk-OSIO7PLX.js";import{Va as _}from"./chunk-2DFR7PJ4.js";import{I as g,N,O as B}from"./chunk-4WEUCGJ3.js";import{$a as V,Ya as x,ab as F,gb as R}from"./chunk-JIMU3KDA.js";import{m as I}from"./chunk-QDHMP5FS.js";import{wa as b}from"./chunk-YDT7L3VZ.js";import{Ja as E,Ka as C,La as y,v as A}from"./chunk-KD3QVRIJ.js";import{c as D,e as v,f as U,g as M,i as O,qa as T}from"./chunk-ARQEJOEK.js";import{m as p}from"./chunk-KGNCKIFP.js";import{b as o}from"./chunk-ES2ISFJC.js";import{a as w,c as P,f as j,h as c}from"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import h from"node:path";import{AsyncLocalStorage as ee}from"node:async_hooks";import{promises as z}from"node:fs";var J=new ee;function fe(r,e=!1){let t=J.getStore();t&&(e&&(t.length=0),t.push(r))}i(fe,"onStartupFailure");async function ge(r,e){await T(r);let t;try{t=await M(h.join(c(r).runtime,"server-owner"),100)}catch(n){if(n instanceof P&&n.issue.code==="STORAGE_BUSY"){let a=await O(h.join(c(r).runtime,"endpoint.json"),()=>null);throw new P({code:"RUNTIME_ALREADY_RUNNING",path:r,message:"An OpenPond runtime already owns this home.",action:a?.url?`Connect to the existing runtime at ${a.url}, or stop it before starting another.`:"Stop the existing runtime before starting another with this home."})}throw n}let s=[];try{let n=await w(r,()=>J.run(s,e)),a=n.close.bind(n);s.length=0;let d;return{...n,close:i(()=>d??=(async()=>{try{await w(r,a)}finally{await z.rm(h.join(c(r).runtime,"endpoint.json"),{force:!0}),await t()}})(),"close")}}catch(n){try{for(let a of s.reverse())await Promise.resolve().then(()=>w(r,a)).catch(()=>{});await z.rm(h.join(c(r).runtime,"endpoint.json"),{force:!0})}finally{await t()}throw n}}i(ge,"ownHomeRuntime");async function he(r,e,t){await v(h.join(c(r).runtime,"endpoint.json"),JSON.stringify({schemaVersion:"openpond.runtimeEndpoint.v1",pid:process.pid,url:e,serverId:t}))}i(he,"publishRuntimeEndpoint");function ye(r){return te({runtime:B(r.ports),close:r.close})}i(ye,"createAppServer");function te(r){let e=!1;return{runtime:r.runtime,close:i(async()=>{e||(e=!0,await r.close?.())},"close")}}i(te,"attachAppServer");async function Pe(r){let e=typeof r.appServer=="function"?null:r.appServer;try{await N({host:e?.runtime??(async()=>(e=await r.appServer(),e.runtime)),readable:r.readable,writable:r.writable,hostStorageClient:r.hostStorageClient})}finally{await e?.close()}}i(Pe,"runAppServerJsonl");import S from"node:path";import{lstat as re,readFile as oe,realpath as $}from"node:fs/promises";import{randomUUID as se}from"node:crypto";var ne=o.object({id:o.string(),version:o.string(),contentHash:o.string().regex(/^[a-f0-9]{64}$/),feedbackKey:o.string(),release:o.object({id:o.string(),revision:o.union([o.string(),o.number()]),contentHash:o.string().regex(/^[a-f0-9]{64}$/)}).strict().nullable()}).strict(),G=o.object({binding:C,packageValue:o.unknown(),graders:o.array(ne).max(100),actualGrading:o.object({pass:o.unknown(),evidence:o.unknown()}).strict().optional(),sourceCandidate:E.optional()}).strict();async function Me(r,e){let t=await $(e),s=S.resolve(r);if(S.dirname(s)!==t||await $(s)!==s)throw new Error("External Dataset package escaped its private owner home.");let n=await re(s);if(!n.isFile()||n.isSymbolicLink()||n.size>32*1024*1024)throw new Error("External Dataset package is not a bounded regular file.");let a=G.parse(JSON.parse(new TextDecoder("utf8",{fatal:!0}).decode(await oe(s))));return a.binding=y(a.binding),a.packageValue=I({...a,packageValue:b(a.packageValue)}),a}i(Me,"readHostProfileExternalDataset");async function Oe(r){let e=G.parse(r.value),t=y(e.binding),s=r.release,n={id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash};if(t.protectedProfileClosureHash!==p(s.harnessRelease.files.filter(l=>l.visibility!=="policy").map(l=>({path:l.path,asset:l}))))throw new Error("The external Dataset protected Profile closure changed.");if(e.sourceCandidate){let l=await _({workspaceId:typeof s.agentSnapshot.metadata.workspaceId=="string"?s.agentSnapshot.metadata.workspaceId:s.workspaceId,sourceDir:S.join(s.bundlePath,"source")});if(p(e.sourceCandidate.harnessRelease)!==p(n)||L(l).protectedClosureHash!==e.sourceCandidate.protectedClosureHash)throw new Error("The external Dataset candidate differs from its retained frozen compiled source.")}let a=i(async l=>{if(o.object({authorized:o.literal(!0),bindingHash:o.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(await r.client.request({contractVersion:1,requestId:se(),operation:"profile.externalDataset.authorize",params:{...l,bindingHash:t.contentHash}})).bindingHash!==t.contentHash)throw new Error("The host authorized another external Dataset binding.")},"authorize");return{authorize:a,resolveExternalDataset:i(async(l,m)=>{if(await a(),p(l)!==p(t)||m.profileRef.profileId!==t.profileId||m.sourceRevision!==r.sourceRevision||p(m.harnessRelease)!==p(n))throw new Error("External Dataset requested another actual Profile source or recipe.");let f=I({...e,binding:l,packageValue:b(e.packageValue)});return{binding:t,packageValue:f,authorize:a}},"resolveExternalDataset"),sourceCandidate:e.sourceCandidate}}i(Oe,"createHostProfileExternalDataset");import{randomBytes as ae}from"node:crypto";function Ne(){return j()}i(Ne,"appDataDir");function Be(r){return c(r).config}i(Be,"providersConfigPath");function Le(r){return c(r).credentials}i(Le,"providerSecretsConfigPath");function ze(r){return c(r).key}i(ze,"providerSecretsKeyPath");async function Je(r){let e=c(r).token;return U(e,async()=>{let t=(await D(e))?.trim(),s=process.env.OPENPOND_APP_TOKEN||t||ae(32).toString("base64url");return s!==t&&await v(e,s),{token:s,tokenFile:e}})}i(Je,"ensureCapabilityToken");import u from"node:path";import{readFile as W}from"node:fs/promises";var q=o.object({profileId:o.string().min(1),sourceRevision:o.string().min(1),repositoryId:o.string().min(1),harnessRelease:o.object({id:o.string().min(1),contentHash:o.string().regex(/^[a-f0-9]{64}$/)}).strict(),hostExecution:o.object({conversationId:o.string().min(1),turnId:o.string().min(1)}).strict().optional(),workspaceId:o.string().min(1),assetsPath:o.string().min(1).refine(u.isAbsolute)}).strict();async function Ze(r,e){let t=q.parse(e),s=await H(r,t.harnessRelease);if(!s||u.resolve(s.release.bundlePath)!==u.resolve(t.assetsPath))throw new Error("Hosted Profile release changed after admission.");let n=s.release.harnessRelease.metadata.profile;if(!n||typeof n!="object"||n.id!==t.profileId||n.sourceRevision!==t.sourceRevision||n.repositoryId!==void 0&&n.repositoryId!==t.repositoryId)throw new Error("Hosted Profile provenance differs from admitted release.");return{profile:F(),profileLibrary:V()}}i(Ze,"loadHostedProfileStateAndLibrary");async function et(r,e){let t=q.parse(e),s=await H(r,t.harnessRelease);if(!s||u.resolve(s.release.bundlePath)!==u.resolve(t.assetsPath))throw new Error("Hosted Profile workflow release is unavailable.");let n=s.release.harnessRelease.metadata.profile;if(n?.id!==t.profileId||n.sourceRevision!==t.sourceRevision||n.repositoryId!==void 0&&n.repositoryId!==t.repositoryId)throw new Error("Hosted Profile workflow provenance changed.");let a=t.harnessRelease,d={source:"openpond_git",repositoryId:t.repositoryId,profileId:t.profileId};if(!s.release.harnessRelease.files.some(f=>f.path==="workflows/catalog.json"))return{profileRef:d,sourceRevision:t.sourceRevision,harnessRelease:a,workflows:[]};let l=u.join(s.release.bundlePath,"source","workflows"),m=A({agentSnapshot:s.release.agentSnapshot,harnessRelease:s.release.harnessRelease,catalogBytes:await W(u.join(l,"catalog.json")),actionBytes:await W(u.join(l,"actions.json"))});return{profileRef:d,sourceRevision:t.sourceRevision,harnessRelease:a,workflows:m.catalog.workflows.map(f=>({workflow:f,binding:{schemaVersion:"openpond.profileWorkflowBinding.v1",profileId:t.profileId,sourceRevision:t.sourceRevision,harnessRelease:a,catalogHash:m.catalogHash,workflowId:f.id}}))}}i(et,"listHostedProfileWorkflows");import{createHash as ie,randomUUID as k}from"node:crypto";var K=o.object({approval:x,revision:o.number().int().positive()}).strict(),Q=o.object({record:R}).strict(),le=o.object({startedAt:o.string().min(1),requestOrdinal:o.number().int().nonnegative(),id:o.string().min(1)}).strict(),ce=o.object({records:o.array(R).max(200),nextBefore:le.nullable()}).strict(),Y=1e4,X=class{constructor(e){this.client=e}client;static{i(this,"HostedApprovalStorage")}async readApproval(e){let t=await this.client.request({contractVersion:g,requestId:k(),operation:"approval/get",params:{approvalId:e}});return t===null?null:K.parse(t)}async getApproval(e){return(await this.readApproval(e))?.approval??null}async putApproval(e){let t=x.parse(e.approval);if(!e.requestId.trim())throw new Error("Approval mutation requires a stable request ID.");return K.parse(await this.client.request({contractVersion:g,requestId:e.requestId,operation:"approval/upsert",params:{approval:t,expectedRevision:e.expectedRevision}}))}},Z=class{constructor(e){this.client=e}client;static{i(this,"HostedModelUsageStorage")}async upsertModelUsageRecord(e){let t=R.parse(e),s=ie("sha256").update(JSON.stringify(t)).digest("hex"),n=await this.client.request({contractVersion:g,requestId:`usage:${s}`,operation:"usage/upsert",params:{record:t}}),a=Q.parse(n).record;if(a.requestId!==t.requestId)throw new Error("Host usage upsert changed request identity.");return a}async getModelUsageRecordByRequestId(e){let t=await this.client.request({contractVersion:g,requestId:k(),operation:"usage/getByRequestId",params:{requestId:e}});return t===null?null:Q.parse(t).record}async listModelUsageRecords(e={}){let t=e.limit===void 0||e.limit>=Y,s=e.limit===void 0?Y:Math.max(1,Math.min(1e4,Math.trunc(e.limit))),n={...e.sessionId?{sessionId:e.sessionId}:{},...e.turnId?{turnId:e.turnId}:{},...e.provider?{provider:e.provider}:{},...e.model?{model:e.model}:{},...e.startedAtFrom?{startedAtFrom:e.startedAtFrom}:{},...e.startedAtTo?{startedAtTo:e.startedAtTo}:{},...e.visibility&&e.visibility!=="all"?{visibility:e.visibility}:{},...e.status&&e.status!=="all"?{status:e.status}:{}},a=[],d=null;for(;a.length<s+(t?1:0);){let l=ce.parse(await this.client.request({contractVersion:g,requestId:k(),operation:"usage/page",params:{query:n,before:d,limit:Math.min(200,s+(t?1:0)-a.length)}}));if(a.push(...l.records),a.length>s)throw new Error(`Hosted usage query exceeds ${s} rows; narrow its filters or use a streamed aggregation.`);if(l.nextBefore===null)break;if(l.records.length===0||JSON.stringify(l.nextBefore)===JSON.stringify(d))throw new Error("Host usage cursor did not advance.");d=l.nextBefore}return a}async listModelUsageRecordsComplete(e={}){return this.listModelUsageRecords(e)}};export{fe as a,ge as b,he as c,ye as d,Pe as e,Me as f,Oe as g,Ne as h,Be as i,Le as j,ze as k,Je as l,q as m,Ze as n,et as o,X as p,Z as q};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as e}from"./chunk-ES2ISFJC.js";import{a as o}from"./chunk-FTQLQJQV.js";import{createHash as Te}from"node:crypto";function W(n){if(n===null||typeof n=="boolean"||typeof n=="string")return n;if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("Canonical JSON cannot encode a non-finite number.");return n}if(Array.isArray(n))return n.map(W);if(typeof n=="object"){let t={};for(let r of Object.keys(n).sort()){let i=n[r];i!==void 0&&(t[r]=W(i))}return t}throw new Error(`Canonical JSON cannot encode ${typeof n}.`)}o(W,"canonicalJson");function R(n){return Te("sha256").update(JSON.stringify(W(n)),"utf8").digest("hex")}o(R,"canonicalHash");function rt(n){if(!n.maxContextTokens||!n.usableContextTokens)return{shouldCompact:!1,projectedTokens:n.projectedTokens,thresholdTokens:Number.MAX_SAFE_INTEGER,usableContextTokens:0,maxContextTokens:0,tokenSource:"heuristic"};let t=Math.max(.01,Math.min(1,(n.triggerPercent??85)/100)),r=Math.max(1,Math.floor(n.usableContextTokens*t));return{shouldCompact:n.projectedTokens>=r,projectedTokens:n.projectedTokens,thresholdTokens:r,usableContextTokens:n.usableContextTokens,maxContextTokens:n.maxContextTokens,tokenSource:"heuristic"}}o(rt,"agentCompactionDecision");async function it(n){await n.started();try{return await n.compact()}catch(t){throw await n.failed(t),t}}o(it,"runAgentCompaction");async function nt(n){let t=n.host.projectEvents(n.events),r=n.host.selectEvents(t,n.maxContextTokens),{summaryEvents:i,preservedEvents:s,preservedEventIds:c}=r;if(i.length===0)throw new Error("There is not enough prior context to compact.");let l=n.host.normalizeRecords(i),d=n.host.normalizeRecords(s),m=n.host.buildFileLedger(n.host.normalizeRecords(t)),h=n.host.serializeRecords(l,n.host.inputCharBudget(n.maxContextTokens));if(!h.text.trim())throw new Error("There is not enough prior context to compact.");let y=n.host.buildSummaryMessages({serializedHistory:h.text,fileLedger:m}),b=Date.now(),v=(await n.host.streamSummary({model:n.model,messages:y,signal:n.signal})).trim(),I=Date.now()-b;if(!v)throw new Error("Compaction summary was empty.");let g=n.host.estimateProjection({events:t,preservedEvents:s,summary:v}),f=n.host.createMetrics({sourceEvents:t.length,summarizedEvents:i.length,preservedEvents:s.length,sourceRecords:h.sourceRecordCount,includedRecords:h.includedRecordCount,omittedRecords:h.omittedRecordCount,preservedRecords:d.length,truncatedRecords:h.truncatedRecordCount,summaryInputTruncated:h.inputTruncated,sourceSelectionStrategy:h.selectionStrategy,summaryInputChars:h.inputChars,retainedTailTokens:r.retainedTailTokens,retainedTailBudgetTokens:r.retainedTailBudgetTokens,finalProviderContextTokens:g.inputTokensAfter,durationMs:I,fileLedgerEntries:m.length,splitTurnId:r.splitTurnId});return{summary:v,model:n.model,compactedThroughEventId:t[t.length-1]?.id??null,compactedThroughTurnId:n.host.lastTurnId(t),preservedFromEventId:s[0]?.id??null,preservedEventIds:c,preservedResourceRefs:n.host.durableResourceRefs(n.events),sourceEventCount:i.length,preservedEventCount:s.length,fileLedger:m,inputTokensBefore:g.inputTokensBefore,inputTokensAfter:g.inputTokensAfter,maxContextTokens:n.maxContextTokens,tokenSource:"heuristic",metrics:f}}o(nt,"runAgentCompactionProgram");var Ce=e.enum(["thread.started","thread.resumed","turn.started","turn.steered","turn.interrupted","turn.completed","turn.failed","item.started","item.delta","item.completed","assistant.reasoning.delta","assistant.delta","tool.started","tool.completed","approval.requested","approval.resolved","user_input.requested","user_input.resolved","compaction.started","compaction.completed","harness.admitted","harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed","diagnostic"]),qe=e.object({sequence:e.number().int().nonnegative(),name:Ce,source:e.enum(["runtime","provider","tool","host","refiner"]),status:e.string().trim().min(1).nullable().default(null),threadId:e.string().trim().min(1),turnId:e.string().trim().min(1).nullable().default(null),callId:e.string().trim().min(1).nullable().default(null),output:e.string().nullable().default(null),error:e.string().nullable().default(null),data:e.record(e.string(),e.unknown()).default({})}).strict();function lt(n){return R(qe.parse(n))}o(lt,"canonicalEventHash");var A="2026-09-20",mt=["initialize","initialized","runtime/capabilities","thread/start","thread/resume","thread/read","turn/start","turn/steer","task/inbox","task/queue","task/inputUpdate","turn/interrupt","approval/resolve","userInput/resolve","profile/workflows","profile/evaluations","profile/trainingSource","profile/evaluations/prepare","profile/evaluations/run","profile/evaluations/runSuite","profile/evaluations/executeCase","profile/evaluations/executeRun","profile/evaluations/compare","profile/evaluations/report","experiments/executeCase","experiments/cancelCase","harness/inspect","harness/proposalReview","harness/review","harness/acceptEvaluationReview","harness/materializeEvaluationTaskset","harness/runEvaluationBaseline","harness/validate","harness/backgroundReview","harness/diff","harness/rollback","refiner/inspect","refiner/update","refiner/activate","refiner/rollback"],Z=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number()]),method:e.string().trim().min(1),params:e.unknown().optional()}).strict(),ee=e.object({jsonrpc:e.literal("2.0"),method:e.string().trim().min(1),params:e.unknown().optional()}).strict(),F=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number()]),result:e.unknown()}).strict(),J=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number(),e.null()]),error:e.object({code:e.number().int(),message:e.string(),data:e.unknown().optional()}).strict()}).strict(),ht=e.union([Z,ee,F,J]),Pe=e.object({protocolVersion:e.string().trim().min(1),client:e.object({name:e.string().trim().min(1),version:e.string().trim().min(1)}).strict(),capabilities:e.record(e.string(),e.unknown()).default({})}).strict(),B=class{static{o(this,"AgentJsonRpcDispatcher")}#e;#t=null;#r=!1;constructor(t){this.#e=t}get initialized(){return this.#r}async handle(t){let r=ee.safeParse(t);if(r.success&&!("id"in t)){if(r.data.method==="initialized"){if(!this.#t)throw new T(-32002,"initialize must be called first");this.#r=!0}return null}let i=Z.safeParse(t);if(!i.success)return Y(null,-32600,"Invalid Request",i.error.flatten());let s=i.data;try{let c=await this.#i(s.method,s.params);return{jsonrpc:"2.0",id:s.id,result:c}}catch(c){let l=c instanceof T?c:new T(-32603,c instanceof Error?c.message:String(c));return Y(s.id,l.code,l.message,l.data)}}async#i(t,r){if(t==="initialize"){let i=Pe.parse(r);if(i.protocolVersion!==A)throw new T(-32001,"Incompatible agent protocol version",{requested:i.protocolVersion,supported:A});return this.#t=i,{protocolVersion:A,server:{name:"openpond-app-server",version:"1"},capabilities:await this.#e.capabilities()}}if(!this.#r)throw new T(-32002,"initialized notification is required");switch(t){case"runtime/capabilities":return this.#e.capabilities(r);case"thread/start":return this.#e.threadStart(r);case"thread/resume":return this.#e.threadResume(r);case"thread/read":return this.#e.threadRead(r);case"turn/start":return this.#e.turnStart(r);case"turn/steer":return this.#e.turnSteer(r);case"task/inbox":return this.#e.taskInbox(r);case"task/queue":return this.#e.taskQueue(r);case"task/inputUpdate":return this.#e.taskInputUpdate(r);case"turn/interrupt":return this.#e.turnInterrupt(r);case"approval/resolve":return this.#e.approvalResolve(r);case"userInput/resolve":return this.#e.userInputResolve(r);case"profile/workflows":return this.#e.profileWorkflows(r);case"profile/evaluations":return this.#e.profileEvaluations(r);case"profile/trainingSource":return this.#e.profileTrainingSource(r);case"profile/evaluations/prepare":return this.#e.profileEvaluationPrepare(r);case"profile/evaluations/run":return this.#e.profileEvaluationRun(r);case"experiments/executeCase":{if(!this.#e.experimentExecuteCase)throw new Error("Experiment execution is unavailable in this runtime.");return this.#e.experimentExecuteCase(r)}case"experiments/cancelCase":{if(!this.#e.experimentCancelCase)throw new Error("Experiment cancellation is unavailable in this runtime.");return this.#e.experimentCancelCase(r)}case"profile/evaluations/runSuite":return this.#e.profileEvaluationRunSuite(r);case"profile/evaluations/executeCase":return this.#e.profileEvaluationExecuteCase(r);case"profile/evaluations/executeRun":return this.#e.profileEvaluationExecuteRun(r);case"profile/evaluations/compare":return this.#e.profileEvaluationCompare(r);case"profile/evaluations/report":return this.#e.profileEvaluationReport(r);case"harness/inspect":return this.#e.harnessInspect(r);case"harness/proposalReview":return this.#e.harnessProposalReview(r);case"harness/review":return this.#e.harnessReview(r);case"harness/acceptEvaluationReview":return this.#e.harnessAcceptEvaluationReview(r);case"harness/materializeEvaluationTaskset":return this.#e.harnessMaterializeEvaluationTaskset(r);case"harness/runEvaluationBaseline":return this.#e.harnessRunEvaluationBaseline(r);case"harness/validate":return this.#e.harnessValidate(r);case"harness/backgroundReview":return this.#e.harnessBackgroundReview(r);case"harness/diff":return this.#e.harnessDiff(r);case"harness/rollback":return this.#e.harnessRollback(r);case"refiner/inspect":return this.#e.refinerInspect(r);case"refiner/update":return this.#e.refinerUpdate(r);case"refiner/activate":return this.#e.refinerActivate(r);case"refiner/rollback":return this.#e.refinerRollback(r);default:throw new T(-32601,`Method not found: ${t}`)}}},T=class extends Error{static{o(this,"JsonRpcDispatchError")}code;data;constructor(t,r,i){super(r),this.code=t,this.data=i}};function Y(n,t,r,i){return{jsonrpc:"2.0",id:n,error:{code:t,message:r,...i===void 0?{}:{data:i}}}}o(Y,"jsonRpcError");var te=class{static{o(this,"AgentRpcClient")}#e;#t;constructor(t){this.#e=t.request.bind(t),this.#t=t.notify.bind(t)}async initialize(t,r={}){let i=await this.#e("initialize",{protocolVersion:A,client:t,capabilities:r});return await this.#t("initialized"),i}capabilities=o((t={})=>this.#e("runtime/capabilities",t),"capabilities");threadStart=o(t=>this.#e("thread/start",t),"threadStart");threadResume=o(t=>this.#e("thread/resume",t),"threadResume");threadRead=o(t=>this.#e("thread/read",t),"threadRead");turnStart=o(t=>this.#e("turn/start",t),"turnStart");turnSteer=o(t=>this.#e("turn/steer",t),"turnSteer");taskInbox=o(t=>this.#e("task/inbox",t),"taskInbox");taskQueue=o(t=>this.#e("task/queue",t),"taskQueue");taskInputUpdate=o(t=>this.#e("task/inputUpdate",t),"taskInputUpdate");turnInterrupt=o(t=>this.#e("turn/interrupt",t),"turnInterrupt");approvalResolve=o(t=>this.#e("approval/resolve",t),"approvalResolve");userInputResolve=o(t=>this.#e("userInput/resolve",t),"userInputResolve");profileWorkflows=o(t=>this.#e("profile/workflows",t),"profileWorkflows");profileEvaluations=o(t=>this.#e("profile/evaluations",t),"profileEvaluations");profileEvaluationPrepare=o(t=>this.#e("profile/evaluations/prepare",t),"profileEvaluationPrepare");profileEvaluationRun=o(t=>this.#e("profile/evaluations/run",t),"profileEvaluationRun");profileEvaluationRunSuite=o(t=>this.#e("profile/evaluations/runSuite",t),"profileEvaluationRunSuite");profileEvaluationExecuteCase=o(t=>this.#e("profile/evaluations/executeCase",t),"profileEvaluationExecuteCase");profileEvaluationExecuteRun=o(t=>this.#e("profile/evaluations/executeRun",t),"profileEvaluationExecuteRun");profileEvaluationCompare=o(t=>this.#e("profile/evaluations/compare",t),"profileEvaluationCompare");experimentExecuteCase=o(t=>this.#e("experiments/executeCase",t),"experimentExecuteCase");experimentCancelCase=o(t=>this.#e("experiments/cancelCase",t),"experimentCancelCase");harnessInspect=o((t={})=>this.#e("harness/inspect",t),"harnessInspect");harnessProposalReview=o((t={})=>this.#e("harness/proposalReview",t),"harnessProposalReview");harnessReview=o((t={})=>this.#e("harness/review",t),"harnessReview");harnessAcceptEvaluationReview=o((t={})=>this.#e("harness/acceptEvaluationReview",t),"harnessAcceptEvaluationReview");harnessMaterializeEvaluationTaskset=o((t={})=>this.#e("harness/materializeEvaluationTaskset",t),"harnessMaterializeEvaluationTaskset");harnessRunEvaluationBaseline=o((t={})=>this.#e("harness/runEvaluationBaseline",t),"harnessRunEvaluationBaseline");harnessValidate=o((t={})=>this.#e("harness/validate",t),"harnessValidate");harnessBackgroundReview=o((t={})=>this.#e("harness/backgroundReview",t),"harnessBackgroundReview");harnessDiff=o((t={})=>this.#e("harness/diff",t),"harnessDiff");harnessRollback=o((t={})=>this.#e("harness/rollback",t),"harnessRollback");refinerInspect=o(t=>this.#e("refiner/inspect",t),"refinerInspect");refinerUpdate=o(t=>this.#e("refiner/update",t),"refinerUpdate");refinerActivate=o(t=>this.#e("refiner/activate",t),"refinerActivate");refinerRollback=o(t=>this.#e("refiner/rollback",t),"refinerRollback")};var G=e.object({caseId:e.string().trim().min(1).max(191),admissionHash:e.string().regex(/^[a-f0-9]{64}$/),definitionHash:e.string().regex(/^[a-f0-9]{64}$/),ordinal:e.number().int().nonnegative(),operation:e.enum(["create","reset","step","collect","destroy"]),value:e.record(e.string(),e.unknown()),timeoutMs:e.number().int().min(1).max(3e4)}).strict();var u=e.string().trim().min(1).max(200),$=e.string().trim().min(1).max(32e3),z=e.number().int().nonnegative(),re=e.object({id:u,sessionId:u,senderSessionId:u.nullable(),senderKind:e.enum(["user","task","runtime"]),kind:e.enum(["steer","message","followup","queued","result"]),body:$,payload:e.record(e.string(),e.unknown()),idempotencyKey:u,replyTo:u.nullable(),expectedTurnId:u.nullable()}).strict(),Ae=e.discriminatedUnion("action",[e.object({action:e.literal("resume"),expectedRevision:e.number().int().positive()}).strict(),e.object({action:e.literal("cancel"),expectedRevision:e.number().int().positive()}).strict(),e.object({action:e.literal("edit"),expectedRevision:e.number().int().positive(),body:$}).strict(),e.object({action:e.literal("steer"),expectedRevision:e.number().int().positive(),expectedTurnId:u}).strict()]),ie=e.object({id:u,sessionId:u,turnId:u,targetSessionId:u.nullable(),targetTurnId:u.nullable(),targetInputId:u.nullable(),afterSequence:z,deadline:e.string(),state:e.enum(["waiting","message","completed","failed","interrupted","unavailable","timeout","cancelled"]),createdAt:e.string(),updatedAt:e.string()}).strict(),ne=e.record(e.string(),e.unknown()),ze=e.enum(["queued","running","completed","failed","cancelled","needs_resume"]),He=e.object({parentSessionId:u.nullable().optional(),childSessionId:u.nullable().optional(),status:e.array(ze).nullable().optional(),afterId:e.string().max(200),limit:e.number().int().min(1).max(10)}).strict(),se=e.discriminatedUnion("action",[e.object({action:e.literal("recoverTaskInboxOwners"),ownerId:u}).strict(),e.object({action:e.literal("hasTaskCompletion"),turnId:u}).strict(),e.object({action:e.literal("taskInboxSnapshot"),sessionId:u}).strict(),e.object({action:e.literal("taskInboxSnapshotInputs"),sessionId:u,afterSequence:z}).strict(),e.object({action:e.literal("declareTaskWork"),sessionId:u,turnId:u,ownerId:u,areas:e.array($).max(100)}).strict(),e.object({action:e.literal("taskWorkAreas"),sessionId:u}).strict(),e.object({action:e.literal("admitTaskInput"),input:re}).strict(),e.object({action:e.literal("admitTaskInputs"),inputs:e.array(re).max(50)}).strict(),e.object({action:e.literal("rejectTaskInput"),id:u,error:$}).strict(),e.object({action:e.literal("getTaskInput"),id:u}).strict(),e.object({action:e.literal("taskInputsForSession"),sessionId:u,query:e.object({afterSequence:z.optional(),pendingOnly:e.boolean().optional(),limit:e.number().int().min(1).max(500).optional()}).strict()}).strict(),e.object({action:e.literal("mutateTaskInput"),sessionId:u,inputId:u,change:Ae}).strict(),e.object({action:e.literal("openTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("renewTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("pendingTaskInputs"),sessionId:u,turnId:u,afterSequence:z}).strict(),e.object({action:e.literal("taskAssignmentInputs"),turnId:u,afterSequence:z}).strict(),e.object({action:e.literal("pauseTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("includeTaskInputs"),sessionId:u,turnId:u,ownerId:u,requestId:u}).strict(),e.object({action:e.literal("settleTaskInputRequest"),requestId:u,outcome:e.enum(["resolved","failed","replaced"])}).strict(),e.object({action:e.literal("sealTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("sealNativeTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("closeTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u,outcome:e.enum(["completed","failed","interrupted"])}).strict(),e.object({action:e.literal("taskInboxPaused"),sessionId:u}).strict(),e.object({action:e.literal("reserveTaskFollowup"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("taskInboxWakeTargets"),afterSessionId:e.string().max(200)}).strict(),e.object({action:e.literal("createTaskWait"),value:ie}).strict(),e.object({action:e.literal("settleTaskWait"),id:u,state:ie.shape.state}).strict(),e.object({action:e.literal("taskWaitsForSession"),sessionId:u,afterId:e.string().max(200)}).strict(),e.object({action:e.literal("commitSubagentCompletion"),value:ne,turnId:u}).strict(),e.object({action:e.literal("pendingTaskCompletions"),afterTurnId:e.string().max(200)}).strict(),e.object({action:e.literal("settleTaskCompletion"),turnId:u,inputId:u}).strict(),e.object({action:e.literal("upsertSubagentRun"),value:ne}).strict(),e.object({action:e.literal("getSubagentRun"),id:u}).strict(),e.object({action:e.literal("listSubagentRuns"),query:He}).strict()]);var H=e.string().trim().min(1).max(191),oe=e.object({createdAt:e.string().min(1),id:H}).strict(),ae=e.enum(["trigger_decision","route_decision","refiner_outcome","proposal","targeted_validation","apply_receipt"]),ce=e.discriminatedUnion("action",[e.object({action:e.literal("active_release"),workspaceId:H}).strict(),e.object({action:e.literal("put_artifact"),workspaceId:H,kind:ae,artifact:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("artifact_page"),workspaceId:H,kind:ae,before:oe.nullable(),limit:e.number().int().min(1).max(200)}).strict(),e.object({action:e.literal("pending_trigger_page"),workspaceId:H,before:oe.nullable(),limit:e.number().int().min(1).max(200)}).strict()]);var w=e.string().trim().min(1).max(240),le=e.string().regex(/^[a-f0-9]{64}$/),ue=e.enum(["run_overlay","observation","trigger_decision","route_decision","proposal","targeted_validation","apply_receipt","refiner_outcome"]),de=e.object({createdAt:e.string().datetime(),id:w}).strict(),pe=e.discriminatedUnion("action",[e.object({action:e.literal("artifact_put"),workspaceId:w,kind:ue,artifact:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("artifact_page"),workspaceId:w,kind:ue,before:de.nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("pending_page"),workspaceId:w,before:de.nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("workspace_get"),workspaceId:w}).strict(),e.object({action:e.literal("background_get"),workspaceId:w}).strict(),e.object({action:e.literal("overlay_get"),runId:w}).strict(),e.object({action:e.literal("overlay_freeze"),runId:w,expectedRevision:e.number().int().nonnegative(),overlay:e.record(e.string(),e.unknown()),proposal:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("memory_get"),workspaceId:w,sessionId:w,key:w}).strict(),e.object({action:e.literal("memory_page"),workspaceId:w,sessionId:w,before:e.object({updatedAt:e.string().datetime(),key:w}).strict().nullable(),limit:e.number().int().min(1).max(20),includeDeleted:e.boolean()}).strict(),e.object({action:e.literal("memory_write"),sessionId:w,input:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("release_get"),contentHash:le}).strict(),e.object({action:e.literal("release_put"),record:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("session_get"),sessionId:w}).strict(),e.object({action:e.literal("turn_get"),turnId:w}).strict(),e.object({action:e.literal("turn_page"),sessionId:w,before:e.number().int().positive().nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("event_page"),turnId:w,afterSequence:e.number().int().nonnegative(),names:e.array(w).max(40),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("event_append"),event:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("usage_put"),record:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("snapshot_restore"),turnId:w,expectedHash:le,snapshot:e.record(e.string(),e.unknown())}).strict()]);var j=e.string().trim().min(1).max(200),me=e.string().regex(/^[a-f0-9]{64}$/),Me=e.object({kind:e.enum(["structural","visual","test","user_review"]),status:e.enum(["passed","failed","not_run"]),label:e.string().trim().min(1).max(240),detail:e.string().trim().max(4e3).nullable().optional(),ref:e.string().trim().max(4096).nullable().optional()}),he=e.object({id:j,title:e.string().trim().min(1).max(240),sourceTaskId:j,sourceTurnId:j,revision:e.number().int().positive(),createdAt:e.string().datetime(),contentType:e.string().trim().min(1).max(200),sizeBytes:e.number().int().min(1).max(1e7),sha256:me,validation:e.array(Me).max(32)}).strict(),fe=e.object({sessionId:j,turnId:j,output:he}).strict(),be=e.object({uploadId:j,index:e.number().int().min(0).max(1024),offset:e.number().int().min(0).max(1e7),sha256:me,contentsBase64:e.string().min(1).max(131072)}).strict(),ge=e.object({uploadId:j}).strict(),Ve=he.pick({id:!0,title:!0,sourceTaskId:!0,sourceTurnId:!0,revision:!0,createdAt:!0,validation:!0}),we=e.object({sessionId:j,turnId:j,output:Ve,sandboxPath:e.string().trim().min(1).max(4096)}).strict();var M=e.string().trim().min(1).max(200),Ue=e.object({type:e.enum(["create","get","start","stop","exec","open_port","list_files","download_file","upload_file","search_files","delete_file","stat_file","mkdir","move_file","process_start","process_get","git_status","git_diff","git_export_patch","git_branch","git_commit","git_pull","git_push"]),sandboxId:M.optional(),payload:e.unknown().optional(),processId:M.optional(),failOnUnpreservedChanges:e.boolean().optional()}).strict().superRefine((n,t)=>{n.type!=="create"&&!n.sandboxId&&t.addIssue({code:"custom",message:"Sandbox identity is required."}),n.type==="create"&&n.sandboxId&&t.addIssue({code:"custom",message:"Create cannot target a sandbox identity."}),n.type==="process_get"&&!n.processId&&t.addIssue({code:"custom",message:"Process identity is required."})}),ve=e.object({action:Ue}).strict(),xe=e.object({sessionId:M,turnId:M,name:M}).strict();var p=1,a=e.string().trim().min(1).max(191),C=e.number().int().min(1).max(200),Ot=e.object({teamId:a,ownerUserId:a,workspaceId:a,conversationId:a,turnId:a,attempt:e.number().int().min(1),leaseGeneration:e.number().int().min(1)}).strict(),Ie=e.discriminatedUnion("operation",[e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/grade"),params:e.object({action:e.enum(["upload","execute"]),callId:a,sessionId:a,turnId:a,sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().positive().max(2e7),timeoutMs:e.number().int().positive().max(3e5),offset:e.number().int().nonnegative().max(2e7).optional(),contentsBase64:e.string().max(131072).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/sandbox"),params:e.object({sessionId:a,turnId:a,action:e.enum(["upload","exec","read","stop"]),area:e.enum(["policy","runtime"]).optional(),path:e.string().min(1).max(4096).optional(),sha256:e.string().regex(/^[a-f0-9]{64}$/).optional(),sizeBytes:e.number().int().min(0).max(1e7).optional(),offset:e.number().int().min(0).max(1e7).optional(),contentsBase64:e.string().max(131072).optional(),command:e.string().min(1).max(2e4).optional(),stdin:e.string().max(12e4).optional(),cwd:e.string().max(4096).optional(),timeoutMs:e.number().int().min(1).max(18e4).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/list"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/read"),params:e.object({fileId:a,revision:e.number().int().min(1),offset:e.number().int().min(0).max(1e7).optional(),maxChars:e.number().int().min(1).max(1e5).optional(),firstPage:e.number().int().min(1).max(1e3).optional(),pageCount:e.number().int().min(1).max(10).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/readBytes"),params:e.object({sessionId:a,turnId:a,fileId:a,revision:e.number().int().positive(),sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().min(1).max(1e7),offset:e.number().int().min(0).max(1e7)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile.externalDataset.authorize"),params:e.object({bindingHash:e.string().regex(/^[a-f0-9]{64}$/),manifestHash:e.string().regex(/^[a-f0-9]{64}$/).optional(),taskId:a.optional(),seed:e.string().min(1).max(500).optional()}).strict().refine(n=>!!n.taskId==!!n.seed,"Case authority requires both task and seed.")}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("experiment/environment"),params:G}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("experiment/policy"),params:e.object({caseId:a,admissionHash:e.string().regex(/^[a-f0-9]{64}$/),ordinal:e.number().int().nonnegative(),messages:e.array(e.record(e.string(),e.unknown())).max(2e3),tools:e.array(e.record(e.string(),e.unknown())).max(200)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("sandbox/request"),params:ve}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("embedding/authorize"),params:xe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/begin"),params:fe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/chunk"),params:be}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/complete"),params:ge}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/saveSandboxFile"),params:we}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("settings/get"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/get"),params:e.object({reference:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/get"),params:e.object({runId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/put"),params:e.object({runId:a,expectedRevision:e.number().int().min(0).nullable(),overlay:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/freezeProposal"),params:e.object({runId:a,expectedRevision:e.number().int().min(0),overlay:e.record(e.string(),e.unknown()),proposal:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/get"),params:e.object({workspaceId:a,key:e.string().min(1).max(120)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/list"),params:e.object({workspaceId:a,includeDeleted:e.boolean(),before:e.object({updatedAt:e.string(),key:e.string()}).strict().nullable(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/search"),params:e.object({workspaceId:a,query:e.string().trim().min(1).max(500),limit:e.number().int().min(1).max(20)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/write"),params:e.object({input:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/state/read"),params:e.object({workspaceId:a,kind:e.enum(["selection","workspace_settings","evaluation_review_settings","candidates","cross_run_requests"]),afterId:a.nullable(),limit:e.number().int().min(1).max(100)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/execute"),params:e.discriminatedUnion("action",[e.object({action:e.literal("get"),kind:e.enum(["grade","receipt","run","comparison","suite"]),id:a}).strict(),e.object({action:e.literal("page"),kind:e.enum(["grade","receipt","run","comparison","suite"]),profileKey:e.string().regex(/^[a-f0-9]{64}$/),before:e.object({createdAt:e.string(),id:a}).strict().nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("put"),kind:e.enum(["grade","receipt","run","comparison","suite"]),payload:e.record(e.string(),e.unknown()),profileKey:e.string().regex(/^[a-f0-9]{64}$/).nullable(),createdAt:e.string()}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/workspace/transition"),params:e.discriminatedUnion("action",[e.object({action:e.literal("advance"),receiptId:a,workspaceId:a,proposal:e.record(e.string(),e.unknown()),validations:e.array(e.record(e.string(),e.unknown())).max(100),nextRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),nextSourceRevision:e.string().min(1),now:e.string()}).strict(),e.object({action:e.literal("reviewedAdvance"),receiptId:a,workspaceId:a,proposal:e.record(e.string(),e.unknown()),validations:e.array(e.record(e.string(),e.unknown())).max(100),nextRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),nextSourceRevision:e.string().min(1),reviewer:a,now:e.string()}).strict(),e.object({action:e.literal("rollback"),receiptId:a,workspaceId:a,expectedWorkspaceRevision:e.number().int().nonnegative(),expectedChannelRevision:e.number().int().nonnegative(),targetRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),targetSourceRevision:e.string().min(1),rollbackOf:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),now:e.string()}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("task-inbox/execute"),params:se}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/review/execute"),params:pe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("refiner/execute"),params:e.object({action:ce}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("create-improve/execute"),params:e.discriminatedUnion("action",[e.object({action:e.literal("get"),runId:a}).strict(),e.object({action:e.literal("page"),query:e.object({profileId:a.nullable(),targetKind:a.nullable(),targetId:a.nullable(),state:e.array(a).max(20)}).strict(),before:e.object({updatedAt:e.string(),id:a}).strict().nullable(),limit:C}).strict(),e.object({action:e.literal("put"),run:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("mutate"),mutation:e.record(e.string(),e.unknown()),next:e.record(e.string(),e.unknown())}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("approval/get"),params:e.object({approvalId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("approval/upsert"),params:e.object({approval:e.record(e.string(),e.unknown()),expectedRevision:e.number().int().min(1).nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/getByRequestId"),params:e.object({requestId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/upsert"),params:e.object({record:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/page"),params:e.object({query:e.object({sessionId:a.optional(),turnId:a.optional(),provider:a.optional(),model:a.optional(),startedAtFrom:e.string().optional(),startedAtTo:e.string().optional(),visibility:e.enum(["user_facing","background","system"]).optional(),status:e.enum(["started","completed","failed","interrupted","missing"]).optional()}).strict(),before:e.object({startedAt:e.string(),requestOrdinal:e.number().int().min(0),id:a}).strict().nullable(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("capabilities"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/count"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/get"),params:e.object({sessionId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/page"),params:e.object({afterId:a.nullable(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/put"),params:e.object({sessionId:a,expectedRevision:e.number().int().min(1).nullable(),session:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/count"),params:e.object({sessionId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/wakeCount"),params:e.object({sessionId:a,key:e.enum(["messageId","fromRunId"]),value:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/get"),params:e.object({turnId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/put"),params:e.object({sessionId:a,turnId:a,expectedRevision:e.number().int().min(1).nullable(),turn:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/latest"),params:e.object({sessionId:a,status:e.enum(["in_progress","completed","failed","interrupted"]).nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/page"),params:e.object({sessionId:a,beforeSortIndex:e.number().int().min(0).nullable().optional(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("thread/turnPage"),params:e.object({sessionId:a,beforeSortIndex:e.number().int().min(0).nullable().optional(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("event/append"),params:e.object({event:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("events/page"),params:e.object({sessionId:a.nullable(),afterSequence:e.number().int().min(0),beforeSequence:e.number().int().min(1).nullable().optional(),limit:C,excludeReasoningDeltas:e.boolean().optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("events/latestAssistantText"),params:e.object({sessionId:a}).strict()}).strict()]),Bt=e.object({contractVersion:e.literal(p),operations:e.array(e.enum(["experiment/policy","experiment/environment","sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","output/readBytes","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/overlay/freezeProposal","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","profile-evaluations/execute","profile-evaluations/sandbox","profile-evaluations/grade","harness/review/execute","harness/workspace/transition","task-inbox/execute","refiner/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"])).max(50),allowedTools:e.array(a).max(128),maxPageSize:C,maxRequestBytes:e.number().int().min(1).max(8388608),maxInFlight:e.number().int().min(1).max(64)}).strict();var ye=class{static{o(this,"AgentHostStorageClient")}#e=new Map;#t=null;#r=1;bind(t){if(this.#t)throw new Error("Host storage client is already bound.");this.#t=t}async request(t,r=15e3){let i=Ie.parse(t);if(!this.#t)throw new Error("Host storage transport is unavailable.");if(this.#e.size>=32)throw new Error("Host storage request limit exceeded.");let s=`host-storage:${this.#r++}`,c={jsonrpc:"2.0",id:s,method:"host/storage",params:i},l=i.operation==="experiment/policy"||i.operation==="experiment/environment";if(Buffer.byteLength(JSON.stringify(c))>(l?8388608:256e3))throw new Error("Host storage request is too large.");let d=new Promise((m,h)=>{let y=i.operation==="profile-evaluations/grade"?42e4:i.operation==="sandbox/request"||i.operation==="profile-evaluations/sandbox"||l?3e5:6e4,b=setTimeout(()=>{this.#e.delete(s),h(new Error("Host storage request timed out."))},Math.max(1,Math.min(y,r)));this.#e.set(s,{resolve:m,reject:h,timer:b,maxResponseBytes:i.operation==="experiment/environment"?16e5:1e6})});try{await this.#t(c)}catch(m){let h=this.#e.get(s);h&&(clearTimeout(h.timer),this.#e.delete(s),h.reject(m instanceof Error?m:new Error(String(m))))}return d}accept(t){let r=F.safeParse(t),i=r.success?null:J.safeParse(t),s=r.success?r.data:i?.success?i.data:null;if(!s||typeof s.id!="string"||!s.id.startsWith("host-storage:"))return!1;let c=this.#e.get(s.id);return c?(clearTimeout(c.timer),this.#e.delete(s.id),Buffer.byteLength(JSON.stringify(s))>c.maxResponseBytes?(c.reject(new Error("Host storage response is too large.")),!0):("error"in s?c.reject(new Error(`Host storage request failed: ${s.error.message}`)):c.resolve(s.result),!0)):!0}close(){this.#t=null;for(let t of this.#e.values())clearTimeout(t.timer),t.reject(new Error("Host storage transport closed."));this.#e.clear()}};import{once as Oe}from"node:events";import{createInterface as Be}from"node:readline";async function Qt(n){let t=null,r=Promise.resolve(),i=[],s=o(g=>(r=r.then(async()=>{n.writable.write(`${JSON.stringify(g)}
|
|
3
|
-
`)||await
|
|
2
|
+
import{b as e}from"./chunk-ES2ISFJC.js";import{a as o}from"./chunk-FTQLQJQV.js";import{createHash as Ce}from"node:crypto";function F(i){if(i===null||typeof i=="boolean"||typeof i=="string")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new Error("Canonical JSON cannot encode a non-finite number.");return i}if(Array.isArray(i))return i.map(F);if(typeof i=="object"){let t={};for(let r of Object.keys(i).sort()){let n=i[r];n!==void 0&&(t[r]=F(n))}return t}throw new Error(`Canonical JSON cannot encode ${typeof i}.`)}o(F,"canonicalJson");function R(i){return Ce("sha256").update(JSON.stringify(F(i)),"utf8").digest("hex")}o(R,"canonicalHash");function st(i){if(!i.maxContextTokens||!i.usableContextTokens)return{shouldCompact:!1,projectedTokens:i.projectedTokens,thresholdTokens:Number.MAX_SAFE_INTEGER,usableContextTokens:0,maxContextTokens:0,tokenSource:"heuristic"};let t=Math.max(.01,Math.min(1,(i.triggerPercent??85)/100)),r=Math.max(1,Math.floor(i.usableContextTokens*t));return{shouldCompact:i.projectedTokens>=r,projectedTokens:i.projectedTokens,thresholdTokens:r,usableContextTokens:i.usableContextTokens,maxContextTokens:i.maxContextTokens,tokenSource:"heuristic"}}o(st,"agentCompactionDecision");async function ot(i){await i.started();try{return await i.compact()}catch(t){throw await i.failed(t),t}}o(ot,"runAgentCompaction");async function at(i){let t=i.host.projectEvents(i.events),r=i.host.selectEvents(t,i.maxContextTokens),{summaryEvents:n,preservedEvents:s,preservedEventIds:c}=r;if(n.length===0)throw new Error("There is not enough prior context to compact.");let l=i.host.normalizeRecords(n),u=i.host.normalizeRecords(s),m=i.host.buildFileLedger(i.host.normalizeRecords(t)),h=i.host.serializeRecords(l,i.host.inputCharBudget(i.maxContextTokens));if(!h.text.trim())throw new Error("There is not enough prior context to compact.");let y=i.host.buildSummaryMessages({serializedHistory:h.text,fileLedger:m}),b=Date.now(),v=(await i.host.streamSummary({model:i.model,messages:y,signal:i.signal})).trim(),I=Date.now()-b;if(!v)throw new Error("Compaction summary was empty.");let g=i.host.estimateProjection({events:t,preservedEvents:s,summary:v}),f=i.host.createMetrics({sourceEvents:t.length,summarizedEvents:n.length,preservedEvents:s.length,sourceRecords:h.sourceRecordCount,includedRecords:h.includedRecordCount,omittedRecords:h.omittedRecordCount,preservedRecords:u.length,truncatedRecords:h.truncatedRecordCount,summaryInputTruncated:h.inputTruncated,sourceSelectionStrategy:h.selectionStrategy,summaryInputChars:h.inputChars,retainedTailTokens:r.retainedTailTokens,retainedTailBudgetTokens:r.retainedTailBudgetTokens,finalProviderContextTokens:g.inputTokensAfter,durationMs:I,fileLedgerEntries:m.length,splitTurnId:r.splitTurnId});return{summary:v,model:i.model,compactedThroughEventId:t[t.length-1]?.id??null,compactedThroughTurnId:i.host.lastTurnId(t),preservedFromEventId:s[0]?.id??null,preservedEventIds:c,preservedResourceRefs:i.host.durableResourceRefs(i.events),sourceEventCount:n.length,preservedEventCount:s.length,fileLedger:m,inputTokensBefore:g.inputTokensBefore,inputTokensAfter:g.inputTokensAfter,maxContextTokens:i.maxContextTokens,tokenSource:"heuristic",metrics:f}}o(at,"runAgentCompactionProgram");var qe=e.enum(["thread.started","thread.resumed","turn.started","turn.steered","turn.interrupted","turn.completed","turn.failed","item.started","item.delta","item.completed","assistant.reasoning.delta","assistant.delta","tool.started","tool.completed","approval.requested","approval.resolved","user_input.requested","user_input.resolved","compaction.started","compaction.completed","harness.admitted","harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed","diagnostic"]),Pe=e.object({sequence:e.number().int().nonnegative(),name:qe,source:e.enum(["runtime","provider","tool","host","refiner"]),status:e.string().trim().min(1).nullable().default(null),threadId:e.string().trim().min(1),turnId:e.string().trim().min(1).nullable().default(null),callId:e.string().trim().min(1).nullable().default(null),output:e.string().nullable().default(null),error:e.string().nullable().default(null),data:e.record(e.string(),e.unknown()).default({})}).strict();function pt(i){return R(Pe.parse(i))}o(pt,"canonicalEventHash");var A="2026-09-20",bt=["initialize","initialized","runtime/capabilities","thread/start","thread/resume","thread/read","turn/start","turn/steer","task/inbox","task/queue","task/inputUpdate","turn/interrupt","approval/resolve","userInput/resolve","profile/workflows","profile/evaluations","profile/trainingSource","profile/evaluations/prepare","profile/evaluations/run","profile/evaluations/runSuite","profile/evaluations/executeCase","profile/evaluations/executeRun","profile/evaluations/compare","profile/evaluations/report","experiments/executeCase","experiments/cancelCase","harness/inspect","harness/proposalReview","harness/review","harness/acceptEvaluationReview","harness/materializeEvaluationTaskset","harness/runEvaluationBaseline","harness/validate","harness/backgroundReview","harness/diff","harness/rollback","refiner/inspect","refiner/update","refiner/activate","refiner/rollback"],Z=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number()]),method:e.string().trim().min(1),params:e.unknown().optional()}).strict(),ee=e.object({jsonrpc:e.literal("2.0"),method:e.string().trim().min(1),params:e.unknown().optional()}).strict(),W=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number()]),result:e.unknown()}).strict(),J=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number(),e.null()]),error:e.object({code:e.number().int(),message:e.string(),data:e.unknown().optional()}).strict()}).strict(),gt=e.union([Z,ee,W,J]),Ae=e.object({protocolVersion:e.string().trim().min(1),client:e.object({name:e.string().trim().min(1),version:e.string().trim().min(1)}).strict(),capabilities:e.record(e.string(),e.unknown()).default({})}).strict(),B=class{static{o(this,"AgentJsonRpcDispatcher")}#e;#t=null;#r=!1;constructor(t){this.#e=t}get initialized(){return this.#r}async handle(t){let r=ee.safeParse(t);if(r.success&&!("id"in t)){if(r.data.method==="initialized"){if(!this.#t)throw new T(-32002,"initialize must be called first");this.#r=!0}return null}let n=Z.safeParse(t);if(!n.success)return Y(null,-32600,"Invalid Request",n.error.flatten());let s=n.data;try{let c=await this.#n(s.method,s.params);return{jsonrpc:"2.0",id:s.id,result:c}}catch(c){let l=c instanceof T?c:new T(-32603,c instanceof Error?c.message:String(c));return Y(s.id,l.code,l.message,l.data)}}async#n(t,r){if(t==="initialize"){let n=Ae.parse(r);if(n.protocolVersion!==A)throw new T(-32001,"Incompatible agent protocol version",{requested:n.protocolVersion,supported:A});return this.#t=n,{protocolVersion:A,server:{name:"openpond-app-server",version:"1"},capabilities:await this.#e.capabilities()}}if(!this.#r)throw new T(-32002,"initialized notification is required");switch(t){case"runtime/capabilities":return this.#e.capabilities(r);case"thread/start":return this.#e.threadStart(r);case"thread/resume":return this.#e.threadResume(r);case"thread/read":return this.#e.threadRead(r);case"turn/start":return this.#e.turnStart(r);case"turn/steer":return this.#e.turnSteer(r);case"task/inbox":return this.#e.taskInbox(r);case"task/queue":return this.#e.taskQueue(r);case"task/inputUpdate":return this.#e.taskInputUpdate(r);case"turn/interrupt":return this.#e.turnInterrupt(r);case"approval/resolve":return this.#e.approvalResolve(r);case"userInput/resolve":return this.#e.userInputResolve(r);case"profile/workflows":return this.#e.profileWorkflows(r);case"profile/evaluations":return this.#e.profileEvaluations(r);case"profile/trainingSource":return this.#e.profileTrainingSource(r);case"profile/evaluations/prepare":return this.#e.profileEvaluationPrepare(r);case"profile/evaluations/run":return this.#e.profileEvaluationRun(r);case"experiments/executeCase":{if(!this.#e.experimentExecuteCase)throw new Error("Experiment execution is unavailable in this runtime.");return this.#e.experimentExecuteCase(r)}case"experiments/cancelCase":{if(!this.#e.experimentCancelCase)throw new Error("Experiment cancellation is unavailable in this runtime.");return this.#e.experimentCancelCase(r)}case"profile/evaluations/runSuite":return this.#e.profileEvaluationRunSuite(r);case"profile/evaluations/executeCase":return this.#e.profileEvaluationExecuteCase(r);case"profile/evaluations/executeRun":return this.#e.profileEvaluationExecuteRun(r);case"profile/evaluations/compare":return this.#e.profileEvaluationCompare(r);case"profile/evaluations/report":return this.#e.profileEvaluationReport(r);case"harness/inspect":return this.#e.harnessInspect(r);case"harness/proposalReview":return this.#e.harnessProposalReview(r);case"harness/review":return this.#e.harnessReview(r);case"harness/acceptEvaluationReview":return this.#e.harnessAcceptEvaluationReview(r);case"harness/materializeEvaluationTaskset":return this.#e.harnessMaterializeEvaluationTaskset(r);case"harness/runEvaluationBaseline":return this.#e.harnessRunEvaluationBaseline(r);case"harness/validate":return this.#e.harnessValidate(r);case"harness/backgroundReview":return this.#e.harnessBackgroundReview(r);case"harness/diff":return this.#e.harnessDiff(r);case"harness/rollback":return this.#e.harnessRollback(r);case"refiner/inspect":return this.#e.refinerInspect(r);case"refiner/update":return this.#e.refinerUpdate(r);case"refiner/activate":return this.#e.refinerActivate(r);case"refiner/rollback":return this.#e.refinerRollback(r);default:throw new T(-32601,`Method not found: ${t}`)}}},T=class extends Error{static{o(this,"JsonRpcDispatchError")}code;data;constructor(t,r,n){super(r),this.code=t,this.data=n}};function Y(i,t,r,n){return{jsonrpc:"2.0",id:i,error:{code:t,message:r,...n===void 0?{}:{data:n}}}}o(Y,"jsonRpcError");var te=class{static{o(this,"AgentRpcClient")}#e;#t;constructor(t){this.#e=t.request.bind(t),this.#t=t.notify.bind(t)}async initialize(t,r={}){let n=await this.#e("initialize",{protocolVersion:A,client:t,capabilities:r});return await this.#t("initialized"),n}capabilities=o((t={})=>this.#e("runtime/capabilities",t),"capabilities");threadStart=o(t=>this.#e("thread/start",t),"threadStart");threadResume=o(t=>this.#e("thread/resume",t),"threadResume");threadRead=o(t=>this.#e("thread/read",t),"threadRead");turnStart=o(t=>this.#e("turn/start",t),"turnStart");turnSteer=o(t=>this.#e("turn/steer",t),"turnSteer");taskInbox=o(t=>this.#e("task/inbox",t),"taskInbox");taskQueue=o(t=>this.#e("task/queue",t),"taskQueue");taskInputUpdate=o(t=>this.#e("task/inputUpdate",t),"taskInputUpdate");turnInterrupt=o(t=>this.#e("turn/interrupt",t),"turnInterrupt");approvalResolve=o(t=>this.#e("approval/resolve",t),"approvalResolve");userInputResolve=o(t=>this.#e("userInput/resolve",t),"userInputResolve");profileWorkflows=o(t=>this.#e("profile/workflows",t),"profileWorkflows");profileEvaluations=o(t=>this.#e("profile/evaluations",t),"profileEvaluations");profileEvaluationPrepare=o(t=>this.#e("profile/evaluations/prepare",t),"profileEvaluationPrepare");profileEvaluationRun=o(t=>this.#e("profile/evaluations/run",t),"profileEvaluationRun");profileEvaluationRunSuite=o(t=>this.#e("profile/evaluations/runSuite",t),"profileEvaluationRunSuite");profileEvaluationExecuteCase=o(t=>this.#e("profile/evaluations/executeCase",t),"profileEvaluationExecuteCase");profileEvaluationExecuteRun=o(t=>this.#e("profile/evaluations/executeRun",t),"profileEvaluationExecuteRun");profileEvaluationCompare=o(t=>this.#e("profile/evaluations/compare",t),"profileEvaluationCompare");experimentExecuteCase=o(t=>this.#e("experiments/executeCase",t),"experimentExecuteCase");experimentCancelCase=o(t=>this.#e("experiments/cancelCase",t),"experimentCancelCase");harnessInspect=o((t={})=>this.#e("harness/inspect",t),"harnessInspect");harnessProposalReview=o((t={})=>this.#e("harness/proposalReview",t),"harnessProposalReview");harnessReview=o((t={})=>this.#e("harness/review",t),"harnessReview");harnessAcceptEvaluationReview=o((t={})=>this.#e("harness/acceptEvaluationReview",t),"harnessAcceptEvaluationReview");harnessMaterializeEvaluationTaskset=o((t={})=>this.#e("harness/materializeEvaluationTaskset",t),"harnessMaterializeEvaluationTaskset");harnessRunEvaluationBaseline=o((t={})=>this.#e("harness/runEvaluationBaseline",t),"harnessRunEvaluationBaseline");harnessValidate=o((t={})=>this.#e("harness/validate",t),"harnessValidate");harnessBackgroundReview=o((t={})=>this.#e("harness/backgroundReview",t),"harnessBackgroundReview");harnessDiff=o((t={})=>this.#e("harness/diff",t),"harnessDiff");harnessRollback=o((t={})=>this.#e("harness/rollback",t),"harnessRollback");refinerInspect=o(t=>this.#e("refiner/inspect",t),"refinerInspect");refinerUpdate=o(t=>this.#e("refiner/update",t),"refinerUpdate");refinerActivate=o(t=>this.#e("refiner/activate",t),"refinerActivate");refinerRollback=o(t=>this.#e("refiner/rollback",t),"refinerRollback")};var G=e.object({caseId:e.string().trim().min(1).max(191),admissionHash:e.string().regex(/^[a-f0-9]{64}$/),definitionHash:e.string().regex(/^[a-f0-9]{64}$/),ordinal:e.number().int().nonnegative(),operation:e.enum(["create","reset","step","collect","destroy"]),value:e.record(e.string(),e.unknown()),timeoutMs:e.number().int().min(1).max(3e4)}).strict();var d=e.string().trim().min(1).max(200),$=e.string().trim().min(1).max(32e3),z=e.number().int().nonnegative(),re=e.object({id:d,sessionId:d,senderSessionId:d.nullable(),senderKind:e.enum(["user","task","runtime"]),kind:e.enum(["steer","message","followup","queued","result"]),body:$,payload:e.record(e.string(),e.unknown()),idempotencyKey:d,replyTo:d.nullable(),expectedTurnId:d.nullable()}).strict(),ze=e.discriminatedUnion("action",[e.object({action:e.literal("resume"),expectedRevision:e.number().int().positive()}).strict(),e.object({action:e.literal("cancel"),expectedRevision:e.number().int().positive()}).strict(),e.object({action:e.literal("edit"),expectedRevision:e.number().int().positive(),body:$}).strict(),e.object({action:e.literal("steer"),expectedRevision:e.number().int().positive(),expectedTurnId:d}).strict()]),ne=e.object({id:d,sessionId:d,turnId:d,targetSessionId:d.nullable(),targetTurnId:d.nullable(),targetInputId:d.nullable(),afterSequence:z,deadline:e.string(),state:e.enum(["waiting","message","completed","failed","interrupted","unavailable","timeout","cancelled"]),createdAt:e.string(),updatedAt:e.string()}).strict(),ie=e.record(e.string(),e.unknown()),He=e.enum(["queued","running","completed","failed","cancelled","needs_resume"]),Me=e.object({parentSessionId:d.nullable().optional(),childSessionId:d.nullable().optional(),status:e.array(He).nullable().optional(),afterId:e.string().max(200),limit:e.number().int().min(1).max(10)}).strict(),se=e.discriminatedUnion("action",[e.object({action:e.literal("recoverTaskInboxOwners"),ownerId:d}).strict(),e.object({action:e.literal("hasTaskCompletion"),turnId:d}).strict(),e.object({action:e.literal("taskInboxSnapshot"),sessionId:d}).strict(),e.object({action:e.literal("taskInboxSnapshotInputs"),sessionId:d,afterSequence:z}).strict(),e.object({action:e.literal("declareTaskWork"),sessionId:d,turnId:d,ownerId:d,areas:e.array($).max(100)}).strict(),e.object({action:e.literal("taskWorkAreas"),sessionId:d}).strict(),e.object({action:e.literal("admitTaskInput"),input:re}).strict(),e.object({action:e.literal("admitTaskInputs"),inputs:e.array(re).max(50)}).strict(),e.object({action:e.literal("rejectTaskInput"),id:d,error:$}).strict(),e.object({action:e.literal("getTaskInput"),id:d}).strict(),e.object({action:e.literal("taskInputsForSession"),sessionId:d,query:e.object({afterSequence:z.optional(),pendingOnly:e.boolean().optional(),limit:e.number().int().min(1).max(500).optional()}).strict()}).strict(),e.object({action:e.literal("mutateTaskInput"),sessionId:d,inputId:d,change:ze}).strict(),e.object({action:e.literal("openTaskInboxTurn"),sessionId:d,turnId:d,ownerId:d}).strict(),e.object({action:e.literal("renewTaskInboxTurn"),sessionId:d,turnId:d,ownerId:d}).strict(),e.object({action:e.literal("pendingTaskInputs"),sessionId:d,turnId:d,afterSequence:z}).strict(),e.object({action:e.literal("taskAssignmentInputs"),turnId:d,afterSequence:z}).strict(),e.object({action:e.literal("pauseTaskInboxTurn"),sessionId:d,turnId:d,ownerId:d}).strict(),e.object({action:e.literal("includeTaskInputs"),sessionId:d,turnId:d,ownerId:d,requestId:d}).strict(),e.object({action:e.literal("settleTaskInputRequest"),requestId:d,outcome:e.enum(["resolved","failed","replaced"])}).strict(),e.object({action:e.literal("sealTaskInboxTurn"),sessionId:d,turnId:d,ownerId:d}).strict(),e.object({action:e.literal("sealNativeTaskInboxTurn"),sessionId:d,turnId:d,ownerId:d}).strict(),e.object({action:e.literal("closeTaskInboxTurn"),sessionId:d,turnId:d,ownerId:d,outcome:e.enum(["completed","failed","interrupted"])}).strict(),e.object({action:e.literal("taskInboxPaused"),sessionId:d}).strict(),e.object({action:e.literal("reserveTaskFollowup"),sessionId:d,turnId:d,ownerId:d}).strict(),e.object({action:e.literal("taskInboxWakeTargets"),afterSessionId:e.string().max(200)}).strict(),e.object({action:e.literal("createTaskWait"),value:ne}).strict(),e.object({action:e.literal("settleTaskWait"),id:d,state:ne.shape.state}).strict(),e.object({action:e.literal("taskWaitsForSession"),sessionId:d,afterId:e.string().max(200)}).strict(),e.object({action:e.literal("commitSubagentCompletion"),value:ie,turnId:d}).strict(),e.object({action:e.literal("pendingTaskCompletions"),afterTurnId:e.string().max(200)}).strict(),e.object({action:e.literal("settleTaskCompletion"),turnId:d,inputId:d}).strict(),e.object({action:e.literal("upsertSubagentRun"),value:ie}).strict(),e.object({action:e.literal("getSubagentRun"),id:d}).strict(),e.object({action:e.literal("listSubagentRuns"),query:Me}).strict()]);var H=e.string().trim().min(1).max(191),oe=e.object({createdAt:e.string().min(1),id:H}).strict(),ae=e.enum(["trigger_decision","route_decision","refiner_outcome","proposal","targeted_validation","apply_receipt"]),ce=e.discriminatedUnion("action",[e.object({action:e.literal("active_release"),workspaceId:H}).strict(),e.object({action:e.literal("put_artifact"),workspaceId:H,kind:ae,artifact:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("artifact_page"),workspaceId:H,kind:ae,before:oe.nullable(),limit:e.number().int().min(1).max(200)}).strict(),e.object({action:e.literal("pending_trigger_page"),workspaceId:H,before:oe.nullable(),limit:e.number().int().min(1).max(200)}).strict()]);var w=e.string().trim().min(1).max(240),le=e.string().regex(/^[a-f0-9]{64}$/),ue=e.enum(["run_overlay","observation","trigger_decision","route_decision","proposal","targeted_validation","apply_receipt","refiner_outcome"]),de=e.object({createdAt:e.string().datetime(),id:w}).strict(),pe=e.discriminatedUnion("action",[e.object({action:e.literal("artifact_put"),workspaceId:w,kind:ue,artifact:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("artifact_page"),workspaceId:w,kind:ue,before:de.nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("pending_page"),workspaceId:w,before:de.nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("workspace_get"),workspaceId:w}).strict(),e.object({action:e.literal("background_get"),workspaceId:w}).strict(),e.object({action:e.literal("overlay_get"),runId:w}).strict(),e.object({action:e.literal("overlay_freeze"),runId:w,expectedRevision:e.number().int().nonnegative(),overlay:e.record(e.string(),e.unknown()),proposal:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("memory_get"),workspaceId:w,sessionId:w,key:w}).strict(),e.object({action:e.literal("memory_page"),workspaceId:w,sessionId:w,before:e.object({updatedAt:e.string().datetime(),key:w}).strict().nullable(),limit:e.number().int().min(1).max(20),includeDeleted:e.boolean()}).strict(),e.object({action:e.literal("memory_write"),sessionId:w,input:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("release_get"),contentHash:le}).strict(),e.object({action:e.literal("release_put"),record:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("session_get"),sessionId:w}).strict(),e.object({action:e.literal("turn_get"),turnId:w}).strict(),e.object({action:e.literal("turn_page"),sessionId:w,before:e.number().int().positive().nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("event_page"),turnId:w,afterSequence:e.number().int().nonnegative(),names:e.array(w).max(40),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("event_append"),event:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("usage_put"),record:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("snapshot_restore"),turnId:w,expectedHash:le,snapshot:e.record(e.string(),e.unknown())}).strict()]);var j=e.string().trim().min(1).max(200),me=e.string().regex(/^[a-f0-9]{64}$/),Ve=e.object({kind:e.enum(["structural","visual","test","user_review"]),status:e.enum(["passed","failed","not_run"]),label:e.string().trim().min(1).max(240),detail:e.string().trim().max(4e3).nullable().optional(),ref:e.string().trim().max(4096).nullable().optional()}),he=e.object({id:j,title:e.string().trim().min(1).max(240),sourceTaskId:j,sourceTurnId:j,revision:e.number().int().positive(),createdAt:e.string().datetime(),contentType:e.string().trim().min(1).max(200),sizeBytes:e.number().int().min(1).max(1e7),sha256:me,validation:e.array(Ve).max(32)}).strict(),fe=e.object({sessionId:j,turnId:j,output:he}).strict(),be=e.object({uploadId:j,index:e.number().int().min(0).max(1024),offset:e.number().int().min(0).max(1e7),sha256:me,contentsBase64:e.string().min(1).max(131072)}).strict(),ge=e.object({uploadId:j}).strict(),Ue=he.pick({id:!0,title:!0,sourceTaskId:!0,sourceTurnId:!0,revision:!0,createdAt:!0,validation:!0}),we=e.object({sessionId:j,turnId:j,output:Ue,sandboxPath:e.string().trim().min(1).max(4096)}).strict();var M=e.string().trim().min(1).max(200),Oe=e.object({type:e.enum(["create","get","start","stop","exec","open_port","list_files","download_file","upload_file","search_files","delete_file","stat_file","mkdir","move_file","process_start","process_get","git_status","git_diff","git_export_patch","git_branch","git_commit","git_pull","git_push"]),sandboxId:M.optional(),payload:e.unknown().optional(),processId:M.optional(),failOnUnpreservedChanges:e.boolean().optional()}).strict().superRefine((i,t)=>{i.type!=="create"&&!i.sandboxId&&t.addIssue({code:"custom",message:"Sandbox identity is required."}),i.type==="create"&&i.sandboxId&&t.addIssue({code:"custom",message:"Create cannot target a sandbox identity."}),i.type==="process_get"&&!i.processId&&t.addIssue({code:"custom",message:"Process identity is required."})}),ve=e.object({action:Oe}).strict(),xe=e.object({sessionId:M,turnId:M,name:M}).strict();var p=1,a=e.string().trim().min(1).max(191),C=e.number().int().min(1).max(200),Nt=e.object({teamId:a,ownerUserId:a,workspaceId:a,conversationId:a,turnId:a,attempt:e.number().int().min(1),leaseGeneration:e.number().int().min(1)}).strict(),Ie=e.discriminatedUnion("operation",[e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/grade"),params:e.object({action:e.enum(["upload","execute"]),callId:a,sessionId:a,turnId:a,sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().positive().max(2e7),timeoutMs:e.number().int().positive().max(3e5),offset:e.number().int().nonnegative().max(2e7).optional(),contentsBase64:e.string().max(131072).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/sandbox"),params:e.object({sessionId:a,turnId:a,action:e.enum(["upload","exec","read","stop"]),area:e.enum(["policy","runtime"]).optional(),path:e.string().min(1).max(4096).optional(),sha256:e.string().regex(/^[a-f0-9]{64}$/).optional(),sizeBytes:e.number().int().min(0).max(1e7).optional(),offset:e.number().int().min(0).max(1e7).optional(),contentsBase64:e.string().max(131072).optional(),command:e.string().min(1).max(2e4).optional(),stdin:e.string().max(12e4).optional(),cwd:e.string().max(4096).optional(),timeoutMs:e.number().int().min(1).max(18e4).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/list"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/read"),params:e.object({fileId:a,revision:e.number().int().min(1),offset:e.number().int().min(0).max(1e7).optional(),maxChars:e.number().int().min(1).max(1e5).optional(),firstPage:e.number().int().min(1).max(1e3).optional(),pageCount:e.number().int().min(1).max(10).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/readBytes"),params:e.object({sessionId:a,turnId:a,fileId:a,revision:e.number().int().positive(),sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().min(1).max(1e7),offset:e.number().int().min(0).max(1e7)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile.externalDataset.authorize"),params:e.object({bindingHash:e.string().regex(/^[a-f0-9]{64}$/),manifestHash:e.string().regex(/^[a-f0-9]{64}$/).optional(),taskId:a.optional(),seed:e.string().min(1).max(500).optional()}).strict().refine(i=>!!i.taskId==!!i.seed,"Case authority requires both task and seed.")}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("experiment/environment"),params:G}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("experiment/policy"),params:e.object({caseId:a,admissionHash:e.string().regex(/^[a-f0-9]{64}$/),ordinal:e.number().int().nonnegative(),messages:e.array(e.record(e.string(),e.unknown())).max(2e3),tools:e.array(e.record(e.string(),e.unknown())).max(200)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("sandbox/request"),params:ve}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("embedding/authorize"),params:xe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/begin"),params:fe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/chunk"),params:be}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/complete"),params:ge}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/saveSandboxFile"),params:we}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("settings/get"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/get"),params:e.object({reference:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/get"),params:e.object({runId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/put"),params:e.object({runId:a,expectedRevision:e.number().int().min(0).nullable(),overlay:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/freezeProposal"),params:e.object({runId:a,expectedRevision:e.number().int().min(0),overlay:e.record(e.string(),e.unknown()),proposal:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/get"),params:e.object({workspaceId:a,key:e.string().min(1).max(120)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/list"),params:e.object({workspaceId:a,includeDeleted:e.boolean(),before:e.object({updatedAt:e.string(),key:e.string()}).strict().nullable(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/search"),params:e.object({workspaceId:a,query:e.string().trim().min(1).max(500),limit:e.number().int().min(1).max(20)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/write"),params:e.object({input:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/state/read"),params:e.object({workspaceId:a,kind:e.enum(["selection","workspace_settings","evaluation_review_settings","candidates","cross_run_requests"]),afterId:a.nullable(),limit:e.number().int().min(1).max(100)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/execute"),params:e.discriminatedUnion("action",[e.object({action:e.literal("get"),kind:e.enum(["grade","receipt","run","comparison","suite"]),id:a}).strict(),e.object({action:e.literal("page"),kind:e.enum(["grade","receipt","run","comparison","suite"]),profileKey:e.string().regex(/^[a-f0-9]{64}$/),before:e.object({createdAt:e.string(),id:a}).strict().nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("put"),kind:e.enum(["grade","receipt","run","comparison","suite"]),payload:e.record(e.string(),e.unknown()),profileKey:e.string().regex(/^[a-f0-9]{64}$/).nullable(),createdAt:e.string()}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/workspace/transition"),params:e.discriminatedUnion("action",[e.object({action:e.literal("advance"),receiptId:a,workspaceId:a,proposal:e.record(e.string(),e.unknown()),validations:e.array(e.record(e.string(),e.unknown())).max(100),nextRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),nextSourceRevision:e.string().min(1),now:e.string()}).strict(),e.object({action:e.literal("reviewedAdvance"),receiptId:a,workspaceId:a,proposal:e.record(e.string(),e.unknown()),validations:e.array(e.record(e.string(),e.unknown())).max(100),nextRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),nextSourceRevision:e.string().min(1),reviewer:a,now:e.string()}).strict(),e.object({action:e.literal("rollback"),receiptId:a,workspaceId:a,expectedWorkspaceRevision:e.number().int().nonnegative(),expectedChannelRevision:e.number().int().nonnegative(),targetRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),targetSourceRevision:e.string().min(1),rollbackOf:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),now:e.string()}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("task-inbox/execute"),params:se}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/review/execute"),params:pe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("refiner/execute"),params:e.object({action:ce}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("create-improve/execute"),params:e.discriminatedUnion("action",[e.object({action:e.literal("get"),runId:a}).strict(),e.object({action:e.literal("page"),query:e.object({profileId:a.nullable(),targetKind:a.nullable(),targetId:a.nullable(),state:e.array(a).max(20)}).strict(),before:e.object({updatedAt:e.string(),id:a}).strict().nullable(),limit:C}).strict(),e.object({action:e.literal("put"),run:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("mutate"),mutation:e.record(e.string(),e.unknown()),next:e.record(e.string(),e.unknown())}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("approval/get"),params:e.object({approvalId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("approval/upsert"),params:e.object({approval:e.record(e.string(),e.unknown()),expectedRevision:e.number().int().min(1).nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/getByRequestId"),params:e.object({requestId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/upsert"),params:e.object({record:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/page"),params:e.object({query:e.object({sessionId:a.optional(),turnId:a.optional(),provider:a.optional(),model:a.optional(),startedAtFrom:e.string().optional(),startedAtTo:e.string().optional(),visibility:e.enum(["user_facing","background","system"]).optional(),status:e.enum(["started","completed","failed","interrupted","missing"]).optional()}).strict(),before:e.object({startedAt:e.string(),requestOrdinal:e.number().int().min(0),id:a}).strict().nullable(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("capabilities"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/count"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/get"),params:e.object({sessionId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/page"),params:e.object({afterId:a.nullable(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/put"),params:e.object({sessionId:a,expectedRevision:e.number().int().min(1).nullable(),session:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/count"),params:e.object({sessionId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/wakeCount"),params:e.object({sessionId:a,key:e.enum(["messageId","fromRunId"]),value:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/get"),params:e.object({turnId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/put"),params:e.object({sessionId:a,turnId:a,expectedRevision:e.number().int().min(1).nullable(),turn:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/latest"),params:e.object({sessionId:a,status:e.enum(["in_progress","completed","failed","interrupted"]).nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/page"),params:e.object({sessionId:a,beforeSortIndex:e.number().int().min(0).nullable().optional(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("thread/turnPage"),params:e.object({sessionId:a,beforeSortIndex:e.number().int().min(0).nullable().optional(),limit:C}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("event/append"),params:e.object({event:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("events/page"),params:e.object({sessionId:a.nullable(),afterSequence:e.number().int().min(0),beforeSequence:e.number().int().min(1).nullable().optional(),limit:C,excludeReasoningDeltas:e.boolean().optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("events/latestAssistantText"),params:e.object({sessionId:a}).strict()}).strict()]),Lt=e.object({contractVersion:e.literal(p),operations:e.array(e.enum(["experiment/policy","experiment/environment","sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","output/readBytes","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/overlay/freezeProposal","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","profile-evaluations/execute","profile-evaluations/sandbox","profile-evaluations/grade","harness/review/execute","harness/workspace/transition","task-inbox/execute","refiner/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"])).max(50),allowedTools:e.array(a).max(128),maxPageSize:C,maxRequestBytes:e.number().int().min(1).max(8388608),maxInFlight:e.number().int().min(1).max(64)}).strict();var ye=class{static{o(this,"AgentHostStorageClient")}#e=new Map;#t=null;#r=1;bind(t){if(this.#t)throw new Error("Host storage client is already bound.");this.#t=t}async request(t,r=15e3){let n=Ie.parse(t);if(!this.#t)throw new Error("Host storage transport is unavailable.");if(this.#e.size>=32)throw new Error("Host storage request limit exceeded.");let s=`host-storage:${this.#r++}`,c={jsonrpc:"2.0",id:s,method:"host/storage",params:n},l=n.operation==="experiment/policy"||n.operation==="experiment/environment";if(Buffer.byteLength(JSON.stringify(c))>(l?8388608:256e3))throw new Error("Host storage request is too large.");let u=new Promise((m,h)=>{let y=n.operation==="profile-evaluations/grade"?42e4:n.operation==="sandbox/request"||n.operation==="profile-evaluations/sandbox"||l?3e5:6e4,b=setTimeout(()=>{this.#e.delete(s),h(new Error("Host storage request timed out."))},Math.max(1,Math.min(y,r)));this.#e.set(s,{resolve:m,reject:h,timer:b,maxResponseBytes:n.operation==="experiment/environment"?16e5:1e6})});try{await this.#t(c)}catch(m){let h=this.#e.get(s);h&&(clearTimeout(h.timer),this.#e.delete(s),h.reject(m instanceof Error?m:new Error(String(m))))}return u}accept(t){let r=W.safeParse(t),n=r.success?null:J.safeParse(t),s=r.success?r.data:n?.success?n.data:null;if(!s||typeof s.id!="string"||!s.id.startsWith("host-storage:"))return!1;let c=this.#e.get(s.id);return c?(clearTimeout(c.timer),this.#e.delete(s.id),Buffer.byteLength(JSON.stringify(s))>c.maxResponseBytes?(c.reject(new Error("Host storage response is too large.")),!0):("error"in s?c.reject(new Error(`Host storage request failed: ${s.error.message}`)):c.resolve(s.result),!0)):!0}close(){this.#t=null;for(let t of this.#e.values())clearTimeout(t.timer),t.reject(new Error("Host storage transport closed."));this.#e.clear()}};import{once as Be}from"node:events";import{createInterface as $e}from"node:readline";async function Zt(i){let t=null,r=Promise.resolve(),n=[],s=o(g=>(r=r.then(async()=>{i.writable.write(`${JSON.stringify(g)}
|
|
3
|
+
`)||await Be(i.writable,"drain")}),r),"write");i.hostStorageClient?.bind(g=>s(g));let c=o(()=>{if(!(!t?.initialized||n.length===0))for(let g of n.splice(0))s(g)},"flushPendingNotifications"),l,u=new Set,m=$e({input:i.readable,crlfDelay:1/0}),h=[],y=!1,b=null,v=o(async g=>{let f=t;if(!f)throw new Error("Agent runtime dispatcher is unavailable.");let E=(async()=>{let X=await f.handle(g);X&&await s(X),c()})(),Q=g&&typeof g=="object"&&"method"in g?g.method:null;if(Q==="initialize"||Q==="initialized"){await E;return}u.add(E),E.finally(()=>u.delete(E))},"dispatch"),I=(async()=>{let g=typeof i.host=="function"?await i.host():i.host;for(t=new B(g),l=g.subscribe?.(f=>{if(!t?.initialized){n.push(f);return}s(f)});h.length>0;)await v(h.shift());y=!0})().catch(g=>{b=g,m.close()});try{for await(let g of m){if(!g.trim())continue;if(Buffer.byteLength(g,"utf8")>1e6){await s({jsonrpc:"2.0",id:null,error:{code:-32600,message:"Request exceeds the JSONL size limit"}});continue}let f;try{f=JSON.parse(g)}catch{await s({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}});continue}if(!i.hostStorageClient?.accept(f))if(y)await v(f);else if(h.length>=64){let E=f&&typeof f=="object"&&"id"in f?f.id:null;(typeof E=="string"||typeof E=="number")&&await s({jsonrpc:"2.0",id:E,error:{code:-32e3,message:"Runtime startup request limit exceeded"}})}else h.push(f)}if(await I,b)throw b;await Promise.all(u),await r}finally{i.hostStorageClient?.close(),l?.()}}o(Zt,"runAgentJsonlServer");async function*ke(i){if(!Number.isInteger(i.maxRounds)||i.maxRounds<1)throw new Error("Provider maxRounds must be a positive integer.");for(let t=0;t<i.maxRounds;t+=1){if(i.signal.aborted)throw i.signal.reason??new Error("Provider loop interrupted.");yield{index:t,requestId:`${i.turnId}:model:${t}`,signal:i.signal}}}o(ke,"providerRoundSequence");async function Ne(i){for await(let t of ke(i)){let r=await i.runRound(t);if(r.type==="complete")return r.result}return i.onExhausted()}o(Ne,"runProviderRoundLoop");async function Le(i){let t="",r="",n,s=null,c,l=[];try{for await(let m of i.stream){if(await i.onDelta?.(m),i.signal.aborted)throw i.signal.reason??new Error("Provider round interrupted.");m.text&&(t+=m.text),m.reasoningText&&(r+=m.reasoningText),m.usage!==void 0&&(n=m.usage),m.continuation!==void 0&&(s=m.continuation),m.toolCalls&&l.push([...m.toolCalls]),m.finishReason!==void 0&&(c=m.finishReason)}let u={text:t,reasoningText:r,usage:n,continuation:s,toolCallBatches:l,finishReason:c};return await i.onCompleted?.(u),u}catch(u){throw await i.onFailed?.(u),u}}o(Le,"runProviderRound");var N=e.object({threadId:e.string().trim().min(1)}).passthrough(),De=N.extend({includeHistory:e.boolean().optional()}),Fe=e.object({session:e.unknown()}).strict(),V=N.extend({input:e.unknown()}),We=V.extend({idempotencyKey:e.string().trim().min(1).max(200)}),Je=V.extend({inputId:e.string().trim().min(1)}),Ge=N.extend({reason:e.string().trim().min(1).optional()}),Ke=e.object({approvalId:e.string().trim().min(1),input:e.unknown()}).strict();function ar(i){let t=o(async(n,s,c)=>{let l=performance.now();i.telemetry?.({method:n,phase:"started",threadId:s,durationMs:null,errorClass:null});try{let u=await c();return i.telemetry?.({method:n,phase:"completed",threadId:s,durationMs:performance.now()-l,errorClass:null}),u}catch(u){throw i.telemetry?.({method:n,phase:"failed",threadId:s,durationMs:performance.now()-l,errorClass:u instanceof Error?u.name:"UnknownError"}),u}},"run"),r=o(async(n,s="thread/read")=>{let{threadId:c,includeHistory:l}=De.parse(n);return t(s,c,async()=>{if(l===!1)return{thread:await i.readThread(c),turns:[],events:[]};let[u,m,h]=await Promise.all([i.readThread(c),i.listTurns(c),i.listEvents(c)]);return{thread:u,turns:m,events:h}})},"threadRead");return{capabilities:o(n=>t("runtime/capabilities",null,()=>i.capabilities(n)),"capabilities"),threadStart:o(async n=>t("thread/start",null,async()=>({thread:await i.createThread(Fe.parse(n).session)})),"threadStart"),threadResume:o(n=>r(n,"thread/resume"),"threadResume"),threadRead:r,turnStart:o(async n=>{let s=V.parse(n);return t("turn/start",s.threadId,async()=>({turn:await i.startTurn(s.threadId,s.input)}))},"turnStart"),turnSteer:o(async n=>{let s=V.parse(n);return t("turn/steer",s.threadId,async()=>({receipt:await i.steerTurn(s.threadId,s.input)}))},"turnSteer"),taskInbox:o(async n=>{let{threadId:s}=N.parse(n);return t("task/inbox",s,()=>i.readTaskInbox(s))},"taskInbox"),taskQueue:o(async n=>{let s=We.parse(n);return t("task/queue",s.threadId,()=>i.queueTaskInput(s.threadId,s.input,s.idempotencyKey))},"taskQueue"),taskInputUpdate:o(async n=>{let s=Je.parse(n);return t("task/inputUpdate",s.threadId,()=>i.updateTaskInput(s.threadId,s.inputId,s.input))},"taskInputUpdate"),turnInterrupt:o(async n=>{let s=Ge.parse(n);return t("turn/interrupt",s.threadId,async()=>({turn:await i.interruptTurn(s.threadId,s.reason)}))},"turnInterrupt"),approvalResolve:o(async n=>{let s=Ke.parse(n);return t("approval/resolve",null,async()=>({approval:await i.resolveApproval(s.approvalId,s.input)}))},"approvalResolve"),userInputResolve:o(async n=>{let s=V.parse(n);return t("userInput/resolve",s.threadId,async()=>(i.isTurnActive(s.threadId)&&await i.waitForTurnSettlement(s.threadId),{turn:await i.startTurn(s.threadId,s.input)}))},"userInputResolve"),profileWorkflows:o(()=>t("profile/workflows",null,()=>i.listProfileWorkflows()),"profileWorkflows"),profileEvaluations:o(n=>t("profile/evaluations",null,()=>i.listProfileEvaluations(n)),"profileEvaluations"),profileTrainingSource:o(()=>t("profile/trainingSource",null,()=>i.loadProfileTrainingSource()),"profileTrainingSource"),profileEvaluationPrepare:o(n=>t("profile/evaluations/prepare",null,()=>i.prepareProfileEvaluationRun(n)),"profileEvaluationPrepare"),profileEvaluationRun:o(n=>t("profile/evaluations/run",null,()=>i.runPreparedProfileEvaluation(n)),"profileEvaluationRun"),...i.executeExperimentCase?{experimentExecuteCase:o(n=>t("experiments/executeCase",null,()=>i.executeExperimentCase(n)),"experimentExecuteCase")}:{},...i.cancelExperimentCase?{experimentCancelCase:o(n=>t("experiments/cancelCase",null,()=>i.cancelExperimentCase(n)),"experimentCancelCase")}:{},profileEvaluationRunSuite:o(n=>t("profile/evaluations/runSuite",null,()=>i.runProfileEvaluationSuite(n)),"profileEvaluationRunSuite"),profileEvaluationExecuteCase:o(n=>t("profile/evaluations/executeCase",null,()=>i.executeProfileEvaluationCase(n)),"profileEvaluationExecuteCase"),profileEvaluationExecuteRun:o(n=>t("profile/evaluations/executeRun",null,()=>i.executeProfileEvaluationRun(n)),"profileEvaluationExecuteRun"),profileEvaluationCompare:o(n=>t("profile/evaluations/compare",null,()=>i.compareProfileEvaluationRuns(n)),"profileEvaluationCompare"),profileEvaluationReport:o(n=>t("profile/evaluations/report",null,()=>i.buildProfileEvaluationReport(n)),"profileEvaluationReport"),harnessInspect:o(()=>t("harness/inspect",null,()=>i.inspectHarness()),"harnessInspect"),harnessProposalReview:o(n=>t("harness/proposalReview",null,()=>i.reviewHarnessProposal(n)),"harnessProposalReview"),harnessReview:o(n=>t("harness/review",null,()=>i.reviewHarness(n)),"harnessReview"),harnessAcceptEvaluationReview:o(n=>t("harness/acceptEvaluationReview",null,()=>i.acceptHarnessEvaluationReview(n)),"harnessAcceptEvaluationReview"),harnessMaterializeEvaluationTaskset:o(n=>t("harness/materializeEvaluationTaskset",null,()=>i.materializeHarnessEvaluationTaskset(n)),"harnessMaterializeEvaluationTaskset"),harnessRunEvaluationBaseline:o(n=>t("harness/runEvaluationBaseline",null,()=>i.runHarnessEvaluationBaseline(n)),"harnessRunEvaluationBaseline"),harnessValidate:o(()=>t("harness/validate",null,()=>i.validateHarness()),"harnessValidate"),harnessBackgroundReview:o(n=>t("harness/backgroundReview",null,()=>i.updateHarnessBackgroundReview(n)),"harnessBackgroundReview"),harnessDiff:o(n=>t("harness/diff",null,()=>i.diffHarness(n)),"harnessDiff"),harnessRollback:o(n=>t("harness/rollback",null,()=>i.rollbackHarness(n)),"harnessRollback"),refinerInspect:o(()=>t("refiner/inspect",null,()=>i.inspectRefiner()),"refinerInspect"),refinerUpdate:o(n=>t("refiner/update",null,()=>i.updateRefiner(n)),"refinerUpdate"),refinerActivate:o(n=>t("refiner/activate",null,()=>i.activateRefiner(n)),"refinerActivate"),refinerRollback:o(n=>t("refiner/rollback",null,()=>i.rollbackRefiner(n)),"refinerRollback"),subscribe:i.subscribeEvents&&i.eventNotification?n=>i.subscribeEvents(s=>n(i.eventNotification(s))):void 0}}o(ar,"createAgentRuntimeService");var q=e.string().regex(/^[a-f0-9]{64}$/),Qe=e.object({harnessReleaseHash:q,instructionsHash:q,skillHashes:e.record(e.string(),q),agentAssetHashes:e.record(e.string(),q),toolCatalogHash:q,memoryRevision:e.number().int().nonnegative().nullable()}).strict(),Xe=e.object({protocolVersion:e.string().trim().min(1),threadId:e.string().trim().min(1),turnId:e.string().trim().min(1),harnessReleaseHash:q,toolCatalogHash:q,context:e.record(e.string(),e.unknown()),pendingInteraction:e.record(e.string(),e.unknown()).nullable(),usage:e.record(e.string(),e.unknown())}).strict();function pr(i){return R(Qe.parse(i))}o(pr,"effectiveSurfaceHash");function mr(i){return R(Xe.parse(i))}o(mr,"checkpointHash");function hr(i){return[i.system,...i.harnessInstructions,...i.skillInstructions,...i.hostInstructions??[]].map(t=>t.trim()).filter(Boolean).join(`
|
|
4
4
|
|
|
5
|
-
`)}o(
|
|
5
|
+
`)}o(hr,"materializeAgentPrompt");function vr(i){let t=new Map;for(let l of i){let u=l.name.trim();if(!u)throw new Error("Agent tool names cannot be empty.");if(t.has(u))throw new Error(`Duplicate agent tool: ${u}.`);if(!l.unavailableReason&&!l.execute)throw new Error(`Agent tool ${u} is declared as available without an executor.`);t.set(u,{...l,name:u})}let r=[...t.values()].sort((l,u)=>l.name.localeCompare(u.name)),n=r.filter(l=>!l.unavailableReason).map(l=>({name:l.name,description:l.description,inputSchema:e.toJSONSchema(l.inputSchema,{target:"draft-7",unrepresentable:"any"})})),s=r.map(l=>({name:l.name,displayLabel:l.displayLabel??l.name,placement:l.placement,available:!l.unavailableReason,unavailableReason:l.unavailableReason??null})),c=R({modelTools:n,capabilities:s});return{byName:t,tools:r,modelTools:n,capabilities:s,hash:c}}o(vr,"createAgentToolCatalog");async function xr(i,t){let r=i.byName.get(t.name);if(!r)throw new Error(`Unknown agent tool: ${t.name}.`);if(r.unavailableReason)throw new Error(`Agent tool ${t.name} is unavailable: ${r.unavailableReason}`);if(!r.execute)throw new Error(`Agent tool ${t.name} has no executor.`);return r.execute(r.inputSchema.parse(t.arguments),t.context)}o(xr,"executeAgentTool");function Ir(i){let t=new Set,r=[...i].map(c=>{let l=c.name.trim();if(!l)throw new Error("Agent tool names cannot be empty.");if(t.has(l))throw new Error(`Duplicate agent tool: ${l}.`);if(t.add(l),!c.unavailableReason&&!c.executorAvailable)throw new Error(`Agent tool ${l} is declared as available without an executor.`);return{...c,name:l}}).sort((c,l)=>c.name.localeCompare(l.name)),n=r.filter(c=>!c.unavailableReason).map(c=>({name:c.name,description:c.description,inputSchema:c.inputSchema})),s=r.map(c=>({name:c.name,displayLabel:c.displayLabel??c.name,placement:c.placement,available:!c.unavailableReason,unavailableReason:c.unavailableReason??null}));return{byName:new Map(r.map(c=>[c.name,c])),tools:r,modelTools:n,capabilities:s,hash:R({modelTools:n,capabilities:s})}}o(Ir,"createAgentToolCatalogProjection");async function yr(i,t){let r=i.byName.get(t.name);if(!r)throw new Error(`Unknown agent tool: ${t.name}.`);if(r.unavailableReason)throw new Error(`Agent tool ${t.name} is unavailable: ${r.unavailableReason}`);if(!r.execute)throw new Error(`Agent tool ${t.name} has no executor.`);let n=r.validateArguments?r.validateArguments(t.arguments):t.arguments;return r.execute(n,t.context)}o(yr,"executeProjectedAgentTool");var je=class{static{o(this,"TaskSignals")}#e=new Map;notify(t){for(let r of[...this.#e.get(t)??[]])r()}subscribe(t,r){let n=this.#e.get(t);return n||this.#e.set(t,n=new Set),n.add(r),()=>{n.delete(r),n.size===0&&this.#e.delete(t)}}async wait(t){let r=o(()=>{},"wake"),n=0,s=o(()=>{n+=1,r()},"changed"),c=[...new Set(t.taskIds)].map(u=>this.subscribe(u,s)),l=setTimeout(s,Math.max(0,t.deadline-Date.now()));t.signal.addEventListener("abort",s);try{for(;;){t.signal.throwIfAborted();let u=n,m=await t.read();if(m!==null)return m;if(Date.now()>=t.deadline)return null;n===u&&await new Promise(h=>{r=h,(n!==u||t.signal.aborted)&&h()})}}finally{clearTimeout(l),t.signal.removeEventListener("abort",s);for(let u of c)u()}}},_e=class{static{o(this,"TaskSerialExecutor")}#e=new Map;async run(t,r){let s=(this.#e.get(t)??Promise.resolve()).then(r),c=s.then(()=>{},()=>{});this.#e.set(t,c);try{return await s}finally{this.#e.get(t)===c&&this.#e.delete(t)}}};var L=class extends Error{static{o(this,"AcpRpcError")}code;data;constructor(t,r,n){super(r),this.code=t,this.data=n,this.name="AcpRpcError"}};import{execFile as Ye}from"node:child_process";function k(i,t){if(i.pid){if(process.platform==="win32"){Ye("taskkill",["/PID",String(i.pid),"/T",...t==="SIGKILL"?["/F"]:[]],{windowsHide:!0},()=>{});return}try{process.kill(-i.pid,t)}catch(r){if(r.code!=="ESRCH")throw r}}}o(k,"signalNativeProcess");import{spawn as Ze}from"node:child_process";import{StringDecoder as et}from"node:string_decoder";var K=8*1024*1024,D={outcome:{outcome:"cancelled"}};function P(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}o(P,"object");var Se=class{static{o(this,"AcpClient")}options;child=null;pending=new Map;sessions=new Set;activePrompts=new Set;permissions=new Map;nextId=1;buffer="";decoder=new et("utf8");initialized=null;updateQueue=Promise.resolve();stopped=!1;constructor(t){this.options=t}initialize(){return this.initialized?this.initialized:(this.initialized=this.connect(),this.initialized)}async connect(){if(this.stopped)throw new Error("ACP client is closed; reconnect with a new client.");let t=Ze(this.options.command,this.options.args,{cwd:this.options.cwd,env:this.options.env??process.env,stdio:["pipe","pipe","pipe"],shell:!1,detached:process.platform!=="win32"});this.child=t,t.stdout.on("data",r=>this.consume(this.decoder.write(r))),t.stderr.resume(),t.stdin.on("error",r=>this.fail(r)),t.on("error",r=>this.fail(r)),t.on("exit",(r,n)=>this.fail(new Error(`ACP agent exited (${n??r??"unknown"}).`)));try{let r=await this.request("initialize",{protocolVersion:1,clientInfo:{name:"openpond",title:"OpenPond",version:"1"},clientCapabilities:{fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}});if(r.protocolVersion!==1)throw new Error(`Unsupported ACP protocol version: ${r.protocolVersion}`);return r}catch(r){throw await this.stop(),r}}async authenticate(t){let n=(await this.initialize()).authMethods?.find(s=>s.id===t);if(!n)throw new Error("The agent did not advertise this authentication method.");if(n.type==="terminal")throw new Error("Run the agent's terminal login, then reconnect.");await this.request("authenticate",{methodId:t})}async createSession(t,r=[]){await this.initialize();let n=await this.request("session/new",{cwd:t,mcpServers:r});if(typeof n.sessionId!="string"||!n.sessionId)throw new Error("Agent returned no native session identity.");return this.sessions.add(n.sessionId),n}async loadSession(t,r,n=[]){if(!(await this.initialize()).agentCapabilities?.loadSession)throw new Error("This agent does not support native session loading.");this.sessions.add(t);try{let c=await this.request("session/load",{sessionId:t,cwd:r,mcpServers:n});return await this.updateQueue,{...c,sessionId:t}}catch(c){throw this.sessions.delete(t),c}}async setModel(t,r){this.assertSession(t),await this.request("session/set_model",{sessionId:t,modelId:r})}async setMode(t,r){this.assertSession(t),await this.request("session/set_mode",{sessionId:t,modeId:r})}async setConfigOption(t,r,n){return this.assertSession(t),await this.request("session/set_config_option",{sessionId:t,configId:r,value:n})}async prompt(t,r,n){if(this.assertSession(t),n?.aborted)throw new Error("ACP prompt cancelled.");if(this.activePrompts.has(t))throw new Error("A prompt is already active for this native session.");this.activePrompts.add(t);let s,c=o(()=>{this.cancel(t),s=setTimeout(()=>{this.stop()},5e3),s.unref()},"abort");n?.addEventListener("abort",c,{once:!0});try{let l=await this.request("session/prompt",{sessionId:t,prompt:r},0);return await this.updateQueue,n?.aborted?{...l,stopReason:"cancelled"}:l}catch(l){if(n?.aborted)return{stopReason:"cancelled"};throw l}finally{s&&clearTimeout(s),n?.removeEventListener("abort",c),this.activePrompts.delete(t),this.cancelPermissions(t)}}cancel(t){this.cancelPermissions(t),this.sessions.has(t)&&this.child&&this.write({jsonrpc:"2.0",method:"session/cancel",params:{sessionId:t}})}async stop(){if(this.stopped)return;this.stopped=!0;let t=this.child;this.fail(new Error("ACP connection closed.")),!(!t||t.exitCode!==null||t.signalCode!==null)&&await new Promise(r=>{let n=setTimeout(()=>k(t,"SIGKILL"),2e3);n.unref(),t.once("exit",()=>{clearTimeout(n),r()}),k(t,"SIGTERM")})}assertSession(t){if(!this.sessions.has(t))throw new Error("Session does not belong to this ACP connection.")}request(t,r,n=this.options.requestTimeoutMs??3e4){let s=this.nextId++;return new Promise((c,l)=>{let u=n>0?setTimeout(()=>{this.pending.delete(s),l(new Error(`ACP request timed out: ${t}`))},n):void 0;u?.unref(),this.pending.set(s,{resolve:c,reject:l,timer:u});try{this.write({jsonrpc:"2.0",id:s,method:t,params:r})}catch(m){u&&clearTimeout(u),this.pending.delete(s),l(m)}})}write(t){if(!this.child||this.child.stdin.destroyed)throw new Error("ACP connection is not running.");let r=JSON.stringify(t);if(Buffer.byteLength(r)>K)throw new Error("ACP frame exceeds the size limit.");this.child.stdin.write(`${r}
|
|
6
6
|
`)}consume(t){this.buffer+=t;let r;for(;(r=this.buffer.indexOf(`
|
|
7
|
-
`))!==-1;){let
|
|
8
|
-
`))>=0;){let I=h.slice(0,v);if(h=h.slice(v+1),!!I.trim())try{if(Buffer.byteLength(I)>8*1024*1024)throw new Error("Oversized frame");this.receive(x(JSON.parse(I)))}catch{this.fail(new Error("Invalid Claude CLI protocol frame.")),this.stop();return}}Buffer.byteLength(h)>8*1024*1024&&(this.fail(new Error("Claude CLI frame exceeds limit.")),this.stop())}),
|
|
9
|
-
`)}control(t){let r=O();return new Promise((
|
|
7
|
+
`))!==-1;){let n=this.buffer.slice(0,r);if(this.buffer=this.buffer.slice(r+1),!!n.trim())try{if(Buffer.byteLength(n)>K)throw new Error("ACP frame exceeds the size limit.");this.receive(JSON.parse(n))}catch{this.fail(new Error("Invalid ACP protocol frame.")),this.stop();return}}Buffer.byteLength(this.buffer)>K&&(this.fail(new Error("ACP frame exceeds the size limit.")),this.stop())}receive(t){if(!P(t)||t.jsonrpc!=="2.0")throw new Error("Invalid JSON-RPC envelope.");if(typeof t.method=="string"){if("id"in t){this.handleRequest(t);return}if(t.method==="session/update"&&P(t.params)){let{sessionId:n,update:s}=t.params;if(typeof n!="string"||!this.sessions.has(n)||!P(s))return;this.updateQueue=this.updateQueue.then(async()=>{await this.options.onUpdate?.(n,s)}),this.updateQueue.catch(c=>{this.fail(c),this.stop()})}return}if(typeof t.id!="number")return;let r=this.pending.get(t.id);r&&(this.pending.delete(t.id),r.timer&&clearTimeout(r.timer),P(t.error)?r.reject(new L(Number(t.error.code),String(t.error.message),t.error.data)):r.resolve(t.result))}async handleRequest(t){let r=t.id;if(!(typeof r!="number"&&typeof r!="string"))try{if(t.method!=="session/request_permission"){this.write({jsonrpc:"2.0",id:r,error:{code:-32601,message:"Client method not supported."}});return}let n=t.params;if(!P(n)||typeof n.sessionId!="string"||!Array.isArray(n.options)||!P(n.toolCall))throw new Error("Invalid permission request.");if(this.assertSession(n.sessionId),!this.activePrompts.has(n.sessionId)){this.write({jsonrpc:"2.0",id:r,result:D});return}let s=new AbortController,c=this.permissions.get(n.sessionId)??new Set;c.add(s),this.permissions.set(n.sessionId,c);let l=D;try{if(this.options.onPermission&&(l=await Promise.race([this.options.onPermission(n,s.signal),new Promise(u=>s.signal.addEventListener("abort",()=>u(D),{once:!0}))])),s.signal.aborted&&(l=D),l.outcome.outcome==="selected"){let u=l.outcome.optionId;if(!n.options.some(m=>P(m)&&m.optionId===u))throw new Error("Permission option was not advertised by the agent.")}}finally{c.delete(s),c.size||this.permissions.delete(n.sessionId)}this.child&&this.write({jsonrpc:"2.0",id:r,result:l})}catch{this.child&&this.write({jsonrpc:"2.0",id:r,error:{code:-32602,message:"Invalid or expired client request."}})}}cancelPermissions(t){for(let r of this.permissions.get(t)??[])r.abort();this.permissions.delete(t)}fail(t){let r=this.child,n=!!r;this.child=null,r&&(k(r,"SIGTERM"),setTimeout(()=>k(r,"SIGKILL"),2e3).unref());for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(t);this.pending.clear();for(let s of this.sessions)this.cancelPermissions(s);this.sessions.clear(),n&&this.options.onExit?.(t)}};var _=o(i=>i&&typeof i=="object"&&!Array.isArray(i)?i:{},"record"),S=o(i=>typeof i=="number"&&Number.isFinite(i)&&i>=0?Math.floor(i):null,"count"),U=class{static{o(this,"ClaudeObservations")}emit;contextWindows;tools=new Map;models=new Set;latestUsage={};latestModel="unknown";compacting=!1;constructor(t,r=new Map){this.emit=t,this.contextWindows=r}tool(t){let r=String(t.toolCallId),s={...this.tools.get(r)??{},...t};this.tools.set(r,s),this.emit(s)}observe(t){if(!t.parent_tool_use_id){if(t.type==="stream_event"){let r=_(t.event),n=_(r.message);r.type==="message_start"&&this.assistant(n,!0),r.type==="message_delta"&&(this.latestUsage={...this.latestUsage,..._(r.usage)},this.context())}if(t.type==="assistant"){this.assistant(_(t.message),!1);let r=_(t.context_usage),n=S(r.total_tokens),s=S(r.raw_max_tokens);n!==null&&s&&typeof r.model=="string"&&(this.contextWindows.set(r.model,s),this.emit({sessionUpdate:"context_usage",model:r.model,usedTokens:n,maxContextTokens:s}))}if(t.type==="system"&&t.subtype==="status"&&t.status==="compacting"&&!this.compacting&&(this.compacting=!0,this.emit({sessionUpdate:"compaction_started"})),t.type==="system"&&t.subtype==="compact_boundary"){this.compacting=!1,this.latestUsage={};let r=_(t.compact_metadata);this.emit({sessionUpdate:"compaction_completed",reason:r.trigger,preTokens:r.pre_tokens})}}}assistant(t,r){typeof t.model=="string"&&!t.model.startsWith("<")&&(this.latestModel=t.model,this.models.add(t.model));let n=_(t.usage);r?this.latestUsage=n:this.latestUsage={...this.latestUsage,...n,output_tokens:Math.max(S(this.latestUsage.output_tokens)??0,S(n.output_tokens)??0)}}result(t,r){this.finishCompaction(),this.emit({sessionUpdate:"usage_update",usage:t.usage,model:this.models.size>1?"Claude Code (multiple models)":this.latestModel,status:r?"interrupted":t.is_error?"failed":"completed",scope:"main_loop_turn"});for(let[n,s]of Object.entries(_(t.modelUsage))){let c=S(_(s).contextWindow);c&&this.contextWindows.set(n,c)}this.context()}context(){let t=this.contextWindows.get(this.latestModel),r=S(this.latestUsage.input_tokens);if(t&&r!==null){let n=r+(S(this.latestUsage.cache_read_input_tokens)??0)+(S(this.latestUsage.cache_creation_input_tokens)??0)+(S(this.latestUsage.output_tokens)??0);this.emit({sessionUpdate:"context_usage",model:this.latestModel,usedTokens:n,maxContextTokens:t})}}finishCompaction(){this.compacting&&(this.compacting=!1,this.emit({sessionUpdate:"compaction_failed",error:"Claude ended before confirming compaction completed."}))}};import{spawn as tt}from"node:child_process";import{randomUUID as O}from"node:crypto";import{StringDecoder as Ee}from"node:string_decoder";var x=o(i=>i&&typeof i=="object"&&!Array.isArray(i)?i:{},"record"),Re=[{id:"manual",name:"Ask for permissions"},{id:"plan",name:"Plan"},{id:"bypassPermissions",name:"YOLO / Full access"}],Te=class{static{o(this,"ClaudeCliClient")}options;child=null;sessionId=null;pending=new Map;turn=null;messageId="";lastTextMessageId=null;permissions=new Set;updates=Promise.resolve();closed=!1;model="default";contextWindows=new Map;observations=new U(t=>this.emit(t),this.contextWindows);stderrTail="";constructor(t){this.options=t}async initialize(){return{protocolVersion:1,agentCapabilities:{loadSession:!0,mcpCapabilities:{http:!0},promptCapabilities:{image:!0,embeddedContext:!0}},authMethods:[],agentInfo:{name:"Claude Code CLI",version:"native"}}}async authenticate(t){throw new Error("Use Claude Code's native login, then reconnect.")}async createSession(t,r=[]){return this.start(O(),t,!1,r)}async loadSession(t,r,n=[]){return this.start(t,r,!0,n)}async start(t,r,n,s){if(this.child||this.closed)throw new Error("Claude connection already owns a session or is closed.");if(!/^[a-f0-9-]{36}$/i.test(t))throw new Error("Invalid native Claude session identity.");this.sessionId=t;let c=Object.fromEntries(s.map(b=>[String(b.name),{type:"http",url:b.url,headers:Object.fromEntries((Array.isArray(b.headers)?b.headers:[]).map(v=>{let I=x(v);return[String(I.name),String(I.value)]}))}])),l=["--print","--verbose","--input-format","stream-json","--output-format","stream-json","--include-partial-messages","--allow-dangerously-skip-permissions","--permission-prompt-tool","stdio","--append-system-prompt","When you create files for the user, link each deliverable using Markdown with its absolute local path so OpenPond can open it. For example: [Report](/absolute/path/report.pdf).",...(this.options.additionalDirectories??[]).flatMap(b=>["--add-dir",b]),...s.length?["--mcp-config",JSON.stringify({mcpServers:c})]:[],n?"--resume":"--session-id",t],u=tt(this.options.command,l,{cwd:r,env:this.options.env??process.env,stdio:["pipe","pipe","pipe"],shell:!1,detached:process.platform!=="win32"});this.child=u;let m=new Ee("utf8"),h="",y=new Ee("utf8");u.stderr.on("data",b=>{this.stderrTail=(this.stderrTail+y.write(b)).slice(-4096)}),u.stdout.on("data",b=>{h+=m.write(b);let v;for(;(v=h.indexOf(`
|
|
8
|
+
`))>=0;){let I=h.slice(0,v);if(h=h.slice(v+1),!!I.trim())try{if(Buffer.byteLength(I)>8*1024*1024)throw new Error("Oversized frame");this.receive(x(JSON.parse(I)))}catch{this.fail(new Error("Invalid Claude CLI protocol frame.")),this.stop();return}}Buffer.byteLength(h)>8*1024*1024&&(this.fail(new Error("Claude CLI frame exceeds limit.")),this.stop())}),u.on("error",b=>this.fail(b)),u.stdin.on("error",b=>this.fail(b)),u.on("exit",b=>{this.fail(new Error(`Claude CLI exited (${b??"signal"}).${this.stderrTail.trim()?` ${this.stderrTail.trim()}`:""}`)),k(u,"SIGTERM"),setTimeout(()=>k(u,"SIGKILL"),2e3).unref(),this.child=null});try{let b=await this.control({subtype:"initialize",hooks:null}),v=Array.isArray(b.models)?b.models.map(x).filter(f=>typeof f.value=="string"):[],I=v.find(f=>f.value==="default")?.description,g=typeof I=="string"?v.find(f=>f.value!=="default"&&typeof f.displayName=="string"&&(I===f.displayName||I.startsWith(`${f.displayName} \xB7`))):void 0;return{sessionId:t,models:{currentModelId:this.model,availableModels:v.map(f=>({modelId:String(f.value),name:f.value==="default"&&g?`${g.displayName} (default)`:String(f.displayName??f.value),...typeof f.description=="string"?{description:f.description}:{}}))},modes:{currentModeId:String(b.current_permission_mode??"manual"),availableModes:Re.map(f=>({...f}))}}}catch(b){throw await this.stop(),b}}async setModel(t,r){this.assertSession(t),await this.control({subtype:"set_model",model:r}),this.model=r}async setMode(t,r){if(this.assertSession(t),!Re.some(n=>n.id===r))throw new Error("Unsupported Claude permission mode.");await this.control({subtype:"set_permission_mode",mode:r})}async prompt(t,r,n){if(this.assertSession(t),this.turn)throw new Error("A prompt is already active for this native session.");if(n?.aborted)throw new Error("Claude turn cancelled.");this.observations=new U(u=>this.emit(u),this.contextWindows),this.stderrTail="",this.messageId=O(),this.lastTextMessageId=null;let s=new Promise((u,m)=>{this.turn={resolve:u,reject:m,signal:n,resultReceived:!1}}),c,l=o(()=>{for(let u of this.permissions)u.abort();this.control({subtype:"interrupt"}).catch(()=>{}),c=setTimeout(()=>{this.stop()},5e3),c.unref()},"abort");n?.addEventListener("abort",l,{once:!0});try{this.write({type:"user",session_id:t,parent_tool_use_id:null,message:{role:"user",content:r.map(m=>m.type==="image"?{type:"image",source:{type:"base64",media_type:m.mimeType,data:m.data}}:m)}});let u=await s;return await this.updates,n?.aborted?{stopReason:"cancelled"}:u}catch(u){if(await this.updates.catch(()=>{}),n?.aborted)return{stopReason:"cancelled"};throw u}finally{n?.removeEventListener("abort",l),c&&clearTimeout(c),this.turn=null;for(let u of this.permissions)u.abort();this.permissions.clear()}}assertSession(t){if(!this.child||this.sessionId!==t||this.closed)throw new Error("Session does not belong to this Claude connection.")}write(t){if(!this.child||this.child.stdin.destroyed)throw new Error("Claude connection is closed.");let r=JSON.stringify(t);if(Buffer.byteLength(r)>8*1024*1024)throw new Error("Claude input exceeds limit.");this.child.stdin.write(`${r}
|
|
9
|
+
`)}control(t){let r=O();return new Promise((n,s)=>{let c=setTimeout(()=>{this.pending.delete(r),s(new Error(`Claude control request timed out: ${t.subtype}`))},this.options.requestTimeoutMs??3e4);c.unref(),this.pending.set(r,{resolve:n,reject:s,timer:c});try{this.write({type:"control_request",request_id:r,request:t})}catch(l){clearTimeout(c),this.pending.delete(r),s(l)}})}emit(t){if(!this.turn||!this.sessionId)return;let r=this.sessionId;this.updates=this.updates.then(async()=>{await this.options.onUpdate?.(r,t)}),this.updates.catch(n=>{this.fail(n),this.stop()})}receive(t){if(typeof t.session_id=="string"&&t.session_id!==this.sessionId){this.fail(new Error("Claude changed native session identity.")),this.stop();return}if(this.turn&&!this.turn.resultReceived&&this.observations.observe(t),t.type==="control_response"){let r=x(t.response),n=String(r.request_id),s=this.pending.get(n);if(!s)return;clearTimeout(s.timer),this.pending.delete(n),r.subtype==="error"?s.reject(new Error(String(r.error??"Claude control failed."))):s.resolve(x(r.response))}else if(t.type==="control_request")this.permission(t);else if(t.type==="stream_event"){if(!this.turn||this.turn.resultReceived||t.parent_tool_use_id)return;let r=x(t.event),n=x(r.delta),s=x(r.content_block);if(r.type==="message_start"){let c=x(r.message).id;this.messageId=typeof c=="string"?c:O(),this.lastTextMessageId=null}if(r.type==="content_block_delta"&&(n.type==="text_delta"||n.type==="thinking_delta")){let c=n.type==="text_delta";c&&(this.lastTextMessageId=this.messageId),this.emit({sessionUpdate:c?"agent_message_chunk":"agent_thought_chunk",messageId:this.messageId,phase:c?"commentary":"reasoning",content:{type:"text",text:n.text??n.thinking??""}})}r.type==="content_block_start"&&s.type==="tool_use"&&(this.lastTextMessageId=null,this.observations.tool({sessionUpdate:"tool_call",toolCallId:s.id,title:s.name,kind:"other",status:"in_progress",rawInput:s.input}))}else if(t.type==="assistant"){if(!this.turn||this.turn.resultReceived)return;let r=x(t.message),n=r.content;!t.parent_tool_use_id&&typeof r.id=="string"&&Array.isArray(n)&&n.some(s=>x(s).type==="text")&&(this.lastTextMessageId=r.id),!t.parent_tool_use_id&&Array.isArray(n)&&n.some(s=>x(s).type==="tool_use")&&(this.lastTextMessageId=null);for(let s of Array.isArray(n)?n.map(x):[])s.type==="tool_use"&&this.observations.tool({sessionUpdate:"tool_call_update",toolCallId:s.id,title:s.name,status:"in_progress",rawInput:s.input})}else if(t.type==="user"){if(!this.turn||this.turn.resultReceived)return;let r=x(t.message).content;for(let n of Array.isArray(r)?r.map(x):[])n.type==="tool_result"&&this.observations.tool({sessionUpdate:"tool_call_update",toolCallId:n.tool_use_id,status:n.is_error?"failed":"completed",content:n.content})}else if(t.type==="result"){if(!this.turn||this.turn.resultReceived)return;if(this.turn.resultReceived=!0,t.session_id&&t.session_id!==this.sessionId){this.fail(new Error("Claude changed native session identity."));return}!t.is_error&&!this.turn.signal?.aborted&&typeof t.result=="string"&&t.result.trim()&&this.emit({sessionUpdate:"agent_message_final",messageId:this.lastTextMessageId??O(),content:{type:"text",text:t.result}}),this.observations.result(t,!!this.turn.signal?.aborted),t.is_error?this.turn?.reject(new Error(Array.isArray(t.errors)?t.errors.map(String).join("; "):"Claude turn failed.")):this.turn?.resolve({stopReason:"end_turn"})}}async permission(t){let r=x(t.request),n=String(t.request_id);if(r.subtype!=="can_use_tool"||!this.turn||!this.sessionId){this.write({type:"control_response",response:{subtype:"error",request_id:n,error:"Unsupported or inactive control request."}});return}let s=new AbortController;this.permissions.add(s);try{let c=x(r.input),l=r.tool_name==="AskUserQuestion"&&Array.isArray(c.questions)?c.questions:void 0,u=new Promise(y=>s.signal.addEventListener("abort",()=>y({outcome:{outcome:"cancelled"}}),{once:!0})),m=await Promise.race([u,this.options.onPermission?.({sessionId:this.sessionId,toolCall:{toolCallId:r.tool_use_id,title:r.title??r.tool_name,rawInput:r.input},questions:l,options:[{optionId:"allow",name:"Allow once",kind:"allow_once"},{optionId:"deny",name:"Deny",kind:"reject_once"}]},s.signal)]),h=!s.signal.aborted&&m?.outcome.outcome==="selected"&&m.outcome.optionId==="allow";this.child&&this.write({type:"control_response",response:{subtype:"success",request_id:n,response:h?{behavior:"allow",updatedInput:l?{...c,answers:m?.answers}:r.input}:{behavior:"deny",message:"Permission declined or turn cancelled."}}})}catch{this.child&&this.write({type:"control_response",response:{subtype:"success",request_id:n,response:{behavior:"deny",message:"Permission could not be resolved."}}})}finally{this.permissions.delete(s)}}fail(t){this.observations.finishCompaction();for(let r of this.pending.values())clearTimeout(r.timer),r.reject(t);this.pending.clear(),this.turn?.reject(t),this.turn=null;for(let r of this.permissions)r.abort();this.permissions.clear(),this.options.onExit?.(t)}async stop(){if(this.closed)return;this.closed=!0,this.fail(new Error("Claude connection closed."));let t=this.child;!t||t.exitCode!==null||t.signalCode!==null||(await new Promise(r=>{let n=setTimeout(()=>k(t,"SIGKILL"),2e3);n.unref(),t.once("exit",()=>{clearTimeout(n),r()}),k(t,"SIGTERM")}),this.child=null)}};export{ke as a,Ne as b,Le as c,F as d,R as e,st as f,ot as g,at as h,qe as i,Pe as j,pt as k,A as l,bt as m,Z as n,ee as o,W as p,J as q,gt as r,Ae as s,B as t,te as u,G as v,se as w,ce as x,pe as y,he as z,fe as A,be as B,ge as C,Ue as D,we as E,Oe as F,ve as G,xe as H,p as I,Nt as J,Ie as K,Lt as L,ye as M,Zt as N,ar as O,Qe as P,Xe as Q,pr as R,mr as S,hr as T,vr as U,xr as V,Ir as W,yr as X,je as Y,_e as Z,L as _,Se as $,Te as aa};
|