botmux 3.11.0-canary.1 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.runtime-build-id +1 -1
- package/dist/adapters/backend/riff-backend.d.ts +29 -5
- package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
- package/dist/adapters/backend/riff-backend.js +313 -33
- package/dist/adapters/backend/riff-backend.js.map +1 -1
- package/dist/adapters/backend/types.d.ts +37 -3
- package/dist/adapters/backend/types.d.ts.map +1 -1
- package/dist/adapters/backend/types.js.map +1 -1
- package/dist/adapters/cli/coco.js +3 -3
- package/dist/adapters/cli/coco.js.map +1 -1
- package/dist/adapters/cli/codex.js +2 -2
- package/dist/adapters/cli/codex.js.map +1 -1
- package/dist/adapters/cli/read-isolation.d.ts +35 -2
- package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
- package/dist/adapters/cli/read-isolation.js +88 -7
- package/dist/adapters/cli/read-isolation.js.map +1 -1
- package/dist/cli/dashboard-command.d.ts +23 -0
- package/dist/cli/dashboard-command.d.ts.map +1 -0
- package/dist/cli/dashboard-command.js +61 -0
- package/dist/cli/dashboard-command.js.map +1 -0
- package/dist/cli/dashboard-endpoint.d.ts +3 -3
- package/dist/cli/dashboard-endpoint.d.ts.map +1 -1
- package/dist/cli/dashboard-endpoint.js +1 -1
- package/dist/cli/fleet-shutdown.d.ts +47 -0
- package/dist/cli/fleet-shutdown.d.ts.map +1 -0
- package/dist/cli/fleet-shutdown.js +387 -0
- package/dist/cli/fleet-shutdown.js.map +1 -0
- package/dist/cli/pm2-descriptor-guard.d.ts +19 -0
- package/dist/cli/pm2-descriptor-guard.d.ts.map +1 -0
- package/dist/cli/pm2-descriptor-guard.js +122 -0
- package/dist/cli/pm2-descriptor-guard.js.map +1 -0
- package/dist/cli/pm2-exact-start.d.ts +16 -0
- package/dist/cli/pm2-exact-start.d.ts.map +1 -0
- package/dist/cli/pm2-exact-start.js +63 -0
- package/dist/cli/pm2-exact-start.js.map +1 -0
- package/dist/cli/pm2-god-admission.d.ts +8 -0
- package/dist/cli/pm2-god-admission.d.ts.map +1 -0
- package/dist/cli/pm2-god-admission.js +25 -0
- package/dist/cli/pm2-god-admission.js.map +1 -0
- package/dist/cli/pm2-jlist.d.ts +13 -0
- package/dist/cli/pm2-jlist.d.ts.map +1 -0
- package/dist/cli/pm2-jlist.js +108 -0
- package/dist/cli/pm2-jlist.js.map +1 -0
- package/dist/cli/pm2-preflight.d.ts +10 -0
- package/dist/cli/pm2-preflight.d.ts.map +1 -0
- package/dist/cli/pm2-preflight.js +23 -0
- package/dist/cli/pm2-preflight.js.map +1 -0
- package/dist/cli/pm2-shutdown-capability.d.ts +27 -0
- package/dist/cli/pm2-shutdown-capability.d.ts.map +1 -0
- package/dist/cli/pm2-shutdown-capability.js +161 -0
- package/dist/cli/pm2-shutdown-capability.js.map +1 -0
- package/dist/cli/pm2-start-transaction.d.ts +55 -0
- package/dist/cli/pm2-start-transaction.d.ts.map +1 -0
- package/dist/cli/pm2-start-transaction.js +220 -0
- package/dist/cli/pm2-start-transaction.js.map +1 -0
- package/dist/cli/send-dispatch.d.ts +12 -0
- package/dist/cli/send-dispatch.d.ts.map +1 -1
- package/dist/cli/send-dispatch.js +31 -4
- package/dist/cli/send-dispatch.js.map +1 -1
- package/dist/cli/supervisor-shutdown-client.d.ts +31 -0
- package/dist/cli/supervisor-shutdown-client.d.ts.map +1 -0
- package/dist/cli/supervisor-shutdown-client.js +146 -0
- package/dist/cli/supervisor-shutdown-client.js.map +1 -0
- package/dist/cli/vc-agent.d.ts.map +1 -1
- package/dist/cli/vc-agent.js +1 -1
- package/dist/cli/vc-agent.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1403 -440
- package/dist/cli.js.map +1 -1
- package/dist/codex-rpc-engine.d.ts +33 -3
- package/dist/codex-rpc-engine.d.ts.map +1 -1
- package/dist/codex-rpc-engine.js +182 -20
- package/dist/codex-rpc-engine.js.map +1 -1
- package/dist/codex-rpc-lifecycle.d.ts +42 -7
- package/dist/codex-rpc-lifecycle.d.ts.map +1 -1
- package/dist/codex-rpc-lifecycle.js +73 -7
- package/dist/codex-rpc-lifecycle.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/core/cli-session-id-publisher.d.ts +20 -0
- package/dist/core/cli-session-id-publisher.d.ts.map +1 -0
- package/dist/core/cli-session-id-publisher.js +21 -0
- package/dist/core/cli-session-id-publisher.js.map +1 -0
- package/dist/core/command-handler.d.ts +3 -2
- package/dist/core/command-handler.d.ts.map +1 -1
- package/dist/core/command-handler.js +47 -3
- package/dist/core/command-handler.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts +5 -0
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +322 -29
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/dispatch.d.ts +9 -10
- package/dist/core/dispatch.d.ts.map +1 -1
- package/dist/core/dispatch.js +17 -10
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/explicit-session-backing-cleanup.d.ts +49 -0
- package/dist/core/explicit-session-backing-cleanup.d.ts.map +1 -0
- package/dist/core/explicit-session-backing-cleanup.js +76 -0
- package/dist/core/explicit-session-backing-cleanup.js.map +1 -0
- package/dist/core/managed-origin-attestation.d.ts +51 -0
- package/dist/core/managed-origin-attestation.d.ts.map +1 -0
- package/dist/core/managed-origin-attestation.js +208 -0
- package/dist/core/managed-origin-attestation.js.map +1 -0
- package/dist/core/managed-origin-capability.d.ts +62 -3
- package/dist/core/managed-origin-capability.d.ts.map +1 -1
- package/dist/core/managed-origin-capability.js +419 -9
- package/dist/core/managed-origin-capability.js.map +1 -1
- package/dist/core/persistent-backend.d.ts +6 -1
- package/dist/core/persistent-backend.d.ts.map +1 -1
- package/dist/core/persistent-backend.js +12 -6
- package/dist/core/persistent-backend.js.map +1 -1
- package/dist/core/process-start-identity.d.ts +3 -0
- package/dist/core/process-start-identity.d.ts.map +1 -0
- package/dist/core/process-start-identity.js +62 -0
- package/dist/core/process-start-identity.js.map +1 -0
- package/dist/core/restart-report.d.ts +6 -1
- package/dist/core/restart-report.d.ts.map +1 -1
- package/dist/core/restart-report.js +22 -4
- package/dist/core/restart-report.js.map +1 -1
- package/dist/core/riff-shutdown-detach.d.ts +164 -0
- package/dist/core/riff-shutdown-detach.d.ts.map +1 -0
- package/dist/core/riff-shutdown-detach.js +787 -0
- package/dist/core/riff-shutdown-detach.js.map +1 -0
- package/dist/core/riff-worker-shutdown-readiness.d.ts +17 -0
- package/dist/core/riff-worker-shutdown-readiness.d.ts.map +1 -0
- package/dist/core/riff-worker-shutdown-readiness.js +21 -0
- package/dist/core/riff-worker-shutdown-readiness.js.map +1 -0
- package/dist/core/role-resolver.d.ts +5 -2
- package/dist/core/role-resolver.d.ts.map +1 -1
- package/dist/core/role-resolver.js +55 -23
- package/dist/core/role-resolver.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +20 -18
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-marker.d.ts +1 -1
- package/dist/core/session-marker.d.ts.map +1 -1
- package/dist/core/session-marker.js +2 -2
- package/dist/core/session-marker.js.map +1 -1
- package/dist/core/shutdown-budgets.d.ts +27 -0
- package/dist/core/shutdown-budgets.d.ts.map +1 -0
- package/dist/core/shutdown-budgets.js +47 -0
- package/dist/core/shutdown-budgets.js.map +1 -0
- package/dist/core/supervisor-shutdown-ipc.d.ts +10 -0
- package/dist/core/supervisor-shutdown-ipc.d.ts.map +1 -0
- package/dist/core/supervisor-shutdown-ipc.js +10 -0
- package/dist/core/supervisor-shutdown-ipc.js.map +1 -0
- package/dist/core/supervisor-shutdown-protocol.d.ts +16 -0
- package/dist/core/supervisor-shutdown-protocol.d.ts.map +1 -0
- package/dist/core/supervisor-shutdown-protocol.js +16 -0
- package/dist/core/supervisor-shutdown-protocol.js.map +1 -0
- package/dist/core/terminal-write-auth.d.ts +4 -4
- package/dist/core/terminal-write-auth.d.ts.map +1 -1
- package/dist/core/terminal-write-auth.js +18 -6
- package/dist/core/terminal-write-auth.js.map +1 -1
- package/dist/core/types.d.ts +26 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +9 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +20 -3
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +586 -62
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts +1 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +345 -111
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/auth.d.ts +21 -11
- package/dist/dashboard/auth.d.ts.map +1 -1
- package/dist/dashboard/auth.js +39 -25
- package/dist/dashboard/auth.js.map +1 -1
- package/dist/dashboard/bot-payload.d.ts +0 -1
- package/dist/dashboard/bot-payload.d.ts.map +1 -1
- package/dist/dashboard/bot-payload.js +0 -1
- package/dist/dashboard/bot-payload.js.map +1 -1
- package/dist/dashboard/dashboard-summary-endpoint.d.ts +39 -0
- package/dist/dashboard/dashboard-summary-endpoint.d.ts.map +1 -0
- package/dist/dashboard/dashboard-summary-endpoint.js +50 -0
- package/dist/dashboard/dashboard-summary-endpoint.js.map +1 -0
- package/dist/dashboard/dashboard-summary.d.ts +62 -0
- package/dist/dashboard/dashboard-summary.d.ts.map +1 -0
- package/dist/dashboard/dashboard-summary.js +106 -0
- package/dist/dashboard/dashboard-summary.js.map +1 -0
- package/dist/dashboard/feed-groups.d.ts +17 -0
- package/dist/dashboard/feed-groups.d.ts.map +1 -0
- package/dist/dashboard/feed-groups.js +75 -0
- package/dist/dashboard/feed-groups.js.map +1 -0
- package/dist/dashboard/web/feed-group-picker.d.ts +13 -0
- package/dist/dashboard/web/feed-group-picker.d.ts.map +1 -0
- package/dist/dashboard/web/feed-group-picker.js +45 -0
- package/dist/dashboard/web/feed-group-picker.js.map +1 -0
- package/dist/dashboard/web/groups-page.d.ts.map +1 -1
- package/dist/dashboard/web/groups-page.js +92 -2
- package/dist/dashboard/web/groups-page.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +8 -14
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/roles-page.d.ts.map +1 -1
- package/dist/dashboard/web/roles-page.js +36 -4
- package/dist/dashboard/web/roles-page.js.map +1 -1
- package/dist/dashboard/web/roles.d.ts +3 -1
- package/dist/dashboard/web/roles.d.ts.map +1 -1
- package/dist/dashboard/web/roles.js +10 -2
- package/dist/dashboard/web/roles.js.map +1 -1
- package/dist/dashboard/web/schedules-page.d.ts.map +1 -1
- package/dist/dashboard/web/schedules-page.js +8 -2
- package/dist/dashboard/web/schedules-page.js.map +1 -1
- package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
- package/dist/dashboard/web/sessions-page.js +101 -2
- package/dist/dashboard/web/sessions-page.js.map +1 -1
- package/dist/dashboard/web/sessions.js +1 -1
- package/dist/dashboard/web/sessions.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/{bot-defaults-page-GED4FEMS.js → bot-defaults-page-USC6EZXP.js} +1 -1
- package/dist/dashboard-web/chunks/chunk-6ALR252E.js +1 -0
- package/dist/dashboard-web/chunks/{chunk-VBXJOJFH.js → chunk-A7VC4BXR.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-HK7NIBJG.js → chunk-KOPISPHN.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-6J5LS5AU.js → chunk-M6BHWQFO.js} +6 -6
- package/dist/dashboard-web/chunks/{chunk-KRHWZEXU.js → chunk-RXRJB5SO.js} +1 -1
- package/dist/dashboard-web/chunks/{connectors-page-EELM66G3.js → connectors-page-4Z76HWRH.js} +1 -1
- package/dist/dashboard-web/chunks/groups-page-C6NSDTIN.js +8 -0
- package/dist/dashboard-web/chunks/{insights-page-54UBPPOC.js → insights-page-UTOVYLLY.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-PORHVKRH.js → monitor-room-UKTJYTA2.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-XGA7AXNL.js → monitoring-page-Q3CEZIVX.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-AO3AFG45.js → office-page-GYCZOOVJ.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-F5BUTYR6.js → overview-page-W2VBJ6OH.js} +1 -1
- package/dist/dashboard-web/chunks/roles-page-U4SHER4K.js +1 -0
- package/dist/dashboard-web/chunks/schedules-page-TNPW3N3Q.js +1 -0
- package/dist/dashboard-web/chunks/sessions-page-YWWDDV57.js +6 -0
- package/dist/dashboard-web/chunks/{settings-page-OJAZLZQT.js → settings-page-VKW5ZK5K.js} +1 -1
- package/dist/dashboard-web/chunks/{skills-page-EFZQPWV4.js → skills-page-ZCEDFGZZ.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-ZJVAP7HW.js → team-federation-page-OMFGGBT2.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-GYWTRGO2.js → v3-page-PLXWK4KO.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-MSDAG6P7.js → whiteboards-page-NJQOEO2P.js} +1 -1
- package/dist/dashboard-web/style.css +179 -0
- package/dist/dashboard.js +264 -34
- package/dist/dashboard.js.map +1 -1
- package/dist/desktop/main/ipc.js +1 -1
- package/dist/desktop/main/runtime-service.js +2 -2
- package/dist/desktop/main/runtime-service.js.map +1 -1
- package/dist/desktop/renderer/app.js +21 -0
- package/dist/desktop/renderer/app.js.map +1 -1
- package/dist/desktop/shared/types.d.ts +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +19 -7
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +19 -7
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +34 -6
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +28 -1
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/client.d.ts +7 -0
- package/dist/im/lark/client.d.ts.map +1 -1
- package/dist/im/lark/client.js +36 -23
- package/dist/im/lark/client.js.map +1 -1
- package/dist/im/lark/doc-comment.d.ts +7 -4
- package/dist/im/lark/doc-comment.d.ts.map +1 -1
- package/dist/im/lark/doc-comment.js +19 -6
- package/dist/im/lark/doc-comment.js.map +1 -1
- package/dist/im/lark/md-card.d.ts +11 -0
- package/dist/im/lark/md-card.d.ts.map +1 -1
- package/dist/im/lark/md-card.js +46 -0
- package/dist/im/lark/md-card.js.map +1 -1
- package/dist/services/adopt-input-sequence.d.ts +52 -0
- package/dist/services/adopt-input-sequence.d.ts.map +1 -0
- package/dist/services/adopt-input-sequence.js +50 -0
- package/dist/services/adopt-input-sequence.js.map +1 -0
- package/dist/services/bridge-fallback-gate.d.ts +40 -0
- package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
- package/dist/services/bridge-fallback-gate.js +147 -24
- package/dist/services/bridge-fallback-gate.js.map +1 -1
- package/dist/services/codex-bridge-queue.d.ts +104 -7
- package/dist/services/codex-bridge-queue.d.ts.map +1 -1
- package/dist/services/codex-bridge-queue.js +292 -17
- package/dist/services/codex-bridge-queue.js.map +1 -1
- package/dist/services/codex-service-tier.d.ts +2 -0
- package/dist/services/codex-service-tier.d.ts.map +1 -1
- package/dist/services/codex-service-tier.js +1 -0
- package/dist/services/codex-service-tier.js.map +1 -1
- package/dist/services/codex-transcript.d.ts +31 -3
- package/dist/services/codex-transcript.d.ts.map +1 -1
- package/dist/services/codex-transcript.js +340 -2
- package/dist/services/codex-transcript.js.map +1 -1
- package/dist/services/hook-runner.d.ts +20 -1
- package/dist/services/hook-runner.d.ts.map +1 -1
- package/dist/services/hook-runner.js +17 -13
- package/dist/services/hook-runner.js.map +1 -1
- package/dist/services/open-platform-rename.d.ts.map +1 -1
- package/dist/services/open-platform-rename.js +1 -108
- package/dist/services/open-platform-rename.js.map +1 -1
- package/dist/services/restart-intent-store.d.ts +22 -2
- package/dist/services/restart-intent-store.d.ts.map +1 -1
- package/dist/services/restart-intent-store.js +160 -18
- package/dist/services/restart-intent-store.js.map +1 -1
- package/dist/services/sandbox-store.d.ts +22 -0
- package/dist/services/sandbox-store.d.ts.map +1 -1
- package/dist/services/sandbox-store.js +37 -8
- package/dist/services/sandbox-store.js.map +1 -1
- package/dist/services/session-store.d.ts +52 -2
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +276 -23
- package/dist/services/session-store.js.map +1 -1
- package/dist/services/structured-bridge-clis.d.ts +8 -1
- package/dist/services/structured-bridge-clis.d.ts.map +1 -1
- package/dist/services/structured-bridge-clis.js +13 -0
- package/dist/services/structured-bridge-clis.js.map +1 -1
- package/dist/services/submit-confirmation.d.ts +50 -0
- package/dist/services/submit-confirmation.d.ts.map +1 -1
- package/dist/services/submit-confirmation.js +82 -0
- package/dist/services/submit-confirmation.js.map +1 -1
- package/dist/services/submit-notification.d.ts +3 -0
- package/dist/services/submit-notification.d.ts.map +1 -0
- package/dist/services/submit-notification.js +15 -0
- package/dist/services/submit-notification.js.map +1 -0
- package/dist/services/traex-transcript.d.ts +25 -2
- package/dist/services/traex-transcript.d.ts.map +1 -1
- package/dist/services/traex-transcript.js +133 -1
- package/dist/services/traex-transcript.js.map +1 -1
- package/dist/services/voice/index.d.ts +3 -2
- package/dist/services/voice/index.d.ts.map +1 -1
- package/dist/services/voice/index.js +5 -5
- package/dist/services/voice/index.js.map +1 -1
- package/dist/services/voice/openai.d.ts +2 -1
- package/dist/services/voice/openai.d.ts.map +1 -1
- package/dist/services/voice/openai.js +2 -1
- package/dist/services/voice/openai.js.map +1 -1
- package/dist/services/voice/sami.d.ts +5 -2
- package/dist/services/voice/sami.d.ts.map +1 -1
- package/dist/services/voice/sami.js +19 -4
- package/dist/services/voice/sami.js.map +1 -1
- package/dist/setup/bots-store.d.ts.map +1 -1
- package/dist/setup/bots-store.js +10 -4
- package/dist/setup/bots-store.js.map +1 -1
- package/dist/setup/lark-scopes.json +2 -0
- package/dist/setup/open-platform-automation.d.ts +9 -1
- package/dist/setup/open-platform-automation.d.ts.map +1 -1
- package/dist/setup/open-platform-automation.js +44 -15
- package/dist/setup/open-platform-automation.js.map +1 -1
- package/dist/setup/open-platform-visibility.d.ts +42 -0
- package/dist/setup/open-platform-visibility.d.ts.map +1 -0
- package/dist/setup/open-platform-visibility.js +133 -0
- package/dist/setup/open-platform-visibility.js.map +1 -0
- package/dist/setup/verify-permissions.d.ts.map +1 -1
- package/dist/setup/verify-permissions.js +6 -0
- package/dist/setup/verify-permissions.js.map +1 -1
- package/dist/types.d.ts +50 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/async-serial-queue.d.ts +9 -0
- package/dist/utils/async-serial-queue.d.ts.map +1 -0
- package/dist/utils/async-serial-queue.js +13 -0
- package/dist/utils/async-serial-queue.js.map +1 -0
- package/dist/utils/child-env.d.ts +1 -1
- package/dist/utils/child-env.d.ts.map +1 -1
- package/dist/utils/child-env.js +6 -0
- package/dist/utils/child-env.js.map +1 -1
- package/dist/utils/idle-detector.d.ts +12 -0
- package/dist/utils/idle-detector.d.ts.map +1 -1
- package/dist/utils/idle-detector.js +19 -0
- package/dist/utils/idle-detector.js.map +1 -1
- package/dist/utils/input-gate.d.ts +87 -0
- package/dist/utils/input-gate.d.ts.map +1 -1
- package/dist/utils/input-gate.js +86 -0
- package/dist/utils/input-gate.js.map +1 -1
- package/dist/utils/runtime-screen-status.d.ts +52 -0
- package/dist/utils/runtime-screen-status.d.ts.map +1 -0
- package/dist/utils/runtime-screen-status.js +60 -0
- package/dist/utils/runtime-screen-status.js.map +1 -0
- package/dist/utils/user-token.d.ts.map +1 -1
- package/dist/utils/user-token.js +53 -2
- package/dist/utils/user-token.js.map +1 -1
- package/dist/worker.js +2287 -578
- package/dist/worker.js.map +1 -1
- package/dist/workflows/v3/session-relay-client.d.ts +1 -0
- package/dist/workflows/v3/session-relay-client.d.ts.map +1 -1
- package/dist/workflows/v3/session-relay-client.js +12 -3
- package/dist/workflows/v3/session-relay-client.js.map +1 -1
- package/package.json +1 -1
- package/dist/dashboard-web/chunks/groups-page-SGE2BNX7.js +0 -8
- package/dist/dashboard-web/chunks/roles-page-M5GIASJU.js +0 -1
- package/dist/dashboard-web/chunks/schedules-page-O232WQRR.js +0 -1
- package/dist/dashboard-web/chunks/sessions-page-WG4PRQXJ.js +0 -6
package/dist/.runtime-build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a63627355856e846a26be9f4935292c6302f4a68df15eebdd3467897f32a02ea
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SessionBackend, SpawnOpts } from './types.js';
|
|
1
|
+
import type { SessionBackend, SessionDestroyResult, SessionShutdownDetachResult, SpawnOpts } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Mandatory setup commands run in the riff sandbox to ensure `botmux` is
|
|
4
4
|
* available. These are ALWAYS sent to the riff API via `config.setupCommands`
|
|
@@ -173,6 +173,24 @@ export declare class RiffBackend implements SessionBackend {
|
|
|
173
173
|
private cancelTimeoutMs;
|
|
174
174
|
private createTimeoutMs;
|
|
175
175
|
private destroyDeadlineMs;
|
|
176
|
+
/** Exact late/current task whose close cancellation failed. Retained across
|
|
177
|
+
* the prepare-close handshake so the daemon can persist a retry handle. */
|
|
178
|
+
private closeFailureTaskId;
|
|
179
|
+
private closeFailureError;
|
|
180
|
+
private closeLateTaskHandled;
|
|
181
|
+
private closePrepared;
|
|
182
|
+
private closeAttempt;
|
|
183
|
+
private destroyInFlight;
|
|
184
|
+
private cancelInFlight;
|
|
185
|
+
private abortInFlight;
|
|
186
|
+
/** Graceful daemon shutdown is a non-cancelling two-phase detach. It fences
|
|
187
|
+
* only writes arriving after prepare; writes already appended to writeChain
|
|
188
|
+
* still drain so a late child id can be durably handed to the daemon. */
|
|
189
|
+
private shutdownDetaching;
|
|
190
|
+
private shutdownDetachPrepared;
|
|
191
|
+
private shutdownDetachAttempt;
|
|
192
|
+
private shutdownDetachInFlight;
|
|
193
|
+
private shutdownDetachAbortInFlight;
|
|
176
194
|
/** Serializes write() → createTask/followUp. Without this, a second message
|
|
177
195
|
* arriving before the first task-execute HTTP returns would see
|
|
178
196
|
* currentTaskId === null and create a duplicate task. */
|
|
@@ -191,12 +209,17 @@ export declare class RiffBackend implements SessionBackend {
|
|
|
191
209
|
private resolveJwt;
|
|
192
210
|
private readJwtFromBytecloudKeychain;
|
|
193
211
|
spawn(_bin: string, _args: string[], _opts: SpawnOpts): void;
|
|
194
|
-
write(data: string):
|
|
212
|
+
write(data: string): boolean;
|
|
195
213
|
resize(_cols: number, _rows: number): void;
|
|
196
214
|
onData(cb: (data: string) => void): void;
|
|
197
215
|
onExit(cb: (code: number | null, signal: string | null) => void): void;
|
|
198
216
|
kill(): void;
|
|
199
|
-
destroySession(): Promise<
|
|
217
|
+
destroySession(): Promise<SessionDestroyResult>;
|
|
218
|
+
abortDestroySession(): Promise<void>;
|
|
219
|
+
commitDestroySession(): void;
|
|
220
|
+
prepareShutdownDetach(): Promise<SessionShutdownDetachResult>;
|
|
221
|
+
abortShutdownDetach(): Promise<SessionShutdownDetachResult>;
|
|
222
|
+
commitShutdownDetach(): void;
|
|
200
223
|
getChildPid(): number | null;
|
|
201
224
|
captureCurrentScreen(): string;
|
|
202
225
|
captureViewport(): string;
|
|
@@ -240,8 +263,8 @@ export declare class RiffBackend implements SessionBackend {
|
|
|
240
263
|
* Post-await adoption gate for a freshly created/followed-up task id.
|
|
241
264
|
* - closing(/close 竞态窗口):这个 late task 已经没有会话可服务——立即取消
|
|
242
265
|
* (有界+一次重试),绝不 stream/登记,防远端 orphan;
|
|
243
|
-
* - killed(detach
|
|
244
|
-
* (任务合法续跑,重启后 follow-up 接上);
|
|
266
|
+
* - killed / shutdownDetaching(detach):登记 id 让 daemon 持久化血缘,
|
|
267
|
+
* 但不 stream(任务合法续跑,重启后 follow-up 接上);
|
|
245
268
|
* - 正常:登记 + 由调用方启动 stream。
|
|
246
269
|
*/
|
|
247
270
|
private adoptLateTask;
|
|
@@ -251,6 +274,7 @@ export declare class RiffBackend implements SessionBackend {
|
|
|
251
274
|
* with no UI left to clear it. */
|
|
252
275
|
private buildRepos;
|
|
253
276
|
private cancelTask;
|
|
277
|
+
private cancelTaskWithRetry;
|
|
254
278
|
private streamTask;
|
|
255
279
|
private handleSseEvent;
|
|
256
280
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"riff-backend.d.ts","sourceRoot":"","sources":["../../../src/adapters/backend/riff-backend.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"riff-backend.d.ts","sourceRoot":"","sources":["../../../src/adapters/backend/riff-backend.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,2BAA2B,EAC3B,SAAS,EACV,MAAM,YAAY,CAAC;AAqCpB;;;;;;;GAOG;AACH,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,6CAA8C,CAAC;AAClF,eAAO,MAAM,qBAAqB,wBAAyB,CAAC;AAC5D,MAAM,MAAM,kBAAkB,GAAG,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAatE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;mDAC+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;6DACyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oEAAoE;IACp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250
|
cancelTimeoutMs = 4_000;
|
|
251
251
|
createTimeoutMs = 10_000;
|
|
252
252
|
destroyDeadlineMs = 20_000;
|
|
253
|
+
/** Exact late/current task whose close cancellation failed. Retained across
|
|
254
|
+
* the prepare-close handshake so the daemon can persist a retry handle. */
|
|
255
|
+
closeFailureTaskId = null;
|
|
256
|
+
closeFailureError = null;
|
|
257
|
+
closeLateTaskHandled = false;
|
|
258
|
+
closePrepared = false;
|
|
259
|
+
closeAttempt = null;
|
|
260
|
+
destroyInFlight = null;
|
|
261
|
+
cancelInFlight = null;
|
|
262
|
+
abortInFlight = null;
|
|
263
|
+
/** Graceful daemon shutdown is a non-cancelling two-phase detach. It fences
|
|
264
|
+
* only writes arriving after prepare; writes already appended to writeChain
|
|
265
|
+
* still drain so a late child id can be durably handed to the daemon. */
|
|
266
|
+
shutdownDetaching = false;
|
|
267
|
+
shutdownDetachPrepared = false;
|
|
268
|
+
shutdownDetachAttempt = null;
|
|
269
|
+
shutdownDetachInFlight = null;
|
|
270
|
+
shutdownDetachAbortInFlight = null;
|
|
253
271
|
/** Serializes write() → createTask/followUp. Without this, a second message
|
|
254
272
|
* arriving before the first task-execute HTTP returns would see
|
|
255
273
|
* currentTaskId === null and create a duplicate task. */
|
|
@@ -325,8 +343,16 @@ export class RiffBackend {
|
|
|
325
343
|
// No actual process to spawn. Task creation happens on first write().
|
|
326
344
|
}
|
|
327
345
|
write(data) {
|
|
328
|
-
if (this.killed
|
|
329
|
-
return;
|
|
346
|
+
if (this.killed)
|
|
347
|
+
return false;
|
|
348
|
+
if (this.shutdownDetaching) {
|
|
349
|
+
logger.warn('[riff] write rejected while graceful shutdown detach is preparing/prepared');
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
if (this.closing) {
|
|
353
|
+
logger.warn('[riff] write rejected while explicit close is preparing/prepared');
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
330
356
|
const { text, attachments } = this.extractAttachments(data);
|
|
331
357
|
this.writeChain = this.writeChain
|
|
332
358
|
.then(async () => {
|
|
@@ -348,6 +374,7 @@ export class RiffBackend {
|
|
|
348
374
|
.catch((err) => {
|
|
349
375
|
logger.warn(`[riff] queued write failed: ${err}`);
|
|
350
376
|
});
|
|
377
|
+
return true;
|
|
351
378
|
}
|
|
352
379
|
resize(_cols, _rows) {
|
|
353
380
|
// No terminal screen to resize.
|
|
@@ -372,7 +399,7 @@ export class RiffBackend {
|
|
|
372
399
|
this.exitCb?.(0, null);
|
|
373
400
|
}
|
|
374
401
|
async destroySession() {
|
|
375
|
-
// /close
|
|
402
|
+
// /close 必须把远端任务真正取消掉——fire-and-forget
|
|
376
403
|
// 在 worker 紧接 process.exit 时大概率发不出去,已关闭话题的远端 agent 会
|
|
377
404
|
// 继续拿着注入的凭证发消息。有界 await + 一次重试,失败也明确留痕。
|
|
378
405
|
//
|
|
@@ -380,11 +407,31 @@ export class RiffBackend {
|
|
|
380
407
|
// currentTaskId 还是 null/旧值,直接 cancel 会漏掉 late task。先立 closing
|
|
381
408
|
// 门(拒新写 + 令 in-flight 完成后自取消),再有界等 writeChain 沉降,最后
|
|
382
409
|
// cancel 沉降后的 current task。
|
|
410
|
+
if (this.shutdownDetaching) {
|
|
411
|
+
return {
|
|
412
|
+
ok: false,
|
|
413
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
414
|
+
error: 'shutdown_detach_in_progress',
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
if (this.destroyInFlight)
|
|
418
|
+
return this.destroyInFlight;
|
|
419
|
+
if (this.closePrepared) {
|
|
420
|
+
return {
|
|
421
|
+
ok: true,
|
|
422
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
const attempt = Symbol('riff-close-prepare');
|
|
426
|
+
this.closeAttempt = attempt;
|
|
383
427
|
this.closing = true;
|
|
428
|
+
this.closeFailureTaskId = null;
|
|
429
|
+
this.closeFailureError = null;
|
|
430
|
+
this.closeLateTaskHandled = false;
|
|
384
431
|
// 预算层级(单调覆盖,无内层 race——writeChain 本身有界):
|
|
385
432
|
// create/follow-up fetch 10s + late cancel 4s×2 = chain 最坏 18s
|
|
386
433
|
// own cancel 4s×2 = 8s(与 late 情形互斥:closing 分支不登记 current)
|
|
387
|
-
// → destroySession 总 deadline 20s → worker close
|
|
434
|
+
// → destroySession 总 deadline 20s → worker close handshake 22s
|
|
388
435
|
// → daemon SIGTERM backstop 24s / SIGKILL 29s。
|
|
389
436
|
// 对 writeChain 只整体 await:单独给它小窗口会在窗口边缘掐掉链内的
|
|
390
437
|
// late cancel(create 于 t≈窗口末返回 → cancel 尚 pending → teardown 提前
|
|
@@ -394,25 +441,220 @@ export class RiffBackend {
|
|
|
394
441
|
await this.writeChain;
|
|
395
442
|
}
|
|
396
443
|
catch { /* writeChain never rejects (caught internally) */ }
|
|
397
|
-
if (this.
|
|
444
|
+
if (this.closeAttempt !== attempt) {
|
|
445
|
+
return {
|
|
446
|
+
ok: false,
|
|
447
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
448
|
+
error: 'close_aborted',
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
if (this.closeFailureTaskId) {
|
|
452
|
+
return {
|
|
453
|
+
ok: false,
|
|
454
|
+
taskId: this.closeFailureTaskId,
|
|
455
|
+
error: this.closeFailureError ?? 'late_task_cancel_failed',
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
// A task materialized while closing was already cancelled inside the
|
|
459
|
+
// writeChain. Do not then cancel its stale parent lineage as if it were
|
|
460
|
+
// still the active execution.
|
|
461
|
+
if (!this.closeLateTaskHandled && this.currentTaskId && !this.taskDone) {
|
|
398
462
|
const id = this.currentTaskId;
|
|
399
|
-
|
|
400
|
-
|
|
463
|
+
const cancelled = await this.cancelTaskWithRetry(id, 'close');
|
|
464
|
+
// abortDestroySession invalidates the exact attempt before waiting for
|
|
465
|
+
// an already-issued cancellation. A late successful HTTP response must
|
|
466
|
+
// not resurrect that aborted generation as a prepared close.
|
|
467
|
+
if (this.closeAttempt !== attempt || !this.closing) {
|
|
468
|
+
return {
|
|
469
|
+
ok: false,
|
|
470
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
471
|
+
error: 'close_aborted',
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
if (cancelled) {
|
|
401
475
|
logger.info(`[riff] task ${id} cancelled on close`);
|
|
402
476
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
logger.warn(`[riff] task-cancel failed on close (task ${id} may keep running remotely): ${err2}`);
|
|
410
|
-
}
|
|
477
|
+
else {
|
|
478
|
+
return {
|
|
479
|
+
ok: false,
|
|
480
|
+
taskId: id,
|
|
481
|
+
error: this.closeFailureError ?? 'task_cancel_failed',
|
|
482
|
+
};
|
|
411
483
|
}
|
|
412
484
|
}
|
|
485
|
+
if (this.closeAttempt !== attempt || !this.closing) {
|
|
486
|
+
return {
|
|
487
|
+
ok: false,
|
|
488
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
489
|
+
error: 'close_aborted',
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
ok: true,
|
|
494
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
495
|
+
};
|
|
413
496
|
})();
|
|
414
|
-
|
|
415
|
-
|
|
497
|
+
this.destroyInFlight = Promise.race([
|
|
498
|
+
teardown,
|
|
499
|
+
new Promise(resolve => setTimeout(() => resolve({
|
|
500
|
+
ok: false,
|
|
501
|
+
...(this.closeFailureTaskId || this.currentTaskId
|
|
502
|
+
? { taskId: this.closeFailureTaskId ?? this.currentTaskId }
|
|
503
|
+
: {}),
|
|
504
|
+
error: 'close_timeout',
|
|
505
|
+
}), this.destroyDeadlineMs)),
|
|
506
|
+
]).then(async (result) => {
|
|
507
|
+
// Promise.race and the teardown continuation each add a microtask
|
|
508
|
+
// boundary. Revalidate the generation immediately before publishing the
|
|
509
|
+
// prepared bit so a concurrent abort can never be overwritten.
|
|
510
|
+
if (result.ok && (this.closeAttempt !== attempt || !this.closing)) {
|
|
511
|
+
result = {
|
|
512
|
+
ok: false,
|
|
513
|
+
...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
|
|
514
|
+
error: 'close_aborted',
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
if (result.ok) {
|
|
518
|
+
this.closePrepared = true;
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
// A failed prepare is not a terminal close. Restore admission so the
|
|
522
|
+
// still-active durable owner can accept a follow-up or a close retry.
|
|
523
|
+
await this.abortDestroySession();
|
|
524
|
+
}
|
|
525
|
+
return result;
|
|
526
|
+
}).finally(() => {
|
|
527
|
+
this.destroyInFlight = null;
|
|
528
|
+
});
|
|
529
|
+
return this.destroyInFlight;
|
|
530
|
+
}
|
|
531
|
+
async abortDestroySession() {
|
|
532
|
+
if (this.killed)
|
|
533
|
+
return;
|
|
534
|
+
if (this.abortInFlight)
|
|
535
|
+
return this.abortInFlight;
|
|
536
|
+
this.closeAttempt = null;
|
|
537
|
+
this.closePrepared = false;
|
|
538
|
+
const pendingCancel = this.cancelInFlight;
|
|
539
|
+
this.abortInFlight = (async () => {
|
|
540
|
+
// A close timeout can win Promise.race after task-cancel was already
|
|
541
|
+
// issued. Reopening admission before that request settles lets a new
|
|
542
|
+
// follow-up race a late successful cancellation of its parent. Keep the
|
|
543
|
+
// backend fenced until the exact cancellation attempt reaches terminal.
|
|
544
|
+
if (pendingCancel) {
|
|
545
|
+
try {
|
|
546
|
+
await pendingCancel;
|
|
547
|
+
}
|
|
548
|
+
catch { /* cancel helper returns boolean */ }
|
|
549
|
+
}
|
|
550
|
+
if (this.killed || this.closeAttempt !== null || this.closePrepared)
|
|
551
|
+
return;
|
|
552
|
+
this.closing = false;
|
|
553
|
+
this.closeFailureTaskId = null;
|
|
554
|
+
this.closeFailureError = null;
|
|
555
|
+
this.closeLateTaskHandled = false;
|
|
556
|
+
logger.info('[riff] explicit close aborted; write admission restored');
|
|
557
|
+
})().finally(() => {
|
|
558
|
+
this.abortInFlight = null;
|
|
559
|
+
});
|
|
560
|
+
return this.abortInFlight;
|
|
561
|
+
}
|
|
562
|
+
commitDestroySession() {
|
|
563
|
+
// The daemon has durably published the closed row. Keep admission fenced
|
|
564
|
+
// until the worker immediately detaches/exits.
|
|
565
|
+
this.closePrepared = false;
|
|
566
|
+
this.closeAttempt = null;
|
|
567
|
+
this.closing = true;
|
|
568
|
+
}
|
|
569
|
+
async prepareShutdownDetach() {
|
|
570
|
+
if (this.shutdownDetachInFlight)
|
|
571
|
+
return this.shutdownDetachInFlight;
|
|
572
|
+
if (this.shutdownDetachPrepared) {
|
|
573
|
+
return { ok: true, taskId: this.currentTaskId };
|
|
574
|
+
}
|
|
575
|
+
if (this.killed) {
|
|
576
|
+
return { ok: false, taskId: this.currentTaskId, error: 'backend_killed' };
|
|
577
|
+
}
|
|
578
|
+
if (this.closing || this.destroyInFlight || this.closePrepared) {
|
|
579
|
+
return { ok: false, taskId: this.currentTaskId, error: 'explicit_close_in_progress' };
|
|
580
|
+
}
|
|
581
|
+
const attempt = Symbol('riff-shutdown-detach');
|
|
582
|
+
this.shutdownDetachAttempt = attempt;
|
|
583
|
+
this.shutdownDetaching = true;
|
|
584
|
+
// Existing SSE delivery is presentation-only. Stop it now, but do not
|
|
585
|
+
// cancel the remote task. Any create/follow-up already accepted before the
|
|
586
|
+
// fence remains in writeChain and is allowed to materialize below.
|
|
587
|
+
this.abortController?.abort();
|
|
588
|
+
const drain = (async () => {
|
|
589
|
+
try {
|
|
590
|
+
await this.writeChain;
|
|
591
|
+
}
|
|
592
|
+
catch { /* writeChain catches its own failures */ }
|
|
593
|
+
if (this.killed || this.shutdownDetachAttempt !== attempt || !this.shutdownDetaching) {
|
|
594
|
+
return { ok: false, taskId: this.currentTaskId, error: 'shutdown_detach_aborted' };
|
|
595
|
+
}
|
|
596
|
+
if (this.closing || this.closePrepared) {
|
|
597
|
+
return { ok: false, taskId: this.currentTaskId, error: 'explicit_close_in_progress' };
|
|
598
|
+
}
|
|
599
|
+
this.shutdownDetachPrepared = true;
|
|
600
|
+
logger.info(`[riff] graceful shutdown detach prepared`
|
|
601
|
+
+ `${this.currentTaskId ? ` (task ${this.currentTaskId})` : ' (no task lineage)'}`);
|
|
602
|
+
return { ok: true, taskId: this.currentTaskId };
|
|
603
|
+
})();
|
|
604
|
+
this.shutdownDetachInFlight = drain.finally(() => {
|
|
605
|
+
this.shutdownDetachInFlight = null;
|
|
606
|
+
});
|
|
607
|
+
return this.shutdownDetachInFlight;
|
|
608
|
+
}
|
|
609
|
+
async abortShutdownDetach() {
|
|
610
|
+
if (this.killed) {
|
|
611
|
+
return { ok: false, taskId: this.currentTaskId, error: 'backend_killed' };
|
|
612
|
+
}
|
|
613
|
+
if (this.shutdownDetachAbortInFlight)
|
|
614
|
+
return this.shutdownDetachAbortInFlight;
|
|
615
|
+
const pending = this.shutdownDetachInFlight;
|
|
616
|
+
const pendingCancel = this.cancelInFlight;
|
|
617
|
+
this.shutdownDetachAttempt = null;
|
|
618
|
+
this.shutdownDetachPrepared = false;
|
|
619
|
+
this.shutdownDetachAbortInFlight = (async () => {
|
|
620
|
+
// Normally shutdown detach never cancels a remote task. Still wait for
|
|
621
|
+
// any exact cancellation already issued by an overlapping explicit close
|
|
622
|
+
// before reopening admission, otherwise its late result could invalidate
|
|
623
|
+
// a newly accepted follow-up.
|
|
624
|
+
await Promise.all([
|
|
625
|
+
pending ? pending.catch(() => undefined) : Promise.resolve(),
|
|
626
|
+
pendingCancel ? pendingCancel.catch(() => false) : Promise.resolve(),
|
|
627
|
+
]);
|
|
628
|
+
if (this.killed) {
|
|
629
|
+
return { ok: false, taskId: this.currentTaskId, error: 'backend_killed' };
|
|
630
|
+
}
|
|
631
|
+
if (this.closing || this.shutdownDetachAttempt !== null) {
|
|
632
|
+
return {
|
|
633
|
+
ok: false,
|
|
634
|
+
taskId: this.currentTaskId,
|
|
635
|
+
error: this.closing ? 'explicit_close_in_progress' : 'new_shutdown_detach_in_progress',
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
this.shutdownDetaching = false;
|
|
639
|
+
// prepare stopped SSE before the persistence ACK. If shutdown is
|
|
640
|
+
// aborted, reconnect the exact current task so the still-live owner
|
|
641
|
+
// resumes normal output and completion tracking.
|
|
642
|
+
if (this.currentTaskId && !this.taskDone) {
|
|
643
|
+
this.reconnectAttempts = 0;
|
|
644
|
+
void this.streamTask(this.currentTaskId);
|
|
645
|
+
}
|
|
646
|
+
logger.info('[riff] graceful shutdown detach aborted; write admission restored');
|
|
647
|
+
return { ok: true, taskId: this.currentTaskId };
|
|
648
|
+
})().finally(() => {
|
|
649
|
+
this.shutdownDetachAbortInFlight = null;
|
|
650
|
+
});
|
|
651
|
+
return this.shutdownDetachAbortInFlight;
|
|
652
|
+
}
|
|
653
|
+
commitShutdownDetach() {
|
|
654
|
+
this.shutdownDetachPrepared = false;
|
|
655
|
+
this.shutdownDetachAttempt = null;
|
|
656
|
+
// Keep admission fenced until the worker exits immediately after commit.
|
|
657
|
+
this.shutdownDetaching = true;
|
|
416
658
|
}
|
|
417
659
|
getChildPid() {
|
|
418
660
|
return null;
|
|
@@ -648,8 +890,8 @@ export class RiffBackend {
|
|
|
648
890
|
* Post-await adoption gate for a freshly created/followed-up task id.
|
|
649
891
|
* - closing(/close 竞态窗口):这个 late task 已经没有会话可服务——立即取消
|
|
650
892
|
* (有界+一次重试),绝不 stream/登记,防远端 orphan;
|
|
651
|
-
* - killed(detach
|
|
652
|
-
* (任务合法续跑,重启后 follow-up 接上);
|
|
893
|
+
* - killed / shutdownDetaching(detach):登记 id 让 daemon 持久化血缘,
|
|
894
|
+
* 但不 stream(任务合法续跑,重启后 follow-up 接上);
|
|
653
895
|
* - 正常:登记 + 由调用方启动 stream。
|
|
654
896
|
*/
|
|
655
897
|
async adoptLateTask(taskId) {
|
|
@@ -657,22 +899,22 @@ export class RiffBackend {
|
|
|
657
899
|
// 在 writeChain 内 await——destroySession 等 writeChain 沉降时就能把这次
|
|
658
900
|
// 取消一起等到(void 触发会在 worker exit 时被掐断)。
|
|
659
901
|
logger.info(`[riff] task ${taskId} created during close — cancelling late task`);
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
902
|
+
this.closeLateTaskHandled = true;
|
|
903
|
+
// Preserve the exact newest lineage even when cancellation succeeds.
|
|
904
|
+
// If the daemon cannot durably commit the close and sends abort, the
|
|
905
|
+
// next follow-up must continue from this child rather than its stale
|
|
906
|
+
// parent. Publishing before the cancel also makes a failed cancel
|
|
907
|
+
// retryable by the daemon.
|
|
908
|
+
this.currentTaskId = taskId;
|
|
909
|
+
this.taskIdCb?.(taskId);
|
|
910
|
+
const cancelled = await this.cancelTaskWithRetry(taskId, 'late-task close');
|
|
911
|
+
if (!cancelled)
|
|
912
|
+
this.taskDone = false;
|
|
671
913
|
return false;
|
|
672
914
|
}
|
|
673
915
|
this.currentTaskId = taskId;
|
|
674
916
|
this.taskIdCb?.(taskId);
|
|
675
|
-
if (this.killed)
|
|
917
|
+
if (this.killed || this.shutdownDetaching)
|
|
676
918
|
return false;
|
|
677
919
|
return true;
|
|
678
920
|
}
|
|
@@ -699,6 +941,35 @@ export class RiffBackend {
|
|
|
699
941
|
if (!resp.ok)
|
|
700
942
|
throw new Error(`task-cancel HTTP ${resp.status}`);
|
|
701
943
|
}
|
|
944
|
+
async cancelTaskWithRetry(taskId, context) {
|
|
945
|
+
const operation = (async () => {
|
|
946
|
+
try {
|
|
947
|
+
await this.cancelTask(taskId);
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
catch {
|
|
951
|
+
try {
|
|
952
|
+
await this.cancelTask(taskId);
|
|
953
|
+
logger.info(`[riff] task ${taskId} cancelled on ${context} (retry)`);
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
catch (err) {
|
|
957
|
+
this.closeFailureTaskId = taskId;
|
|
958
|
+
this.closeFailureError = err instanceof Error ? err.message : String(err);
|
|
959
|
+
logger.warn(`[riff] ${context} cancel failed (task ${taskId} may keep running remotely): ${err}`);
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
})();
|
|
964
|
+
this.cancelInFlight = operation;
|
|
965
|
+
try {
|
|
966
|
+
return await operation;
|
|
967
|
+
}
|
|
968
|
+
finally {
|
|
969
|
+
if (this.cancelInFlight === operation)
|
|
970
|
+
this.cancelInFlight = null;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
702
973
|
async streamTask(taskId) {
|
|
703
974
|
const url = `${this.config.baseUrl}/api2/task-stream?id=${encodeURIComponent(taskId)}`;
|
|
704
975
|
const headers = {};
|
|
@@ -885,9 +1156,18 @@ export class RiffBackend {
|
|
|
885
1156
|
const kind = data['kind'];
|
|
886
1157
|
const group = data['group']
|
|
887
1158
|
?? data['payload']?.['group'];
|
|
888
|
-
// stdout logs are the real output stream — emit as data regardless of logLevel
|
|
1159
|
+
// stdout logs are the real output stream — emit as data regardless of logLevel.
|
|
1160
|
+
// riff stores each stdout log line BARE (no trailing newline): the runner's
|
|
1161
|
+
// logger persists `message` verbatim (Logger.createRootLog) and the SSE `log`
|
|
1162
|
+
// event carries it as `text` unchanged (taskLog.ts runnerLog*→text: log.message).
|
|
1163
|
+
// For codex_app_server that message is one `JSON.stringify(event)` per line. Since
|
|
1164
|
+
// emitText only NORMALIZES existing newlines and never adds a separator, emitting
|
|
1165
|
+
// the bare text would butt consecutive events together into one unreadable wall.
|
|
1166
|
+
// Re-add the per-line separator here (safe & non-duplicating precisely because the
|
|
1167
|
+
// stored line has no trailing newline). NOTE: the `output`/chunk path stays raw —
|
|
1168
|
+
// those chunks may be partial lines, so they must NOT get a synthetic newline.
|
|
889
1169
|
if (group === 'stdout' && text) {
|
|
890
|
-
this.emitText(text);
|
|
1170
|
+
this.emitText(`${text}\n`);
|
|
891
1171
|
}
|
|
892
1172
|
else if (this.config.logLevel === 'verbose' && text) {
|
|
893
1173
|
this.emitLine(`[riff:${kind ?? 'log'}] ${text}`);
|