@agimon-ai/po-runner 0.0.0-alpha.21 → 0.0.0-alpha.211
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/LICENSE +21 -149
- package/README.md +34 -206
- package/dist/apiContracts.cjs +45 -2
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +2 -2
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +45 -2
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{bashResult-BqDa7sbC.mjs → bashResult-BLCLerXE.mjs} +57 -7
- package/dist/bashResult-BLCLerXE.mjs.map +1 -0
- package/dist/{bashResult-C2iKhHpD.cjs → bashResult-CZYiyl4p.cjs} +74 -6
- package/dist/bashResult-CZYiyl4p.cjs.map +1 -0
- package/dist/{bashResult-DcrRaBLv.d.mts → bashResult-CgVS_JpL.d.mts} +8 -3
- package/dist/{bashResult-DcrRaBLv.d.mts.map → bashResult-CgVS_JpL.d.mts.map} +1 -1
- package/dist/{bashRunService-DjOH5kye.cjs → bashRunService-DmuA1mKL.cjs} +52 -31
- package/dist/bashRunService-DmuA1mKL.cjs.map +1 -0
- package/dist/{bashRunService-Ci0cGdYO.d.mts → bashRunService-Iotfc_nV.d.mts} +21 -2
- package/dist/bashRunService-Iotfc_nV.d.mts.map +1 -0
- package/dist/{bashRunService-Cl3pYccr.mjs → bashRunService-Luy2hPMS.mjs} +52 -31
- package/dist/bashRunService-Luy2hPMS.mjs.map +1 -0
- package/dist/bashRunService.cjs +1 -1
- package/dist/bashRunService.d.mts +4 -4
- package/dist/bashRunService.d.mts.map +1 -1
- package/dist/bashRunService.mjs +1 -1
- package/dist/bashSchema.cjs +1 -1
- package/dist/bashSchema.d.mts +1 -1
- package/dist/bashSchema.mjs +1 -1
- package/dist/bashTool-D2ECDAhc.cjs +43 -0
- package/dist/bashTool-D2ECDAhc.cjs.map +1 -0
- package/dist/{bashTool-B1EwZLo_.d.mts → bashTool-Dc1ld2E3.d.mts} +3 -9
- package/dist/bashTool-Dc1ld2E3.d.mts.map +1 -0
- package/dist/bashTool-vg8uhbkj.mjs +26 -0
- package/dist/bashTool-vg8uhbkj.mjs.map +1 -0
- package/dist/bashTool.cjs +3 -3
- package/dist/bashTool.cjs.map +1 -1
- package/dist/bashTool.d.mts +4 -4
- package/dist/bashTool.d.mts.map +1 -1
- package/dist/bashTool.mjs +3 -3
- package/dist/bashTool.mjs.map +1 -1
- package/dist/bin/cli.cjs +372 -9
- package/dist/bin/cli.cjs.map +1 -1
- package/dist/bin/cli.d.mts.map +1 -1
- package/dist/bin/cli.mjs +369 -8
- package/dist/bin/cli.mjs.map +1 -1
- package/dist/bin/logSink.cjs +27 -24
- package/dist/bin/logSink.cjs.map +1 -1
- package/dist/bin/logSink.mjs +24 -21
- package/dist/bin/logSink.mjs.map +1 -1
- package/dist/bin/runnerHost.cjs +141 -53
- package/dist/bin/runnerHost.cjs.map +1 -1
- package/dist/bin/runnerHost.d.mts.map +1 -1
- package/dist/bin/runnerHost.mjs +141 -53
- package/dist/bin/runnerHost.mjs.map +1 -1
- package/dist/cliApp-7iTUx5KZ.cjs +351 -0
- package/dist/cliApp-7iTUx5KZ.cjs.map +1 -0
- package/dist/cliApp-S4iEO-fi.mjs +338 -0
- package/dist/cliApp-S4iEO-fi.mjs.map +1 -0
- package/dist/cliApp.cjs +2 -1
- package/dist/cliApp.d.mts +9 -4
- package/dist/cliApp.d.mts.map +1 -1
- package/dist/cliApp.mjs +1 -1
- package/dist/compaction.d.mts +1 -1
- package/dist/extensions/mcp-ui.mjs +7 -6
- package/dist/extensions/mcp-ui.mjs.map +1 -1
- package/dist/extensions/mcp.cjs +37 -17
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts.map +1 -1
- package/dist/extensions/mcp.mjs +37 -17
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/native.mjs +1225 -374
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +900 -221
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +908 -227
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +924 -766
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/headless-CMj9hunm.cjs +237 -0
- package/dist/headless-CMj9hunm.cjs.map +1 -0
- package/dist/headless-CUJt5Ihx.mjs +226 -0
- package/dist/headless-CUJt5Ihx.mjs.map +1 -0
- package/dist/{index-DM7yJpMs.d.mts → index-7_nuKoVm.d.mts} +6 -6
- package/dist/index-7_nuKoVm.d.mts.map +1 -0
- package/dist/index-BCCF1sGD.d.mts.map +1 -1
- package/dist/{index-CzCF_OP9.d.mts → index-CH-z0BX3.d.mts} +11 -4
- package/dist/index-CH-z0BX3.d.mts.map +1 -0
- package/dist/{index-C-IC35d9.d.mts → index-CJNsR-Ir.d.mts} +10 -7
- package/dist/index-CJNsR-Ir.d.mts.map +1 -0
- package/dist/{index--xF7DvsE.d.mts → index-CNCb1usM.d.mts} +8 -2
- package/dist/index-CNCb1usM.d.mts.map +1 -0
- package/dist/index-EMbmq9gu.d.mts +45 -0
- package/dist/index-EMbmq9gu.d.mts.map +1 -0
- package/dist/index-QlfncPRs.d.mts +58 -0
- package/dist/index-QlfncPRs.d.mts.map +1 -0
- package/dist/index-qSi4-EJW.d.mts +49 -0
- package/dist/index-qSi4-EJW.d.mts.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/launch.cjs +4 -0
- package/dist/launch.d.mts +55 -0
- package/dist/launch.d.mts.map +1 -0
- package/dist/launch.mjs +1 -0
- package/dist/{launcher-CCYsFBM9.mjs → launcher-3xMxw72I.mjs} +45 -31
- package/dist/launcher-3xMxw72I.mjs.map +1 -0
- package/dist/{launcher-BG5t9nvG.d.mts → launcher-CDDBTvZq.d.mts} +4 -3
- package/dist/launcher-CDDBTvZq.d.mts.map +1 -0
- package/dist/{launcher-ZgDdyXpq.cjs → launcher-D7qAhSRL.cjs} +47 -33
- package/dist/launcher-D7qAhSRL.cjs.map +1 -0
- package/dist/launcher.cjs +1 -1
- package/dist/launcher.d.mts +5 -5
- package/dist/launcher.d.mts.map +1 -1
- package/dist/launcher.mjs +1 -1
- package/dist/lifeline-26IaW5w7.d.mts +34 -0
- package/dist/lifeline-26IaW5w7.d.mts.map +1 -0
- package/dist/lifeline-B4cjtrBe.cjs +27 -0
- package/dist/lifeline-B4cjtrBe.cjs.map +1 -0
- package/dist/lifeline-C1v2ItCY.mjs +214 -0
- package/dist/lifeline-C1v2ItCY.mjs.map +1 -0
- package/dist/lifeline-D4_ZRAhO.cjs +229 -0
- package/dist/lifeline-D4_ZRAhO.cjs.map +1 -0
- package/dist/lifeline-nPh3cx5A.mjs +10 -0
- package/dist/lifeline-nPh3cx5A.mjs.map +1 -0
- package/dist/lifeline.cjs +4 -1
- package/dist/lifeline.d.mts +4 -21
- package/dist/lifeline.mjs +3 -3
- package/dist/logFile-B9FSwmE0.cjs +44 -0
- package/dist/logFile-B9FSwmE0.cjs.map +1 -0
- package/dist/{logFile-C7oQ_v-g.d.mts → logFile-BirfZtS1.d.mts} +4 -4
- package/dist/logFile-BirfZtS1.d.mts.map +1 -0
- package/dist/logFile-D1EOKqmL.mjs +39 -0
- package/dist/logFile-D1EOKqmL.mjs.map +1 -0
- package/dist/logFile.cjs +1 -1
- package/dist/logFile.d.mts +3 -3
- package/dist/logFile.d.mts.map +1 -1
- package/dist/logFile.mjs +1 -1
- package/dist/{logReader-mq9uVurh.mjs → logReader-BYKii_s_.mjs} +99 -52
- package/dist/logReader-BYKii_s_.mjs.map +1 -0
- package/dist/{logReader-MdW9ffvV.d.mts → logReader-Bn3WEdjg.d.mts} +4 -2
- package/dist/{logReader-MdW9ffvV.d.mts.map → logReader-Bn3WEdjg.d.mts.map} +1 -1
- package/dist/{logReader-DHCK2BEr.cjs → logReader-DpMjBqfn.cjs} +101 -54
- package/dist/logReader-DpMjBqfn.cjs.map +1 -0
- package/dist/logReader.cjs +1 -1
- package/dist/logReader.d.mts +2 -2
- package/dist/logReader.mjs +1 -1
- package/dist/po-runtime-identity.json +1 -0
- package/dist/{ptyHost-D35hNmtd.cjs → ptyHost-C-oWV455.cjs} +20 -14
- package/dist/ptyHost-C-oWV455.cjs.map +1 -0
- package/dist/{ptyHost-CwbLLr90.mjs → ptyHost-C2zu-ZfO.mjs} +19 -13
- package/dist/ptyHost-C2zu-ZfO.mjs.map +1 -0
- package/dist/{ptyHost-DWWtRrGn.d.mts → ptyHost-C_6x2xuJ.d.mts} +2 -2
- package/dist/{ptyHost-DWWtRrGn.d.mts.map → ptyHost-C_6x2xuJ.d.mts.map} +1 -1
- package/dist/ptyHost.cjs +1 -1
- package/dist/ptyHost.d.mts +2 -2
- package/dist/ptyHost.d.mts.map +1 -1
- package/dist/ptyHost.mjs +1 -1
- package/dist/{reconcile-wNYQJZF-.mjs → reconcile-DUaX_vKZ.mjs} +2 -2
- package/dist/reconcile-DUaX_vKZ.mjs.map +1 -0
- package/dist/{reconcile-5cZ11jSD.cjs → reconcile-DjF9T1hN.cjs} +2 -2
- package/dist/reconcile-DjF9T1hN.cjs.map +1 -0
- package/dist/reconcile.cjs +1 -1
- package/dist/reconcile.d.mts +3 -3
- package/dist/reconcile.mjs +1 -1
- package/dist/responseEnvelope.cjs +5 -2
- package/dist/responseEnvelope.d.mts +15 -6
- package/dist/responseEnvelope.d.mts.map +1 -1
- package/dist/responseEnvelope.mjs +3 -3
- package/dist/{rmuxBackend-Dh0CYVAL.cjs → rmuxBackend-9tHTx1vf.cjs} +82 -48
- package/dist/rmuxBackend-9tHTx1vf.cjs.map +1 -0
- package/dist/{rmuxBackend-rjrVTG6K.mjs → rmuxBackend-BaK-R35I.mjs} +79 -45
- package/dist/rmuxBackend-BaK-R35I.mjs.map +1 -0
- package/dist/{rmuxBackend-CaEWooWn.d.mts → rmuxBackend-xFzlANM9.d.mts} +4 -4
- package/dist/rmuxBackend-xFzlANM9.d.mts.map +1 -0
- package/dist/rmuxBackend.cjs +1 -1
- package/dist/rmuxBackend.d.mts +2 -2
- package/dist/rmuxBackend.mjs +1 -1
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-C0BPl7ul.cjs} +15 -0
- package/dist/{rtkProcessor-Iw9gP5Xp.mjs → rtkProcessor-DOXcp51z.mjs} +6 -5
- package/dist/rtkProcessor-DOXcp51z.mjs.map +1 -0
- package/dist/{rtkProcessor-DSGbM-Cm.cjs → rtkProcessor-J2gLQvM4.cjs} +8 -6
- package/dist/rtkProcessor-J2gLQvM4.cjs.map +1 -0
- package/dist/rtkProcessor.cjs +1 -1
- package/dist/rtkProcessor.mjs +1 -1
- package/dist/{runnerDependencies-DSun3xO-.cjs → runnerDependencies-CABYjW7H.cjs} +97 -64
- package/dist/runnerDependencies-CABYjW7H.cjs.map +1 -0
- package/dist/{runnerDependencies-7h_cxOva.mjs → runnerDependencies-DmvIcpZi.mjs} +95 -62
- package/dist/runnerDependencies-DmvIcpZi.mjs.map +1 -0
- package/dist/runnerDependencies.cjs +1 -1
- package/dist/runnerDependencies.d.mts +1 -1
- package/dist/runnerDependencies.mjs +1 -1
- package/dist/runnerHost-BvNYPMeh.mjs +165 -0
- package/dist/runnerHost-BvNYPMeh.mjs.map +1 -0
- package/dist/runnerHost-C2F5oxzn.cjs +184 -0
- package/dist/runnerHost-C2F5oxzn.cjs.map +1 -0
- package/dist/runnerLaunch-BAf7hXMr.cjs +192 -0
- package/dist/runnerLaunch-BAf7hXMr.cjs.map +1 -0
- package/dist/runnerLaunch-Bimgdh4h.mjs +175 -0
- package/dist/runnerLaunch-Bimgdh4h.mjs.map +1 -0
- package/dist/runnerNamer.d.mts +1 -1
- package/dist/{runnerPaths-B41rMOY6.cjs → runnerPaths-CSkswyjR.cjs} +97 -179
- package/dist/runnerPaths-CSkswyjR.cjs.map +1 -0
- package/dist/{runnerPaths-Dibbvyx_.mjs → runnerPaths-D3P7_EhW.mjs} +91 -179
- package/dist/runnerPaths-D3P7_EhW.mjs.map +1 -0
- package/dist/runnerPaths.cjs +1 -1
- package/dist/runnerPaths.d.mts +7 -9
- package/dist/runnerPaths.d.mts.map +1 -1
- package/dist/runnerPaths.mjs +1 -1
- package/dist/{runnerRegistry-dQYlMSpQ.cjs → runnerRegistry-B8K1L3lq.cjs} +68 -45
- package/dist/runnerRegistry-B8K1L3lq.cjs.map +1 -0
- package/dist/{runnerRegistry-V-Ocaf4N.d.mts → runnerRegistry-BlZhS9yL.d.mts} +2 -2
- package/dist/{runnerRegistry-V-Ocaf4N.d.mts.map → runnerRegistry-BlZhS9yL.d.mts.map} +1 -1
- package/dist/{runnerRegistry-BgaR5O86.mjs → runnerRegistry-Dqca6SD3.mjs} +53 -29
- package/dist/runnerRegistry-Dqca6SD3.mjs.map +1 -0
- package/dist/runnerRegistry-NW6oAJ71.cjs +60 -0
- package/dist/runnerRegistry-NW6oAJ71.cjs.map +1 -0
- package/dist/runnerRegistry-l0C_55oO.mjs +13 -0
- package/dist/runnerRegistry-l0C_55oO.mjs.map +1 -0
- package/dist/runnerRegistry.cjs +1 -1
- package/dist/runnerRegistry.d.mts +2 -2
- package/dist/runnerRegistry.mjs +1 -1
- package/dist/runnerSequence-ZTYgZ_2W.cjs +32 -0
- package/dist/runnerSequence-ZTYgZ_2W.cjs.map +1 -0
- package/dist/runnerSequence-k-_Fd77y.mjs +9 -0
- package/dist/runnerSequence-k-_Fd77y.mjs.map +1 -0
- package/dist/runnerSequenceStore-CaY7S_Sd.mjs +76 -0
- package/dist/runnerSequenceStore-CaY7S_Sd.mjs.map +1 -0
- package/dist/runnerSequenceStore-Ck6M-8r_.cjs +89 -0
- package/dist/runnerSequenceStore-Ck6M-8r_.cjs.map +1 -0
- package/dist/services/lifeline/client.cjs +88 -4
- package/dist/services/lifeline/client.cjs.map +1 -1
- package/dist/services/lifeline/client.d.mts +16 -0
- package/dist/services/lifeline/client.d.mts.map +1 -1
- package/dist/services/lifeline/client.mjs +83 -2
- package/dist/services/lifeline/client.mjs.map +1 -1
- package/dist/services/runnerSupervisor/index.cjs +36 -22
- package/dist/services/runnerSupervisor/index.cjs.map +1 -1
- package/dist/services/runnerSupervisor/index.d.mts +7 -5
- package/dist/services/runnerSupervisor/index.d.mts.map +1 -1
- package/dist/services/runnerSupervisor/index.mjs +35 -21
- package/dist/services/runnerSupervisor/index.mjs.map +1 -1
- package/dist/session-CdVeSD7F.mjs +8 -0
- package/dist/session-CdVeSD7F.mjs.map +1 -0
- package/dist/session-DnUj8Q71.cjs +25 -0
- package/dist/session-DnUj8Q71.cjs.map +1 -0
- package/dist/session-ISEGK4z9.mjs +26 -0
- package/dist/session-ISEGK4z9.mjs.map +1 -0
- package/dist/session-PQd3azWf.cjs +43 -0
- package/dist/session-PQd3azWf.cjs.map +1 -0
- package/dist/session.cjs +4 -3
- package/dist/session.d.mts +3 -1
- package/dist/session.d.mts.map +1 -1
- package/dist/session.mjs +3 -3
- package/dist/{type-DwMZoINK.d.mts → type-BWY9vvSq.d.mts} +6 -4
- package/dist/type-BWY9vvSq.d.mts.map +1 -0
- package/dist/{type-Do0YxwVQ.d.mts → type-bZgYQ7hv.d.mts} +11 -11
- package/dist/{type-Do0YxwVQ.d.mts.map → type-bZgYQ7hv.d.mts.map} +1 -1
- package/dist/types.d.mts +1 -1
- package/llms.txt +2 -1
- package/locales/vi.json +169 -0
- package/locales/zh-CN.json +169 -0
- package/package.json +95 -30
- package/skills/po-runner/SKILL.md +32 -14
- package/src/prompts/codemode-how-to-runner/SKILL.md +85 -0
- package/src/prompts/help-how-to-runner/SKILL.md +51 -0
- package/dist/bashResult-BqDa7sbC.mjs.map +0 -1
- package/dist/bashResult-C2iKhHpD.cjs.map +0 -1
- package/dist/bashRunService-Ci0cGdYO.d.mts.map +0 -1
- package/dist/bashRunService-Cl3pYccr.mjs.map +0 -1
- package/dist/bashRunService-DjOH5kye.cjs.map +0 -1
- package/dist/bashTool-B1EwZLo_.d.mts.map +0 -1
- package/dist/bashTool-BvC3YOgG.mjs +0 -24
- package/dist/bashTool-BvC3YOgG.mjs.map +0 -1
- package/dist/bashTool-euL6zMDl.cjs +0 -41
- package/dist/bashTool-euL6zMDl.cjs.map +0 -1
- package/dist/cliApp-T8Fx_-1j.cjs +0 -244
- package/dist/cliApp-T8Fx_-1j.cjs.map +0 -1
- package/dist/cliApp-q97eVh4E.mjs +0 -237
- package/dist/cliApp-q97eVh4E.mjs.map +0 -1
- package/dist/headless-DOlCixyf.mjs +0 -169
- package/dist/headless-DOlCixyf.mjs.map +0 -1
- package/dist/headless-Dko_yBiy.cjs +0 -180
- package/dist/headless-Dko_yBiy.cjs.map +0 -1
- package/dist/index--xF7DvsE.d.mts.map +0 -1
- package/dist/index-BzeXJk6V.d.mts +0 -12
- package/dist/index-BzeXJk6V.d.mts.map +0 -1
- package/dist/index-C-IC35d9.d.mts.map +0 -1
- package/dist/index-CzCF_OP9.d.mts.map +0 -1
- package/dist/index-DM7yJpMs.d.mts.map +0 -1
- package/dist/launcher-BG5t9nvG.d.mts.map +0 -1
- package/dist/launcher-CCYsFBM9.mjs.map +0 -1
- package/dist/launcher-ZgDdyXpq.cjs.map +0 -1
- package/dist/lifeline-Bm-bHIjS.mjs +0 -88
- package/dist/lifeline-Bm-bHIjS.mjs.map +0 -1
- package/dist/lifeline-eJdZV0nN.d.mts +0 -19
- package/dist/lifeline-eJdZV0nN.d.mts.map +0 -1
- package/dist/lifeline-m7laIzIP.cjs +0 -98
- package/dist/lifeline-m7laIzIP.cjs.map +0 -1
- package/dist/lifeline.d.mts.map +0 -1
- package/dist/logFile-C7oQ_v-g.d.mts.map +0 -1
- package/dist/logFile-CnPKtxPy.cjs +0 -67
- package/dist/logFile-CnPKtxPy.cjs.map +0 -1
- package/dist/logFile-XcDHBwu1.mjs +0 -60
- package/dist/logFile-XcDHBwu1.mjs.map +0 -1
- package/dist/logReader-DHCK2BEr.cjs.map +0 -1
- package/dist/logReader-mq9uVurh.mjs.map +0 -1
- package/dist/ptyHost-CwbLLr90.mjs.map +0 -1
- package/dist/ptyHost-D35hNmtd.cjs.map +0 -1
- package/dist/reconcile-5cZ11jSD.cjs.map +0 -1
- package/dist/reconcile-wNYQJZF-.mjs.map +0 -1
- package/dist/rmuxBackend-CaEWooWn.d.mts.map +0 -1
- package/dist/rmuxBackend-Dh0CYVAL.cjs.map +0 -1
- package/dist/rmuxBackend-rjrVTG6K.mjs.map +0 -1
- package/dist/rtkProcessor-DSGbM-Cm.cjs.map +0 -1
- package/dist/rtkProcessor-Iw9gP5Xp.mjs.map +0 -1
- package/dist/runnerDependencies-7h_cxOva.mjs.map +0 -1
- package/dist/runnerDependencies-DSun3xO-.cjs.map +0 -1
- package/dist/runnerPaths-B41rMOY6.cjs.map +0 -1
- package/dist/runnerPaths-Dibbvyx_.mjs.map +0 -1
- package/dist/runnerRegistry-BgaR5O86.mjs.map +0 -1
- package/dist/runnerRegistry-dQYlMSpQ.cjs.map +0 -1
- package/dist/session-BKYnH4R6.mjs +0 -18
- package/dist/session-BKYnH4R6.mjs.map +0 -1
- package/dist/session-BvqzhXZY.cjs +0 -29
- package/dist/session-BvqzhXZY.cjs.map +0 -1
- package/dist/session-DE2Acesp.mjs +0 -6
- package/dist/session-DE2Acesp.mjs.map +0 -1
- package/dist/session-SfIPtdZO.cjs +0 -11
- package/dist/session-SfIPtdZO.cjs.map +0 -1
- package/dist/type-DwMZoINK.d.mts.map +0 -1
- package/src/prompts/po-use-runner/SKILL.md +0 -47
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
2
|
-
let node_crypto = require("node:crypto");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
5
|
-
let node_path = require("node:path");
|
|
6
|
-
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
7
|
-
let node_net = require("node:net");
|
|
8
|
-
node_net = require_rolldown_runtime.__toESM(node_net, 1);
|
|
9
|
-
let node_os = require("node:os");
|
|
10
|
-
node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
11
|
-
//#region src/constants/lifeline.ts
|
|
12
|
-
const SOCKET_NAME = "lifeline.sock";
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/services/lifeline/index.ts
|
|
15
|
-
/** Unix socket paths are capped at 104 bytes, so a long agent directory falls back to the temp dir. */
|
|
16
|
-
var NodeLifeline = class {
|
|
17
|
-
paths;
|
|
18
|
-
server;
|
|
19
|
-
target;
|
|
20
|
-
/** Closing a server stops it accepting; only the connections carry the death signal. */
|
|
21
|
-
connections = /* @__PURE__ */ new Set();
|
|
22
|
-
constructor(paths) {
|
|
23
|
-
this.paths = paths;
|
|
24
|
-
}
|
|
25
|
-
async arm(sessionId) {
|
|
26
|
-
if (this.target) return this.target;
|
|
27
|
-
try {
|
|
28
|
-
this.paths.ensureDirectories(sessionId);
|
|
29
|
-
const target = this.socketPath(sessionId);
|
|
30
|
-
node_fs.default.rmSync(target, { force: true });
|
|
31
|
-
const server = node_net.default.createServer((connection) => {
|
|
32
|
-
connection.unref();
|
|
33
|
-
connection.resume();
|
|
34
|
-
this.connections.add(connection);
|
|
35
|
-
connection.on("close", () => this.connections.delete(connection));
|
|
36
|
-
});
|
|
37
|
-
await listen(server, target);
|
|
38
|
-
node_fs.default.chmodSync(target, 384);
|
|
39
|
-
server.unref();
|
|
40
|
-
this.server = server;
|
|
41
|
-
this.target = target;
|
|
42
|
-
return target;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
process.emitWarning(`Could not arm the po-runner lifeline: ${String(error)}`);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
path() {
|
|
49
|
-
return this.target;
|
|
50
|
-
}
|
|
51
|
-
dispose() {
|
|
52
|
-
for (const connection of this.connections) connection.destroy();
|
|
53
|
-
this.connections.clear();
|
|
54
|
-
if (this.server) {
|
|
55
|
-
try {
|
|
56
|
-
this.server.close();
|
|
57
|
-
} catch (error) {
|
|
58
|
-
process.emitWarning(`Could not close the po-runner lifeline: ${String(error)}`);
|
|
59
|
-
}
|
|
60
|
-
this.server = void 0;
|
|
61
|
-
}
|
|
62
|
-
if (this.target) {
|
|
63
|
-
try {
|
|
64
|
-
node_fs.default.rmSync(this.target, { force: true });
|
|
65
|
-
} catch (error) {
|
|
66
|
-
process.emitWarning(`Could not remove the po-runner lifeline: ${String(error)}`);
|
|
67
|
-
}
|
|
68
|
-
this.target = void 0;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/** Keeps the socket beside the session it belongs to unless that path is too long to bind. */
|
|
72
|
-
socketPath(sessionId) {
|
|
73
|
-
const preferred = node_path.default.join(this.paths.stateDirectory(sessionId), SOCKET_NAME);
|
|
74
|
-
if (Buffer.byteLength(preferred) <= 100) return preferred;
|
|
75
|
-
const hash = (0, node_crypto.createHash)("sha256").update(preferred).digest("hex").slice(0, 12);
|
|
76
|
-
return node_path.default.join(node_os.default.tmpdir(), `po-runner-${hash}.sock`);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
/** Binding must complete before the first runner launches, so arming waits for it. */
|
|
80
|
-
function listen(server, target) {
|
|
81
|
-
return new Promise((resolve, reject) => {
|
|
82
|
-
server.once("error", reject);
|
|
83
|
-
server.listen(target, () => {
|
|
84
|
-
server.removeListener("error", reject);
|
|
85
|
-
server.on("error", (error) => process.emitWarning(`po-runner lifeline failed: ${error.message}`));
|
|
86
|
-
resolve();
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
Object.defineProperty(exports, "NodeLifeline", {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
get: function() {
|
|
94
|
-
return NodeLifeline;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
//# sourceMappingURL=lifeline-m7laIzIP.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifeline-m7laIzIP.cjs","names":["net","path","createHash","os"],"sources":["../src/constants/lifeline.ts","../src/services/lifeline/index.ts"],"sourcesContent":["export const SOCKET_NAME = 'lifeline.sock';\nexport const SOCKET_PATH_LIMIT = 100;\nexport const SOCKET_HASH_LENGTH = 12;\nexport const SOCKET_MODE = 0o600;\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport net from 'node:net';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { SOCKET_HASH_LENGTH, SOCKET_MODE, SOCKET_NAME, SOCKET_PATH_LIMIT } from '../../constants/lifeline';\nimport type { ILifeline } from '../../types/lifeline';\nimport type { IRunnerPaths } from '../runnerPaths/type';\n\n/** Unix socket paths are capped at 104 bytes, so a long agent directory falls back to the temp dir. */\n\nexport class NodeLifeline implements ILifeline {\n private server: net.Server | undefined;\n private target: string | undefined;\n /** Closing a server stops it accepting; only the connections carry the death signal. */\n private readonly connections = new Set<net.Socket>();\n\n constructor(private readonly paths: IRunnerPaths) {}\n\n async arm(sessionId: string): Promise<string | undefined> {\n if (this.target) return this.target;\n try {\n this.paths.ensureDirectories(sessionId);\n const target = this.socketPath(sessionId);\n // A socket left behind by a SIGKILLed predecessor refuses connections, never accepts them.\n fs.rmSync(target, { force: true });\n const server = net.createServer((connection) => {\n // Runners need only the close edge, so their liveness and their data are equally irrelevant.\n connection.unref();\n connection.resume();\n this.connections.add(connection);\n connection.on('close', () => this.connections.delete(connection));\n });\n await listen(server, target);\n fs.chmodSync(target, SOCKET_MODE);\n // The lifeline must never be the reason pi stays alive.\n server.unref();\n this.server = server;\n this.target = target;\n return target;\n } catch (error) {\n // Runners stay unwatched rather than unlaunchable, so a session without a\n // lifeline degrades to running them unsupervised instead of failing.\n process.emitWarning(`Could not arm the po-runner lifeline: ${String(error)}`);\n return undefined;\n }\n }\n\n path(): string | undefined {\n return this.target;\n }\n\n dispose(): void {\n // Dropping the connections is what a runner sees, and it is the whole point\n // of disposing: closing the server alone would leave every runner waiting.\n for (const connection of this.connections) connection.destroy();\n this.connections.clear();\n if (this.server) {\n try {\n this.server.close();\n } catch (error) {\n process.emitWarning(`Could not close the po-runner lifeline: ${String(error)}`);\n }\n this.server = undefined;\n }\n if (this.target) {\n try {\n fs.rmSync(this.target, { force: true });\n } catch (error) {\n process.emitWarning(`Could not remove the po-runner lifeline: ${String(error)}`);\n }\n this.target = undefined;\n }\n }\n\n /** Keeps the socket beside the session it belongs to unless that path is too long to bind. */\n private socketPath(sessionId: string): string {\n const preferred = path.join(this.paths.stateDirectory(sessionId), SOCKET_NAME);\n if (Buffer.byteLength(preferred) <= SOCKET_PATH_LIMIT) return preferred;\n const hash = createHash('sha256').update(preferred).digest('hex').slice(0, SOCKET_HASH_LENGTH);\n return path.join(os.tmpdir(), `po-runner-${hash}.sock`);\n }\n}\n\n/** Binding must complete before the first runner launches, so arming waits for it. */\nfunction listen(server: net.Server, target: string): Promise<void> {\n return new Promise((resolve, reject) => {\n server.once('error', reject);\n server.listen(target, () => {\n server.removeListener('error', reject);\n // Later errors would otherwise reach the process as unhandled.\n server.on('error', (error: Error) => process.emitWarning(`po-runner lifeline failed: ${error.message}`));\n resolve();\n });\n });\n}\n"],"mappings":";;;;;;;;;;;AAAA,MAAa,cAAc;;;;ACY3B,IAAa,eAAb,MAA+C;CAMhB;CAL7B;CACA;;CAEA,8BAA+B,IAAI,IAAgB;CAEnD,YAAY,OAAsC;EAArB,KAAA,QAAA;CAAsB;CAEnD,MAAM,IAAI,WAAgD;EACxD,IAAI,KAAK,QAAQ,OAAO,KAAK;EAC7B,IAAI;GACF,KAAK,MAAM,kBAAkB,SAAS;GACtC,MAAM,SAAS,KAAK,WAAW,SAAS;GAExC,QAAA,QAAG,OAAO,QAAQ,EAAE,OAAO,KAAK,CAAC;GACjC,MAAM,SAASA,SAAAA,QAAI,cAAc,eAAe;IAE9C,WAAW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I,SAAS,SAAS,WAAW;EACtC,OAAO,KAAK,SAAS,MAAM;EAC3B,OAAO,OAAO,cAAc;GAC1B,OAAO,eAAe,SAAS,MAAM;GAErC,OAAO,GAAG,UAAU,UAAiB,QAAQ,YAAY,8BAA8B,MAAM,SAAS,CAAC;GACvG,QAAQ;EACV,CAAC;CACH,CAAC;AACH"}
|
package/dist/lifeline.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifeline.d.mts","names":[],"sources":["../src/services/lifeline/index.ts"],"mappings":";;;;;qBAYa,wBAAwB;mBAMN;UALrB;UACA;;mBAES;EAEjB,YAA6B,OAAO;EAE9B,IAAI,oBAAoB;EA6B9B;EAIA;;UAwBQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logFile-C7oQ_v-g.d.mts","names":[],"sources":["../src/types/logFile.ts"],"mappings":";;UACiB;WACN;EACT,OAAO;;EAEP;EACA;;;UAIe;EACf,KAAK,aAAa"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
2
|
-
const require_runnerConfig = require("./runnerConfig-BoLMinlx.cjs");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
5
|
-
//#region src/services/logFile/index.ts
|
|
6
|
-
var LogFile = class {
|
|
7
|
-
paths;
|
|
8
|
-
constructor(paths) {
|
|
9
|
-
this.paths = paths;
|
|
10
|
-
}
|
|
11
|
-
open(id) {
|
|
12
|
-
this.paths.ensureDirectories();
|
|
13
|
-
const logPath = this.paths.logPathFor(id);
|
|
14
|
-
const rotatedPath = this.paths.rotatedLogPathFor(id);
|
|
15
|
-
const maxBytes = require_runnerConfig.getLogMaxBytes();
|
|
16
|
-
let handle = node_fs.default.openSync(logPath, "w");
|
|
17
|
-
let written = 0;
|
|
18
|
-
let closed = false;
|
|
19
|
-
/**
|
|
20
|
-
* A run that keeps producing output for hours would otherwise grow one file
|
|
21
|
-
* without limit. Rotating keeps the newest window at the advertised path
|
|
22
|
-
* and the window before it alongside, so on-disk cost is bounded at roughly
|
|
23
|
-
* twice the ceiling, the path a result advertises stays valid, and the line
|
|
24
|
-
* counts a reader reports still describe the file it actually read.
|
|
25
|
-
*/
|
|
26
|
-
const rotate = () => {
|
|
27
|
-
node_fs.default.closeSync(handle);
|
|
28
|
-
try {
|
|
29
|
-
node_fs.default.renameSync(logPath, rotatedPath);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
process.emitWarning(`Could not rotate runner log ${logPath}: ${String(error)}`);
|
|
32
|
-
}
|
|
33
|
-
handle = node_fs.default.openSync(logPath, "w");
|
|
34
|
-
written = 0;
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
path: logPath,
|
|
38
|
-
append(text) {
|
|
39
|
-
const chunk = Buffer.from(text, "utf8");
|
|
40
|
-
if (written > 0 && written + chunk.byteLength > maxBytes) rotate();
|
|
41
|
-
node_fs.default.writeSync(handle, chunk);
|
|
42
|
-
written += chunk.byteLength;
|
|
43
|
-
},
|
|
44
|
-
size() {
|
|
45
|
-
return written;
|
|
46
|
-
},
|
|
47
|
-
close() {
|
|
48
|
-
if (closed) return;
|
|
49
|
-
closed = true;
|
|
50
|
-
try {
|
|
51
|
-
node_fs.default.closeSync(handle);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
process.emitWarning(`Could not close runner log ${logPath}: ${String(error)}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
//#endregion
|
|
60
|
-
Object.defineProperty(exports, "LogFile", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function() {
|
|
63
|
-
return LogFile;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=logFile-CnPKtxPy.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logFile-CnPKtxPy.cjs","names":["getLogMaxBytes","fs"],"sources":["../src/services/logFile/index.ts"],"sourcesContent":["import fs from 'node:fs';\n\nimport type { ILogFile, LogWriter } from '../../types/logFile';\nimport { getLogMaxBytes } from '../runnerConfig';\nimport type { IRunnerPaths } from '../runnerPaths/type';\n\nexport class LogFile implements ILogFile {\n constructor(private readonly paths: IRunnerPaths) {}\n\n open(id: string): LogWriter {\n this.paths.ensureDirectories();\n const logPath = this.paths.logPathFor(id);\n const rotatedPath = this.paths.rotatedLogPathFor(id);\n const maxBytes = getLogMaxBytes();\n\n // A reused name starts clean: the previous runner's output is already\n // available to whoever wanted it, and mixing two runs in one file makes\n // both unreadable.\n let handle = fs.openSync(logPath, 'w');\n let written = 0;\n let closed = false;\n\n /**\n * A run that keeps producing output for hours would otherwise grow one file\n * without limit. Rotating keeps the newest window at the advertised path\n * and the window before it alongside, so on-disk cost is bounded at roughly\n * twice the ceiling, the path a result advertises stays valid, and the line\n * counts a reader reports still describe the file it actually read.\n */\n const rotate = (): void => {\n fs.closeSync(handle);\n try {\n fs.renameSync(logPath, rotatedPath);\n } catch (error) {\n // Holding the ceiling matters more than keeping the previous window,\n // so the new file is opened either way and the loss is reported.\n process.emitWarning(`Could not rotate runner log ${logPath}: ${String(error)}`);\n }\n handle = fs.openSync(logPath, 'w');\n written = 0;\n };\n\n return {\n path: logPath,\n append(text: string): void {\n const chunk = Buffer.from(text, 'utf8');\n // An empty file always takes the chunk, so a single write larger than\n // the ceiling is stored rather than rotated away into nothing.\n if (written > 0 && written + chunk.byteLength > maxBytes) rotate();\n fs.writeSync(handle, chunk);\n written += chunk.byteLength;\n },\n size(): number {\n return written;\n },\n close(): void {\n // Closing twice is normal: a launch that fails closes the log before\n // the exit handler does. Only a first close that fails is news.\n if (closed) return;\n closed = true;\n try {\n fs.closeSync(handle);\n } catch (error) {\n process.emitWarning(`Could not close runner log ${logPath}: ${String(error)}`);\n }\n },\n };\n }\n}\n"],"mappings":";;;;;AAMA,IAAa,UAAb,MAAyC;CACV;CAA7B,YAAY,OAAsC;EAArB,KAAA,QAAA;CAAsB;CAEnD,KAAK,IAAuB;EAC1B,KAAK,MAAM,kBAAkB;EAC7B,MAAM,UAAU,KAAK,MAAM,WAAW,EAAE;EACxC,MAAM,cAAc,KAAK,MAAM,kBAAkB,EAAE;EACnD,MAAM,WAAWA,qBAAAA,eAAe;EAKhC,IAAI,SAASC,QAAAA,QAAG,SAAS,SAAS,GAAG;EACrC,IAAI,UAAU;EACd,IAAI,SAAS;;;;;;;;EASb,MAAM,eAAqB;GACzB,QAAA,QAAG,UAAU,MAAM;GACnB,IAAI;IACF,QAAA,QAAG,WAAW,SAAS,WAAW;GACpC,SAAS,OAAO;IAGd,QAAQ,YAAY,+BAA+B,QAAQ,IAAI,OAAO,KAAK,GAAG;GAChF;GACA,SAASA,QAAAA,QAAG,SAAS,SAAS,GAAG;GACjC,UAAU;EACZ;EAEA,OAAO;GACL,MAAM;GACN,OAAO,MAAoB;IACzB,MAAM,QAAQ,OAAO,KAAK,MAAM,MAAM;IAGtC,IAAI,UAAU,KAAK,UAAU,MAAM,aAAa,UAAU,OAAO;IACjE,QAAA,QAAG,UAAU,QAAQ,KAAK;IAC1B,WAAW,MAAM;GACnB;GACA,OAAe;IACb,OAAO;GACT;GACA,QAAc;IAGZ,IAAI,QAAQ;IACZ,SAAS;IACT,IAAI;KACF,QAAA,QAAG,UAAU,MAAM;IACrB,SAAS,OAAO;KACd,QAAQ,YAAY,8BAA8B,QAAQ,IAAI,OAAO,KAAK,GAAG;IAC/E;GACF;EACF;CACF;AACF"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { s as getLogMaxBytes } from "./runnerConfig-XXMq4VQA.mjs";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
//#region src/services/logFile/index.ts
|
|
4
|
-
var LogFile = class {
|
|
5
|
-
paths;
|
|
6
|
-
constructor(paths) {
|
|
7
|
-
this.paths = paths;
|
|
8
|
-
}
|
|
9
|
-
open(id) {
|
|
10
|
-
this.paths.ensureDirectories();
|
|
11
|
-
const logPath = this.paths.logPathFor(id);
|
|
12
|
-
const rotatedPath = this.paths.rotatedLogPathFor(id);
|
|
13
|
-
const maxBytes = getLogMaxBytes();
|
|
14
|
-
let handle = fs.openSync(logPath, "w");
|
|
15
|
-
let written = 0;
|
|
16
|
-
let closed = false;
|
|
17
|
-
/**
|
|
18
|
-
* A run that keeps producing output for hours would otherwise grow one file
|
|
19
|
-
* without limit. Rotating keeps the newest window at the advertised path
|
|
20
|
-
* and the window before it alongside, so on-disk cost is bounded at roughly
|
|
21
|
-
* twice the ceiling, the path a result advertises stays valid, and the line
|
|
22
|
-
* counts a reader reports still describe the file it actually read.
|
|
23
|
-
*/
|
|
24
|
-
const rotate = () => {
|
|
25
|
-
fs.closeSync(handle);
|
|
26
|
-
try {
|
|
27
|
-
fs.renameSync(logPath, rotatedPath);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
process.emitWarning(`Could not rotate runner log ${logPath}: ${String(error)}`);
|
|
30
|
-
}
|
|
31
|
-
handle = fs.openSync(logPath, "w");
|
|
32
|
-
written = 0;
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
path: logPath,
|
|
36
|
-
append(text) {
|
|
37
|
-
const chunk = Buffer.from(text, "utf8");
|
|
38
|
-
if (written > 0 && written + chunk.byteLength > maxBytes) rotate();
|
|
39
|
-
fs.writeSync(handle, chunk);
|
|
40
|
-
written += chunk.byteLength;
|
|
41
|
-
},
|
|
42
|
-
size() {
|
|
43
|
-
return written;
|
|
44
|
-
},
|
|
45
|
-
close() {
|
|
46
|
-
if (closed) return;
|
|
47
|
-
closed = true;
|
|
48
|
-
try {
|
|
49
|
-
fs.closeSync(handle);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
process.emitWarning(`Could not close runner log ${logPath}: ${String(error)}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
//#endregion
|
|
58
|
-
export { LogFile as t };
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=logFile-XcDHBwu1.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logFile-XcDHBwu1.mjs","names":[],"sources":["../src/services/logFile/index.ts"],"sourcesContent":["import fs from 'node:fs';\n\nimport type { ILogFile, LogWriter } from '../../types/logFile';\nimport { getLogMaxBytes } from '../runnerConfig';\nimport type { IRunnerPaths } from '../runnerPaths/type';\n\nexport class LogFile implements ILogFile {\n constructor(private readonly paths: IRunnerPaths) {}\n\n open(id: string): LogWriter {\n this.paths.ensureDirectories();\n const logPath = this.paths.logPathFor(id);\n const rotatedPath = this.paths.rotatedLogPathFor(id);\n const maxBytes = getLogMaxBytes();\n\n // A reused name starts clean: the previous runner's output is already\n // available to whoever wanted it, and mixing two runs in one file makes\n // both unreadable.\n let handle = fs.openSync(logPath, 'w');\n let written = 0;\n let closed = false;\n\n /**\n * A run that keeps producing output for hours would otherwise grow one file\n * without limit. Rotating keeps the newest window at the advertised path\n * and the window before it alongside, so on-disk cost is bounded at roughly\n * twice the ceiling, the path a result advertises stays valid, and the line\n * counts a reader reports still describe the file it actually read.\n */\n const rotate = (): void => {\n fs.closeSync(handle);\n try {\n fs.renameSync(logPath, rotatedPath);\n } catch (error) {\n // Holding the ceiling matters more than keeping the previous window,\n // so the new file is opened either way and the loss is reported.\n process.emitWarning(`Could not rotate runner log ${logPath}: ${String(error)}`);\n }\n handle = fs.openSync(logPath, 'w');\n written = 0;\n };\n\n return {\n path: logPath,\n append(text: string): void {\n const chunk = Buffer.from(text, 'utf8');\n // An empty file always takes the chunk, so a single write larger than\n // the ceiling is stored rather than rotated away into nothing.\n if (written > 0 && written + chunk.byteLength > maxBytes) rotate();\n fs.writeSync(handle, chunk);\n written += chunk.byteLength;\n },\n size(): number {\n return written;\n },\n close(): void {\n // Closing twice is normal: a launch that fails closes the log before\n // the exit handler does. Only a first close that fails is news.\n if (closed) return;\n closed = true;\n try {\n fs.closeSync(handle);\n } catch (error) {\n process.emitWarning(`Could not close runner log ${logPath}: ${String(error)}`);\n }\n },\n };\n }\n}\n"],"mappings":";;;AAMA,IAAa,UAAb,MAAyC;CACV;CAA7B,YAAY,OAAsC;EAArB,KAAA,QAAA;CAAsB;CAEnD,KAAK,IAAuB;EAC1B,KAAK,MAAM,kBAAkB;EAC7B,MAAM,UAAU,KAAK,MAAM,WAAW,EAAE;EACxC,MAAM,cAAc,KAAK,MAAM,kBAAkB,EAAE;EACnD,MAAM,WAAW,eAAe;EAKhC,IAAI,SAAS,GAAG,SAAS,SAAS,GAAG;EACrC,IAAI,UAAU;EACd,IAAI,SAAS;;;;;;;;EASb,MAAM,eAAqB;GACzB,GAAG,UAAU,MAAM;GACnB,IAAI;IACF,GAAG,WAAW,SAAS,WAAW;GACpC,SAAS,OAAO;IAGd,QAAQ,YAAY,+BAA+B,QAAQ,IAAI,OAAO,KAAK,GAAG;GAChF;GACA,SAAS,GAAG,SAAS,SAAS,GAAG;GACjC,UAAU;EACZ;EAEA,OAAO;GACL,MAAM;GACN,OAAO,MAAoB;IACzB,MAAM,QAAQ,OAAO,KAAK,MAAM,MAAM;IAGtC,IAAI,UAAU,KAAK,UAAU,MAAM,aAAa,UAAU,OAAO;IACjE,GAAG,UAAU,QAAQ,KAAK;IAC1B,WAAW,MAAM;GACnB;GACA,OAAe;IACb,OAAO;GACT;GACA,QAAc;IAGZ,IAAI,QAAQ;IACZ,SAAS;IACT,IAAI;KACF,GAAG,UAAU,MAAM;IACrB,SAAS,OAAO;KACd,QAAQ,YAAY,8BAA8B,QAAQ,IAAI,OAAO,KAAK,GAAG;IAC/E;GACF;EACF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logReader-DHCK2BEr.cjs","names":["fs","StringDecoder","getResultMaxLines","getResultMaxBytes","getResultMaxTokens","createErrorScanner","getErrorMaxEntries","boundExcerpt","composeExcerpt","countLines","formatSize"],"sources":["../src/constants/logReader.ts","../src/services/logReader/index.ts"],"sourcesContent":["export const DEFAULT_LINES = 200;\nexport const READ_CHUNK_BYTES = 65_536;\n","import fs from 'node:fs';\nimport { StringDecoder } from 'node:string_decoder';\n\nimport { DEFAULT_LINES, READ_CHUNK_BYTES } from '../../constants/logReader';\nimport { type Excerpt, type LogSummary, type TruncatedOutput } from '../../types/bashResult';\nimport type { ILogReader, LogQuery, LogSlice } from '../../types/logReader';\nimport type { RunnerSettings } from '../../types/runnerSettings';\nimport { boundExcerpt, composeExcerpt, countLines, createErrorScanner, formatSize } from '../bashResult';\nimport { getErrorMaxEntries, getResultMaxBytes, getResultMaxLines, getResultMaxTokens } from '../runnerConfig';\n\ninterface IndexedLine {\n readonly index: number;\n readonly text: string;\n}\n\ninterface ScannedLog {\n readonly text: string;\n readonly lineCount: number;\n readonly totalLines: number;\n readonly completeBytes: number;\n readonly lineNumbers?: number[];\n}\n\nexport class LogReader implements ILogReader {\n read(logPath: string, query: LogQuery = {}): LogSlice {\n let handle: number | undefined;\n try {\n handle = fs.openSync(logPath, 'r');\n const scanned = scanLog(handle, query);\n return {\n ...scanned,\n fileSize: fs.fstatSync(handle).size,\n path: logPath,\n exists: true,\n };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n return {\n text: '',\n lineCount: 0,\n totalLines: 0,\n fileSize: 0,\n completeBytes: 0,\n path: logPath,\n exists: false,\n };\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n }\n}\n\nfunction scanLog(handle: number, query: LogQuery): ScannedLog {\n const limit = Math.max(0, Math.floor(query.lines ?? DEFAULT_LINES));\n const needle = query.grep ? (query.ignoreCase ? query.grep.toLowerCase() : query.grep) : undefined;\n const contextLines = Math.max(0, Math.floor(query.contextLines ?? 0));\n const decoder = new StringDecoder('utf8');\n const buffer = Buffer.alloc(READ_CHUNK_BYTES);\n const before: IndexedLine[] = [];\n const output: IndexedLine[] = [];\n let pending = '';\n let totalLines = 0;\n let afterThrough = -1;\n let lastEmitted = -1;\n let lastByte: number | undefined;\n let bytesSeen = 0;\n let completeBytes = 0;\n\n const retain = (line: IndexedLine): void => {\n if (limit === 0) return;\n output.push(line);\n if (output.length > limit) output.shift();\n };\n const emit = (line: IndexedLine): void => {\n if (line.index <= lastEmitted) return;\n lastEmitted = line.index;\n retain(line);\n };\n const consume = (text: string): void => {\n const line = { index: totalLines, text };\n totalLines += 1;\n if (!needle) {\n retain(line);\n return;\n }\n\n const haystack = query.ignoreCase ? text.toLowerCase() : text;\n if (haystack.includes(needle)) {\n for (const previous of before) emit(previous);\n emit(line);\n afterThrough = Math.max(afterThrough, line.index + contextLines);\n } else if (line.index <= afterThrough) {\n emit(line);\n }\n before.push(line);\n if (before.length > contextLines) before.shift();\n };\n\n for (;;) {\n const bytesRead = fs.readSync(handle, buffer, 0, buffer.byteLength, null);\n if (bytesRead === 0) break;\n lastByte = buffer[bytesRead - 1];\n // A newline is a single byte in UTF-8 and never a continuation byte, so the\n // last one in this chunk ends the last complete line seen so far.\n const lastNewline = buffer.subarray(0, bytesRead).lastIndexOf(0x0a);\n if (lastNewline >= 0) completeBytes = bytesSeen + lastNewline + 1;\n bytesSeen += bytesRead;\n pending += decoder.write(buffer.subarray(0, bytesRead));\n let newline = pending.indexOf('\\n');\n while (newline >= 0) {\n consume(pending.slice(0, newline));\n pending = pending.slice(newline + 1);\n newline = pending.indexOf('\\n');\n }\n }\n pending += decoder.end();\n if (pending.length > 0) consume(pending);\n\n const trailingNewline = lastByte === 0x0a;\n const body = output.map((line) => line.text).join('\\n');\n const text = `${body}${!needle && trailingNewline && output.length > 0 ? '\\n' : ''}`;\n const scanned: ScannedLog = { text, lineCount: output.length, totalLines, completeBytes };\n if (!needle) return scanned;\n return { ...scanned, lineNumbers: output.map((line) => line.index + 1) };\n}\n\n/**\n * Grep with context, matching the `product-stack logs` semantics so the two\n * surfaces behave the same. Overlapping and adjacent context windows merge.\n */\nexport function filterLogText(text: string, query: Pick<LogQuery, 'grep' | 'ignoreCase' | 'contextLines'>): string {\n if (!query.grep) return text;\n const lines = text.split('\\n');\n const needle = query.ignoreCase ? query.grep.toLowerCase() : query.grep;\n const contextLines = Math.max(0, query.contextLines ?? 0);\n const ranges: Array<{ start: number; end: number }> = [];\n\n lines.forEach((line, index) => {\n const haystack = query.ignoreCase ? line.toLowerCase() : line;\n if (!haystack.includes(needle)) return;\n ranges.push({\n start: Math.max(0, index - contextLines),\n end: Math.min(lines.length - 1, index + contextLines),\n });\n });\n\n if (ranges.length === 0) return '';\n const merged: Array<{ start: number; end: number }> = [];\n for (const range of ranges) {\n const previous = merged.at(-1);\n if (previous && range.start <= previous.end + 1) {\n previous.end = Math.max(previous.end, range.end);\n } else {\n merged.push({ ...range });\n }\n }\n return merged.flatMap((range) => lines.slice(range.start, range.end + 1)).join('\\n');\n}\n\n/** Reads a bounded head and tail plus exact metadata after the writer has flushed. */\nexport function summarizeLog(\n path: string,\n maxLines = getResultMaxLines(),\n maxBytes = getResultMaxBytes(),\n maxTokens = getResultMaxTokens(),\n settings?: RunnerSettings,\n): LogSummary {\n let handle: number | undefined;\n try {\n const size = fs.statSync(path).size;\n handle = fs.openSync(path, 'r');\n const readBuffer = Buffer.alloc(READ_CHUNK_BYTES);\n // Both ends are captured at the full budget; the line trim decides the split.\n const endLimit = Math.max(1, maxBytes + 1);\n let headBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n let tailBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n let newlineCount = 0;\n let lastByte: number | undefined;\n const decoder = new StringDecoder('utf8');\n const scanned = createErrorScanner(getErrorMaxEntries(settings), settings);\n let pending = '';\n for (;;) {\n const bytesRead = fs.readSync(handle, readBuffer, 0, readBuffer.byteLength, null);\n if (bytesRead === 0) break;\n const chunk = readBuffer.subarray(0, bytesRead);\n for (const byte of chunk) if (byte === 0x0a) newlineCount += 1;\n lastByte = chunk.at(-1);\n if (headBuffer.byteLength < endLimit) {\n headBuffer = Buffer.concat([headBuffer, chunk.subarray(0, endLimit - headBuffer.byteLength)]);\n }\n tailBuffer = appendBufferTail(tailBuffer, chunk, endLimit);\n pending += decoder.write(chunk);\n let newline = pending.indexOf('\\n');\n while (newline >= 0) {\n scanned.push(pending.slice(0, newline));\n pending = pending.slice(newline + 1);\n newline = pending.indexOf('\\n');\n }\n }\n pending += decoder.end();\n if (pending.length > 0) scanned.push(pending);\n const lines = newlineCount + (size > 0 && lastByte !== 0x0a ? 1 : 0);\n // The tail capture holds the whole file only while the file fits inside one\n // buffer. Past that the start is already gone from it, so the two ends have\n // to be composed instead.\n const excerpt =\n size <= tailBuffer.byteLength\n ? boundExcerpt(utf8Tail(tailBuffer, tailBuffer.byteLength), maxLines, maxBytes, maxTokens, settings)\n : composeExcerpt(\n headBuffer.toString('utf8'),\n utf8Tail(tailBuffer, tailBuffer.byteLength),\n lines,\n maxLines,\n maxBytes,\n scanned.entries(),\n maxTokens,\n settings,\n );\n return { tail: excerpt.text, bytes: size, lines, tailLines: excerpt.lines };\n } catch {\n return { tail: '', bytes: 0, lines: 0, tailLines: 0 };\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n}\n\n/**\n * Keeps both ends of an oversized result and points at the file holding the rest.\n *\n * The notice states the file's real size and line count so the model does not\n * guess at offsets when it goes on to read the file, which is the failure this\n * whole policy exists to prevent.\n */\nexport function truncateForResult(\n text: string,\n fullOutputPath: string,\n maxBytes = getResultMaxBytes(),\n maxLines = getResultMaxLines(),\n): TruncatedOutput {\n const excerpt = boundExcerpt(text, maxLines, maxBytes);\n if (!excerpt.truncated) return { text, truncated: false, outputLines: excerpt.lines };\n\n return {\n text: `${excerpt.text}\\n${truncationNotice(excerpt, fullOutputPath, text)}`,\n truncated: true,\n outputLines: excerpt.lines,\n };\n}\n\nfunction truncationNotice(excerpt: Excerpt, fullOutputPath: string, text: string): string {\n // Counted from the file, never from `text`. What the caller holds in memory\n // is itself capped, so using it here would understate the file by orders of\n // magnitude and send the reader looking past the end of a much longer file.\n const file = measureFile(fullOutputPath);\n const totalLines = file?.lines ?? countLines(text);\n const fileSize = file?.bytes ?? Buffer.byteLength(text, 'utf8');\n\n return [\n `[output truncated: showing ${excerpt.lines.toLocaleString('en-US')} of ${totalLines.toLocaleString('en-US')} lines,`,\n `${excerpt.elidedLines.toLocaleString('en-US')} elided from the middle.`,\n `Full output is at ${fullOutputPath} (${formatSize(fileSize)}, ${totalLines.toLocaleString('en-US')} lines).`,\n `Inspect it with po-runner logs, or read the file with an offset near line ${totalLines.toLocaleString('en-US')}.]`,\n ].join(' ');\n}\n\n/** Real size and line count of the file the notice points at. */\nfunction measureFile(path: string): { bytes: number; lines: number } | undefined {\n let handle: number | undefined;\n try {\n const bytes = fs.statSync(path).size;\n handle = fs.openSync(path, 'r');\n const buffer = Buffer.alloc(READ_CHUNK_BYTES);\n let newlineCount = 0;\n let lastByte: number | undefined;\n for (;;) {\n const bytesRead = fs.readSync(handle, buffer, 0, buffer.byteLength, null);\n if (bytesRead === 0) break;\n const chunk = buffer.subarray(0, bytesRead);\n for (const byte of chunk) if (byte === 0x0a) newlineCount += 1;\n lastByte = chunk.at(-1);\n }\n return { bytes, lines: newlineCount + (bytes > 0 && lastByte !== 0x0a ? 1 : 0) };\n } catch {\n return undefined;\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n}\n\nfunction utf8Tail(encoded: Buffer<ArrayBufferLike>, maxBytes: number): string {\n let start = Math.max(0, encoded.byteLength - maxBytes);\n while (start < encoded.byteLength && (encoded[start]! & 0xc0) === 0x80) start += 1;\n return encoded.subarray(start).toString('utf8');\n}\n\nfunction appendBufferTail(\n current: Buffer<ArrayBufferLike>,\n chunk: Buffer<ArrayBufferLike>,\n limit: number,\n): Buffer<ArrayBufferLike> {\n if (chunk.byteLength >= limit) return Buffer.from(chunk.subarray(chunk.byteLength - limit));\n const combined = Buffer.concat([current, chunk]);\n return combined.byteLength > limit ? Buff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"],"sourcesContent":["export const DEFAULT_LINES = 200;\nexport const READ_CHUNK_BYTES = 65_536;\n","import fs from 'node:fs';\nimport { StringDecoder } from 'node:string_decoder';\n\nimport { DEFAULT_LINES, READ_CHUNK_BYTES } from '../../constants/logReader';\nimport { type Excerpt, type LogSummary, type TruncatedOutput } from '../../types/bashResult';\nimport type { ILogReader, LogQuery, LogSlice } from '../../types/logReader';\nimport type { RunnerSettings } from '../../types/runnerSettings';\nimport { boundExcerpt, composeExcerpt, countLines, createErrorScanner, formatSize } from '../bashResult';\nimport { getErrorMaxEntries, getResultMaxBytes, getResultMaxLines, getResultMaxTokens } from '../runnerConfig';\n\ninterface IndexedLine {\n readonly index: number;\n readonly text: string;\n}\n\ninterface ScannedLog {\n readonly text: string;\n readonly lineCount: number;\n readonly totalLines: number;\n readonly completeBytes: number;\n readonly lineNumbers?: number[];\n}\n\nexport class LogReader implements ILogReader {\n read(logPath: string, query: LogQuery = {}): LogSlice {\n let handle: number | undefined;\n try {\n handle = fs.openSync(logPath, 'r');\n const scanned = scanLog(handle, query);\n return {\n ...scanned,\n fileSize: fs.fstatSync(handle).size,\n path: logPath,\n exists: true,\n };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n return {\n text: '',\n lineCount: 0,\n totalLines: 0,\n fileSize: 0,\n completeBytes: 0,\n path: logPath,\n exists: false,\n };\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n }\n}\n\nfunction scanLog(handle: number, query: LogQuery): ScannedLog {\n const limit = Math.max(0, Math.floor(query.lines ?? DEFAULT_LINES));\n const needle = query.grep ? (query.ignoreCase ? query.grep.toLowerCase() : query.grep) : undefined;\n const contextLines = Math.max(0, Math.floor(query.contextLines ?? 0));\n const decoder = new StringDecoder('utf8');\n const buffer = Buffer.alloc(READ_CHUNK_BYTES);\n const before: IndexedLine[] = [];\n const output: IndexedLine[] = [];\n let pending = '';\n let totalLines = 0;\n let afterThrough = -1;\n let lastEmitted = -1;\n let lastByte: number | undefined;\n let bytesSeen = 0;\n let completeBytes = 0;\n\n const retain = (line: IndexedLine): void => {\n if (limit === 0) return;\n output.push(line);\n if (output.length > limit) output.shift();\n };\n const emit = (line: IndexedLine): void => {\n if (line.index <= lastEmitted) return;\n lastEmitted = line.index;\n retain(line);\n };\n const consume = (text: string): void => {\n const line = { index: totalLines, text };\n totalLines += 1;\n if (!needle) {\n retain(line);\n return;\n }\n\n const haystack = query.ignoreCase ? text.toLowerCase() : text;\n if (haystack.includes(needle)) {\n for (const previous of before) emit(previous);\n emit(line);\n afterThrough = Math.max(afterThrough, line.index + contextLines);\n } else if (line.index <= afterThrough) {\n emit(line);\n }\n before.push(line);\n if (before.length > contextLines) before.shift();\n };\n\n for (;;) {\n const bytesRead = fs.readSync(handle, buffer, 0, buffer.byteLength, null);\n if (bytesRead === 0) break;\n lastByte = buffer[bytesRead - 1];\n // A newline is a single byte in UTF-8 and never a continuation byte, so the\n // last one in this chunk ends the last complete line seen so far.\n const lastNewline = buffer.subarray(0, bytesRead).lastIndexOf(0x0a);\n if (lastNewline >= 0) completeBytes = bytesSeen + lastNewline + 1;\n bytesSeen += bytesRead;\n pending += decoder.write(buffer.subarray(0, bytesRead));\n let newline = pending.indexOf('\\n');\n while (newline >= 0) {\n consume(pending.slice(0, newline));\n pending = pending.slice(newline + 1);\n newline = pending.indexOf('\\n');\n }\n }\n pending += decoder.end();\n if (pending.length > 0) consume(pending);\n\n const trailingNewline = lastByte === 0x0a;\n const body = output.map((line) => line.text).join('\\n');\n const text = `${body}${!needle && trailingNewline && output.length > 0 ? '\\n' : ''}`;\n const scanned: ScannedLog = { text, lineCount: output.length, totalLines, completeBytes };\n if (!needle) return scanned;\n return { ...scanned, lineNumbers: output.map((line) => line.index + 1) };\n}\n\n/**\n * Grep with context, matching the `product-stack logs` semantics so the two\n * surfaces behave the same. Overlapping and adjacent context windows merge.\n */\nexport function filterLogText(text: string, query: Pick<LogQuery, 'grep' | 'ignoreCase' | 'contextLines'>): string {\n if (!query.grep) return text;\n const lines = text.split('\\n');\n const needle = query.ignoreCase ? query.grep.toLowerCase() : query.grep;\n const contextLines = Math.max(0, query.contextLines ?? 0);\n const ranges: Array<{ start: number; end: number }> = [];\n\n lines.forEach((line, index) => {\n const haystack = query.ignoreCase ? line.toLowerCase() : line;\n if (!haystack.includes(needle)) return;\n ranges.push({\n start: Math.max(0, index - contextLines),\n end: Math.min(lines.length - 1, index + contextLines),\n });\n });\n\n if (ranges.length === 0) return '';\n const merged: Array<{ start: number; end: number }> = [];\n for (const range of ranges) {\n const previous = merged.at(-1);\n if (previous && range.start <= previous.end + 1) {\n previous.end = Math.max(previous.end, range.end);\n } else {\n merged.push({ ...range });\n }\n }\n return merged.flatMap((range) => lines.slice(range.start, range.end + 1)).join('\\n');\n}\n\n/** Reads a bounded head and tail plus exact metadata after the writer has flushed. */\nexport function summarizeLog(\n path: string,\n maxLines = getResultMaxLines(),\n maxBytes = getResultMaxBytes(),\n maxTokens = getResultMaxTokens(),\n settings?: RunnerSettings,\n): LogSummary {\n let handle: number | undefined;\n try {\n const size = fs.statSync(path).size;\n handle = fs.openSync(path, 'r');\n const readBuffer = Buffer.alloc(READ_CHUNK_BYTES);\n // Both ends are captured at the full budget; the line trim decides the split.\n const endLimit = Math.max(1, maxBytes + 1);\n let headBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n let tailBuffer: Buffer<ArrayBufferLike> = Buffer.alloc(0);\n let newlineCount = 0;\n let lastByte: number | undefined;\n const decoder = new StringDecoder('utf8');\n const scanned = createErrorScanner(getErrorMaxEntries(settings), settings);\n let pending = '';\n for (;;) {\n const bytesRead = fs.readSync(handle, readBuffer, 0, readBuffer.byteLength, null);\n if (bytesRead === 0) break;\n const chunk = readBuffer.subarray(0, bytesRead);\n for (const byte of chunk) if (byte === 0x0a) newlineCount += 1;\n lastByte = chunk.at(-1);\n if (headBuffer.byteLength < endLimit) {\n headBuffer = Buffer.concat([headBuffer, chunk.subarray(0, endLimit - headBuffer.byteLength)]);\n }\n tailBuffer = appendBufferTail(tailBuffer, chunk, endLimit);\n pending += decoder.write(chunk);\n let newline = pending.indexOf('\\n');\n while (newline >= 0) {\n scanned.push(pending.slice(0, newline));\n pending = pending.slice(newline + 1);\n newline = pending.indexOf('\\n');\n }\n }\n pending += decoder.end();\n if (pending.length > 0) scanned.push(pending);\n const lines = newlineCount + (size > 0 && lastByte !== 0x0a ? 1 : 0);\n // The tail capture holds the whole file only while the file fits inside one\n // buffer. Past that the start is already gone from it, so the two ends have\n // to be composed instead.\n const excerpt =\n size <= tailBuffer.byteLength\n ? boundExcerpt(utf8Tail(tailBuffer, tailBuffer.byteLength), maxLines, maxBytes, maxTokens, settings)\n : composeExcerpt(\n headBuffer.toString('utf8'),\n utf8Tail(tailBuffer, tailBuffer.byteLength),\n lines,\n maxLines,\n maxBytes,\n scanned.entries(),\n maxTokens,\n settings,\n );\n return { tail: excerpt.text, bytes: size, lines, tailLines: excerpt.lines };\n } catch {\n return { tail: '', bytes: 0, lines: 0, tailLines: 0 };\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n}\n\n/**\n * Keeps both ends of an oversized result and points at the file holding the rest.\n *\n * The notice states the file's real size and line count so the model does not\n * guess at offsets when it goes on to read the file, which is the failure this\n * whole policy exists to prevent.\n */\nexport function truncateForResult(\n text: string,\n fullOutputPath: string,\n maxBytes = getResultMaxBytes(),\n maxLines = getResultMaxLines(),\n): TruncatedOutput {\n const excerpt = boundExcerpt(text, maxLines, maxBytes);\n if (!excerpt.truncated) return { text, truncated: false, outputLines: excerpt.lines };\n\n return {\n text: `${excerpt.text}\\n${truncationNotice(excerpt, fullOutputPath, text)}`,\n truncated: true,\n outputLines: excerpt.lines,\n };\n}\n\nfunction truncationNotice(excerpt: Excerpt, fullOutputPath: string, text: string): string {\n // Counted from the file, never from `text`. What the caller holds in memory\n // is itself capped, so using it here would understate the file by orders of\n // magnitude and send the reader looking past the end of a much longer file.\n const file = measureFile(fullOutputPath);\n const totalLines = file?.lines ?? countLines(text);\n const fileSize = file?.bytes ?? Buffer.byteLength(text, 'utf8');\n\n return [\n `[output truncated: showing ${excerpt.lines.toLocaleString('en-US')} of ${totalLines.toLocaleString('en-US')} lines,`,\n `${excerpt.elidedLines.toLocaleString('en-US')} elided from the middle.`,\n `Full output is at ${fullOutputPath} (${formatSize(fileSize)}, ${totalLines.toLocaleString('en-US')} lines).`,\n `Inspect it with po-runner logs, or read the file with an offset near line ${totalLines.toLocaleString('en-US')}.]`,\n ].join(' ');\n}\n\n/** Real size and line count of the file the notice points at. */\nfunction measureFile(path: string): { bytes: number; lines: number } | undefined {\n let handle: number | undefined;\n try {\n const bytes = fs.statSync(path).size;\n handle = fs.openSync(path, 'r');\n const buffer = Buffer.alloc(READ_CHUNK_BYTES);\n let newlineCount = 0;\n let lastByte: number | undefined;\n for (;;) {\n const bytesRead = fs.readSync(handle, buffer, 0, buffer.byteLength, null);\n if (bytesRead === 0) break;\n const chunk = buffer.subarray(0, bytesRead);\n for (const byte of chunk) if (byte === 0x0a) newlineCount += 1;\n lastByte = chunk.at(-1);\n }\n return { bytes, lines: newlineCount + (bytes > 0 && lastByte !== 0x0a ? 1 : 0) };\n } catch {\n return undefined;\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n}\n\nfunction utf8Tail(encoded: Buffer<ArrayBufferLike>, maxBytes: number): string {\n let start = Math.max(0, encoded.byteLength - maxBytes);\n while (start < encoded.byteLength && (encoded[start]! & 0xc0) === 0x80) start += 1;\n return encoded.subarray(start).toString('utf8');\n}\n\nfunction appendBufferTail(\n current: Buffer<ArrayBufferLike>,\n chunk: Buffer<ArrayBufferLike>,\n limit: number,\n): Buffer<ArrayBufferLike> {\n if (chunk.byteLength >= limit) return Buffer.from(chunk.subarray(chunk.byteLength - limit));\n const combined = Buffer.concat([current, chunk]);\n return combined.byteLength > limit ? Buffer.from(combined.subarray(combined.byteLength - limit)) : combined;\n}\n"],"mappings":";;;;;AACA,MAAa,mBAAmB;;;AC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Y,IAAI;GACxE,IAAI,cAAc,GAAG;GACrB,MAAM,QAAQ,OAAO,SAAS,GAAG,SAAS;GAC1C,KAAK,MAAM,QAAQ,OAAO,IAAI,SAAS,IAAM,gBAAgB;GAC7D,WAAW,MAAM,GAAG,EAAE;EACxB;EACA,OAAO;GAAE;GAAO,OAAO,gBAAgB,QAAQ,KAAK,aAAa,KAAO,IAAI;EAAG;CACjF,QAAQ;EACN;CACF,UAAU;EACR,IAAI,WAAW,KAAA,GAAW,GAAG,UAAU,MAAM;CAC/C;AACF;AAEA,SAAS,SAAS,SAAkC,UAA0B;CAC5E,IAAI,QAAQ,KAAK,IAAI,GAAG,QAAQ,aAAa,QAAQ;CACrD,OAAO,QAAQ,QAAQ,eAAe,QAAQ,SAAU,SAAU,KAAM,SAAS;CACjF,OAAO,QAAQ,SAAS,KAAK,CAAC,CAAC,SAAS,MAAM;AAChD;AAEA,SAAS,iBACP,SACA,OACA,OACyB;CACzB,IAAI,MAAM,cAAc,OAAO,OAAO,OAAO,KAAK,MAAM,SAAS,MAAM,aAAa,KAAK,CAAC;CAC1F,MAAM,WAAW,OAAO,OAAO,CAAC,SAAS,KAAK,CAAC;CAC/C,OAAO,SAAS,aAAa,QAAQ,OAAO,KAAK,SAAS,SAAS,SAAS,aAAa,KAAK,CAAC,IAAI;AACrG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ptyHost-CwbLLr90.mjs","names":[],"sources":["../src/constants/ptyHost.ts","../src/services/ptyHost/index.ts"],"sourcesContent":["export const DEFAULT_COLS = 120;\nexport const DEFAULT_ROWS = 30;\nexport const SCROLLBACK = 2_000;\nexport const MEMORY_BUFFER_FACTOR = 2;\nexport const TERM_GRACE_MS = 2_000;\nexport const LIVENESS_POLL_MS = 100;\nexport const NEWLINE = '\\n';\n","import headless, { type Terminal } from '@xterm/headless';\n\nimport {\n DEFAULT_COLS,\n DEFAULT_ROWS,\n LIVENESS_POLL_MS,\n MEMORY_BUFFER_FACTOR,\n NEWLINE,\n SCROLLBACK,\n TERM_GRACE_MS,\n} from '../../constants/ptyHost';\nimport { PI_SESSION_ID_ENV } from '../../constants/session';\nimport type { IClock } from '../../types/clock';\nimport type { ILogFile } from '../../types/logFile';\nimport type { IProcessControl } from '../../types/processControl';\nimport type { IPtyHost, PtyLaunchRequest, PtyRun } from '../../types/ptyHost';\nimport type { IPtySpawner, PtyProcess } from '../../types/ptySpawner';\nimport type { RunnerSettings } from '../../types/runnerSettings';\nimport type { ExitResult } from '../../types/spawner';\nimport { scrubTerminalOutput } from '../ansiScrub';\nimport { getResultMaxBytes } from '../runnerConfig';\nimport { NO_TERMINAL_INPUT_ENV } from '../runnerSupervisor';\n\n/** Enough history for the overlay to scroll without holding a whole build. */\n\n// Use the CommonJS default export: Node cannot detect this package's named exports.\n// A static import also lets server bundles include it without a live node_modules lookup.\nconst { Terminal: HeadlessTerminal } = headless;\n\nexport class PtyHost implements IPtyHost {\n private readonly runs = new Map<string, PtyRun>();\n\n constructor(\n private readonly spawner: IPtySpawner,\n private readonly logFile: ILogFile,\n private readonly processControl: IProcessControl,\n private readonly clock: IClock,\n private readonly environment: Readonly<Record<string, string | undefined>> = process.env,\n private readonly settings?: RunnerSettings,\n ) {}\n\n async launch(request: PtyLaunchRequest): Promise<PtyRun> {\n const cols = request.cols ?? DEFAULT_COLS;\n const rows = request.rows ?? DEFAULT_ROWS;\n const writer = this.logFile.open(request.id);\n const terminal = new HeadlessTerminal({ cols, rows, scrollback: SCROLLBACK, allowProposedApi: true });\n const memoryLimit = getResultMaxBytes(this.environment, this.settings) * MEMORY_BUFFER_FACTOR;\n\n const child = await this.spawner.spawn({\n command: request.command,\n cwd: request.cwd,\n env: { ...this.environment, ...NO_TERMINAL_INPUT_ENV, [PI_SESSION_ID_ENV]: request.sessionId },\n cols,\n rows,\n });\n\n let buffer = '';\n let buffering = true;\n let settled = false;\n let resolveCompletion: (result: ExitResult) => void = () => undefined;\n const completion = new Promise<ExitResult>((resolve) => {\n resolveCompletion = resolve;\n });\n const dataHandlers = new Set<(data: string) => void>();\n\n child.onData((data) => {\n // The terminal keeps the screen; the log keeps text worth grepping.\n terminal.write(data);\n const scrubbed = scrubTerminalOutput(data);\n writer.append(scrubbed);\n if (buffering) {\n buffer += scrubbed;\n if (buffer.length > memoryLimit) buffer = buffer.slice(-memoryLimit);\n }\n for (const handler of dataHandlers) handler(data);\n });\n\n child.onExit((result) => {\n if (settled) return;\n settled = true;\n this.runs.delete(request.name);\n writer.close();\n resolveCompletion({ code: result.exitCode, signal: null });\n });\n\n const run: PtyRun = {\n id: request.id,\n name: request.name,\n pid: child.pid,\n logPath: writer.path,\n backend: 'native',\n output: () => buffer,\n completion: () => completion,\n detach: () => {\n buffering = false;\n buffer = '';\n },\n stop: () => this.stopChild(child, request.name),\n write: (text) => child.write(text),\n screen: () => renderScreen(terminal),\n onData: (handler) => {\n dataHandlers.add(handler);\n return () => dataHandlers.delete(handler);\n },\n resize: (nextCols, nextRows) => {\n child.resize(nextCols, nextRows);\n terminal.resize(nextCols, nextRows);\n },\n };\n\n this.runs.set(request.name, run);\n return run;\n }\n\n get(name: string): PtyRun | undefined {\n return this.runs.get(name);\n }\n\n write(name: string, text: string): boolean {\n const run = this.runs.get(name);\n if (!run) return false;\n run.write(text.endsWith(NEWLINE) ? text : `${text}${NEWLINE}`);\n return true;\n }\n\n list(): PtyRun[] {\n return [...this.runs.values()];\n }\n\n async disposeAll(): Promise<void> {\n const runs = [...this.runs.values()];\n this.runs.clear();\n for (const run of runs) await run.stop();\n }\n\n private async stopChild(child: PtyProcess, name: string): Promise<boolean> {\n this.runs.delete(name);\n if (!this.processControl.isAlive(child.pid)) return false;\n\n child.kill('SIGTERM');\n const deadline = this.clock.now() + TERM_GRACE_MS;\n while (this.clock.now() < deadline) {\n if (!this.processControl.isAlive(child.pid)) return true;\n await new Promise<void>((resolve) => {\n this.clock.after(LIVENESS_POLL_MS, resolve);\n });\n }\n child.kill('SIGKILL');\n return true;\n }\n}\n\n/** The visible rows, trimmed of trailing blanks, as plain text. */\nfunction renderScreen(terminal: Terminal): string {\n const buffer = terminal.buffer.active;\n const lines: string[] = [];\n for (let row = buffer.baseY; row < buffer.baseY + terminal.rows; row += 1) {\n lines.push(buffer.getLine(row)?.translateToString(true) ?? '');\n }\n while (lines.length > 0 && lines.at(-1) === '') lines.pop();\n return lines.join(NEWLINE);\n}\n"],"mappings":";;;;;;AAEA,MAAa,aAAa;AAE1B,MAAa,gBAAgB;;;;ACuB7B,MAAM,EAAE,UAAU,qBAAqB;AAEvC,IAAa,UAAb,MAAyC;CAIpB;CACA;CACA;CACA;CACA;CACA;CARnB,uBAAwB,IAAI,IAAoB;CAEhD,YACE,SACA,SACA,gBACA,OACA,cAA6E,QAAQ,KACrF,UACA;EANiB,KAAA,UAAA;EACA,KAAA,UAAA;EACA,KAAA,iBAAA;EACA,KAAA,QAAA;EACA,KAAA,cAAA;EACA,KAAA,WAAA;CAChB;CAEH,MAAM,OAAO,SAA4C;EACvD,MAAM,OAAO,QAAQ,QAAA;EACrB,MAAM,OAAO,QAAQ,QAAA;EACrB,MAAM,SAAS,KAAK,QAAQ,KAAK,QAAQ,EAAE;EAC3C,MAAM,WAAW,IAAI,iBAAiB;GAAE;GAAM;GAAM,YAAY;GAAY,kBAAkB;EAAK,CAAC;EACpG,MAAM,cAAc,kBAAkB,KAAK,aAAa,KAAK,QAAQ,IAAA;EAErE,MAAM,QAAQ,MAAM,KAAK,QAAQ,MAAM;GACrC,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACb,KAAK;IAAE,GAAG,KAAK;IAAa,GAAG;KAAwB,oBAAoB,QAAQ;GAAU;GAC7F;GACA;EACF,CAAC;EAED,IAAI,SAAS;EACb,IAAI,YAAY;EAChB,IAAI,UAAU;EACd,IAAI,0BAAwD,KAAA;EAC5D,MAAM,aAAa,IAAI,SAAqB,YAAY;GACtD,oBAAoB;EACtB,CAAC;EACD,MAAM,+BAAe,IAAI,IAA4B;EAErD,MAAM,QAAQ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/B;CAEA,MAAM,aAA4B;EAChC,MAAM,OAAO,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC;EACnC,KAAK,KAAK,MAAM;EAChB,KAAK,MAAM,OAAO,MAAM,MAAM,IAAI,KAAK;CACzC;CAEA,MAAc,UAAU,OAAmB,MAAgC;EACzE,KAAK,KAAK,OAAO,IAAI;EACrB,IAAI,CAAC,KAAK,eAAe,QAAQ,MAAM,GAAG,GAAG,OAAO;EAEpD,MAAM,KAAK,SAAS;EACpB,MAAM,WAAW,KAAK,MAAM,IAAI,IAAI;EACpC,OAAO,KAAK,MAAM,IAAI,IAAI,UAAU;GAClC,IAAI,CAAC,KAAK,eAAe,QAAQ,MAAM,GAAG,GAAG,OAAO;GACpD,MAAM,IAAI,SAAe,YAAY;IACnC,KAAK,MAAM,MAAA,KAAwB,OAAO;GAC5C,CAAC;EACH;EACA,MAAM,KAAK,SAAS;EACpB,OAAO;CACT;AACF;;AAGA,SAAS,aAAa,UAA4B;CAChD,MAAM,SAAS,SAAS,OAAO;CAC/B,MAAM,QAAkB,CAAC;CACzB,KAAK,IAAI,MAAM,OAAO,OAAO,MAAM,OAAO,QAAQ,SAAS,MAAM,OAAO,GACtE,MAAM,KAAK,OAAO,QAAQ,GAAG,CAAC,EAAE,kBAAkB,IAAI,KAAK,EAAE;CAE/D,OAAO,MAAM,SAAS,KAAK,MAAM,GAAG,EAAE,MAAM,IAAI,MAAM,IAAI;CAC1D,OAAO,MAAM,KAAA,IAAY;AAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ptyHost-D35hNmtd.cjs","names":["headless","getResultMaxBytes","NO_TERMINAL_INPUT_ENV","PI_SESSION_ID_ENV","scrubTerminalOutput"],"sources":["../src/constants/ptyHost.ts","../src/services/ptyHost/index.ts"],"sourcesContent":["export const DEFAULT_COLS = 120;\nexport const DEFAULT_ROWS = 30;\nexport const SCROLLBACK = 2_000;\nexport const MEMORY_BUFFER_FACTOR = 2;\nexport const TERM_GRACE_MS = 2_000;\nexport const LIVENESS_POLL_MS = 100;\nexport const NEWLINE = '\\n';\n","import headless, { type Terminal } from '@xterm/headless';\n\nimport {\n DEFAULT_COLS,\n DEFAULT_ROWS,\n LIVENESS_POLL_MS,\n MEMORY_BUFFER_FACTOR,\n NEWLINE,\n SCROLLBACK,\n TERM_GRACE_MS,\n} from '../../constants/ptyHost';\nimport { PI_SESSION_ID_ENV } from '../../constants/session';\nimport type { IClock } from '../../types/clock';\nimport type { ILogFile } from '../../types/logFile';\nimport type { IProcessControl } from '../../types/processControl';\nimport type { IPtyHost, PtyLaunchRequest, PtyRun } from '../../types/ptyHost';\nimport type { IPtySpawner, PtyProcess } from '../../types/ptySpawner';\nimport type { RunnerSettings } from '../../types/runnerSettings';\nimport type { ExitResult } from '../../types/spawner';\nimport { scrubTerminalOutput } from '../ansiScrub';\nimport { getResultMaxBytes } from '../runnerConfig';\nimport { NO_TERMINAL_INPUT_ENV } from '../runnerSupervisor';\n\n/** Enough history for the overlay to scroll without holding a whole build. */\n\n// Use the CommonJS default export: Node cannot detect this package's named exports.\n// A static import also lets server bundles include it without a live node_modules lookup.\nconst { Terminal: HeadlessTerminal } = headless;\n\nexport class PtyHost implements IPtyHost {\n private readonly runs = new Map<string, PtyRun>();\n\n constructor(\n private readonly spawner: IPtySpawner,\n private readonly logFile: ILogFile,\n private readonly processControl: IProcessControl,\n private readonly clock: IClock,\n private readonly environment: Readonly<Record<string, string | undefined>> = process.env,\n private readonly settings?: RunnerSettings,\n ) {}\n\n async launch(request: PtyLaunchRequest): Promise<PtyRun> {\n const cols = request.cols ?? DEFAULT_COLS;\n const rows = request.rows ?? DEFAULT_ROWS;\n const writer = this.logFile.open(request.id);\n const terminal = new HeadlessTerminal({ cols, rows, scrollback: SCROLLBACK, allowProposedApi: true });\n const memoryLimit = getResultMaxBytes(this.environment, this.settings) * MEMORY_BUFFER_FACTOR;\n\n const child = await this.spawner.spawn({\n command: request.command,\n cwd: request.cwd,\n env: { ...this.environment, ...NO_TERMINAL_INPUT_ENV, [PI_SESSION_ID_ENV]: request.sessionId },\n cols,\n rows,\n });\n\n let buffer = '';\n let buffering = true;\n let settled = false;\n let resolveCompletion: (result: ExitResult) => void = () => undefined;\n const completion = new Promise<ExitResult>((resolve) => {\n resolveCompletion = resolve;\n });\n const dataHandlers = new Set<(data: string) => void>();\n\n child.onData((data) => {\n // The terminal keeps the screen; the log keeps text worth grepping.\n terminal.write(data);\n const scrubbed = scrubTerminalOutput(data);\n writer.append(scrubbed);\n if (buffering) {\n buffer += scrubbed;\n if (buffer.length > memoryLimit) buffer = buffer.slice(-memoryLimit);\n }\n for (const handler of dataHandlers) handler(data);\n });\n\n child.onExit((result) => {\n if (settled) return;\n settled = true;\n this.runs.delete(request.name);\n writer.close();\n resolveCompletion({ code: result.exitCode, signal: null });\n });\n\n const run: PtyRun = {\n id: request.id,\n name: request.name,\n pid: child.pid,\n logPath: writer.path,\n backend: 'native',\n output: () => buffer,\n completion: () => completion,\n detach: () => {\n buffering = false;\n buffer = '';\n },\n stop: () => this.stopChild(child, request.name),\n write: (text) => child.write(text),\n screen: () => renderScreen(terminal),\n onData: (handler) => {\n dataHandlers.add(handler);\n return () => dataHandlers.delete(handler);\n },\n resize: (nextCols, nextRows) => {\n child.resize(nextCols, nextRows);\n terminal.resize(nextCols, nextRows);\n },\n };\n\n this.runs.set(request.name, run);\n return run;\n }\n\n get(name: string): PtyRun | undefined {\n return this.runs.get(name);\n }\n\n write(name: string, text: string): boolean {\n const run = this.runs.get(name);\n if (!run) return false;\n run.write(text.endsWith(NEWLINE) ? text : `${text}${NEWLINE}`);\n return true;\n }\n\n list(): PtyRun[] {\n return [...this.runs.values()];\n }\n\n async disposeAll(): Promise<void> {\n const runs = [...this.runs.values()];\n this.runs.clear();\n for (const run of runs) await run.stop();\n }\n\n private async stopChild(child: PtyProcess, name: string): Promise<boolean> {\n this.runs.delete(name);\n if (!this.processControl.isAlive(child.pid)) return false;\n\n child.kill('SIGTERM');\n const deadline = this.clock.now() + TERM_GRACE_MS;\n while (this.clock.now() < deadline) {\n if (!this.processControl.isAlive(child.pid)) return true;\n await new Promise<void>((resolve) => {\n this.clock.after(LIVENESS_POLL_MS, resolve);\n });\n }\n child.kill('SIGKILL');\n return true;\n }\n}\n\n/** The visible rows, trimmed of trailing blanks, as plain text. */\nfunction renderScreen(terminal: Terminal): string {\n const buffer = terminal.buffer.active;\n const lines: string[] = [];\n for (let row = buffer.baseY; row < buffer.baseY + terminal.rows; row += 1) {\n lines.push(buffer.getLine(row)?.translateToString(true) ?? '');\n }\n while (lines.length > 0 && lines.at(-1) === '') lines.pop();\n return lines.join(NEWLINE);\n}\n"],"mappings":";;;;;;;;AAEA,MAAa,aAAa;AAE1B,MAAa,gBAAgB;;;;ACuB7B,MAAM,EAAE,UAAU,qBAAqBA,gBAAAA;AAEvC,IAAa,UAAb,MAAyC;CAIpB;CACA;CACA;CACA;CACA;CACA;CARnB,uBAAwB,IAAI,IAAoB;CAEhD,YACE,SACA,SACA,gBACA,OACA,cAA6E,QAAQ,KACrF,UACA;EANiB,KAAA,UAAA;EACA,KAAA,UAAA;EACA,KAAA,iBAAA;EACA,KAAA,QAAA;EACA,KAAA,cAAA;EACA,KAAA,WAAA;CAChB;CAEH,MAAM,OAAO,SAA4C;EACvD,MAAM,OAAO,QAAQ,QAAA;EACrB,MAAM,OAAO,QAAQ,QAAA;EACrB,MAAM,SAAS,KAAK,QAAQ,KAAK,QAAQ,EAAE;EAC3C,MAAM,WAAW,IAAI,iBAAiB;GAAE;GAAM;GAAM,YAAY;GAAY,kBAAkB;EAAK,CAAC;EACpG,MAAM,cAAcC,qBAAAA,kBAAkB,KAAK,aAAa,KAAK,QAAQ,IAAA;EAErE,MAAM,QAAQ,MAAM,KAAK,QAAQ,MAAM;GACrC,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACb,KAAK;IAAE,GAAG,KAAK;IAAa,GAAGC,wCAAAA;KAAwBC,gBAAAA,oBAAoB,QAAQ;GA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":["../src/constants/reconcile.ts","../src/services/reconcile/index.ts"],"sourcesContent":["export const COMPLETED_STATE = 'completed';\n","import { COMPLETED_STATE } from '../../constants/reconcile';\nimport type { ILauncher } from '../../types/launcher';\nimport type { IProcessControl } from '../../types/processControl';\nimport type { IRmuxBackend } from '../../types/rmuxBackend';\nimport type { IRunnerRegistry, RunnerRecord, RunnerTerminationIntent } from '../../types/runnerRegistry';\n\nconst MULTIPLEXER_BACKENDS = new Set(['rmux', 'tmux']);\n\ninterface ReconcileDependencies {\n registry: IRunnerRegistry;\n launcher: ILauncher;\n rmuxBackend: IRmuxBackend;\n processControl: IProcessControl;\n currentHostPid: number;\n startup: boolean;\n /** Same-host restart cleanup belongs only to this session. */\n startupSessionId?: string;\n active?: readonly RunnerRecord[];\n}\n\nexport interface RunnerReconcileResult {\n reclaimed: string[];\n errors: string[];\n}\n\nexport async function stopRunnerProcess(\n record: RunnerRecord,\n launcher: ILauncher,\n rmuxBackend: IRmuxBackend,\n termination?: { registry: IRunnerRegistry; intent: RunnerTerminationIntent },\n): Promise<boolean> {\n if (termination) await termination.registry.requestTermination(record.id, termination.intent, record.sessionId);\n const stopped =\n (MULTIPLEXER_BACKENDS.has(record.backend) && record.backendTarget\n ? await rmuxBackend.stop(record.backendTarget, record.pid)\n : false) || (await launcher.stop(record.pid));\n if (!stopped && termination) await termination.registry.requestTermination(record.id, undefined, record.sessionId);\n return stopped;\n}\n\n/** Repairs active registry entries that lost their original completion observer. */\nexport async function reconcileActiveRunners(dependencies: ReconcileDependencies): Promise<RunnerReconcileResult> {\n const result: RunnerReconcileResult = { reclaimed: [], errors: [] };\n const active = dependencies.active ?? (await dependencies.registry.list());\n for (const record of active) {\n try {\n const persisted = await dependencies.registry.get(record.id, record.sessionId);\n if (persisted?.state === COMPLETED_STATE) {\n await dependencies.registry.release(record.id, record.sessionId);\n result.reclaimed.push(record.id);\n continue;\n }\n\n const rmuxOutcome = MULTIPLEXER_BACKENDS.has(record.backend)\n ? dependencies.rmuxBackend.readOutcome(record.id, record.sessionId)\n : undefined;\n if (rmuxOutcome) {\n await dependencies.registry.complete(\n record.id,\n {\n reason:\n rmuxOutcome.reason ??\n (rmuxOutcome.signal ? 'signaled' : rmuxOutcome.code === 0 ? COMPLETED_STATE : 'failed'),\n code: rmuxOutcome.code,\n signal: rmuxOutcome.signal,\n ...(rmuxOutcome.terminationReason ? { terminationReason: rmuxOutcome.terminationReason } : {}),\n ...(rmuxOutcome.stopReason ? { stopReason: rmuxOutcome.stopReason } : {}),\n },\n record.sessionId,\n );\n result.reclaimed.push(record.id);\n continue;\n }\n\n if (!dependencies.processControl.isAlive(record.pid)) {\n await dependencies.registry.complete(\n record.id,\n { reason: 'backend_lost', code: null, signal: null },\n record.sessionId,\n );\n result.reclaimed.push(record.id);\n continue;\n }\n\n const previousRuntime =\n dependencies.startup &&\n record.hostPid === dependencies.currentHostPid &&\n record.sessionId === dependencies.startupSessionId;\n const ownerLost = !dependencies.processControl.isAlive(record.hostPid);\n if (!previousRuntime && !ownerLost) continue;\n\n const stopped = await stopRunnerProcess(record, dependencies.launcher, dependencies.rmuxBackend, {\n registry: dependencies.registry,\n intent: {\n reason: 'stopped',\n terminationReason: ownerLost ? 'owner_lost' : 'parent_session_cleanup',\n stopReason: 'owner session ended',\n },\n });\n if (!stopped && dependencies.processControl.isAlive(record.pid)) {\n result.errors.push(`Could not stop orphaned runner ${record.id}`);\n continue;\n }\n await dependencies.registry.complete(\n record.id,\n {\n reason: 'stopped',\n code: null,\n signal: 'SIGTERM',\n stopReason: 'owner session ended',\n },\n record.sessionId,\n );\n result.reclaimed.push(record.id);\n } catch (error) {\n result.errors.push(`Could not reconcile runner ${record.id}: ${String(error)}`);\n }\n }\n return result;\n}\n"],"mappings":";;ACMA,MAAM,uCAAuB,IAAI,IAAI,CAAC,QAAQ,MAAM,CAAC;AAmBrD,eAAsB,kBACpB,QACA,UACA,aACA,aACkB;CAClB,IAAI,aAAa,MAAM,YAAY,SAAS,mBAAmB,OAAO,I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Q;IAAgB,MAAM;IAAM,QAAQ;GAAK,GACnD,OAAO,SACT;GACA,OAAO,UAAU,KAAK,OAAO,EAAE;GAC/B;EACF;EAEA,MAAM,kBACJ,aAAa,WACb,OAAO,YAAY,aAAa,kBAChC,OAAO,cAAc,aAAa;EACpC,MAAM,YAAY,CAAC,aAAa,eAAe,QAAQ,OAAO,OAAO;EACrE,IAAI,CAAC,mBAAmB,CAAC,WAAW;EAUpC,IAAI,CAAC,MARiB,kBAAkB,QAAQ,aAAa,UAAU,aAAa,aAAa;GAC/F,UAAU,aAAa;GACvB,QAAQ;IACN,QAAQ;IACR,mBAAmB,YAAY,eAAe;IAC9C,YAAY;GACd;EACF,CAAC,KACe,aAAa,eAAe,QAAQ,OAAO,GAAG,GAAG;GAC/D,OAAO,OAAO,KAAK,kCAAkC,OAAO,IAAI;GAChE;EACF;EACA,MAAM,aAAa,SAAS,SAC1B,OAAO,IACP;GACE,QAAQ;GACR,MAAM;GACN,QAAQ;GACR,YAAY;EACd,GACA,OAAO,SACT;EACA,OAAO,UAAU,KAAK,OAAO,EAAE;CACjC,SAAS,OAAO;EACd,OAAO,OAAO,KAAK,8BAA8B,OAAO,GAAG,IAAI,OAAO,KAAK,GAAG;CAChF;CAEF,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile-wNYQJZF-.mjs","names":[],"sources":["../src/constants/reconcile.ts","../src/services/reconcile/index.ts"],"sourcesContent":["export const COMPLETED_STATE = 'completed';\n","import { COMPLETED_STATE } from '../../constants/reconcile';\nimport type { ILauncher } from '../../types/launcher';\nimport type { IProcessControl } from '../../types/processControl';\nimport type { IRmuxBackend } from '../../types/rmuxBackend';\nimport type { IRunnerRegistry, RunnerRecord, RunnerTerminationIntent } from '../../types/runnerRegistry';\n\nconst MULTIPLEXER_BACKENDS = new Set(['rmux', 'tmux']);\n\ninterface ReconcileDependencies {\n registry: IRunnerRegistry;\n launcher: ILauncher;\n rmuxBackend: IRmuxBackend;\n processControl: IProcessControl;\n currentHostPid: number;\n startup: boolean;\n /** Same-host restart cleanup belongs only to this session. */\n startupSessionId?: string;\n active?: readonly RunnerRecord[];\n}\n\nexport interface RunnerReconcileResult {\n reclaimed: string[];\n errors: string[];\n}\n\nexport async function stopRunnerProcess(\n record: RunnerRecord,\n launcher: ILauncher,\n rmuxBackend: IRmuxBackend,\n termination?: { registry: IRunnerRegistry; intent: RunnerTerminationIntent },\n): Promise<boolean> {\n if (termination) await termination.registry.requestTermination(record.id, termination.intent, record.sessionId);\n const stopped =\n (MULTIPLEXER_BACKENDS.has(record.backend) && record.backendTarget\n ? await rmuxBackend.stop(record.backendTarget, record.pid)\n : false) || (await launcher.stop(record.pid));\n if (!stopped && termination) await termination.registry.requestTermination(record.id, undefined, record.sessionId);\n return stopped;\n}\n\n/** Repairs active registry entries that lost their original completion observer. */\nexport async function reconcileActiveRunners(dependencies: ReconcileDependencies): Promise<RunnerReconcileResult> {\n const result: RunnerReconcileResult = { reclaimed: [], errors: [] };\n const active = dependencies.active ?? (await dependencies.registry.list());\n for (const record of active) {\n try {\n const persisted = await dependencies.registry.get(record.id, record.sessionId);\n if (persisted?.state === COMPLETED_STATE) {\n await dependencies.registry.release(record.id, record.sessionId);\n result.reclaimed.push(record.id);\n continue;\n }\n\n const rmuxOutcome = MULTIPLEXER_BACKENDS.has(record.backend)\n ? dependencies.rmuxBackend.readOutcome(record.id, record.sessionId)\n : undefined;\n if (rmuxOutcome) {\n await dependencies.registry.complete(\n record.id,\n {\n reason:\n rmuxOutcome.reason ??\n (rmuxOutcome.signal ? 'signaled' : rmuxOutcome.code === 0 ? COMPLETED_STATE : 'failed'),\n code: rmuxOutcome.code,\n signal: rmuxOutcome.signal,\n ...(rmuxOutcome.terminationReason ? { terminationReason: rmuxOutcome.terminationReason } : {}),\n ...(rmuxOutcome.stopReason ? { stopReason: rmuxOutcome.stopReason } : {}),\n },\n record.sessionId,\n );\n result.reclaimed.push(record.id);\n continue;\n }\n\n if (!dependencies.processControl.isAlive(record.pid)) {\n await dependencies.registry.complete(\n record.id,\n { reason: 'backend_lost', code: null, signal: null },\n record.sessionId,\n );\n result.reclaimed.push(record.id);\n continue;\n }\n\n const previousRuntime =\n dependencies.startup &&\n record.hostPid === dependencies.currentHostPid &&\n record.sessionId === dependencies.startupSessionId;\n const ownerLost = !dependencies.processControl.isAlive(record.hostPid);\n if (!previousRuntime && !ownerLost) continue;\n\n const stopped = await stopRunnerProcess(record, dependencies.launcher, dependencies.rmuxBackend, {\n registry: dependencies.registry,\n intent: {\n reason: 'stopped',\n terminationReason: ownerLost ? 'owner_lost' : 'parent_session_cleanup',\n stopReason: 'owner session ended',\n },\n });\n if (!stopped && dependencies.processControl.isAlive(record.pid)) {\n result.errors.push(`Could not stop orphaned runner ${record.id}`);\n continue;\n }\n await dependencies.registry.complete(\n record.id,\n {\n reason: 'stopped',\n code: null,\n signal: 'SIGTERM',\n stopReason: 'owner session ended',\n },\n record.sessionId,\n );\n result.reclaimed.push(record.id);\n } catch (error) {\n result.errors.push(`Could not reconcile runner ${record.id}: ${String(error)}`);\n }\n }\n return result;\n}\n"],"mappings":";;ACMA,MAAM,uCAAuB,IAAI,IAAI,CAAC,QAAQ,MAAM,CAAC;AAmBrD,eAAsB,kBACpB,QACA,UACA,aACA,aACkB;CAClB,IAAI,aAAa,MAAM,YAAY,SAAS,mBAAmB,OAAO,IAAI,YAAY,QAAQ,OAAO,SAAS;CAC9G,MAAM,WACH,qBAAqB,IAAI,OAAO,OAAO,KAAK,OAAO,gBAChD,MAAM,YAAY,KAAK,OAAO,eAAe,OAAO,GAAG,IACvD,UAAW,MAAM,SAAS,KAAK,OAAO,GAAG;CAC/C,IAAI,CAAC,WAAW,aAAa,MAAM,YAAY,SAAS,mBAAmB,OAAO,IAAI,KAAA,GAAW,OAAO,SAAS;CACjH,OAAO;AACT;;AAGA,eAAsB,uBAAuB,cAAqE;CAChH,MAAM,SAAgC;EAAE,WAAW,CAAC;EAAG,QAAQ,CA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AQ;IACR,mBAAmB,YAAY,eAAe;IAC9C,YAAY;GACd;EACF,CAAC,KACe,aAAa,eAAe,QAAQ,OAAO,GAAG,GAAG;GAC/D,OAAO,OAAO,KAAK,kCAAkC,OAAO,IAAI;GAChE;EACF;EACA,MAAM,aAAa,SAAS,SAC1B,OAAO,IACP;GACE,QAAQ;GACR,MAAM;GACN,QAAQ;GACR,YAAY;EACd,GACA,OAAO,SACT;EACA,OAAO,UAAU,KAAK,OAAO,EAAE;CACjC,SAAS,OAAO;EACd,OAAO,OAAO,KAAK,8BAA8B,OAAO,GAAG,IAAI,OAAO,KAAK,GAAG;CAChF;CAEF,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rmuxBackend-CaEWooWn.d.mts","names":[],"sources":["../src/types/rmuxBackend.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;;EAEf,OAAO,SAAS,oBAAoB,QAAQ;;EAE5C,MAAM,YAAY,gBAAgB,qBAAqB,QAAQ;;EAE/D,YAAY,YAAY,oBAAoB;EAC5C,KAAK,gBAAgB,sBAAsB;EAC3C,MAAM,gBAAgB,eAAe;;;;;;;;;;EAUrC,QAAQ,iBAAiB;EACzB,IAAI,eAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rmuxBackend-Dh0CYVAL.cjs","names":["runtimeEntry","getResultMaxBytes","readExitMetadata","RMUX","supervisorPaths","path","shellJoin","getLogMaxBytes","createRequire","fs","createHash","noninteractiveEnvironment","NO_TERMINAL_INPUT_ENV","watchForFile"],"sources":["../src/constants/rmuxBackend.ts","../src/services/rmuxBackend/index.ts"],"sourcesContent":["export const RMUX_BINARY_ENV = 'PO_RMUX_BINARY';\nexport const POLL_MS = 100;\nexport const LOG_DRAIN_TIMEOUT_MS = 2_000;\n/**\n * Fallback interval for a missed log-completion event or a lost session.\n * The retained pane lets the sink write its marker before session cleanup.\n */\nexport const LOG_DRAIN_POLL_MS = 25;\nexport const PANE_STATE_FORMAT = '#{pane_dead}:#{pane_dead_status}:#{session_name}';\nexport const PANE_PID_FORMAT = '#{pane_pid}';\nexport const STOP_GRACE_MS = 3_000;\nexport const STOP_CLOSE_TIMEOUT_MS = 1_000;\nexport const EXECUTABLE_MODE = 0o755;\n/** The owner, group, and other execute bits, so an already runnable file is left alone. */\nexport const EXECUTABLE_BITS = 0o111;\nexport const VENDOR_DIRECTORY = 'vendor';\nexport const SESSION_PREFIX = 'po-runner-';\nexport const OWNED_TARGET_PATTERN = /^po-runner-[A-Za-z0-9_-]+$/;\nexport const SOCKET_HASH_LENGTH = 12;\nexport const NON_INTERACTIVE_ENV = { NO_COLOR: '1', CI: '1' };\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { type Pane, RMUX, type Rmux } from '@rmux/sdk';\n\nimport {\n EXECUTABLE_BITS,\n EXECUTABLE_MODE,\n LOG_DRAIN_POLL_MS,\n LOG_DRAIN_TIMEOUT_MS,\n NON_INTERACTIVE_ENV,\n OWNED_TARGET_PATTERN,\n PANE_PID_FORMAT,\n PANE_STATE_FORMAT,\n POLL_MS,\n RMUX_BINARY_ENV,\n SESSION_PREFIX,\n SOCKET_HASH_LENGTH,\n STOP_CLOSE_TIMEOUT_MS,\n STOP_GRACE_MS,\n VENDOR_DIRECTORY,\n} from '../../constants/rmuxBackend';\nimport type { RunHandle } from '../../types/launcher';\nimport type { PtyRun } from '../../types/ptyHost';\nimport type { IRmuxBackend, RmuxLaunchRequest } from '../../types/rmuxBackend';\nimport type { RunnerSettings } from '../../types/runnerSettings';\nimport type { ExitResult } from '../../types/spawner';\nimport { getLogMaxBytes, getResultMaxBytes, noninteractiveEnvironment } from '../runnerConfig';\nimport type { IRunnerPaths } from '../runnerPaths/type';\nimport {\n cleanupSupervisorFiles,\n type CommandSpec,\n NO_TERMINAL_INPUT_ENV,\n readExitMetadata,\n runtimeEntry,\n shellJoin,\n type SupervisorPaths,\n supervisorPaths,\n watchForFile,\n writeCommandSpec,\n} from '../runnerSupervisor';\n\n/** Pane liveness, its exit status, and whether the session still exists, in one read. */\nconst PACKAGE_BY_PLATFORM: Readonly<Record<string, string>> = {\n 'darwin-arm64': '@agimon-ai/po-runner-rmux-darwin-arm64',\n 'darwin-x64': '@agimon-ai/po-runner-rmux-darwin-x64',\n 'linux-arm64': '@agimon-ai/po-runner-rmux-linux-arm64',\n 'linux-x64': '@agimon-ai/po-runner-rmux-linux-x64',\n};\n\nexport class RmuxBackend implements IRmuxBackend {\n private clientPromise: Promise<Rmux | undefined> | undefined;\n private readonly runs = new Map<string, PtyRun>();\n private readonly completions = new Map<string, Promise<ExitResult>>();\n\n constructor(\n private readonly paths: IRunnerPaths,\n private readonly env: Readonly<Record<string, string | undefined>> = process.env,\n private readonly settings?: RunnerSettings,\n ) {}\n\n async launch(request: RmuxLaunchRequest): Promise<RunHandle | undefined> {\n const rmux = await this.client();\n if (!rmux) return undefined;\n\n this.paths.ensureDirectories();\n const target = `${SESSION_PREFIX}${request.id}`;\n const logPath = this.paths.logPathFor(request.id);\n const aux = this.auxPaths(request.id, request.sessionId);\n let created = false;\n let released = false;\n\n try {\n this.prepareFiles(request, logPath, aux);\n // `-P -F` reports the pane pid from the call that creates the pane, so the\n // launch does not spend a second round trip asking for it.\n const opened = await rmux.cmd(\n 'new-session',\n '-d',\n '-P',\n '-F',\n PANE_PID_FORMAT,\n '-s',\n target,\n '-c',\n request.cwd,\n process.execPath,\n runtimeEntry('runnerHost'),\n aux.spec,\n aux.gate,\n aux.exit,\n { check: true },\n );\n created = true;\n // Keep the pane until the log reader drains. Otherwise a fast shell can\n // end the session before the reader starts, losing its final output.\n await rmux.cmd('set-option', '-t', target, 'remain-on-exit', 'on', { check: true });\n await rmux.cmd('pipe-pane', '-t', target, this.logPipeCommand(logPath, aux.logDone, request), { check: true });\n\n const pane = rmux.session(target).pane(0, 0);\n const pid = reportedPid(String(opened.stdout ?? '')) ?? (await panePid(rmux, target));\n fs.writeFileSync(aux.gate, '', { mode: 0o600 });\n released = true;\n\n let buffering = true;\n const completion = this.monitor(rmux, pane, target, aux);\n this.trackCompletion(target, completion);\n const stop = (): Promise<boolean> => this.stop(target, pid);\n const handle: RunHandle = {\n id: request.id,\n name: request.name,\n pid,\n logPath,\n backend: 'rmux',\n backendTarget: target,\n output: () => (buffering ? readTail(logPath, getResultMaxBytes(this.env, this.settings) * 2) : ''),\n completion: () => completion,\n detach: () => {\n buffering = false;\n },\n stop,\n };\n\n if (request.interactive) this.runs.set(request.name, this.interactiveRun(handle, pane, completion));\n void completion\n .finally(() => this.runs.delete(request.name))\n .catch((error: unknown) => process.emitWarning(`RMUX completion failed for ${target}: ${errorMessage(error)}`));\n return handle;\n } catch (error) {\n if (released) throw error;\n if (created) {\n await rmux\n .session(target)\n .kill()\n .catch((cleanupError: unknown) =>\n process.emitWarning(`Could not clean up failed RMUX launch ${target}: ${errorMessage(cleanupError)}`),\n );\n }\n cleanupSupervisorFiles(aux);\n process.emitWarning(\n request.interactive\n ? `RMUX launch unavailable for interactive runner: ${errorMessage(error)}`\n : `RMUX launch unavailable, using supervised subprocess: ${errorMessage(error)}`,\n );\n return undefined;\n }\n }\n\n async stop(target: string, expectedPid: number): Promise<boolean> {\n if (!OWNED_TARGET_PATTERN.test(target) || !Number.isInteger(expectedPid) || expectedPid <= 0) return false;\n\n const rmux = await this.client();\n if (!rmux) return false;\n try {\n // A session that already ended took its process group with it.\n if (await sessionMissing(rmux, target)) return true;\n\n const pid = await panePid(rmux, target);\n if (pid !== expectedPid) return false;\n const signalled = signalPane(pid, target);\n if (signalled === 'gone') return true;\n if (signalled === 'failed') return false;\n\n if (await waitForPaneStop(rmux, target, STOP_GRACE_MS)) return true;\n if (await sessionMissing(rmux, target)) return true;\n\n // Revalidate after the grace period so a replacement pane is never closed.\n const currentPid = await panePid(rmux, target);\n if (currentPid !== expectedPid) return false;\n\n return closeOwnedSession(rmux, target);\n } catch (error) {\n process.emitWarning(`Could not stop RMUX target ${target}: ${errorMessage(error)}`);\n return false;\n }\n }\n\n async watch(id: string, target: string, sessionId?: string): Promise<ExitResult | undefined> {\n const rmux = await this.client();\n if (!rmux) return undefined;\n const pane = rmux.session(target).pane(0, 0);\n try {\n await rmux.displayMessage('#{pane_id}', { target });\n } catch (error) {\n process.emitWarning(`Could not watch RMUX target ${target}: ${errorMessage(error)}`);\n return undefined;\n }\n const completion = this.monitor(rmux, pane, target, this.auxPaths(id, sessionId));\n this.trackCompletion(target, completion);\n return completion;\n }\n\n async input(target: string, text: string): Promise<boolean> {\n const rmux = await this.client();\n if (!rmux) return false;\n const result = await rmux\n .session(target)\n .pane(0, 0)\n .sendText(text)\n .catch((error: unknown) => {\n process.emitWarning(`Could not send input to RMUX target ${target}: ${errorMessage(error)}`);\n return undefined;\n });\n return result !== undefined;\n }\n\n async capture(target: string): Promise<string | undefined> {\n const rmux = await this.client();\n if (!rmux) return undefined;\n return rmux\n .session(target)\n .pane(0, 0)\n .captureText()\n .catch((error: unknown) => {\n process.emitWarning(`Could not capture RMUX target ${target}: ${errorMessage(error)}`);\n return undefined;\n });\n }\n\n get(name: string): PtyRun | undefined {\n return this.runs.get(name);\n }\n\n readOutcome(id: string, sessionId: string): ExitResult | undefined {\n return readExitMetadata(this.auxPaths(id, sessionId).exit);\n }\n\n private trackCompletion(target: string, completion: Promise<ExitResult>): void {\n this.completions.set(target, completion);\n void completion\n .finally(() => this.completions.delete(target))\n .catch((error: unknown) => process.emitWarning(`RMUX monitor failed for ${target}: ${errorMessage(error)}`));\n }\n\n private client(): Promise<Rmux | undefined> {\n this.clientPromise ??= this.resolveClient();\n return this.clientPromise;\n }\n\n private async resolveClient(): Promise<Rmux | undefined> {\n const binaries = [resolveBundledRmuxBinary(import.meta.url, this.env), 'rmux'].filter(\n (value): value is string => value !== undefined,\n );\n for (const binary of binaries) {\n try {\n if (binary !== 'rmux') ensureExecutablePayload(binary);\n const client = new RMUX({ binary, socketName: socketName(this.paths.repositoryPath()) });\n await client.capabilities();\n return client;\n } catch (error) {\n process.emitWarning(`RMUX candidate ${binary} is unavailable: ${errorMessage(error)}`);\n // Try the next compatible candidate. Non-interactive calls can use the subprocess launcher.\n }\n }\n return undefined;\n }\n\n private prepareFiles(request: RmuxLaunchRequest, logPath: string, aux: SupervisorPaths): void {\n cleanupSupervisorFiles(aux);\n fs.writeFileSync(logPath, '', { mode: 0o600 });\n const env = environment(request.sessionId, request.interactive, this.env);\n // runnerHost supervises the command and watches the lifeline itself, so an\n // owner that dies mid-run is handled inside the pane rather than around it.\n const spec: CommandSpec = { command: request.command, cwd: request.cwd, env };\n writeCommandSpec(aux.spec, spec);\n }\n\n private auxPaths(id: string, sessionId?: string): SupervisorPaths {\n return supervisorPaths(this.paths.stateDirectory(sessionId), id);\n }\n\n /**\n * The sink the pane pipes into.\n *\n * An interactive run also asks for a raw copy: the scrubbed log it writes\n * beside it has had cursor movement taken out, which is what a terminal\n * needs most. Only interactive runs pay for it, because only they can be\n * attached to.\n */\n private logPipeCommand(logPath: string, donePath: string, request: RmuxLaunchRequest): string {\n const id = path.basename(logPath, '.log');\n return shellJoin([\n process.execPath,\n runtimeEntry('logSink'),\n logPath,\n this.paths.rotatedLogPathFor(id),\n String(getLogMaxBytes(this.env)),\n donePath,\n ...(request.interactive ? [this.paths.rawLogPathFor(id)] : []),\n ]);\n }\n\n private async monitor(rmux: Rmux, pane: Pane, target: string, aux: SupervisorPaths): Promise<ExitResult> {\n try {\n const paneCode = await waitForRunEnd(rmux, target, aux.exit);\n await waitForLogDrain(rmux, target, aux.logDone);\n return readExitMetadata(aux.exit) ?? { code: paneCode, signal: null };\n } finally {\n // The pane stays alive for log capture. Remove its session after draining,\n // allowing the last completed run to shut down the mux server too.\n let timer: ReturnType<typeof setTimeout> | undefined;\n const cleanup = async (): Promise<void> => {\n if (!(await sessionMissing(rmux, target))) await pane.server.session(target).kill();\n };\n try {\n await Promise.race([\n cleanup().catch((error: unknown) =>\n process.emitWarning(`Could not clean up completed RMUX target ${target}: ${errorMessage(error)}`),\n ),\n new Promise<void>((resolve) => {\n timer = setTimeout(() => {\n process.emitWarning(`Timed out cleaning up RMUX target ${target} after ${STOP_CLOSE_TIMEOUT_MS}ms`);\n resolve();\n }, STOP_CLOSE_TIMEOUT_MS);\n }),\n ]);\n } finally {\n if (timer) clearTimeout(timer);\n cleanupSupervisorFiles(aux);\n }\n }\n }\n\n private interactiveRun(handle: RunHandle, pane: Pane, completion: Promise<ExitResult>): PtyRun {\n let screen = '';\n let active = true;\n const handlers = new Set<(data: string) => void>();\n const refresh = async (): Promise<void> => {\n while (active) {\n const next = await pane.captureText().catch((error: unknown) => {\n process.emitWarning(`Could not capture RMUX screen for ${handle.name}: ${errorMessage(error)}`);\n return screen;\n });\n if (next !== screen) {\n screen = next;\n for (const handler of handlers) handler(next);\n }\n await delay(POLL_MS);\n }\n };\n void refresh();\n void completion\n .finally(() => {\n active = false;\n })\n .catch((error: unknown) =>\n process.emitWarning(`RMUX interactive completion failed for ${handle.name}: ${errorMessage(error)}`),\n );\n return {\n ...handle,\n write: (text) => {\n void pane.sendText(text).catch((error: unknown) => process.emitWarning(errorMessage(error)));\n },\n screen: () => screen,\n onData: (handler) => {\n handlers.add(handler);\n return () => handlers.delete(handler);\n },\n resize: (cols, rows) => {\n void pane\n .resize({ width: cols, height: rows })\n .catch((error: unknown) => process.emitWarning(errorMessage(error)));\n },\n };\n }\n}\n\nexport function rmuxPackageForTarget(platform: string, architecture: string): string | undefined {\n const target = `${platform}-${architecture}`;\n const packageName = PACKAGE_BY_PLATFORM[target];\n if (!packageName) process.emitWarning(`Bundled RMUX binary is unavailable for unsupported target ${target}`);\n return packageName;\n}\n\nexport function resolveBundledRmuxBinary(\n moduleUrl = import.meta.url,\n env: Readonly<Record<string, string | undefined>> = process.env,\n): string | undefined {\n const configured = env[RMUX_BINARY_ENV];\n if (configured !== undefined && configured !== '') return configured;\n const packageName = rmuxPackageForTarget(process.platform, process.arch);\n if (!packageName) return undefined;\n try {\n const require = createRequire(moduleUrl);\n const manifest = require.resolve(`${packageName}/package.json`);\n return path.join(path.dirname(manifest), VENDOR_DIRECTORY, 'bin', 'rmux');\n } catch (error) {\n process.emitWarning(`Bundled RMUX binary is unavailable for ${packageName}: ${errorMessage(error)}`);\n return undefined;\n }\n}\n\n/**\n * Make the bundled payload runnable before the launcher is spawned.\n *\n * The prebuilt packages reach npm with plain 0644 files, so the executable bit\n * the build set is not what lands on a user machine. Restoring it on the one\n * binary we spawn is not enough: rmux execs two files of its own,\n * `bin/rmux-daemon` and `libexec/rmux/rmux`, and the launcher fails on that\n * first exec with a permission error. Every file the payload ships is restored\n * here instead, which also covers a helper a later rmux release adds.\n *\n * A configured override (PO_RMUX_BINARY) usually points at a stand-alone\n * binary, so only paths that really sit inside a package vendor tree get the\n * walk. Files that are already executable are left untouched, since chmod on a\n * binary owned by someone else would throw and drop an otherwise usable\n * candidate.\n */\nexport function ensureExecutablePayload(binary: string): void {\n const vendor = path.resolve(path.dirname(binary), '..');\n const payload =\n path.basename(vendor) === VENDOR_DIRECTORY\n ? fs\n .readdirSync(vendor, { recursive: true, withFileTypes: true })\n .filter((entry) => entry.isFile())\n .map((entry) => path.join(entry.parentPath, entry.name))\n : [binary];\n for (const file of payload) {\n if ((fs.statSync(file).mode & EXECUTABLE_BITS) === 0) fs.chmodSync(file, EXECUTABLE_MODE);\n }\n}\n\nfunction socketName(repositoryPath: string): string {\n const hash = createHash('sha256').update(repositoryPath).digest('hex').slice(0, SOCKET_HASH_LENGTH);\n return `${SESSION_PREFIX}${hash}`;\n}\n\nfunction environment(\n sessionId: string,\n interactive: boolean,\n env: Readonly<Record<string, string | undefined>>,\n): Record<string, string> {\n const values: NodeJS.ProcessEnv = {\n ...env,\n ...(interactive ? {} : { ...NON_INTERACTIVE_ENV, ...noninteractiveEnvironment(env) }),\n // Applied to interactive runs as well: a pane is a tty either way, and an\n // agent sending input to a prompt still has no way past a pager.\n ...NO_TERMINAL_INPUT_ENV,\n PI_SESSION_ID: sessionId,\n };\n if (!interactive) delete values['FORCE_COLOR'];\n return Object.fromEntries(\n Object.entries(values).filter((entry): entry is [string, string] => entry[1] !== undefined),\n );\n}\n\nasync function panePid(rmux: Rmux, target: string): Promise<number> {\n const response = await rmux.displayMessage(PANE_PID_FORMAT, { target });\n const message = typeof response['message'] === 'string' ? response['message'] : '';\n const pid = reportedPid(message);\n if (pid === undefined) throw new Error(`RMUX did not report a pane pid for ${target}`);\n return pid;\n}\n\n/** A pane pid as rmux prints it, or nothing when the output holds no usable pid. */\nfunction reportedPid(output: string): number | undefined {\n const pid = Number(output.trim());\n return Number.isInteger(pid) && pid > 0 ? pid : undefined;\n}\n\n/**\n * Waits for the run to end, preferring the supervisor's own record of it.\n *\n * The sidecar is written before the command's pane can end, and it outlives the\n * server that the pane's exit takes down with it. Watching for it means a run\n * that finishes inside a poll interval is observed when it finishes rather than\n * on the next tick. Asking the server stays the fallback for a supervisor that\n * died without recording anything.\n */\nasync function waitForRunEnd(rmux: Rmux, target: string, exitPath: string): Promise<number | null> {\n const landed = watchForFile(exitPath);\n let active = true;\n const readEvidence = async (): Promise<null> => {\n while (active) {\n if (await landed.appeared(POLL_MS)) return null;\n }\n return null;\n };\n const probePane = async (): Promise<number | null> => {\n while (active) {\n await delay(POLL_MS);\n if (!active) return null;\n const state = await readPaneExit(rmux, target);\n if (state.exited) return state.code;\n }\n return null;\n };\n try {\n // A stalled SDK request must not block the supervisor's durable evidence.\n // Keep only one pane request in flight, even when it never answers.\n return await Promise.race([readEvidence(), probePane()]);\n } finally {\n active = false;\n landed.close();\n }\n}\n\n/**\n * Gives the log sink a moment to mark the log complete.\n *\n * Normal completion retains the session until the sink records its final\n * writes. A lost session cannot guarantee a later marker, so it ends the wait.\n */\nasync function waitForLogDrain(rmux: Rmux, target: string, donePath: string): Promise<void> {\n const deadline = Date.now() + LOG_DRAIN_TIMEOUT_MS;\n const landed = watchForFile(donePath);\n let active = true;\n const readEvidence = async (): Promise<void> => {\n while (active && Date.now() < deadline) {\n if (await landed.appeared(LOG_DRAIN_POLL_MS)) return;\n }\n };\n const probeSession = async (): Promise<void> => {\n while (active && Date.now() < deadline) {\n await delay(LOG_DRAIN_POLL_MS);\n if (!active) return;\n if (await sessionMissing(rmux, target)) return;\n }\n };\n try {\n // The file loop enforces the deadline while a session query is outstanding.\n await Promise.race([readEvidence(), probeSession()]);\n } finally {\n active = false;\n landed.close();\n }\n}\n\nasync function closeOwnedSession(rmux: Rmux, target: string): Promise<boolean> {\n return new Promise((resolve) => {\n let settled = false;\n const finish = (result: boolean): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(result);\n };\n const timer = setTimeout(() => {\n process.emitWarning(`Timed out closing RMUX target ${target} after ${STOP_CLOSE_TIMEOUT_MS}ms`);\n finish(false);\n }, STOP_CLOSE_TIMEOUT_MS);\n void rmux\n .session(target)\n .kill()\n .then(\n () => finish(true),\n (error: unknown) => {\n process.emitWarning(`Could not close RMUX target ${target}: ${errorMessage(error)}`);\n finish(false);\n },\n );\n });\n}\n\nasync function waitForPaneStop(rmux: Rmux, target: string, timeoutMs: number): Promise<boolean> {\n const deadline = Date.now() + timeoutMs;\n while (Date.now() < deadline) {\n try {\n if ((await readPaneExit(rmux, target)).exited) return true;\n } catch (error) {\n process.emitWarning(`Could not verify RMUX target ${target} stopped: ${errorMessage(error)}`);\n return false;\n }\n await delay(POLL_MS);\n }\n return false;\n}\n\n/**\n * One formatted read answers both questions this poll asks, so watching a run\n * costs the same single rmux call it always did.\n */\nasync function readPaneExit(rmux: Rmux, target: string): Promise<{ exited: boolean; code: number | null }> {\n let message: string;\n try {\n const response = await rmux.displayMessage(PANE_STATE_FORMAT, { target });\n message = typeof response['message'] === 'string' ? response['message'] : '';\n } catch {\n // The last session ending stops the server, so a server that cannot be\n // reached is the ordinary end of the last run rather than a fault.\n return { exited: true, code: null };\n }\n const [dead, status, ...rest] = message.trim().split(':');\n // A missing session formats as a live pane with no name rather than failing,\n // so the name is what says whether there is still anything to watch.\n if (rest.join(':') === '') return { exited: true, code: null };\n if (dead === '1' || dead === 'true') {\n const code = Number(status);\n return { exited: true, code: Number.isInteger(code) ? code : null };\n }\n return { exited: false, code: null };\n}\n\n/** A session that cannot be found, on a server that may itself be gone. */\nasync function sessionMissing(rmux: Rmux, target: string): Promise<boolean> {\n try {\n const probe = await rmux.cmd('has-session', '-t', target);\n return probe.returnCode !== 0;\n } catch {\n // No server to ask means no session to find.\n return true;\n }\n}\n\n/**\n * A pane that was already gone and a signal that could not be delivered are\n * opposite answers to \"is it stopped\", so they are reported apart.\n */\nfunction signalPane(pid: number, target: string): 'signalled' | 'gone' | 'failed' {\n try {\n process.kill(pid, 'SIGTERM');\n return 'signalled';\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ESRCH') return 'gone';\n process.emitWarning(`Could not signal RMUX target ${target}: ${errorMessage(error)}`);\n return 'failed';\n }\n}\n\nfunction readTail(target: string, maxBytes: number): string {\n let handle: number | undefined;\n try {\n const size = fs.statSync(target).size;\n const bytes = Math.min(size, maxBytes);\n const buffer = Buffer.alloc(bytes);\n handle = fs.openSync(target, 'r');\n fs.readSync(handle, buffer, 0, bytes, size - bytes);\n return buffer.toString('utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n process.emitWarning(`Could not read RMUX log ${target}: ${errorMessage(error)}`);\n }\n return '';\n } finally {\n if (handle !== undefined) fs.closeSync(handle);\n }\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => {\n const timer = setTimeout(resolve, ms);\n timer.unref?.();\n });\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;;;;;;;;;AAAA,MAAa,kBAAkB;AAE/B,MAAa,uBAAuB;AAMpC,MAAa,oBAAoB;AACjC,MAAa,kBAAkB;AAE/B,MAAa,wBAAwB;AAIrC,MAAa,mBAAmB;AAChC,MAAa,iBAAiB;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