@theokit/sdk 4.35.0 → 4.37.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 +42 -0
- package/dist/agent-K5LYVJGJ.cjs +51 -0
- package/dist/{agent-P77NPBF4.cjs.map → agent-K5LYVJGJ.cjs.map} +1 -1
- package/dist/agent-ODWMOAEC.js +42 -0
- package/dist/{agent-H6HL5ITH.js.map → agent-ODWMOAEC.js.map} +1 -1
- package/dist/agent.d.ts +2 -1
- package/dist/auth/index.cjs +15 -15
- package/dist/auth/index.js +4 -4
- package/dist/{batch-2FSD2UNL.cjs → batch-3SEPDXCU.cjs} +23 -23
- package/dist/{batch-2FSD2UNL.cjs.map → batch-3SEPDXCU.cjs.map} +1 -1
- package/dist/{batch-MR2HKYMS.js → batch-SY5GZLFD.js} +9 -9
- package/dist/{batch-MR2HKYMS.js.map → batch-SY5GZLFD.js.map} +1 -1
- package/dist/{chunk-JLMXKTBX.cjs → chunk-2423XDPT.cjs} +26 -26
- package/dist/{chunk-JLMXKTBX.cjs.map → chunk-2423XDPT.cjs.map} +1 -1
- package/dist/{chunk-5IB2UKSN.js → chunk-2WFB5ZOX.js} +5 -5
- package/dist/{chunk-5IB2UKSN.js.map → chunk-2WFB5ZOX.js.map} +1 -1
- package/dist/{chunk-EPYZOCOL.cjs → chunk-3ILFUXNE.cjs} +5 -5
- package/dist/{chunk-EPYZOCOL.cjs.map → chunk-3ILFUXNE.cjs.map} +1 -1
- package/dist/{chunk-KSKU6JY6.cjs → chunk-3O2ELBST.cjs} +5 -5
- package/dist/{chunk-KSKU6JY6.cjs.map → chunk-3O2ELBST.cjs.map} +1 -1
- package/dist/{chunk-M2PU44HP.cjs → chunk-4YB7B3RP.cjs} +8 -8
- package/dist/{chunk-M2PU44HP.cjs.map → chunk-4YB7B3RP.cjs.map} +1 -1
- package/dist/{chunk-S2BBRVQX.js → chunk-56OXYUZE.js} +8 -7
- package/dist/chunk-56OXYUZE.js.map +1 -0
- package/dist/{chunk-D42XHI4O.cjs → chunk-56ZM6P7Z.cjs} +13 -14
- package/dist/chunk-56ZM6P7Z.cjs.map +1 -0
- package/dist/{chunk-7BTE3RXJ.js → chunk-5SB4V74H.js} +7 -8
- package/dist/chunk-5SB4V74H.js.map +1 -0
- package/dist/{chunk-MZ5ZRORA.cjs → chunk-6EDQBX7U.cjs} +17 -16
- package/dist/chunk-6EDQBX7U.cjs.map +1 -0
- package/dist/{chunk-RKG6QFCJ.js → chunk-6VP3XGEK.js} +4 -4
- package/dist/{chunk-RKG6QFCJ.js.map → chunk-6VP3XGEK.js.map} +1 -1
- package/dist/{chunk-KAP4GJHO.js → chunk-77WHPVXE.js} +10 -11
- package/dist/chunk-77WHPVXE.js.map +1 -0
- package/dist/{chunk-LALRCFSN.cjs → chunk-7DXLNNKH.cjs} +4 -4
- package/dist/{chunk-LALRCFSN.cjs.map → chunk-7DXLNNKH.cjs.map} +1 -1
- package/dist/{chunk-WEHUJ7ZS.cjs → chunk-ALU3KC4G.cjs} +267 -120
- package/dist/chunk-ALU3KC4G.cjs.map +1 -0
- package/dist/{chunk-Z2OC3UIW.cjs → chunk-BJMKQOY2.cjs} +11 -11
- package/dist/{chunk-Z2OC3UIW.cjs.map → chunk-BJMKQOY2.cjs.map} +1 -1
- package/dist/{chunk-WLKFWQSJ.js → chunk-CD73YHEH.js} +3 -3
- package/dist/{chunk-WLKFWQSJ.js.map → chunk-CD73YHEH.js.map} +1 -1
- package/dist/{chunk-BXV2QUIC.js → chunk-CSZRJ4RE.js} +6 -5
- package/dist/chunk-CSZRJ4RE.js.map +1 -0
- package/dist/{chunk-6M6A6WWW.cjs → chunk-D4ZUJTFB.cjs} +9 -10
- package/dist/chunk-D4ZUJTFB.cjs.map +1 -0
- package/dist/{chunk-XAUBQMQU.js → chunk-DCJ5MCJ3.js} +7 -7
- package/dist/{chunk-XAUBQMQU.js.map → chunk-DCJ5MCJ3.js.map} +1 -1
- package/dist/{chunk-Y66627E4.cjs → chunk-E7X2B66S.cjs} +24 -24
- package/dist/{chunk-Y66627E4.cjs.map → chunk-E7X2B66S.cjs.map} +1 -1
- package/dist/{chunk-6CLRANZA.js → chunk-EXQV452X.js} +3 -3
- package/dist/{chunk-6CLRANZA.js.map → chunk-EXQV452X.js.map} +1 -1
- package/dist/{chunk-EKFA76N4.js → chunk-F3X7Q4BF.js} +344 -453
- package/dist/chunk-F3X7Q4BF.js.map +1 -0
- package/dist/{chunk-XIG2IE3L.js → chunk-F6Y4IEQM.js} +5 -4
- package/dist/chunk-F6Y4IEQM.js.map +1 -0
- package/dist/{chunk-N24XBYNX.cjs → chunk-FAY3QDGC.cjs} +11 -10
- package/dist/chunk-FAY3QDGC.cjs.map +1 -0
- package/dist/{chunk-JD74LN7R.cjs → chunk-FK4EJD2I.cjs} +7 -6
- package/dist/chunk-FK4EJD2I.cjs.map +1 -0
- package/dist/{chunk-IX2LKBCD.js → chunk-GL7CFBVC.js} +176 -35
- package/dist/chunk-GL7CFBVC.js.map +1 -0
- package/dist/{chunk-77FOZCOT.js → chunk-GLUWH6JO.js} +6 -5
- package/dist/chunk-GLUWH6JO.js.map +1 -0
- package/dist/{chunk-RZQ6E5YZ.cjs → chunk-GM7QDQ24.cjs} +11 -11
- package/dist/{chunk-RZQ6E5YZ.cjs.map → chunk-GM7QDQ24.cjs.map} +1 -1
- package/dist/{chunk-G4WI3VW2.cjs → chunk-H5YVJB4K.cjs} +9 -10
- package/dist/chunk-H5YVJB4K.cjs.map +1 -0
- package/dist/{chunk-HRA3CPGG.js → chunk-HEN5WXXI.js} +9 -8
- package/dist/chunk-HEN5WXXI.js.map +1 -0
- package/dist/{chunk-LU7VALW5.js → chunk-I35DI7ES.js} +3 -3
- package/dist/{chunk-LU7VALW5.js.map → chunk-I35DI7ES.js.map} +1 -1
- package/dist/{chunk-TIZ4TS5V.cjs → chunk-ICYBIC6N.cjs} +8 -7
- package/dist/chunk-ICYBIC6N.cjs.map +1 -0
- package/dist/{chunk-2DYI7MIF.cjs → chunk-IEUDKUPM.cjs} +8 -8
- package/dist/{chunk-2DYI7MIF.cjs.map → chunk-IEUDKUPM.cjs.map} +1 -1
- package/dist/{chunk-AIDNODHJ.cjs → chunk-ITLS5LRF.cjs} +11 -11
- package/dist/{chunk-AIDNODHJ.cjs.map → chunk-ITLS5LRF.cjs.map} +1 -1
- package/dist/{chunk-M72RJVPC.js → chunk-JNIWFCKI.js} +3 -3
- package/dist/{chunk-M72RJVPC.js.map → chunk-JNIWFCKI.js.map} +1 -1
- package/dist/{chunk-LEJXBUBD.js → chunk-LISL36B6.js} +5 -5
- package/dist/{chunk-LEJXBUBD.js.map → chunk-LISL36B6.js.map} +1 -1
- package/dist/{chunk-3XJ7CS2C.cjs → chunk-LMWXF4LL.cjs} +554 -666
- package/dist/chunk-LMWXF4LL.cjs.map +1 -0
- package/dist/{chunk-BEURCLDV.cjs → chunk-LTCOPATU.cjs} +9 -3
- package/dist/chunk-LTCOPATU.cjs.map +1 -0
- package/dist/{chunk-TQKCU7CL.js → chunk-M5ZQBOIZ.js} +3 -3
- package/dist/{chunk-TQKCU7CL.js.map → chunk-M5ZQBOIZ.js.map} +1 -1
- package/dist/{chunk-A44COQJJ.cjs → chunk-MHCKWQR3.cjs} +8 -8
- package/dist/{chunk-A44COQJJ.cjs.map → chunk-MHCKWQR3.cjs.map} +1 -1
- package/dist/{chunk-7S7KKUO6.cjs → chunk-MRODLUGY.cjs} +4 -4
- package/dist/{chunk-7S7KKUO6.cjs.map → chunk-MRODLUGY.cjs.map} +1 -1
- package/dist/{chunk-BOTK6ZUP.js → chunk-MXSMAGDU.js} +3 -3
- package/dist/{chunk-BOTK6ZUP.js.map → chunk-MXSMAGDU.js.map} +1 -1
- package/dist/{chunk-5PZMMF4H.js → chunk-NFCKEBHI.js} +3 -3
- package/dist/{chunk-5PZMMF4H.js.map → chunk-NFCKEBHI.js.map} +1 -1
- package/dist/{chunk-6M4ODB2V.cjs → chunk-NNSKJCBM.cjs} +10 -10
- package/dist/{chunk-6M4ODB2V.cjs.map → chunk-NNSKJCBM.cjs.map} +1 -1
- package/dist/{chunk-4WL52CXU.cjs → chunk-NQ4AC2U4.cjs} +9 -9
- package/dist/{chunk-4WL52CXU.cjs.map → chunk-NQ4AC2U4.cjs.map} +1 -1
- package/dist/{chunk-YRXTIESB.cjs → chunk-P34DHHYQ.cjs} +4 -4
- package/dist/{chunk-YRXTIESB.cjs.map → chunk-P34DHHYQ.cjs.map} +1 -1
- package/dist/{chunk-HFPGOTVF.cjs → chunk-PAEJPLVN.cjs} +4 -4
- package/dist/{chunk-HFPGOTVF.cjs.map → chunk-PAEJPLVN.cjs.map} +1 -1
- package/dist/{chunk-S5RCBTSF.js → chunk-QFMXXUUT.js} +3 -3
- package/dist/{chunk-S5RCBTSF.js.map → chunk-QFMXXUUT.js.map} +1 -1
- package/dist/{chunk-V4XRLPEF.js → chunk-QGDKZDPN.js} +3 -3
- package/dist/{chunk-V4XRLPEF.js.map → chunk-QGDKZDPN.js.map} +1 -1
- package/dist/{chunk-DHLZIMP6.cjs → chunk-QUFSDDNU.cjs} +15 -15
- package/dist/{chunk-DHLZIMP6.cjs.map → chunk-QUFSDDNU.cjs.map} +1 -1
- package/dist/{chunk-BFWPZMG7.js → chunk-SDIBMLL5.js} +8 -8
- package/dist/{chunk-BFWPZMG7.js.map → chunk-SDIBMLL5.js.map} +1 -1
- package/dist/{chunk-GIW4L6HY.cjs → chunk-SWIBQFPH.cjs} +4 -4
- package/dist/{chunk-GIW4L6HY.cjs.map → chunk-SWIBQFPH.cjs.map} +1 -1
- package/dist/{chunk-JTFYYKDT.js → chunk-TAPQWDW2.js} +9 -4
- package/dist/chunk-TAPQWDW2.js.map +1 -0
- package/dist/{chunk-4GTXATWK.cjs → chunk-THEYGCYS.cjs} +4 -4
- package/dist/{chunk-4GTXATWK.cjs.map → chunk-THEYGCYS.cjs.map} +1 -1
- package/dist/{chunk-CJVMDRQB.cjs → chunk-TQI3KRXZ.cjs} +5 -4
- package/dist/chunk-TQI3KRXZ.cjs.map +1 -0
- package/dist/{chunk-LUSXDZPV.cjs → chunk-U2WLFOA3.cjs} +4 -4
- package/dist/{chunk-LUSXDZPV.cjs.map → chunk-U2WLFOA3.cjs.map} +1 -1
- package/dist/{chunk-FKCC2MED.js → chunk-UQPDFW4E.js} +3 -3
- package/dist/{chunk-FKCC2MED.js.map → chunk-UQPDFW4E.js.map} +1 -1
- package/dist/{chunk-CR3DGWUQ.js → chunk-VNNK6AKU.js} +3 -3
- package/dist/{chunk-CR3DGWUQ.js.map → chunk-VNNK6AKU.js.map} +1 -1
- package/dist/{chunk-ANIZEWTU.cjs → chunk-W4QN5CMG.cjs} +9 -8
- package/dist/chunk-W4QN5CMG.cjs.map +1 -0
- package/dist/{chunk-POQT2OIF.js → chunk-WDGCZDRG.js} +3 -3
- package/dist/{chunk-POQT2OIF.js.map → chunk-WDGCZDRG.js.map} +1 -1
- package/dist/{chunk-Q56IYTBZ.js → chunk-XAEAMI5H.js} +4 -4
- package/dist/{chunk-Q56IYTBZ.js.map → chunk-XAEAMI5H.js.map} +1 -1
- package/dist/{chunk-BWT67BI4.cjs → chunk-XAYVHS2B.cjs} +4 -4
- package/dist/{chunk-BWT67BI4.cjs.map → chunk-XAYVHS2B.cjs.map} +1 -1
- package/dist/{chunk-KIO7QFIV.cjs → chunk-YBFDBOUN.cjs} +8 -8
- package/dist/{chunk-KIO7QFIV.cjs.map → chunk-YBFDBOUN.cjs.map} +1 -1
- package/dist/{chunk-BNIFFFH3.js → chunk-YCXMSDSP.js} +4 -4
- package/dist/{chunk-BNIFFFH3.js.map → chunk-YCXMSDSP.js.map} +1 -1
- package/dist/{chunk-UVNG67DG.js → chunk-YDLNI7J6.js} +3 -3
- package/dist/{chunk-UVNG67DG.js.map → chunk-YDLNI7J6.js.map} +1 -1
- package/dist/{chunk-UAYYNWYJ.js → chunk-YHZXBDAW.js} +5 -4
- package/dist/chunk-YHZXBDAW.js.map +1 -0
- package/dist/{chunk-OKXUMCGM.js → chunk-YVTNFKZO.js} +5 -5
- package/dist/{chunk-OKXUMCGM.js.map → chunk-YVTNFKZO.js.map} +1 -1
- package/dist/{chunk-GJAGKFTR.js → chunk-ZJN6NTHE.js} +3 -3
- package/dist/{chunk-GJAGKFTR.js.map → chunk-ZJN6NTHE.js.map} +1 -1
- package/dist/{chunk-XV2RBL6D.js → chunk-ZW345YOI.js} +8 -9
- package/dist/chunk-ZW345YOI.js.map +1 -0
- package/dist/compact-session-H5TKLD55.cjs +54 -0
- package/dist/{compact-session-BEA3IOON.cjs.map → compact-session-H5TKLD55.cjs.map} +1 -1
- package/dist/compact-session-WNKKIIDW.js +17 -0
- package/dist/{compact-session-5BDD4HIB.js.map → compact-session-WNKKIIDW.js.map} +1 -1
- package/dist/compaction.cjs +16 -16
- package/dist/compaction.js +3 -3
- package/dist/concurrency.cjs +6 -6
- package/dist/concurrency.js +4 -4
- package/dist/context-VAYLPT4O.js +5 -0
- package/dist/{context-GWANQLX4.js.map → context-VAYLPT4O.js.map} +1 -1
- package/dist/context-ZV33V4DC.cjs +22 -0
- package/dist/{context-KNWVTZSY.cjs.map → context-ZV33V4DC.cjs.map} +1 -1
- package/dist/cron.cjs +28 -28
- package/dist/cron.js +27 -27
- package/dist/errors.cjs +21 -21
- package/dist/errors.js +2 -2
- package/dist/eval.cjs +31 -31
- package/dist/eval.js +27 -27
- package/dist/{executor-Y4MKPIUD.cjs → executor-OZSYXDKF.cjs} +23 -23
- package/dist/{executor-Y4MKPIUD.cjs.map → executor-OZSYXDKF.cjs.map} +1 -1
- package/dist/{executor-ORJS5GV2.js → executor-PAH72CB5.js} +7 -7
- package/dist/{executor-ORJS5GV2.js.map → executor-PAH72CB5.js.map} +1 -1
- package/dist/filesystem/index.cjs +7 -7
- package/dist/filesystem/index.js +3 -3
- package/dist/fs-session-store-6MY7PNI2.js +10 -0
- package/dist/{fs-session-store-4ALCDU3K.js.map → fs-session-store-6MY7PNI2.js.map} +1 -1
- package/dist/fs-session-store-7E7UPLF2.cjs +19 -0
- package/dist/{fs-session-store-IQYE35HX.cjs.map → fs-session-store-7E7UPLF2.cjs.map} +1 -1
- package/dist/generate-object-5SCEH2EE.cjs +20 -0
- package/dist/{generate-object-H3RNAM6S.cjs.map → generate-object-5SCEH2EE.cjs.map} +1 -1
- package/dist/generate-object-I7UD4NWN.js +7 -0
- package/dist/{generate-object-YJPDV5BS.js.map → generate-object-I7UD4NWN.js.map} +1 -1
- package/dist/index-manager-KKAK7NT3.js +10 -0
- package/dist/{index-manager-P7ZUX2RG.js.map → index-manager-KKAK7NT3.js.map} +1 -1
- package/dist/index-manager-R6ZJFEZF.cjs +19 -0
- package/dist/{index-manager-H7HUMW52.cjs.map → index-manager-R6ZJFEZF.cjs.map} +1 -1
- package/dist/index.cjs +124 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +45 -50
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-SMH56NXP.cjs → inject-session-DM4SKTZO.cjs} +8 -8
- package/dist/{inject-session-SMH56NXP.cjs.map → inject-session-DM4SKTZO.cjs.map} +1 -1
- package/dist/{inject-session-V5FTK72N.js → inject-session-UXNJQTZ6.js} +6 -6
- package/dist/{inject-session-V5FTK72N.js.map → inject-session-UXNJQTZ6.js.map} +1 -1
- package/dist/internal/diagnostics.d.ts +54 -0
- package/dist/internal/local-agent/local-agent-invalidate.d.ts +0 -7
- package/dist/internal/local-agent/local-agent-lifecycle.d.ts +13 -0
- package/dist/internal/local-agent/local-agent.d.ts +1 -93
- package/dist/internal/persistence/index.cjs +25 -25
- package/dist/internal/persistence/index.js +6 -6
- package/dist/internal/persistence/sqlite-wal.d.cts +0 -9
- package/dist/internal/persistence/sqlite-wal.d.ts +0 -9
- package/dist/internal/persistence/transcript-ops.d.cts +14 -0
- package/dist/internal/persistence/transcript-ops.d.ts +14 -0
- package/dist/internal/plugins/lifecycle.d.cts +1 -0
- package/dist/internal/plugins/lifecycle.d.ts +1 -0
- package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +19 -0
- package/dist/internal/runtime/registry/agent-registry.d.ts +0 -1
- package/dist/internal/security/index.cjs +13 -13
- package/dist/internal/security/index.js +3 -3
- package/dist/internal/security/redact.d.cts +0 -18
- package/dist/internal/security/redact.d.ts +0 -18
- package/dist/judge-call-SP3G3X2Y.cjs +22 -0
- package/dist/{judge-call-2FULQ6KL.cjs.map → judge-call-SP3G3X2Y.cjs.map} +1 -1
- package/dist/judge-call-TAEIXMYG.js +5 -0
- package/dist/{judge-call-D7R3ZTZS.js.map → judge-call-TAEIXMYG.js.map} +1 -1
- package/dist/models.cjs +22 -26
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +13 -17
- package/dist/models.js.map +1 -1
- package/dist/path-safety.cjs +10 -10
- package/dist/path-safety.js +3 -3
- package/dist/persistence.cjs +27 -27
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +8 -8
- package/dist/persistence.js.map +1 -1
- package/dist/project.cjs +5 -5
- package/dist/project.js +3 -3
- package/dist/registry-N3GTKYCI.cjs +46 -0
- package/dist/{registry-APYDISL6.cjs.map → registry-N3GTKYCI.cjs.map} +1 -1
- package/dist/registry-SOXE4RY6.js +9 -0
- package/dist/{registry-34IWWDQQ.js.map → registry-SOXE4RY6.js.map} +1 -1
- package/dist/retry.cjs +4 -4
- package/dist/retry.js +3 -3
- package/dist/sandbox/index.cjs +6 -6
- package/dist/sandbox/index.js +2 -2
- package/dist/server/errors-envelope.cjs +14 -14
- package/dist/server/errors-envelope.js +3 -3
- package/dist/session-transcript-6WKLYIN4.js +5 -0
- package/dist/{session-transcript-F2ANTA2M.js.map → session-transcript-6WKLYIN4.js.map} +1 -1
- package/dist/session-transcript-EAKR4D2W.cjs +50 -0
- package/dist/{session-transcript-JXFMPLOT.cjs.map → session-transcript-EAKR4D2W.cjs.map} +1 -1
- package/dist/skills.cjs +7 -7
- package/dist/skills.js +5 -5
- package/dist/stream-object-OFM66VUT.js +7 -0
- package/dist/{stream-object-WUQSSRY2.js.map → stream-object-OFM66VUT.js.map} +1 -1
- package/dist/stream-object-Y7YCX3BI.cjs +20 -0
- package/dist/{stream-object-QEQJJDTI.cjs.map → stream-object-Y7YCX3BI.cjs.map} +1 -1
- package/dist/subagents-loader.cjs +23 -8
- package/dist/subagents-loader.cjs.map +1 -1
- package/dist/subagents-loader.d.cts +18 -3
- package/dist/subagents-loader.d.ts +18 -3
- package/dist/subagents-loader.js +23 -8
- package/dist/subagents-loader.js.map +1 -1
- package/dist/subscription/index.cjs +3 -3
- package/dist/subscription/index.js +2 -2
- package/dist/task-store.cjs +7 -7
- package/dist/task-store.js +4 -4
- package/dist/workflow.cjs +27 -27
- package/dist/workflow.js +6 -6
- package/package.json +1 -1
- package/dist/agent-H6HL5ITH.js +0 -42
- package/dist/agent-P77NPBF4.cjs +0 -51
- package/dist/chunk-3XJ7CS2C.cjs.map +0 -1
- package/dist/chunk-6M6A6WWW.cjs.map +0 -1
- package/dist/chunk-77FOZCOT.js.map +0 -1
- package/dist/chunk-7BTE3RXJ.js.map +0 -1
- package/dist/chunk-ANIZEWTU.cjs.map +0 -1
- package/dist/chunk-BEURCLDV.cjs.map +0 -1
- package/dist/chunk-BXV2QUIC.js.map +0 -1
- package/dist/chunk-CJVMDRQB.cjs.map +0 -1
- package/dist/chunk-D42XHI4O.cjs.map +0 -1
- package/dist/chunk-EKFA76N4.js.map +0 -1
- package/dist/chunk-G4WI3VW2.cjs.map +0 -1
- package/dist/chunk-HRA3CPGG.js.map +0 -1
- package/dist/chunk-IX2LKBCD.js.map +0 -1
- package/dist/chunk-JD74LN7R.cjs.map +0 -1
- package/dist/chunk-JTFYYKDT.js.map +0 -1
- package/dist/chunk-KAP4GJHO.js.map +0 -1
- package/dist/chunk-MZ5ZRORA.cjs.map +0 -1
- package/dist/chunk-N24XBYNX.cjs.map +0 -1
- package/dist/chunk-S2BBRVQX.js.map +0 -1
- package/dist/chunk-TIZ4TS5V.cjs.map +0 -1
- package/dist/chunk-UAYYNWYJ.js.map +0 -1
- package/dist/chunk-WEHUJ7ZS.cjs.map +0 -1
- package/dist/chunk-XIG2IE3L.js.map +0 -1
- package/dist/chunk-XV2RBL6D.js.map +0 -1
- package/dist/compact-session-5BDD4HIB.js +0 -17
- package/dist/compact-session-BEA3IOON.cjs +0 -54
- package/dist/context-GWANQLX4.js +0 -5
- package/dist/context-KNWVTZSY.cjs +0 -22
- package/dist/fs-session-store-4ALCDU3K.js +0 -10
- package/dist/fs-session-store-IQYE35HX.cjs +0 -19
- package/dist/generate-object-H3RNAM6S.cjs +0 -20
- package/dist/generate-object-YJPDV5BS.js +0 -7
- package/dist/index-manager-H7HUMW52.cjs +0 -19
- package/dist/index-manager-P7ZUX2RG.js +0 -10
- package/dist/judge-call-2FULQ6KL.cjs +0 -22
- package/dist/judge-call-D7R3ZTZS.js +0 -5
- package/dist/registry-34IWWDQQ.js +0 -9
- package/dist/registry-APYDISL6.cjs +0 -46
- package/dist/session-transcript-F2ANTA2M.js +0 -5
- package/dist/session-transcript-JXFMPLOT.cjs +0 -50
- package/dist/stream-object-QEQJJDTI.cjs +0 -20
- package/dist/stream-object-WUQSSRY2.js +0 -7
package/dist/persistence.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkPNVDQL5Y_cjs = require('./chunk-PNVDQL5Y.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var chunkP34DHHYQ_cjs = require('./chunk-P34DHHYQ.cjs');
|
|
5
|
+
var chunkTQI3KRXZ_cjs = require('./chunk-TQI3KRXZ.cjs');
|
|
6
|
+
var chunkFK4EJD2I_cjs = require('./chunk-FK4EJD2I.cjs');
|
|
7
7
|
var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
8
|
+
var chunkIEUDKUPM_cjs = require('./chunk-IEUDKUPM.cjs');
|
|
9
|
+
var chunkICYBIC6N_cjs = require('./chunk-ICYBIC6N.cjs');
|
|
10
|
+
var chunkMHCKWQR3_cjs = require('./chunk-MHCKWQR3.cjs');
|
|
11
|
+
require('./chunk-LTCOPATU.cjs');
|
|
12
12
|
var fs = require('fs');
|
|
13
13
|
|
|
14
|
-
var LiveSessionError = class extends
|
|
14
|
+
var LiveSessionError = class extends chunkMHCKWQR3_cjs.TheokitAgentError {
|
|
15
15
|
constructor(path) {
|
|
16
16
|
super(
|
|
17
17
|
`refusing to write over a live session transcript: ${path}. Fork to a new id instead \u2014 the live pointer, the most recent transcript and any active registry entry are never overwritten (audit-trail rotation, M60).`,
|
|
@@ -30,7 +30,7 @@ function forkTranscript(src, dst, options = {}) {
|
|
|
30
30
|
const kept = options.beforeRecordIndex === void 0 ? lines : lines.slice(0, options.beforeRecordIndex);
|
|
31
31
|
const body = kept.length > 0 ? `${kept.join("\n")}
|
|
32
32
|
` : "";
|
|
33
|
-
const fd = fs.openSync(dst, "wx");
|
|
33
|
+
const fd = fs.openSync(dst, "wx", options.mode ?? 384);
|
|
34
34
|
try {
|
|
35
35
|
fs.writeSync(fd, body);
|
|
36
36
|
} finally {
|
|
@@ -83,51 +83,51 @@ Object.defineProperty(exports, "PersistenceSchema", {
|
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "SessionBusyError", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkP34DHHYQ_cjs.SessionBusyError; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "acquireSessionWriter", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkP34DHHYQ_cjs.acquireSessionWriter; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "sessaoTemEscritor", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkP34DHHYQ_cjs.sessaoTemEscritor; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "JsonlParseError", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkTQI3KRXZ_cjs.JsonlParseError; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "appendJsonl", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkTQI3KRXZ_cjs.appendJsonl; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "loadJsonl", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkTQI3KRXZ_cjs.loadJsonl; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "readJsonlIds", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkTQI3KRXZ_cjs.readJsonlIds; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "withFileLock", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkTQI3KRXZ_cjs.withFileLock; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "applyWalWithFallback", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkFK4EJD2I_cjs.applyWalWithFallback; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "isCorruptionError", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkFK4EJD2I_cjs.isCorruptionError; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "openSqliteResilient", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkFK4EJD2I_cjs.openSqliteResilient; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "sanitizeFts5Query", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunkFK4EJD2I_cjs.sanitizeFts5Query; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "withCwdMutex", {
|
|
133
133
|
enumerable: true,
|
|
@@ -135,27 +135,27 @@ Object.defineProperty(exports, "withCwdMutex", {
|
|
|
135
135
|
});
|
|
136
136
|
Object.defineProperty(exports, "encodeProjectDir", {
|
|
137
137
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
138
|
+
get: function () { return chunkIEUDKUPM_cjs.encodeProjectDir; }
|
|
139
139
|
});
|
|
140
140
|
Object.defineProperty(exports, "transcriptPath", {
|
|
141
141
|
enumerable: true,
|
|
142
|
-
get: function () { return
|
|
142
|
+
get: function () { return chunkIEUDKUPM_cjs.transcriptPath; }
|
|
143
143
|
});
|
|
144
144
|
Object.defineProperty(exports, "transcriptRoot", {
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: function () { return
|
|
146
|
+
get: function () { return chunkIEUDKUPM_cjs.transcriptRoot; }
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(exports, "atomicWriteJson", {
|
|
149
149
|
enumerable: true,
|
|
150
|
-
get: function () { return
|
|
150
|
+
get: function () { return chunkICYBIC6N_cjs.atomicWriteJson; }
|
|
151
151
|
});
|
|
152
152
|
Object.defineProperty(exports, "atomicWriteText", {
|
|
153
153
|
enumerable: true,
|
|
154
|
-
get: function () { return
|
|
154
|
+
get: function () { return chunkICYBIC6N_cjs.atomicWriteText; }
|
|
155
155
|
});
|
|
156
156
|
Object.defineProperty(exports, "replaceFileAtomic", {
|
|
157
157
|
enumerable: true,
|
|
158
|
-
get: function () { return
|
|
158
|
+
get: function () { return chunkICYBIC6N_cjs.replaceFileAtomic; }
|
|
159
159
|
});
|
|
160
160
|
exports.LiveSessionError = LiveSessionError;
|
|
161
161
|
exports.forkTranscript = forkTranscript;
|
package/dist/persistence.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/persistence/transcript-ops.ts"],"names":["TheokitAgentError","readFileSync","openSync","writeSync","closeSync","statSync","readSync"],"mappings":";;;;;;;;;;;;;AAkCO,IAAM,gBAAA,GAAN,cAA+BA,mCAAA,CAAkB;AAAA,EAGtD,YAAqB,IAAA,EAAc;AACjC,IAAA,KAAA;AAAA,MACE,qDAAqD,IAAI,CAAA,+JAAA,CAAA;AAAA,MAGzD,EAAE,IAAA,EAAM,wBAAA,EAA0B,WAAA,EAAa,KAAA;AAAM,KACvD;AANmB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAOrB;AAAA,EAPqB,IAAA;AAAA,EAFH,IAAA,GAAO,kBAAA;AAU3B;AAqBO,SAAS,cAAA,CACd,GAAA,EACA,GAAA,EACA,OAAA,GAAiC,EAAC,EAC5B;AACN,EAAA,KAAA,MAAW,IAAA,IAAQ,OAAA,CAAQ,gBAAA,IAAoB,EAAC,EAAG;AACjD,IAAA,IAAI,IAAA,KAAS,GAAA,EAAK,MAAM,IAAI,iBAAiB,GAAG,CAAA;AAAA,EAClD;AAEA,EAAA,MAAM,KAAA,GAAQC,eAAA,CAAa,GAAA,EAAK,MAAM,EACnC,KAAA,CAAM,IAAI,CAAA,CACV,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,EAAK,CAAE,SAAS,CAAC,CAAA;AACpC,EAAA,MAAM,IAAA,GACJ,QAAQ,iBAAA,KAAsB,MAAA,GAAY,QAAQ,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,OAAA,CAAQ,iBAAiB,CAAA;AAC5F,EAAA,MAAM,IAAA,GAAO,KAAK,MAAA,GAAS,CAAA,GAAI,GAAG,IAAA,CAAK,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA,GAAO,EAAA;AAGxD,EAAA,MAAM,E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AAA,EAAU;AACjE;AAGA,SAAS,UAAU,KAAA,EAAyB;AAC1C,EAAA,OAAO,KAAA,CAAM,KAAA,CAAM,IAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,EAAK,CAAE,MAAA,GAAS,CAAC,CAAA;AAC5D;AASO,SAAS,aAAA,CACd,IAAA,EACA,OAAA,GAAgC,EAAC,EAC5B;AACL,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,iBAAA;AAC1C,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAA,EAAU,GAAI,aAAA,CAAc,MAAM,IAAI,CAAA;AAEtD,EAAA,IAAI,GAAA,GAAM,MAAA;AACV,EAAA,IAAI,OAAA,CAAQ,gBAAgB,MAAA,EAAW;AACrC,IAAA,MAAM,WAAW,OAAA,CAAQ,WAAA;AACzB,IAAA,MAAM,GAAA,GAAM,IAAI,aAAA,CAAc,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAC,CAAA;AACzD,IAAA,IAAI,OAAO,CAAA,EAAG,GAAA,GAAM,GAAA,CAAI,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,MAAA,CAAO,SAAS,IAAI,CAAA,QAAS,GAAA,CAAI,KAAA,CAAM,CAAC,IAAI,CAAA;AAEhD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,CAAC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAM,CAAA;AAC7C,EAAA,OAAO,OAAA,CAAQ,WAAW,IAAA,GAAQ,MAAA,CAAO,OAAO,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.cjs","sourcesContent":["/**\n * M81 — transcript operations the consumer was doing by hand INSIDE the framework's own store.\n *\n * ## What this replaces\n *\n * `agents/lib/session/backtrack.ts:188` (agent-builder) wrote straight into the session store with a\n * bare `writeFileSync` — no atomicity, no lock, no API. 243 lines re-implementing parse, cut and\n * write for a format the framework owns. The consumer is not at fault: nothing here was reachable.\n *\n * ## The rule that travels WITH the operation\n *\n * `rules/audit-trail-rotation.md § Session transcripts (M60)` defines a NEVER-delete list — the live\n * pointer, the most recent transcript, and any active registry entry. That rule lived in the\n * CONSUMER. Moving the operation here without moving the rule would ship an API able to destroy\n * exactly what the rule protects — the same shape of defect as M80's `reconcileUpdateGoalStatus`:\n * critical knowledge outside the module that needs it, applied by convention.\n *\n * So `forkTranscript` takes `liveSessionPaths` and refuses, with a TYPED error, to write over any of\n * them. The caller supplies the list because only the caller knows which session is live; the\n * enforcement lives here because that is where the write happens.\n *\n * @internal\n */\n\nimport { closeSync, openSync, readFileSync, readSync, statSync, writeSync } from \"node:fs\";\n\nimport { TheokitAgentError } from \"../../errors.js\";\n\n/**\n * M81 — the target is a protected session (live pointer / most-recent transcript / active entry).\n *\n * Typed rather than a bare `Error` because the caller must distinguish \"this session is protected\"\n * from \"the disk is full\": the first is a correct refusal, the second is an incident.\n */\nexport class LiveSessionError extends TheokitAgentError {\n override readonly name = \"LiveSessionError\";\n\n constructor(readonly path: string) {\n super(\n `refusing to write over a live session transcript: ${path}. ` +\n \"Fork to a new id instead — the live pointer, the most recent transcript and any active \" +\n \"registry entry are never overwritten (audit-trail rotation, M60).\",\n { code: \"live_session_protected\", isRetryable: false },\n );\n }\n}\n\n/** Options for {@link forkTranscript}. */\nexport interface ForkTranscriptOptions {\n /** Keep records `[0, beforeRecordIndex)`. Omit to copy the whole transcript. */\n readonly beforeRecordIndex?: number;\n /**\n * Paths that must never be written over — the live pointer, the most recent transcript, any active\n * registry entry. The caller supplies them because only the caller knows which session is live.\n */\n readonly liveSessionPaths?: readonly string[];\n}\n\n/**\n * Copy `src` into `dst`, keeping the first `beforeRecordIndex` records. The SOURCE is never touched.\n *\n * Atomicity comes from `wx` (exclusive create): two concurrent forks to the same destination cannot\n * both succeed — the loser gets `EEXIST` rather than writing over a half-written file. That is also\n * why an existing destination is a refusal, not a silent overwrite: losing a transcript without an\n * error is the worst failure mode for an operation that touches user sessions.\n */\nexport function forkTranscript(\n src: string,\n dst: string,\n options: ForkTranscriptOptions = {},\n): void {\n for (const live of options.liveSessionPaths ?? []) {\n if (live === dst) throw new LiveSessionError(dst);\n }\n\n const lines = readFileSync(src, \"utf8\")\n .split(\"\\n\")\n .filter((l) => l.trim().length > 0);\n const kept =\n options.beforeRecordIndex === undefined ? lines : lines.slice(0, options.beforeRecordIndex);\n const body = kept.length > 0 ? `${kept.join(\"\\n\")}\\n` : \"\";\n\n // `wx` — fails with EEXIST instead of truncating. The exclusivity IS the concurrency guarantee.\n const fd = openSync(dst, \"wx\");\n try {\n writeSync(fd, body);\n } finally {\n closeSync(fd);\n }\n}\n\n/** Options for {@link readJsonlTail}. */\nexport interface ReadJsonlTailOptions {\n /** Maximum records to return, counted from the END. */\n readonly maxRecords?: number;\n /** Stop once a line contains this marker (exclusive). */\n readonly sinceMarker?: string;\n /** Test-only: also report how many bytes were read, to prove the read is not whole-file. */\n readonly _stats?: boolean;\n}\n\nconst TAIL_CHUNK = 64 * 1024;\n\n/**\n * Lê chunks de trás para frente até acumular linhas completas suficientes.\n *\n * Extraído de `readJsonlTail` porque o laço de leitura e a seleção de registros são duas\n * responsabilidades — e juntas passavam do teto de complexidade. A primeira linha do buffer pode\n * estar cortada ao meio quando a leitura parou antes do início do arquivo; por isso ela é descartada.\n */\nfunction lerCaudaBruta(path: string, want: number): { linhas: string[]; bytesRead: number } {\n const size = statSync(path).size;\n const fd = openSync(path, \"r\");\n let bytesRead = 0;\n let tail = \"\";\n let pos = size;\n try {\n while (pos > 0) {\n const len = Math.min(TAIL_CHUNK, pos);\n pos -= len;\n const buf = Buffer.alloc(len);\n readSync(fd, buf, 0, len, pos);\n bytesRead += len;\n tail = buf.toString(\"utf8\") + tail;\n if (naoVazias(tail).length > want) break;\n }\n } finally {\n closeSync(fd);\n }\n const linhas = naoVazias(tail);\n return { linhas: pos > 0 ? linhas.slice(1) : linhas, bytesRead };\n}\n\n/** Linhas com conteúdo, na ordem do arquivo. */\nfunction naoVazias(texto: string): string[] {\n return texto.split(\"\\n\").filter((l) => l.trim().length > 0);\n}\n\n/**\n * Read the LAST records of a JSONL file without loading the whole thing.\n *\n * Reads fixed-size chunks backwards from EOF until enough newlines have been seen. A session\n * transcript grows without bound; loading megabytes to show the last three turns is the cost this\n * exists to avoid — and a `slice` over a full read would be that same cost with a better name.\n */\nexport function readJsonlTail<T = Record<string, unknown>>(\n path: string,\n options: ReadJsonlTailOptions = {},\n): T[] {\n const want = options.maxRecords ?? Number.POSITIVE_INFINITY;\n const { linhas, bytesRead } = lerCaudaBruta(path, want);\n\n let sel = linhas;\n if (options.sinceMarker !== undefined) {\n const marcador = options.sinceMarker;\n const idx = sel.findLastIndex((l) => l.includes(marcador));\n if (idx >= 0) sel = sel.slice(idx + 1);\n }\n if (Number.isFinite(want)) sel = sel.slice(-want);\n\n const out = sel.map((l) => JSON.parse(l) as T);\n return options._stats === true ? (Object.assign(out, { bytesRead }) as T[]) : out;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/internal/persistence/transcript-ops.ts"],"names":["TheokitAgentError","readFileSync","openSync","writeSync","closeSync","statSync","readSync"],"mappings":";;;;;;;;;;;;;AAkCO,IAAM,gBAAA,GAAN,cAA+BA,mCAAA,CAAkB;AAAA,EAGtD,YAAqB,IAAA,EAAc;AACjC,IAAA,KAAA;AAAA,MACE,qDAAqD,IAAI,CAAA,+JAAA,CAAA;AAAA,MAGzD,EAAE,IAAA,EAAM,wBAAA,EAA0B,WAAA,EAAa,KAAA;AAAM,KACvD;AANmB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAOrB;AAAA,EAPqB,IAAA;AAAA,EAFH,IAAA,GAAO,kBAAA;AAU3B;AAmCO,SAAS,cAAA,CACd,GAAA,EACA,GAAA,EACA,OAAA,GAAiC,EAAC,EAC5B;AACN,EAAA,KAAA,MAAW,IAAA,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,CAAE,QAAA,CAAS,QAAQ,CAAC,CAAA;AACzD,IAAA,IAAI,OAAO,CAAA,EAAG,GAAA,GAAM,GAAA,CAAI,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,MAAA,CAAO,SAAS,IAAI,CAAA,QAAS,GAAA,CAAI,KAAA,CAAM,CAAC,IAAI,CAAA;AAEhD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,CAAC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAM,CAAA;AAC7C,EAAA,OAAO,OAAA,CAAQ,WAAW,IAAA,GAAQ,MAAA,CAAO,OAAO,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.cjs","sourcesContent":["/**\n * M81 — transcript operations the consumer was doing by hand INSIDE the framework's own store.\n *\n * ## What this replaces\n *\n * `agents/lib/session/backtrack.ts:188` (agent-builder) wrote straight into the session store with a\n * bare `writeFileSync` — no atomicity, no lock, no API. 243 lines re-implementing parse, cut and\n * write for a format the framework owns. The consumer is not at fault: nothing here was reachable.\n *\n * ## The rule that travels WITH the operation\n *\n * `rules/audit-trail-rotation.md § Session transcripts (M60)` defines a NEVER-delete list — the live\n * pointer, the most recent transcript, and any active registry entry. That rule lived in the\n * CONSUMER. Moving the operation here without moving the rule would ship an API able to destroy\n * exactly what the rule protects — the same shape of defect as M80's `reconcileUpdateGoalStatus`:\n * critical knowledge outside the module that needs it, applied by convention.\n *\n * So `forkTranscript` takes `liveSessionPaths` and refuses, with a TYPED error, to write over any of\n * them. The caller supplies the list because only the caller knows which session is live; the\n * enforcement lives here because that is where the write happens.\n *\n * @internal\n */\n\nimport { closeSync, openSync, readFileSync, readSync, statSync, writeSync } from \"node:fs\";\n\nimport { TheokitAgentError } from \"../../errors.js\";\n\n/**\n * M81 — the target is a protected session (live pointer / most-recent transcript / active entry).\n *\n * Typed rather than a bare `Error` because the caller must distinguish \"this session is protected\"\n * from \"the disk is full\": the first is a correct refusal, the second is an incident.\n */\nexport class LiveSessionError extends TheokitAgentError {\n override readonly name = \"LiveSessionError\";\n\n constructor(readonly path: string) {\n super(\n `refusing to write over a live session transcript: ${path}. ` +\n \"Fork to a new id instead — the live pointer, the most recent transcript and any active \" +\n \"registry entry are never overwritten (audit-trail rotation, M60).\",\n { code: \"live_session_protected\", isRetryable: false },\n );\n }\n}\n\n/** Options for {@link forkTranscript}. */\nexport interface ForkTranscriptOptions {\n /** Keep records `[0, beforeRecordIndex)`. Omit to copy the whole transcript. */\n readonly beforeRecordIndex?: number;\n /**\n * Paths that must never be written over — the live pointer, the most recent transcript, any active\n * registry entry. The caller supplies them because only the caller knows which session is live.\n */\n readonly liveSessionPaths?: readonly string[];\n /**\n * M107 — permission bits for the created destination. Default: `0o600`.\n *\n * A transcript carries the conversation. Before M107 no mode was passed at all, so the file was\n * born `0o666 & ~umask` — measured `0o664` (group-WRITABLE) on a `umask 002` machine, `0o644` on\n * `umask 022`, `0o466` on `umask 0200`. This is a DEFAULT and not a required knob on purpose: a\n * knob would reach zero consumers by omission, which is the failure mode that matters.\n *\n * As with any `open` mode, the `umask` may still CLEAR bits — under `umask 0200` the result is\n * `0o400`. That is accepted: the invariant bought here is \"neither group nor others\", and `0o400`\n * satisfies it more strictly. The SDK deliberately does not `fchmod` the default back, because\n * that would hand back a bit the operator asked to remove.\n */\n readonly mode?: number;\n}\n\n/**\n * Copy `src` into `dst`, keeping the first `beforeRecordIndex` records. The SOURCE is never touched.\n *\n * Atomicity comes from `wx` (exclusive create): two concurrent forks to the same destination cannot\n * both succeed — the loser gets `EEXIST` rather than writing over a half-written file. That is also\n * why an existing destination is a refusal, not a silent overwrite: losing a transcript without an\n * error is the worst failure mode for an operation that touches user sessions.\n */\nexport function forkTranscript(\n src: string,\n dst: string,\n options: ForkTranscriptOptions = {},\n): void {\n for (const live of options.liveSessionPaths ?? []) {\n if (live === dst) throw new LiveSessionError(dst);\n }\n\n const lines = readFileSync(src, \"utf8\")\n .split(\"\\n\")\n .filter((l) => l.trim().length > 0);\n const kept =\n options.beforeRecordIndex === undefined ? lines : lines.slice(0, options.beforeRecordIndex);\n const body = kept.length > 0 ? `${kept.join(\"\\n\")}\\n` : \"\";\n\n // `wx` — fails with EEXIST instead of truncating. The exclusivity IS the concurrency guarantee,\n // and M107 only added the third argument: the mode. See `ForkTranscriptOptions.mode`.\n const fd = openSync(dst, \"wx\", options.mode ?? 0o600);\n try {\n writeSync(fd, body);\n } finally {\n closeSync(fd);\n }\n}\n\n/** Options for {@link readJsonlTail}. */\nexport interface ReadJsonlTailOptions {\n /** Maximum records to return, counted from the END. */\n readonly maxRecords?: number;\n /** Stop once a line contains this marker (exclusive). */\n readonly sinceMarker?: string;\n /** Test-only: also report how many bytes were read, to prove the read is not whole-file. */\n readonly _stats?: boolean;\n}\n\nconst TAIL_CHUNK = 64 * 1024;\n\n/**\n * Lê chunks de trás para frente até acumular linhas completas suficientes.\n *\n * Extraído de `readJsonlTail` porque o laço de leitura e a seleção de registros são duas\n * responsabilidades — e juntas passavam do teto de complexidade. A primeira linha do buffer pode\n * estar cortada ao meio quando a leitura parou antes do início do arquivo; por isso ela é descartada.\n */\nfunction lerCaudaBruta(path: string, want: number): { linhas: string[]; bytesRead: number } {\n const size = statSync(path).size;\n const fd = openSync(path, \"r\");\n let bytesRead = 0;\n let tail = \"\";\n let pos = size;\n try {\n while (pos > 0) {\n const len = Math.min(TAIL_CHUNK, pos);\n pos -= len;\n const buf = Buffer.alloc(len);\n readSync(fd, buf, 0, len, pos);\n bytesRead += len;\n tail = buf.toString(\"utf8\") + tail;\n if (naoVazias(tail).length > want) break;\n }\n } finally {\n closeSync(fd);\n }\n const linhas = naoVazias(tail);\n return { linhas: pos > 0 ? linhas.slice(1) : linhas, bytesRead };\n}\n\n/** Linhas com conteúdo, na ordem do arquivo. */\nfunction naoVazias(texto: string): string[] {\n return texto.split(\"\\n\").filter((l) => l.trim().length > 0);\n}\n\n/**\n * Read the LAST records of a JSONL file without loading the whole thing.\n *\n * Reads fixed-size chunks backwards from EOF until enough newlines have been seen. A session\n * transcript grows without bound; loading megabytes to show the last three turns is the cost this\n * exists to avoid — and a `slice` over a full read would be that same cost with a better name.\n */\nexport function readJsonlTail<T = Record<string, unknown>>(\n path: string,\n options: ReadJsonlTailOptions = {},\n): T[] {\n const want = options.maxRecords ?? Number.POSITIVE_INFINITY;\n const { linhas, bytesRead } = lerCaudaBruta(path, want);\n\n let sel = linhas;\n if (options.sinceMarker !== undefined) {\n const marcador = options.sinceMarker;\n const idx = sel.findLastIndex((l) => l.includes(marcador));\n if (idx >= 0) sel = sel.slice(idx + 1);\n }\n if (Number.isFinite(want)) sel = sel.slice(-want);\n\n const out = sel.map((l) => JSON.parse(l) as T);\n return options._stats === true ? (Object.assign(out, { bytesRead }) as T[]) : out;\n}\n"]}
|
package/dist/persistence.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { PersistenceSchema } from './chunk-CAH3G4IS.js';
|
|
2
|
-
export { SessionBusyError, acquireSessionWriter, sessaoTemEscritor } from './chunk-
|
|
3
|
-
export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-
|
|
4
|
-
export { applyWalWithFallback, isCorruptionError, openSqliteResilient, sanitizeFts5Query } from './chunk-
|
|
2
|
+
export { SessionBusyError, acquireSessionWriter, sessaoTemEscritor } from './chunk-MXSMAGDU.js';
|
|
3
|
+
export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-YHZXBDAW.js';
|
|
4
|
+
export { applyWalWithFallback, isCorruptionError, openSqliteResilient, sanitizeFts5Query } from './chunk-GLUWH6JO.js';
|
|
5
5
|
export { withCwdMutex } from './chunk-2XLKLVVR.js';
|
|
6
|
-
export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-
|
|
7
|
-
export { atomicWriteJson, atomicWriteText, replaceFileAtomic } from './chunk-
|
|
8
|
-
import { TheokitAgentError } from './chunk-
|
|
9
|
-
import './chunk-
|
|
6
|
+
export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-XAEAMI5H.js';
|
|
7
|
+
export { atomicWriteJson, atomicWriteText, replaceFileAtomic } from './chunk-56OXYUZE.js';
|
|
8
|
+
import { TheokitAgentError } from './chunk-CD73YHEH.js';
|
|
9
|
+
import './chunk-TAPQWDW2.js';
|
|
10
10
|
import { readFileSync, openSync, writeSync, closeSync, statSync, readSync } from 'fs';
|
|
11
11
|
|
|
12
12
|
var LiveSessionError = class extends TheokitAgentError {
|
|
@@ -28,7 +28,7 @@ function forkTranscript(src, dst, options = {}) {
|
|
|
28
28
|
const kept = options.beforeRecordIndex === void 0 ? lines : lines.slice(0, options.beforeRecordIndex);
|
|
29
29
|
const body = kept.length > 0 ? `${kept.join("\n")}
|
|
30
30
|
` : "";
|
|
31
|
-
const fd = openSync(dst, "wx");
|
|
31
|
+
const fd = openSync(dst, "wx", options.mode ?? 384);
|
|
32
32
|
try {
|
|
33
33
|
writeSync(fd, body);
|
|
34
34
|
} finally {
|
package/dist/persistence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/persistence/transcript-ops.ts"],"names":[],"mappings":";;;;;;;;;;;AAkCO,IAAM,gBAAA,GAAN,cAA+B,iBAAA,CAAkB;AAAA,EAGtD,YAAqB,IAAA,EAAc;AACjC,IAAA,KAAA;AAAA,MACE,qDAAqD,IAAI,CAAA,+JAAA,CAAA;AAAA,MAGzD,EAAE,IAAA,EAAM,wBAAA,EAA0B,WAAA,EAAa,KAAA;AAAM,KACvD;AANmB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAOrB;AAAA,EAPqB,IAAA;AAAA,EAFH,IAAA,GAAO,kBAAA;AAU3B;AAqBO,SAAS,cAAA,CACd,GAAA,EACA,GAAA,EACA,OAAA,GAAiC,EAAC,EAC5B;AACN,EAAA,KAAA,MAAW,IAAA,IAAQ,OAAA,CAAQ,gBAAA,IAAoB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,EAAG,GAAA,GAAM,GAAA,CAAI,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,MAAA,CAAO,SAAS,IAAI,CAAA,QAAS,GAAA,CAAI,KAAA,CAAM,CAAC,IAAI,CAAA;AAEhD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,CAAC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAM,CAAA;AAC7C,EAAA,OAAO,OAAA,CAAQ,WAAW,IAAA,GAAQ,MAAA,CAAO,OAAO,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.js","sourcesContent":["/**\n * M81 — transcript operations the consumer was doing by hand INSIDE the framework's own store.\n *\n * ## What this replaces\n *\n * `agents/lib/session/backtrack.ts:188` (agent-builder) wrote straight into the session store with a\n * bare `writeFileSync` — no atomicity, no lock, no API. 243 lines re-implementing parse, cut and\n * write for a format the framework owns. The consumer is not at fault: nothing here was reachable.\n *\n * ## The rule that travels WITH the operation\n *\n * `rules/audit-trail-rotation.md § Session transcripts (M60)` defines a NEVER-delete list — the live\n * pointer, the most recent transcript, and any active registry entry. That rule lived in the\n * CONSUMER. Moving the operation here without moving the rule would ship an API able to destroy\n * exactly what the rule protects — the same shape of defect as M80's `reconcileUpdateGoalStatus`:\n * critical knowledge outside the module that needs it, applied by convention.\n *\n * So `forkTranscript` takes `liveSessionPaths` and refuses, with a TYPED error, to write over any of\n * them. The caller supplies the list because only the caller knows which session is live; the\n * enforcement lives here because that is where the write happens.\n *\n * @internal\n */\n\nimport { closeSync, openSync, readFileSync, readSync, statSync, writeSync } from \"node:fs\";\n\nimport { TheokitAgentError } from \"../../errors.js\";\n\n/**\n * M81 — the target is a protected session (live pointer / most-recent transcript / active entry).\n *\n * Typed rather than a bare `Error` because the caller must distinguish \"this session is protected\"\n * from \"the disk is full\": the first is a correct refusal, the second is an incident.\n */\nexport class LiveSessionError extends TheokitAgentError {\n override readonly name = \"LiveSessionError\";\n\n constructor(readonly path: string) {\n super(\n `refusing to write over a live session transcript: ${path}. ` +\n \"Fork to a new id instead — the live pointer, the most recent transcript and any active \" +\n \"registry entry are never overwritten (audit-trail rotation, M60).\",\n { code: \"live_session_protected\", isRetryable: false },\n );\n }\n}\n\n/** Options for {@link forkTranscript}. */\nexport interface ForkTranscriptOptions {\n /** Keep records `[0, beforeRecordIndex)`. Omit to copy the whole transcript. */\n readonly beforeRecordIndex?: number;\n /**\n * Paths that must never be written over — the live pointer, the most recent transcript, any active\n * registry entry. The caller supplies them because only the caller knows which session is live.\n */\n readonly liveSessionPaths?: readonly string[];\n}\n\n/**\n * Copy `src` into `dst`, keeping the first `beforeRecordIndex` records. The SOURCE is never touched.\n *\n * Atomicity comes from `wx` (exclusive create): two concurrent forks to the same destination cannot\n * both succeed — the loser gets `EEXIST` rather than writing over a half-written file. That is also\n * why an existing destination is a refusal, not a silent overwrite: losing a transcript without an\n * error is the worst failure mode for an operation that touches user sessions.\n */\nexport function forkTranscript(\n src: string,\n dst: string,\n options: ForkTranscriptOptions = {},\n): void {\n for (const live of options.liveSessionPaths ?? []) {\n if (live === dst) throw new LiveSessionError(dst);\n }\n\n const lines = readFileSync(src, \"utf8\")\n .split(\"\\n\")\n .filter((l) => l.trim().length > 0);\n const kept =\n options.beforeRecordIndex === undefined ? lines : lines.slice(0, options.beforeRecordIndex);\n const body = kept.length > 0 ? `${kept.join(\"\\n\")}\\n` : \"\";\n\n // `wx` — fails with EEXIST instead of truncating. The exclusivity IS the concurrency guarantee.\n const fd = openSync(dst, \"wx\");\n try {\n writeSync(fd, body);\n } finally {\n closeSync(fd);\n }\n}\n\n/** Options for {@link readJsonlTail}. */\nexport interface ReadJsonlTailOptions {\n /** Maximum records to return, counted from the END. */\n readonly maxRecords?: number;\n /** Stop once a line contains this marker (exclusive). */\n readonly sinceMarker?: string;\n /** Test-only: also report how many bytes were read, to prove the read is not whole-file. */\n readonly _stats?: boolean;\n}\n\nconst TAIL_CHUNK = 64 * 1024;\n\n/**\n * Lê chunks de trás para frente até acumular linhas completas suficientes.\n *\n * Extraído de `readJsonlTail` porque o laço de leitura e a seleção de registros são duas\n * responsabilidades — e juntas passavam do teto de complexidade. A primeira linha do buffer pode\n * estar cortada ao meio quando a leitura parou antes do início do arquivo; por isso ela é descartada.\n */\nfunction lerCaudaBruta(path: string, want: number): { linhas: string[]; bytesRead: number } {\n const size = statSync(path).size;\n const fd = openSync(path, \"r\");\n let bytesRead = 0;\n let tail = \"\";\n let pos = size;\n try {\n while (pos > 0) {\n const len = Math.min(TAIL_CHUNK, pos);\n pos -= len;\n const buf = Buffer.alloc(len);\n readSync(fd, buf, 0, len, pos);\n bytesRead += len;\n tail = buf.toString(\"utf8\") + tail;\n if (naoVazias(tail).length > want) break;\n }\n } finally {\n closeSync(fd);\n }\n const linhas = naoVazias(tail);\n return { linhas: pos > 0 ? linhas.slice(1) : linhas, bytesRead };\n}\n\n/** Linhas com conteúdo, na ordem do arquivo. */\nfunction naoVazias(texto: string): string[] {\n return texto.split(\"\\n\").filter((l) => l.trim().length > 0);\n}\n\n/**\n * Read the LAST records of a JSONL file without loading the whole thing.\n *\n * Reads fixed-size chunks backwards from EOF until enough newlines have been seen. A session\n * transcript grows without bound; loading megabytes to show the last three turns is the cost this\n * exists to avoid — and a `slice` over a full read would be that same cost with a better name.\n */\nexport function readJsonlTail<T = Record<string, unknown>>(\n path: string,\n options: ReadJsonlTailOptions = {},\n): T[] {\n const want = options.maxRecords ?? Number.POSITIVE_INFINITY;\n const { linhas, bytesRead } = lerCaudaBruta(path, want);\n\n let sel = linhas;\n if (options.sinceMarker !== undefined) {\n const marcador = options.sinceMarker;\n const idx = sel.findLastIndex((l) => l.includes(marcador));\n if (idx >= 0) sel = sel.slice(idx + 1);\n }\n if (Number.isFinite(want)) sel = sel.slice(-want);\n\n const out = sel.map((l) => JSON.parse(l) as T);\n return options._stats === true ? (Object.assign(out, { bytesRead }) as T[]) : out;\n}\n"]}
|
|
1
|
+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,CAAA,KAAM,CAAA,CAAE,IAAA,EAAK,CAAE,MAAA,GAAS,CAAC,CAAA;AAC5D;AASO,SAAS,aAAA,CACd,IAAA,EACA,OAAA,GAAgC,EAAC,EAC5B;AACL,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,iBAAA;AAC1C,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAA,EAAU,GAAI,aAAA,CAAc,MAAM,IAAI,CAAA;AAEtD,EAAA,IAAI,GAAA,GAAM,MAAA;AACV,EAAA,IAAI,OAAA,CAAQ,gBAAgB,MAAA,EAAW;AACrC,IAAA,MAAM,WAAW,OAAA,CAAQ,WAAA;AACzB,IAAA,MAAM,GAAA,GAAM,IAAI,aAAA,CAAc,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAC,CAAA;AACzD,IAAA,IAAI,OAAO,CAAA,EAAG,GAAA,GAAM,GAAA,CAAI,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,MAAA,CAAO,SAAS,IAAI,CAAA,QAAS,GAAA,CAAI,KAAA,CAAM,CAAC,IAAI,CAAA;AAEhD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,CAAC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAM,CAAA;AAC7C,EAAA,OAAO,OAAA,CAAQ,WAAW,IAAA,GAAQ,MAAA,CAAO,OAAO,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.js","sourcesContent":["/**\n * M81 — transcript operations the consumer was doing by hand INSIDE the framework's own store.\n *\n * ## What this replaces\n *\n * `agents/lib/session/backtrack.ts:188` (agent-builder) wrote straight into the session store with a\n * bare `writeFileSync` — no atomicity, no lock, no API. 243 lines re-implementing parse, cut and\n * write for a format the framework owns. The consumer is not at fault: nothing here was reachable.\n *\n * ## The rule that travels WITH the operation\n *\n * `rules/audit-trail-rotation.md § Session transcripts (M60)` defines a NEVER-delete list — the live\n * pointer, the most recent transcript, and any active registry entry. That rule lived in the\n * CONSUMER. Moving the operation here without moving the rule would ship an API able to destroy\n * exactly what the rule protects — the same shape of defect as M80's `reconcileUpdateGoalStatus`:\n * critical knowledge outside the module that needs it, applied by convention.\n *\n * So `forkTranscript` takes `liveSessionPaths` and refuses, with a TYPED error, to write over any of\n * them. The caller supplies the list because only the caller knows which session is live; the\n * enforcement lives here because that is where the write happens.\n *\n * @internal\n */\n\nimport { closeSync, openSync, readFileSync, readSync, statSync, writeSync } from \"node:fs\";\n\nimport { TheokitAgentError } from \"../../errors.js\";\n\n/**\n * M81 — the target is a protected session (live pointer / most-recent transcript / active entry).\n *\n * Typed rather than a bare `Error` because the caller must distinguish \"this session is protected\"\n * from \"the disk is full\": the first is a correct refusal, the second is an incident.\n */\nexport class LiveSessionError extends TheokitAgentError {\n override readonly name = \"LiveSessionError\";\n\n constructor(readonly path: string) {\n super(\n `refusing to write over a live session transcript: ${path}. ` +\n \"Fork to a new id instead — the live pointer, the most recent transcript and any active \" +\n \"registry entry are never overwritten (audit-trail rotation, M60).\",\n { code: \"live_session_protected\", isRetryable: false },\n );\n }\n}\n\n/** Options for {@link forkTranscript}. */\nexport interface ForkTranscriptOptions {\n /** Keep records `[0, beforeRecordIndex)`. Omit to copy the whole transcript. */\n readonly beforeRecordIndex?: number;\n /**\n * Paths that must never be written over — the live pointer, the most recent transcript, any active\n * registry entry. The caller supplies them because only the caller knows which session is live.\n */\n readonly liveSessionPaths?: readonly string[];\n /**\n * M107 — permission bits for the created destination. Default: `0o600`.\n *\n * A transcript carries the conversation. Before M107 no mode was passed at all, so the file was\n * born `0o666 & ~umask` — measured `0o664` (group-WRITABLE) on a `umask 002` machine, `0o644` on\n * `umask 022`, `0o466` on `umask 0200`. This is a DEFAULT and not a required knob on purpose: a\n * knob would reach zero consumers by omission, which is the failure mode that matters.\n *\n * As with any `open` mode, the `umask` may still CLEAR bits — under `umask 0200` the result is\n * `0o400`. That is accepted: the invariant bought here is \"neither group nor others\", and `0o400`\n * satisfies it more strictly. The SDK deliberately does not `fchmod` the default back, because\n * that would hand back a bit the operator asked to remove.\n */\n readonly mode?: number;\n}\n\n/**\n * Copy `src` into `dst`, keeping the first `beforeRecordIndex` records. The SOURCE is never touched.\n *\n * Atomicity comes from `wx` (exclusive create): two concurrent forks to the same destination cannot\n * both succeed — the loser gets `EEXIST` rather than writing over a half-written file. That is also\n * why an existing destination is a refusal, not a silent overwrite: losing a transcript without an\n * error is the worst failure mode for an operation that touches user sessions.\n */\nexport function forkTranscript(\n src: string,\n dst: string,\n options: ForkTranscriptOptions = {},\n): void {\n for (const live of options.liveSessionPaths ?? []) {\n if (live === dst) throw new LiveSessionError(dst);\n }\n\n const lines = readFileSync(src, \"utf8\")\n .split(\"\\n\")\n .filter((l) => l.trim().length > 0);\n const kept =\n options.beforeRecordIndex === undefined ? lines : lines.slice(0, options.beforeRecordIndex);\n const body = kept.length > 0 ? `${kept.join(\"\\n\")}\\n` : \"\";\n\n // `wx` — fails with EEXIST instead of truncating. The exclusivity IS the concurrency guarantee,\n // and M107 only added the third argument: the mode. See `ForkTranscriptOptions.mode`.\n const fd = openSync(dst, \"wx\", options.mode ?? 0o600);\n try {\n writeSync(fd, body);\n } finally {\n closeSync(fd);\n }\n}\n\n/** Options for {@link readJsonlTail}. */\nexport interface ReadJsonlTailOptions {\n /** Maximum records to return, counted from the END. */\n readonly maxRecords?: number;\n /** Stop once a line contains this marker (exclusive). */\n readonly sinceMarker?: string;\n /** Test-only: also report how many bytes were read, to prove the read is not whole-file. */\n readonly _stats?: boolean;\n}\n\nconst TAIL_CHUNK = 64 * 1024;\n\n/**\n * Lê chunks de trás para frente até acumular linhas completas suficientes.\n *\n * Extraído de `readJsonlTail` porque o laço de leitura e a seleção de registros são duas\n * responsabilidades — e juntas passavam do teto de complexidade. A primeira linha do buffer pode\n * estar cortada ao meio quando a leitura parou antes do início do arquivo; por isso ela é descartada.\n */\nfunction lerCaudaBruta(path: string, want: number): { linhas: string[]; bytesRead: number } {\n const size = statSync(path).size;\n const fd = openSync(path, \"r\");\n let bytesRead = 0;\n let tail = \"\";\n let pos = size;\n try {\n while (pos > 0) {\n const len = Math.min(TAIL_CHUNK, pos);\n pos -= len;\n const buf = Buffer.alloc(len);\n readSync(fd, buf, 0, len, pos);\n bytesRead += len;\n tail = buf.toString(\"utf8\") + tail;\n if (naoVazias(tail).length > want) break;\n }\n } finally {\n closeSync(fd);\n }\n const linhas = naoVazias(tail);\n return { linhas: pos > 0 ? linhas.slice(1) : linhas, bytesRead };\n}\n\n/** Linhas com conteúdo, na ordem do arquivo. */\nfunction naoVazias(texto: string): string[] {\n return texto.split(\"\\n\").filter((l) => l.trim().length > 0);\n}\n\n/**\n * Read the LAST records of a JSONL file without loading the whole thing.\n *\n * Reads fixed-size chunks backwards from EOF until enough newlines have been seen. A session\n * transcript grows without bound; loading megabytes to show the last three turns is the cost this\n * exists to avoid — and a `slice` over a full read would be that same cost with a better name.\n */\nexport function readJsonlTail<T = Record<string, unknown>>(\n path: string,\n options: ReadJsonlTailOptions = {},\n): T[] {\n const want = options.maxRecords ?? Number.POSITIVE_INFINITY;\n const { linhas, bytesRead } = lerCaudaBruta(path, want);\n\n let sel = linhas;\n if (options.sinceMarker !== undefined) {\n const marcador = options.sinceMarker;\n const idx = sel.findLastIndex((l) => l.includes(marcador));\n if (idx >= 0) sel = sel.slice(idx + 1);\n }\n if (Number.isFinite(want)) sel = sel.slice(-want);\n\n const out = sel.map((l) => JSON.parse(l) as T);\n return options._stats === true ? (Object.assign(out, { bytesRead }) as T[]) : out;\n}\n"]}
|
package/dist/project.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
4
|
+
var chunkICYBIC6N_cjs = require('./chunk-ICYBIC6N.cjs');
|
|
5
|
+
var chunkMHCKWQR3_cjs = require('./chunk-MHCKWQR3.cjs');
|
|
6
|
+
require('./chunk-LTCOPATU.cjs');
|
|
7
7
|
var promises = require('fs/promises');
|
|
8
8
|
var path = require('path');
|
|
9
9
|
|
|
@@ -31,12 +31,12 @@ function reduceContent(files, scope) {
|
|
|
31
31
|
async function writeProjectInstructions(cwd, content, options) {
|
|
32
32
|
const filename = options?.filename ?? DEFAULT_FILENAME;
|
|
33
33
|
if (!chunkYPEPCZHF_cjs.isSafePattern(filename)) {
|
|
34
|
-
throw new
|
|
34
|
+
throw new chunkMHCKWQR3_cjs.ConfigurationError(
|
|
35
35
|
`writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,
|
|
36
36
|
{ code: "unsafe_filename" }
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
await
|
|
39
|
+
await chunkICYBIC6N_cjs.replaceFileAtomic(path.join(cwd, filename), content);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
exports.readProjectInstructions = readProjectInstructions;
|
package/dist/project.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { walkUpForFile, isSafePattern } from './chunk-UJ7IQJAG.js';
|
|
2
|
-
import { replaceFileAtomic } from './chunk-
|
|
3
|
-
import { ConfigurationError } from './chunk-
|
|
4
|
-
import './chunk-
|
|
2
|
+
import { replaceFileAtomic } from './chunk-56OXYUZE.js';
|
|
3
|
+
import { ConfigurationError } from './chunk-CD73YHEH.js';
|
|
4
|
+
import './chunk-TAPQWDW2.js';
|
|
5
5
|
import { readFile } from 'fs/promises';
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk6EDQBX7U_cjs = require('./chunk-6EDQBX7U.cjs');
|
|
4
|
+
require('./chunk-BUUUWQMB.cjs');
|
|
5
|
+
require('./chunk-MRODLUGY.cjs');
|
|
6
|
+
require('./chunk-W4QN5CMG.cjs');
|
|
7
|
+
require('./chunk-ICYBIC6N.cjs');
|
|
8
|
+
require('./chunk-MHCKWQR3.cjs');
|
|
9
|
+
require('./chunk-LTCOPATU.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "__getSubscribersCountForTests", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunk6EDQBX7U_cjs.__getSubscribersCountForTests; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "__resetTaskRegistryForTests", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunk6EDQBX7U_cjs.__resetTaskRegistryForTests; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "cancel", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunk6EDQBX7U_cjs.cancel; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "configure", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunk6EDQBX7U_cjs.configure; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "get", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunk6EDQBX7U_cjs.get; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "list", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return chunk6EDQBX7U_cjs.list; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "submit", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return chunk6EDQBX7U_cjs.submit; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "subscribe", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return chunk6EDQBX7U_cjs.subscribe; }
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=registry-N3GTKYCI.cjs.map
|
|
46
|
+
//# sourceMappingURL=registry-N3GTKYCI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"registry-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"registry-N3GTKYCI.cjs"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { __getSubscribersCountForTests, __resetTaskRegistryForTests, cancel, configure, get, list, submit, subscribe } from './chunk-HEN5WXXI.js';
|
|
2
|
+
import './chunk-K2BQQ445.js';
|
|
3
|
+
import './chunk-NFCKEBHI.js';
|
|
4
|
+
import './chunk-CSZRJ4RE.js';
|
|
5
|
+
import './chunk-56OXYUZE.js';
|
|
6
|
+
import './chunk-CD73YHEH.js';
|
|
7
|
+
import './chunk-TAPQWDW2.js';
|
|
8
|
+
//# sourceMappingURL=registry-SOXE4RY6.js.map
|
|
9
|
+
//# sourceMappingURL=registry-SOXE4RY6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"registry-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"registry-SOXE4RY6.js"}
|
package/dist/retry.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunk3O2ELBST_cjs = require('./chunk-3O2ELBST.cjs');
|
|
4
|
+
require('./chunk-MHCKWQR3.cjs');
|
|
5
|
+
require('./chunk-LTCOPATU.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "Retry", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunk3O2ELBST_cjs.Retry; }
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=retry.cjs.map
|
|
14
14
|
//# sourceMappingURL=retry.cjs.map
|
package/dist/retry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Retry } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { Retry } from './chunk-JNIWFCKI.js';
|
|
2
|
+
import './chunk-CD73YHEH.js';
|
|
3
|
+
import './chunk-TAPQWDW2.js';
|
|
4
4
|
//# sourceMappingURL=retry.js.map
|
|
5
5
|
//# sourceMappingURL=retry.js.map
|
package/dist/sandbox/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkS7OEXQMI_cjs = require('../chunk-S7OEXQMI.cjs');
|
|
4
4
|
require('../chunk-WPZTYOUX.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkMHCKWQR3_cjs = require('../chunk-MHCKWQR3.cjs');
|
|
6
|
+
var chunkLTCOPATU_cjs = require('../chunk-LTCOPATU.cjs');
|
|
7
7
|
var child_process = require('child_process');
|
|
8
8
|
var fs = require('fs');
|
|
9
9
|
var path = require('path');
|
|
@@ -319,7 +319,7 @@ function seccompPathForArch(arch, warn) {
|
|
|
319
319
|
var seccompFilterPath;
|
|
320
320
|
function restrictedSeccompPath() {
|
|
321
321
|
if (seccompFilterPath !== void 0) return seccompFilterPath ?? void 0;
|
|
322
|
-
const path2 = seccompPathForArch(process.arch, (m) => console.warn(
|
|
322
|
+
const path2 = seccompPathForArch(process.arch, (m) => console.warn(chunkLTCOPATU_cjs.redactSecrets(m)));
|
|
323
323
|
seccompFilterPath = path2 ?? null;
|
|
324
324
|
return path2;
|
|
325
325
|
}
|
|
@@ -344,7 +344,7 @@ function createSandboxBackend(opts) {
|
|
|
344
344
|
if (!detection.ok) {
|
|
345
345
|
if (!warnedUnavailable) {
|
|
346
346
|
warnedUnavailable = true;
|
|
347
|
-
const warn = opts.warn ?? ((m) => console.warn(
|
|
347
|
+
const warn = opts.warn ?? ((m) => console.warn(chunkLTCOPATU_cjs.redactSecrets(m)));
|
|
348
348
|
warn(
|
|
349
349
|
`[sandbox] OS-level enforcement unavailable (${detection.reason}) \u2014 falling back to tool-level gating only (sandbox_mode=${opts.mode}).`
|
|
350
350
|
);
|
|
@@ -366,7 +366,7 @@ function decidirConfinamento(opts) {
|
|
|
366
366
|
if (detection.ok) return detection.bin;
|
|
367
367
|
if (!avisouInterativo) {
|
|
368
368
|
avisouInterativo = true;
|
|
369
|
-
const warn = opts.warn ?? ((m) => console.warn(
|
|
369
|
+
const warn = opts.warn ?? ((m) => console.warn(chunkLTCOPATU_cjs.redactSecrets(m)));
|
|
370
370
|
warn(
|
|
371
371
|
`[sandbox] OS-level enforcement unavailable (${detection.reason}) \u2014 interactive session runs WITHOUT kernel confinement (sandbox_mode=${opts.mode}).`
|
|
372
372
|
);
|
|
@@ -392,7 +392,7 @@ function interactiveWrapCommand(opts) {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
// src/sandbox/provision.ts
|
|
395
|
-
var RepoProvisionError = class extends
|
|
395
|
+
var RepoProvisionError = class extends chunkMHCKWQR3_cjs.TheokitAgentError {
|
|
396
396
|
constructor(instanceId, message, options = {}) {
|
|
397
397
|
super(`[${instanceId}] ${message}`, {
|
|
398
398
|
code: "repo_provision_failed",
|
package/dist/sandbox/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LocalSandbox, shellEscapePosix } from '../chunk-SKWVAQAY.js';
|
|
2
2
|
export { LocalSandbox, SandboxBackend, SandboxNotAvailableError, SandboxSecurityError, resolveSandbox } from '../chunk-SKWVAQAY.js';
|
|
3
3
|
import '../chunk-7GFX45DD.js';
|
|
4
|
-
import { TheokitAgentError } from '../chunk-
|
|
5
|
-
import { redactSecrets } from '../chunk-
|
|
4
|
+
import { TheokitAgentError } from '../chunk-CD73YHEH.js';
|
|
5
|
+
import { redactSecrets } from '../chunk-TAPQWDW2.js';
|
|
6
6
|
import { execFileSync } from 'child_process';
|
|
7
7
|
import { existsSync, mkdtempSync, writeFileSync, rmSync } from 'fs';
|
|
8
8
|
import path, { dirname, join } from 'path';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkMHCKWQR3_cjs = require('../chunk-MHCKWQR3.cjs');
|
|
4
|
+
require('../chunk-LTCOPATU.cjs');
|
|
5
5
|
|
|
6
6
|
// src/server/errors-envelope.ts
|
|
7
7
|
var NAME_TO_CODE = /* @__PURE__ */ new Map([
|
|
@@ -37,7 +37,7 @@ function toEnvelope(value) {
|
|
|
37
37
|
}
|
|
38
38
|
function buildMeta(name, err) {
|
|
39
39
|
const meta = { sdkErrorName: name };
|
|
40
|
-
if (err instanceof
|
|
40
|
+
if (err instanceof chunkMHCKWQR3_cjs.TheokitAgentError && err.metadata !== void 0) {
|
|
41
41
|
meta.provider = err.metadata.provider;
|
|
42
42
|
meta.endpoint = err.metadata.endpoint;
|
|
43
43
|
if (err.metadata.statusCode !== void 0) {
|
|
@@ -47,13 +47,13 @@ function buildMeta(name, err) {
|
|
|
47
47
|
return meta;
|
|
48
48
|
}
|
|
49
49
|
function buildExt(err) {
|
|
50
|
-
if (err instanceof
|
|
50
|
+
if (err instanceof chunkMHCKWQR3_cjs.RateLimitError && err.metadata?.retryAfter !== void 0) {
|
|
51
51
|
return {
|
|
52
52
|
retryable: true,
|
|
53
53
|
retryAfterMs: err.metadata.retryAfter * 1e3
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
if (err instanceof
|
|
56
|
+
if (err instanceof chunkMHCKWQR3_cjs.CredentialPoolExhaustedError && err.nextRetryAt !== void 0) {
|
|
57
57
|
const delayMs = Math.max(0, err.nextRetryAt - Date.now());
|
|
58
58
|
return {
|
|
59
59
|
retryable: true,
|
|
@@ -63,22 +63,22 @@ function buildExt(err) {
|
|
|
63
63
|
return void 0;
|
|
64
64
|
}
|
|
65
65
|
var CODE_TO_RECONSTRUCTOR = /* @__PURE__ */ new Map([
|
|
66
|
-
["UNAUTHORIZED", (env) => new
|
|
66
|
+
["UNAUTHORIZED", (env) => new chunkMHCKWQR3_cjs.AuthenticationError(env.message)],
|
|
67
67
|
[
|
|
68
68
|
"RATE_LIMITED",
|
|
69
|
-
(env) => new
|
|
69
|
+
(env) => new chunkMHCKWQR3_cjs.RateLimitError(env.message, env.cause !== void 0 ? { cause: env.cause } : {})
|
|
70
70
|
],
|
|
71
|
-
["PROVIDER_KEY_MISSING", (env) => new
|
|
72
|
-
["SERVICE_UNAVAILABLE", (env) => new
|
|
73
|
-
["GATEWAY_TIMEOUT", (env) => new
|
|
71
|
+
["PROVIDER_KEY_MISSING", (env) => new chunkMHCKWQR3_cjs.ConfigurationError(env.message)],
|
|
72
|
+
["SERVICE_UNAVAILABLE", (env) => new chunkMHCKWQR3_cjs.NetworkError(env.message)],
|
|
73
|
+
["GATEWAY_TIMEOUT", (env) => new chunkMHCKWQR3_cjs.NetworkError(env.message)],
|
|
74
74
|
[
|
|
75
75
|
"AGENT_RUN_ERROR",
|
|
76
|
-
(env) => new
|
|
76
|
+
(env) => new chunkMHCKWQR3_cjs.AgentRunError(env.message, {
|
|
77
77
|
code: "unknown",
|
|
78
78
|
...env.cause !== void 0 ? { cause: env.cause } : {}
|
|
79
79
|
})
|
|
80
80
|
],
|
|
81
|
-
["INTERNAL_SERVER_ERROR", (env) => new
|
|
81
|
+
["INTERNAL_SERVER_ERROR", (env) => new chunkMHCKWQR3_cjs.UnknownAgentError(env.message)]
|
|
82
82
|
// BUDGET_EXCEEDED + CREDENTIAL_POOL_EXHAUSTED reconstructors require
|
|
83
83
|
// domain-specific args (budgetName, provider) that the envelope doesn't
|
|
84
84
|
// always carry. Fall back to UnknownAgentError when those fields are
|
|
@@ -88,12 +88,12 @@ var CODE_TO_RECONSTRUCTOR = /* @__PURE__ */ new Map([
|
|
|
88
88
|
function fromEnvelope(env) {
|
|
89
89
|
const reconstructor = CODE_TO_RECONSTRUCTOR.get(env.code);
|
|
90
90
|
if (reconstructor) return reconstructor(env);
|
|
91
|
-
return new
|
|
91
|
+
return new chunkMHCKWQR3_cjs.UnknownAgentError(env.message);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
Object.defineProperty(exports, "MemoryAdapterError", {
|
|
95
95
|
enumerable: true,
|
|
96
|
-
get: function () { return
|
|
96
|
+
get: function () { return chunkMHCKWQR3_cjs.MemoryAdapterError; }
|
|
97
97
|
});
|
|
98
98
|
exports.fromEnvelope = fromEnvelope;
|
|
99
99
|
exports.toEnvelope = toEnvelope;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TheokitAgentError, RateLimitError, CredentialPoolExhaustedError, UnknownAgentError, AuthenticationError, ConfigurationError, NetworkError, AgentRunError } from '../chunk-
|
|
2
|
-
export { MemoryAdapterError } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { TheokitAgentError, RateLimitError, CredentialPoolExhaustedError, UnknownAgentError, AuthenticationError, ConfigurationError, NetworkError, AgentRunError } from '../chunk-CD73YHEH.js';
|
|
2
|
+
export { MemoryAdapterError } from '../chunk-CD73YHEH.js';
|
|
3
|
+
import '../chunk-TAPQWDW2.js';
|
|
4
4
|
|
|
5
5
|
// src/server/errors-envelope.ts
|
|
6
6
|
var NAME_TO_CODE = /* @__PURE__ */ new Map([
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SessionTranscript, defaultBaseDir, encodeProjectDir, expandTilde, readTranscript, reconstructMessages, safeSessionId, transcriptPath, transcriptRoot, writeTranscript } from './chunk-XAEAMI5H.js';
|
|
2
|
+
import './chunk-56OXYUZE.js';
|
|
3
|
+
import './chunk-TAPQWDW2.js';
|
|
4
|
+
//# sourceMappingURL=session-transcript-6WKLYIN4.js.map
|
|
5
|
+
//# sourceMappingURL=session-transcript-6WKLYIN4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-6WKLYIN4.js"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkIEUDKUPM_cjs = require('./chunk-IEUDKUPM.cjs');
|
|
4
|
+
require('./chunk-ICYBIC6N.cjs');
|
|
5
|
+
require('./chunk-LTCOPATU.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "SessionTranscript", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkIEUDKUPM_cjs.SessionTranscript; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "defaultBaseDir", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkIEUDKUPM_cjs.defaultBaseDir; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "encodeProjectDir", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkIEUDKUPM_cjs.encodeProjectDir; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "expandTilde", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkIEUDKUPM_cjs.expandTilde; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "readTranscript", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkIEUDKUPM_cjs.readTranscript; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "reconstructMessages", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunkIEUDKUPM_cjs.reconstructMessages; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "safeSessionId", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return chunkIEUDKUPM_cjs.safeSessionId; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "transcriptPath", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return chunkIEUDKUPM_cjs.transcriptPath; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "transcriptRoot", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return chunkIEUDKUPM_cjs.transcriptRoot; }
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "writeTranscript", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return chunkIEUDKUPM_cjs.writeTranscript; }
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=session-transcript-EAKR4D2W.cjs.map
|
|
50
|
+
//# sourceMappingURL=session-transcript-EAKR4D2W.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-EAKR4D2W.cjs"}
|