oh-my-codex 0.11.13 → 0.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/Cargo.lock +5 -5
- package/Cargo.toml +1 -1
- package/README.md +27 -17
- package/crates/omx-runtime/src/main.rs +6 -2
- package/dist/agents/native-config.js +1 -1
- package/dist/agents/native-config.js.map +1 -1
- package/dist/cli/__tests__/autoresearch-guided.test.js +74 -2
- package/dist/cli/__tests__/autoresearch-guided.test.js.map +1 -1
- package/dist/cli/__tests__/cleanup.test.js +22 -30
- package/dist/cli/__tests__/cleanup.test.js.map +1 -1
- package/dist/cli/__tests__/error-handling-warnings.test.js +3 -1
- package/dist/cli/__tests__/error-handling-warnings.test.js.map +1 -1
- package/dist/cli/__tests__/index.test.js +217 -4
- package/dist/cli/__tests__/index.test.js.map +1 -1
- package/dist/cli/__tests__/setup-refresh.test.js +49 -9
- package/dist/cli/__tests__/setup-refresh.test.js.map +1 -1
- package/dist/cli/__tests__/setup-scope.test.js +9 -0
- package/dist/cli/__tests__/setup-scope.test.js.map +1 -1
- package/dist/cli/__tests__/team.test.js +136 -11
- package/dist/cli/__tests__/team.test.js.map +1 -1
- package/dist/cli/__tests__/uninstall.test.js +10 -0
- package/dist/cli/__tests__/uninstall.test.js.map +1 -1
- package/dist/cli/__tests__/windows-popup-loop-contract.test.js +1 -0
- package/dist/cli/__tests__/windows-popup-loop-contract.test.js.map +1 -1
- package/dist/cli/autoresearch-guided.d.ts.map +1 -1
- package/dist/cli/autoresearch-guided.js +2 -1
- package/dist/cli/autoresearch-guided.js.map +1 -1
- package/dist/cli/autoresearch.d.ts.map +1 -1
- package/dist/cli/autoresearch.js +2 -1
- package/dist/cli/autoresearch.js.map +1 -1
- package/dist/cli/cleanup.d.ts.map +1 -1
- package/dist/cli/cleanup.js +4 -2
- package/dist/cli/cleanup.js.map +1 -1
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +238 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/omx.js +2 -0
- package/dist/cli/omx.js.map +1 -1
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +41 -7
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/team.d.ts.map +1 -1
- package/dist/cli/team.js +16 -557
- package/dist/cli/team.js.map +1 -1
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +34 -9
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/config/__tests__/generator-idempotent.test.js +79 -2
- package/dist/config/__tests__/generator-idempotent.test.js.map +1 -1
- package/dist/config/__tests__/generator-notify.test.js +2 -0
- package/dist/config/__tests__/generator-notify.test.js.map +1 -1
- package/dist/config/codex-hooks.d.ts +11 -0
- package/dist/config/codex-hooks.d.ts.map +1 -0
- package/dist/config/codex-hooks.js +50 -0
- package/dist/config/codex-hooks.js.map +1 -0
- package/dist/config/generator.d.ts +5 -3
- package/dist/config/generator.d.ts.map +1 -1
- package/dist/config/generator.js +24 -14
- package/dist/config/generator.js.map +1 -1
- package/dist/hooks/__tests__/debugger-log-recency-contract.test.d.ts +2 -0
- package/dist/hooks/__tests__/debugger-log-recency-contract.test.d.ts.map +1 -0
- package/dist/hooks/__tests__/debugger-log-recency-contract.test.js +20 -0
- package/dist/hooks/__tests__/debugger-log-recency-contract.test.js.map +1 -0
- package/dist/hooks/__tests__/notify-fallback-watcher.test.js +236 -2
- package/dist/hooks/__tests__/notify-fallback-watcher.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.js +86 -0
- package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-auto-nudge.test.js +40 -0
- package/dist/hooks/__tests__/notify-hook-auto-nudge.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-managed-tmux.test.d.ts +2 -0
- package/dist/hooks/__tests__/notify-hook-managed-tmux.test.d.ts.map +1 -0
- package/dist/hooks/__tests__/notify-hook-managed-tmux.test.js +54 -0
- package/dist/hooks/__tests__/notify-hook-managed-tmux.test.js.map +1 -0
- package/dist/hooks/__tests__/notify-hook-modules.test.js +31 -0
- package/dist/hooks/__tests__/notify-hook-modules.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-ralph-resume.test.js +51 -0
- package/dist/hooks/__tests__/notify-hook-ralph-resume.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.d.ts +2 -0
- package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.d.ts.map +1 -0
- package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.js +136 -0
- package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.js.map +1 -0
- package/dist/hooks/__tests__/notify-hook-team-dispatch.test.js +120 -0
- package/dist/hooks/__tests__/notify-hook-team-dispatch.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.js +145 -20
- package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.js +116 -0
- package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.js.map +1 -1
- package/dist/hooks/__tests__/notify-hook-worker-idle.test.js +86 -0
- package/dist/hooks/__tests__/notify-hook-worker-idle.test.js.map +1 -1
- package/dist/hooks/__tests__/pre-context-gate-skills.test.js +1 -0
- package/dist/hooks/__tests__/pre-context-gate-skills.test.js.map +1 -1
- package/dist/hooks/extensibility/__tests__/runtime.test.js +49 -0
- package/dist/hooks/extensibility/__tests__/runtime.test.js.map +1 -1
- package/dist/hooks/extensibility/runtime.d.ts.map +1 -1
- package/dist/hooks/extensibility/runtime.js +10 -0
- package/dist/hooks/extensibility/runtime.js.map +1 -1
- package/dist/hooks/extensibility/types.d.ts +1 -1
- package/dist/hooks/extensibility/types.d.ts.map +1 -1
- package/dist/hooks/prompt-guidance-contract.d.ts.map +1 -1
- package/dist/hooks/prompt-guidance-contract.js +12 -8
- package/dist/hooks/prompt-guidance-contract.js.map +1 -1
- package/dist/hooks/session.d.ts +5 -1
- package/dist/hooks/session.d.ts.map +1 -1
- package/dist/hooks/session.js +10 -6
- package/dist/hooks/session.js.map +1 -1
- package/dist/hud/index.d.ts.map +1 -1
- package/dist/hud/index.js +6 -1
- package/dist/hud/index.js.map +1 -1
- package/dist/mcp/__tests__/bootstrap.test.js +0 -3
- package/dist/mcp/__tests__/bootstrap.test.js.map +1 -1
- package/dist/mcp/__tests__/code-intel-server.test.js +27 -1
- package/dist/mcp/__tests__/code-intel-server.test.js.map +1 -1
- package/dist/mcp/__tests__/server-lifecycle.test.js +0 -5
- package/dist/mcp/__tests__/server-lifecycle.test.js.map +1 -1
- package/dist/mcp/bootstrap.d.ts +1 -1
- package/dist/mcp/bootstrap.d.ts.map +1 -1
- package/dist/mcp/bootstrap.js +0 -1
- package/dist/mcp/bootstrap.js.map +1 -1
- package/dist/mcp/code-intel-server.d.ts +20 -0
- package/dist/mcp/code-intel-server.d.ts.map +1 -1
- package/dist/mcp/code-intel-server.js +6 -5
- package/dist/mcp/code-intel-server.js.map +1 -1
- package/dist/notifications/__tests__/idle-cooldown.test.js +24 -1
- package/dist/notifications/__tests__/idle-cooldown.test.js.map +1 -1
- package/dist/notifications/__tests__/reply-listener.test.js +20 -1
- package/dist/notifications/__tests__/reply-listener.test.js.map +1 -1
- package/dist/notifications/__tests__/tmux.test.js +41 -0
- package/dist/notifications/__tests__/tmux.test.js.map +1 -1
- package/dist/notifications/idle-cooldown.d.ts +13 -0
- package/dist/notifications/idle-cooldown.d.ts.map +1 -1
- package/dist/notifications/idle-cooldown.js +50 -16
- package/dist/notifications/idle-cooldown.js.map +1 -1
- package/dist/notifications/reply-listener.d.ts.map +1 -1
- package/dist/notifications/reply-listener.js +2 -0
- package/dist/notifications/reply-listener.js.map +1 -1
- package/dist/notifications/tmux.d.ts.map +1 -1
- package/dist/notifications/tmux.js +4 -0
- package/dist/notifications/tmux.js.map +1 -1
- package/dist/scripts/__tests__/codex-native-hook.test.d.ts +2 -0
- package/dist/scripts/__tests__/codex-native-hook.test.d.ts.map +1 -0
- package/dist/scripts/__tests__/codex-native-hook.test.js +720 -0
- package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -0
- package/dist/scripts/codex-native-hook.d.ts +22 -0
- package/dist/scripts/codex-native-hook.d.ts.map +1 -0
- package/dist/scripts/codex-native-hook.js +594 -0
- package/dist/scripts/codex-native-hook.js.map +1 -0
- package/dist/scripts/codex-native-pre-post.d.ts +26 -0
- package/dist/scripts/codex-native-pre-post.d.ts.map +1 -0
- package/dist/scripts/codex-native-pre-post.js +118 -0
- package/dist/scripts/codex-native-pre-post.js.map +1 -0
- package/dist/scripts/notify-fallback-watcher.js +262 -18
- package/dist/scripts/notify-fallback-watcher.js.map +1 -1
- package/dist/scripts/notify-hook/auto-nudge.d.ts.map +1 -1
- package/dist/scripts/notify-hook/auto-nudge.js +5 -6
- package/dist/scripts/notify-hook/auto-nudge.js.map +1 -1
- package/dist/scripts/notify-hook/log.d.ts +2 -2
- package/dist/scripts/notify-hook/log.d.ts.map +1 -1
- package/dist/scripts/notify-hook/log.js +10 -2
- package/dist/scripts/notify-hook/log.js.map +1 -1
- package/dist/scripts/notify-hook/managed-tmux.d.ts.map +1 -1
- package/dist/scripts/notify-hook/managed-tmux.js +2 -0
- package/dist/scripts/notify-hook/managed-tmux.js.map +1 -1
- package/dist/scripts/notify-hook/orchestration-intent.d.ts +18 -0
- package/dist/scripts/notify-hook/orchestration-intent.d.ts.map +1 -0
- package/dist/scripts/notify-hook/orchestration-intent.js +72 -0
- package/dist/scripts/notify-hook/orchestration-intent.js.map +1 -0
- package/dist/scripts/notify-hook/process-runner.js.map +1 -1
- package/dist/scripts/notify-hook/ralph-session-resume.d.ts.map +1 -1
- package/dist/scripts/notify-hook/ralph-session-resume.js +7 -0
- package/dist/scripts/notify-hook/ralph-session-resume.js.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.d.ts +15 -6
- package/dist/scripts/notify-hook/team-dispatch.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.js +125 -6
- package/dist/scripts/notify-hook/team-dispatch.js.map +1 -1
- package/dist/scripts/notify-hook/team-leader-nudge.d.ts +3 -2
- package/dist/scripts/notify-hook/team-leader-nudge.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-leader-nudge.js +165 -37
- package/dist/scripts/notify-hook/team-leader-nudge.js.map +1 -1
- package/dist/scripts/notify-hook/team-tmux-guard.d.ts +4 -1
- package/dist/scripts/notify-hook/team-tmux-guard.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-tmux-guard.js +33 -44
- package/dist/scripts/notify-hook/team-tmux-guard.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker.js +68 -5
- package/dist/scripts/notify-hook/team-worker.js.map +1 -1
- package/dist/scripts/notify-hook/utils.d.ts +1 -1
- package/dist/scripts/notify-hook/utils.d.ts.map +1 -1
- package/dist/scripts/notify-hook/utils.js.map +1 -1
- package/dist/scripts/notify-hook.js +55 -32
- package/dist/scripts/notify-hook.js.map +1 -1
- package/dist/team/__tests__/api-interop.test.js +344 -18
- package/dist/team/__tests__/api-interop.test.js.map +1 -1
- package/dist/team/__tests__/delivery-e2e-smoke.test.d.ts +2 -0
- package/dist/team/__tests__/delivery-e2e-smoke.test.d.ts.map +1 -0
- package/dist/team/__tests__/delivery-e2e-smoke.test.js +671 -0
- package/dist/team/__tests__/delivery-e2e-smoke.test.js.map +1 -0
- package/dist/team/__tests__/mcp-comm.test.js +5 -0
- package/dist/team/__tests__/mcp-comm.test.js.map +1 -1
- package/dist/team/__tests__/runtime.test.js +422 -12
- package/dist/team/__tests__/runtime.test.js.map +1 -1
- package/dist/team/__tests__/state.test.js +126 -8
- package/dist/team/__tests__/state.test.js.map +1 -1
- package/dist/team/__tests__/team-ops-contract.test.js +4 -0
- package/dist/team/__tests__/team-ops-contract.test.js.map +1 -1
- package/dist/team/__tests__/tmux-session.test.js +160 -0
- package/dist/team/__tests__/tmux-session.test.js.map +1 -1
- package/dist/team/__tests__/worker-bootstrap.test.js +19 -1
- package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -1
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js +95 -23
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/contracts.d.ts +11 -1
- package/dist/team/contracts.d.ts.map +1 -1
- package/dist/team/contracts.js +29 -0
- package/dist/team/contracts.js.map +1 -1
- package/dist/team/delivery-log.d.ts +14 -0
- package/dist/team/delivery-log.d.ts.map +1 -0
- package/dist/team/delivery-log.js +35 -0
- package/dist/team/delivery-log.js.map +1 -0
- package/dist/team/idle-nudge.d.ts +2 -2
- package/dist/team/idle-nudge.js +2 -2
- package/dist/team/mcp-comm.d.ts +4 -0
- package/dist/team/mcp-comm.d.ts.map +1 -1
- package/dist/team/mcp-comm.js +84 -1
- package/dist/team/mcp-comm.js.map +1 -1
- package/dist/team/pane-status.d.ts +149 -0
- package/dist/team/pane-status.d.ts.map +1 -0
- package/dist/team/pane-status.js +558 -0
- package/dist/team/pane-status.js.map +1 -0
- package/dist/team/reminder-intents.d.ts +11 -0
- package/dist/team/reminder-intents.d.ts.map +1 -0
- package/dist/team/reminder-intents.js +40 -0
- package/dist/team/reminder-intents.js.map +1 -0
- package/dist/team/runtime-cli.d.ts +1 -1
- package/dist/team/runtime-cli.js +2 -2
- package/dist/team/runtime-cli.js.map +1 -1
- package/dist/team/runtime.d.ts +2 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +407 -190
- package/dist/team/runtime.js.map +1 -1
- package/dist/team/scaling.d.ts.map +1 -1
- package/dist/team/scaling.js +6 -5
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/state/dispatch.d.ts +4 -1
- package/dist/team/state/dispatch.d.ts.map +1 -1
- package/dist/team/state/dispatch.js +59 -18
- package/dist/team/state/dispatch.js.map +1 -1
- package/dist/team/state/mailbox.d.ts.map +1 -1
- package/dist/team/state/mailbox.js +39 -2
- package/dist/team/state/mailbox.js.map +1 -1
- package/dist/team/state/monitor.d.ts +2 -1
- package/dist/team/state/monitor.d.ts.map +1 -1
- package/dist/team/state/monitor.js +30 -1
- package/dist/team/state/monitor.js.map +1 -1
- package/dist/team/state/types.d.ts +5 -2
- package/dist/team/state/types.d.ts.map +1 -1
- package/dist/team/state/types.js.map +1 -1
- package/dist/team/state.d.ts +30 -3
- package/dist/team/state.d.ts.map +1 -1
- package/dist/team/state.js +170 -2
- package/dist/team/state.js.map +1 -1
- package/dist/team/team-ops.d.ts +5 -1
- package/dist/team/team-ops.d.ts.map +1 -1
- package/dist/team/team-ops.js +4 -0
- package/dist/team/team-ops.js.map +1 -1
- package/dist/team/tmux-session.d.ts +2 -0
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +19 -3
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/worker-bootstrap.d.ts +4 -0
- package/dist/team/worker-bootstrap.d.ts.map +1 -1
- package/dist/team/worker-bootstrap.js +33 -6
- package/dist/team/worker-bootstrap.js.map +1 -1
- package/dist/utils/__tests__/paths.test.js +63 -1
- package/dist/utils/__tests__/paths.test.js.map +1 -1
- package/dist/utils/__tests__/platform-command.test.js +50 -4
- package/dist/utils/__tests__/platform-command.test.js.map +1 -1
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +44 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/platform-command.d.ts.map +1 -1
- package/dist/utils/platform-command.js +13 -5
- package/dist/utils/platform-command.js.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +10 -1
- package/dist/utils/sleep.js.map +1 -1
- package/package.json +1 -1
- package/prompts/analyst.md +2 -2
- package/prompts/api-reviewer.md +2 -2
- package/prompts/architect.md +2 -2
- package/prompts/build-fixer.md +2 -2
- package/prompts/code-reviewer.md +2 -2
- package/prompts/code-simplifier.md +1 -1
- package/prompts/critic.md +2 -2
- package/prompts/debugger.md +3 -2
- package/prompts/dependency-expert.md +2 -2
- package/prompts/designer.md +2 -2
- package/prompts/executor.md +3 -2
- package/prompts/explore.md +2 -2
- package/prompts/git-master.md +2 -2
- package/prompts/information-architect.md +2 -2
- package/prompts/performance-reviewer.md +2 -2
- package/prompts/planner.md +3 -2
- package/prompts/product-analyst.md +2 -2
- package/prompts/product-manager.md +2 -2
- package/prompts/qa-tester.md +2 -2
- package/prompts/quality-reviewer.md +2 -2
- package/prompts/quality-strategist.md +2 -2
- package/prompts/researcher.md +2 -2
- package/prompts/security-reviewer.md +2 -2
- package/prompts/sisyphus-lite.md +2 -2
- package/prompts/style-reviewer.md +2 -2
- package/prompts/team-executor.md +2 -2
- package/prompts/test-engineer.md +2 -2
- package/prompts/ux-researcher.md +2 -2
- package/prompts/verifier.md +3 -2
- package/prompts/vision.md +2 -2
- package/prompts/writer.md +2 -2
- package/skills/team/SKILL.md +18 -33
- package/src/scripts/__tests__/codex-native-hook.test.ts +931 -0
- package/src/scripts/codex-native-hook.ts +721 -0
- package/src/scripts/codex-native-pre-post.ts +161 -0
- package/src/scripts/notify-fallback-watcher.ts +318 -26
- package/src/scripts/notify-hook/auto-nudge.ts +5 -10
- package/src/scripts/notify-hook/log.ts +18 -4
- package/src/scripts/notify-hook/managed-tmux.ts +1 -0
- package/src/scripts/notify-hook/orchestration-intent.ts +82 -0
- package/src/scripts/notify-hook/process-runner.ts +4 -4
- package/src/scripts/notify-hook/ralph-session-resume.ts +9 -0
- package/src/scripts/notify-hook/team-dispatch.ts +134 -6
- package/src/scripts/notify-hook/team-leader-nudge.ts +183 -37
- package/src/scripts/notify-hook/team-tmux-guard.ts +35 -43
- package/src/scripts/notify-hook/team-worker.ts +73 -4
- package/src/scripts/notify-hook/utils.ts +1 -1
- package/src/scripts/notify-hook.ts +64 -32
- package/templates/AGENTS.md +21 -11
- package/README.de.md +0 -263
- package/README.el.md +0 -223
- package/README.es.md +0 -263
- package/README.fr.md +0 -263
- package/README.it.md +0 -263
- package/README.ja.md +0 -264
- package/README.ko.md +0 -264
- package/README.pl.md +0 -216
- package/README.pt.md +0 -263
- package/README.ru.md +0 -263
- package/README.tr.md +0 -263
- package/README.vi.md +0 -223
- package/README.zh-TW.md +0 -293
- package/README.zh.md +0 -264
- package/dist/mcp/__tests__/team-server-cleanup.test.d.ts +0 -2
- package/dist/mcp/__tests__/team-server-cleanup.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/team-server-cleanup.test.js +0 -219
- package/dist/mcp/__tests__/team-server-cleanup.test.js.map +0 -1
- package/dist/mcp/__tests__/team-server-runtime-deps.test.d.ts +0 -2
- package/dist/mcp/__tests__/team-server-runtime-deps.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/team-server-runtime-deps.test.js +0 -13
- package/dist/mcp/__tests__/team-server-runtime-deps.test.js.map +0 -1
- package/dist/mcp/__tests__/team-server-wait.test.d.ts +0 -2
- package/dist/mcp/__tests__/team-server-wait.test.d.ts.map +0 -1
- package/dist/mcp/__tests__/team-server-wait.test.js +0 -155
- package/dist/mcp/__tests__/team-server-wait.test.js.map +0 -1
- package/dist/mcp/team-server.d.ts +0 -24
- package/dist/mcp/team-server.d.ts.map +0 -1
- package/dist/mcp/team-server.js +0 -482
- package/dist/mcp/team-server.js.map +0 -1
|
@@ -12,6 +12,7 @@ import { checkWorkerPanesAlive, isLeaderStale, maybeNudgeTeamLeader, resolveLead
|
|
|
12
12
|
import { DEFAULT_MARKER } from './tmux-hook-engine.js';
|
|
13
13
|
import { isTerminalPhase } from './notify-hook/utils.js';
|
|
14
14
|
import { isSessionStale, readSessionState } from '../hooks/session.js';
|
|
15
|
+
import { DEFAULT_SUBAGENT_ACTIVE_WINDOW_MS, readSubagentSessionSummary, } from '../subagents/tracker.js';
|
|
15
16
|
function argValue(name, fallback = '') {
|
|
16
17
|
const idx = process.argv.indexOf(name);
|
|
17
18
|
if (idx < 0 || idx + 1 >= process.argv.length)
|
|
@@ -64,6 +65,7 @@ const authorityOnly = process.argv.includes('--authority-only');
|
|
|
64
65
|
// ack budget so leaderless team dispatch + stale-alert recovery do not feel
|
|
65
66
|
// laggy between native notify-hook turns.
|
|
66
67
|
const pollMs = Math.max(50, asNumber(argValue('--poll-ms', '250'), 250));
|
|
68
|
+
const idleMaxPollMs = Math.max(pollMs, asNumber(argValue('--idle-max-poll-ms', process.env.OMX_NOTIFY_FALLBACK_IDLE_MAX_POLL_MS || '1000'), 1000));
|
|
67
69
|
const parentPid = Math.trunc(asNumber(argValue('--parent-pid', String(process.ppid || 0)), process.ppid || 0));
|
|
68
70
|
const startedAt = Date.now();
|
|
69
71
|
const fileWindowMs = runOnce ? 15000 : 30000;
|
|
@@ -119,6 +121,8 @@ let lastRalphContinueSteer = {
|
|
|
119
121
|
pane_id: '',
|
|
120
122
|
pane_current_command: '',
|
|
121
123
|
current_phase: '',
|
|
124
|
+
subagent_session_id: '',
|
|
125
|
+
active_subagent_thread_ids: [],
|
|
122
126
|
shared_timestamp_path: ralphSteerTimestampPath,
|
|
123
127
|
shared_last_sent_at: '',
|
|
124
128
|
singleton_lock_path: ralphSteerLockPath,
|
|
@@ -128,6 +132,14 @@ let lastParentGuard = {
|
|
|
128
132
|
state_path: '',
|
|
129
133
|
current_phase: '',
|
|
130
134
|
};
|
|
135
|
+
let lastAuthorityBackoff = {
|
|
136
|
+
active: false,
|
|
137
|
+
reason: '',
|
|
138
|
+
primary_pid: null,
|
|
139
|
+
primary_last_tick_at: '',
|
|
140
|
+
freshness_ms: null,
|
|
141
|
+
threshold_ms: null,
|
|
142
|
+
};
|
|
131
143
|
const AUTO_NUDGE_STALL_MS = Math.max(pollMs, asNumber(process.env.OMX_NOTIFY_FALLBACK_AUTO_NUDGE_STALL_MS || '5000', 5000));
|
|
132
144
|
let lastFallbackAutoNudge = {
|
|
133
145
|
enabled: true,
|
|
@@ -141,12 +153,54 @@ let lastFallbackAutoNudge = {
|
|
|
141
153
|
last_nudged_signature: '',
|
|
142
154
|
last_nudged_at: '',
|
|
143
155
|
};
|
|
156
|
+
let adaptivePollState = {
|
|
157
|
+
enabled: true,
|
|
158
|
+
base_ms: pollMs,
|
|
159
|
+
max_ms: idleMaxPollMs,
|
|
160
|
+
current_ms: pollMs,
|
|
161
|
+
idle_streak: 0,
|
|
162
|
+
last_tick_at: null,
|
|
163
|
+
last_activity_at: null,
|
|
164
|
+
last_activity_reason: 'init',
|
|
165
|
+
};
|
|
144
166
|
function eventLog(event) {
|
|
145
167
|
return appendFile(logPath, `${JSON.stringify({ timestamp: new Date().toISOString(), ...event })}\n`).catch(() => { });
|
|
146
168
|
}
|
|
147
169
|
function shouldLogLeaderNudgeTick(reason) {
|
|
148
170
|
return reason === 'leader_nudge_checked' || reason === 'leader_nudge_failed';
|
|
149
171
|
}
|
|
172
|
+
function nextIdlePollMs(currentMs) {
|
|
173
|
+
return Math.min(idleMaxPollMs, Math.max(pollMs, currentMs * 2));
|
|
174
|
+
}
|
|
175
|
+
function updateAdaptivePollState(summary) {
|
|
176
|
+
const nowIso = new Date().toISOString();
|
|
177
|
+
if (summary.active) {
|
|
178
|
+
adaptivePollState = {
|
|
179
|
+
...adaptivePollState,
|
|
180
|
+
enabled: true,
|
|
181
|
+
base_ms: pollMs,
|
|
182
|
+
max_ms: idleMaxPollMs,
|
|
183
|
+
current_ms: pollMs,
|
|
184
|
+
idle_streak: 0,
|
|
185
|
+
last_tick_at: nowIso,
|
|
186
|
+
last_activity_at: nowIso,
|
|
187
|
+
last_activity_reason: summary.reason,
|
|
188
|
+
};
|
|
189
|
+
return adaptivePollState.current_ms;
|
|
190
|
+
}
|
|
191
|
+
const nextMs = nextIdlePollMs(adaptivePollState.current_ms);
|
|
192
|
+
adaptivePollState = {
|
|
193
|
+
...adaptivePollState,
|
|
194
|
+
enabled: true,
|
|
195
|
+
base_ms: pollMs,
|
|
196
|
+
max_ms: idleMaxPollMs,
|
|
197
|
+
current_ms: nextMs,
|
|
198
|
+
idle_streak: adaptivePollState.idle_streak + 1,
|
|
199
|
+
last_tick_at: nowIso,
|
|
200
|
+
last_activity_reason: summary.reason,
|
|
201
|
+
};
|
|
202
|
+
return adaptivePollState.current_ms;
|
|
203
|
+
}
|
|
150
204
|
function shouldLogDispatchDrainTick(result) {
|
|
151
205
|
if (!result || typeof result !== 'object')
|
|
152
206
|
return false;
|
|
@@ -176,6 +230,10 @@ function normalizeRalphContinueSteerState(raw) {
|
|
|
176
230
|
pane_id: safeString(raw.pane_id),
|
|
177
231
|
pane_current_command: safeString(raw.pane_current_command),
|
|
178
232
|
current_phase: safeString(raw.current_phase),
|
|
233
|
+
subagent_session_id: safeString(raw.subagent_session_id),
|
|
234
|
+
active_subagent_thread_ids: Array.isArray(raw.active_subagent_thread_ids)
|
|
235
|
+
? raw.active_subagent_thread_ids.map((value) => safeString(value).trim()).filter(Boolean)
|
|
236
|
+
: [],
|
|
179
237
|
shared_timestamp_path: safeString(raw.shared_timestamp_path) || ralphSteerTimestampPath,
|
|
180
238
|
shared_last_sent_at: safeString(raw.shared_last_sent_at),
|
|
181
239
|
singleton_lock_path: safeString(raw.singleton_lock_path) || ralphSteerLockPath,
|
|
@@ -215,6 +273,19 @@ async function loadPersistedWatcherState() {
|
|
|
215
273
|
last_nudged_at: safeString(persistedAutoNudge.last_nudged_at),
|
|
216
274
|
};
|
|
217
275
|
}
|
|
276
|
+
const persistedAdaptivePoll = persisted?.adaptive_poll;
|
|
277
|
+
if (persistedAdaptivePoll && typeof persistedAdaptivePoll === 'object') {
|
|
278
|
+
adaptivePollState = {
|
|
279
|
+
enabled: persistedAdaptivePoll.enabled !== false,
|
|
280
|
+
base_ms: pollMs,
|
|
281
|
+
max_ms: idleMaxPollMs,
|
|
282
|
+
current_ms: Math.min(idleMaxPollMs, Math.max(pollMs, asNumber(persistedAdaptivePoll.current_ms, pollMs))),
|
|
283
|
+
idle_streak: Math.max(0, Math.trunc(asNumber(persistedAdaptivePoll.idle_streak, 0))),
|
|
284
|
+
last_tick_at: safeString(persistedAdaptivePoll.last_tick_at) || null,
|
|
285
|
+
last_activity_at: safeString(persistedAdaptivePoll.last_activity_at) || null,
|
|
286
|
+
last_activity_reason: safeString(persistedAdaptivePoll.last_activity_reason) || 'init',
|
|
287
|
+
};
|
|
288
|
+
}
|
|
218
289
|
}
|
|
219
290
|
async function resolveActiveModeState(mode) {
|
|
220
291
|
const candidateDirs = [];
|
|
@@ -416,7 +487,8 @@ async function withRalphSteerLock(task) {
|
|
|
416
487
|
throw error;
|
|
417
488
|
const existing = await readRalphSteerLock(ralphSteerLockPath);
|
|
418
489
|
const lockAgeMs = parseIsoMillis(existing?.acquired_at) ?? 0;
|
|
419
|
-
const stale =
|
|
490
|
+
const stale = existing !== null
|
|
491
|
+
&& (!isPidAlive(existing.pid) || (lockAgeMs > 0 && Date.now() - lockAgeMs > RALPH_STEER_LOCK_STALE_MS));
|
|
420
492
|
if (stale) {
|
|
421
493
|
await unlink(ralphSteerLockPath).catch(() => { });
|
|
422
494
|
continue;
|
|
@@ -438,23 +510,39 @@ async function withRalphSteerLock(task) {
|
|
|
438
510
|
}
|
|
439
511
|
}
|
|
440
512
|
}
|
|
441
|
-
async function readRalphProgressGate(now) {
|
|
513
|
+
async function readRalphProgressGate(activeRalphState, now) {
|
|
514
|
+
const subagentSessionId = safeString(activeRalphState?.owner_codex_session_id).trim();
|
|
515
|
+
if (subagentSessionId) {
|
|
516
|
+
const summary = await readSubagentSessionSummary(cwd, subagentSessionId, {
|
|
517
|
+
now: new Date(now),
|
|
518
|
+
activeWindowMs: DEFAULT_SUBAGENT_ACTIVE_WINDOW_MS,
|
|
519
|
+
});
|
|
520
|
+
if ((summary?.activeSubagentThreadIds.length ?? 0) > 0) {
|
|
521
|
+
return {
|
|
522
|
+
allow: false,
|
|
523
|
+
reason: 'subagents_active',
|
|
524
|
+
progress_at: '',
|
|
525
|
+
subagent_session_id: subagentSessionId,
|
|
526
|
+
active_subagent_thread_ids: summary?.activeSubagentThreadIds ?? [],
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
}
|
|
442
530
|
const hudState = await readJsonObject(join(stateDir, 'hud-state.json'));
|
|
443
531
|
if (!hudState || typeof hudState !== 'object') {
|
|
444
|
-
return { allow: false, reason: 'progress_missing', progress_at: '' };
|
|
532
|
+
return { allow: false, reason: 'progress_missing', progress_at: '', subagent_session_id: subagentSessionId };
|
|
445
533
|
}
|
|
446
534
|
const progressAt = safeString(hudState.last_progress_at).trim();
|
|
447
535
|
if (!progressAt) {
|
|
448
|
-
return { allow: false, reason: 'progress_missing', progress_at: '' };
|
|
536
|
+
return { allow: false, reason: 'progress_missing', progress_at: '', subagent_session_id: subagentSessionId };
|
|
449
537
|
}
|
|
450
538
|
const progressMs = parseIsoMillis(progressAt);
|
|
451
539
|
if (progressMs === null) {
|
|
452
|
-
return { allow: false, reason: 'progress_invalid', progress_at: progressAt };
|
|
540
|
+
return { allow: false, reason: 'progress_invalid', progress_at: progressAt, subagent_session_id: subagentSessionId };
|
|
453
541
|
}
|
|
454
542
|
if (now - progressMs < RALPH_CONTINUE_CADENCE_MS) {
|
|
455
|
-
return { allow: false, reason: 'progress_fresh', progress_at: progressAt };
|
|
543
|
+
return { allow: false, reason: 'progress_fresh', progress_at: progressAt, subagent_session_id: subagentSessionId };
|
|
456
544
|
}
|
|
457
|
-
return { allow: true, reason: 'progress_stale', progress_at: progressAt };
|
|
545
|
+
return { allow: true, reason: 'progress_stale', progress_at: progressAt, subagent_session_id: subagentSessionId };
|
|
458
546
|
}
|
|
459
547
|
function shouldSkipRalphContinue(now, candidateIso, startupIso) {
|
|
460
548
|
const sharedMs = parseIsoMillis(candidateIso);
|
|
@@ -497,6 +585,100 @@ async function readPidFileRecord(path) {
|
|
|
497
585
|
return pid === null ? null : { pid };
|
|
498
586
|
}
|
|
499
587
|
}
|
|
588
|
+
function createAuthorityBackoffState(reason, overrides = {}) {
|
|
589
|
+
return {
|
|
590
|
+
active: false,
|
|
591
|
+
reason,
|
|
592
|
+
primary_pid: null,
|
|
593
|
+
primary_last_tick_at: '',
|
|
594
|
+
freshness_ms: null,
|
|
595
|
+
threshold_ms: null,
|
|
596
|
+
...overrides,
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function latestWatcherTickIso(state) {
|
|
600
|
+
if (!state || typeof state !== 'object')
|
|
601
|
+
return '';
|
|
602
|
+
const candidates = [
|
|
603
|
+
safeString(state.dispatch_drain?.last_tick_at),
|
|
604
|
+
safeString(state.leader_nudge?.last_tick_at),
|
|
605
|
+
safeString(state.fallback_auto_nudge?.last_tick_at),
|
|
606
|
+
safeString(state.ralph_continue_steer?.last_state_check_at),
|
|
607
|
+
]
|
|
608
|
+
.map((value) => value.trim())
|
|
609
|
+
.filter(Boolean);
|
|
610
|
+
let latestIso = '';
|
|
611
|
+
let latestMs = -1;
|
|
612
|
+
for (const candidate of candidates) {
|
|
613
|
+
const parsed = parseIsoMillis(candidate);
|
|
614
|
+
if (parsed === null || parsed <= latestMs)
|
|
615
|
+
continue;
|
|
616
|
+
latestMs = parsed;
|
|
617
|
+
latestIso = candidate;
|
|
618
|
+
}
|
|
619
|
+
return latestIso;
|
|
620
|
+
}
|
|
621
|
+
async function resolveAuthorityPrimaryWatcherHealth(now = Date.now()) {
|
|
622
|
+
if (!authorityOnly)
|
|
623
|
+
return createAuthorityBackoffState('not_authority');
|
|
624
|
+
const existingRecord = await readPidFileRecord(pidFilePath).catch(() => null);
|
|
625
|
+
if (!existingRecord)
|
|
626
|
+
return createAuthorityBackoffState('pid_missing');
|
|
627
|
+
if (existingRecord.cwd && resolve(existingRecord.cwd) !== cwd)
|
|
628
|
+
return createAuthorityBackoffState('cwd_mismatch');
|
|
629
|
+
if (!isPidAlive(existingRecord.pid)) {
|
|
630
|
+
return createAuthorityBackoffState('pid_stale', {
|
|
631
|
+
primary_pid: existingRecord.pid,
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
const persistedState = await readJsonObject(statePath);
|
|
635
|
+
if (!persistedState) {
|
|
636
|
+
return createAuthorityBackoffState('state_missing', {
|
|
637
|
+
primary_pid: existingRecord.pid,
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
const persistedPid = Math.trunc(asNumber(persistedState.pid, 0));
|
|
641
|
+
if (persistedPid > 0 && persistedPid !== existingRecord.pid) {
|
|
642
|
+
return createAuthorityBackoffState('state_pid_mismatch', {
|
|
643
|
+
primary_pid: existingRecord.pid,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
const lastTickAt = latestWatcherTickIso(persistedState);
|
|
647
|
+
if (!lastTickAt) {
|
|
648
|
+
return createAuthorityBackoffState('tick_missing', {
|
|
649
|
+
primary_pid: existingRecord.pid,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
const lastTickMs = parseIsoMillis(lastTickAt);
|
|
653
|
+
const primaryPollMs = Math.max(50, asNumber(persistedState.poll_ms, 250));
|
|
654
|
+
const thresholdMs = Math.max(1_000, primaryPollMs * 4);
|
|
655
|
+
if (lastTickMs === null) {
|
|
656
|
+
return createAuthorityBackoffState('tick_invalid', {
|
|
657
|
+
primary_pid: existingRecord.pid,
|
|
658
|
+
primary_last_tick_at: lastTickAt,
|
|
659
|
+
threshold_ms: thresholdMs,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
const freshnessMs = now - lastTickMs;
|
|
663
|
+
if (freshnessMs > thresholdMs) {
|
|
664
|
+
return {
|
|
665
|
+
active: false,
|
|
666
|
+
reason: 'tick_stale',
|
|
667
|
+
primary_pid: existingRecord.pid,
|
|
668
|
+
primary_last_tick_at: lastTickAt,
|
|
669
|
+
freshness_ms: freshnessMs,
|
|
670
|
+
threshold_ms: thresholdMs,
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
active: true,
|
|
675
|
+
reason: 'primary_watcher_healthy',
|
|
676
|
+
primary_pid: existingRecord.pid,
|
|
677
|
+
primary_last_tick_at: lastTickAt,
|
|
678
|
+
freshness_ms: freshnessMs,
|
|
679
|
+
threshold_ms: thresholdMs,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
500
682
|
async function writePidFileRecord() {
|
|
501
683
|
const nextRecord = {
|
|
502
684
|
pid: process.pid,
|
|
@@ -524,6 +706,8 @@ async function runRalphContinueSteerTick() {
|
|
|
524
706
|
state_path: activeRalph.path,
|
|
525
707
|
pane_id: activePaneId,
|
|
526
708
|
pane_current_command: '',
|
|
709
|
+
subagent_session_id: safeString(activeRalph.state?.owner_codex_session_id).trim(),
|
|
710
|
+
active_subagent_thread_ids: [],
|
|
527
711
|
shared_timestamp_path: ralphSteerTimestampPath,
|
|
528
712
|
singleton_lock_path: ralphSteerLockPath,
|
|
529
713
|
};
|
|
@@ -553,9 +737,11 @@ async function runRalphContinueSteerTick() {
|
|
|
553
737
|
}
|
|
554
738
|
return { sent: false, skipped: true };
|
|
555
739
|
}
|
|
556
|
-
const progressGate = await readRalphProgressGate(Date.now());
|
|
740
|
+
const progressGate = await readRalphProgressGate(activeRalph.state, Date.now());
|
|
557
741
|
if (!progressGate.allow) {
|
|
558
742
|
lastRalphContinueSteer.last_reason = progressGate.reason;
|
|
743
|
+
lastRalphContinueSteer.subagent_session_id = progressGate.subagent_session_id ?? lastRalphContinueSteer.subagent_session_id;
|
|
744
|
+
lastRalphContinueSteer.active_subagent_thread_ids = progressGate.active_subagent_thread_ids ?? [];
|
|
559
745
|
return { sent: false, skipped: true };
|
|
560
746
|
}
|
|
561
747
|
const paneId = safeString(activeRalph.state?.tmux_pane_id).trim();
|
|
@@ -675,6 +861,8 @@ async function writeState(extra = {}) {
|
|
|
675
861
|
notify_script: notifyScript,
|
|
676
862
|
authority_only: authorityOnly,
|
|
677
863
|
poll_ms: pollMs,
|
|
864
|
+
effective_poll_ms: adaptivePollState.current_ms,
|
|
865
|
+
idle_max_poll_ms: idleMaxPollMs,
|
|
678
866
|
pid_file: runOnce ? null : pidFilePath,
|
|
679
867
|
max_lifetime_ms: maxLifetimeMs,
|
|
680
868
|
tracked_files: fileState.size,
|
|
@@ -701,10 +889,25 @@ async function writeState(extra = {}) {
|
|
|
701
889
|
enabled: true,
|
|
702
890
|
stall_ms: AUTO_NUDGE_STALL_MS,
|
|
703
891
|
},
|
|
892
|
+
authority_backoff: lastAuthorityBackoff,
|
|
893
|
+
adaptive_poll: {
|
|
894
|
+
...adaptivePollState,
|
|
895
|
+
enabled: true,
|
|
896
|
+
base_ms: pollMs,
|
|
897
|
+
max_ms: idleMaxPollMs,
|
|
898
|
+
},
|
|
704
899
|
...extra,
|
|
705
900
|
};
|
|
706
901
|
await writeFile(statePath, JSON.stringify(state, null, 2)).catch(() => { });
|
|
707
902
|
}
|
|
903
|
+
async function writeAuthorityBackoffState() {
|
|
904
|
+
await mkdir(stateDir, { recursive: true }).catch(() => { });
|
|
905
|
+
const existing = await readJsonObject(statePath);
|
|
906
|
+
const state = existing && typeof existing === 'object'
|
|
907
|
+
? { ...existing, authority_backoff: lastAuthorityBackoff }
|
|
908
|
+
: { authority_backoff: lastAuthorityBackoff };
|
|
909
|
+
await writeFile(statePath, JSON.stringify(state, null, 2)).catch(() => { });
|
|
910
|
+
}
|
|
708
911
|
async function readJsonObject(path) {
|
|
709
912
|
return readFile(path, 'utf-8')
|
|
710
913
|
.then((content) => JSON.parse(content))
|
|
@@ -1020,6 +1223,7 @@ function splitBufferedLines(partial, delta) {
|
|
|
1020
1223
|
};
|
|
1021
1224
|
}
|
|
1022
1225
|
async function pollFiles() {
|
|
1226
|
+
let processedCount = 0;
|
|
1023
1227
|
for (const [path, meta] of fileState.entries()) {
|
|
1024
1228
|
const currentSize = (await stat(path).catch(() => ({ size: 0 }))).size || 0;
|
|
1025
1229
|
if (currentSize <= meta.offset)
|
|
@@ -1036,8 +1240,10 @@ async function pollFiles() {
|
|
|
1036
1240
|
if (!line.trim())
|
|
1037
1241
|
continue;
|
|
1038
1242
|
await processLine(meta, line, path);
|
|
1243
|
+
processedCount += 1;
|
|
1039
1244
|
}
|
|
1040
1245
|
}
|
|
1246
|
+
return processedCount;
|
|
1041
1247
|
}
|
|
1042
1248
|
async function runLeaderNudgeTick() {
|
|
1043
1249
|
const startedIso = new Date().toISOString();
|
|
@@ -1053,7 +1259,7 @@ async function runLeaderNudgeTick() {
|
|
|
1053
1259
|
last_tick_at: startedIso,
|
|
1054
1260
|
last_error: 'worker_context',
|
|
1055
1261
|
};
|
|
1056
|
-
return;
|
|
1262
|
+
return false;
|
|
1057
1263
|
}
|
|
1058
1264
|
try {
|
|
1059
1265
|
const preComputedLeaderStale = await isLeaderStale(stateDir, staleThresholdMs, Date.now());
|
|
@@ -1063,6 +1269,7 @@ async function runLeaderNudgeTick() {
|
|
|
1063
1269
|
logsDir,
|
|
1064
1270
|
preComputedLeaderStale,
|
|
1065
1271
|
allowFreshMailboxNudges: false,
|
|
1272
|
+
source: 'notify_fallback_watcher',
|
|
1066
1273
|
});
|
|
1067
1274
|
leaderNudgeRuns += 1;
|
|
1068
1275
|
lastLeaderNudge = {
|
|
@@ -1084,6 +1291,7 @@ async function runLeaderNudgeTick() {
|
|
|
1084
1291
|
reason,
|
|
1085
1292
|
});
|
|
1086
1293
|
}
|
|
1294
|
+
return preComputedLeaderStale;
|
|
1087
1295
|
}
|
|
1088
1296
|
catch (err) {
|
|
1089
1297
|
leaderNudgeRuns += 1;
|
|
@@ -1103,6 +1311,7 @@ async function runLeaderNudgeTick() {
|
|
|
1103
1311
|
reason: 'leader_nudge_failed',
|
|
1104
1312
|
error: lastLeaderNudge.last_error,
|
|
1105
1313
|
});
|
|
1314
|
+
return true;
|
|
1106
1315
|
}
|
|
1107
1316
|
}
|
|
1108
1317
|
async function runDispatchDrainTick() {
|
|
@@ -1125,6 +1334,7 @@ async function runDispatchDrainTick() {
|
|
|
1125
1334
|
...(result && typeof result === 'object' ? result : {}),
|
|
1126
1335
|
});
|
|
1127
1336
|
}
|
|
1337
|
+
return shouldLogDispatchDrainTick(result);
|
|
1128
1338
|
}
|
|
1129
1339
|
catch (err) {
|
|
1130
1340
|
dispatchDrainRuns += 1;
|
|
@@ -1142,6 +1352,7 @@ async function runDispatchDrainTick() {
|
|
|
1142
1352
|
reason: 'dispatch_drain_failed',
|
|
1143
1353
|
error: lastDispatchDrain.last_error,
|
|
1144
1354
|
});
|
|
1355
|
+
return true;
|
|
1145
1356
|
}
|
|
1146
1357
|
}
|
|
1147
1358
|
async function shouldSuppressInteractiveFallbackTicks() {
|
|
@@ -1152,34 +1363,65 @@ async function shouldSuppressInteractiveFallbackTicks() {
|
|
|
1152
1363
|
return deepInterviewStateActive || deepInterviewInputLockActive;
|
|
1153
1364
|
}
|
|
1154
1365
|
async function pumpTeamControlPlaneTick() {
|
|
1155
|
-
await runDispatchDrainTick();
|
|
1156
|
-
if (await shouldSuppressInteractiveFallbackTicks())
|
|
1157
|
-
return;
|
|
1158
|
-
|
|
1366
|
+
const dispatchActive = await runDispatchDrainTick();
|
|
1367
|
+
if (await shouldSuppressInteractiveFallbackTicks()) {
|
|
1368
|
+
return { active: dispatchActive, reason: dispatchActive ? 'dispatch_drain' : 'deep_interview_locked' };
|
|
1369
|
+
}
|
|
1370
|
+
const leaderActive = await runLeaderNudgeTick();
|
|
1159
1371
|
await runFallbackAutoNudgeTick();
|
|
1372
|
+
const autoNudgeActive = lastFallbackAutoNudge.last_reason === 'sent';
|
|
1373
|
+
if (dispatchActive)
|
|
1374
|
+
return { active: true, reason: 'dispatch_drain' };
|
|
1375
|
+
if (leaderActive)
|
|
1376
|
+
return { active: true, reason: 'leader_nudge' };
|
|
1377
|
+
if (autoNudgeActive)
|
|
1378
|
+
return { active: true, reason: 'fallback_auto_nudge' };
|
|
1379
|
+
return { active: false, reason: lastFallbackAutoNudge.last_reason || 'control_plane_idle' };
|
|
1160
1380
|
}
|
|
1161
1381
|
async function runWatcherCycle() {
|
|
1382
|
+
let processedRolloutCount = 0;
|
|
1383
|
+
if (authorityOnly) {
|
|
1384
|
+
const authorityBackoff = await resolveAuthorityPrimaryWatcherHealth();
|
|
1385
|
+
lastAuthorityBackoff = authorityBackoff;
|
|
1386
|
+
if (authorityBackoff.active) {
|
|
1387
|
+
await writeAuthorityBackoffState();
|
|
1388
|
+
return processedRolloutCount;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
else {
|
|
1392
|
+
lastAuthorityBackoff = createAuthorityBackoffState('');
|
|
1393
|
+
}
|
|
1162
1394
|
if (!authorityOnly) {
|
|
1163
1395
|
await ensureTrackedFiles();
|
|
1164
|
-
await pollFiles();
|
|
1396
|
+
processedRolloutCount = await pollFiles();
|
|
1165
1397
|
}
|
|
1166
|
-
await pumpTeamControlPlaneTick();
|
|
1398
|
+
const controlPlaneSummary = await pumpTeamControlPlaneTick();
|
|
1167
1399
|
if (!authorityOnly && !(await shouldSuppressInteractiveFallbackTicks())) {
|
|
1168
1400
|
await runRalphWatcherBehaviorTick();
|
|
1169
1401
|
}
|
|
1170
|
-
|
|
1402
|
+
const ralphActive = lastRalphContinueSteer.last_reason === 'sent';
|
|
1403
|
+
const summary = processedRolloutCount > 0
|
|
1404
|
+
? { active: true, reason: 'rollout_event' }
|
|
1405
|
+
: controlPlaneSummary.active
|
|
1406
|
+
? controlPlaneSummary
|
|
1407
|
+
: ralphActive
|
|
1408
|
+
? { active: true, reason: 'ralph_continue_steer' }
|
|
1409
|
+
: { active: false, reason: controlPlaneSummary.reason || lastRalphContinueSteer.last_reason || 'idle' };
|
|
1410
|
+
const nextDelayMs = updateAdaptivePollState(summary);
|
|
1411
|
+
await writeState({ last_cycle_activity: summary.reason });
|
|
1412
|
+
return nextDelayMs;
|
|
1171
1413
|
}
|
|
1172
1414
|
async function tick() {
|
|
1173
1415
|
if (stopping)
|
|
1174
1416
|
return;
|
|
1175
1417
|
if (await enforceLifecycleGuards())
|
|
1176
1418
|
return;
|
|
1177
|
-
await runWatcherCycle();
|
|
1419
|
+
const nextDelayMs = await runWatcherCycle();
|
|
1178
1420
|
if (await enforceLifecycleGuards())
|
|
1179
1421
|
return;
|
|
1180
1422
|
setTimeout(() => {
|
|
1181
1423
|
void tick();
|
|
1182
|
-
},
|
|
1424
|
+
}, nextDelayMs);
|
|
1183
1425
|
}
|
|
1184
1426
|
function shutdown(signal) {
|
|
1185
1427
|
void requestShutdown('signal', signal);
|
|
@@ -1200,6 +1442,8 @@ async function main() {
|
|
|
1200
1442
|
notify_script: notifyScript,
|
|
1201
1443
|
authority_only: authorityOnly,
|
|
1202
1444
|
poll_ms: pollMs,
|
|
1445
|
+
effective_poll_ms: adaptivePollState.current_ms,
|
|
1446
|
+
idle_max_poll_ms: idleMaxPollMs,
|
|
1203
1447
|
once: runOnce,
|
|
1204
1448
|
parent_pid: parentPid,
|
|
1205
1449
|
pid_file: runOnce ? null : pidFilePath,
|