@namzu/cli 50.1.0 → 50.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/dist/bin.js +1 -1
- package/dist/chunks/{acp-PFKCDYRZ.js → acp-2T35QG5N.js} +76 -87
- package/dist/chunks/acp-2T35QG5N.js.map +6 -0
- package/dist/chunks/{activity-command-VZNRTS4Y.js → activity-command-I3AIOI7D.js} +12 -12
- package/dist/chunks/{add-ILOY57M3.js → add-UGB46RWA.js} +19 -19
- package/dist/chunks/{agent-7XMB6YDL.js → agent-2667K2DP.js} +37 -35
- package/dist/chunks/agent-session-5KMMWJTY.js +69 -0
- package/dist/chunks/{archive-YUJITQ3K.js → archive-3AAGSJMI.js} +10 -10
- package/dist/chunks/{bin-main-QQCDUNOU.js → bin-main-N76J3LXV.js} +7 -7
- package/dist/chunks/{binding-QXY72MYE.js → binding-YGRSM4NK.js} +3 -3
- package/dist/chunks/{browser-T5M3N46O.js → browser-55KWOLRE.js} +6 -6
- package/dist/chunks/{chat-H6P7555R.js → chat-2JCXYCK4.js} +15 -15
- package/dist/chunks/{chunk-SFGTJCGU.js → chunk-2ADHYVB2.js} +2 -2
- package/dist/chunks/{chunk-UBB7EIHC.js → chunk-2T3C6WAE.js} +3 -3
- package/dist/chunks/{chunk-IZHREIZK.js → chunk-2VKT4OPG.js} +192 -85
- package/dist/chunks/chunk-2VKT4OPG.js.map +6 -0
- package/dist/chunks/{chunk-SSPDO3JT.js → chunk-2WSCH27F.js} +9 -9
- package/dist/chunks/{chunk-GKPO6EGA.js → chunk-35KJUUIZ.js} +2 -2
- package/dist/chunks/{chunk-HYWVPQQD.js → chunk-3L7O76A5.js} +4 -4
- package/dist/chunks/{chunk-FXAHVRUE.js → chunk-4XONZ3IH.js} +3 -3
- package/dist/chunks/{chunk-GN424XZ3.js → chunk-5ISSWZYV.js} +7 -7
- package/dist/chunks/{chunk-GL6KSVMS.js → chunk-7DCFWJDK.js} +9 -9
- package/dist/chunks/{chunk-SECKALTU.js → chunk-7JPWIMTU.js} +2 -2
- package/dist/chunks/{chunk-CFCULKSN.js → chunk-7OYYEJXX.js} +2 -2
- package/dist/chunks/{chunk-AKXUNA4X.js → chunk-AXB6T7KH.js} +6 -6
- package/dist/chunks/{chunk-MAMV7MUG.js → chunk-B72UXUIV.js} +9 -9
- package/dist/chunks/{chunk-HUKEVKWH.js → chunk-BFK5ZLTI.js} +3 -3
- package/dist/chunks/{chunk-FM2QPMPK.js → chunk-BKAGWRB7.js} +2 -2
- package/dist/chunks/{chunk-NXRUXNJ5.js → chunk-CI2P6MWQ.js} +2 -2
- package/dist/chunks/{chunk-JQUAYX3B.js → chunk-CKQSYJLF.js} +5 -5
- package/dist/chunks/{chunk-K4PPNYXR.js → chunk-DBPV2NYH.js} +2 -2
- package/dist/chunks/{chunk-IQPD7KYD.js → chunk-ENQ34C3Q.js} +3 -3
- package/dist/chunks/{chunk-SVB7IHBE.js → chunk-FPW3QSQD.js} +3 -3
- package/dist/chunks/{chunk-QNIHTTLG.js → chunk-G3R4GLH5.js} +3 -3
- package/dist/chunks/{chunk-T4BQXXZS.js → chunk-GMCZYW6K.js} +5 -5
- package/dist/chunks/{chunk-GWXAAFPJ.js → chunk-GNBTKM54.js} +2 -2
- package/dist/chunks/{chunk-JGYCZO6C.js → chunk-H734PAIA.js} +2 -2
- package/dist/chunks/{chunk-HYUVSO4X.js → chunk-HHZYPDYM.js} +4 -4
- package/dist/chunks/{chunk-PCW42R33.js → chunk-HM3XROXV.js} +5 -5
- package/dist/chunks/{chunk-2BMVENUB.js → chunk-HOBBN5HG.js} +2 -2
- package/dist/chunks/{chunk-CPWGSBBN.js → chunk-I7DZMDL4.js} +3 -3
- package/dist/chunks/{chunk-RZ6PDAMQ.js → chunk-IDHX5QU5.js} +2 -2
- package/dist/chunks/{chunk-MIJGXF3Z.js → chunk-IO6AH6S6.js} +2 -2
- package/dist/chunks/{chunk-4IP74K5V.js → chunk-IWBRKHR3.js} +2 -2
- package/dist/chunks/{chunk-URBIMXZN.js → chunk-JNPUGWLC.js} +6 -6
- package/dist/chunks/{chunk-EPDDCCV5.js → chunk-JXIZ23M4.js} +2 -2
- package/dist/chunks/{chunk-IXDECEIX.js → chunk-JZVNLDXW.js} +4 -4
- package/dist/chunks/{chunk-6X3NKVRL.js → chunk-K6CL6T23.js} +30 -4
- package/dist/chunks/{chunk-6X3NKVRL.js.map → chunk-K6CL6T23.js.map} +1 -1
- package/dist/chunks/{chunk-FIIZZRMV.js → chunk-KCRRCSBK.js} +3 -3
- package/dist/chunks/{chunk-XC6UYANY.js → chunk-KONJIEUP.js} +2 -2
- package/dist/chunks/{chunk-SB3GBZ65.js → chunk-KRGFQLGY.js} +3 -3
- package/dist/chunks/{chunk-WKW65PAC.js → chunk-KUPDSMDC.js} +2 -2
- package/dist/chunks/{chunk-Y22AUU3X.js → chunk-L37OHUPQ.js} +4 -4
- package/dist/chunks/{chunk-WTMP5H7T.js → chunk-LJFJLXD5.js} +4 -4
- package/dist/chunks/{chunk-RGUF5E22.js → chunk-LYTJJ2LG.js} +4 -4
- package/dist/chunks/{chunk-7VXBUWVA.js → chunk-M3BND4IS.js} +2 -2
- package/dist/chunks/{chunk-NVZRRJJS.js → chunk-MT2KWIQD.js} +2 -2
- package/dist/chunks/{chunk-SAJGEVVD.js → chunk-MVCDUAE3.js} +3 -3
- package/dist/chunks/{chunk-S4Q4PC2L.js → chunk-MZI3ULZR.js} +21 -5
- package/dist/chunks/{chunk-S4Q4PC2L.js.map → chunk-MZI3ULZR.js.map} +1 -1
- package/dist/chunks/{chunk-HDOYZYBW.js → chunk-P2CH7AHO.js} +3 -3
- package/dist/chunks/{chunk-XXHZE4KV.js → chunk-PMUGOF5V.js} +2 -2
- package/dist/chunks/{chunk-D7W5LUXV.js → chunk-PP5FDOXX.js} +3 -3
- package/dist/chunks/{chunk-UXXV6VCO.js → chunk-QAQBDQOO.js} +3 -3
- package/dist/chunks/{chunk-QPREGR6U.js → chunk-QFECRPMQ.js} +4 -4
- package/dist/chunks/{chunk-57EJUGDT.js → chunk-QHNAT275.js} +3 -3
- package/dist/chunks/{chunk-56WREK7X.js → chunk-QKRGJPU6.js} +2 -2
- package/dist/chunks/{chunk-UARXWUZO.js → chunk-QUADPKLH.js} +4 -4
- package/dist/chunks/{chunk-HNVUVSOI.js → chunk-RC3A3XQL.js} +2 -2
- package/dist/chunks/{chunk-2FQ6QJIZ.js → chunk-RSMLOV7S.js} +12 -12
- package/dist/chunks/{chunk-T2DRSTJV.js → chunk-RVWRZVRT.js} +2 -2
- package/dist/chunks/{chunk-FGEJOOL4.js → chunk-S5HIHXZO.js} +3 -3
- package/dist/chunks/{chunk-E6BNHEYX.js → chunk-SDK374XH.js} +2 -2
- package/dist/chunks/{chunk-KKEWKJVL.js → chunk-SWEP7MWK.js} +3 -3
- package/dist/chunks/{chunk-5WSDPQ3D.js → chunk-TCOZSNNY.js} +4 -4
- package/dist/chunks/{chunk-CR23VYUE.js → chunk-TKXFM6UF.js} +15 -14
- package/dist/chunks/{chunk-CR23VYUE.js.map → chunk-TKXFM6UF.js.map} +1 -1
- package/dist/chunks/{chunk-BIDU2JUB.js → chunk-TPYEIOFB.js} +2 -2
- package/dist/chunks/{chunk-Z3DTGVZS.js → chunk-UDA4YOUW.js} +127 -42
- package/dist/chunks/chunk-UDA4YOUW.js.map +6 -0
- package/dist/chunks/{chunk-45PI33XV.js → chunk-UGECQ2K7.js} +3 -3
- package/dist/chunks/{chunk-P2E6HFIP.js → chunk-ULRP7FUP.js} +2 -2
- package/dist/chunks/{chunk-G5OCRPZF.js → chunk-UU6Z4RNI.js} +2 -2
- package/dist/chunks/{chunk-ZJKISI2K.js → chunk-V6W5ILRM.js} +13 -5
- package/dist/chunks/chunk-V6W5ILRM.js.map +6 -0
- package/dist/chunks/{chunk-ITNMS75R.js → chunk-VXZ4I76G.js} +2 -2
- package/dist/chunks/{chunk-P7NXR4OV.js → chunk-VZD5OAVF.js} +4 -4
- package/dist/chunks/{chunk-ZE6HLPD4.js → chunk-W4BOQPYP.js} +944 -327
- package/dist/chunks/chunk-W4BOQPYP.js.map +6 -0
- package/dist/chunks/{chunk-VQ7FOO7M.js → chunk-WBDMD7WY.js} +2 -2
- package/dist/chunks/{chunk-424T6RL4.js → chunk-WBWDM4FM.js} +2 -2
- package/dist/chunks/{chunk-IXNUPR24.js → chunk-WHZO5JAN.js} +33 -33
- package/dist/chunks/{chunk-C2PBNQYT.js → chunk-YEDLKZJU.js} +10 -10
- package/dist/chunks/{chunk-RSAB3MPL.js → chunk-ZVAXTBZ4.js} +11 -11
- package/dist/chunks/{cli-runtime-JXRGA4O7.js → cli-runtime-WBHLU5Z2.js} +11 -11
- package/dist/chunks/{commands-3K6WWRUN.js → commands-Q5YVFT5H.js} +5 -5
- package/dist/chunks/{crash-report-NTEADY4P.js → crash-report-7B6INW5Z.js} +6 -6
- package/dist/chunks/{dist-Z2QVC4OK.js → dist-55O7DGZC.js} +2 -2
- package/dist/chunks/{dist-WDRMCFAU.js → dist-64A6FTG4.js} +10 -2
- package/dist/chunks/{dist-G2QITXMW.js → dist-CX6YZPQP.js} +2 -2
- package/dist/chunks/{dist-5ZAKSBZS.js → dist-DM56OGFI.js} +2 -2
- package/dist/chunks/{dist-43NXQHZ2.js → dist-JFEBD4RQ.js} +2 -2
- package/dist/chunks/{dist-EHAGNOTG.js → dist-JTKWJRF3.js} +2 -2
- package/dist/chunks/{dist-VEUKVTZP.js → dist-JXBZJMCJ.js} +2 -2
- package/dist/chunks/{dist-CRT6EQAR.js → dist-XF4ALE5R.js} +2 -2
- package/dist/chunks/{doctor-UVX6YR2I.js → doctor-J74VP3YF.js} +16 -16
- package/dist/chunks/{drain-URR6CUUH.js → drain-43YQMN3N.js} +9 -9
- package/dist/chunks/{entry-WCWSORA2.js → entry-EBSTYPZD.js} +6 -6
- package/dist/chunks/{eval-Y6FUUDCX.js → eval-6FWPUHTJ.js} +2 -2
- package/dist/chunks/{exec-5BUTAYMJ.js → exec-3OL72UXM.js} +34 -34
- package/dist/chunks/{home-HDE3CFLB.js → home-S7VBBT2P.js} +3 -3
- package/dist/chunks/{host-TZ6GSDWP.js → host-F6WQBUBZ.js} +10 -10
- package/dist/chunks/{host-queries-Y7A4XJ64.js → host-queries-PXLHY5OD.js} +15 -15
- package/dist/chunks/{learn-GYBZNIT3.js → learn-NNNC4PEC.js} +11 -11
- package/dist/chunks/{learn-builtin-EJXTHMX6.js → learn-builtin-BDKIORNW.js} +14 -14
- package/dist/chunks/{lifecycle-5EM2QRFV.js → lifecycle-6UXAIU2W.js} +28 -28
- package/dist/chunks/{list-M34JU5AG.js → list-RAVXA62R.js} +11 -11
- package/dist/chunks/{live-XMBIOII4.js → live-R457RDVD.js} +15 -15
- package/dist/chunks/{login-NI3DFWOW.js → login-XFL5R3F3.js} +13 -13
- package/dist/chunks/{logs-OI6GZRRC.js → logs-FHXX2ZYY.js} +4 -4
- package/dist/chunks/{mcp-FK3OBBSJ.js → mcp-GJYWIZDK.js} +24 -21
- package/dist/chunks/{mcp-FK3OBBSJ.js.map → mcp-GJYWIZDK.js.map} +1 -1
- package/dist/chunks/{message-command-CIYB47HZ.js → message-command-HLV22I75.js} +41 -41
- package/dist/chunks/{open-XYGGZHXM.js → open-52RISMYT.js} +8 -8
- package/dist/chunks/{operator-tools-QSZS57PI.js → operator-tools-KRVBU5DK.js} +13 -13
- package/dist/chunks/{output-schema-BTNJ6DL5.js → output-schema-TN574F4W.js} +3 -3
- package/dist/chunks/{pal-EQAAJBWP.js → pal-F6UND6OQ.js} +16 -16
- package/dist/chunks/{peers-35H6CZOZ.js → peers-TJCZBKJN.js} +7 -7
- package/dist/chunks/{peers-KN4BGJHU.js → peers-VBFD7USO.js} +6 -6
- package/dist/chunks/{providers-I2GONE3C.js → providers-WZ5ZDUB3.js} +11 -11
- package/dist/chunks/{pty-GZ4R2DCS.js → pty-KWFUBODN.js} +3 -3
- package/dist/chunks/resume-FVNBMR6D.js +23 -0
- package/dist/chunks/{resume-command-TOAGIGZO.js → resume-command-RVILL4QU.js} +4 -4
- package/dist/chunks/{schedule-FU5WY3WV.js → schedule-3QGQRJB7.js} +8 -8
- package/dist/chunks/{service-3UYEV4JX.js → service-MI36D5ZK.js} +28 -28
- package/dist/chunks/{skills-4V2SBEY3.js → skills-W5AH33BU.js} +8 -8
- package/dist/chunks/{start-check-RBYWVZT4.js → start-check-567HOC4A.js} +2 -2
- package/dist/chunks/{startup-failure-SST73T7Q.js → startup-failure-AXFS5D3F.js} +2 -2
- package/dist/chunks/{state-N46ZI3LZ.js → state-NYIQ2RRT.js} +2 -2
- package/dist/chunks/{store-RHAHG45U.js → store-BEOWOJIT.js} +4 -4
- package/dist/chunks/{store-R662Y2YQ.js → store-JUC4TU6P.js} +14 -10
- package/dist/chunks/{store-KA6NETSP.js → store-LNGCY3CJ.js} +3 -3
- package/dist/chunks/{store-M56FSIZT.js → store-LWOLZU4Z.js} +6 -6
- package/dist/chunks/{tui-TJNH67YO.js → tui-W7I4CLSF.js} +1006 -350
- package/dist/chunks/tui-W7I4CLSF.js.map +6 -0
- package/dist/chunks/{upgrade-YNYPRYFI.js → upgrade-APJTDSEG.js} +7 -7
- package/dist/chunks/{workspaces-OITS2AZJ.js → workspaces-F6RNJXKR.js} +16 -16
- package/dist/chunks/{worktree-DJW4XCBG.js → worktree-LE5FPYCK.js} +12 -12
- package/dist/commands/acp-harness.d.ts.map +1 -1
- package/dist/commands/acp-provider-retry.d.ts.map +1 -1
- package/dist/commands/acp.d.ts.map +1 -1
- package/dist/commands/desktop-host.d.ts.map +1 -1
- package/dist/commands/desktop-model-catalogue.d.ts +4 -0
- package/dist/commands/desktop-model-catalogue.d.ts.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/schema.d.ts +10 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/settings-descriptors.d.ts.map +1 -1
- package/dist/index.js +19 -19
- package/dist/integrations/mcp/servers.d.ts +25 -0
- package/dist/integrations/mcp/servers.d.ts.map +1 -1
- package/dist/integrations/sessions/conversation-facts.d.ts +76 -0
- package/dist/integrations/sessions/conversation-facts.d.ts.map +1 -0
- package/dist/integrations/sessions/store.d.ts +22 -18
- package/dist/integrations/sessions/store.d.ts.map +1 -1
- package/dist/rounds/types.d.ts +1 -1
- package/dist/rounds/types.d.ts.map +1 -1
- package/dist/schedule/daemon/sessions.d.ts +3 -3
- package/dist/schedule/daemon/sessions.d.ts.map +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/Composer.d.ts +7 -1
- package/dist/tui/Composer.d.ts.map +1 -1
- package/dist/tui/ReadSearchGroup.d.ts.map +1 -1
- package/dist/tui/Transcript.d.ts +1 -1
- package/dist/tui/Transcript.d.ts.map +1 -1
- package/dist/tui/agent.d.ts +7 -1
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/attachment-rows.d.ts +39 -0
- package/dist/tui/attachment-rows.d.ts.map +1 -0
- package/dist/tui/composer-undo.d.ts +3 -0
- package/dist/tui/composer-undo.d.ts.map +1 -1
- package/dist/tui/diff-view.d.ts +1 -0
- package/dist/tui/diff-view.d.ts.map +1 -1
- package/dist/tui/fullscreen/FullscreenTranscript.d.ts +3 -1
- package/dist/tui/fullscreen/FullscreenTranscript.d.ts.map +1 -1
- package/dist/tui/fullscreen/layout.d.ts +23 -4
- package/dist/tui/fullscreen/layout.d.ts.map +1 -1
- package/dist/tui/fullscreen/rows.d.ts +2 -0
- package/dist/tui/fullscreen/rows.d.ts.map +1 -1
- package/dist/tui/fullscreen/viewport.d.ts +27 -0
- package/dist/tui/fullscreen/viewport.d.ts.map +1 -1
- package/dist/tui/group-rows.d.ts +10 -0
- package/dist/tui/group-rows.d.ts.map +1 -1
- package/dist/tui/live-window.d.ts.map +1 -1
- package/dist/tui/outcome-line.d.ts +27 -0
- package/dist/tui/outcome-line.d.ts.map +1 -1
- package/dist/tui/paste-chips.d.ts +55 -6
- package/dist/tui/paste-chips.d.ts.map +1 -1
- package/dist/tui/read-search-group.d.ts +34 -1
- package/dist/tui/read-search-group.d.ts.map +1 -1
- package/dist/tui/restored-rows.d.ts +16 -1
- package/dist/tui/restored-rows.d.ts.map +1 -1
- package/dist/tui/shell-cell.d.ts +4 -0
- package/dist/tui/shell-cell.d.ts.map +1 -1
- package/dist/tui/terminal-hyperlinks.d.ts +8 -0
- package/dist/tui/terminal-hyperlinks.d.ts.map +1 -1
- package/dist/tui/tidy-tool-output.d.ts.map +1 -1
- package/dist/tui/tool-end-rows.d.ts.map +1 -1
- package/dist/tui/transcript-scroll.d.ts +12 -2
- package/dist/tui/transcript-scroll.d.ts.map +1 -1
- package/dist/tui/truncation.d.ts +9 -0
- package/dist/tui/truncation.d.ts.map +1 -1
- package/dist/tui/types.d.ts +3 -0
- package/dist/tui/types.d.ts.map +1 -1
- package/dist/tui/useReadSearchGroup.d.ts +13 -6
- package/dist/tui/useReadSearchGroup.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunks/acp-PFKCDYRZ.js.map +0 -6
- package/dist/chunks/agent-session-EJPBND2I.js +0 -69
- package/dist/chunks/chunk-IZHREIZK.js.map +0 -6
- package/dist/chunks/chunk-Z3DTGVZS.js.map +0 -6
- package/dist/chunks/chunk-ZE6HLPD4.js.map +0 -6
- package/dist/chunks/chunk-ZJKISI2K.js.map +0 -6
- package/dist/chunks/resume-4KW4GUYR.js +0 -23
- package/dist/chunks/tui-TJNH67YO.js.map +0 -6
- /package/dist/chunks/{activity-command-VZNRTS4Y.js.map → activity-command-I3AIOI7D.js.map} +0 -0
- /package/dist/chunks/{add-ILOY57M3.js.map → add-UGB46RWA.js.map} +0 -0
- /package/dist/chunks/{agent-7XMB6YDL.js.map → agent-2667K2DP.js.map} +0 -0
- /package/dist/chunks/{agent-session-EJPBND2I.js.map → agent-session-5KMMWJTY.js.map} +0 -0
- /package/dist/chunks/{archive-YUJITQ3K.js.map → archive-3AAGSJMI.js.map} +0 -0
- /package/dist/chunks/{bin-main-QQCDUNOU.js.map → bin-main-N76J3LXV.js.map} +0 -0
- /package/dist/chunks/{binding-QXY72MYE.js.map → binding-YGRSM4NK.js.map} +0 -0
- /package/dist/chunks/{browser-T5M3N46O.js.map → browser-55KWOLRE.js.map} +0 -0
- /package/dist/chunks/{chat-H6P7555R.js.map → chat-2JCXYCK4.js.map} +0 -0
- /package/dist/chunks/{chunk-SFGTJCGU.js.map → chunk-2ADHYVB2.js.map} +0 -0
- /package/dist/chunks/{chunk-UBB7EIHC.js.map → chunk-2T3C6WAE.js.map} +0 -0
- /package/dist/chunks/{chunk-SSPDO3JT.js.map → chunk-2WSCH27F.js.map} +0 -0
- /package/dist/chunks/{chunk-GKPO6EGA.js.map → chunk-35KJUUIZ.js.map} +0 -0
- /package/dist/chunks/{chunk-HYWVPQQD.js.map → chunk-3L7O76A5.js.map} +0 -0
- /package/dist/chunks/{chunk-FXAHVRUE.js.map → chunk-4XONZ3IH.js.map} +0 -0
- /package/dist/chunks/{chunk-GN424XZ3.js.map → chunk-5ISSWZYV.js.map} +0 -0
- /package/dist/chunks/{chunk-GL6KSVMS.js.map → chunk-7DCFWJDK.js.map} +0 -0
- /package/dist/chunks/{chunk-SECKALTU.js.map → chunk-7JPWIMTU.js.map} +0 -0
- /package/dist/chunks/{chunk-CFCULKSN.js.map → chunk-7OYYEJXX.js.map} +0 -0
- /package/dist/chunks/{chunk-AKXUNA4X.js.map → chunk-AXB6T7KH.js.map} +0 -0
- /package/dist/chunks/{chunk-MAMV7MUG.js.map → chunk-B72UXUIV.js.map} +0 -0
- /package/dist/chunks/{chunk-HUKEVKWH.js.map → chunk-BFK5ZLTI.js.map} +0 -0
- /package/dist/chunks/{chunk-FM2QPMPK.js.map → chunk-BKAGWRB7.js.map} +0 -0
- /package/dist/chunks/{chunk-NXRUXNJ5.js.map → chunk-CI2P6MWQ.js.map} +0 -0
- /package/dist/chunks/{chunk-JQUAYX3B.js.map → chunk-CKQSYJLF.js.map} +0 -0
- /package/dist/chunks/{chunk-K4PPNYXR.js.map → chunk-DBPV2NYH.js.map} +0 -0
- /package/dist/chunks/{chunk-IQPD7KYD.js.map → chunk-ENQ34C3Q.js.map} +0 -0
- /package/dist/chunks/{chunk-SVB7IHBE.js.map → chunk-FPW3QSQD.js.map} +0 -0
- /package/dist/chunks/{chunk-QNIHTTLG.js.map → chunk-G3R4GLH5.js.map} +0 -0
- /package/dist/chunks/{chunk-T4BQXXZS.js.map → chunk-GMCZYW6K.js.map} +0 -0
- /package/dist/chunks/{chunk-GWXAAFPJ.js.map → chunk-GNBTKM54.js.map} +0 -0
- /package/dist/chunks/{chunk-JGYCZO6C.js.map → chunk-H734PAIA.js.map} +0 -0
- /package/dist/chunks/{chunk-HYUVSO4X.js.map → chunk-HHZYPDYM.js.map} +0 -0
- /package/dist/chunks/{chunk-PCW42R33.js.map → chunk-HM3XROXV.js.map} +0 -0
- /package/dist/chunks/{chunk-2BMVENUB.js.map → chunk-HOBBN5HG.js.map} +0 -0
- /package/dist/chunks/{chunk-CPWGSBBN.js.map → chunk-I7DZMDL4.js.map} +0 -0
- /package/dist/chunks/{chunk-RZ6PDAMQ.js.map → chunk-IDHX5QU5.js.map} +0 -0
- /package/dist/chunks/{chunk-MIJGXF3Z.js.map → chunk-IO6AH6S6.js.map} +0 -0
- /package/dist/chunks/{chunk-4IP74K5V.js.map → chunk-IWBRKHR3.js.map} +0 -0
- /package/dist/chunks/{chunk-URBIMXZN.js.map → chunk-JNPUGWLC.js.map} +0 -0
- /package/dist/chunks/{chunk-EPDDCCV5.js.map → chunk-JXIZ23M4.js.map} +0 -0
- /package/dist/chunks/{chunk-IXDECEIX.js.map → chunk-JZVNLDXW.js.map} +0 -0
- /package/dist/chunks/{chunk-FIIZZRMV.js.map → chunk-KCRRCSBK.js.map} +0 -0
- /package/dist/chunks/{chunk-XC6UYANY.js.map → chunk-KONJIEUP.js.map} +0 -0
- /package/dist/chunks/{chunk-SB3GBZ65.js.map → chunk-KRGFQLGY.js.map} +0 -0
- /package/dist/chunks/{chunk-WKW65PAC.js.map → chunk-KUPDSMDC.js.map} +0 -0
- /package/dist/chunks/{chunk-Y22AUU3X.js.map → chunk-L37OHUPQ.js.map} +0 -0
- /package/dist/chunks/{chunk-WTMP5H7T.js.map → chunk-LJFJLXD5.js.map} +0 -0
- /package/dist/chunks/{chunk-RGUF5E22.js.map → chunk-LYTJJ2LG.js.map} +0 -0
- /package/dist/chunks/{chunk-7VXBUWVA.js.map → chunk-M3BND4IS.js.map} +0 -0
- /package/dist/chunks/{chunk-NVZRRJJS.js.map → chunk-MT2KWIQD.js.map} +0 -0
- /package/dist/chunks/{chunk-SAJGEVVD.js.map → chunk-MVCDUAE3.js.map} +0 -0
- /package/dist/chunks/{chunk-HDOYZYBW.js.map → chunk-P2CH7AHO.js.map} +0 -0
- /package/dist/chunks/{chunk-XXHZE4KV.js.map → chunk-PMUGOF5V.js.map} +0 -0
- /package/dist/chunks/{chunk-D7W5LUXV.js.map → chunk-PP5FDOXX.js.map} +0 -0
- /package/dist/chunks/{chunk-UXXV6VCO.js.map → chunk-QAQBDQOO.js.map} +0 -0
- /package/dist/chunks/{chunk-QPREGR6U.js.map → chunk-QFECRPMQ.js.map} +0 -0
- /package/dist/chunks/{chunk-57EJUGDT.js.map → chunk-QHNAT275.js.map} +0 -0
- /package/dist/chunks/{chunk-56WREK7X.js.map → chunk-QKRGJPU6.js.map} +0 -0
- /package/dist/chunks/{chunk-UARXWUZO.js.map → chunk-QUADPKLH.js.map} +0 -0
- /package/dist/chunks/{chunk-HNVUVSOI.js.map → chunk-RC3A3XQL.js.map} +0 -0
- /package/dist/chunks/{chunk-2FQ6QJIZ.js.map → chunk-RSMLOV7S.js.map} +0 -0
- /package/dist/chunks/{chunk-T2DRSTJV.js.map → chunk-RVWRZVRT.js.map} +0 -0
- /package/dist/chunks/{chunk-FGEJOOL4.js.map → chunk-S5HIHXZO.js.map} +0 -0
- /package/dist/chunks/{chunk-E6BNHEYX.js.map → chunk-SDK374XH.js.map} +0 -0
- /package/dist/chunks/{chunk-KKEWKJVL.js.map → chunk-SWEP7MWK.js.map} +0 -0
- /package/dist/chunks/{chunk-5WSDPQ3D.js.map → chunk-TCOZSNNY.js.map} +0 -0
- /package/dist/chunks/{chunk-BIDU2JUB.js.map → chunk-TPYEIOFB.js.map} +0 -0
- /package/dist/chunks/{chunk-45PI33XV.js.map → chunk-UGECQ2K7.js.map} +0 -0
- /package/dist/chunks/{chunk-P2E6HFIP.js.map → chunk-ULRP7FUP.js.map} +0 -0
- /package/dist/chunks/{chunk-G5OCRPZF.js.map → chunk-UU6Z4RNI.js.map} +0 -0
- /package/dist/chunks/{chunk-ITNMS75R.js.map → chunk-VXZ4I76G.js.map} +0 -0
- /package/dist/chunks/{chunk-P7NXR4OV.js.map → chunk-VZD5OAVF.js.map} +0 -0
- /package/dist/chunks/{chunk-VQ7FOO7M.js.map → chunk-WBDMD7WY.js.map} +0 -0
- /package/dist/chunks/{chunk-424T6RL4.js.map → chunk-WBWDM4FM.js.map} +0 -0
- /package/dist/chunks/{chunk-IXNUPR24.js.map → chunk-WHZO5JAN.js.map} +0 -0
- /package/dist/chunks/{chunk-C2PBNQYT.js.map → chunk-YEDLKZJU.js.map} +0 -0
- /package/dist/chunks/{chunk-RSAB3MPL.js.map → chunk-ZVAXTBZ4.js.map} +0 -0
- /package/dist/chunks/{cli-runtime-JXRGA4O7.js.map → cli-runtime-WBHLU5Z2.js.map} +0 -0
- /package/dist/chunks/{commands-3K6WWRUN.js.map → commands-Q5YVFT5H.js.map} +0 -0
- /package/dist/chunks/{crash-report-NTEADY4P.js.map → crash-report-7B6INW5Z.js.map} +0 -0
- /package/dist/chunks/{dist-Z2QVC4OK.js.map → dist-55O7DGZC.js.map} +0 -0
- /package/dist/chunks/{dist-WDRMCFAU.js.map → dist-64A6FTG4.js.map} +0 -0
- /package/dist/chunks/{dist-G2QITXMW.js.map → dist-CX6YZPQP.js.map} +0 -0
- /package/dist/chunks/{dist-5ZAKSBZS.js.map → dist-DM56OGFI.js.map} +0 -0
- /package/dist/chunks/{dist-43NXQHZ2.js.map → dist-JFEBD4RQ.js.map} +0 -0
- /package/dist/chunks/{dist-EHAGNOTG.js.map → dist-JTKWJRF3.js.map} +0 -0
- /package/dist/chunks/{dist-VEUKVTZP.js.map → dist-JXBZJMCJ.js.map} +0 -0
- /package/dist/chunks/{dist-CRT6EQAR.js.map → dist-XF4ALE5R.js.map} +0 -0
- /package/dist/chunks/{doctor-UVX6YR2I.js.map → doctor-J74VP3YF.js.map} +0 -0
- /package/dist/chunks/{drain-URR6CUUH.js.map → drain-43YQMN3N.js.map} +0 -0
- /package/dist/chunks/{entry-WCWSORA2.js.map → entry-EBSTYPZD.js.map} +0 -0
- /package/dist/chunks/{eval-Y6FUUDCX.js.map → eval-6FWPUHTJ.js.map} +0 -0
- /package/dist/chunks/{exec-5BUTAYMJ.js.map → exec-3OL72UXM.js.map} +0 -0
- /package/dist/chunks/{home-HDE3CFLB.js.map → home-S7VBBT2P.js.map} +0 -0
- /package/dist/chunks/{host-TZ6GSDWP.js.map → host-F6WQBUBZ.js.map} +0 -0
- /package/dist/chunks/{host-queries-Y7A4XJ64.js.map → host-queries-PXLHY5OD.js.map} +0 -0
- /package/dist/chunks/{learn-GYBZNIT3.js.map → learn-NNNC4PEC.js.map} +0 -0
- /package/dist/chunks/{learn-builtin-EJXTHMX6.js.map → learn-builtin-BDKIORNW.js.map} +0 -0
- /package/dist/chunks/{lifecycle-5EM2QRFV.js.map → lifecycle-6UXAIU2W.js.map} +0 -0
- /package/dist/chunks/{list-M34JU5AG.js.map → list-RAVXA62R.js.map} +0 -0
- /package/dist/chunks/{live-XMBIOII4.js.map → live-R457RDVD.js.map} +0 -0
- /package/dist/chunks/{login-NI3DFWOW.js.map → login-XFL5R3F3.js.map} +0 -0
- /package/dist/chunks/{logs-OI6GZRRC.js.map → logs-FHXX2ZYY.js.map} +0 -0
- /package/dist/chunks/{message-command-CIYB47HZ.js.map → message-command-HLV22I75.js.map} +0 -0
- /package/dist/chunks/{open-XYGGZHXM.js.map → open-52RISMYT.js.map} +0 -0
- /package/dist/chunks/{operator-tools-QSZS57PI.js.map → operator-tools-KRVBU5DK.js.map} +0 -0
- /package/dist/chunks/{output-schema-BTNJ6DL5.js.map → output-schema-TN574F4W.js.map} +0 -0
- /package/dist/chunks/{pal-EQAAJBWP.js.map → pal-F6UND6OQ.js.map} +0 -0
- /package/dist/chunks/{peers-35H6CZOZ.js.map → peers-TJCZBKJN.js.map} +0 -0
- /package/dist/chunks/{peers-KN4BGJHU.js.map → peers-VBFD7USO.js.map} +0 -0
- /package/dist/chunks/{providers-I2GONE3C.js.map → providers-WZ5ZDUB3.js.map} +0 -0
- /package/dist/chunks/{pty-GZ4R2DCS.js.map → pty-KWFUBODN.js.map} +0 -0
- /package/dist/chunks/{resume-4KW4GUYR.js.map → resume-FVNBMR6D.js.map} +0 -0
- /package/dist/chunks/{resume-command-TOAGIGZO.js.map → resume-command-RVILL4QU.js.map} +0 -0
- /package/dist/chunks/{schedule-FU5WY3WV.js.map → schedule-3QGQRJB7.js.map} +0 -0
- /package/dist/chunks/{service-3UYEV4JX.js.map → service-MI36D5ZK.js.map} +0 -0
- /package/dist/chunks/{skills-4V2SBEY3.js.map → skills-W5AH33BU.js.map} +0 -0
- /package/dist/chunks/{start-check-RBYWVZT4.js.map → start-check-567HOC4A.js.map} +0 -0
- /package/dist/chunks/{startup-failure-SST73T7Q.js.map → startup-failure-AXFS5D3F.js.map} +0 -0
- /package/dist/chunks/{state-N46ZI3LZ.js.map → state-NYIQ2RRT.js.map} +0 -0
- /package/dist/chunks/{store-KA6NETSP.js.map → store-BEOWOJIT.js.map} +0 -0
- /package/dist/chunks/{store-M56FSIZT.js.map → store-JUC4TU6P.js.map} +0 -0
- /package/dist/chunks/{store-R662Y2YQ.js.map → store-LNGCY3CJ.js.map} +0 -0
- /package/dist/chunks/{store-RHAHG45U.js.map → store-LWOLZU4Z.js.map} +0 -0
- /package/dist/chunks/{upgrade-YNYPRYFI.js.map → upgrade-APJTDSEG.js.map} +0 -0
- /package/dist/chunks/{workspaces-OITS2AZJ.js.map → workspaces-F6RNJXKR.js.map} +0 -0
- /package/dist/chunks/{worktree-DJW4XCBG.js.map → worktree-LE5FPYCK.js.map} +0 -0
|
@@ -325,7 +325,7 @@ var require_brace_expansion = __commonJS({
|
|
|
325
325
|
});
|
|
326
326
|
|
|
327
327
|
// ../sdk/dist/version.js
|
|
328
|
-
var VERSION = "62.
|
|
328
|
+
var VERSION = "62.10.0";
|
|
329
329
|
|
|
330
330
|
// ../sdk/dist/runtime/harness-session/index.js
|
|
331
331
|
import { posix, win32 } from "node:path";
|
|
@@ -28543,6 +28543,20 @@ var CompactionConfigSchema = external_exports.object({
|
|
|
28543
28543
|
* `triggerThreshold` summarises. The context is held around here.
|
|
28544
28544
|
*/
|
|
28545
28545
|
softTarget: external_exports.number().min(0).max(1).optional(),
|
|
28546
|
+
/**
|
|
28547
|
+
* `salience` only: how far below `softTarget`, as a fraction of the
|
|
28548
|
+
* window, a pass sheds. A pass still starts when the context reaches the
|
|
28549
|
+
* soft target, but it then keeps shedding until the context is
|
|
28550
|
+
* `softTargetHeadroom` of the window under it, so the next pass is needed
|
|
28551
|
+
* only after that headroom has been used instead of on the next turn.
|
|
28552
|
+
* Fewer passes, and the request is rewritten (a prompt cache's prefix
|
|
28553
|
+
* broken) once per headroom instead of once per turn; the cost is that
|
|
28554
|
+
* the context is held that much lower, so that much less history stays
|
|
28555
|
+
* whole. The messages shed are the same ones in the same order, only
|
|
28556
|
+
* earlier. Absent or `0`, the default, a pass sheds to the soft target
|
|
28557
|
+
* and no further, exactly as before.
|
|
28558
|
+
*/
|
|
28559
|
+
softTargetHeadroom: external_exports.number().min(0).max(1).optional(),
|
|
28546
28560
|
/**
|
|
28547
28561
|
* Optional model context-window size (tokens) the compaction trigger
|
|
28548
28562
|
* measures the CURRENT window against. NO default: when omitted the
|
|
@@ -28822,6 +28836,8 @@ var MCP_SUPPORTED_PROTOCOL_VERSIONS = [
|
|
|
28822
28836
|
...MCP_LEGACY_VERSIONS
|
|
28823
28837
|
];
|
|
28824
28838
|
var DEFAULT_MCP_REQUEST_TIMEOUT_MS = 3e4;
|
|
28839
|
+
var DEFAULT_MCP_TOTAL_TIMEOUT_FACTOR = 10;
|
|
28840
|
+
var MCP_TOOL_DEADLINE_SLACK_MS = 5e3;
|
|
28825
28841
|
var JSON_RPC_INVALID_PARAMS = -32602;
|
|
28826
28842
|
var JSON_RPC_METHOD_NOT_FOUND = -32601;
|
|
28827
28843
|
var RESOURCE_NOT_FOUND_CODES = [-32602, -32002];
|
|
@@ -30437,12 +30453,12 @@ function applyTemplate(record4) {
|
|
|
30437
30453
|
__name(applyTemplate, "applyTemplate");
|
|
30438
30454
|
var PALETTE = [31, 32, 33, 34, 35, 36, 91, 92];
|
|
30439
30455
|
function scopeColour(scope) {
|
|
30440
|
-
let
|
|
30456
|
+
let hash4 = 2166136261;
|
|
30441
30457
|
for (let i = 0; i < scope.length; i++) {
|
|
30442
|
-
|
|
30443
|
-
|
|
30458
|
+
hash4 ^= scope.charCodeAt(i);
|
|
30459
|
+
hash4 = Math.imul(hash4, 16777619);
|
|
30444
30460
|
}
|
|
30445
|
-
return PALETTE[Math.abs(
|
|
30461
|
+
return PALETTE[Math.abs(hash4) % PALETTE.length];
|
|
30446
30462
|
}
|
|
30447
30463
|
__name(scopeColour, "scopeColour");
|
|
30448
30464
|
|
|
@@ -41337,6 +41353,13 @@ var MessageReplacedRecordSchema = recordSchema("message_replaced", {
|
|
|
41337
41353
|
"history-repair"
|
|
41338
41354
|
])
|
|
41339
41355
|
});
|
|
41356
|
+
var MessageEditedRecordSchema = inTurn("message_edited", {
|
|
41357
|
+
ignorable: external_exports.literal(true),
|
|
41358
|
+
targetMessageId: messageId2,
|
|
41359
|
+
content: messageBody,
|
|
41360
|
+
spill: spill.optional(),
|
|
41361
|
+
reason: text4.min(1)
|
|
41362
|
+
});
|
|
41340
41363
|
var CheckpointWrittenRecordSchema = inTurn("checkpoint_written", {
|
|
41341
41364
|
checkpointId,
|
|
41342
41365
|
iteration: count4,
|
|
@@ -41462,6 +41485,7 @@ var RECORD_ONLY_SCHEMAS = {
|
|
|
41462
41485
|
session_updated: SessionUpdatedRecordSchema,
|
|
41463
41486
|
message: MessageRecordSchema,
|
|
41464
41487
|
message_replaced: MessageReplacedRecordSchema,
|
|
41488
|
+
message_edited: MessageEditedRecordSchema,
|
|
41465
41489
|
checkpoint_written: CheckpointWrittenRecordSchema,
|
|
41466
41490
|
checkpoint_pruned: CheckpointPrunedRecordSchema,
|
|
41467
41491
|
decision_requested: DecisionRequestedRecordSchema,
|
|
@@ -41863,6 +41887,9 @@ function childSessionLog(childSessionId) {
|
|
|
41863
41887
|
}
|
|
41864
41888
|
__name(childSessionLog, "childSessionLog");
|
|
41865
41889
|
|
|
41890
|
+
// ../sdk/dist/manager/session/turn-recorder.js
|
|
41891
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
41892
|
+
|
|
41866
41893
|
// ../sdk/dist/session/log-hash.js
|
|
41867
41894
|
import { createHash as createHash6 } from "node:crypto";
|
|
41868
41895
|
var NEWLINE = 10;
|
|
@@ -42164,7 +42191,11 @@ async function foldSessionLog(log, fold4) {
|
|
|
42164
42191
|
}
|
|
42165
42192
|
let moved = false;
|
|
42166
42193
|
try {
|
|
42167
|
-
const walk2 = log.read({
|
|
42194
|
+
const walk2 = log.read({
|
|
42195
|
+
mode: fold4.mode,
|
|
42196
|
+
...anchor2 ? { after: anchor2 } : {},
|
|
42197
|
+
...fold4.reverify && fold4.mode === "strict" ? { reverify: true } : {}
|
|
42198
|
+
});
|
|
42168
42199
|
let summary2;
|
|
42169
42200
|
for (; ; ) {
|
|
42170
42201
|
summary2 = await walk2.next();
|
|
@@ -42269,7 +42300,8 @@ var SessionMessageFold = class {
|
|
|
42269
42300
|
case "message":
|
|
42270
42301
|
this.#message(record4);
|
|
42271
42302
|
return;
|
|
42272
|
-
case "message_replaced":
|
|
42303
|
+
case "message_replaced":
|
|
42304
|
+
case "message_edited": {
|
|
42273
42305
|
const spill3 = record4.spill;
|
|
42274
42306
|
this.#replacements.set(record4.targetMessageId, {
|
|
42275
42307
|
message: record4.content,
|
|
@@ -42384,7 +42416,7 @@ var TurnRuleError = class extends Error {
|
|
|
42384
42416
|
}
|
|
42385
42417
|
name = "TurnRuleError";
|
|
42386
42418
|
};
|
|
42387
|
-
var SessionTurnState = class {
|
|
42419
|
+
var SessionTurnState = class _SessionTurnState {
|
|
42388
42420
|
static {
|
|
42389
42421
|
__name(this, "SessionTurnState");
|
|
42390
42422
|
}
|
|
@@ -42394,6 +42426,17 @@ var SessionTurnState = class {
|
|
|
42394
42426
|
get active() {
|
|
42395
42427
|
return this.#active;
|
|
42396
42428
|
}
|
|
42429
|
+
/**
|
|
42430
|
+
* An independent copy at the records applied so far. `apply` replaces the
|
|
42431
|
+
* active turn's object rather than editing it, so the copy may share it.
|
|
42432
|
+
*/
|
|
42433
|
+
clone() {
|
|
42434
|
+
const copy = new _SessionTurnState();
|
|
42435
|
+
copy.#active = this.#active;
|
|
42436
|
+
copy.#lastTurnId = this.#lastTurnId;
|
|
42437
|
+
copy.#started = this.#started;
|
|
42438
|
+
return copy;
|
|
42439
|
+
}
|
|
42397
42440
|
/** The last turn that started, active or not. */
|
|
42398
42441
|
get lastTurnId() {
|
|
42399
42442
|
return this.#lastTurnId;
|
|
@@ -42492,6 +42535,7 @@ var CLOSES_OR_DECIDES = /* @__PURE__ */ new Set([
|
|
|
42492
42535
|
"audit",
|
|
42493
42536
|
"log_repaired",
|
|
42494
42537
|
"message_replaced",
|
|
42538
|
+
"message_edited",
|
|
42495
42539
|
"session_updated"
|
|
42496
42540
|
]);
|
|
42497
42541
|
|
|
@@ -43169,6 +43213,188 @@ async function restoreSpilledRequestInputs(request, read) {
|
|
|
43169
43213
|
}
|
|
43170
43214
|
__name(restoreSpilledRequestInputs, "restoreSpilledRequestInputs");
|
|
43171
43215
|
|
|
43216
|
+
// ../sdk/dist/store/session-log/verified-prefix.js
|
|
43217
|
+
import * as crypto from "node:crypto";
|
|
43218
|
+
var DIGEST_BYTES = 32;
|
|
43219
|
+
var LEDGERS_KEPT = 16;
|
|
43220
|
+
var MAX_RECORDS = 1 << 21;
|
|
43221
|
+
var hexDigestOf = typeof crypto.hash === "function" ? (line) => crypto.hash("sha256", line, "hex") : (line) => crypto.createHash("sha256").update(line).digest("hex");
|
|
43222
|
+
function hexEqualsBytes(hex4, bytes, at) {
|
|
43223
|
+
if (hex4.length !== DIGEST_BYTES * 2)
|
|
43224
|
+
return false;
|
|
43225
|
+
for (let i = 0; i < DIGEST_BYTES; i++) {
|
|
43226
|
+
const high = hex4.charCodeAt(i * 2);
|
|
43227
|
+
const low = hex4.charCodeAt(i * 2 + 1);
|
|
43228
|
+
const value = (high <= 57 ? high - 48 : high - 87) << 4 | (low <= 57 ? low - 48 : low - 87);
|
|
43229
|
+
if (value !== bytes[at + i])
|
|
43230
|
+
return false;
|
|
43231
|
+
}
|
|
43232
|
+
return true;
|
|
43233
|
+
}
|
|
43234
|
+
__name(hexEqualsBytes, "hexEqualsBytes");
|
|
43235
|
+
var VerifiedPrefix = class {
|
|
43236
|
+
static {
|
|
43237
|
+
__name(this, "VerifiedPrefix");
|
|
43238
|
+
}
|
|
43239
|
+
#count = 0;
|
|
43240
|
+
#lengths = new Uint32Array(1024);
|
|
43241
|
+
#digests = Buffer.allocUnsafe(1024 * DIGEST_BYTES);
|
|
43242
|
+
#head = null;
|
|
43243
|
+
#gen = 0;
|
|
43244
|
+
#sessionId;
|
|
43245
|
+
#end = 0;
|
|
43246
|
+
#dead = false;
|
|
43247
|
+
#turns = new SessionTurnState();
|
|
43248
|
+
/** Records remembered. */
|
|
43249
|
+
get count() {
|
|
43250
|
+
return this.#count;
|
|
43251
|
+
}
|
|
43252
|
+
get head() {
|
|
43253
|
+
return this.#head;
|
|
43254
|
+
}
|
|
43255
|
+
get gen() {
|
|
43256
|
+
return this.#gen;
|
|
43257
|
+
}
|
|
43258
|
+
get sessionId() {
|
|
43259
|
+
return this.#sessionId;
|
|
43260
|
+
}
|
|
43261
|
+
/** Byte offset just after the last remembered record. */
|
|
43262
|
+
get end() {
|
|
43263
|
+
return this.#end;
|
|
43264
|
+
}
|
|
43265
|
+
/** The turn state at the head, as its own copy. */
|
|
43266
|
+
turns() {
|
|
43267
|
+
return this.#turns.clone();
|
|
43268
|
+
}
|
|
43269
|
+
/** Lengths and digests as they stand now; entries below `count` never change. */
|
|
43270
|
+
get lengths() {
|
|
43271
|
+
return this.#lengths;
|
|
43272
|
+
}
|
|
43273
|
+
get digests() {
|
|
43274
|
+
return this.#digests;
|
|
43275
|
+
}
|
|
43276
|
+
/** Whether the remembered record `seq` is exactly `pointer` (length and digest). */
|
|
43277
|
+
holds(pointer2) {
|
|
43278
|
+
const at = pointer2.seq - 1;
|
|
43279
|
+
if (at < 0 || at >= this.#count)
|
|
43280
|
+
return false;
|
|
43281
|
+
if (this.#lengths[at] !== pointer2.length)
|
|
43282
|
+
return false;
|
|
43283
|
+
return this.#digests.toString("hex", at * DIGEST_BYTES, (at + 1) * DIGEST_BYTES) === pointer2.sha256;
|
|
43284
|
+
}
|
|
43285
|
+
/**
|
|
43286
|
+
* Remember a record that was verified in full. Ignored unless it continues
|
|
43287
|
+
* what is held: the next seq, naming the head by its pointer.
|
|
43288
|
+
*/
|
|
43289
|
+
append(entry) {
|
|
43290
|
+
if (this.#dead)
|
|
43291
|
+
return;
|
|
43292
|
+
const { record: record4, pointer: pointer2 } = entry;
|
|
43293
|
+
if (pointer2.seq !== this.#count + 1 || pointer2.offset !== this.#end)
|
|
43294
|
+
return;
|
|
43295
|
+
const prev = record4.prev;
|
|
43296
|
+
if (this.#head === null ? prev !== null : !samePointer2(prev, this.#head))
|
|
43297
|
+
return;
|
|
43298
|
+
if (this.#sessionId !== void 0 && record4.sessionId !== this.#sessionId)
|
|
43299
|
+
return;
|
|
43300
|
+
if (this.#count >= MAX_RECORDS) {
|
|
43301
|
+
this.#dead = true;
|
|
43302
|
+
return;
|
|
43303
|
+
}
|
|
43304
|
+
if (this.#count === this.#lengths.length) {
|
|
43305
|
+
const lengths = new Uint32Array(this.#lengths.length * 2);
|
|
43306
|
+
lengths.set(this.#lengths);
|
|
43307
|
+
this.#lengths = lengths;
|
|
43308
|
+
const digests = Buffer.allocUnsafe(this.#digests.length * 2);
|
|
43309
|
+
this.#digests.copy(digests);
|
|
43310
|
+
this.#digests = digests;
|
|
43311
|
+
}
|
|
43312
|
+
this.#lengths[this.#count] = pointer2.length;
|
|
43313
|
+
this.#digests.write(pointer2.sha256, this.#count * DIGEST_BYTES, DIGEST_BYTES, "hex");
|
|
43314
|
+
this.#count += 1;
|
|
43315
|
+
this.#head = pointer2;
|
|
43316
|
+
this.#gen = record4.gen;
|
|
43317
|
+
this.#end = pointer2.offset + pointer2.length;
|
|
43318
|
+
this.#sessionId ??= record4.sessionId;
|
|
43319
|
+
this.#turns.apply(record4);
|
|
43320
|
+
}
|
|
43321
|
+
};
|
|
43322
|
+
function samePointer2(a, b) {
|
|
43323
|
+
return a !== null && a !== void 0 && a.seq === b.seq && a.offset === b.offset && a.length === b.length && a.sha256 === b.sha256;
|
|
43324
|
+
}
|
|
43325
|
+
__name(samePointer2, "samePointer");
|
|
43326
|
+
var ledgers = /* @__PURE__ */ new Map();
|
|
43327
|
+
function verifiedPrefixOf(key6) {
|
|
43328
|
+
const found = ledgers.get(key6);
|
|
43329
|
+
if (found !== void 0) {
|
|
43330
|
+
ledgers.delete(key6);
|
|
43331
|
+
ledgers.set(key6, found);
|
|
43332
|
+
}
|
|
43333
|
+
return found;
|
|
43334
|
+
}
|
|
43335
|
+
__name(verifiedPrefixOf, "verifiedPrefixOf");
|
|
43336
|
+
function startVerifiedPrefix(key6) {
|
|
43337
|
+
ledgers.delete(key6);
|
|
43338
|
+
if (ledgers.size >= LEDGERS_KEPT) {
|
|
43339
|
+
const oldest = ledgers.keys().next().value;
|
|
43340
|
+
if (oldest !== void 0)
|
|
43341
|
+
ledgers.delete(oldest);
|
|
43342
|
+
}
|
|
43343
|
+
const fresh = new VerifiedPrefix();
|
|
43344
|
+
ledgers.set(key6, fresh);
|
|
43345
|
+
return fresh;
|
|
43346
|
+
}
|
|
43347
|
+
__name(startVerifiedPrefix, "startVerifiedPrefix");
|
|
43348
|
+
async function rehashPrefix(bytes, ledger, count7) {
|
|
43349
|
+
if (count7 === 0)
|
|
43350
|
+
return true;
|
|
43351
|
+
if (count7 > ledger.count)
|
|
43352
|
+
return false;
|
|
43353
|
+
const lengths = ledger.lengths;
|
|
43354
|
+
const digests = ledger.digests;
|
|
43355
|
+
if (await bytes.size() < endOfLine(lengths, count7))
|
|
43356
|
+
return false;
|
|
43357
|
+
const splitter = new LineSplitter(0);
|
|
43358
|
+
let index = 0;
|
|
43359
|
+
let matched = false;
|
|
43360
|
+
const visit2 = /* @__PURE__ */ __name((chunk) => {
|
|
43361
|
+
for (const { line } of splitter.push(chunk)) {
|
|
43362
|
+
if (line.byteLength !== lengths[index])
|
|
43363
|
+
return true;
|
|
43364
|
+
if (!hexEqualsBytes(hexDigestOf(line), digests, index * DIGEST_BYTES))
|
|
43365
|
+
return true;
|
|
43366
|
+
index += 1;
|
|
43367
|
+
if (index === count7) {
|
|
43368
|
+
matched = true;
|
|
43369
|
+
return true;
|
|
43370
|
+
}
|
|
43371
|
+
}
|
|
43372
|
+
return false;
|
|
43373
|
+
}, "visit");
|
|
43374
|
+
try {
|
|
43375
|
+
if (bytes.scan !== void 0) {
|
|
43376
|
+
await bytes.scan(0, visit2);
|
|
43377
|
+
} else {
|
|
43378
|
+
for await (const chunk of bytes.stream(0))
|
|
43379
|
+
if (visit2(chunk))
|
|
43380
|
+
break;
|
|
43381
|
+
}
|
|
43382
|
+
} catch (error62) {
|
|
43383
|
+
if (error62.name === "SessionLogIntegrityError")
|
|
43384
|
+
return false;
|
|
43385
|
+
throw error62;
|
|
43386
|
+
}
|
|
43387
|
+
return matched;
|
|
43388
|
+
}
|
|
43389
|
+
__name(rehashPrefix, "rehashPrefix");
|
|
43390
|
+
function endOfLine(lengths, count7) {
|
|
43391
|
+
let total2 = 0;
|
|
43392
|
+
for (let i = 0; i < count7; i++)
|
|
43393
|
+
total2 += lengths[i];
|
|
43394
|
+
return total2;
|
|
43395
|
+
}
|
|
43396
|
+
__name(endOfLine, "endOfLine");
|
|
43397
|
+
|
|
43172
43398
|
// ../sdk/dist/store/session-log/core.js
|
|
43173
43399
|
function sessionLogDegradedCause(error62) {
|
|
43174
43400
|
switch (error62?.code) {
|
|
@@ -43253,6 +43479,8 @@ var SessionLogCore = class {
|
|
|
43253
43479
|
#holding = { release: /* @__PURE__ */ __name(() => this.#releaseHeld(), "release") };
|
|
43254
43480
|
/** Bytes of the log this instance has verified and applied. */
|
|
43255
43481
|
#synced = 0;
|
|
43482
|
+
/** What this process remembers of the log's verified prefix (see `verified-prefix.ts`). */
|
|
43483
|
+
#ledgerKey;
|
|
43256
43484
|
#torn = 0;
|
|
43257
43485
|
#degradedBufferBytes;
|
|
43258
43486
|
/** Records accepted into the chain that the medium has not taken yet, oldest first. */
|
|
@@ -43299,7 +43527,16 @@ var SessionLogCore = class {
|
|
|
43299
43527
|
return this.#degradedCause !== void 0;
|
|
43300
43528
|
}
|
|
43301
43529
|
// ── state ──
|
|
43302
|
-
/**
|
|
43530
|
+
/**
|
|
43531
|
+
* Catch up with the medium: verify and apply whatever was appended since the last sync.
|
|
43532
|
+
*
|
|
43533
|
+
* An instance that has nothing yet (a fresh one) first asks whether this
|
|
43534
|
+
* process already verified a prefix of this very log: it then re-reads and
|
|
43535
|
+
* hashes every byte of that prefix, and takes it as verified only when
|
|
43536
|
+
* every line's length and SHA-256 equal what was verified (no parsing, no
|
|
43537
|
+
* schema check). The bytes after it, and every byte when nothing matches,
|
|
43538
|
+
* are verified in full.
|
|
43539
|
+
*/
|
|
43303
43540
|
async #catchUp() {
|
|
43304
43541
|
if (this.#pending.length > 0)
|
|
43305
43542
|
return;
|
|
@@ -43308,6 +43545,26 @@ var SessionLogCore = class {
|
|
|
43308
43545
|
return;
|
|
43309
43546
|
if (size < this.#synced)
|
|
43310
43547
|
this.#reset();
|
|
43548
|
+
let ledger;
|
|
43549
|
+
const key6 = await this.#medium.identity?.();
|
|
43550
|
+
this.#ledgerKey = key6;
|
|
43551
|
+
if (key6 !== void 0) {
|
|
43552
|
+
ledger = verifiedPrefixOf(key6);
|
|
43553
|
+
if (this.#synced === 0 && this.#chain.head === null) {
|
|
43554
|
+
const remembered = ledger;
|
|
43555
|
+
if (remembered !== void 0 && remembered.count > 0 && remembered.sessionId === this.sessionId && remembered.end <= size && await rehashPrefix(this.#medium, remembered, remembered.count)) {
|
|
43556
|
+
this.#chain = new SessionLogChain({
|
|
43557
|
+
head: remembered.head,
|
|
43558
|
+
sessionId: remembered.sessionId,
|
|
43559
|
+
gen: remembered.gen
|
|
43560
|
+
});
|
|
43561
|
+
this.#turns = remembered.turns();
|
|
43562
|
+
this.#synced = remembered.end;
|
|
43563
|
+
} else {
|
|
43564
|
+
ledger = startVerifiedPrefix(key6);
|
|
43565
|
+
}
|
|
43566
|
+
}
|
|
43567
|
+
}
|
|
43311
43568
|
const splitter = new LineSplitter(this.#synced);
|
|
43312
43569
|
for await (const chunk of this.#medium.stream(this.#synced)) {
|
|
43313
43570
|
for (const { line, offset } of splitter.push(chunk)) {
|
|
@@ -43317,6 +43574,7 @@ var SessionLogCore = class {
|
|
|
43317
43574
|
}
|
|
43318
43575
|
this.#turns.apply(entry.record);
|
|
43319
43576
|
this.#synced = offset + line.byteLength;
|
|
43577
|
+
ledger?.append(entry);
|
|
43320
43578
|
}
|
|
43321
43579
|
}
|
|
43322
43580
|
this.#torn = splitter.pendingBytes;
|
|
@@ -43534,8 +43792,19 @@ var SessionLogCore = class {
|
|
|
43534
43792
|
const entry = this.#chain.accept(bytes, this.#synced);
|
|
43535
43793
|
this.#turns.apply(entry.record);
|
|
43536
43794
|
this.#synced += bytes.byteLength;
|
|
43795
|
+
if (this.#pending.length === 0)
|
|
43796
|
+
await this.#rememberWritten(entry);
|
|
43537
43797
|
return entry;
|
|
43538
43798
|
}
|
|
43799
|
+
/** Let this process remember a record this instance just wrote and verified. */
|
|
43800
|
+
async #rememberWritten(entry) {
|
|
43801
|
+
if (this.#ledgerKey === void 0)
|
|
43802
|
+
this.#ledgerKey = await this.#medium.identity?.();
|
|
43803
|
+
if (this.#ledgerKey === void 0)
|
|
43804
|
+
return;
|
|
43805
|
+
const ledger = verifiedPrefixOf(this.#ledgerKey) ?? (entry.pointer.seq === 1 ? startVerifiedPrefix(this.#ledgerKey) : void 0);
|
|
43806
|
+
ledger?.append(entry);
|
|
43807
|
+
}
|
|
43539
43808
|
/**
|
|
43540
43809
|
* Hand a record's bytes to the medium. A volume that refuses writes (full,
|
|
43541
43810
|
* over quota, read-only) does not fail the record: it waits in a bounded
|
|
@@ -43647,7 +43916,7 @@ var SessionLogCore = class {
|
|
|
43647
43916
|
if (typeof type === "string" && TOOL_INPUT_RECORD_TYPES.has(type)) {
|
|
43648
43917
|
return this.#spillToolInputs(candidate);
|
|
43649
43918
|
}
|
|
43650
|
-
if (type !== "message" && type !== "message_replaced" && type !== "compaction" && type !== "turn_completed")
|
|
43919
|
+
if (type !== "message" && type !== "message_replaced" && type !== "message_edited" && type !== "compaction" && type !== "turn_completed")
|
|
43651
43920
|
return candidate;
|
|
43652
43921
|
const size = Buffer.byteLength(`${JSON.stringify(candidate)}
|
|
43653
43922
|
`, "utf8");
|
|
@@ -43676,7 +43945,7 @@ ${NOT_SAVED_NOTE}`
|
|
|
43676
43945
|
return { ...candidate, summary: ref2 };
|
|
43677
43946
|
}
|
|
43678
43947
|
const content = candidate.content;
|
|
43679
|
-
const key6 = content.role === "tool" && typeof content.toolCallId === "string" ? content.toolCallId : type === "message_replaced" ? `record:${String(candidate.id)}` : `message:${String(candidate.messageId)}`;
|
|
43948
|
+
const key6 = content.role === "tool" && typeof content.toolCallId === "string" ? content.toolCallId : type === "message_replaced" || type === "message_edited" ? `record:${String(candidate.id)}` : `message:${String(candidate.messageId)}`;
|
|
43680
43949
|
const ref = await this.#spillOrLose(key6, "message", JSON.stringify(content));
|
|
43681
43950
|
const text9 = typeof content.content === "string" ? content.content : JSON.stringify(content.content);
|
|
43682
43951
|
if (ref === void 0) {
|
|
@@ -43823,6 +44092,8 @@ async function* walkSessionLog(medium, options) {
|
|
|
43823
44092
|
throw error62;
|
|
43824
44093
|
brokeAt = error62;
|
|
43825
44094
|
}, "fail");
|
|
44095
|
+
let covered = 0;
|
|
44096
|
+
let ledger;
|
|
43826
44097
|
if (options.after !== void 0) {
|
|
43827
44098
|
const after = options.after;
|
|
43828
44099
|
if (!await verifyPointer(medium, after)) {
|
|
@@ -43830,15 +44101,34 @@ async function* walkSessionLog(medium, options) {
|
|
|
43830
44101
|
fail2(error62);
|
|
43831
44102
|
return { intact: false, throughSeq: 0, head: null, tornBytes: 0, break: error62 };
|
|
43832
44103
|
}
|
|
43833
|
-
const
|
|
43834
|
-
|
|
43835
|
-
|
|
43836
|
-
sessionId
|
|
43837
|
-
|
|
43838
|
-
|
|
43839
|
-
|
|
44104
|
+
const key6 = options.reverify && strict ? await medium.identity?.() : void 0;
|
|
44105
|
+
if (key6 !== void 0) {
|
|
44106
|
+
const remembered = verifiedPrefixOf(key6);
|
|
44107
|
+
if (remembered !== void 0 && remembered.sessionId === options.sessionId && remembered.holds(after) && await rehashPrefix(medium, remembered, after.seq)) {
|
|
44108
|
+
ledger = remembered;
|
|
44109
|
+
} else {
|
|
44110
|
+
ledger = startVerifiedPrefix(key6);
|
|
44111
|
+
covered = after.seq;
|
|
44112
|
+
}
|
|
44113
|
+
}
|
|
44114
|
+
if (covered > 0) {
|
|
44115
|
+
chain = new SessionLogChain({ head: null, sessionId: options.sessionId });
|
|
44116
|
+
} else {
|
|
44117
|
+
const parsed = parseSessionLogLine(await medium.read(after.offset, after.length));
|
|
44118
|
+
chain = new SessionLogChain({
|
|
44119
|
+
head: after,
|
|
44120
|
+
sessionId: options.sessionId ?? parsed.record.sessionId,
|
|
44121
|
+
gen: parsed.record.gen
|
|
44122
|
+
});
|
|
44123
|
+
start = after.offset + after.length;
|
|
44124
|
+
}
|
|
43840
44125
|
} else {
|
|
43841
44126
|
chain = new SessionLogChain({ head: null, sessionId: options.sessionId });
|
|
44127
|
+
if (options.reverify && strict) {
|
|
44128
|
+
const key6 = await medium.identity?.();
|
|
44129
|
+
if (key6 !== void 0)
|
|
44130
|
+
ledger = verifiedPrefixOf(key6) ?? startVerifiedPrefix(key6);
|
|
44131
|
+
}
|
|
43842
44132
|
}
|
|
43843
44133
|
const splitter = new LineSplitter(start);
|
|
43844
44134
|
let anchorSeen = false;
|
|
@@ -43867,6 +44157,9 @@ async function* walkSessionLog(medium, options) {
|
|
|
43867
44157
|
break outer;
|
|
43868
44158
|
}
|
|
43869
44159
|
}
|
|
44160
|
+
ledger?.append(entry);
|
|
44161
|
+
if (entry.pointer.seq <= covered)
|
|
44162
|
+
continue;
|
|
43870
44163
|
yield entry;
|
|
43871
44164
|
if (options.throughSeq !== void 0 && entry.pointer.seq >= options.throughSeq) {
|
|
43872
44165
|
stopped = true;
|
|
@@ -43902,7 +44195,7 @@ import { mkdir as mkdir7, open as open7, stat as stat3 } from "node:fs/promises"
|
|
|
43902
44195
|
import { dirname as dirname7 } from "node:path";
|
|
43903
44196
|
|
|
43904
44197
|
// ../sdk/dist/session/paths.js
|
|
43905
|
-
import { createHash as
|
|
44198
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
43906
44199
|
import { link as link4, mkdir as mkdir6, open as open6, readFile as readFile6, realpath, unlink as unlink5 } from "node:fs/promises";
|
|
43907
44200
|
import { basename as basename4, dirname as dirname6, join as join12 } from "node:path";
|
|
43908
44201
|
function sessionLocatorFromLogFile(file2, sessionId5) {
|
|
@@ -43930,7 +44223,7 @@ var SLUG = /^[A-Za-z0-9-]+$/;
|
|
|
43930
44223
|
var NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
43931
44224
|
var MAX_SLUG = 200;
|
|
43932
44225
|
function sha256Hex4(value) {
|
|
43933
|
-
return
|
|
44226
|
+
return createHash9("sha256").update(value).digest("hex");
|
|
43934
44227
|
}
|
|
43935
44228
|
__name(sha256Hex4, "sha256Hex");
|
|
43936
44229
|
function checkId(value, kind) {
|
|
@@ -44198,6 +44491,16 @@ var DiskLogMedium = class {
|
|
|
44198
44491
|
throw error62;
|
|
44199
44492
|
}
|
|
44200
44493
|
}
|
|
44494
|
+
async identity() {
|
|
44495
|
+
try {
|
|
44496
|
+
const stats = await stat3(this.file);
|
|
44497
|
+
return `${stats.dev}:${stats.ino}:${this.file}`;
|
|
44498
|
+
} catch (error62) {
|
|
44499
|
+
if (isErrno3(error62, "ENOENT"))
|
|
44500
|
+
return void 0;
|
|
44501
|
+
throw error62;
|
|
44502
|
+
}
|
|
44503
|
+
}
|
|
44201
44504
|
async read(offset, length) {
|
|
44202
44505
|
let handle;
|
|
44203
44506
|
try {
|
|
@@ -44215,6 +44518,30 @@ var DiskLogMedium = class {
|
|
|
44215
44518
|
await handle.close();
|
|
44216
44519
|
}
|
|
44217
44520
|
}
|
|
44521
|
+
async scan(offset, visit2) {
|
|
44522
|
+
let handle;
|
|
44523
|
+
try {
|
|
44524
|
+
handle = await open7(this.file, "r");
|
|
44525
|
+
} catch (error62) {
|
|
44526
|
+
if (isErrno3(error62, "ENOENT"))
|
|
44527
|
+
return;
|
|
44528
|
+
throw error62;
|
|
44529
|
+
}
|
|
44530
|
+
try {
|
|
44531
|
+
const buffer = Buffer.allocUnsafe(1 << 20);
|
|
44532
|
+
let position = offset;
|
|
44533
|
+
for (; ; ) {
|
|
44534
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, position);
|
|
44535
|
+
if (bytesRead === 0)
|
|
44536
|
+
return;
|
|
44537
|
+
position += bytesRead;
|
|
44538
|
+
if (visit2(buffer.subarray(0, bytesRead)))
|
|
44539
|
+
return;
|
|
44540
|
+
}
|
|
44541
|
+
} finally {
|
|
44542
|
+
await handle.close();
|
|
44543
|
+
}
|
|
44544
|
+
}
|
|
44218
44545
|
async *stream(offset) {
|
|
44219
44546
|
if (await this.size() <= offset)
|
|
44220
44547
|
return;
|
|
@@ -44487,6 +44814,12 @@ function stampMessageId(message, id3) {
|
|
|
44487
44814
|
message.id = id3;
|
|
44488
44815
|
}
|
|
44489
44816
|
__name(stampMessageId, "stampMessageId");
|
|
44817
|
+
function sameStoredContent(a, b) {
|
|
44818
|
+
const { id: _a4, timestamp: _ta, ...restA } = a;
|
|
44819
|
+
const { id: _b, timestamp: _tb, ...restB } = b;
|
|
44820
|
+
return isDeepStrictEqual2(JSON.parse(JSON.stringify(restA)), JSON.parse(JSON.stringify(restB)));
|
|
44821
|
+
}
|
|
44822
|
+
__name(sameStoredContent, "sameStoredContent");
|
|
44490
44823
|
var DEFAULT_TURN_LEASE_TTL_MS = 5 * 6e4;
|
|
44491
44824
|
var TURN_BOUND_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
44492
44825
|
"tool_calls_admitted",
|
|
@@ -44583,6 +44916,8 @@ var TurnRecorder = class {
|
|
|
44583
44916
|
* these needs no re-basing, so no `compaction` record is written for it.
|
|
44584
44917
|
*/
|
|
44585
44918
|
#foldIdsAtResume;
|
|
44919
|
+
/** What the log folds to for a message a replacement or an edit changed, as of the resume. */
|
|
44920
|
+
#foldEditedAtResume = /* @__PURE__ */ new Map();
|
|
44586
44921
|
/** When a resumed turn began: its `turn_started` record, not this process's start. */
|
|
44587
44922
|
#resumedTurnStartedAt;
|
|
44588
44923
|
constructor(config2) {
|
|
@@ -45127,6 +45462,7 @@ var TurnRecorder = class {
|
|
|
45127
45462
|
async #readResumedLog() {
|
|
45128
45463
|
await this.flush();
|
|
45129
45464
|
const fold4 = new SessionMessageFold();
|
|
45465
|
+
const latestChange = /* @__PURE__ */ new Map();
|
|
45130
45466
|
for await (const entry of this.log.read()) {
|
|
45131
45467
|
const record4 = entry.record;
|
|
45132
45468
|
if (record4.type === "turn_started" && record4.turnId === this.turnId) {
|
|
@@ -45134,17 +45470,25 @@ var TurnRecorder = class {
|
|
|
45134
45470
|
if (Number.isFinite(at))
|
|
45135
45471
|
this.#resumedTurnStartedAt = at;
|
|
45136
45472
|
}
|
|
45473
|
+
if (record4.type === "message_edited")
|
|
45474
|
+
latestChange.set(record4.targetMessageId, "edited");
|
|
45475
|
+
else if (record4.type === "message_replaced")
|
|
45476
|
+
latestChange.set(record4.targetMessageId, "replaced");
|
|
45137
45477
|
fold4.apply(record4);
|
|
45138
45478
|
}
|
|
45139
|
-
if (fold4.spilledSummary)
|
|
45140
|
-
return void 0;
|
|
45141
45479
|
const ids = [];
|
|
45480
|
+
let allRecorded = !fold4.spilledSummary;
|
|
45481
|
+
this.#foldEditedAtResume.clear();
|
|
45142
45482
|
for (const entry of fold4.entries()) {
|
|
45143
|
-
if (!entry.messageId)
|
|
45144
|
-
|
|
45483
|
+
if (!entry.messageId) {
|
|
45484
|
+
allRecorded = false;
|
|
45485
|
+
continue;
|
|
45486
|
+
}
|
|
45145
45487
|
ids.push(entry.messageId);
|
|
45488
|
+
if (latestChange.get(entry.messageId) === "edited" && entry.spill === void 0)
|
|
45489
|
+
this.#foldEditedAtResume.set(entry.messageId, entry.message);
|
|
45146
45490
|
}
|
|
45147
|
-
return ids;
|
|
45491
|
+
return allRecorded ? ids : void 0;
|
|
45148
45492
|
}
|
|
45149
45493
|
/** The recorded context is exactly what the log folds to: a resume changed nothing. */
|
|
45150
45494
|
#viewMatchesFold() {
|
|
@@ -45348,6 +45692,10 @@ var TurnRecorder = class {
|
|
|
45348
45692
|
});
|
|
45349
45693
|
return;
|
|
45350
45694
|
}
|
|
45695
|
+
if (options.restored && this.#rebasePending && this.#phase === "active") {
|
|
45696
|
+
this.#view.push({ message });
|
|
45697
|
+
return;
|
|
45698
|
+
}
|
|
45351
45699
|
this.#syncMessages();
|
|
45352
45700
|
}
|
|
45353
45701
|
/** Replace the context without replacing the turn; recorded as one `compaction`. */
|
|
@@ -45382,6 +45730,101 @@ var TurnRecorder = class {
|
|
|
45382
45730
|
stampMessageId(message, id3);
|
|
45383
45731
|
return id3;
|
|
45384
45732
|
}
|
|
45733
|
+
/**
|
|
45734
|
+
* A compaction pass edits one message by replacing its object with a copy
|
|
45735
|
+
* that has other content (`{ ...message, content }`). The copy still carries
|
|
45736
|
+
* the id the original was stamped with, but the recorder's own indexes are
|
|
45737
|
+
* keyed by object identity, so without this it would see an unknown message
|
|
45738
|
+
* and record every message after it again. A live object that is not in the
|
|
45739
|
+
* view, whose `id` is that of a recorded view entry whose own object has left
|
|
45740
|
+
* the context, is that same message edited: one `message_edited` record
|
|
45741
|
+
* carries its new content and the view entry follows the new object.
|
|
45742
|
+
*
|
|
45743
|
+
* Only an id claimed by exactly one live object is taken, so two copies of
|
|
45744
|
+
* one message are never both treated as its edit. Anything else is left to
|
|
45745
|
+
* the callers, which record it as a new message.
|
|
45746
|
+
*/
|
|
45747
|
+
#absorbEdits() {
|
|
45748
|
+
if (this.#phase !== "active")
|
|
45749
|
+
return;
|
|
45750
|
+
const live2 = this.#turn.messages;
|
|
45751
|
+
const inContext = new Set(live2);
|
|
45752
|
+
let orphans;
|
|
45753
|
+
for (const entry of this.#view) {
|
|
45754
|
+
if (entry.id === void 0 || entry.transient || inContext.has(entry.message))
|
|
45755
|
+
continue;
|
|
45756
|
+
orphans ??= /* @__PURE__ */ new Map();
|
|
45757
|
+
orphans.set(entry.id, entry);
|
|
45758
|
+
}
|
|
45759
|
+
if (orphans === void 0)
|
|
45760
|
+
return;
|
|
45761
|
+
const known = new Set(this.#view.map((entry) => entry.message));
|
|
45762
|
+
const claimed = /* @__PURE__ */ new Map();
|
|
45763
|
+
for (const message of live2) {
|
|
45764
|
+
if (known.has(message) || this.#transient.has(message))
|
|
45765
|
+
continue;
|
|
45766
|
+
const id3 = message.id;
|
|
45767
|
+
if (id3 === void 0 || !orphans.has(id3))
|
|
45768
|
+
continue;
|
|
45769
|
+
const list2 = claimed.get(id3);
|
|
45770
|
+
if (list2)
|
|
45771
|
+
list2.push(message);
|
|
45772
|
+
else
|
|
45773
|
+
claimed.set(id3, [message]);
|
|
45774
|
+
}
|
|
45775
|
+
const turnId6 = this.turnId;
|
|
45776
|
+
for (const [id3, messages] of claimed) {
|
|
45777
|
+
const message = messages[0];
|
|
45778
|
+
const entry = orphans.get(id3);
|
|
45779
|
+
if (messages.length !== 1 || message.role !== entry.message.role)
|
|
45780
|
+
continue;
|
|
45781
|
+
const previous = entry.message;
|
|
45782
|
+
entry.message = message;
|
|
45783
|
+
this.#ids.set(message, id3);
|
|
45784
|
+
this.#recorded.set(message, id3);
|
|
45785
|
+
if (sameStoredContent(previous, message))
|
|
45786
|
+
continue;
|
|
45787
|
+
void this.#enqueue(() => this.#append({
|
|
45788
|
+
type: "message_edited",
|
|
45789
|
+
turnId: turnId6,
|
|
45790
|
+
targetMessageId: id3,
|
|
45791
|
+
content: message,
|
|
45792
|
+
ignorable: true,
|
|
45793
|
+
reason: "compaction"
|
|
45794
|
+
})).catch(() => void 0);
|
|
45795
|
+
}
|
|
45796
|
+
}
|
|
45797
|
+
/**
|
|
45798
|
+
* A resume restores the context a checkpoint holds, which can predate a
|
|
45799
|
+
* compaction edit written after it. The ids still match, so the log is not
|
|
45800
|
+
* re-based; but the fold then shows the edited text of a message the context
|
|
45801
|
+
* holds as it was. One `message_edited` per such message makes the fold show
|
|
45802
|
+
* the context the resume actually runs with.
|
|
45803
|
+
*/
|
|
45804
|
+
#recordDriftFromFold() {
|
|
45805
|
+
const edited = this.#foldEditedAtResume;
|
|
45806
|
+
if (edited.size === 0)
|
|
45807
|
+
return;
|
|
45808
|
+
const turnId6 = this.turnId;
|
|
45809
|
+
for (const entry of this.#view) {
|
|
45810
|
+
if (entry.id === void 0 || entry.transient)
|
|
45811
|
+
continue;
|
|
45812
|
+
const folded = edited.get(entry.id);
|
|
45813
|
+
if (folded === void 0 || sameStoredContent(folded, entry.message))
|
|
45814
|
+
continue;
|
|
45815
|
+
const message = entry.message;
|
|
45816
|
+
const id3 = entry.id;
|
|
45817
|
+
void this.#enqueue(() => this.#append({
|
|
45818
|
+
type: "message_edited",
|
|
45819
|
+
turnId: turnId6,
|
|
45820
|
+
targetMessageId: id3,
|
|
45821
|
+
content: message,
|
|
45822
|
+
ignorable: true,
|
|
45823
|
+
reason: "resume"
|
|
45824
|
+
})).catch(() => void 0);
|
|
45825
|
+
}
|
|
45826
|
+
edited.clear();
|
|
45827
|
+
}
|
|
45385
45828
|
/**
|
|
45386
45829
|
* Reconcile the context with the log. Nothing is written before the turn
|
|
45387
45830
|
* begins or after it pauses or settles.
|
|
@@ -45395,9 +45838,12 @@ var TurnRecorder = class {
|
|
|
45395
45838
|
this.#foldIdsAtResume = void 0;
|
|
45396
45839
|
if (!unchanged) {
|
|
45397
45840
|
this.#recordCompaction();
|
|
45841
|
+
this.#recordDriftFromFold();
|
|
45398
45842
|
return;
|
|
45399
45843
|
}
|
|
45844
|
+
this.#recordDriftFromFold();
|
|
45400
45845
|
}
|
|
45846
|
+
this.#absorbEdits();
|
|
45401
45847
|
const live2 = this.#turn.messages;
|
|
45402
45848
|
const view = this.#view;
|
|
45403
45849
|
let prefix = 0;
|
|
@@ -45433,6 +45879,7 @@ var TurnRecorder = class {
|
|
|
45433
45879
|
* log order, the whole context becomes the summary.
|
|
45434
45880
|
*/
|
|
45435
45881
|
#recordCompaction() {
|
|
45882
|
+
this.#absorbEdits();
|
|
45436
45883
|
const live2 = this.#turn.messages;
|
|
45437
45884
|
const byMessage = new Map(this.#view.map((entry) => [entry.message, entry]));
|
|
45438
45885
|
const next2 = live2.map((message) => {
|
|
@@ -45653,36 +46100,58 @@ async function recordedMessages(log, fold4) {
|
|
|
45653
46100
|
return out;
|
|
45654
46101
|
}
|
|
45655
46102
|
__name(recordedMessages, "recordedMessages");
|
|
45656
|
-
|
|
46103
|
+
function recordedContent(record4) {
|
|
46104
|
+
return { content: record4.content, ...record4.spill ? { spill: record4.spill } : {} };
|
|
46105
|
+
}
|
|
46106
|
+
__name(recordedContent, "recordedContent");
|
|
46107
|
+
async function readEverRecordedMessageIndex(log) {
|
|
45657
46108
|
return foldSessionLog(log, {
|
|
45658
46109
|
name: "ever-recorded-messages",
|
|
45659
46110
|
mode: "strict",
|
|
45660
|
-
create: /* @__PURE__ */ __name(() => /* @__PURE__ */ new Map(), "create"),
|
|
45661
|
-
apply: /* @__PURE__ */ __name((latest, entry) => {
|
|
46111
|
+
create: /* @__PURE__ */ __name(() => ({ latest: /* @__PURE__ */ new Map(), earlier: /* @__PURE__ */ new Map() }), "create"),
|
|
46112
|
+
apply: /* @__PURE__ */ __name(({ latest, earlier }, entry) => {
|
|
45662
46113
|
const record4 = entry.record;
|
|
45663
46114
|
if (record4.type === "message") {
|
|
45664
|
-
latest.set(record4.messageId,
|
|
45665
|
-
content: record4.content,
|
|
45666
|
-
...record4.spill ? { spill: record4.spill } : {}
|
|
45667
|
-
});
|
|
46115
|
+
latest.set(record4.messageId, recordedContent(record4));
|
|
45668
46116
|
} else if (record4.type === "message_replaced") {
|
|
45669
|
-
|
|
45670
|
-
|
|
45671
|
-
|
|
45672
|
-
|
|
46117
|
+
earlier.delete(record4.targetMessageId);
|
|
46118
|
+
latest.set(record4.targetMessageId, recordedContent(record4));
|
|
46119
|
+
} else if (record4.type === "message_edited") {
|
|
46120
|
+
const before = latest.get(record4.targetMessageId);
|
|
46121
|
+
if (before !== void 0) {
|
|
46122
|
+
const held3 = earlier.get(record4.targetMessageId);
|
|
46123
|
+
if (held3)
|
|
46124
|
+
held3.push(before);
|
|
46125
|
+
else
|
|
46126
|
+
earlier.set(record4.targetMessageId, [before]);
|
|
46127
|
+
}
|
|
46128
|
+
latest.set(record4.targetMessageId, recordedContent(record4));
|
|
45673
46129
|
}
|
|
45674
46130
|
}, "apply"),
|
|
45675
|
-
result: /* @__PURE__ */ __name(async (latest) => {
|
|
46131
|
+
result: /* @__PURE__ */ __name(async ({ latest, earlier }) => {
|
|
45676
46132
|
const resolved2 = /* @__PURE__ */ new Map();
|
|
45677
46133
|
for (const [id3, entry] of latest) {
|
|
45678
46134
|
const content = entry.spill ? JSON.parse(await log.readSpill(entry.spill)) : structuredClone(entry.content);
|
|
45679
46135
|
resolved2.set(id3, withMessageId(content, id3));
|
|
45680
46136
|
}
|
|
45681
|
-
|
|
46137
|
+
const held3 = /* @__PURE__ */ new Map();
|
|
46138
|
+
for (const [id3, list2] of earlier)
|
|
46139
|
+
held3.set(id3, [...list2]);
|
|
46140
|
+
return {
|
|
46141
|
+
latest: resolved2,
|
|
46142
|
+
async heldBeforeAnEdit(id3, message) {
|
|
46143
|
+
for (const entry of held3.get(id3) ?? []) {
|
|
46144
|
+
const content = entry.spill ? JSON.parse(await log.readSpill(entry.spill)) : entry.content;
|
|
46145
|
+
if (sameStoredContent(content, message))
|
|
46146
|
+
return true;
|
|
46147
|
+
}
|
|
46148
|
+
return false;
|
|
46149
|
+
}
|
|
46150
|
+
};
|
|
45682
46151
|
}, "result")
|
|
45683
46152
|
});
|
|
45684
46153
|
}
|
|
45685
|
-
__name(
|
|
46154
|
+
__name(readEverRecordedMessageIndex, "readEverRecordedMessageIndex");
|
|
45686
46155
|
|
|
45687
46156
|
// ../sdk/dist/prompt/contributions.js
|
|
45688
46157
|
var PromptContributionCollisionError = class extends RegistryCollisionError {
|
|
@@ -48866,7 +49335,7 @@ async function* settlePreStartCancellation(params, prepared) {
|
|
|
48866
49335
|
});
|
|
48867
49336
|
const push = /* @__PURE__ */ __name((message, ids) => {
|
|
48868
49337
|
const messageId4 = ids.get(message);
|
|
48869
|
-
ctx.recorder.pushMessage(message, messageId4 ? { messageId: messageId4 } : {});
|
|
49338
|
+
ctx.recorder.pushMessage(message, { ...messageId4 ? { messageId: messageId4 } : {}, restored: true });
|
|
48870
49339
|
}, "push");
|
|
48871
49340
|
try {
|
|
48872
49341
|
if (selectedResumeState) {
|
|
@@ -49789,7 +50258,7 @@ async function readRecordedMessage(log, messageId4, throughSeq) {
|
|
|
49789
50258
|
let found;
|
|
49790
50259
|
for await (const { record: record4 } of log.read({ throughSeq })) {
|
|
49791
50260
|
const entry = record4;
|
|
49792
|
-
if (entry.type === "message" && entry.messageId === messageId4 || entry.type === "message_replaced" && entry.targetMessageId === messageId4) {
|
|
50261
|
+
if (entry.type === "message" && entry.messageId === messageId4 || (entry.type === "message_replaced" || entry.type === "message_edited") && entry.targetMessageId === messageId4) {
|
|
49793
50262
|
found = { content: entry.content, ...entry.spill ? { spill: entry.spill } : {} };
|
|
49794
50263
|
}
|
|
49795
50264
|
}
|
|
@@ -49970,10 +50439,10 @@ var DetachedCalls = class {
|
|
|
49970
50439
|
};
|
|
49971
50440
|
|
|
49972
50441
|
// ../sdk/dist/store/memory/digest.js
|
|
49973
|
-
import { createHash as
|
|
50442
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
49974
50443
|
var KNOWLEDGE_TAG_PREFIX = "knowledge:";
|
|
49975
50444
|
function knowledgeDigest(value) {
|
|
49976
|
-
return
|
|
50445
|
+
return createHash10("sha256").update(JSON.stringify(value)).digest("hex");
|
|
49977
50446
|
}
|
|
49978
50447
|
__name(knowledgeDigest, "knowledgeDigest");
|
|
49979
50448
|
async function holdsKnowledgeDigest(store, tags, digest8, isWriter) {
|
|
@@ -52078,7 +52547,7 @@ async function deliverDurableInbound(recorder, source, signal) {
|
|
|
52078
52547
|
__name(deliverDurableInbound, "deliverDurableInbound");
|
|
52079
52548
|
|
|
52080
52549
|
// ../sdk/dist/runtime/query/observation-context.js
|
|
52081
|
-
import { createHash as
|
|
52550
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
52082
52551
|
|
|
52083
52552
|
// ../sdk/dist/compaction/retention.js
|
|
52084
52553
|
var isAssistantWithCalls = /* @__PURE__ */ __name((m) => m.role === "assistant" && Array.isArray(m.toolCalls), "isAssistantWithCalls");
|
|
@@ -52154,12 +52623,12 @@ function findRetainedIndices(messages) {
|
|
|
52154
52623
|
__name(findRetainedIndices, "findRetainedIndices");
|
|
52155
52624
|
|
|
52156
52625
|
// ../sdk/dist/runtime/query/tool-output-budget.js
|
|
52157
|
-
import { createHash as
|
|
52626
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
52158
52627
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
52159
52628
|
import { join as join13 } from "node:path";
|
|
52160
52629
|
|
|
52161
52630
|
// ../sdk/dist/store/evidence/format.js
|
|
52162
|
-
import { createHash as
|
|
52631
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
52163
52632
|
|
|
52164
52633
|
// ../sdk/dist/utils/evidence-tokens.js
|
|
52165
52634
|
function evidenceTokens(text9) {
|
|
@@ -52198,36 +52667,36 @@ var SEARCH_OVERLAP_BYTES = 1024;
|
|
|
52198
52667
|
var FILTER_BYTES = 1024;
|
|
52199
52668
|
var TOKEN_FILTER_PREFIX = `tokens-v1:${digest2(`${process.version}:${process.versions.v8}:${process.versions.unicode}`).slice(0, 16)}:`;
|
|
52200
52669
|
function digest2(value) {
|
|
52201
|
-
return
|
|
52670
|
+
return createHash11("sha256").update(value).digest("hex");
|
|
52202
52671
|
}
|
|
52203
52672
|
__name(digest2, "digest");
|
|
52204
52673
|
function hashAt(text9, offset) {
|
|
52205
|
-
let
|
|
52674
|
+
let hash4 = 2166136261;
|
|
52206
52675
|
for (let i = 0; i < 3; i++)
|
|
52207
|
-
|
|
52208
|
-
return
|
|
52676
|
+
hash4 = Math.imul(hash4 ^ text9.charCodeAt(offset + i), 16777619);
|
|
52677
|
+
return hash4 >>> 0;
|
|
52209
52678
|
}
|
|
52210
52679
|
__name(hashAt, "hashAt");
|
|
52211
|
-
function second(
|
|
52212
|
-
return Math.imul(
|
|
52680
|
+
function second(hash4) {
|
|
52681
|
+
return Math.imul(hash4 ^ hash4 >>> 16, 73244475) >>> 0;
|
|
52213
52682
|
}
|
|
52214
52683
|
__name(second, "second");
|
|
52215
|
-
function contains(bits,
|
|
52216
|
-
const bit =
|
|
52684
|
+
function contains(bits, hash4) {
|
|
52685
|
+
const bit = hash4 % (bits.length * 8);
|
|
52217
52686
|
return ((bits[bit >>> 3] ?? 0) & 1 << (bit & 7)) !== 0;
|
|
52218
52687
|
}
|
|
52219
52688
|
__name(contains, "contains");
|
|
52220
|
-
function set2(bits,
|
|
52221
|
-
const bit =
|
|
52689
|
+
function set2(bits, hash4) {
|
|
52690
|
+
const bit = hash4 % (bits.length * 8);
|
|
52222
52691
|
bits[bit >>> 3] = (bits[bit >>> 3] ?? 0) | 1 << (bit & 7);
|
|
52223
52692
|
}
|
|
52224
52693
|
__name(set2, "set");
|
|
52225
52694
|
function textFilter(text9) {
|
|
52226
52695
|
const bits = Buffer.alloc(FILTER_BYTES);
|
|
52227
52696
|
for (let i = 0; i + 2 < text9.length; i++) {
|
|
52228
|
-
const
|
|
52229
|
-
set2(bits,
|
|
52230
|
-
set2(bits, second(
|
|
52697
|
+
const hash4 = hashAt(text9, i);
|
|
52698
|
+
set2(bits, hash4);
|
|
52699
|
+
set2(bits, second(hash4));
|
|
52231
52700
|
}
|
|
52232
52701
|
return bits.toString("base64");
|
|
52233
52702
|
}
|
|
@@ -52237,26 +52706,26 @@ function mayContain(filter, query2) {
|
|
|
52237
52706
|
if (bits.length !== FILTER_BYTES)
|
|
52238
52707
|
throw new Error("Invalid evidence filter.");
|
|
52239
52708
|
for (let i = 0; i + 2 < query2.length; i++) {
|
|
52240
|
-
const
|
|
52241
|
-
if (!contains(bits,
|
|
52709
|
+
const hash4 = hashAt(query2, i);
|
|
52710
|
+
if (!contains(bits, hash4) || !contains(bits, second(hash4)))
|
|
52242
52711
|
return false;
|
|
52243
52712
|
}
|
|
52244
52713
|
return true;
|
|
52245
52714
|
}
|
|
52246
52715
|
__name(mayContain, "mayContain");
|
|
52247
52716
|
function tokenHash(token) {
|
|
52248
|
-
let
|
|
52717
|
+
let hash4 = 2166136261;
|
|
52249
52718
|
for (let i = 0; i < token.length; i++)
|
|
52250
|
-
|
|
52251
|
-
return
|
|
52719
|
+
hash4 = Math.imul(hash4 ^ token.charCodeAt(i), 16777619);
|
|
52720
|
+
return hash4 >>> 0;
|
|
52252
52721
|
}
|
|
52253
52722
|
__name(tokenHash, "tokenHash");
|
|
52254
52723
|
function tokenFilter(text9) {
|
|
52255
52724
|
const bits = Buffer.alloc(text9.length <= 1024 ? 128 : text9.length <= 8192 ? 512 : FILTER_BYTES);
|
|
52256
52725
|
for (const match of evidenceTokenEntries(text9)) {
|
|
52257
|
-
const
|
|
52258
|
-
set2(bits,
|
|
52259
|
-
set2(bits, second(
|
|
52726
|
+
const hash4 = tokenHash(evidenceTokenKey(match[0]));
|
|
52727
|
+
set2(bits, hash4);
|
|
52728
|
+
set2(bits, second(hash4));
|
|
52260
52729
|
}
|
|
52261
52730
|
return TOKEN_FILTER_PREFIX + bits.toString("base64");
|
|
52262
52731
|
}
|
|
@@ -52267,8 +52736,8 @@ function mayContainToken(filter, query2) {
|
|
|
52267
52736
|
const bits = Buffer.from(filter.slice(TOKEN_FILTER_PREFIX.length), "base64");
|
|
52268
52737
|
if (![128, 512, FILTER_BYTES].includes(bits.length))
|
|
52269
52738
|
throw new Error("Invalid evidence token filter.");
|
|
52270
|
-
const
|
|
52271
|
-
return contains(bits,
|
|
52739
|
+
const hash4 = tokenHash(evidenceTokenKey(query2));
|
|
52740
|
+
return contains(bits, hash4) && contains(bits, second(hash4));
|
|
52272
52741
|
}
|
|
52273
52742
|
__name(mayContainToken, "mayContainToken");
|
|
52274
52743
|
function encodeSpillManifest(manifest) {
|
|
@@ -52463,7 +52932,7 @@ __name(applyToolOutputBudget, "applyToolOutputBudget");
|
|
|
52463
52932
|
function spill2(dir, toolUseId3, content, onError) {
|
|
52464
52933
|
try {
|
|
52465
52934
|
mkdirSync3(dir, { recursive: true, mode: 448 });
|
|
52466
|
-
const name2 =
|
|
52935
|
+
const name2 = createHash12("sha256").update(toolUseId3).digest("hex");
|
|
52467
52936
|
const path2 = join13(dir, `${name2}.txt`);
|
|
52468
52937
|
const bytes = Buffer.from(content, "utf8");
|
|
52469
52938
|
writeFileSync2(path2, bytes, { flag: "wx", mode: 384 });
|
|
@@ -52685,7 +53154,7 @@ function projectObservationContext(messages, tools, preserveToolResultsFrom = []
|
|
|
52685
53154
|
}
|
|
52686
53155
|
if (executionKey === void 0)
|
|
52687
53156
|
continue;
|
|
52688
|
-
const key6 =
|
|
53157
|
+
const key6 = createHash13("sha256").update(JSON.stringify([
|
|
52689
53158
|
call2.function.name,
|
|
52690
53159
|
call2.function.arguments,
|
|
52691
53160
|
message.content,
|
|
@@ -52712,7 +53181,7 @@ function projectObservationContext(messages, tools, preserveToolResultsFrom = []
|
|
|
52712
53181
|
__name(projectObservationContext, "projectObservationContext");
|
|
52713
53182
|
|
|
52714
53183
|
// ../sdk/dist/runtime/query/request-context.js
|
|
52715
|
-
import { createHash as
|
|
53184
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
52716
53185
|
function canonicalJson2(value) {
|
|
52717
53186
|
return JSON.stringify(value, (_key, item) => {
|
|
52718
53187
|
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
@@ -52731,7 +53200,7 @@ function snapshotRequestContext(messages) {
|
|
|
52731
53200
|
partIndex: partIndex++,
|
|
52732
53201
|
role: message.role,
|
|
52733
53202
|
kind,
|
|
52734
|
-
digest:
|
|
53203
|
+
digest: createHash14("sha256").update(canonicalJson2(payload)).digest("hex"),
|
|
52735
53204
|
...toolCallId !== void 0 ? { toolCallId } : {},
|
|
52736
53205
|
...message.role === "tool" ? { isError: message.isError === true } : {}
|
|
52737
53206
|
}));
|
|
@@ -55933,7 +56402,7 @@ function deliverArrivedMonitorNotices(ctx) {
|
|
|
55933
56402
|
__name(deliverArrivedMonitorNotices, "deliverArrivedMonitorNotices");
|
|
55934
56403
|
|
|
55935
56404
|
// ../sdk/dist/runtime/query/iteration/request-repair.js
|
|
55936
|
-
import { createHash as
|
|
56405
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
55937
56406
|
|
|
55938
56407
|
// ../sdk/dist/provider/image-input-refusal.js
|
|
55939
56408
|
var IMAGE_INPUT_REFUSAL_PATTERNS = [
|
|
@@ -56210,7 +56679,7 @@ function isAccepted(chunk) {
|
|
|
56210
56679
|
return Boolean(chunk.delta.content || chunk.delta.toolCalls?.length || chunk.delta.toolCallEnd || chunk.delta.reasoning || chunk.delta.citation || chunk.finishReason !== void 0 || chunk.usage !== void 0 || chunk.replayState !== void 0 || chunk.textParts !== void 0);
|
|
56211
56680
|
}
|
|
56212
56681
|
__name(isAccepted, "isAccepted");
|
|
56213
|
-
var mediaFingerprint = /* @__PURE__ */ __name((data, mediaType) =>
|
|
56682
|
+
var mediaFingerprint = /* @__PURE__ */ __name((data, mediaType) => createHash15("sha256").update(mediaType).update("\0").update(data).digest("hex"), "mediaFingerprint");
|
|
56214
56683
|
var FAULT_NOTE = "the provider could not process it. The file may be unsupported or corrupt; do not retry reading it. If you need to inspect it, use a shell command instead.";
|
|
56215
56684
|
var LIMIT_NOTE = "this conversation holds more files than the provider accepts at once, so the oldest are left out of the request. They are still in the conversation.";
|
|
56216
56685
|
var removedNote = /* @__PURE__ */ __name((kind, limit) => `[${kind} removed: ${limit ? LIMIT_NOTE : FAULT_NOTE}]`, "removedNote");
|
|
@@ -57268,12 +57737,12 @@ __name(bm25Score, "bm25Score");
|
|
|
57268
57737
|
var HASHES = 64;
|
|
57269
57738
|
var SHINGLE = 3;
|
|
57270
57739
|
function fnv1a(text9, seed) {
|
|
57271
|
-
let
|
|
57740
|
+
let hash4 = (2166136261 ^ seed) >>> 0;
|
|
57272
57741
|
for (let i = 0; i < text9.length; i += 1) {
|
|
57273
|
-
|
|
57274
|
-
|
|
57742
|
+
hash4 ^= text9.charCodeAt(i);
|
|
57743
|
+
hash4 = Math.imul(hash4, 16777619) >>> 0;
|
|
57275
57744
|
}
|
|
57276
|
-
return
|
|
57745
|
+
return hash4;
|
|
57277
57746
|
}
|
|
57278
57747
|
__name(fnv1a, "fnv1a");
|
|
57279
57748
|
function minhash(tokens) {
|
|
@@ -57297,14 +57766,19 @@ function minhash(tokens) {
|
|
|
57297
57766
|
return signature;
|
|
57298
57767
|
}
|
|
57299
57768
|
__name(minhash, "minhash");
|
|
57300
|
-
function
|
|
57301
|
-
|
|
57302
|
-
|
|
57303
|
-
|
|
57304
|
-
|
|
57305
|
-
|
|
57306
|
-
|
|
57307
|
-
|
|
57769
|
+
function similarityAtLeast(a, b, floor) {
|
|
57770
|
+
const allowedMisses = HASHES - Math.ceil(floor * HASHES);
|
|
57771
|
+
let misses = 0;
|
|
57772
|
+
for (let slot = 0; slot < HASHES; slot += 1) {
|
|
57773
|
+
if (a[slot] !== b[slot]) {
|
|
57774
|
+
misses += 1;
|
|
57775
|
+
if (misses > allowedMisses)
|
|
57776
|
+
return 0;
|
|
57777
|
+
}
|
|
57778
|
+
}
|
|
57779
|
+
return (HASHES - misses) / HASHES;
|
|
57780
|
+
}
|
|
57781
|
+
__name(similarityAtLeast, "similarityAtLeast");
|
|
57308
57782
|
function isEmptySignature(signature) {
|
|
57309
57783
|
return signature.every((h) => h === 4294967295);
|
|
57310
57784
|
}
|
|
@@ -57351,6 +57825,25 @@ function citable(tokens) {
|
|
|
57351
57825
|
return out;
|
|
57352
57826
|
}
|
|
57353
57827
|
__name(citable, "citable");
|
|
57828
|
+
var FEATURES = /* @__PURE__ */ new WeakMap();
|
|
57829
|
+
function featuresOf(message, text9) {
|
|
57830
|
+
const cached4 = FEATURES.get(message);
|
|
57831
|
+
if (cached4 !== void 0 && cached4.text === text9)
|
|
57832
|
+
return cached4;
|
|
57833
|
+
const tokens = tokenize(text9);
|
|
57834
|
+
const signature = minhash(tokens);
|
|
57835
|
+
const features = {
|
|
57836
|
+
text: text9,
|
|
57837
|
+
tokenCount: tokens.length,
|
|
57838
|
+
document: indexDocument(text9, tokens),
|
|
57839
|
+
citable: citable(tokens),
|
|
57840
|
+
signature,
|
|
57841
|
+
signatureKey: String.fromCharCode(...new Uint16Array(signature.buffer))
|
|
57842
|
+
};
|
|
57843
|
+
FEATURES.set(message, features);
|
|
57844
|
+
return features;
|
|
57845
|
+
}
|
|
57846
|
+
__name(featuresOf, "featuresOf");
|
|
57354
57847
|
function scoreMessages(messages, options) {
|
|
57355
57848
|
const config2 = {
|
|
57356
57849
|
...DEFAULT_SALIENCE_CONFIG,
|
|
@@ -57358,10 +57851,9 @@ function scoreMessages(messages, options) {
|
|
|
57358
57851
|
weights: { ...DEFAULT_SALIENCE_WEIGHTS, ...options.config?.weights }
|
|
57359
57852
|
};
|
|
57360
57853
|
const n = messages.length;
|
|
57361
|
-
const
|
|
57854
|
+
const features = messages.map((message) => featuresOf(message, messageText(message)));
|
|
57362
57855
|
const richContent = messages.map(hasRichContent);
|
|
57363
|
-
const
|
|
57364
|
-
const documents = texts.map((text9, i) => indexDocument(text9, tokenLists[i]));
|
|
57856
|
+
const documents = features.map((f) => f.document);
|
|
57365
57857
|
const index = buildIndex(documents);
|
|
57366
57858
|
const goalTokens = tokenize(options.goal);
|
|
57367
57859
|
const rawRelevance = documents.map((doc) => bm25Score(index, doc, goalTokens));
|
|
@@ -57369,23 +57861,48 @@ function scoreMessages(messages, options) {
|
|
|
57369
57861
|
const m = messages[i];
|
|
57370
57862
|
return m.role === "tool" || m.role === "assistant" && !isAssistantWithCalls2(m);
|
|
57371
57863
|
}));
|
|
57372
|
-
const
|
|
57373
|
-
let
|
|
57374
|
-
for (let i = n - 1; i >= 0; i -= 1) {
|
|
57375
|
-
citedAfter[i] = running;
|
|
57864
|
+
const lastCited = /* @__PURE__ */ new Map();
|
|
57865
|
+
for (let i = 0; i < n; i += 1) {
|
|
57376
57866
|
const message = messages[i];
|
|
57377
|
-
if (message.role
|
|
57378
|
-
|
|
57379
|
-
|
|
57867
|
+
if (message.role !== "assistant" && message.role !== "user")
|
|
57868
|
+
continue;
|
|
57869
|
+
for (const token of features[i].citable)
|
|
57870
|
+
lastCited.set(token, i);
|
|
57380
57871
|
}
|
|
57381
|
-
const signatures = tokenLists.map(minhash);
|
|
57382
57872
|
const callKeys = messages.map((m) => isAssistantWithCalls2(m) ? (m.toolCalls ?? []).map((c) => `${c.function.name}:${c.function.arguments}`) : []);
|
|
57383
|
-
const
|
|
57384
|
-
let
|
|
57873
|
+
const lastCalled = /* @__PURE__ */ new Map();
|
|
57874
|
+
for (let i = 0; i < n; i += 1) {
|
|
57875
|
+
for (const key6 of callKeys[i])
|
|
57876
|
+
lastCalled.set(key6, i);
|
|
57877
|
+
}
|
|
57878
|
+
const floor = Math.min(0.5, config2.duplicateThreshold);
|
|
57879
|
+
const redundancyOf = new Array(n).fill(0);
|
|
57880
|
+
const laterSignatures = /* @__PURE__ */ new Map();
|
|
57881
|
+
const laterKeys = /* @__PURE__ */ new Map();
|
|
57385
57882
|
for (let i = n - 1; i >= 0; i -= 1) {
|
|
57386
|
-
|
|
57387
|
-
if (
|
|
57388
|
-
|
|
57883
|
+
const message = messages[i];
|
|
57884
|
+
if (richContent[i])
|
|
57885
|
+
continue;
|
|
57886
|
+
const own2 = features[i];
|
|
57887
|
+
const sameRole = laterSignatures.get(message.role) ?? [];
|
|
57888
|
+
const sameRoleKeys = laterKeys.get(message.role) ?? /* @__PURE__ */ new Set();
|
|
57889
|
+
let redundancy = 0;
|
|
57890
|
+
if (!isEmptySignature(own2.signature)) {
|
|
57891
|
+
if (sameRoleKeys.has(own2.signatureKey))
|
|
57892
|
+
redundancy = 1;
|
|
57893
|
+
else {
|
|
57894
|
+
for (const other of sameRole) {
|
|
57895
|
+
const sim = similarityAtLeast(own2.signature, other, floor);
|
|
57896
|
+
if (sim > redundancy)
|
|
57897
|
+
redundancy = sim;
|
|
57898
|
+
}
|
|
57899
|
+
}
|
|
57900
|
+
}
|
|
57901
|
+
redundancyOf[i] = redundancy;
|
|
57902
|
+
sameRole.push(own2.signature);
|
|
57903
|
+
sameRoleKeys.add(own2.signatureKey);
|
|
57904
|
+
laterSignatures.set(message.role, sameRole);
|
|
57905
|
+
laterKeys.set(message.role, sameRoleKeys);
|
|
57389
57906
|
}
|
|
57390
57907
|
const protectedBy = new Array(n).fill(null);
|
|
57391
57908
|
let floorEnd = 0;
|
|
@@ -57441,28 +57958,20 @@ function scoreMessages(messages, options) {
|
|
|
57441
57958
|
const relevance = maxRelevance > 0 ? rawRelevance[i] / maxRelevance : 0;
|
|
57442
57959
|
let utility = 0;
|
|
57443
57960
|
if (message.role === "user") {
|
|
57444
|
-
const
|
|
57445
|
-
utility = citable
|
|
57961
|
+
const own2 = features[i];
|
|
57962
|
+
utility = own2.citable.size > 0 || own2.tokenCount >= 6 ? 1 : 0.2;
|
|
57446
57963
|
} else if (message.role === "tool") {
|
|
57447
|
-
|
|
57448
|
-
|
|
57449
|
-
|
|
57450
|
-
|
|
57451
|
-
|
|
57452
|
-
|
|
57964
|
+
let cited = false;
|
|
57965
|
+
for (const token of features[i].citable) {
|
|
57966
|
+
if ((lastCited.get(token) ?? -1) > i) {
|
|
57967
|
+
cited = true;
|
|
57968
|
+
break;
|
|
57969
|
+
}
|
|
57970
|
+
}
|
|
57971
|
+
utility = cited ? 1 : 0;
|
|
57453
57972
|
} else if (isAssistantWithCalls2(message))
|
|
57454
57973
|
utility = 0.5;
|
|
57455
|
-
let redundancy =
|
|
57456
|
-
const signature = signatures[i];
|
|
57457
|
-
if (!richContent[i] && !isEmptySignature(signature)) {
|
|
57458
|
-
for (let j = i + 1; j < n; j += 1) {
|
|
57459
|
-
if (richContent[j] || messages[j].role !== message.role)
|
|
57460
|
-
continue;
|
|
57461
|
-
const sim = similarity(signature, signatures[j]);
|
|
57462
|
-
if (sim > redundancy)
|
|
57463
|
-
redundancy = sim;
|
|
57464
|
-
}
|
|
57465
|
-
}
|
|
57974
|
+
let redundancy = redundancyOf[i];
|
|
57466
57975
|
if (redundancy < config2.duplicateThreshold)
|
|
57467
57976
|
redundancy = redundancy >= 0.5 ? redundancy : 0;
|
|
57468
57977
|
else
|
|
@@ -57475,7 +57984,7 @@ function scoreMessages(messages, options) {
|
|
|
57475
57984
|
const call2 = (producer.toolCalls ?? []).find((c) => c.id === message.toolCallId);
|
|
57476
57985
|
if (call2) {
|
|
57477
57986
|
const key6 = `${call2.function.name}:${call2.function.arguments}`;
|
|
57478
|
-
if (
|
|
57987
|
+
if ((lastCalled.get(key6) ?? -1) > i)
|
|
57479
57988
|
redundancy = 1;
|
|
57480
57989
|
break;
|
|
57481
57990
|
}
|
|
@@ -57510,10 +58019,7 @@ function isStubbedNarration(content) {
|
|
|
57510
58019
|
return typeof content === "string" && content.includes(STUB_MARK);
|
|
57511
58020
|
}
|
|
57512
58021
|
__name(isStubbedNarration, "isStubbedNarration");
|
|
57513
|
-
function
|
|
57514
|
-
const minTool = options.minToolResultChars ?? 1e3;
|
|
57515
|
-
const minNarration = options.minNarrationChars ?? 240;
|
|
57516
|
-
const preserve = new Set(options.preserveTools ?? []);
|
|
58022
|
+
function evictionRules(messages, options) {
|
|
57517
58023
|
const toolNameByCallId = /* @__PURE__ */ new Map();
|
|
57518
58024
|
for (const m of messages) {
|
|
57519
58025
|
if (m.role !== "assistant")
|
|
@@ -57522,38 +58028,80 @@ function planWorkingSet(messages, scored, options) {
|
|
|
57522
58028
|
toolNameByCallId.set(call2.id, call2.function.name);
|
|
57523
58029
|
}
|
|
57524
58030
|
}
|
|
58031
|
+
return {
|
|
58032
|
+
minTool: options.minToolResultChars ?? 1e3,
|
|
58033
|
+
minNarration: options.minNarrationChars ?? 240,
|
|
58034
|
+
preserve: new Set(options.preserveTools ?? []),
|
|
58035
|
+
toolNameByCallId
|
|
58036
|
+
};
|
|
58037
|
+
}
|
|
58038
|
+
__name(evictionRules, "evictionRules");
|
|
58039
|
+
function evictionKind(m, tokens, rules) {
|
|
58040
|
+
if (tokens === 0)
|
|
58041
|
+
return null;
|
|
58042
|
+
if (m.role === "tool") {
|
|
58043
|
+
const tool = m;
|
|
58044
|
+
if (tool.isError || isClearedToolResult(tool.content))
|
|
58045
|
+
return null;
|
|
58046
|
+
if (rules.preserve.has(rules.toolNameByCallId.get(tool.toolCallId) ?? ""))
|
|
58047
|
+
return null;
|
|
58048
|
+
if (tokens * CHARS_PER_TOKEN < rules.minTool)
|
|
58049
|
+
return null;
|
|
58050
|
+
return "clear";
|
|
58051
|
+
}
|
|
58052
|
+
if (m.role === "assistant" && !Array.isArray(m.toolCalls)) {
|
|
58053
|
+
const text9 = typeof m.content === "string" ? m.content : "";
|
|
58054
|
+
if (text9.length < rules.minNarration || isStubbedNarration(text9))
|
|
58055
|
+
return null;
|
|
58056
|
+
return "stub";
|
|
58057
|
+
}
|
|
58058
|
+
return null;
|
|
58059
|
+
}
|
|
58060
|
+
__name(evictionKind, "evictionKind");
|
|
58061
|
+
function hasEvictableMessage(messages, options) {
|
|
58062
|
+
const rules = evictionRules(messages, options);
|
|
58063
|
+
let floorEnd = 0;
|
|
58064
|
+
while (floorEnd < messages.length && messages[floorEnd]?.role === "system")
|
|
58065
|
+
floorEnd += 1;
|
|
58066
|
+
const end = Math.max(floorEnd, messages.length - options.keepRecentMessages);
|
|
58067
|
+
for (let i = floorEnd; i < end; i += 1) {
|
|
58068
|
+
const m = messages[i];
|
|
58069
|
+
if (evictionKind(m, estimateMessageTokens(m), rules) !== null)
|
|
58070
|
+
return true;
|
|
58071
|
+
}
|
|
58072
|
+
return false;
|
|
58073
|
+
}
|
|
58074
|
+
__name(hasEvictableMessage, "hasEvictableMessage");
|
|
58075
|
+
function planNothingToShed(messages, options) {
|
|
58076
|
+
return {
|
|
58077
|
+
messages: [...messages],
|
|
58078
|
+
actions: [],
|
|
58079
|
+
clearedCount: 0,
|
|
58080
|
+
stubbedCount: 0,
|
|
58081
|
+
charsReclaimed: 0,
|
|
58082
|
+
reclaimedTokens: 0,
|
|
58083
|
+
reachedTarget: options.estimatedTokens - options.targetTokens <= 0
|
|
58084
|
+
};
|
|
58085
|
+
}
|
|
58086
|
+
__name(planNothingToShed, "planNothingToShed");
|
|
58087
|
+
function planWorkingSet(messages, scored, options) {
|
|
58088
|
+
const rules = evictionRules(messages, options);
|
|
58089
|
+
const { toolNameByCallId } = rules;
|
|
57525
58090
|
const candidates = [];
|
|
57526
58091
|
for (const s of scored) {
|
|
57527
|
-
if (s.protected !== null
|
|
58092
|
+
if (s.protected !== null)
|
|
57528
58093
|
continue;
|
|
57529
58094
|
const m = messages[s.index];
|
|
57530
|
-
|
|
57531
|
-
|
|
57532
|
-
|
|
57533
|
-
|
|
57534
|
-
|
|
57535
|
-
|
|
57536
|
-
|
|
57537
|
-
|
|
57538
|
-
|
|
57539
|
-
|
|
57540
|
-
kind: "clear",
|
|
57541
|
-
salience: s.salience,
|
|
57542
|
-
tokens: s.tokens,
|
|
57543
|
-
goalBound: s.relevance >= 0.5 || s.utility >= 1
|
|
57544
|
-
});
|
|
57545
|
-
} else if (m.role === "assistant" && !Array.isArray(m.toolCalls)) {
|
|
57546
|
-
const text9 = typeof m.content === "string" ? m.content : "";
|
|
57547
|
-
if (text9.length < minNarration || isStubbedNarration(text9))
|
|
57548
|
-
continue;
|
|
57549
|
-
candidates.push({
|
|
57550
|
-
index: s.index,
|
|
57551
|
-
kind: "stub",
|
|
57552
|
-
salience: s.salience,
|
|
57553
|
-
tokens: s.tokens,
|
|
57554
|
-
goalBound: s.relevance >= 0.5 || s.utility >= 1
|
|
57555
|
-
});
|
|
57556
|
-
}
|
|
58095
|
+
const kind = evictionKind(m, s.tokens, rules);
|
|
58096
|
+
if (kind === null)
|
|
58097
|
+
continue;
|
|
58098
|
+
candidates.push({
|
|
58099
|
+
index: s.index,
|
|
58100
|
+
kind,
|
|
58101
|
+
salience: s.salience,
|
|
58102
|
+
tokens: s.tokens,
|
|
58103
|
+
goalBound: s.relevance >= 0.5 || s.utility >= 1
|
|
58104
|
+
});
|
|
57557
58105
|
}
|
|
57558
58106
|
candidates.sort((a, b) => a.salience - b.salience || b.tokens - a.tokens || a.index - b.index);
|
|
57559
58107
|
const maxSalience = candidates.reduce((m, c) => Math.max(m, c.salience), Number.NEGATIVE_INFINITY);
|
|
@@ -57627,21 +58175,34 @@ function naiveKeepStartByTokens(messages, budgetTokens) {
|
|
|
57627
58175
|
}
|
|
57628
58176
|
__name(naiveKeepStartByTokens, "naiveKeepStartByTokens");
|
|
57629
58177
|
var DEFAULT_SOFT_TARGET = 0.5;
|
|
57630
|
-
function
|
|
57631
|
-
const
|
|
57632
|
-
const
|
|
57633
|
-
|
|
57634
|
-
|
|
57635
|
-
|
|
57636
|
-
|
|
58178
|
+
function salienceTargetTokens(config2, windowTokens) {
|
|
58179
|
+
const soft = config2.softTarget ?? DEFAULT_SOFT_TARGET;
|
|
58180
|
+
const headroom = config2.softTargetHeadroom ?? 0;
|
|
58181
|
+
return Math.floor(windowTokens * (headroom > 0 ? Math.max(0, soft - headroom) : soft));
|
|
58182
|
+
}
|
|
58183
|
+
__name(salienceTargetTokens, "salienceTargetTokens");
|
|
58184
|
+
function canShedSalienceWorkingSet(messages, config2) {
|
|
58185
|
+
return hasEvictableMessage(messages, {
|
|
58186
|
+
minToolResultChars: config2.minToolResultCharsToClear,
|
|
58187
|
+
...config2.preserveToolResultsFrom ? { preserveTools: config2.preserveToolResultsFrom } : {},
|
|
57637
58188
|
keepRecentMessages: config2.keepRecentMessages
|
|
57638
58189
|
});
|
|
57639
|
-
|
|
58190
|
+
}
|
|
58191
|
+
__name(canShedSalienceWorkingSet, "canShedSalienceWorkingSet");
|
|
58192
|
+
function planSalienceWorkingSet(input2) {
|
|
58193
|
+
const { config: config2, estimatedTokens, contextWindowTokens: budget } = input2;
|
|
58194
|
+
const workingOptions = {
|
|
57640
58195
|
estimatedTokens,
|
|
57641
|
-
targetTokens:
|
|
58196
|
+
targetTokens: salienceTargetTokens(config2, budget),
|
|
57642
58197
|
minToolResultChars: config2.minToolResultCharsToClear,
|
|
57643
58198
|
...config2.preserveToolResultsFrom ? { preserveTools: config2.preserveToolResultsFrom } : {}
|
|
57644
|
-
}
|
|
58199
|
+
};
|
|
58200
|
+
const working = canShedSalienceWorkingSet(input2.messages, config2) ? planWorkingSet(input2.messages, scoreMessages(input2.messages, {
|
|
58201
|
+
goal: buildGoal(input2.messages, {
|
|
58202
|
+
...input2.openTasks ? { openTasks: input2.openTasks } : {}
|
|
58203
|
+
}),
|
|
58204
|
+
keepRecentMessages: config2.keepRecentMessages
|
|
58205
|
+
}), workingOptions) : planNothingToShed(input2.messages, workingOptions);
|
|
57645
58206
|
return {
|
|
57646
58207
|
kind: "cleared",
|
|
57647
58208
|
messages: working.messages,
|
|
@@ -58633,6 +59194,9 @@ async function runCompactionCheckInner(ctx, pass, options) {
|
|
|
58633
59194
|
const startAt = salience ? Math.min(config2.softTarget ?? DEFAULT_SOFT_TARGET, trigger) : trigger;
|
|
58634
59195
|
if (!options?.force && usage < startAt)
|
|
58635
59196
|
return;
|
|
59197
|
+
if (salience && !options?.force && !ctx.contextReducer && usage < trigger && !canShedSalienceWorkingSet(ctx.recorder.messages, config2)) {
|
|
59198
|
+
return;
|
|
59199
|
+
}
|
|
58636
59200
|
const breaker2 = compactionBreaker(ctx);
|
|
58637
59201
|
if (breaker2?.failuresOpen && !options?.force) {
|
|
58638
59202
|
if (breaker2.takeFailureNotice()) {
|
|
@@ -59424,7 +59988,7 @@ __name(runPlanGate, "runPlanGate");
|
|
|
59424
59988
|
var DECLINED_TOOL_CALL_FEEDBACK = "The user declined this. Do not get the same content or result another way (another tool, another site or address, or a web search) unless you ask the user first and they agree. Say what you wanted to do, or carry on without it.";
|
|
59425
59989
|
|
|
59426
59990
|
// ../sdk/dist/runtime/query/project-instructions.js
|
|
59427
|
-
import { isDeepStrictEqual as
|
|
59991
|
+
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
59428
59992
|
async function awaitProjectInstructionCallback(signal, start) {
|
|
59429
59993
|
signal.throwIfAborted();
|
|
59430
59994
|
return new Promise((resolve37, reject2) => {
|
|
@@ -59517,7 +60081,7 @@ function canonical(message) {
|
|
|
59517
60081
|
}
|
|
59518
60082
|
__name(canonical, "canonical");
|
|
59519
60083
|
function sameProjectInstructionSnapshot(a, b) {
|
|
59520
|
-
return
|
|
60084
|
+
return isDeepStrictEqual3(canonical(a), canonical(b));
|
|
59521
60085
|
}
|
|
59522
60086
|
__name(sameProjectInstructionSnapshot, "sameProjectInstructionSnapshot");
|
|
59523
60087
|
function latestProjectInstructionSnapshot(messages) {
|
|
@@ -59586,7 +60150,7 @@ function replaceProjectInstructionSnapshot(messages, snapshot, placement = "appe
|
|
|
59586
60150
|
__name(replaceProjectInstructionSnapshot, "replaceProjectInstructionSnapshot");
|
|
59587
60151
|
|
|
59588
60152
|
// ../sdk/dist/runtime/query/repeat-call.js
|
|
59589
|
-
import { createHash as
|
|
60153
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
59590
60154
|
|
|
59591
60155
|
// ../sdk/dist/runtime/query/tool-grants.js
|
|
59592
60156
|
function toolGrantKeys(call2) {
|
|
@@ -59695,7 +60259,7 @@ var RepeatCallTracker = class {
|
|
|
59695
60259
|
this.failures.delete(key6);
|
|
59696
60260
|
return;
|
|
59697
60261
|
}
|
|
59698
|
-
const fingerprint =
|
|
60262
|
+
const fingerprint = createHash16("sha256").update(stableStringify(outcome.result ?? null)).digest("hex");
|
|
59699
60263
|
const previous = this.failures.get(key6);
|
|
59700
60264
|
this.failures.set(key6, {
|
|
59701
60265
|
fingerprint,
|
|
@@ -62598,9 +63162,9 @@ import { homedir } from "node:os";
|
|
|
62598
63162
|
import { basename as basename6, isAbsolute as isAbsolute6, join as join15, resolve as resolve6 } from "node:path";
|
|
62599
63163
|
|
|
62600
63164
|
// ../sdk/dist/tools/builtins/content-fingerprint.js
|
|
62601
|
-
import { createHash as
|
|
63165
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
62602
63166
|
function fingerprintContent(content) {
|
|
62603
|
-
return
|
|
63167
|
+
return createHash17("sha256").update(content, "utf-8").digest("hex").slice(0, 16);
|
|
62604
63168
|
}
|
|
62605
63169
|
__name(fingerprintContent, "fingerprintContent");
|
|
62606
63170
|
function staleFileError(path2, operation = "edit") {
|
|
@@ -64884,7 +65448,7 @@ function createReviewPolicy(options = {}) {
|
|
|
64884
65448
|
__name(createReviewPolicy, "createReviewPolicy");
|
|
64885
65449
|
|
|
64886
65450
|
// ../sdk/dist/runtime/query/executor.js
|
|
64887
|
-
import { createHash as
|
|
65451
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
64888
65452
|
import { isAbsolute as isAbsolute11, join as join20, resolve as resolve12 } from "node:path";
|
|
64889
65453
|
|
|
64890
65454
|
// ../sdk/dist/probe/context.js
|
|
@@ -66051,7 +66615,7 @@ async function cropAndFitPng(data, rect, limits) {
|
|
|
66051
66615
|
__name(cropAndFitPng, "cropAndFitPng");
|
|
66052
66616
|
|
|
66053
66617
|
// ../sdk/dist/tools/builtins/view-image.js
|
|
66054
|
-
import { createHash as
|
|
66618
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
66055
66619
|
import { open as open10 } from "node:fs/promises";
|
|
66056
66620
|
import { inflateSync } from "node:zlib";
|
|
66057
66621
|
|
|
@@ -66671,7 +67235,7 @@ ${validation === "container" ? "The complete container and dimensions were valid
|
|
|
66671
67235
|
width: image.width,
|
|
66672
67236
|
height: image.height,
|
|
66673
67237
|
sourceBytes: artifact.bytes.length,
|
|
66674
|
-
sha256:
|
|
67238
|
+
sha256: createHash18("sha256").update(artifact.bytes).digest("hex"),
|
|
66675
67239
|
validation
|
|
66676
67240
|
}
|
|
66677
67241
|
};
|
|
@@ -69377,7 +69941,7 @@ import { mkdir as mkdir9, readFile as readFile10 } from "node:fs/promises";
|
|
|
69377
69941
|
import { dirname as dirname13 } from "node:path";
|
|
69378
69942
|
|
|
69379
69943
|
// ../sdk/dist/tools/builtins/file-write-result.js
|
|
69380
|
-
import { createHash as
|
|
69944
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
69381
69945
|
function previewSide(hunks2, changed) {
|
|
69382
69946
|
return hunks2.flatMap((hunk) => hunk.lines).filter((row) => row.startsWith(" ") || row.startsWith(changed)).map((row) => `${row.slice(1)}
|
|
69383
69947
|
`).join("");
|
|
@@ -69419,7 +69983,7 @@ function fileWriteResult(path2, before, after, sandboxed = false) {
|
|
|
69419
69983
|
}
|
|
69420
69984
|
},
|
|
69421
69985
|
bytes,
|
|
69422
|
-
sha256:
|
|
69986
|
+
sha256: createHash19("sha256").update(after, "utf8").digest("hex"),
|
|
69423
69987
|
...before === null ? {} : { added: diff.added, removed: diff.removed, newlineChanged }
|
|
69424
69988
|
}
|
|
69425
69989
|
}
|
|
@@ -70683,7 +71247,7 @@ var ToolExecutor = class {
|
|
|
70683
71247
|
return recorded !== void 0 && message.toolCallId === call2.id && !message.isError && typeof message.content === "string" && this.config.tools.get(recorded.toolName) === recorded.definition && recorded.fingerprint === this.observationFingerprint(call2, message.content) ? recorded.inputFingerprint : void 0;
|
|
70684
71248
|
}
|
|
70685
71249
|
observationFingerprint(call2, content) {
|
|
70686
|
-
return
|
|
71250
|
+
return createHash20("sha256").update(JSON.stringify([call2.function.name, call2.function.arguments, content])).digest("hex");
|
|
70687
71251
|
}
|
|
70688
71252
|
recordExecutedObservation(call2, toolName, definition, input2, content) {
|
|
70689
71253
|
if (typeof content !== "string" || this.config.tools.get(toolName) !== definition)
|
|
@@ -70695,7 +71259,7 @@ var ToolExecutor = class {
|
|
|
70695
71259
|
toolName,
|
|
70696
71260
|
definition,
|
|
70697
71261
|
fingerprint: this.observationFingerprint(call2, content),
|
|
70698
|
-
inputFingerprint:
|
|
71262
|
+
inputFingerprint: createHash20("sha256").update(JSON.stringify([toolName, input2])).digest("hex")
|
|
70699
71263
|
});
|
|
70700
71264
|
} catch {
|
|
70701
71265
|
}
|
|
@@ -72946,7 +73510,7 @@ function inputPathOf(call2) {
|
|
|
72946
73510
|
__name(inputPathOf, "inputPathOf");
|
|
72947
73511
|
|
|
72948
73512
|
// ../sdk/dist/runtime/query/resume-pending.js
|
|
72949
|
-
import { isDeepStrictEqual as
|
|
73513
|
+
import { isDeepStrictEqual as isDeepStrictEqual4 } from "node:util";
|
|
72950
73514
|
|
|
72951
73515
|
// ../sdk/dist/runtime/query/question-park.js
|
|
72952
73516
|
var QuestionParkBinding = class {
|
|
@@ -73420,7 +73984,7 @@ async function applyPendingResume(plan, recorder, executor, prior, assistantMess
|
|
|
73420
73984
|
const reviewed = reviewedById.get(call2.id);
|
|
73421
73985
|
const wasModified = plan.modifiedCallIds?.has(call2.id) === true;
|
|
73422
73986
|
if (reviewed && !wasModified) {
|
|
73423
|
-
const unchanged = reviewed.name === call2.name &&
|
|
73987
|
+
const unchanged = reviewed.name === call2.name && isDeepStrictEqual4(reviewed.input, call2.input);
|
|
73424
73988
|
if (!unchanged) {
|
|
73425
73989
|
const reason2 = "The tool input changed after its durable review; the earlier approval cannot be reused.";
|
|
73426
73990
|
denials.set(call2.id, reason2);
|
|
@@ -78494,7 +79058,7 @@ function enforcedModelInputToolNames(registry2, tools) {
|
|
|
78494
79058
|
__name(enforcedModelInputToolNames, "enforcedModelInputToolNames");
|
|
78495
79059
|
|
|
78496
79060
|
// ../sdk/dist/runtime/query/prepare-turn.js
|
|
78497
|
-
import { isDeepStrictEqual as
|
|
79061
|
+
import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
|
|
78498
79062
|
|
|
78499
79063
|
// ../sdk/dist/provider/retry.js
|
|
78500
79064
|
var gaveUpEarly = /* @__PURE__ */ new WeakMap();
|
|
@@ -79690,7 +80254,7 @@ import { lstat as lstat4 } from "node:fs/promises";
|
|
|
79690
80254
|
import { resolve as resolve13 } from "node:path";
|
|
79691
80255
|
|
|
79692
80256
|
// ../sdk/dist/store/evidence/index-page.js
|
|
79693
|
-
import { createHash as
|
|
80257
|
+
import { createHash as createHash21, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
79694
80258
|
|
|
79695
80259
|
// ../sdk/dist/store/evidence/compaction-provenance.js
|
|
79696
80260
|
function record2(value) {
|
|
@@ -79805,7 +80369,7 @@ var positionSchema = external_exports.object({
|
|
|
79805
80369
|
textIndex: integer3.default(0)
|
|
79806
80370
|
});
|
|
79807
80371
|
function evidenceSeal(sessionStart, sourceKey) {
|
|
79808
|
-
const key6 =
|
|
80372
|
+
const key6 = createHash21("sha256").update("namzu-session-evidence-v1\n").update(sessionStart).digest();
|
|
79809
80373
|
const mac3 = /* @__PURE__ */ __name((value) => createHmac2("sha256", key6).update(`${sourceKey}
|
|
79810
80374
|
${value}`).digest(), "mac");
|
|
79811
80375
|
return {
|
|
@@ -79899,7 +80463,7 @@ async function indexPage(handle, size, sessionId5, start, budget) {
|
|
|
79899
80463
|
const parts = recordTexts(record4);
|
|
79900
80464
|
if (textIndex > parts.length)
|
|
79901
80465
|
throw new Error("Invalid textual part position.");
|
|
79902
|
-
const
|
|
80466
|
+
const hash4 = digest2(raw);
|
|
79903
80467
|
const tool = toolEntry(record4, offset, raw);
|
|
79904
80468
|
records4++;
|
|
79905
80469
|
while (textIndex < parts.length && entries2.length < 64) {
|
|
@@ -79909,7 +80473,7 @@ async function indexPage(handle, size, sessionId5, start, budget) {
|
|
|
79909
80473
|
entries2.push(tool ?? entrySchema.parse({
|
|
79910
80474
|
offset,
|
|
79911
80475
|
length: raw.length,
|
|
79912
|
-
sha256:
|
|
80476
|
+
sha256: hash4,
|
|
79913
80477
|
seq: record4.seq,
|
|
79914
80478
|
...typeof record4.turnId === "string" ? { turnId: record4.turnId } : {},
|
|
79915
80479
|
source: part2.source,
|
|
@@ -81990,7 +82554,7 @@ var InMemorySessionTokenBudgetStore = class {
|
|
|
81990
82554
|
};
|
|
81991
82555
|
|
|
81992
82556
|
// ../sdk/dist/store/checkpoint/contract.js
|
|
81993
|
-
import { createHash as
|
|
82557
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
81994
82558
|
var CheckpointIntegrityError = class extends Error {
|
|
81995
82559
|
static {
|
|
81996
82560
|
__name(this, "CheckpointIntegrityError");
|
|
@@ -82025,7 +82589,7 @@ function serializeCheckpoint(checkpoint) {
|
|
|
82025
82589
|
}
|
|
82026
82590
|
__name(serializeCheckpoint, "serializeCheckpoint");
|
|
82027
82591
|
function sha256Hex5(text9) {
|
|
82028
|
-
return
|
|
82592
|
+
return createHash22("sha256").update(text9, "utf8").digest("hex");
|
|
82029
82593
|
}
|
|
82030
82594
|
__name(sha256Hex5, "sha256Hex");
|
|
82031
82595
|
function checkpointRecordPath(checkpointId4) {
|
|
@@ -83068,7 +83632,7 @@ __name(projectRecordedHistory, "projectRecordedHistory");
|
|
|
83068
83632
|
function sameMessageContent(a, b) {
|
|
83069
83633
|
const { id: _a4, timestamp: _ta, ...restA } = a;
|
|
83070
83634
|
const { id: _b, timestamp: _tb, ...restB } = b;
|
|
83071
|
-
return
|
|
83635
|
+
return isDeepStrictEqual5(JSON.parse(JSON.stringify(restA)), JSON.parse(JSON.stringify(restB)));
|
|
83072
83636
|
}
|
|
83073
83637
|
__name(sameMessageContent, "sameMessageContent");
|
|
83074
83638
|
function staleCachedHistoryError(kind, message) {
|
|
@@ -83115,7 +83679,8 @@ function reconcileNoIdAgainstFold(caller, pool, hasId) {
|
|
|
83115
83679
|
__name(reconcileNoIdAgainstFold, "reconcileNoIdAgainstFold");
|
|
83116
83680
|
async function reconcileCallerMessages(messages, history, log, continuationMode) {
|
|
83117
83681
|
const hasId = messages.some((message) => message.id !== void 0);
|
|
83118
|
-
const
|
|
83682
|
+
const everRecorded = hasId ? await readEverRecordedMessageIndex(log) : void 0;
|
|
83683
|
+
const recordedById = everRecorded?.latest;
|
|
83119
83684
|
const claimedIds = /* @__PURE__ */ new Set();
|
|
83120
83685
|
const noIdIndices = [];
|
|
83121
83686
|
const noIdMessages = [];
|
|
@@ -83126,8 +83691,10 @@ async function reconcileCallerMessages(messages, history, log, continuationMode)
|
|
|
83126
83691
|
const recorded = recordedById?.get(id3);
|
|
83127
83692
|
if (recorded === void 0)
|
|
83128
83693
|
throw staleCachedHistoryError("foreign", message);
|
|
83129
|
-
if (!sameMessageContent(recorded, message))
|
|
83130
|
-
|
|
83694
|
+
if (!sameMessageContent(recorded, message)) {
|
|
83695
|
+
if (!await everRecorded?.heldBeforeAnEdit(id3, message))
|
|
83696
|
+
throw staleCachedHistoryError("edited", message);
|
|
83697
|
+
}
|
|
83131
83698
|
claimedIds.add(id3);
|
|
83132
83699
|
continue;
|
|
83133
83700
|
}
|
|
@@ -84260,7 +84827,10 @@ ${annotations.join("\n\n")}`, "render")
|
|
|
84260
84827
|
}, "pushSystemMessages");
|
|
84261
84828
|
const pushRestored = /* @__PURE__ */ __name((message, ids) => {
|
|
84262
84829
|
const messageId4 = ids.get(message);
|
|
84263
|
-
ctx.recorder.pushMessage(message,
|
|
84830
|
+
ctx.recorder.pushMessage(message, {
|
|
84831
|
+
...messageId4 ? { messageId: messageId4 } : {},
|
|
84832
|
+
restored: true
|
|
84833
|
+
});
|
|
84264
84834
|
}, "pushRestored");
|
|
84265
84835
|
if (params.resumeFromCheckpoint) {
|
|
84266
84836
|
const checkpoint = await checkpointMgr.restore(params.resumeFromCheckpoint);
|
|
@@ -85139,7 +85709,7 @@ async function startBidiTurn(params) {
|
|
|
85139
85709
|
__name(startBidiTurn, "startBidiTurn");
|
|
85140
85710
|
|
|
85141
85711
|
// ../sdk/dist/runtime/query/prompt-cache.js
|
|
85142
|
-
import { createHash as
|
|
85712
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
85143
85713
|
var PromptCache = class {
|
|
85144
85714
|
static {
|
|
85145
85715
|
__name(this, "PromptCache");
|
|
@@ -85167,12 +85737,12 @@ var PromptCache = class {
|
|
|
85167
85737
|
...input2.contributions ? { contributions: input2.contributions } : {}
|
|
85168
85738
|
});
|
|
85169
85739
|
const prompt = builder.build();
|
|
85170
|
-
const
|
|
85171
|
-
if (this.cachedPrompt !== void 0 && this.cachedConfigHash ===
|
|
85740
|
+
const hash4 = this.computeConfigHash(input2, prompt);
|
|
85741
|
+
if (this.cachedPrompt !== void 0 && this.cachedConfigHash === hash4) {
|
|
85172
85742
|
return this.cachedPrompt;
|
|
85173
85743
|
}
|
|
85174
85744
|
this.cachedPrompt = prompt;
|
|
85175
|
-
this.cachedConfigHash =
|
|
85745
|
+
this.cachedConfigHash = hash4;
|
|
85176
85746
|
return this.cachedPrompt;
|
|
85177
85747
|
}
|
|
85178
85748
|
get configHash() {
|
|
@@ -85214,7 +85784,7 @@ var PromptCache = class {
|
|
|
85214
85784
|
this.cachedStaticHash = void 0;
|
|
85215
85785
|
}
|
|
85216
85786
|
computeStaticHash(staticSegment) {
|
|
85217
|
-
return
|
|
85787
|
+
return createHash23("sha256").update(staticSegment).digest("hex").slice(0, 16);
|
|
85218
85788
|
}
|
|
85219
85789
|
computeConfigHash(input2, prompt) {
|
|
85220
85790
|
const parts = [
|
|
@@ -85224,7 +85794,7 @@ var PromptCache = class {
|
|
|
85224
85794
|
// unsegmented text happens to be identical.
|
|
85225
85795
|
input2.contributions?.list().map((c) => [c.id, c.placement]) ?? []
|
|
85226
85796
|
];
|
|
85227
|
-
return
|
|
85797
|
+
return createHash23("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 16);
|
|
85228
85798
|
}
|
|
85229
85799
|
};
|
|
85230
85800
|
|
|
@@ -88791,7 +89361,7 @@ var LocalExecutionContext = class extends BaseExecutionContext {
|
|
|
88791
89361
|
};
|
|
88792
89362
|
|
|
88793
89363
|
// ../sdk/dist/turn/workspace-fingerprint.js
|
|
88794
|
-
import { createHash as
|
|
89364
|
+
import { createHash as createHash24 } from "node:crypto";
|
|
88795
89365
|
import { lstat as lstat5, readFile as readFile13, readlink } from "node:fs/promises";
|
|
88796
89366
|
import { join as join27 } from "node:path";
|
|
88797
89367
|
var NODE_FS = { lstat: lstat5, readlink, readFile: readFile13 };
|
|
@@ -88807,7 +89377,7 @@ async function untrackedEntry(cwd, rel, fs) {
|
|
|
88807
89377
|
if (!stats.isFile())
|
|
88808
89378
|
return `? ${rel}`;
|
|
88809
89379
|
const body = await fs.readFile(abs);
|
|
88810
|
-
return `F ${rel}\0${
|
|
89380
|
+
return `F ${rel}\0${createHash24("sha256").update(body).digest("hex")}`;
|
|
88811
89381
|
} catch {
|
|
88812
89382
|
return null;
|
|
88813
89383
|
}
|
|
@@ -88852,10 +89422,10 @@ async function fingerprintWorkspace(options) {
|
|
|
88852
89422
|
return null;
|
|
88853
89423
|
parts.push(entry);
|
|
88854
89424
|
}
|
|
88855
|
-
const
|
|
89425
|
+
const hash4 = createHash24("sha256");
|
|
88856
89426
|
for (const part2 of parts)
|
|
88857
|
-
|
|
88858
|
-
return
|
|
89427
|
+
hash4.update(`${Buffer.byteLength(part2, "utf8")}:${part2}`);
|
|
89428
|
+
return hash4.digest("hex");
|
|
88859
89429
|
}
|
|
88860
89430
|
__name(fingerprintWorkspace, "fingerprintWorkspace");
|
|
88861
89431
|
|
|
@@ -89082,7 +89652,7 @@ function createMemoryPromoter(options) {
|
|
|
89082
89652
|
__name(createMemoryPromoter, "createMemoryPromoter");
|
|
89083
89653
|
|
|
89084
89654
|
// ../sdk/dist/turn/json-claim-verifier.js
|
|
89085
|
-
import { createHash as
|
|
89655
|
+
import { createHash as createHash25, randomUUID as randomUUID5 } from "node:crypto";
|
|
89086
89656
|
import { performance as performance2 } from "node:perf_hooks";
|
|
89087
89657
|
function scalar(value) {
|
|
89088
89658
|
return value === null || typeof value === "boolean" || typeof value === "string" && value.length <= 2e3 || typeof value === "number" && Number.isSafeInteger(value);
|
|
@@ -89215,7 +89785,7 @@ function createJsonClaimVerifier(options) {
|
|
|
89215
89785
|
requestId: request.requestId,
|
|
89216
89786
|
observedAt: observation.observedAt,
|
|
89217
89787
|
bytes: bytes.byteLength,
|
|
89218
|
-
sha256:
|
|
89788
|
+
sha256: createHash25("sha256").update(bytes).digest("hex")
|
|
89219
89789
|
});
|
|
89220
89790
|
}
|
|
89221
89791
|
ensureActive();
|
|
@@ -91196,7 +91766,7 @@ function deriveTurnOptions(manifest, input2) {
|
|
|
91196
91766
|
__name(deriveTurnOptions, "deriveTurnOptions");
|
|
91197
91767
|
|
|
91198
91768
|
// ../sdk/dist/agents/runAgent.js
|
|
91199
|
-
import { isDeepStrictEqual as
|
|
91769
|
+
import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
|
|
91200
91770
|
|
|
91201
91771
|
// ../sdk/dist/capabilities/index.js
|
|
91202
91772
|
function assertCapabilityId(id3) {
|
|
@@ -91343,7 +91913,7 @@ var DEFAULT_MAX_ITERATIONS = 16;
|
|
|
91343
91913
|
var DEFAULT_TOKEN_BUDGET = 2e5;
|
|
91344
91914
|
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
91345
91915
|
async function runAgent(options) {
|
|
91346
|
-
if (options.verificationGate && options.authorizationGate && !
|
|
91916
|
+
if (options.verificationGate && options.authorizationGate && !isDeepStrictEqual6(options.verificationGate, options.authorizationGate)) {
|
|
91347
91917
|
throw new Error("runAgent: verificationGate and authorizationGate must name the same policy.");
|
|
91348
91918
|
}
|
|
91349
91919
|
const authorizationGate = options.authorizationGate ?? options.verificationGate;
|
|
@@ -94190,7 +94760,7 @@ var DiskTaskStore = class {
|
|
|
94190
94760
|
};
|
|
94191
94761
|
|
|
94192
94762
|
// ../sdk/dist/store/memory/revision.js
|
|
94193
|
-
import { createHash as
|
|
94763
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
94194
94764
|
var MemoryRevisionUnavailableError = class extends Error {
|
|
94195
94765
|
static {
|
|
94196
94766
|
__name(this, "MemoryRevisionUnavailableError");
|
|
@@ -94296,7 +94866,7 @@ function canonicalRecord(record4) {
|
|
|
94296
94866
|
}
|
|
94297
94867
|
__name(canonicalRecord, "canonicalRecord");
|
|
94298
94868
|
function memoryRevision(record4) {
|
|
94299
|
-
return `m2:${
|
|
94869
|
+
return `m2:${createHash26("sha256").update(canonicalRecord(record4)).digest("hex")}`;
|
|
94300
94870
|
}
|
|
94301
94871
|
__name(memoryRevision, "memoryRevision");
|
|
94302
94872
|
var MemoryRevisionConflictError = class extends NamzuError {
|
|
@@ -95056,7 +95626,7 @@ var DiskMemoryStore = class {
|
|
|
95056
95626
|
};
|
|
95057
95627
|
|
|
95058
95628
|
// ../sdk/dist/store/memory/markdown.js
|
|
95059
|
-
import { createHash as
|
|
95629
|
+
import { createHash as createHash27 } from "node:crypto";
|
|
95060
95630
|
import { lstat as lstat8, mkdir as mkdir15, readFile as readFile18, readdir as readdir11, realpath as realpath9, rename as rename6, unlink as unlink12 } from "node:fs/promises";
|
|
95061
95631
|
import { dirname as dirname19, join as join34, resolve as resolve18 } from "node:path";
|
|
95062
95632
|
|
|
@@ -95296,7 +95866,7 @@ function invalidFile(file2, reason, cause) {
|
|
|
95296
95866
|
}
|
|
95297
95867
|
__name(invalidFile, "invalidFile");
|
|
95298
95868
|
function derivedMemoryId(name2) {
|
|
95299
|
-
const hex4 =
|
|
95869
|
+
const hex4 = createHash27("sha256").update(`namzu-memory-name:${name2}`).digest("hex");
|
|
95300
95870
|
const variant = (Number.parseInt(hex4[16] ?? "0", 16) & 3 | 8).toString(16);
|
|
95301
95871
|
return `${hex4.slice(0, 8)}-${hex4.slice(8, 12)}-8${hex4.slice(13, 16)}-${variant}${hex4.slice(17, 20)}-${hex4.slice(20, 32)}`;
|
|
95302
95872
|
}
|
|
@@ -98806,6 +99376,9 @@ var MCPClient = class {
|
|
|
98806
99376
|
log;
|
|
98807
99377
|
config;
|
|
98808
99378
|
requestTimeoutMs;
|
|
99379
|
+
resetTimeoutOnProgress;
|
|
99380
|
+
/** Total cap for a progress-extended call; meaningful only when `resetTimeoutOnProgress`. */
|
|
99381
|
+
maxTotalTimeoutMs;
|
|
98809
99382
|
eraCache;
|
|
98810
99383
|
eraCacheKey;
|
|
98811
99384
|
eraProbeTimeoutMs;
|
|
@@ -98819,9 +99392,26 @@ var MCPClient = class {
|
|
|
98819
99392
|
* it.
|
|
98820
99393
|
*/
|
|
98821
99394
|
toolParamHeaders = /* @__PURE__ */ new Map();
|
|
99395
|
+
/**
|
|
99396
|
+
* The longest a `tools/call` can legitimately take on this client, or
|
|
99397
|
+
* `undefined` when it has only the fixed request deadline.
|
|
99398
|
+
*
|
|
99399
|
+
* Defined only with `resetTimeoutOnProgress`: the total cap. A layer that
|
|
99400
|
+
* bounds the call from outside (the executor's per-tool deadline) needs it
|
|
99401
|
+
* to avoid cutting a call this client would have kept alive.
|
|
99402
|
+
*/
|
|
99403
|
+
getToolCallWindowMs() {
|
|
99404
|
+
return this.resetTimeoutOnProgress ? this.maxTotalTimeoutMs : void 0;
|
|
99405
|
+
}
|
|
98822
99406
|
constructor(config2) {
|
|
98823
99407
|
this.config = config2;
|
|
98824
99408
|
this.requestTimeoutMs = validateConnectorTimeoutMs(config2.requestTimeoutMs ?? DEFAULT_MCP_REQUEST_TIMEOUT_MS, "MCPClient requestTimeoutMs");
|
|
99409
|
+
this.resetTimeoutOnProgress = config2.resetTimeoutOnProgress === true;
|
|
99410
|
+
const maxTotal = validateConnectorTimeoutMs(config2.maxTotalTimeoutMs ?? Math.min(this.requestTimeoutMs * DEFAULT_MCP_TOTAL_TIMEOUT_FACTOR, MAX_TIMER_DELAY_MS), "MCPClient maxTotalTimeoutMs");
|
|
99411
|
+
if (maxTotal < this.requestTimeoutMs) {
|
|
99412
|
+
throw new Error(`MCPClient maxTotalTimeoutMs must not be below requestTimeoutMs (${this.requestTimeoutMs}); received ${maxTotal}`);
|
|
99413
|
+
}
|
|
99414
|
+
this.maxTotalTimeoutMs = maxTotal;
|
|
98825
99415
|
this.eraProbeTimeoutMs = Math.min(validateConnectorTimeoutMs(config2.eraProbeTimeoutMs ?? DEFAULT_MCP_ERA_PROBE_TIMEOUT_MS, "MCPClient eraProbeTimeoutMs"), this.requestTimeoutMs);
|
|
98826
99416
|
this.eraCache = config2.eraCache ?? (config2.transportFactory ? createMcpEraCache() : defaultMcpEraCache);
|
|
98827
99417
|
this.eraCacheKey = mcpEraCacheKey(config2.transport);
|
|
@@ -99585,6 +100175,7 @@ var MCPClient = class {
|
|
|
99585
100175
|
options?.signal?.throwIfAborted();
|
|
99586
100176
|
const id3 = this.nextRequestId++;
|
|
99587
100177
|
const progressToken = method === "tools/call" && options?.onProgress ? randomUUID7() : void 0;
|
|
100178
|
+
const extendable = this.resetTimeoutOnProgress && progressToken !== void 0;
|
|
99588
100179
|
const requestParams = progressToken === void 0 ? params : {
|
|
99589
100180
|
...params,
|
|
99590
100181
|
_meta: {
|
|
@@ -99623,8 +100214,11 @@ var MCPClient = class {
|
|
|
99623
100214
|
const onCallerAbort = /* @__PURE__ */ __name(() => {
|
|
99624
100215
|
settle3("caller", options?.signal?.reason);
|
|
99625
100216
|
}, "onCallerAbort");
|
|
100217
|
+
let idleTimer;
|
|
100218
|
+
let capTimer;
|
|
99626
100219
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
99627
|
-
clearTimeout(
|
|
100220
|
+
clearTimeout(idleTimer);
|
|
100221
|
+
clearTimeout(capTimer);
|
|
99628
100222
|
options?.signal?.removeEventListener("abort", onCallerAbort);
|
|
99629
100223
|
if (this.pendingRequests.get(id3) === entry)
|
|
99630
100224
|
this.pendingRequests.delete(id3);
|
|
@@ -99657,19 +100251,35 @@ var MCPClient = class {
|
|
|
99657
100251
|
entry.reject(reason);
|
|
99658
100252
|
}, "settleSendFailure");
|
|
99659
100253
|
this.pendingRequests.set(id3, entry);
|
|
99660
|
-
|
|
99661
|
-
this.
|
|
99662
|
-
|
|
99663
|
-
|
|
99664
|
-
const error62 = new Error(`MCP request "${method}" to "${this.config.serverName}" timed out after ${this.requestTimeoutMs}ms`);
|
|
100254
|
+
const expire = /* @__PURE__ */ __name((deadline) => {
|
|
100255
|
+
const limit = deadline === "total_cap" ? this.maxTotalTimeoutMs : this.requestTimeoutMs;
|
|
100256
|
+
const what = deadline === "request" ? `timed out after ${limit}ms` : deadline === "idle" ? `timed out after ${limit}ms with no progress` : `timed out at its total limit of ${limit}ms`;
|
|
100257
|
+
const error62 = new Error(`MCP request "${method}" to "${this.config.serverName}" ${what}`);
|
|
99665
100258
|
error62.name = "TimeoutError";
|
|
99666
100259
|
this.log.warn("MCP request timed out", {
|
|
99667
100260
|
"namzu.connector.server": this.config.serverName,
|
|
99668
100261
|
"namzu.connector.method": method,
|
|
99669
|
-
"namzu.connector.timeout_ms":
|
|
100262
|
+
"namzu.connector.timeout_ms": limit,
|
|
100263
|
+
"namzu.connector.deadline": deadline
|
|
99670
100264
|
});
|
|
99671
100265
|
settle3("timeout", error62);
|
|
99672
|
-
},
|
|
100266
|
+
}, "expire");
|
|
100267
|
+
const armIdle = /* @__PURE__ */ __name(() => {
|
|
100268
|
+
clearTimeout(idleTimer);
|
|
100269
|
+
idleTimer = setTimeout(() => expire(extendable ? "idle" : "request"), this.requestTimeoutMs);
|
|
100270
|
+
}, "armIdle");
|
|
100271
|
+
if (progressToken !== void 0 && options?.onProgress) {
|
|
100272
|
+
this.progressRequests.set(progressToken, {
|
|
100273
|
+
onProgress: options.onProgress,
|
|
100274
|
+
// A settled request has already cleared both timers and its
|
|
100275
|
+
// registration, so a late notification cannot re-arm anything.
|
|
100276
|
+
...extendable ? { onAccepted: /* @__PURE__ */ __name(() => !settled && armIdle(), "onAccepted") } : {}
|
|
100277
|
+
});
|
|
100278
|
+
}
|
|
100279
|
+
armIdle();
|
|
100280
|
+
if (extendable) {
|
|
100281
|
+
capTimer = setTimeout(() => expire("total_cap"), this.maxTotalTimeoutMs);
|
|
100282
|
+
}
|
|
99673
100283
|
options?.signal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
99674
100284
|
if (options?.signal?.aborted) {
|
|
99675
100285
|
onCallerAbort();
|
|
@@ -99988,6 +100598,7 @@ var MCPClient = class {
|
|
|
99988
100598
|
if (pending2.lastProgress !== void 0 && progress <= pending2.lastProgress)
|
|
99989
100599
|
return;
|
|
99990
100600
|
pending2.lastProgress = progress;
|
|
100601
|
+
pending2.onAccepted?.();
|
|
99991
100602
|
const total2 = params?.total;
|
|
99992
100603
|
const message = progressMessage(params?.message);
|
|
99993
100604
|
const update2 = {
|
|
@@ -100577,6 +101188,7 @@ function zodToMCPJsonSchema(zodSchema) {
|
|
|
100577
101188
|
__name(zodToMCPJsonSchema, "zodToMCPJsonSchema");
|
|
100578
101189
|
function mcpToolToToolDefinition(tool, client, serverName, readOnlyHintTrusted = false, maxRetries) {
|
|
100579
101190
|
const inputSchema22 = mcpJsonSchemaToZod(tool.inputSchema);
|
|
101191
|
+
const callWindowMs = typeof client.getToolCallWindowMs === "function" ? client.getToolCallWindowMs() : void 0;
|
|
100580
101192
|
const toolName = `mcp_${serverName}_${tool.name}`;
|
|
100581
101193
|
const mcpMetadata = {};
|
|
100582
101194
|
if (tool.annotations?.title !== void 0)
|
|
@@ -100602,6 +101214,7 @@ function mcpToolToToolDefinition(tool, client, serverName, readOnlyHintTrusted =
|
|
|
100602
101214
|
category: "network",
|
|
100603
101215
|
permissions: ["network_access"],
|
|
100604
101216
|
...maxRetries === void 0 ? {} : { maxRetries },
|
|
101217
|
+
...callWindowMs === void 0 ? {} : { timeoutMs: Math.min(callWindowMs + MCP_TOOL_DEADLINE_SLACK_MS, MAX_TIMER_DELAY_MS) },
|
|
100605
101218
|
// Reports what the SERVER said, faithfully. The outbound re-export
|
|
100606
101219
|
// and the destructive label a human is shown both need the server's
|
|
100607
101220
|
// own answer; whether a gate may act on it is decided separately,
|
|
@@ -100817,7 +101430,7 @@ function toolResultToMCPToolResult(result) {
|
|
|
100817
101430
|
__name(toolResultToMCPToolResult, "toolResultToMCPToolResult");
|
|
100818
101431
|
|
|
100819
101432
|
// ../sdk/dist/connector/mcp/policy.js
|
|
100820
|
-
import { createHash as
|
|
101433
|
+
import { createHash as createHash28 } from "node:crypto";
|
|
100821
101434
|
function applyToolPolicy(tools, policy) {
|
|
100822
101435
|
return applyNamePolicy(tools, policy);
|
|
100823
101436
|
}
|
|
@@ -100857,7 +101470,7 @@ function toolsHash(tools) {
|
|
|
100857
101470
|
// fingerprint built to catch exactly that rug-pull saw nothing.
|
|
100858
101471
|
annotations: stableStringify2(tool.annotations)
|
|
100859
101472
|
}));
|
|
100860
|
-
return
|
|
101473
|
+
return createHash28("sha256").update(JSON.stringify(canonical3)).digest("hex");
|
|
100861
101474
|
}
|
|
100862
101475
|
__name(toolsHash, "toolsHash");
|
|
100863
101476
|
function diffTools(before, after) {
|
|
@@ -101080,7 +101693,7 @@ var MCPToolDiscovery = class {
|
|
|
101080
101693
|
};
|
|
101081
101694
|
|
|
101082
101695
|
// ../sdk/dist/connector/mcp/mcp-toolset.js
|
|
101083
|
-
import { createHash as
|
|
101696
|
+
import { createHash as createHash29 } from "node:crypto";
|
|
101084
101697
|
|
|
101085
101698
|
// ../sdk/dist/connector/mcp/prompt-adapter.js
|
|
101086
101699
|
function renderPromptMessages(serverName, promptName, messages, description) {
|
|
@@ -101151,8 +101764,8 @@ function mcpToolsetName(serverName, ...segments) {
|
|
|
101151
101764
|
const full = ["mcp", serverName, ...segments].join("__");
|
|
101152
101765
|
if (full.length <= MCP_TOOLSET_NAME_MAX_LENGTH)
|
|
101153
101766
|
return full;
|
|
101154
|
-
const
|
|
101155
|
-
const suffix = `_${
|
|
101767
|
+
const hash4 = createHash29("sha256").update(full).digest("hex").slice(0, 8);
|
|
101768
|
+
const suffix = `_${hash4}`;
|
|
101156
101769
|
return `${full.slice(0, MCP_TOOLSET_NAME_MAX_LENGTH - suffix.length)}${suffix}`;
|
|
101157
101770
|
}
|
|
101158
101771
|
__name(mcpToolsetName, "mcpToolsetName");
|
|
@@ -117122,7 +117735,7 @@ var InMemorySessionStore = class {
|
|
|
117122
117735
|
};
|
|
117123
117736
|
|
|
117124
117737
|
// ../sdk/dist/store/session/disk.js
|
|
117125
|
-
import { createHash as
|
|
117738
|
+
import { createHash as createHash30 } from "node:crypto";
|
|
117126
117739
|
import { mkdir as mkdir19, rm as rm7 } from "node:fs/promises";
|
|
117127
117740
|
import { join as join42, resolve as resolve25 } from "node:path";
|
|
117128
117741
|
var SCHEMA9 = defineSchema({
|
|
@@ -117291,7 +117904,7 @@ var DiskSessionStore = class {
|
|
|
117291
117904
|
}
|
|
117292
117905
|
rootPathBindingLocation(rootPath, tenantId2) {
|
|
117293
117906
|
const key6 = rootPathIndexKey(rootPath, tenantId2);
|
|
117294
|
-
const digest8 =
|
|
117907
|
+
const digest8 = createHash30("sha256").update(key6).digest("hex");
|
|
117295
117908
|
const root = join42(this.rootDir, "projects", ".root-path-index", digest8.slice(0, 2));
|
|
117296
117909
|
return {
|
|
117297
117910
|
legacyPath: join42(root, `${digest8.slice(2)}.json`),
|
|
@@ -119541,7 +120154,7 @@ function analyzeContextUsage(input2) {
|
|
|
119541
120154
|
__name(analyzeContextUsage, "analyzeContextUsage");
|
|
119542
120155
|
|
|
119543
120156
|
// ../sdk/dist/learning/skill.js
|
|
119544
|
-
import { createHash as
|
|
120157
|
+
import { createHash as createHash31 } from "node:crypto";
|
|
119545
120158
|
var label = external_exports.string().trim().min(1).max(256);
|
|
119546
120159
|
var name = external_exports.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/);
|
|
119547
120160
|
var digest3 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
@@ -119694,7 +120307,7 @@ function reviseLearningProfile(current, input2) {
|
|
|
119694
120307
|
__name(reviseLearningProfile, "reviseLearningProfile");
|
|
119695
120308
|
function hashLearningSkill(input2) {
|
|
119696
120309
|
const candidate = candidateSchema.parse(input2);
|
|
119697
|
-
return
|
|
120310
|
+
return createHash31("sha256").update(JSON.stringify([
|
|
119698
120311
|
candidate.name,
|
|
119699
120312
|
candidate.description,
|
|
119700
120313
|
candidate.body,
|
|
@@ -119706,7 +120319,7 @@ __name(hashLearningSkill, "hashLearningSkill");
|
|
|
119706
120319
|
function promoteLearningSkill(current, input2, evaluation, inputEvidence) {
|
|
119707
120320
|
const protection = normalizeHarnessProtection(evaluation.protection);
|
|
119708
120321
|
const candidate = candidateSchema.parse(input2);
|
|
119709
|
-
const
|
|
120322
|
+
const hash4 = hashLearningSkill(candidate);
|
|
119710
120323
|
const baseline = current?.skills.find((s) => s.name === candidate.name);
|
|
119711
120324
|
if (baseline && (baseline.purpose ?? "task") !== (candidate.purpose ?? "task"))
|
|
119712
120325
|
throw new Error("A skill cannot change learning purpose; use a distinct skill name.");
|
|
@@ -119715,7 +120328,7 @@ function promoteLearningSkill(current, input2, evaluation, inputEvidence) {
|
|
|
119715
120328
|
for (const batch of [evaluation.verification, evaluation.confirmation]) {
|
|
119716
120329
|
if (!batch)
|
|
119717
120330
|
continue;
|
|
119718
|
-
if (batch.baselineRevision !== baselineHash || batch.candidateRevision !==
|
|
120331
|
+
if (batch.baselineRevision !== baselineHash || batch.candidateRevision !== hash4)
|
|
119719
120332
|
throw new Error("Skill evaluation does not match the active baseline and candidate digests.");
|
|
119720
120333
|
if (batch.baseline.length > 128 || batch.candidate.length > 128 || batch.attributions.length > 128)
|
|
119721
120334
|
throw new Error("Skill evaluation is bounded to 64 tasks per round.");
|
|
@@ -119729,18 +120342,18 @@ function promoteLearningSkill(current, input2, evaluation, inputEvidence) {
|
|
|
119729
120342
|
throw new Error(`Skill promotion ${review.decision}: ${review.reason}`);
|
|
119730
120343
|
const skill = {
|
|
119731
120344
|
...candidate,
|
|
119732
|
-
hash:
|
|
120345
|
+
hash: hash4,
|
|
119733
120346
|
evidence,
|
|
119734
120347
|
verification: {
|
|
119735
120348
|
baselineHash,
|
|
119736
|
-
candidateHash:
|
|
119737
|
-
evidenceDigest:
|
|
120349
|
+
candidateHash: hash4,
|
|
120350
|
+
evidenceDigest: createHash31("sha256").update(JSON.stringify({ ...evaluation, protection })).digest("hex"),
|
|
119738
120351
|
verificationTasks: review.verification.tasks.length,
|
|
119739
120352
|
confirmationTasks: review.confirmation?.tasks.length ?? 0,
|
|
119740
120353
|
protection: {
|
|
119741
120354
|
verificationTasks: protection.verification.length,
|
|
119742
120355
|
confirmationTasks: protection.confirmation.length,
|
|
119743
|
-
planDigest:
|
|
120356
|
+
planDigest: createHash31("sha256").update(JSON.stringify(protection)).digest("hex")
|
|
119744
120357
|
}
|
|
119745
120358
|
}
|
|
119746
120359
|
};
|
|
@@ -119849,13 +120462,13 @@ function projectLearning(current, options) {
|
|
|
119849
120462
|
__name(projectLearning, "projectLearning");
|
|
119850
120463
|
|
|
119851
120464
|
// ../sdk/dist/learning/cycle.js
|
|
119852
|
-
import { createHash as
|
|
120465
|
+
import { createHash as createHash33, randomUUID as randomUUID9 } from "node:crypto";
|
|
119853
120466
|
|
|
119854
120467
|
// ../sdk/dist/learning/guidance.js
|
|
119855
|
-
import { createHash as
|
|
120468
|
+
import { createHash as createHash32 } from "node:crypto";
|
|
119856
120469
|
import { readdir as readdir15 } from "node:fs/promises";
|
|
119857
120470
|
import { join as join43 } from "node:path";
|
|
119858
|
-
import { isDeepStrictEqual as
|
|
120471
|
+
import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
|
|
119859
120472
|
var LearningGuidanceConflictError = class extends Error {
|
|
119860
120473
|
static {
|
|
119861
120474
|
__name(this, "LearningGuidanceConflictError");
|
|
@@ -119897,7 +120510,7 @@ var ADOPTED_MARKER = "adopted.json";
|
|
|
119897
120510
|
var REVISION_FILE = /^([1-9][0-9]{0,15})\.json$/;
|
|
119898
120511
|
function keySegment(key6) {
|
|
119899
120512
|
const encoded = revisionFileSegment(key6);
|
|
119900
|
-
return encoded.length <= 255 ? encoded : `~sha256-${
|
|
120513
|
+
return encoded.length <= 255 ? encoded : `~sha256-${createHash32("sha256").update(encoded).digest("hex")}`;
|
|
119901
120514
|
}
|
|
119902
120515
|
__name(keySegment, "keySegment");
|
|
119903
120516
|
function earlierGuidanceDirectory(root, scope) {
|
|
@@ -120054,7 +120667,7 @@ var DiskLearningGuidance = class {
|
|
|
120054
120667
|
const current = this.checked(record4);
|
|
120055
120668
|
if (current.revision !== snapshot.revision)
|
|
120056
120669
|
throw new LearningGuidanceConflictError();
|
|
120057
|
-
if (!
|
|
120670
|
+
if (!isDeepStrictEqual7(current.learning, snapshot.learning))
|
|
120058
120671
|
throw new LearningGuidanceConflictError();
|
|
120059
120672
|
const next2 = this.checked({ ...current, learning, revision: current.revision + 1 });
|
|
120060
120673
|
return { record: next2, result: next2 };
|
|
@@ -120467,7 +121080,7 @@ ${exploration.evidence.reason}`
|
|
|
120467
121080
|
}, { subject: "exploration.trace", text: exploration.trace });
|
|
120468
121081
|
await append("exploration", {
|
|
120469
121082
|
observations: exploration,
|
|
120470
|
-
digest:
|
|
121083
|
+
digest: createHash33("sha256").update(JSON.stringify(exploration)).digest("hex")
|
|
120471
121084
|
}, "explore");
|
|
120472
121085
|
const problem2 = resourceProblem(true);
|
|
120473
121086
|
if (problem2)
|
|
@@ -120516,7 +121129,7 @@ ${s.revision}`).join("\n"),
|
|
|
120516
121129
|
await append("evaluation", {
|
|
120517
121130
|
baselineRevision,
|
|
120518
121131
|
candidateRevision,
|
|
120519
|
-
digest:
|
|
121132
|
+
digest: createHash33("sha256").update(JSON.stringify(batch)).digest("hex"),
|
|
120520
121133
|
baselineTrajectories: batch.baseline.map((t) => t.trajectoryId),
|
|
120521
121134
|
candidateTrajectories: batch.candidate.map((t) => t.trajectoryId)
|
|
120522
121135
|
}, name2);
|
|
@@ -121047,7 +121660,7 @@ var SqliteLearningExperienceStore = class {
|
|
|
121047
121660
|
};
|
|
121048
121661
|
|
|
121049
121662
|
// ../sdk/dist/learning/store.js
|
|
121050
|
-
import { createHash as
|
|
121663
|
+
import { createHash as createHash34, randomUUID as randomUUID11 } from "node:crypto";
|
|
121051
121664
|
import { closeSync as closeSync2, existsSync as existsSync6, fsyncSync, linkSync, lstatSync as lstatSync4, mkdirSync as mkdirSync5, openSync as openSync2, readFileSync as readFileSync4, unlinkSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
121052
121665
|
import { createRequire as createRequire4 } from "node:module";
|
|
121053
121666
|
import { dirname as dirname24, join as join44, resolve as resolve27 } from "node:path";
|
|
@@ -121076,7 +121689,7 @@ var learningObservationSchema = learningTargetSchema.extend({
|
|
|
121076
121689
|
|
|
121077
121690
|
// ../sdk/dist/learning/store.js
|
|
121078
121691
|
var uuid5 = external_exports.string().uuid().transform((id3) => id3.toLowerCase());
|
|
121079
|
-
var digest4 = /* @__PURE__ */ __name((text9) =>
|
|
121692
|
+
var digest4 = /* @__PURE__ */ __name((text9) => createHash34("sha256").update(text9).digest("hex"), "digest");
|
|
121080
121693
|
var MAX_EVENT_BYTES = 256 * 1024;
|
|
121081
121694
|
var MAX_ARTIFACT_BYTES = 8 * 1024 * 1024;
|
|
121082
121695
|
var MAX_EVENTS = 4096;
|
|
@@ -121399,7 +122012,7 @@ var SqliteLearningStore = class {
|
|
|
121399
122012
|
this.claimObservation(db, event);
|
|
121400
122013
|
let status = row.status;
|
|
121401
122014
|
let result = null;
|
|
121402
|
-
let
|
|
122015
|
+
let hash4 = row.candidate_hash;
|
|
121403
122016
|
if (event.kind === "usage") {
|
|
121404
122017
|
const receipt2 = external_exports.object({
|
|
121405
122018
|
sessionId: uuid5,
|
|
@@ -121415,7 +122028,7 @@ var SqliteLearningStore = class {
|
|
|
121415
122028
|
db.prepare("UPDATE cycles SET tokens = tokens + ?, cost_usd = cost_usd + ?, receipts = receipts + 1, unknown_tokens = unknown_tokens + ?, unknown_costs = unknown_costs + ? WHERE id = ?").run(receipt2.tokens ?? 0, receipt2.costUsd ?? 0, Number(receipt2.tokens === null), Number(receipt2.costUsd === null), event.cycleId);
|
|
121416
122029
|
}
|
|
121417
122030
|
if (event.kind === "candidate")
|
|
121418
|
-
|
|
122031
|
+
hash4 = external_exports.string().regex(/^[0-9a-f]{64}$/).parse(event.data.candidateRevision);
|
|
121419
122032
|
if (event.kind === "activation-requested")
|
|
121420
122033
|
status = "activation-pending";
|
|
121421
122034
|
if (event.kind === "finished") {
|
|
@@ -121447,7 +122060,7 @@ var SqliteLearningStore = class {
|
|
|
121447
122060
|
result = JSON.stringify(value);
|
|
121448
122061
|
}
|
|
121449
122062
|
db.prepare("INSERT INTO events VALUES (?, ?, ?)").run(event.cycleId, event.sequence, body);
|
|
121450
|
-
db.prepare("UPDATE cycles SET sequence = ?, status = ?, updated_at = ?, candidate_hash = ?, result = ? WHERE id = ?").run(event.sequence, status, Date.now(),
|
|
122063
|
+
db.prepare("UPDATE cycles SET sequence = ?, status = ?, updated_at = ?, candidate_hash = ?, result = ? WHERE id = ?").run(event.sequence, status, Date.now(), hash4, result, event.cycleId);
|
|
121451
122064
|
});
|
|
121452
122065
|
}
|
|
121453
122066
|
async get(cycleId) {
|
|
@@ -121795,7 +122408,7 @@ function parsePeerAddress(address2) {
|
|
|
121795
122408
|
__name(parsePeerAddress, "parsePeerAddress");
|
|
121796
122409
|
|
|
121797
122410
|
// ../sdk/dist/peers/record.js
|
|
121798
|
-
import { createHash as
|
|
122411
|
+
import { createHash as createHash35 } from "node:crypto";
|
|
121799
122412
|
|
|
121800
122413
|
// ../sdk/dist/peers/protocol.js
|
|
121801
122414
|
var PEER_PROTOCOL_VERSION = "namzu-peer/1";
|
|
@@ -121933,7 +122546,7 @@ var PeerRecordSchema = external_exports.object({
|
|
|
121933
122546
|
var PeerRecordReaderSchema = PeerRecordSchema.strip();
|
|
121934
122547
|
var PEER_REF_HEX_LENGTH = 6;
|
|
121935
122548
|
function derivePeerRef(sessionId5) {
|
|
121936
|
-
return
|
|
122549
|
+
return createHash35("sha256").update(sessionId5, "utf8").digest("hex").slice(0, PEER_REF_HEX_LENGTH);
|
|
121937
122550
|
}
|
|
121938
122551
|
__name(derivePeerRef, "derivePeerRef");
|
|
121939
122552
|
|
|
@@ -124089,7 +124702,7 @@ var PAL_WORK_GUIDANCE = [
|
|
|
124089
124702
|
].join("\n\n");
|
|
124090
124703
|
|
|
124091
124704
|
// ../sdk/dist/pals/reference-images.js
|
|
124092
|
-
import { createHash as
|
|
124705
|
+
import { createHash as createHash36, randomUUID as randomUUID13 } from "node:crypto";
|
|
124093
124706
|
import { posix as posix4 } from "node:path";
|
|
124094
124707
|
var MAX_IMAGES = 8;
|
|
124095
124708
|
var MAX_IMAGE_BYTES = 3 * 1024 * 1024;
|
|
@@ -124133,7 +124746,7 @@ function preparePalReferenceImages(attachments) {
|
|
|
124133
124746
|
attachmentIndex: index + 1,
|
|
124134
124747
|
mediaType: attachment.mediaType,
|
|
124135
124748
|
data: attachment.data,
|
|
124136
|
-
sha256:
|
|
124749
|
+
sha256: createHash36("sha256").update(bytes).digest("hex"),
|
|
124137
124750
|
bytes: bytes.length
|
|
124138
124751
|
}));
|
|
124139
124752
|
}
|
|
@@ -124314,13 +124927,13 @@ __name(createPalReferenceImageTool, "createPalReferenceImageTool");
|
|
|
124314
124927
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
124315
124928
|
import { chmodSync as chmodSync5, lstatSync as lstatSync9, mkdirSync as mkdirSync10, readdirSync as readdirSync4, realpathSync as realpathSync8 } from "node:fs";
|
|
124316
124929
|
import { join as join51, resolve as resolve30 } from "node:path";
|
|
124317
|
-
import { isDeepStrictEqual as
|
|
124930
|
+
import { isDeepStrictEqual as isDeepStrictEqual10 } from "node:util";
|
|
124318
124931
|
|
|
124319
124932
|
// ../sdk/dist/pals/communication/ingress-schema.js
|
|
124320
|
-
import { isDeepStrictEqual as
|
|
124933
|
+
import { isDeepStrictEqual as isDeepStrictEqual8 } from "node:util";
|
|
124321
124934
|
|
|
124322
124935
|
// ../sdk/dist/pals/communication/schema.js
|
|
124323
|
-
import { createHash as
|
|
124936
|
+
import { createHash as createHash37 } from "node:crypto";
|
|
124324
124937
|
var id2 = external_exports.string().uuid();
|
|
124325
124938
|
var sessionId3 = external_exports.custom((s) => isEntityId(s, "session"));
|
|
124326
124939
|
var turnId4 = external_exports.custom((s) => isEntityId(s, "turn"));
|
|
@@ -124414,10 +125027,10 @@ function freezeCommunicationValue(value) {
|
|
|
124414
125027
|
return value;
|
|
124415
125028
|
}
|
|
124416
125029
|
__name(freezeCommunicationValue, "freezeCommunicationValue");
|
|
124417
|
-
function
|
|
124418
|
-
return
|
|
125030
|
+
function hash3(value) {
|
|
125031
|
+
return createHash37("sha256").update(JSON.stringify(value)).digest("hex");
|
|
124419
125032
|
}
|
|
124420
|
-
__name(
|
|
125033
|
+
__name(hash3, "hash");
|
|
124421
125034
|
function addressTuple(value) {
|
|
124422
125035
|
return [value.tenantId, value.palId];
|
|
124423
125036
|
}
|
|
@@ -124434,11 +125047,11 @@ function routeTuple(value) {
|
|
|
124434
125047
|
}
|
|
124435
125048
|
__name(routeTuple, "routeTuple");
|
|
124436
125049
|
function routeId(value) {
|
|
124437
|
-
return
|
|
125050
|
+
return hash3(routeTuple(routeKeySchema.parse(value)));
|
|
124438
125051
|
}
|
|
124439
125052
|
__name(routeId, "routeId");
|
|
124440
125053
|
function messageId3(source, operationId) {
|
|
124441
|
-
return
|
|
125054
|
+
return hash3([
|
|
124442
125055
|
1,
|
|
124443
125056
|
"pal-message",
|
|
124444
125057
|
addressTuple(source.address),
|
|
@@ -124448,7 +125061,7 @@ function messageId3(source, operationId) {
|
|
|
124448
125061
|
}
|
|
124449
125062
|
__name(messageId3, "messageId");
|
|
124450
125063
|
function intentDigest(intent) {
|
|
124451
|
-
return
|
|
125064
|
+
return hash3([
|
|
124452
125065
|
1,
|
|
124453
125066
|
addressTuple(intent.source.address),
|
|
124454
125067
|
intent.source.conversationId,
|
|
@@ -124783,14 +125396,14 @@ function ingressRouteTuple(key6) {
|
|
|
124783
125396
|
__name(ingressRouteTuple, "ingressRouteTuple");
|
|
124784
125397
|
function ingressRouteId(key6) {
|
|
124785
125398
|
const parsed = ingressRouteKeySchema.parse(key6);
|
|
124786
|
-
return parsed.kind === "pal" ? routeId(parsed) :
|
|
125399
|
+
return parsed.kind === "pal" ? routeId(parsed) : hash3(ingressRouteTuple(parsed));
|
|
124787
125400
|
}
|
|
124788
125401
|
__name(ingressRouteId, "ingressRouteId");
|
|
124789
125402
|
function ingressIntentId(intent) {
|
|
124790
125403
|
if (!("kind" in intent))
|
|
124791
125404
|
return messageId3(intent.source, intent.operationId);
|
|
124792
125405
|
if (intent.kind === "observation")
|
|
124793
|
-
return
|
|
125406
|
+
return hash3([
|
|
124794
125407
|
1,
|
|
124795
125408
|
"pal-observation",
|
|
124796
125409
|
intent.source.subscriptionId,
|
|
@@ -124798,14 +125411,14 @@ function ingressIntentId(intent) {
|
|
|
124798
125411
|
intent.fact.id
|
|
124799
125412
|
]);
|
|
124800
125413
|
if (intent.kind === "operator")
|
|
124801
|
-
return
|
|
125414
|
+
return hash3([
|
|
124802
125415
|
1,
|
|
124803
125416
|
"pal-operator",
|
|
124804
125417
|
intent.source.tenantId,
|
|
124805
125418
|
intent.source.sessionId,
|
|
124806
125419
|
intent.operationId
|
|
124807
125420
|
]);
|
|
124808
|
-
return
|
|
125421
|
+
return hash3([
|
|
124809
125422
|
1,
|
|
124810
125423
|
"pal-channel",
|
|
124811
125424
|
intent.source.tenantId,
|
|
@@ -124818,7 +125431,7 @@ function ingressIntentDigest(intent) {
|
|
|
124818
125431
|
if (!("kind" in intent))
|
|
124819
125432
|
return intentDigest(intent);
|
|
124820
125433
|
if (intent.kind === "observation")
|
|
124821
|
-
return
|
|
125434
|
+
return hash3([
|
|
124822
125435
|
1,
|
|
124823
125436
|
"observation",
|
|
124824
125437
|
intent.source.subscriptionId,
|
|
@@ -124844,7 +125457,7 @@ function ingressIntentDigest(intent) {
|
|
|
124844
125457
|
intent.subscriptionTrail
|
|
124845
125458
|
]);
|
|
124846
125459
|
if (intent.kind === "operator")
|
|
124847
|
-
return
|
|
125460
|
+
return hash3([
|
|
124848
125461
|
1,
|
|
124849
125462
|
"operator",
|
|
124850
125463
|
intent.source.tenantId,
|
|
@@ -124854,7 +125467,7 @@ function ingressIntentDigest(intent) {
|
|
|
124854
125467
|
ingressRouteTuple(intent.routeKey),
|
|
124855
125468
|
intent.body
|
|
124856
125469
|
]);
|
|
124857
|
-
return
|
|
125470
|
+
return hash3([
|
|
124858
125471
|
1,
|
|
124859
125472
|
"channel",
|
|
124860
125473
|
intent.source.tenantId,
|
|
@@ -124877,12 +125490,12 @@ function checkedIngressIntent(value) {
|
|
|
124877
125490
|
if (!sameAddress(intent.source.address, intent.routeKey.sender) || intent.source.conversationId !== intent.routeKey.senderConversationId)
|
|
124878
125491
|
throw new Error("Invalid immutable Pal source operation.");
|
|
124879
125492
|
} else if (intent.kind === "observation") {
|
|
124880
|
-
if (intent.recipient.tenantId !== intent.source.scope.tenantId || intent.source.subscriptionId !== intent.routeKey.subscriptionId || !
|
|
125493
|
+
if (intent.recipient.tenantId !== intent.source.scope.tenantId || intent.source.subscriptionId !== intent.routeKey.subscriptionId || !isDeepStrictEqual8(intent.source.scope, intent.routeKey.scope))
|
|
124881
125494
|
throw new Error("Foreign observation source or route.");
|
|
124882
125495
|
} else if (intent.kind === "operator") {
|
|
124883
125496
|
if (intent.source.tenantId !== intent.recipient.tenantId || intent.source.sessionId !== intent.routeKey.conversationId)
|
|
124884
125497
|
throw new Error("Foreign operator conversation source or route.");
|
|
124885
|
-
} else if (intent.source.tenantId !== intent.recipient.tenantId || !
|
|
125498
|
+
} else if (intent.source.tenantId !== intent.recipient.tenantId || !isDeepStrictEqual8(nativeChannelTuple(intent.source), nativeChannelTuple(intent.routeKey)))
|
|
124886
125499
|
throw new Error("Foreign channel source or route.");
|
|
124887
125500
|
return freezeCommunicationValue(intent);
|
|
124888
125501
|
}
|
|
@@ -124954,7 +125567,7 @@ function currentIngressRecipient(pals, binding) {
|
|
|
124954
125567
|
__name(currentIngressRecipient, "currentIngressRecipient");
|
|
124955
125568
|
|
|
124956
125569
|
// ../sdk/dist/pals/communication/verify.js
|
|
124957
|
-
import { isDeepStrictEqual as
|
|
125570
|
+
import { isDeepStrictEqual as isDeepStrictEqual9 } from "node:util";
|
|
124958
125571
|
function capturedContext(input2) {
|
|
124959
125572
|
return {
|
|
124960
125573
|
binding: freezeCommunicationValue(ingressBindingSchema.parse(input2.binding)),
|
|
@@ -124991,7 +125604,7 @@ function checkedDelivery(input2, context2) {
|
|
|
124991
125604
|
for (const key6 of ["ordinal", "routeId", "phase", "claim", "receipt"])
|
|
124992
125605
|
delete raw[key6];
|
|
124993
125606
|
checkedIngressIntent(raw);
|
|
124994
|
-
if (message.routeId !== ingressRouteId(message.routeKey) || context2.binding.id !== ingressRouteId(context2.binding.key) || context2.binding.id !== message.routeId || !
|
|
125607
|
+
if (message.routeId !== ingressRouteId(message.routeKey) || context2.binding.id !== ingressRouteId(context2.binding.key) || context2.binding.id !== message.routeId || !isDeepStrictEqual9(context2.binding.key, message.routeKey) || !message.claim || message.claim.sessionId !== context2.binding.sessionId)
|
|
124995
125608
|
throw new Error("Foreign delivery route or claim.");
|
|
124996
125609
|
return message;
|
|
124997
125610
|
}
|
|
@@ -125004,7 +125617,7 @@ async function matches(entry, message, context2) {
|
|
|
125004
125617
|
if (!content || content.role !== "user" || content.content !== message.claim.content || !content.source || typeof content.source !== "object")
|
|
125005
125618
|
return false;
|
|
125006
125619
|
const source = content.source;
|
|
125007
|
-
return source.type === "runtime-context" && source.kind === ingressRuntimeContextKind(message) &&
|
|
125620
|
+
return source.type === "runtime-context" && source.kind === ingressRuntimeContextKind(message) && isDeepStrictEqual9(source.deliveryRef, ingressMessageRef(message));
|
|
125008
125621
|
}
|
|
125009
125622
|
__name(matches, "matches");
|
|
125010
125623
|
async function findRecordedIngressMessage(inputMessage, inputContext, through) {
|
|
@@ -125026,7 +125639,7 @@ async function verifyIngressRecorded(inputMessage, inputReceipt, inputContext) {
|
|
|
125026
125639
|
const context2 = capturedContext(inputContext);
|
|
125027
125640
|
const message = checkedDelivery(inputMessage, context2);
|
|
125028
125641
|
const receipt2 = ingressReceiptSchema.parse(inputReceipt);
|
|
125029
|
-
if (!message.claim || context2.binding.id !== message.routeId || !
|
|
125642
|
+
if (!message.claim || context2.binding.id !== message.routeId || !isDeepStrictEqual9(context2.binding.key, message.routeKey) || !isDeepStrictEqual9(receipt2.ref, ingressMessageRef(message)) || receipt2.claimId !== message.claim.id || receipt2.sessionId !== message.claim.sessionId || receipt2.turnId !== message.claim.turnId || receipt2.through.gen < message.claim.generation)
|
|
125030
125643
|
throw new Error("Foreign delivery route or receipt.");
|
|
125031
125644
|
const { entry } = await findRecordedIngressMessage(message, context2, receipt2.through);
|
|
125032
125645
|
if (!entry || entry.record.type !== "message" || entry.record.messageId !== receipt2.messageId || entry.record.seq > receipt2.through.pointer.seq)
|
|
@@ -125143,7 +125756,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125143
125756
|
location(recipient) {
|
|
125144
125757
|
const address2 = addressSchema2.parse(recipient);
|
|
125145
125758
|
this.directory(this.root);
|
|
125146
|
-
const directory = join51(this.root,
|
|
125759
|
+
const directory = join51(this.root, hash3(addressTuple(address2)));
|
|
125147
125760
|
return this.commitLocation(directory);
|
|
125148
125761
|
}
|
|
125149
125762
|
commitLocation(directory) {
|
|
@@ -125223,7 +125836,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125223
125836
|
delete raw[key6];
|
|
125224
125837
|
this.checkedIntent(raw);
|
|
125225
125838
|
const binding = routes.get(message.routeId);
|
|
125226
|
-
if (!binding || !
|
|
125839
|
+
if (!binding || !isDeepStrictEqual10(binding.key, message.routeKey) || !sameAddress(message.recipient, recipient) || ids.has(message.id) || message.ordinal <= ordinal)
|
|
125227
125840
|
throw new Error("Invalid immutable Pal incoming intent.");
|
|
125228
125841
|
ids.add(message.id);
|
|
125229
125842
|
ordinal = message.ordinal;
|
|
@@ -125280,7 +125893,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125280
125893
|
return this.changeRaw(intent.recipient, (current) => {
|
|
125281
125894
|
const routes = current?.routes ?? [];
|
|
125282
125895
|
let binding = routes.find((r) => r.id === id3);
|
|
125283
|
-
if (binding && (!
|
|
125896
|
+
if (binding && (!isDeepStrictEqual10(binding.key, intent.routeKey) || pinnedConversationId !== null && binding.sessionId !== pinnedConversationId))
|
|
125284
125897
|
conflict("Route identity names another immutable conversation.");
|
|
125285
125898
|
const existing = current?.messages.find((m) => m.id === intent.id);
|
|
125286
125899
|
if (existing) {
|
|
@@ -125322,12 +125935,12 @@ var DiskPalCommunicationStore = class {
|
|
|
125322
125935
|
return (await this.readRaw(parsed.recipient))?.routes.find((r) => r.id === ingressRouteId(parsed)) ?? null;
|
|
125323
125936
|
}
|
|
125324
125937
|
async activateIngress(binding, context2) {
|
|
125325
|
-
if (!
|
|
125938
|
+
if (!isDeepStrictEqual10(context2.binding, binding))
|
|
125326
125939
|
throw new Error("Foreign route activation context.");
|
|
125327
125940
|
await verifyIngressConversation(context2);
|
|
125328
125941
|
return this.changeRaw(binding.key.recipient, (state) => {
|
|
125329
125942
|
const current = state?.routes.find((r) => r.id === binding.id);
|
|
125330
|
-
if (!state || !current || !
|
|
125943
|
+
if (!state || !current || !isDeepStrictEqual10(current, binding))
|
|
125331
125944
|
conflict("Route claim changed.");
|
|
125332
125945
|
if (current.phase === "active")
|
|
125333
125946
|
return { state: null, result: current };
|
|
@@ -125357,7 +125970,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125357
125970
|
if (!state || unresolved)
|
|
125358
125971
|
return { state: null, result: null };
|
|
125359
125972
|
const current = state.routes.find((r) => r.id === binding.id);
|
|
125360
|
-
if (!current || current.phase !== "active" || !
|
|
125973
|
+
if (!current || current.phase !== "active" || !isDeepStrictEqual10(current, binding))
|
|
125361
125974
|
conflict("Route is not active.");
|
|
125362
125975
|
const message = state.messages.find((m) => m.routeId === binding.id && m.phase === "pending");
|
|
125363
125976
|
if (!message)
|
|
@@ -125433,7 +126046,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125433
126046
|
}
|
|
125434
126047
|
checkedReceipt(message, input2) {
|
|
125435
126048
|
const value = ingressReceiptSchema.parse(input2);
|
|
125436
|
-
if (!message.claim || !
|
|
126049
|
+
if (!message.claim || !isDeepStrictEqual10(value.ref, ingressMessageRef(message)) || value.claimId !== message.claim.id || value.sessionId !== message.claim.sessionId || value.turnId !== message.claim.turnId || value.through.gen < message.claim.generation || value.through.bytes < value.through.pointer.offset + value.through.pointer.length)
|
|
125437
126050
|
throw new Error("Receipt does not match the exact Pal delivery claim.");
|
|
125438
126051
|
return value;
|
|
125439
126052
|
}
|
|
@@ -125442,7 +126055,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125442
126055
|
await verifyIngressRecorded(message, value, context2);
|
|
125443
126056
|
return this.changeMessage(message, (current) => {
|
|
125444
126057
|
if (current.phase === "recorded") {
|
|
125445
|
-
if (!
|
|
126058
|
+
if (!isDeepStrictEqual10(current.receipt, value))
|
|
125446
126059
|
conflict("Recorded delivery has another receipt.");
|
|
125447
126060
|
return current;
|
|
125448
126061
|
}
|
|
@@ -125461,7 +126074,7 @@ var DiskPalCommunicationStore = class {
|
|
|
125461
126074
|
async changeMessage(message, mutate2) {
|
|
125462
126075
|
return this.changeRaw(message.recipient, (state) => {
|
|
125463
126076
|
const current = state?.messages.find((m) => m.id === message.id);
|
|
125464
|
-
if (!state || !current || !message.claim || !
|
|
126077
|
+
if (!state || !current || !message.claim || !isDeepStrictEqual10(current.claim, message.claim) || current.digest !== message.digest || current.phase !== "claimed" && current.phase !== "recorded")
|
|
125465
126078
|
conflict("Delivery claim changed; a stale claimant cannot settle it.");
|
|
125466
126079
|
const next2 = frozen(mutate2(current));
|
|
125467
126080
|
if (next2 === current)
|
|
@@ -125731,7 +126344,7 @@ function createPalOperatorMessagingTools(options) {
|
|
|
125731
126344
|
if (typeof context2.toolBatchId !== "string" || !context2.toolBatchId || typeof context2.toolUseId !== "string" || !context2.toolUseId)
|
|
125732
126345
|
throw new Error("Pal messaging requires executor toolBatchId and toolUseId.");
|
|
125733
126346
|
const receipt2 = await options.sender.send(conversation, {
|
|
125734
|
-
operationId:
|
|
126347
|
+
operationId: hash3([
|
|
125735
126348
|
1,
|
|
125736
126349
|
"operator-message-tool",
|
|
125737
126350
|
conversation.sessionId,
|
|
@@ -126007,7 +126620,7 @@ var permissionSchema = external_exports.object({
|
|
|
126007
126620
|
allowWake: external_exports.boolean()
|
|
126008
126621
|
});
|
|
126009
126622
|
function key5(source, recipient) {
|
|
126010
|
-
return
|
|
126623
|
+
return hash3([addressTuple(source), addressTuple(recipient)]);
|
|
126011
126624
|
}
|
|
126012
126625
|
__name(key5, "key");
|
|
126013
126626
|
function checked(input2, source, recipient) {
|
|
@@ -126123,10 +126736,10 @@ var DiskPalMessagePolicy = class {
|
|
|
126123
126736
|
};
|
|
126124
126737
|
|
|
126125
126738
|
// ../sdk/dist/pals/activity/source.js
|
|
126126
|
-
import { createHash as
|
|
126739
|
+
import { createHash as createHash39 } from "node:crypto";
|
|
126127
126740
|
|
|
126128
126741
|
// ../sdk/dist/pals/activity/projection.js
|
|
126129
|
-
import { createHash as
|
|
126742
|
+
import { createHash as createHash38 } from "node:crypto";
|
|
126130
126743
|
var activityId2 = external_exports.custom((value) => isEntityId(value, "activity"));
|
|
126131
126744
|
var checkpointId3 = external_exports.custom((value) => isEntityId(value, "checkpoint"));
|
|
126132
126745
|
var toolUseId2 = external_exports.string().min(1).max(512).regex(/^[A-Za-z0-9_.:-]+$/);
|
|
@@ -126185,7 +126798,7 @@ function projectPalActivity(entry, scopeHash) {
|
|
|
126185
126798
|
return null;
|
|
126186
126799
|
}
|
|
126187
126800
|
return Object.freeze({
|
|
126188
|
-
id:
|
|
126801
|
+
id: createHash38("sha256").update(JSON.stringify(["pal-activity/1", scopeHash, pointer2])).digest("hex"),
|
|
126189
126802
|
type: record4.type,
|
|
126190
126803
|
sessionId: record4.sessionId,
|
|
126191
126804
|
..."turnId" in record4 ? { turnId: record4.turnId } : {},
|
|
@@ -126247,10 +126860,10 @@ var cursorSchema2 = external_exports.object({
|
|
|
126247
126860
|
after: pointer,
|
|
126248
126861
|
generation: external_exports.number().int().nonnegative().safe()
|
|
126249
126862
|
}).strict();
|
|
126250
|
-
function
|
|
126863
|
+
function samePointer3(one, two) {
|
|
126251
126864
|
return one.seq === two.seq && one.offset === two.offset && one.length === two.length && one.sha256 === two.sha256;
|
|
126252
126865
|
}
|
|
126253
|
-
__name(
|
|
126866
|
+
__name(samePointer3, "samePointer");
|
|
126254
126867
|
function immutableCursor(value) {
|
|
126255
126868
|
return Object.freeze({
|
|
126256
126869
|
...value,
|
|
@@ -126279,7 +126892,7 @@ function createPalActivitySource(options) {
|
|
|
126279
126892
|
if (definition.id !== scope.palId || definition.revision !== scope.profileRevision)
|
|
126280
126893
|
throw new PalActivityIntegrityError();
|
|
126281
126894
|
const workspace = definition.workspace;
|
|
126282
|
-
const scopeHash =
|
|
126895
|
+
const scopeHash = createHash39("sha256").update(JSON.stringify([
|
|
126283
126896
|
"pal-activity/1",
|
|
126284
126897
|
scope.tenantId,
|
|
126285
126898
|
scope.projectId,
|
|
@@ -126349,7 +126962,7 @@ function createPalActivitySource(options) {
|
|
|
126349
126962
|
let generation = root.record.gen;
|
|
126350
126963
|
if (supplied) {
|
|
126351
126964
|
const anchorEnd = supplied.after.offset + supplied.after.length;
|
|
126352
|
-
if (!
|
|
126965
|
+
if (!samePointer3(root.pointer, supplied.root) || !Number.isSafeInteger(anchorEnd) || anchorEnd > size || supplied.after.seq < 1 || supplied.after.seq > 1 && supplied.after.offset < root.pointer.length)
|
|
126353
126966
|
throw new PalActivityIntegrityError();
|
|
126354
126967
|
let anchor2;
|
|
126355
126968
|
try {
|
|
@@ -126360,7 +126973,7 @@ function createPalActivitySource(options) {
|
|
|
126360
126973
|
throw error62;
|
|
126361
126974
|
throw new PalActivityIntegrityError();
|
|
126362
126975
|
}
|
|
126363
|
-
if (anchor2.sha256 !== supplied.after.sha256 || anchor2.record.sessionId !== scope.sessionId || anchor2.record.seq !== supplied.after.seq || anchor2.record.gen !== supplied.generation || supplied.after.seq === 1 && !
|
|
126976
|
+
if (anchor2.sha256 !== supplied.after.sha256 || anchor2.record.sessionId !== scope.sessionId || anchor2.record.seq !== supplied.after.seq || anchor2.record.gen !== supplied.generation || supplied.after.seq === 1 && !samePointer3(supplied.after, root.pointer))
|
|
126364
126977
|
throw new PalActivityIntegrityError();
|
|
126365
126978
|
after = supplied.after;
|
|
126366
126979
|
generation = anchor2.record.gen;
|
|
@@ -126669,10 +127282,10 @@ __name(dispatchPalIngressOnce, "dispatchPalIngressOnce");
|
|
|
126669
127282
|
// ../sdk/dist/pals/channels/routes.js
|
|
126670
127283
|
import { chmodSync as chmodSync7, lstatSync as lstatSync11, mkdirSync as mkdirSync12, readdirSync as readdirSync6, realpathSync as realpathSync10 } from "node:fs";
|
|
126671
127284
|
import { join as join53, resolve as resolve32 } from "node:path";
|
|
126672
|
-
import { isDeepStrictEqual as
|
|
127285
|
+
import { isDeepStrictEqual as isDeepStrictEqual11 } from "node:util";
|
|
126673
127286
|
|
|
126674
127287
|
// ../sdk/dist/pals/channels/schema.js
|
|
126675
|
-
import { createHash as
|
|
127288
|
+
import { createHash as createHash40 } from "node:crypto";
|
|
126676
127289
|
var connectionSchema = external_exports.object({
|
|
126677
127290
|
tenantId: addressSchema2.shape.tenantId,
|
|
126678
127291
|
provider: label4,
|
|
@@ -126703,7 +127316,7 @@ var verifiedActionSchema = external_exports.object({
|
|
|
126703
127316
|
actionId: label4,
|
|
126704
127317
|
payloadDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
126705
127318
|
payload: external_exports.string().min(1).max(32e3).refine((value) => !value.includes("\0"))
|
|
126706
|
-
}).strict().refine((value) =>
|
|
127319
|
+
}).strict().refine((value) => createHash40("sha256").update(value.payload).digest("hex") === value.payloadDigest, "Channel action payload does not match its authenticated digest.");
|
|
126707
127320
|
var routeDecisionSchema = external_exports.object({
|
|
126708
127321
|
v: external_exports.literal(1),
|
|
126709
127322
|
revision: external_exports.literal(1),
|
|
@@ -126738,7 +127351,7 @@ function nativeTuple(identity) {
|
|
|
126738
127351
|
}
|
|
126739
127352
|
__name(nativeTuple, "nativeTuple");
|
|
126740
127353
|
function decisionId(decision2) {
|
|
126741
|
-
return
|
|
127354
|
+
return hash3([1, decision2.recipient.tenantId, nativeTuple(decision2.identity)]);
|
|
126742
127355
|
}
|
|
126743
127356
|
__name(decisionId, "decisionId");
|
|
126744
127357
|
function checkedDecision(input2) {
|
|
@@ -126827,7 +127440,7 @@ var DiskPalChannelRoutes = class {
|
|
|
126827
127440
|
if (!stored)
|
|
126828
127441
|
return null;
|
|
126829
127442
|
const decision2 = storedDecision(stored);
|
|
126830
|
-
if (decisionId(decision2) !== id3 || !
|
|
127443
|
+
if (decisionId(decision2) !== id3 || !isDeepStrictEqual11(decision2.identity, identity))
|
|
126831
127444
|
throw new Error("Channel route identity changed.");
|
|
126832
127445
|
return decision2;
|
|
126833
127446
|
}
|
|
@@ -126837,7 +127450,7 @@ var DiskPalChannelRoutes = class {
|
|
|
126837
127450
|
return await this.records.transact(this.location(decisionId(decision2)), (stored) => {
|
|
126838
127451
|
if (stored) {
|
|
126839
127452
|
const current = storedDecision(stored);
|
|
126840
|
-
if (!
|
|
127453
|
+
if (!isDeepStrictEqual11(current, decision2))
|
|
126841
127454
|
throw new PalChannelRouteConflictError("This native conversation already has an immutable Pal target.");
|
|
126842
127455
|
throw new ExistingDecision(current);
|
|
126843
127456
|
}
|
|
@@ -126852,7 +127465,7 @@ var DiskPalChannelRoutes = class {
|
|
|
126852
127465
|
};
|
|
126853
127466
|
|
|
126854
127467
|
// ../sdk/dist/pals/channels/ingress.js
|
|
126855
|
-
import { isDeepStrictEqual as
|
|
127468
|
+
import { isDeepStrictEqual as isDeepStrictEqual12 } from "node:util";
|
|
126856
127469
|
var PalChannelIngress = class {
|
|
126857
127470
|
static {
|
|
126858
127471
|
__name(this, "PalChannelIngress");
|
|
@@ -126926,7 +127539,7 @@ var PalChannelIngress = class {
|
|
|
126926
127539
|
if (allowed.allow !== true)
|
|
126927
127540
|
throw new Error(`Channel ingress refused: ${allowed.reason}`);
|
|
126928
127541
|
const reserved = checkedDecision(await routes.reserve(decision2));
|
|
126929
|
-
if (!
|
|
127542
|
+
if (!isDeepStrictEqual12(reserved, decision2))
|
|
126930
127543
|
throw new Error("Channel routing decision changed during acceptance.");
|
|
126931
127544
|
decision2 = reserved;
|
|
126932
127545
|
pals.getRevision(decision2.recipient.palId, decision2.profileRevision);
|
|
@@ -126973,7 +127586,7 @@ var PalChannelIngress = class {
|
|
|
126973
127586
|
};
|
|
126974
127587
|
|
|
126975
127588
|
// ../sdk/dist/pals/channels/routing.js
|
|
126976
|
-
import { isDeepStrictEqual as
|
|
127589
|
+
import { isDeepStrictEqual as isDeepStrictEqual13 } from "node:util";
|
|
126977
127590
|
var contextSchema = external_exports.object({
|
|
126978
127591
|
recipient: addressSchema2,
|
|
126979
127592
|
sessionId: external_exports.custom((value) => isEntityId(value, "session")),
|
|
@@ -127012,11 +127625,11 @@ var PalChannelRouter = class {
|
|
|
127012
127625
|
if (!found)
|
|
127013
127626
|
throw new Error("Channel response does not name an accepted delivery.");
|
|
127014
127627
|
const message = freezeCommunicationValue(ingressInboxSchema.parse(found));
|
|
127015
|
-
if (!("kind" in message) || message.kind !== "channel" || message.phase !== "recorded" || !message.receipt || !
|
|
127628
|
+
if (!("kind" in message) || message.kind !== "channel" || message.phase !== "recorded" || !message.receipt || !isDeepStrictEqual13(ingressMessageRef(message), ref))
|
|
127016
127629
|
throw new Error("Channel response requires the exact recorded channel delivery.");
|
|
127017
127630
|
if (message.source.tenantId !== this.connection.tenantId || message.source.provider !== this.connection.provider || message.source.connectionId !== this.connection.connectionId || message.source.externalTenantId !== this.connection.externalTenantId)
|
|
127018
127631
|
throw new Error("Channel response belongs to another connection.");
|
|
127019
|
-
if (!
|
|
127632
|
+
if (!isDeepStrictEqual13(nativeTuple(message.source), nativeTuple(message.routeKey)))
|
|
127020
127633
|
throw new Error("Channel message source does not match its original native route.");
|
|
127021
127634
|
const binding = await this.options.store.routeIngress(message.routeKey);
|
|
127022
127635
|
if (!binding || binding.id !== message.routeId || binding.phase !== "active" || binding.sessionId !== context2.sessionId || binding.profileRevision !== context2.profileRevision || binding.key.recipient.palId !== context2.recipient.palId || binding.key.recipient.tenantId !== context2.recipient.tenantId)
|
|
@@ -127033,7 +127646,7 @@ var PalChannelRouter = class {
|
|
|
127033
127646
|
}
|
|
127034
127647
|
async resolve(input2, context2, signal, action) {
|
|
127035
127648
|
const message = await this.recorded(input2, context2, signal);
|
|
127036
|
-
if (action && (action.externalTenantId !== message.source.externalTenantId || !
|
|
127649
|
+
if (action && (action.externalTenantId !== message.source.externalTenantId || !isDeepStrictEqual13(nativeTuple({
|
|
127037
127650
|
...action,
|
|
127038
127651
|
provider: this.connection.provider,
|
|
127039
127652
|
connectionId: this.connection.connectionId
|
|
@@ -127099,7 +127712,7 @@ var PalChannelRouter = class {
|
|
|
127099
127712
|
// ../sdk/dist/pals/activity/subscription-store.js
|
|
127100
127713
|
import { chmodSync as chmodSync8, lstatSync as lstatSync12, mkdirSync as mkdirSync13, readdirSync as readdirSync7, realpathSync as realpathSync11 } from "node:fs";
|
|
127101
127714
|
import { join as join54, resolve as resolve33 } from "node:path";
|
|
127102
|
-
import { isDeepStrictEqual as
|
|
127715
|
+
import { isDeepStrictEqual as isDeepStrictEqual14 } from "node:util";
|
|
127103
127716
|
|
|
127104
127717
|
// ../sdk/dist/pals/activity/subscription-schema.js
|
|
127105
127718
|
var positive6 = external_exports.number().int().positive().safe();
|
|
@@ -127244,12 +127857,12 @@ var DiskPalActivitySubscriptionStore = class {
|
|
|
127244
127857
|
throw new Error("Subscription cursor cannot precede its root.");
|
|
127245
127858
|
if (captured.cursor) {
|
|
127246
127859
|
const previous = captured.cursor;
|
|
127247
|
-
if (cursor.scopeHash !== previous.scopeHash || !
|
|
127860
|
+
if (cursor.scopeHash !== previous.scopeHash || !isDeepStrictEqual14(cursor.root, previous.root) || cursor.after.seq < previous.after.seq || cursor.after.offset < previous.after.offset || cursor.generation < previous.generation || cursor.after.seq === previous.after.seq && !isDeepStrictEqual14(cursor, previous))
|
|
127248
127861
|
throw new Error("Subscription cursor identity changed or moved backwards.");
|
|
127249
127862
|
}
|
|
127250
127863
|
return this.records.transact(this.location(captured.id), (stored) => {
|
|
127251
127864
|
const current = stored === null ? null : this.checked(stored, captured.id);
|
|
127252
|
-
if (!current || !current.enabled || !
|
|
127865
|
+
if (!current || !current.enabled || !isDeepStrictEqual14(current, captured))
|
|
127253
127866
|
throw new PalActivitySubscriptionConflictError("Subscription changed before accepted progress could commit.");
|
|
127254
127867
|
const record4 = this.checked({ ...current, revision: current.revision + 1, cursor }, current.id);
|
|
127255
127868
|
return { record: record4, result: record4 };
|
|
@@ -127260,7 +127873,7 @@ var DiskPalActivitySubscriptionStore = class {
|
|
|
127260
127873
|
// ../sdk/dist/pals/activity/subscription-policy.js
|
|
127261
127874
|
import { chmodSync as chmodSync9, lstatSync as lstatSync13, mkdirSync as mkdirSync14, readdirSync as readdirSync8, realpathSync as realpathSync12 } from "node:fs";
|
|
127262
127875
|
import { join as join55, resolve as resolve34 } from "node:path";
|
|
127263
|
-
import { isDeepStrictEqual as
|
|
127876
|
+
import { isDeepStrictEqual as isDeepStrictEqual15 } from "node:util";
|
|
127264
127877
|
var PalActivitySubscriptionPermissionConflictError = class extends Error {
|
|
127265
127878
|
static {
|
|
127266
127879
|
__name(this, "PalActivitySubscriptionPermissionConflictError");
|
|
@@ -127358,13 +127971,13 @@ var DiskPalActivitySubscriptionPolicy = class {
|
|
|
127358
127971
|
const captured = freezeCommunicationValue(subscriptionSchema.parse(request.subscription));
|
|
127359
127972
|
const stored = await this.subscriptions.get(captured.id);
|
|
127360
127973
|
const subscription = stored ? freezeCommunicationValue(subscriptionSchema.parse(stored)) : null;
|
|
127361
|
-
if (!subscription?.enabled || subscription.configurationRevision !== captured.configurationRevision || !
|
|
127974
|
+
if (!subscription?.enabled || subscription.configurationRevision !== captured.configurationRevision || !isDeepStrictEqual15(subscription.scope, captured.scope) || !isDeepStrictEqual15(subscription.recipient, captured.recipient))
|
|
127362
127975
|
return denied();
|
|
127363
127976
|
const observed = await this.get(subscription.id);
|
|
127364
127977
|
if (!permitted(observed))
|
|
127365
127978
|
return denied();
|
|
127366
127979
|
const current = await this.subscriptions.get(subscription.id);
|
|
127367
|
-
if (!current?.enabled || current.configurationRevision !== captured.configurationRevision || !
|
|
127980
|
+
if (!current?.enabled || current.configurationRevision !== captured.configurationRevision || !isDeepStrictEqual15(current.scope, captured.scope) || !isDeepStrictEqual15(current.recipient, captured.recipient))
|
|
127368
127981
|
return denied();
|
|
127369
127982
|
const rule = await this.get(subscription.id);
|
|
127370
127983
|
if (!rule || !permitted(rule))
|
|
@@ -127391,13 +128004,13 @@ var DiskPalActivitySubscriptionPolicy = class {
|
|
|
127391
128004
|
const phase = external_exports.enum(["accept", "deliver", "wake"]).parse(request.phase);
|
|
127392
128005
|
const stored = await this.subscriptions.get(id3);
|
|
127393
128006
|
const subscription = stored ? freezeCommunicationValue(subscriptionSchema.parse(stored)) : null;
|
|
127394
|
-
if (!subscription?.enabled || request.routeKey.kind !== "observation" || request.routeKey.subscriptionId !== id3 || !
|
|
128007
|
+
if (!subscription?.enabled || request.routeKey.kind !== "observation" || request.routeKey.subscriptionId !== id3 || !isDeepStrictEqual15(request.source.scope, subscription.scope) || !isDeepStrictEqual15(request.routeKey.scope, subscription.scope) || !isDeepStrictEqual15(request.recipient, subscription.recipient) || !isDeepStrictEqual15(request.routeKey.recipient, subscription.recipient))
|
|
127395
128008
|
return denied();
|
|
127396
128009
|
const observed = await this.get(id3);
|
|
127397
128010
|
if (!observed?.observe || !observed.disclose || !observed.receive || phase === "wake" && !observed.wake)
|
|
127398
128011
|
return denied();
|
|
127399
128012
|
const current = await this.subscriptions.get(id3);
|
|
127400
|
-
if (!current?.enabled || current.configurationRevision !== subscription.configurationRevision || !
|
|
128013
|
+
if (!current?.enabled || current.configurationRevision !== subscription.configurationRevision || !isDeepStrictEqual15(current.scope, subscription.scope) || !isDeepStrictEqual15(current.recipient, subscription.recipient))
|
|
127401
128014
|
return denied();
|
|
127402
128015
|
const rule = await this.get(id3);
|
|
127403
128016
|
if (!rule?.observe || !rule.disclose || !rule.receive || phase === "wake" && !rule.wake)
|
|
@@ -127413,7 +128026,7 @@ var DiskPalActivitySubscriptionPolicy = class {
|
|
|
127413
128026
|
};
|
|
127414
128027
|
|
|
127415
128028
|
// ../sdk/dist/pals/activity/subscriptions.js
|
|
127416
|
-
import { isDeepStrictEqual as
|
|
128029
|
+
import { isDeepStrictEqual as isDeepStrictEqual16 } from "node:util";
|
|
127417
128030
|
var PalActivitySubscriptionDeniedError = class extends Error {
|
|
127418
128031
|
static {
|
|
127419
128032
|
__name(this, "PalActivitySubscriptionDeniedError");
|
|
@@ -127439,7 +128052,7 @@ async function publishPalActivityOnce(options, id3, input2) {
|
|
|
127439
128052
|
signal.throwIfAborted();
|
|
127440
128053
|
const value = await subscriptions.get(subscriptionId);
|
|
127441
128054
|
signal.throwIfAborted();
|
|
127442
|
-
if (!value?.enabled || value.configurationRevision !== subscription.configurationRevision || !
|
|
128055
|
+
if (!value?.enabled || value.configurationRevision !== subscription.configurationRevision || !isDeepStrictEqual16(value.scope, subscription.scope) || !isDeepStrictEqual16(value.recipient, subscription.recipient))
|
|
127443
128056
|
throw new PalActivitySubscriptionDeniedError();
|
|
127444
128057
|
}
|
|
127445
128058
|
__name(current, "current");
|
|
@@ -127510,7 +128123,7 @@ async function publishPalActivityOnce(options, id3, input2) {
|
|
|
127510
128123
|
subscriptionTrail: [...lineage, subscription.id],
|
|
127511
128124
|
replyTo: null,
|
|
127512
128125
|
grant: {
|
|
127513
|
-
id:
|
|
128126
|
+
id: hash3([
|
|
127514
128127
|
"pal-observation-grants/1",
|
|
127515
128128
|
subscription.id,
|
|
127516
128129
|
observed.id,
|
|
@@ -127518,7 +128131,7 @@ async function publishPalActivityOnce(options, id3, input2) {
|
|
|
127518
128131
|
received2.id,
|
|
127519
128132
|
acceptedGrant.id
|
|
127520
128133
|
]),
|
|
127521
|
-
revision:
|
|
128134
|
+
revision: hash3([
|
|
127522
128135
|
subscription.configurationRevision,
|
|
127523
128136
|
observed.revision,
|
|
127524
128137
|
disclosed.revision,
|
|
@@ -127545,7 +128158,7 @@ async function publishPalActivityOnce(options, id3, input2) {
|
|
|
127545
128158
|
}
|
|
127546
128159
|
}
|
|
127547
128160
|
await permitted("observe");
|
|
127548
|
-
const next2 = subscription.cursor &&
|
|
128161
|
+
const next2 = subscription.cursor && isDeepStrictEqual16(subscription.cursor, page.cursor) ? subscription : await subscriptions.advance(subscription, page.cursor);
|
|
127549
128162
|
return freezeCommunicationValue({
|
|
127550
128163
|
subscription: next2,
|
|
127551
128164
|
accepted,
|
|
@@ -127556,8 +128169,8 @@ async function publishPalActivityOnce(options, id3, input2) {
|
|
|
127556
128169
|
__name(publishPalActivityOnce, "publishPalActivityOnce");
|
|
127557
128170
|
|
|
127558
128171
|
// ../sdk/dist/pals/activity/causality.js
|
|
127559
|
-
import { createHash as
|
|
127560
|
-
import { isDeepStrictEqual as
|
|
128172
|
+
import { createHash as createHash41 } from "node:crypto";
|
|
128173
|
+
import { isDeepStrictEqual as isDeepStrictEqual17 } from "node:util";
|
|
127561
128174
|
var requestMarkerSchema = external_exports.object({
|
|
127562
128175
|
type: external_exports.literal("request_envelope"),
|
|
127563
128176
|
iteration: external_exports.literal(1),
|
|
@@ -127635,7 +128248,7 @@ function createPalActivityCausalityResolver(options) {
|
|
|
127635
128248
|
const root = entries2[0]?.record;
|
|
127636
128249
|
if (root?.type !== "session_started" || root.parent || root.forkedFrom || root.tenantId !== scope.tenantId || root.projectId !== scope.projectId || root.cwd !== workspace || root.origin?.protocol !== "desktop" || root.origin.externalSessionId !== JSON.stringify(["namzu-pal", scope.palId, scope.profileRevision, scope.sessionId]))
|
|
127637
128250
|
unavailable3();
|
|
127638
|
-
const scopeHash =
|
|
128251
|
+
const scopeHash = createHash41("sha256").update(JSON.stringify([
|
|
127639
128252
|
"pal-activity/1",
|
|
127640
128253
|
scope.tenantId,
|
|
127641
128254
|
scope.projectId,
|
|
@@ -127645,7 +128258,7 @@ function createPalActivityCausalityResolver(options) {
|
|
|
127645
128258
|
workspace
|
|
127646
128259
|
])).digest("hex");
|
|
127647
128260
|
const original = entries2.find((e) => e.record.seq === fact.seq);
|
|
127648
|
-
if (!original || !
|
|
128261
|
+
if (!original || !isDeepStrictEqual17(projectPalActivity(original, scopeHash), fact) || !fact.turnId)
|
|
127649
128262
|
unavailable3();
|
|
127650
128263
|
const turnId6 = fact.turnId;
|
|
127651
128264
|
const firstRequest = entries2.find((e) => e.record.type === "request_envelope" && e.record.turnId === turnId6);
|
|
@@ -127682,13 +128295,13 @@ function createPalActivityCausalityResolver(options) {
|
|
|
127682
128295
|
return unavailable3();
|
|
127683
128296
|
const receipt2 = ingressReceiptSchema.parse(message.receipt);
|
|
127684
128297
|
const covered = entries2.find((candidate) => candidate.record.seq === receipt2.through.pointer.seq);
|
|
127685
|
-
if (!covered || !
|
|
128298
|
+
if (!covered || !isDeepStrictEqual17(covered.pointer, receipt2.through.pointer) || covered.record.gen !== receipt2.through.gen || receipt2.through.bytes !== covered.pointer.offset + covered.pointer.length)
|
|
127686
128299
|
return unavailable3();
|
|
127687
128300
|
const parsedRoute = ingressBindingSchema.safeParse(state?.routes.find((r) => r.id === message.routeId));
|
|
127688
128301
|
if (!parsedRoute.success)
|
|
127689
128302
|
return unavailable3();
|
|
127690
128303
|
const route = parsedRoute.data;
|
|
127691
|
-
if (!route || route.phase !== "active" || !
|
|
128304
|
+
if (!route || route.phase !== "active" || !isDeepStrictEqual17(route.key, message.routeKey) || route.sessionId !== scope.sessionId || route.profileRevision !== scope.profileRevision || route.key.recipient.palId !== scope.palId || route.key.recipient.tenantId !== scope.tenantId)
|
|
127692
128305
|
unavailable3();
|
|
127693
128306
|
if (message && "kind" in message && message.kind === "observation")
|
|
127694
128307
|
for (const id3 of message.subscriptionTrail)
|
|
@@ -130041,7 +130654,7 @@ ${observed}
|
|
|
130041
130654
|
});
|
|
130042
130655
|
|
|
130043
130656
|
// ../sdk/dist/tools/builtins/skill.js
|
|
130044
|
-
import { createHash as
|
|
130657
|
+
import { createHash as createHash42 } from "node:crypto";
|
|
130045
130658
|
var inputSchema16 = external_exports.object({
|
|
130046
130659
|
name: external_exports.string().min(1).optional().describe("The skill to load, exactly as listed in the available-skills manifest. Omit it to list model-invocable skills."),
|
|
130047
130660
|
args: external_exports.string().max(8e3).optional().describe("What to apply the skill to, in your own words. A skill that runs as a delegated agent sees only this and its own instructions, so say what it needs. Omit it on a continuation."),
|
|
@@ -130052,7 +130665,7 @@ var LIST_CURSOR_PATTERN = /^v1\.list\.(0|[1-9][0-9]*)\.([01])\.([A-Za-z0-9_-]{43
|
|
|
130052
130665
|
var MAX_SKILLS_PER_PAGE = 20;
|
|
130053
130666
|
var OVERSIZED_CATALOG_WARNING = "Some skills were omitted because their metadata is too large for this response budget.";
|
|
130054
130667
|
function snapshotDigest(snapshot) {
|
|
130055
|
-
return
|
|
130668
|
+
return createHash42("sha256").update(JSON.stringify({
|
|
130056
130669
|
version: 1,
|
|
130057
130670
|
name: snapshot.name,
|
|
130058
130671
|
body: snapshot.body,
|
|
@@ -130096,7 +130709,7 @@ function activeOutputCap(maxChars2) {
|
|
|
130096
130709
|
}
|
|
130097
130710
|
__name(activeOutputCap, "activeOutputCap");
|
|
130098
130711
|
function listDigest(skills, maxChars2) {
|
|
130099
|
-
return
|
|
130712
|
+
return createHash42("sha256").update(JSON.stringify({ version: 1, kind: "list", maxChars: maxChars2 ?? null, skills })).digest("base64url");
|
|
130100
130713
|
}
|
|
130101
130714
|
__name(listDigest, "listDigest");
|
|
130102
130715
|
function serializeListPage(page) {
|
|
@@ -135577,7 +136190,7 @@ function createPalMessagingTools(options) {
|
|
|
135577
136190
|
await assertCurrent(context2);
|
|
135578
136191
|
if (typeof context2.toolBatchId !== "string" || !context2.toolBatchId || typeof context2.toolUseId !== "string" || !context2.toolUseId)
|
|
135579
136192
|
throw new Error("Pal messaging requires executor toolBatchId and toolUseId.");
|
|
135580
|
-
const operationId =
|
|
136193
|
+
const operationId = hash3([
|
|
135581
136194
|
1,
|
|
135582
136195
|
"pal-message-tool",
|
|
135583
136196
|
source.conversationId,
|
|
@@ -135913,6 +136526,8 @@ export {
|
|
|
135913
136526
|
MCP_LEGACY_VERSIONS,
|
|
135914
136527
|
MCP_SUPPORTED_PROTOCOL_VERSIONS,
|
|
135915
136528
|
DEFAULT_MCP_REQUEST_TIMEOUT_MS,
|
|
136529
|
+
DEFAULT_MCP_TOTAL_TIMEOUT_FACTOR,
|
|
136530
|
+
MCP_TOOL_DEADLINE_SLACK_MS,
|
|
135916
136531
|
JSON_RPC_INVALID_PARAMS,
|
|
135917
136532
|
JSON_RPC_METHOD_NOT_FOUND,
|
|
135918
136533
|
RESOURCE_NOT_FOUND_CODES,
|
|
@@ -136194,6 +136809,7 @@ export {
|
|
|
136194
136809
|
TurnFailedRecordSchema,
|
|
136195
136810
|
MessageRecordSchema,
|
|
136196
136811
|
MessageReplacedRecordSchema,
|
|
136812
|
+
MessageEditedRecordSchema,
|
|
136197
136813
|
CompactionRecordSchema,
|
|
136198
136814
|
TurnOutcomeRecordedRecordSchema,
|
|
136199
136815
|
ChildOutcomeRecordedRecordSchema,
|
|
@@ -136216,6 +136832,7 @@ export {
|
|
|
136216
136832
|
LineSplitter,
|
|
136217
136833
|
readSessionLogTail,
|
|
136218
136834
|
verifyPointer,
|
|
136835
|
+
foldSessionLog,
|
|
136219
136836
|
TurnInProgressError,
|
|
136220
136837
|
isTurnInProgressError,
|
|
136221
136838
|
withMessageId,
|
|
@@ -137099,4 +137716,4 @@ export {
|
|
|
137099
137716
|
WakeBudget,
|
|
137100
137717
|
wakeBudgetFromEnv
|
|
137101
137718
|
};
|
|
137102
|
-
//# sourceMappingURL=chunk-
|
|
137719
|
+
//# sourceMappingURL=chunk-W4BOQPYP.js.map
|