@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
|
@@ -5,6 +5,8 @@ let node_crypto = require("node:crypto");
|
|
|
5
5
|
const COMPLETED = "completed";
|
|
6
6
|
const FAILED = "failed";
|
|
7
7
|
const LAUNCHER_ERROR = "launcher_error";
|
|
8
|
+
/** An interactive launch found neither multiplexer. */
|
|
9
|
+
const TERMINAL_UNAVAILABLE = "A terminal needs rmux or tmux, and neither is available on this machine.";
|
|
8
10
|
//#endregion
|
|
9
11
|
//#region src/services/bashRunService/resources.ts
|
|
10
12
|
/** Split shell words without mistaking quoted examples for executed commands. */
|
|
@@ -106,28 +108,32 @@ var BashRunService = class {
|
|
|
106
108
|
this.executionBudget = executionBudget;
|
|
107
109
|
}
|
|
108
110
|
async run(request) {
|
|
111
|
+
if (request.env && request.backend !== "native") throw new Error("Environment overrides require the native launcher.");
|
|
112
|
+
if (request.backend === "native" && (request.interactive || request.preferInteractive)) throw new Error("Native package launches are noninteractive.");
|
|
109
113
|
const id = runnerId();
|
|
110
114
|
const name = await this.namer.allocate(request.command, request.sessionId, request.name);
|
|
111
115
|
const cwd = request.cwd ?? this.cwd;
|
|
112
|
-
|
|
116
|
+
let interactive = request.interactive === true;
|
|
117
|
+
const wantsPane = interactive || request.preferInteractive === true;
|
|
113
118
|
if (request.signal?.aborted) return {
|
|
114
119
|
kind: FAILED,
|
|
115
120
|
id,
|
|
116
121
|
name,
|
|
117
|
-
error: "Operation aborted"
|
|
122
|
+
error: "Operation aborted",
|
|
123
|
+
reason: "cancelled"
|
|
118
124
|
};
|
|
119
125
|
let handle;
|
|
120
126
|
let releaseSlot;
|
|
121
127
|
try {
|
|
122
128
|
if (this.executionBudget && isHeavyCommand(request.command)) releaseSlot = await this.executionBudget.acquire(request.signal);
|
|
123
129
|
request.signal?.throwIfAborted();
|
|
124
|
-
const rmuxHandle = await this.rmuxBackend.launch({
|
|
130
|
+
const rmuxHandle = request.backend === "native" ? void 0 : await this.rmuxBackend.launch({
|
|
125
131
|
id,
|
|
126
132
|
name,
|
|
127
133
|
command: request.command,
|
|
128
134
|
cwd,
|
|
129
135
|
sessionId: request.sessionId,
|
|
130
|
-
interactive
|
|
136
|
+
interactive: wantsPane
|
|
131
137
|
});
|
|
132
138
|
if (interactive && !rmuxHandle) {
|
|
133
139
|
releaseSlot?.();
|
|
@@ -135,15 +141,18 @@ var BashRunService = class {
|
|
|
135
141
|
kind: FAILED,
|
|
136
142
|
id,
|
|
137
143
|
name,
|
|
138
|
-
error:
|
|
144
|
+
error: TERMINAL_UNAVAILABLE,
|
|
145
|
+
reason: "launch_failed"
|
|
139
146
|
};
|
|
140
147
|
}
|
|
141
|
-
|
|
148
|
+
interactive = wantsPane && rmuxHandle !== void 0;
|
|
149
|
+
handle = rmuxHandle ?? await this.launcher.launch({
|
|
142
150
|
id,
|
|
143
151
|
name,
|
|
144
152
|
command: request.command,
|
|
145
153
|
cwd,
|
|
146
|
-
sessionId: request.sessionId
|
|
154
|
+
sessionId: request.sessionId,
|
|
155
|
+
...request.env ? { env: request.env } : {}
|
|
147
156
|
});
|
|
148
157
|
} catch (error) {
|
|
149
158
|
releaseSlot?.();
|
|
@@ -151,7 +160,8 @@ var BashRunService = class {
|
|
|
151
160
|
kind: FAILED,
|
|
152
161
|
id,
|
|
153
162
|
name,
|
|
154
|
-
error: error instanceof Error ? error.message : String(error)
|
|
163
|
+
error: error instanceof Error ? error.message : String(error),
|
|
164
|
+
reason: request.signal?.aborted ? "cancelled" : "launch_failed"
|
|
155
165
|
};
|
|
156
166
|
}
|
|
157
167
|
if (handle.pid === void 0) {
|
|
@@ -160,7 +170,8 @@ var BashRunService = class {
|
|
|
160
170
|
kind: FAILED,
|
|
161
171
|
id,
|
|
162
172
|
name,
|
|
163
|
-
error: "The command did not start, so it cannot be supervised"
|
|
173
|
+
error: "The command did not start, so it cannot be supervised",
|
|
174
|
+
reason: "launch_failed"
|
|
164
175
|
};
|
|
165
176
|
}
|
|
166
177
|
if (releaseSlot) handle.completion().then(releaseSlot, releaseSlot);
|
|
@@ -177,13 +188,19 @@ var BashRunService = class {
|
|
|
177
188
|
backend: handle.backend,
|
|
178
189
|
...handle.backendTarget ? { backendTarget: handle.backendTarget } : {}
|
|
179
190
|
});
|
|
191
|
+
await request.onStarted?.({
|
|
192
|
+
id,
|
|
193
|
+
name,
|
|
194
|
+
logPath: handle.logPath
|
|
195
|
+
});
|
|
180
196
|
} catch (error) {
|
|
181
197
|
await handle.stop();
|
|
182
198
|
return {
|
|
183
199
|
kind: FAILED,
|
|
184
200
|
id,
|
|
185
201
|
name,
|
|
186
|
-
error: error instanceof Error ? error.message : String(error)
|
|
202
|
+
error: error instanceof Error ? error.message : String(error),
|
|
203
|
+
reason: "supervision_failed"
|
|
187
204
|
};
|
|
188
205
|
}
|
|
189
206
|
if (releaseSlot) try {
|
|
@@ -199,7 +216,8 @@ var BashRunService = class {
|
|
|
199
216
|
kind: FAILED,
|
|
200
217
|
id,
|
|
201
218
|
name,
|
|
202
|
-
error: error instanceof Error ? error.message : String(error)
|
|
219
|
+
error: error instanceof Error ? error.message : String(error),
|
|
220
|
+
reason: "supervision_failed"
|
|
203
221
|
};
|
|
204
222
|
}
|
|
205
223
|
if (request.signal?.aborted) {
|
|
@@ -213,22 +231,23 @@ var BashRunService = class {
|
|
|
213
231
|
kind: FAILED,
|
|
214
232
|
id,
|
|
215
233
|
name,
|
|
216
|
-
error: "Operation aborted"
|
|
234
|
+
error: "Operation aborted",
|
|
235
|
+
reason: "cancelled"
|
|
217
236
|
};
|
|
218
237
|
}
|
|
219
|
-
if (request.background === true || interactive) return this.promote(handle, request.background === true ? "requested" : "interactive", request.signal);
|
|
238
|
+
if (request.waitForExit !== true && (request.background === true || interactive)) return this.promote(handle, request.background === true ? "requested" : "interactive", request.signal);
|
|
220
239
|
const outputUpdates = request.onOutput ? this.followOutput(handle, request.onOutput) : void 0;
|
|
221
240
|
try {
|
|
222
|
-
const outcome = await this.race(handle, request.timeoutMs, request.signal);
|
|
223
|
-
outputUpdates?.flush();
|
|
241
|
+
const outcome = await this.race(handle, request.timeoutMs, request.signal, request.waitForExit !== true);
|
|
242
|
+
await outputUpdates?.flush();
|
|
224
243
|
if (outcome === TIMED_OUT) return this.promote(handle, "threshold", request.signal);
|
|
225
244
|
if (outcome === ABORTED) {
|
|
226
245
|
await this.registry.requestTermination(id, {
|
|
227
246
|
reason: "stopped",
|
|
228
247
|
terminationReason: "request_cancelled"
|
|
229
248
|
});
|
|
230
|
-
await handle.stop();
|
|
231
|
-
outputUpdates?.flush();
|
|
249
|
+
if (!await handle.stop() && request.waitForExit) return this.promote(handle, "requested", void 0);
|
|
250
|
+
await outputUpdates?.flush();
|
|
232
251
|
await this.registry.complete(id, {
|
|
233
252
|
reason: "stopped",
|
|
234
253
|
code: null,
|
|
@@ -238,7 +257,7 @@ var BashRunService = class {
|
|
|
238
257
|
kind: COMPLETED,
|
|
239
258
|
id,
|
|
240
259
|
name,
|
|
241
|
-
output: handle.output(),
|
|
260
|
+
output: await handle.output(),
|
|
242
261
|
exitCode: null,
|
|
243
262
|
signal: "SIGTERM",
|
|
244
263
|
logPath: handle.logPath,
|
|
@@ -251,8 +270,8 @@ var BashRunService = class {
|
|
|
251
270
|
reason: "timed_out",
|
|
252
271
|
terminationReason: "timeout"
|
|
253
272
|
});
|
|
254
|
-
await handle.stop();
|
|
255
|
-
outputUpdates?.flush();
|
|
273
|
+
if (!await handle.stop() && request.waitForExit) return this.promote(handle, "requested", void 0);
|
|
274
|
+
await outputUpdates?.flush();
|
|
256
275
|
await this.registry.complete(id, {
|
|
257
276
|
reason: "timed_out",
|
|
258
277
|
code: null,
|
|
@@ -262,7 +281,7 @@ var BashRunService = class {
|
|
|
262
281
|
kind: COMPLETED,
|
|
263
282
|
id,
|
|
264
283
|
name,
|
|
265
|
-
output: handle.output(),
|
|
284
|
+
output: await handle.output(),
|
|
266
285
|
exitCode: null,
|
|
267
286
|
signal: "SIGTERM",
|
|
268
287
|
logPath: handle.logPath,
|
|
@@ -280,7 +299,8 @@ var BashRunService = class {
|
|
|
280
299
|
kind: FAILED,
|
|
281
300
|
id,
|
|
282
301
|
name,
|
|
283
|
-
error: outcome.message
|
|
302
|
+
error: outcome.message,
|
|
303
|
+
reason: "supervision_failed"
|
|
284
304
|
};
|
|
285
305
|
}
|
|
286
306
|
await this.registry.complete(id, {
|
|
@@ -294,7 +314,7 @@ var BashRunService = class {
|
|
|
294
314
|
kind: COMPLETED,
|
|
295
315
|
id,
|
|
296
316
|
name,
|
|
297
|
-
output: handle.output(),
|
|
317
|
+
output: await handle.output(),
|
|
298
318
|
exitCode: outcome.code,
|
|
299
319
|
signal: outcome.signal,
|
|
300
320
|
logPath: handle.logPath,
|
|
@@ -322,16 +342,16 @@ var BashRunService = class {
|
|
|
322
342
|
let active = true;
|
|
323
343
|
let previous = "";
|
|
324
344
|
let cancelPoll;
|
|
325
|
-
const flush = () => {
|
|
345
|
+
const flush = async () => {
|
|
326
346
|
if (!active) return;
|
|
327
|
-
const output = handle.output();
|
|
347
|
+
const output = await handle.output();
|
|
328
348
|
if (output === previous) return;
|
|
329
349
|
previous = output;
|
|
330
350
|
onOutput(output);
|
|
331
351
|
};
|
|
332
|
-
const poll = () => {
|
|
352
|
+
const poll = async () => {
|
|
333
353
|
if (!active) return;
|
|
334
|
-
flush();
|
|
354
|
+
await flush();
|
|
335
355
|
if (active) cancelPoll = this.clock.after(100, poll);
|
|
336
356
|
};
|
|
337
357
|
cancelPoll = this.clock.after(100, poll);
|
|
@@ -351,10 +371,10 @@ var BashRunService = class {
|
|
|
351
371
|
* A rejected completion is returned rather than thrown so the caller can
|
|
352
372
|
* report a start failure as a tool result instead of an exception.
|
|
353
373
|
*/
|
|
354
|
-
async race(handle, timeoutMs, signal) {
|
|
374
|
+
async race(handle, timeoutMs, signal, promoteAtThreshold = true) {
|
|
355
375
|
const cancels = [];
|
|
356
376
|
const racers = [handle.completion().catch((error) => error)];
|
|
357
|
-
racers.push(new Promise((resolve) => {
|
|
377
|
+
if (promoteAtThreshold) racers.push(new Promise((resolve) => {
|
|
358
378
|
cancels.push(this.clock.after(require_runnerConfig.getBackgroundThresholdMs(this.env), () => resolve(TIMED_OUT)));
|
|
359
379
|
}));
|
|
360
380
|
if (timeoutMs !== void 0 && timeoutMs > 0) racers.push(new Promise((resolve) => {
|
|
@@ -380,7 +400,8 @@ var BashRunService = class {
|
|
|
380
400
|
kind: FAILED,
|
|
381
401
|
id: handle.id,
|
|
382
402
|
name: handle.name,
|
|
383
|
-
error: "The command did not start"
|
|
403
|
+
error: "The command did not start",
|
|
404
|
+
reason: "launch_failed"
|
|
384
405
|
};
|
|
385
406
|
await this.registry.markPromoted(handle.id);
|
|
386
407
|
handle.detach();
|
|
@@ -442,4 +463,4 @@ Object.defineProperty(exports, "BashRunService", {
|
|
|
442
463
|
}
|
|
443
464
|
});
|
|
444
465
|
|
|
445
|
-
//# sourceMappingURL=bashRunService-
|
|
466
|
+
//# sourceMappingURL=bashRunService-DmuA1mKL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bashRunService-DmuA1mKL.cjs","names":["randomBytes","RTK_FAILED_WARNING","getBackgroundThresholdMs"],"sources":["../src/constants/bashRunService.ts","../src/services/bashRunService/resources.ts","../src/services/bashRunService/index.ts"],"sourcesContent":["export const RUNNER_ID_RANDOM_BYTES = 3;\nexport const OUTPUT_UPDATE_POLL_MS = 100;\nexport const COMPLETED = 'completed';\nexport const FAILED = 'failed';\nexport const LAUNCHER_ERROR = 'launcher_error';\nexport const SIGNALED = 'signaled';\n/** An interactive launch found neither multiplexer. */\nexport const TERMINAL_UNAVAILABLE = 'A terminal needs rmux or tmux, and neither is available on this machine.';\n","/** Split shell words without mistaking quoted examples for executed commands. */\nfunction commandInvocations(command: string): string[][] {\n const invocations: string[][] = [];\n let words: string[] = [];\n let word = '';\n let quote = '';\n let escaped = false;\n const flushWord = (): void => {\n if (word) words.push(word);\n word = '';\n };\n for (const character of command) {\n if (escaped) {\n word += character;\n escaped = false;\n } else if (character === '\\\\' && quote !== \"'\") {\n escaped = true;\n } else if (quote) {\n if (character === quote) quote = '';\n else word += character;\n } else if (character === '\"' || character === \"'\") {\n quote = character;\n } else if (';&|\\n'.includes(character)) {\n flushWord();\n if (words.length) invocations.push(words);\n words = [];\n } else if (/\\s/.test(character)) {\n flushWord();\n } else {\n word += character;\n }\n }\n flushWord();\n if (words.length) invocations.push(words);\n return invocations;\n}\n\nfunction executableName(word: string): string {\n return word.replace(/\\\\/g, '/').split('/').pop() ?? word;\n}\n\n/** Admission policy, not a shell security boundary. Opaque scripts still need explicit ownership. */\nexport function isHeavyCommand(command: string): boolean {\n const heavyTarget =\n /(?:^|[\\s:,=])(?:build(?:-[\\w-]+)?|test(?:-[\\w-]+)?|lint|fixcode|typecheck|check|bundle)(?:[\\s:,=]|$)/;\n const expensiveBinary =\n /^(?:vitest|jest|tsc|tsgo|tsdown|webpack|rollup|esbuild|oxlint|oxfmt|pytest|maestro|xcodebuild|gradle|gradlew)$/;\n return commandInvocations(command).some((words) => {\n while (words.length) {\n const first = words[0]!;\n if (/^[A-Za-z_][A-Za-z_0-9]*=/.test(first) || /^(?:env|command|exec|time)$/.test(executableName(first))) {\n words.shift();\n } else break;\n }\n let executable = executableName(words.shift() ?? '');\n if (words.includes('--help') || words.includes('--version')) return false;\n if (/^(?:pnpm|npm|npx|yarn|bun)$/.test(executable)) {\n while (words[0]?.startsWith('-')) {\n const option = words.shift()!;\n if (/^(?:--filter|--dir|-C|--cwd|--prefix)$/.test(option)) words.shift();\n }\n if (words[0] === 'exec' || words[0] === 'run') words.shift();\n const invocation = words.shift() ?? '';\n if (/^(?:build|test|lint|fixcode|typecheck|check)(?::[\\w-]+)?$/.test(invocation)) return true;\n executable = executableName(invocation);\n }\n if (expensiveBinary.test(executable)) return true;\n if (executable === 'nx') {\n if (/^(?:show|graph|daemon|reset|report|list)$/.test(words[0] ?? '')) return false;\n return heavyTarget.test(words.join(' '));\n }\n if (/^(?:playwright|vite|cargo|go)$/.test(executable)) return heavyTarget.test(words.join(' '));\n if (/^(?:python|python3)$/.test(executable)) return words[0] === '-m' && words[1] === 'pytest';\n if (/^(?:node|bun|tsx)$/.test(executable)) {\n executable = executableName(words.find((word) => !word.startsWith('-')) ?? '');\n }\n const script = executable.replace(/\\.(?:[cm]?[jt]s)$/, '');\n return (\n script !== executable &&\n (expensiveBinary.test(script) || /^(?:build|test|lint|fixcode|typecheck|dev)(?:[-:]|$)/.test(script))\n );\n });\n}\n","import { randomBytes } from 'node:crypto';\n\nimport type { PoHostExecutionBudget, PoHostExecutionPermit } from '@agimon-ai/po-core/packageApi';\n\nimport {\n COMPLETED,\n FAILED,\n LAUNCHER_ERROR,\n OUTPUT_UPDATE_POLL_MS,\n RUNNER_ID_RANDOM_BYTES,\n SIGNALED,\n TERMINAL_UNAVAILABLE,\n} from '../../constants/bashRunService';\nimport type {\n BashRunRequest,\n BashRunResult,\n CompletedRun,\n IBashRunService,\n PromotedRun,\n} from '../../types/bashRunService';\nimport type { IClock } from '../../types/clock';\nimport type { ILauncher, RunHandle } from '../../types/launcher';\nimport type { IRmuxBackend } from '../../types/rmuxBackend';\nimport { type IRtkProcessor, RTK_FAILED_WARNING } from '../../types/rtkProcessor';\nimport type { IRunnerRegistry } from '../../types/runnerRegistry';\nimport { getBackgroundThresholdMs } from '../runnerConfig';\nimport type { IRunnerNamer } from '../runnerNamer/type';\nimport { isHeavyCommand } from './resources';\n\n/** The command outlived the background threshold and should be promoted. */\nconst TIMED_OUT = Symbol('threshold-reached');\n/** The command outlived the caller's explicit timeout and should be stopped. */\nconst DEADLINE = Symbol('deadline-reached');\n/** The caller cancelled the command and its owned runner should be stopped. */\nconst ABORTED = Symbol('aborted');\n\nfunction runnerId(): string {\n const timestamp = Date.now().toString(36);\n const random = randomBytes(RUNNER_ID_RANDOM_BYTES).toString('base64url');\n return `${timestamp}-${random}`;\n}\n\nexport class BashRunService implements IBashRunService {\n constructor(\n private readonly launcher: ILauncher,\n private readonly rmuxBackend: IRmuxBackend,\n private readonly namer: IRunnerNamer,\n private readonly registry: IRunnerRegistry,\n private readonly clock: IClock,\n private readonly rtkProcessor: IRtkProcessor,\n private readonly cwd: string = process.cwd(),\n private readonly env: Readonly<Record<string, string | undefined>> = process.env,\n private readonly executionBudget?: PoHostExecutionBudget,\n ) {}\n\n async run(request: BashRunRequest): Promise<BashRunResult> {\n if (request.env && request.backend !== 'native')\n throw new Error('Environment overrides require the native launcher.');\n if (request.backend === 'native' && (request.interactive || request.preferInteractive))\n throw new Error('Native package launches are noninteractive.');\n const id = runnerId();\n const name = await this.namer.allocate(request.command, request.sessionId, request.name);\n const cwd = request.cwd ?? this.cwd;\n // Reassigned once the launch shows whether a pane was actually available.\n let interactive = request.interactive === true;\n const wantsPane = interactive || request.preferInteractive === true;\n if (request.signal?.aborted) return { kind: FAILED, id, name, error: 'Operation aborted', reason: 'cancelled' };\n\n let handle: RunHandle;\n let releaseSlot: PoHostExecutionPermit | undefined;\n try {\n if (this.executionBudget && isHeavyCommand(request.command)) {\n releaseSlot = await this.executionBudget.acquire(request.signal);\n }\n request.signal?.throwIfAborted();\n const rmuxHandle =\n request.backend === 'native'\n ? undefined\n : await this.rmuxBackend.launch({\n id,\n name,\n command: request.command,\n cwd,\n sessionId: request.sessionId,\n interactive: wantsPane,\n });\n if (interactive && !rmuxHandle) {\n releaseSlot?.();\n return { kind: FAILED, id, name, error: TERMINAL_UNAVAILABLE, reason: 'launch_failed' };\n }\n interactive = wantsPane && rmuxHandle !== undefined;\n handle =\n rmuxHandle ??\n (await this.launcher.launch({\n id,\n name,\n command: request.command,\n cwd,\n sessionId: request.sessionId,\n ...(request.env ? { env: request.env } : {}),\n }));\n } catch (error) {\n releaseSlot?.();\n return {\n kind: FAILED,\n id,\n name,\n error: error instanceof Error ? error.message : String(error),\n reason: request.signal?.aborted ? 'cancelled' : 'launch_failed',\n };\n }\n\n if (handle.pid === undefined) {\n releaseSlot?.();\n return {\n kind: FAILED,\n id,\n name,\n error: 'The command did not start, so it cannot be supervised',\n reason: 'launch_failed',\n };\n }\n // A background promotion is not process completion. Keep the slot until actual exit.\n if (releaseSlot) void handle.completion().then(releaseSlot, releaseSlot);\n // Register first so a process that survives PID attachment failure remains discoverable.\n try {\n await this.registry.register({\n id,\n name,\n pid: handle.pid,\n command: request.command,\n cwd,\n logPath: handle.logPath,\n interactive,\n sessionId: request.sessionId,\n backend: handle.backend,\n ...(handle.backendTarget ? { backendTarget: handle.backendTarget } : {}),\n });\n await request.onStarted?.({ id, name, logPath: handle.logPath });\n } catch (error) {\n await handle.stop();\n return {\n kind: FAILED,\n id,\n name,\n error: error instanceof Error ? error.message : String(error),\n reason: 'supervision_failed',\n };\n }\n\n if (releaseSlot) {\n try {\n await releaseSlot.attachProcess?.(handle.pid);\n } catch (error) {\n if (!(await handle.stop())) {\n return this.promote(handle, 'requested', undefined);\n }\n await this.registry.complete(id, { reason: 'stopped', code: null, signal: 'SIGTERM' });\n return {\n kind: FAILED,\n id,\n name,\n error: error instanceof Error ? error.message : String(error),\n reason: 'supervision_failed',\n };\n }\n }\n if (request.signal?.aborted) {\n if (!(await handle.stop())) return this.promote(handle, 'requested', undefined);\n await this.registry.complete(id, { reason: 'stopped', code: null, signal: 'SIGTERM' });\n return { kind: FAILED, id, name, error: 'Operation aborted', reason: 'cancelled' };\n }\n\n // A sequence owns the wait and hands control back as soon as its interactive stage starts.\n if (request.waitForExit !== true && (request.background === true || interactive))\n return this.promote(handle, request.background === true ? 'requested' : 'interactive', request.signal);\n\n const outputUpdates = request.onOutput ? this.followOutput(handle, request.onOutput) : undefined;\n try {\n const outcome = await this.race(handle, request.timeoutMs, request.signal, request.waitForExit !== true);\n await outputUpdates?.flush();\n if (outcome === TIMED_OUT) {\n return this.promote(handle, 'threshold', request.signal);\n }\n if (outcome === ABORTED) {\n await this.registry.requestTermination(id, { reason: 'stopped', terminationReason: 'request_cancelled' });\n const stopped = await handle.stop();\n if (!stopped && request.waitForExit) return this.promote(handle, 'requested', undefined);\n await outputUpdates?.flush();\n await this.registry.complete(id, { reason: 'stopped', code: null, signal: 'SIGTERM' });\n return {\n kind: COMPLETED,\n id,\n name,\n output: await handle.output(),\n exitCode: null,\n signal: 'SIGTERM',\n logPath: handle.logPath,\n backend: handle.backend,\n aborted: true,\n };\n }\n if (outcome === DEADLINE) {\n // An explicit timeout means the caller wants the command dead, not\n // supervised, so it is stopped rather than promoted.\n await this.registry.requestTermination(id, { reason: 'timed_out', terminationReason: 'timeout' });\n const stopped = await handle.stop();\n if (!stopped && request.waitForExit) return this.promote(handle, 'requested', undefined);\n await outputUpdates?.flush();\n await this.registry.complete(id, { reason: 'timed_out', code: null, signal: 'SIGTERM' });\n return {\n kind: COMPLETED,\n id,\n name,\n output: await handle.output(),\n exitCode: null,\n signal: 'SIGTERM',\n logPath: handle.logPath,\n backend: handle.backend,\n timedOut: true,\n };\n }\n if (outcome instanceof Error) {\n await this.registry.complete(id, { reason: LAUNCHER_ERROR, code: null, signal: null });\n return { kind: FAILED, id, name, error: outcome.message, reason: 'supervision_failed' };\n }\n\n await this.registry.complete(id, {\n reason: outcome.reason ?? (outcome.signal ? SIGNALED : outcome.code === 0 ? COMPLETED : FAILED),\n code: outcome.code,\n signal: outcome.signal,\n ...(outcome.terminationReason ? { terminationReason: outcome.terminationReason } : {}),\n ...(outcome.stopReason ? { stopReason: outcome.stopReason } : {}),\n });\n\n return {\n kind: COMPLETED,\n id,\n name,\n output: await handle.output(),\n exitCode: outcome.code,\n signal: outcome.signal,\n logPath: handle.logPath,\n backend: handle.backend,\n ...(await this.processLog(request.command, handle.logPath)),\n };\n } finally {\n outputUpdates?.dispose();\n }\n }\n\n private async processLog(command: string, logPath: string): Promise<Pick<CompletedRun, 'rtkOutput' | 'rtkWarning'>> {\n try {\n const result = await this.rtkProcessor.process({ command, logPath });\n if (result.kind === 'processed') return { rtkOutput: result.result };\n if (result.kind === 'fallback') return { rtkWarning: result.warning };\n return {};\n } catch {\n return { rtkWarning: RTK_FAILED_WARNING };\n }\n }\n\n private followOutput(\n handle: RunHandle,\n onOutput: NonNullable<BashRunRequest['onOutput']>,\n ): { flush(): Promise<void>; dispose(): void } {\n let active = true;\n let previous = '';\n let cancelPoll: (() => void) | undefined;\n const flush = async (): Promise<void> => {\n if (!active) return;\n const output = await handle.output();\n if (output === previous) return;\n previous = output;\n onOutput(output);\n };\n const poll = async (): Promise<void> => {\n if (!active) return;\n await flush();\n if (active) cancelPoll = this.clock.after(OUTPUT_UPDATE_POLL_MS, poll);\n };\n cancelPoll = this.clock.after(OUTPUT_UPDATE_POLL_MS, poll);\n return {\n flush,\n dispose: () => {\n active = false;\n cancelPoll?.();\n cancelPoll = undefined;\n },\n };\n }\n\n /**\n * Waits for the command, giving up at the background threshold or at the\n * caller's timeout, whichever comes first.\n *\n * A rejected completion is returned rather than thrown so the caller can\n * report a start failure as a tool result instead of an exception.\n */\n private async race(\n handle: RunHandle,\n timeoutMs: number | undefined,\n signal: AbortSignal | undefined,\n promoteAtThreshold = true,\n ): Promise<\n Awaited<ReturnType<RunHandle['completion']>> | Error | typeof TIMED_OUT | typeof DEADLINE | typeof ABORTED\n > {\n const cancels: Array<() => void> = [];\n const racers: Array<Promise<unknown>> = [handle.completion().catch((error: Error) => error)];\n\n if (promoteAtThreshold)\n racers.push(\n new Promise((resolve) => {\n cancels.push(this.clock.after(getBackgroundThresholdMs(this.env), () => resolve(TIMED_OUT)));\n }),\n );\n if (timeoutMs !== undefined && timeoutMs > 0) {\n racers.push(\n new Promise((resolve) => {\n cancels.push(this.clock.after(timeoutMs, () => resolve(DEADLINE)));\n }),\n );\n }\n if (signal) {\n racers.push(\n new Promise((resolve) => {\n if (signal.aborted) {\n resolve(ABORTED);\n return;\n }\n const abort = (): void => resolve(ABORTED);\n signal.addEventListener('abort', abort, { once: true });\n cancels.push(() => signal.removeEventListener('abort', abort));\n }),\n );\n }\n\n try {\n return (await Promise.race(racers)) as\n | Awaited<ReturnType<RunHandle['completion']>>\n | Error\n | typeof TIMED_OUT\n | typeof DEADLINE\n | typeof ABORTED;\n } finally {\n for (const cancel of cancels) cancel();\n }\n }\n\n private async promote(\n handle: RunHandle,\n reason: PromotedRun['reason'],\n signal: AbortSignal | undefined,\n ): Promise<BashRunResult> {\n if (handle.pid === undefined)\n return {\n kind: FAILED,\n id: handle.id,\n name: handle.name,\n error: 'The command did not start',\n reason: 'launch_failed',\n };\n await this.registry.markPromoted(handle.id);\n // Registration first: an unregistered runner is invisible, and the handle\n // stops buffering the moment it is detached.\n handle.detach();\n let abortStop: Promise<boolean> | undefined;\n const abort = (): void => {\n abortStop = this.registry\n .requestTermination(handle.id, { reason: 'stopped', terminationReason: 'request_cancelled' })\n .then(() => handle.stop())\n .then(async () => {\n await this.registry.complete(handle.id, { reason: 'stopped', code: null, signal: 'SIGTERM' });\n return true;\n })\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.emitWarning(`Failed to stop aborted runner ${handle.id}: ${message}`);\n return false;\n });\n };\n // The signal belongs to the tool call, which ends when this returns, and\n // Pi aborts it at that point. A promoted runner outlives the call, so only\n // an abort that landed before the handoff stops it.\n if (signal?.aborted) abort();\n void handle\n .completion()\n .then(\n async (outcome) => {\n if (await abortStop) return;\n await this.registry.complete(handle.id, {\n reason: outcome.reason ?? (outcome.signal ? SIGNALED : outcome.code === 0 ? COMPLETED : FAILED),\n code: outcome.code,\n signal: outcome.signal,\n ...(outcome.terminationReason ? { terminationReason: outcome.terminationReason } : {}),\n ...(outcome.stopReason ? { stopReason: outcome.stopReason } : {}),\n });\n },\n async () => {\n if (await abortStop) return;\n await this.registry.complete(handle.id, { reason: LAUNCHER_ERROR, code: null, signal: null });\n },\n )\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.emitWarning(`Failed to complete runner ${handle.id}: ${message}`);\n });\n\n return {\n kind: 'promoted',\n id: handle.id,\n name: handle.name,\n pid: handle.pid,\n logPath: handle.logPath,\n backend: handle.backend,\n reason,\n };\n }\n}\n"],"mappings":";;;;AAEA,MAAa,YAAY;AACzB,MAAa,SAAS;AACtB,MAAa,iBAAiB;;AAG9B,MAAa,uBAAuB;;;;ACNpC,SAAS,mBAAmB,SAA6B;CACvD,MAAM,cAA0B,CAAC;CACjC,IAAI,QAAkB,CAAC;CACvB,IAAI,OAAO;CACX,IAAI,QAAQ;CACZ,IAAI,UAAU;CACd,MAAM,kBAAwB;EAC5B,IAAI,MAAM,MAAM,KAAK,IAAI;EACzB,OA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OAAO,IAAI;IAAE,QAAQ;IAAgB,MAAM;IAAM,QAAQ;GAAK,CAAC;EAC9F,CACF,CAAC,CACA,OAAO,UAAmB;GACzB,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GACrE,QAAQ,YAAY,6BAA6B,OAAO,GAAG,IAAI,SAAS;EAC1E,CAAC;EAEH,OAAO;GACL,MAAM;GACN,IAAI,OAAO;GACX,MAAM,OAAO;GACb,KAAK,OAAO;GACZ,SAAS,OAAO;GAChB,SAAS,OAAO;GAChB;EACF;CACF;AACF"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { t as BashFailureReason } from "./bashResult-CgVS_JpL.mjs";
|
|
1
2
|
import { l as RtkProcessedOutput } from "./rtkProcessor-CVZvNhkJ.mjs";
|
|
2
3
|
//#region src/types/bashRunService.d.ts
|
|
3
4
|
interface BashRunRequest {
|
|
4
5
|
command: string;
|
|
5
6
|
cwd?: string;
|
|
7
|
+
/** Internal package launch path. Native bypasses all terminal multiplexers. */
|
|
8
|
+
backend?: 'native';
|
|
9
|
+
/** Per-run environment overrides, only accepted on the native path. */
|
|
10
|
+
env?: Record<string, string>;
|
|
6
11
|
/**
|
|
7
12
|
* Stops the command outright once it has run this long. Only meaningful
|
|
8
13
|
* below the background threshold: past that the command is promoted instead.
|
|
@@ -12,12 +17,25 @@ interface BashRunRequest {
|
|
|
12
17
|
background?: boolean;
|
|
13
18
|
/** Runs under a pseudo terminal so the command can prompt for input. */
|
|
14
19
|
interactive?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Hosts the command on a terminal when a multiplexer is available and runs it
|
|
22
|
+
* as a plain subprocess otherwise. `interactive` fails instead of falling back.
|
|
23
|
+
*/
|
|
24
|
+
preferInteractive?: boolean;
|
|
15
25
|
/** Preferred runner name. A colliding name gets a numbered variant. */
|
|
16
26
|
name?: string;
|
|
17
27
|
/** Receives bounded output snapshots while the command remains in the foreground. */
|
|
18
28
|
onOutput?: (output: string) => void;
|
|
19
29
|
/** Stops this run, including after promotion to a supervised background runner. */
|
|
20
30
|
signal?: AbortSignal;
|
|
31
|
+
/** Internal sequence mode: wait for terminal exit instead of returning on promotion. */
|
|
32
|
+
waitForExit?: boolean;
|
|
33
|
+
/** Records the real stage identity once supervision is attached. */
|
|
34
|
+
onStarted?: (run: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
logPath: string;
|
|
38
|
+
}) => void | Promise<void>;
|
|
21
39
|
/** Session that owns the runner, so shutdown can stop what it started. */
|
|
22
40
|
sessionId: string;
|
|
23
41
|
}
|
|
@@ -54,12 +72,13 @@ interface PromotedRun {
|
|
|
54
72
|
*/
|
|
55
73
|
reason: 'requested' | 'threshold' | 'interactive';
|
|
56
74
|
}
|
|
57
|
-
/** The process could not be started at all. */
|
|
75
|
+
/** The process could not be started at all, or lost supervision before it finished. */
|
|
58
76
|
interface FailedRun {
|
|
59
77
|
kind: 'failed';
|
|
60
78
|
id: string;
|
|
61
79
|
name: string;
|
|
62
80
|
error: string;
|
|
81
|
+
reason?: Extract<BashFailureReason, 'cancelled' | 'launch_failed' | 'supervision_failed'>;
|
|
63
82
|
}
|
|
64
83
|
type BashRunResult = CompletedRun | PromotedRun | FailedRun;
|
|
65
84
|
/** Runs one bash command, promoting it to a background runner when it outlives the threshold. */
|
|
@@ -68,4 +87,4 @@ interface IBashRunService {
|
|
|
68
87
|
}
|
|
69
88
|
//#endregion
|
|
70
89
|
export { IBashRunService as a, FailedRun as i, BashRunResult as n, PromotedRun as o, CompletedRun as r, BashRunRequest as t };
|
|
71
|
-
//# sourceMappingURL=bashRunService-
|
|
90
|
+
//# sourceMappingURL=bashRunService-Iotfc_nV.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bashRunService-Iotfc_nV.d.mts","names":[],"sources":["../src/types/bashRunService.ts"],"mappings":";;;UAGiB;EACf;EACA;;EAEA;;EAEA,MAAM;;;;;EAKN;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA,YAAY;;EAEZ,SAAS;;EAET;;EAEA,aAAa;IAAO;IAAY;IAAc;eAA6B;;EAE3E;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA,QAAQ,OAAO;EACf;EACA;;EAEA,YAAY;;EAEZ;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;EACA;;;;;EAKA;;;UAIe;EACf;EACA;EACA;EACA;EACA,SAAS,QAAQ;;KAGP,gBAAgB,eAAe,cAAc;;UAGxC;EACf,IAAI,SAAS,iBAAiB,QAAQ"}
|
|
@@ -5,6 +5,8 @@ import { randomBytes } from "node:crypto";
|
|
|
5
5
|
const COMPLETED = "completed";
|
|
6
6
|
const FAILED = "failed";
|
|
7
7
|
const LAUNCHER_ERROR = "launcher_error";
|
|
8
|
+
/** An interactive launch found neither multiplexer. */
|
|
9
|
+
const TERMINAL_UNAVAILABLE = "A terminal needs rmux or tmux, and neither is available on this machine.";
|
|
8
10
|
//#endregion
|
|
9
11
|
//#region src/services/bashRunService/resources.ts
|
|
10
12
|
/** Split shell words without mistaking quoted examples for executed commands. */
|
|
@@ -106,28 +108,32 @@ var BashRunService = class {
|
|
|
106
108
|
this.executionBudget = executionBudget;
|
|
107
109
|
}
|
|
108
110
|
async run(request) {
|
|
111
|
+
if (request.env && request.backend !== "native") throw new Error("Environment overrides require the native launcher.");
|
|
112
|
+
if (request.backend === "native" && (request.interactive || request.preferInteractive)) throw new Error("Native package launches are noninteractive.");
|
|
109
113
|
const id = runnerId();
|
|
110
114
|
const name = await this.namer.allocate(request.command, request.sessionId, request.name);
|
|
111
115
|
const cwd = request.cwd ?? this.cwd;
|
|
112
|
-
|
|
116
|
+
let interactive = request.interactive === true;
|
|
117
|
+
const wantsPane = interactive || request.preferInteractive === true;
|
|
113
118
|
if (request.signal?.aborted) return {
|
|
114
119
|
kind: FAILED,
|
|
115
120
|
id,
|
|
116
121
|
name,
|
|
117
|
-
error: "Operation aborted"
|
|
122
|
+
error: "Operation aborted",
|
|
123
|
+
reason: "cancelled"
|
|
118
124
|
};
|
|
119
125
|
let handle;
|
|
120
126
|
let releaseSlot;
|
|
121
127
|
try {
|
|
122
128
|
if (this.executionBudget && isHeavyCommand(request.command)) releaseSlot = await this.executionBudget.acquire(request.signal);
|
|
123
129
|
request.signal?.throwIfAborted();
|
|
124
|
-
const rmuxHandle = await this.rmuxBackend.launch({
|
|
130
|
+
const rmuxHandle = request.backend === "native" ? void 0 : await this.rmuxBackend.launch({
|
|
125
131
|
id,
|
|
126
132
|
name,
|
|
127
133
|
command: request.command,
|
|
128
134
|
cwd,
|
|
129
135
|
sessionId: request.sessionId,
|
|
130
|
-
interactive
|
|
136
|
+
interactive: wantsPane
|
|
131
137
|
});
|
|
132
138
|
if (interactive && !rmuxHandle) {
|
|
133
139
|
releaseSlot?.();
|
|
@@ -135,15 +141,18 @@ var BashRunService = class {
|
|
|
135
141
|
kind: FAILED,
|
|
136
142
|
id,
|
|
137
143
|
name,
|
|
138
|
-
error:
|
|
144
|
+
error: TERMINAL_UNAVAILABLE,
|
|
145
|
+
reason: "launch_failed"
|
|
139
146
|
};
|
|
140
147
|
}
|
|
141
|
-
|
|
148
|
+
interactive = wantsPane && rmuxHandle !== void 0;
|
|
149
|
+
handle = rmuxHandle ?? await this.launcher.launch({
|
|
142
150
|
id,
|
|
143
151
|
name,
|
|
144
152
|
command: request.command,
|
|
145
153
|
cwd,
|
|
146
|
-
sessionId: request.sessionId
|
|
154
|
+
sessionId: request.sessionId,
|
|
155
|
+
...request.env ? { env: request.env } : {}
|
|
147
156
|
});
|
|
148
157
|
} catch (error) {
|
|
149
158
|
releaseSlot?.();
|
|
@@ -151,7 +160,8 @@ var BashRunService = class {
|
|
|
151
160
|
kind: FAILED,
|
|
152
161
|
id,
|
|
153
162
|
name,
|
|
154
|
-
error: error instanceof Error ? error.message : String(error)
|
|
163
|
+
error: error instanceof Error ? error.message : String(error),
|
|
164
|
+
reason: request.signal?.aborted ? "cancelled" : "launch_failed"
|
|
155
165
|
};
|
|
156
166
|
}
|
|
157
167
|
if (handle.pid === void 0) {
|
|
@@ -160,7 +170,8 @@ var BashRunService = class {
|
|
|
160
170
|
kind: FAILED,
|
|
161
171
|
id,
|
|
162
172
|
name,
|
|
163
|
-
error: "The command did not start, so it cannot be supervised"
|
|
173
|
+
error: "The command did not start, so it cannot be supervised",
|
|
174
|
+
reason: "launch_failed"
|
|
164
175
|
};
|
|
165
176
|
}
|
|
166
177
|
if (releaseSlot) handle.completion().then(releaseSlot, releaseSlot);
|
|
@@ -177,13 +188,19 @@ var BashRunService = class {
|
|
|
177
188
|
backend: handle.backend,
|
|
178
189
|
...handle.backendTarget ? { backendTarget: handle.backendTarget } : {}
|
|
179
190
|
});
|
|
191
|
+
await request.onStarted?.({
|
|
192
|
+
id,
|
|
193
|
+
name,
|
|
194
|
+
logPath: handle.logPath
|
|
195
|
+
});
|
|
180
196
|
} catch (error) {
|
|
181
197
|
await handle.stop();
|
|
182
198
|
return {
|
|
183
199
|
kind: FAILED,
|
|
184
200
|
id,
|
|
185
201
|
name,
|
|
186
|
-
error: error instanceof Error ? error.message : String(error)
|
|
202
|
+
error: error instanceof Error ? error.message : String(error),
|
|
203
|
+
reason: "supervision_failed"
|
|
187
204
|
};
|
|
188
205
|
}
|
|
189
206
|
if (releaseSlot) try {
|
|
@@ -199,7 +216,8 @@ var BashRunService = class {
|
|
|
199
216
|
kind: FAILED,
|
|
200
217
|
id,
|
|
201
218
|
name,
|
|
202
|
-
error: error instanceof Error ? error.message : String(error)
|
|
219
|
+
error: error instanceof Error ? error.message : String(error),
|
|
220
|
+
reason: "supervision_failed"
|
|
203
221
|
};
|
|
204
222
|
}
|
|
205
223
|
if (request.signal?.aborted) {
|
|
@@ -213,22 +231,23 @@ var BashRunService = class {
|
|
|
213
231
|
kind: FAILED,
|
|
214
232
|
id,
|
|
215
233
|
name,
|
|
216
|
-
error: "Operation aborted"
|
|
234
|
+
error: "Operation aborted",
|
|
235
|
+
reason: "cancelled"
|
|
217
236
|
};
|
|
218
237
|
}
|
|
219
|
-
if (request.background === true || interactive) return this.promote(handle, request.background === true ? "requested" : "interactive", request.signal);
|
|
238
|
+
if (request.waitForExit !== true && (request.background === true || interactive)) return this.promote(handle, request.background === true ? "requested" : "interactive", request.signal);
|
|
220
239
|
const outputUpdates = request.onOutput ? this.followOutput(handle, request.onOutput) : void 0;
|
|
221
240
|
try {
|
|
222
|
-
const outcome = await this.race(handle, request.timeoutMs, request.signal);
|
|
223
|
-
outputUpdates?.flush();
|
|
241
|
+
const outcome = await this.race(handle, request.timeoutMs, request.signal, request.waitForExit !== true);
|
|
242
|
+
await outputUpdates?.flush();
|
|
224
243
|
if (outcome === TIMED_OUT) return this.promote(handle, "threshold", request.signal);
|
|
225
244
|
if (outcome === ABORTED) {
|
|
226
245
|
await this.registry.requestTermination(id, {
|
|
227
246
|
reason: "stopped",
|
|
228
247
|
terminationReason: "request_cancelled"
|
|
229
248
|
});
|
|
230
|
-
await handle.stop();
|
|
231
|
-
outputUpdates?.flush();
|
|
249
|
+
if (!await handle.stop() && request.waitForExit) return this.promote(handle, "requested", void 0);
|
|
250
|
+
await outputUpdates?.flush();
|
|
232
251
|
await this.registry.complete(id, {
|
|
233
252
|
reason: "stopped",
|
|
234
253
|
code: null,
|
|
@@ -238,7 +257,7 @@ var BashRunService = class {
|
|
|
238
257
|
kind: COMPLETED,
|
|
239
258
|
id,
|
|
240
259
|
name,
|
|
241
|
-
output: handle.output(),
|
|
260
|
+
output: await handle.output(),
|
|
242
261
|
exitCode: null,
|
|
243
262
|
signal: "SIGTERM",
|
|
244
263
|
logPath: handle.logPath,
|
|
@@ -251,8 +270,8 @@ var BashRunService = class {
|
|
|
251
270
|
reason: "timed_out",
|
|
252
271
|
terminationReason: "timeout"
|
|
253
272
|
});
|
|
254
|
-
await handle.stop();
|
|
255
|
-
outputUpdates?.flush();
|
|
273
|
+
if (!await handle.stop() && request.waitForExit) return this.promote(handle, "requested", void 0);
|
|
274
|
+
await outputUpdates?.flush();
|
|
256
275
|
await this.registry.complete(id, {
|
|
257
276
|
reason: "timed_out",
|
|
258
277
|
code: null,
|
|
@@ -262,7 +281,7 @@ var BashRunService = class {
|
|
|
262
281
|
kind: COMPLETED,
|
|
263
282
|
id,
|
|
264
283
|
name,
|
|
265
|
-
output: handle.output(),
|
|
284
|
+
output: await handle.output(),
|
|
266
285
|
exitCode: null,
|
|
267
286
|
signal: "SIGTERM",
|
|
268
287
|
logPath: handle.logPath,
|
|
@@ -280,7 +299,8 @@ var BashRunService = class {
|
|
|
280
299
|
kind: FAILED,
|
|
281
300
|
id,
|
|
282
301
|
name,
|
|
283
|
-
error: outcome.message
|
|
302
|
+
error: outcome.message,
|
|
303
|
+
reason: "supervision_failed"
|
|
284
304
|
};
|
|
285
305
|
}
|
|
286
306
|
await this.registry.complete(id, {
|
|
@@ -294,7 +314,7 @@ var BashRunService = class {
|
|
|
294
314
|
kind: COMPLETED,
|
|
295
315
|
id,
|
|
296
316
|
name,
|
|
297
|
-
output: handle.output(),
|
|
317
|
+
output: await handle.output(),
|
|
298
318
|
exitCode: outcome.code,
|
|
299
319
|
signal: outcome.signal,
|
|
300
320
|
logPath: handle.logPath,
|
|
@@ -322,16 +342,16 @@ var BashRunService = class {
|
|
|
322
342
|
let active = true;
|
|
323
343
|
let previous = "";
|
|
324
344
|
let cancelPoll;
|
|
325
|
-
const flush = () => {
|
|
345
|
+
const flush = async () => {
|
|
326
346
|
if (!active) return;
|
|
327
|
-
const output = handle.output();
|
|
347
|
+
const output = await handle.output();
|
|
328
348
|
if (output === previous) return;
|
|
329
349
|
previous = output;
|
|
330
350
|
onOutput(output);
|
|
331
351
|
};
|
|
332
|
-
const poll = () => {
|
|
352
|
+
const poll = async () => {
|
|
333
353
|
if (!active) return;
|
|
334
|
-
flush();
|
|
354
|
+
await flush();
|
|
335
355
|
if (active) cancelPoll = this.clock.after(100, poll);
|
|
336
356
|
};
|
|
337
357
|
cancelPoll = this.clock.after(100, poll);
|
|
@@ -351,10 +371,10 @@ var BashRunService = class {
|
|
|
351
371
|
* A rejected completion is returned rather than thrown so the caller can
|
|
352
372
|
* report a start failure as a tool result instead of an exception.
|
|
353
373
|
*/
|
|
354
|
-
async race(handle, timeoutMs, signal) {
|
|
374
|
+
async race(handle, timeoutMs, signal, promoteAtThreshold = true) {
|
|
355
375
|
const cancels = [];
|
|
356
376
|
const racers = [handle.completion().catch((error) => error)];
|
|
357
|
-
racers.push(new Promise((resolve) => {
|
|
377
|
+
if (promoteAtThreshold) racers.push(new Promise((resolve) => {
|
|
358
378
|
cancels.push(this.clock.after(getBackgroundThresholdMs(this.env), () => resolve(TIMED_OUT)));
|
|
359
379
|
}));
|
|
360
380
|
if (timeoutMs !== void 0 && timeoutMs > 0) racers.push(new Promise((resolve) => {
|
|
@@ -380,7 +400,8 @@ var BashRunService = class {
|
|
|
380
400
|
kind: FAILED,
|
|
381
401
|
id: handle.id,
|
|
382
402
|
name: handle.name,
|
|
383
|
-
error: "The command did not start"
|
|
403
|
+
error: "The command did not start",
|
|
404
|
+
reason: "launch_failed"
|
|
384
405
|
};
|
|
385
406
|
await this.registry.markPromoted(handle.id);
|
|
386
407
|
handle.detach();
|
|
@@ -437,4 +458,4 @@ var BashRunService = class {
|
|
|
437
458
|
//#endregion
|
|
438
459
|
export { BashRunService as t };
|
|
439
460
|
|
|
440
|
-
//# sourceMappingURL=bashRunService-
|
|
461
|
+
//# sourceMappingURL=bashRunService-Luy2hPMS.mjs.map
|