gentle-pi 4.5.1 → 4.7.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/README.md +17 -15
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +8 -1
- package/assets/agents/gentle-ai-worker.md +4 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +162 -0
- package/assets/orchestrator-delegation-reference.md +7 -7
- package/assets/orchestrator-delegation.md +3 -3
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +14 -8
- package/assets/orchestrator.md +11 -11
- package/bin/gentle-shell.mjs +225 -82
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/ci-performance.md +11 -0
- package/docs/delegated-verification.md +35 -7
- package/docs/fast-mode.md +15 -0
- package/docs/gentle-agents-activity.md +22 -0
- package/docs/gentle-shell.md +113 -25
- package/docs/install-wizard.md +2 -2
- package/docs/mcp-status.md +52 -0
- package/docs/permission-modes.md +9 -4
- package/docs/prompt-budget.md +28 -0
- package/docs/readme-reference.md +154 -50
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/session-profile-format.md +20 -5
- package/docs/sound-notifications.md +1 -1
- package/docs/star-prompt.md +32 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +46 -0
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +2 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/codegraph-tools.ts +38 -4
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +803 -84
- package/extensions/gentle-ai.ts +2491 -596
- package/extensions/gentle-fast.ts +61 -0
- package/extensions/gentle-guide.ts +174 -0
- package/extensions/gentle-herdr-activity.ts +21 -1
- package/extensions/gentle-herdr-agent.ts +144 -0
- package/extensions/gentle-program-identity.ts +61 -0
- package/extensions/gentle-shell.ts +895 -120
- package/extensions/gentle-star-prompt.ts +334 -0
- package/extensions/gentle-stats.ts +5 -5
- package/extensions/gentle-todo.ts +59 -23
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/history/store.ts +18 -12
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +210 -21
- package/extensions/startup-banner.ts +69 -10
- package/lib/agent-assets.ts +74 -17
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +161 -3
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +58 -3
- package/lib/agents-history.ts +24 -5
- package/lib/agents-keys.ts +8 -16
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-protocol.ts +80 -4
- package/lib/agents-runner.ts +287 -15
- package/lib/agents-view.ts +6 -1
- package/lib/agents-widget.ts +132 -9
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/bridge-cost.ts +28 -0
- package/lib/card-content-policy.ts +8 -6
- package/lib/codemode-renderer.ts +16 -0
- package/lib/command-palette-catalog.ts +1 -0
- package/lib/command-palette.ts +154 -25
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +64 -0
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-guide.ts +201 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +47 -8
- package/lib/herdr-activity.ts +23 -5
- package/lib/herdr-busy.ts +45 -0
- package/lib/herdr-task-summary-policy.ts +85 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +282 -132
- package/lib/jobs-sidebar-state.ts +5 -6
- package/lib/jobs-view.ts +198 -11
- package/lib/jobs-widget.ts +16 -52
- package/lib/keymaps-customize.ts +81 -0
- package/lib/keymaps.ts +291 -0
- package/lib/model-fallback-notice.ts +61 -0
- package/lib/model-fallback-policy.ts +141 -0
- package/lib/model-fallback-store.ts +143 -0
- package/lib/model-routing-authority.ts +32 -6
- package/lib/nan-provider.ts +3 -2
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +103 -21
- package/lib/notification-customize.ts +48 -51
- package/lib/openai-fast-tier.ts +22 -0
- package/lib/orchestrator-discovery.ts +5 -1
- package/lib/orchestrator-fallback.ts +75 -0
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/pasted-image-paths.ts +113 -0
- package/lib/questionnaire/questionnaire-view.ts +225 -18
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +85 -44
- package/lib/review-candidate-view.ts +10 -7
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +29 -8
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-repository.ts +5 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-append-controller.ts +21 -6
- package/lib/session-profile-authority.ts +119 -0
- package/lib/session-profile-binding.ts +54 -5
- package/lib/session-profile-freeze.ts +107 -9
- package/lib/session-profile-integration.ts +313 -0
- package/lib/session-profile-persistence.ts +63 -9
- package/lib/shell-bar.ts +269 -72
- package/lib/shell-card.ts +26 -6
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-page.ts +120 -0
- package/lib/shell-panel.ts +163 -0
- package/lib/shell-prompt.ts +53 -1
- package/lib/shell-sidebar-layout.ts +198 -53
- package/lib/shell-sidebar.ts +61 -1
- package/lib/shell-stats.ts +123 -0
- package/lib/shell-todo.ts +79 -1
- package/lib/shell-usage.ts +12 -2
- package/lib/star-prompt.ts +197 -0
- package/lib/verifier-admission.ts +18 -8
- package/lib/verifier-settle-reminder.ts +64 -0
- package/lib/vim-editor-adapter.ts +6 -1
- package/lib/visual-customization-policy.ts +67 -12
- package/lib/visual-customize-view.ts +373 -40
- package/lib/visual-layout-preview.ts +47 -0
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +68 -16
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +46 -7
- package/runtime/native-review-cli.mjs +100 -18
- package/runtime/review-integration-v2.mjs +29 -8
- package/runtime/windows-session-transport.ps1 +60 -3
- package/scripts/bootstrap.sh +4 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +6 -6
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/pi-update.mjs +113 -3
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +41 -13
- package/scripts/shell-snapshot.mjs +340 -0
- package/scripts/test-packed-runner.mjs +1 -1
- package/scripts/update-agent-body-history.mjs +41 -0
- package/scripts/verify-installer-tap.mjs +45 -0
- package/scripts/verify-package-files.mjs +14 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +4 -4
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/tui-design/NOTICE.md +5 -0
- package/skills/tui-design/SKILL.md +56 -0
- package/skills/tui-design/references/commands.md +75 -0
- package/skills/tui-design/references/critique.md +48 -0
- package/skills/tui-design/references/design-doc.md +44 -0
- package/skills/tui-design/references/terminal-craft.md +64 -0
- package/skills/tui-design/references/visual-loop.md +32 -0
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-protocol.test.ts +53 -1
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +345 -4
- package/tests/agents-view.test.ts +27 -0
- package/tests/agents-widget.test.ts +312 -10
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-scan-contract.test.ts +39 -0
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +47 -0
- package/tests/bundled-install.test.ts +36 -9
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/ci-concurrency.test.ts +11 -0
- package/tests/ci-merge-base-identity.test.ts +114 -0
- package/tests/codegraph-tools.test.ts +80 -5
- package/tests/codemode-rendering.test.ts +22 -2
- package/tests/command-palette.test.ts +300 -3
- package/tests/commit-slice-signal.test.ts +11 -9
- package/tests/delegate-for-reason-contract.test.ts +8 -7
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/exploration-budget.test.ts +128 -0
- package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
- package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +172 -0
- package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
- package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
- package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
- package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
- package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
- package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
- package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
- package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1491 -38
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +151 -0
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +1101 -52
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-fast.test.ts +73 -0
- package/tests/gentle-guide.test.ts +208 -0
- package/tests/gentle-herdr-activity.test.ts +80 -3
- package/tests/gentle-herdr-agent.test.ts +111 -0
- package/tests/gentle-program-identity.test.ts +197 -0
- package/tests/gentle-shell-bin.test.ts +172 -26
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +93 -10
- package/tests/gentle-shell.test.ts +1937 -66
- package/tests/gentle-stats.test.ts +15 -2
- package/tests/gentle-todo.test.ts +67 -4
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +132 -0
- package/tests/history-store-private-mode.test.ts +40 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/image-paste-chips.test.ts +42 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +298 -4
- package/tests/installer-posix-bootstrap.test.ts +68 -6
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/installer-windows-diagnostics.test.ts +4 -5
- package/tests/isolated-config-home.ts +28 -0
- package/tests/jobs-view.test.ts +260 -6
- package/tests/jobs-widget.test.ts +25 -37
- package/tests/keymaps-customize.test.ts +114 -0
- package/tests/keymaps.test.ts +103 -0
- package/tests/maintainer/mcp-status.maintest.ts +88 -0
- package/tests/maintainer/pi-update-source.maintest.ts +116 -0
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-notice.test.ts +45 -0
- package/tests/model-fallback-policy.test.ts +83 -0
- package/tests/model-fallback-store.test.ts +111 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider.test.ts +4 -4
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +22 -0
- package/tests/notification-customize.test.ts +58 -34
- package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
- package/tests/odd-routing-contract.test.ts +1 -1
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-fallback.test.ts +82 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +133 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +169 -14
- package/tests/pasted-image-paths.test.ts +118 -0
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/persona-reply-language.test.ts +20 -1
- package/tests/pi-update-launcher.test.ts +40 -8
- package/tests/pi-update-source.test.ts +162 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-fast-tier.test.ts +311 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +84 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +265 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-owner-sweep.test.ts +93 -0
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +52 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +381 -11
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-gate.test.ts +24 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-inspect-preflight.test.ts +197 -0
- package/tests/review-integration-v2-forward.test.ts +59 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-repository.test.ts +52 -1
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-sidebar-state.test.ts +5 -5
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +183 -6
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +250 -0
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-append-controller.test.ts +63 -0
- package/tests/session-profile-authority.test.ts +259 -0
- package/tests/session-profile-binding.test.ts +34 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +615 -0
- package/tests/session-profile-freeze.test.ts +110 -2
- package/tests/session-profile-integration.test.ts +857 -0
- package/tests/session-profile-persistence.test.ts +57 -0
- package/tests/session-profile-v1-compat.test.ts +255 -0
- package/tests/shell-bar.test.ts +274 -72
- package/tests/shell-card.test.ts +13 -1
- package/tests/shell-page.test.ts +108 -0
- package/tests/shell-panel.test.ts +360 -0
- package/tests/shell-prompt.test.ts +54 -0
- package/tests/shell-render-cache.test.ts +5 -0
- package/tests/shell-sidebar-fullscreen.test.ts +13 -1
- package/tests/shell-sidebar-layout.test.ts +447 -44
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-stats.test.ts +90 -0
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +14 -0
- package/tests/skill-registry.test.ts +902 -2
- package/tests/star-prompt.test.ts +470 -0
- package/tests/startup-banner.test.ts +209 -2
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +50 -4
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-settle-reminder.test.ts +281 -0
- package/tests/verify-first-launch-contract.test.ts +134 -8
- package/tests/verify-installer-tap.test.ts +57 -0
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +95 -8
- package/tests/visual-customize-view.test.ts +818 -9
- package/tests/visual-layout-preview.test.ts +42 -0
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-bootstrap.test.ts +105 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +114 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/writer-surfaces.test.ts +12 -10
- package/tests/yolo-customize.test.ts +57 -15
- package/tests/yolo-mode-runtime.test.ts +4 -2
- package/tests/yolo-mode.test.ts +39 -20
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { AGENT_MODE, type AgentDefinition } from "../lib/agents-config.ts";
|
|
4
|
+
import { TASK_STATUS, TaskStore, type TaskRecord } from "../lib/agents-protocol.ts";
|
|
5
|
+
import { AgentRunner, type RunnerDeps, type TaskRequest } from "../lib/agents-runner.ts";
|
|
6
|
+
import { fakeChild, type FakeChild } from "./agents-fake-child.ts";
|
|
7
|
+
|
|
8
|
+
// Settlement drain (#2266): a child that reported unfinished background jobs
|
|
9
|
+
// gets one bounded window on agent_settled before the ordinary orderly
|
|
10
|
+
// shutdown. Every terminal path cancels the window, and a child that never
|
|
11
|
+
// reported a job keeps the pre-existing immediate settlement.
|
|
12
|
+
|
|
13
|
+
const explorer: AgentDefinition = { name: "explore", description: "maps", filePath: "/a/explore.md", scope: "global", instructions: "You map things.", model: undefined, thinking: undefined, mode: undefined, tools: ["read", "bash_background"] };
|
|
14
|
+
const request = (overrides: Partial<TaskRequest> = {}): TaskRequest => ({ agent: explorer, prompt: "Map the repo", label: undefined, context: undefined, mode: AGENT_MODE.TASK, cwd: "/repo", parentSessionId: "s1", model: { provider: "openai-codex", id: "gpt-5.6-terra" }, thinking: "high", sessionDir: "/sessions", resumeSessionPath: undefined, env: { GENTLE_PI_BACKGROUND_SUBAGENTS: "on" }, ...overrides });
|
|
15
|
+
const tick = () => new Promise((resolve) => setImmediate(resolve));
|
|
16
|
+
const job = (id: string, running: number, pending: boolean) => ({ id, kind: "job", message: JSON.stringify({ running, pending }) });
|
|
17
|
+
|
|
18
|
+
function harness(options: { cleanupTimeoutMs?: number; drainTimeoutMs?: number } = {}) {
|
|
19
|
+
const children: FakeChild[] = [];
|
|
20
|
+
const timers: Array<{ fn: () => void; ms: number; cancelled: boolean }> = [];
|
|
21
|
+
const finishes: TaskRecord[] = [];
|
|
22
|
+
const notifications: string[] = [];
|
|
23
|
+
const deps: RunnerDeps = {
|
|
24
|
+
spawn: () => { const fake = fakeChild({ exitOnKill: false, exitOnStdinEnd: false }); children.push(fake); return fake.child; },
|
|
25
|
+
now: () => Date.now(),
|
|
26
|
+
schedule: (fn, ms) => { const timer = { fn, ms, cancelled: false }; timers.push(timer); return () => { timer.cancelled = true; }; },
|
|
27
|
+
pi: { command: "pi", args: [] },
|
|
28
|
+
};
|
|
29
|
+
const store = new TaskStore();
|
|
30
|
+
const runner = new AgentRunner(store, { maxConcurrency: 2, stallTimeoutMs: 600_000, cleanupTimeoutMs: options.cleanupTimeoutMs ?? 3_000, drainTimeoutMs: options.drainTimeoutMs ?? 2_000 }, deps, {
|
|
31
|
+
askUser: async () => ({ cancelled: true }),
|
|
32
|
+
onFinish: (task) => finishes.push(task),
|
|
33
|
+
onNotification: (_task, message) => { notifications.push(message); },
|
|
34
|
+
});
|
|
35
|
+
const pending = (ms: number) => timers.filter((timer) => !timer.cancelled && timer.ms === ms);
|
|
36
|
+
const created = (ms: number) => timers.filter((timer) => timer.ms === ms);
|
|
37
|
+
const fire = (ms: number) => { const timer = pending(ms)[0]; assert.ok(timer, `expected a live ${ms}ms timer`); timer.cancelled = true; timer.fn(); };
|
|
38
|
+
return { store, runner, children, timers, finishes, notifications, pending, created, fire };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function drained(h: ReturnType<typeof harness>) {
|
|
42
|
+
const task = h.runner.run(request());
|
|
43
|
+
await tick();
|
|
44
|
+
const child = h.children[0];
|
|
45
|
+
child.message(job("j1", 1, true));
|
|
46
|
+
child.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "waiting on CI" }] }] });
|
|
47
|
+
child.emit({ type: "agent_settled" });
|
|
48
|
+
await tick();
|
|
49
|
+
return { task, child };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
test("P-B1 one bounded drain is armed, then the ordinary SIGTERM/SIGKILL timeline follows the drain expiry", async () => {
|
|
53
|
+
const h = harness();
|
|
54
|
+
const { task, child } = await drained(h);
|
|
55
|
+
assert.equal(h.created(2_000).length, 1, "exactly one drain window");
|
|
56
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.RUNNING);
|
|
57
|
+
assert.equal(h.store.get(task.id)?.lastStep, "draining background jobs");
|
|
58
|
+
assert.deepEqual(child.killed, [], "nothing is signalled during the drain");
|
|
59
|
+
assert.equal(child.child.stdin.writableEnded, false);
|
|
60
|
+
assert.deepEqual(child.sent[0], { id: "j1", kind: "ack", accepted: true });
|
|
61
|
+
|
|
62
|
+
h.fire(2_000);
|
|
63
|
+
await tick();
|
|
64
|
+
assert.ok(child.child.stdin.writableEnded, "the drain ends by settling");
|
|
65
|
+
assert.equal(h.pending(3_000).length, 1, "cleanup window starts after the drain");
|
|
66
|
+
assert.deepEqual(child.killed, []);
|
|
67
|
+
h.fire(3_000);
|
|
68
|
+
assert.deepEqual(child.killed, ["SIGTERM"]);
|
|
69
|
+
assert.equal(h.pending(250).length, 1, "SIGKILL is exactly TERMINATION_GRACE_MS after SIGTERM");
|
|
70
|
+
h.fire(250);
|
|
71
|
+
assert.deepEqual(child.killed, ["SIGTERM", "SIGKILL"]);
|
|
72
|
+
assert.equal(h.finishes.length, 0, "the slot is held until the exit is confirmed");
|
|
73
|
+
child.exit(0);
|
|
74
|
+
await tick();
|
|
75
|
+
assert.equal(h.finishes.length, 1);
|
|
76
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.COMPLETED);
|
|
77
|
+
assert.equal(h.store.get(task.id)?.error, null);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("P-B2 a report with nothing left ends the drain early, and only one finish follows", async () => {
|
|
81
|
+
const h = harness();
|
|
82
|
+
const { task, child } = await drained(h);
|
|
83
|
+
child.message(job("j2", 0, false));
|
|
84
|
+
await tick();
|
|
85
|
+
assert.ok(h.pending(2_000).length === 0, "the drain timer is cancelled");
|
|
86
|
+
assert.ok(child.child.stdin.writableEnded);
|
|
87
|
+
child.exit(0);
|
|
88
|
+
await tick();
|
|
89
|
+
assert.equal(h.finishes.length, 1);
|
|
90
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.COMPLETED);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("P-B3 many reports during the drain never accumulate a second window", async () => {
|
|
94
|
+
const h = harness();
|
|
95
|
+
const { child } = await drained(h);
|
|
96
|
+
for (let index = 2; index < 8; index += 1) { child.message(job(`j${index}`, 1, true)); await tick(); }
|
|
97
|
+
assert.equal(h.created(2_000).length, 1, "still one created drain timer");
|
|
98
|
+
assert.equal(h.pending(2_000).length, 1, "still one live drain timer");
|
|
99
|
+
child.emit({ type: "agent_settled" });
|
|
100
|
+
await tick();
|
|
101
|
+
assert.equal(h.created(2_000).length, 1, "a repeated settlement cannot arm another window");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("P-B4 requestStop cancels the drain: a cancel is not delayed by the window", async () => {
|
|
105
|
+
const h = harness();
|
|
106
|
+
const { task, child } = await drained(h);
|
|
107
|
+
assert.ok(h.pending(2_000).length === 1);
|
|
108
|
+
assert.equal(h.runner.cancel(task.id), true);
|
|
109
|
+
await tick();
|
|
110
|
+
assert.equal(h.pending(2_000).length, 0, "the drain timer is cancelled by the stop");
|
|
111
|
+
assert.deepEqual(child.killed, ["SIGTERM"], "the stop signals at once instead of draining");
|
|
112
|
+
// A stop keeps today's semantics: it signals at once and does not end stdin.
|
|
113
|
+
assert.equal(child.child.stdin.writableEnded, false);
|
|
114
|
+
child.exit(0, "SIGTERM");
|
|
115
|
+
await tick();
|
|
116
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.CANCELLED);
|
|
117
|
+
assert.equal(h.finishes.length, 1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("P-B5 a child that never reports a job settles immediately, exactly as before", async () => {
|
|
121
|
+
const h = harness();
|
|
122
|
+
const task = h.runner.run(request());
|
|
123
|
+
await tick();
|
|
124
|
+
const child = h.children[0];
|
|
125
|
+
child.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "done" }] }] });
|
|
126
|
+
child.emit({ type: "agent_settled" });
|
|
127
|
+
await tick();
|
|
128
|
+
assert.equal(h.created(2_000).length, 0, "no drain window without a child job report");
|
|
129
|
+
assert.ok(child.child.stdin.writableEnded);
|
|
130
|
+
assert.equal(h.pending(3_000).length, 1);
|
|
131
|
+
child.exit(0);
|
|
132
|
+
await tick();
|
|
133
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.COMPLETED);
|
|
134
|
+
assert.equal(h.finishes.length, 1);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("P-B6 an invalid job report is refused and cannot open or end a drain", async () => {
|
|
138
|
+
for (const message of ["not json", '{"running":-1,"pending":false}', '{"running":1}', '{"running":1,"pending":false,"x":0}', "x".repeat(9_000)]) {
|
|
139
|
+
const h = harness();
|
|
140
|
+
const task = h.runner.run(request());
|
|
141
|
+
await tick();
|
|
142
|
+
const c = h.children[0];
|
|
143
|
+
c.message({ id: "j1", kind: "job", message });
|
|
144
|
+
await tick();
|
|
145
|
+
const ack = c.sent.at(-1) as { accepted?: boolean; error?: string };
|
|
146
|
+
assert.equal(ack.accepted, false, message.slice(0, 24));
|
|
147
|
+
assert.ok(ack.error, message.slice(0, 24));
|
|
148
|
+
c.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "done" }] }] });
|
|
149
|
+
c.emit({ type: "agent_settled" });
|
|
150
|
+
await tick();
|
|
151
|
+
assert.equal(h.created(2_000).length, 0, `no drain for ${message.slice(0, 24)}`);
|
|
152
|
+
assert.ok(c.child.stdin.writableEnded);
|
|
153
|
+
assert.ok(task.id);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("P-B7 a child exit mid-drain settles once, with the status the settlement already produced", async () => {
|
|
158
|
+
const h = harness();
|
|
159
|
+
const { task, child } = await drained(h);
|
|
160
|
+
assert.ok(h.pending(2_000).length === 1);
|
|
161
|
+
child.exit(0);
|
|
162
|
+
await tick();
|
|
163
|
+
assert.equal(h.finishes.length, 1, "exactly one finish");
|
|
164
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.COMPLETED);
|
|
165
|
+
assert.equal(h.pending(2_000).length, 0, "no drain timer is left behind to fire later");
|
|
166
|
+
assert.equal(h.created(2_000).length, 1);
|
|
167
|
+
const after = h.timers.length;
|
|
168
|
+
await tick();
|
|
169
|
+
assert.equal(h.timers.length, after);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("P-B8 job reports are never routed to the parent model", async () => {
|
|
173
|
+
const h = harness();
|
|
174
|
+
const { child } = await drained(h);
|
|
175
|
+
child.message(job("j2", 0, false));
|
|
176
|
+
await tick();
|
|
177
|
+
assert.deepEqual(h.notifications, [], "no parent notification came from a job frame");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("P-B9 a late report after the terminal state cannot reopen a drain or mutate the record", async () => {
|
|
181
|
+
const h = harness();
|
|
182
|
+
const { task, child } = await drained(h);
|
|
183
|
+
child.message(job("j2", 0, false));
|
|
184
|
+
await tick();
|
|
185
|
+
child.exit(0);
|
|
186
|
+
await tick();
|
|
187
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.COMPLETED);
|
|
188
|
+
child.message(job("j3", 1, true));
|
|
189
|
+
await tick();
|
|
190
|
+
assert.equal(h.created(2_000).length, 1, "no window after the terminal state");
|
|
191
|
+
assert.equal(h.finishes.length, 1);
|
|
192
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.COMPLETED);
|
|
193
|
+
});
|
|
@@ -34,7 +34,7 @@ interface Harness {
|
|
|
34
34
|
advance(ms: number): void;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function harness(options: { resolvePi?: RunnerDeps["resolvePi"]; failStart?: boolean; process?: RunnerDeps["process"]; pid?: number; maxConcurrency?: number; stallTimeoutMs?: number; toolStallTimeoutMs?: number; cleanupTimeoutMs?: number; answer?: Record<string, unknown>; exitOnKill?: boolean; exitOnStdinEnd?: boolean; state?: Record<string, unknown>; stateSuccess?: boolean; onNotification?: RunnerHooks["onNotification"]; onSuccessfulMutation?: RunnerHooks["onSuccessfulMutation"]; onFinish?: RunnerHooks["onFinish"] } = {}): Harness {
|
|
37
|
+
function harness(options: { resolvePi?: RunnerDeps["resolvePi"]; failStart?: boolean; process?: RunnerDeps["process"]; pid?: number; maxConcurrency?: number; stallTimeoutMs?: number; toolStallTimeoutMs?: number; cleanupTimeoutMs?: number; drainTimeoutMs?: number; answer?: Record<string, unknown>; exitOnKill?: boolean; exitOnStdinEnd?: boolean; state?: Record<string, unknown>; stateSuccess?: boolean; onNotification?: RunnerHooks["onNotification"]; onSuccessfulMutation?: RunnerHooks["onSuccessfulMutation"]; onFinish?: RunnerHooks["onFinish"]; onFallback?: RunnerHooks["onFallback"]; reject?: (command: Record<string, unknown>) => boolean; hold?: (command: Record<string, unknown>) => boolean } = {}): Harness {
|
|
38
38
|
const children: FakeChild[] = [];
|
|
39
39
|
const timers: Harness["timers"] = [];
|
|
40
40
|
const asks: Harness["asks"] = [];
|
|
@@ -54,8 +54,10 @@ function harness(options: { resolvePi?: RunnerDeps["resolvePi"]; failStart?: boo
|
|
|
54
54
|
fake.child.stdin.on("data", (chunk) => {
|
|
55
55
|
const command = JSON.parse(String(chunk));
|
|
56
56
|
fake.written.push(command);
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
if (options.hold?.(command)) return;
|
|
58
|
+
const rejected = options.reject?.(command) === true;
|
|
59
|
+
fake.emit({ type: "response", id: command.id, success: !rejected && (command.type !== "get_state" || options.stateSuccess !== false),
|
|
60
|
+
...(rejected ? { error: "No API key for provider" } : {}), data: command.type === "get_state" ? options.state : undefined });
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
children.push(fake);
|
|
@@ -73,7 +75,7 @@ function harness(options: { resolvePi?: RunnerDeps["resolvePi"]; failStart?: boo
|
|
|
73
75
|
pi: { command: "pi", args: [] },
|
|
74
76
|
};
|
|
75
77
|
const store = new TaskStore();
|
|
76
|
-
const runner = new AgentRunner(store, { maxConcurrency: options.maxConcurrency ?? 2, stallTimeoutMs: options.stallTimeoutMs ?? 10_000, toolStallTimeoutMs: options.toolStallTimeoutMs, cleanupTimeoutMs: options.cleanupTimeoutMs }, deps, {
|
|
78
|
+
const runner = new AgentRunner(store, { maxConcurrency: options.maxConcurrency ?? 2, stallTimeoutMs: options.stallTimeoutMs ?? 10_000, toolStallTimeoutMs: options.toolStallTimeoutMs, cleanupTimeoutMs: options.cleanupTimeoutMs, drainTimeoutMs: options.drainTimeoutMs }, deps, {
|
|
77
79
|
askUser: async (taskId, ask) => {
|
|
78
80
|
asks.push({ taskId, method: ask.method });
|
|
79
81
|
return options.answer ?? { value: "yes" };
|
|
@@ -81,6 +83,7 @@ function harness(options: { resolvePi?: RunnerDeps["resolvePi"]; failStart?: boo
|
|
|
81
83
|
onFinish: (task, observations) => { finishes.push(task.id); options.onFinish?.(task, observations); },
|
|
82
84
|
onNotification: options.onNotification,
|
|
83
85
|
onSuccessfulMutation: options.onSuccessfulMutation,
|
|
86
|
+
onFallback: options.onFallback,
|
|
84
87
|
});
|
|
85
88
|
return { store, runner, children, timers, asks, finishes, spawnOptions, advance(ms) {
|
|
86
89
|
clock += ms;
|
|
@@ -176,6 +179,26 @@ test("background capability admission refreshes project policy when queued work
|
|
|
176
179
|
assert.equal(readFileSync(file, "utf8"), raw);
|
|
177
180
|
});
|
|
178
181
|
|
|
182
|
+
for (const { tools, forwarded } of [
|
|
183
|
+
{ tools: ["read", "bash_background"], forwarded: true },
|
|
184
|
+
{ tools: ["read", "bash_background", "job_list", "job_stop"], forwarded: true },
|
|
185
|
+
{ tools: ["read", "grep"], forwarded: false },
|
|
186
|
+
{ tools: [], forwarded: false },
|
|
187
|
+
]) {
|
|
188
|
+
test(`background capability forwards the child job marker only for a declared bash_background (${tools.join(",") || "default tools"})`, async (t) => {
|
|
189
|
+
const root = fs.mkdtempSync(join(tmpdir(), "child-jobs-"));
|
|
190
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
191
|
+
const h = harness();
|
|
192
|
+
const env = { GENTLE_PI_CONFIG_HOME: join(root, "config"), GENTLE_PI_BACKGROUND_SUBAGENTS: "on" };
|
|
193
|
+
const task = h.runner.run(request({ cwd: root, env, agent: { ...explorer, tools } }));
|
|
194
|
+
await tick();
|
|
195
|
+
assert.equal(h.store.get(task.id)?.status, TASK_STATUS.RUNNING);
|
|
196
|
+
assert.equal(h.spawnOptions[0].env.GENTLE_PI_AGENTS_CHILD_JOBS, forwarded ? "1" : undefined);
|
|
197
|
+
h.runner.cancel(task.id);
|
|
198
|
+
await tick();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
179
202
|
const FOUR_MIN_MS = 4 * 60_000;
|
|
180
203
|
|
|
181
204
|
function argumentUpdate(type: string, fields: Record<string, unknown> = {}): Record<string, unknown> {
|
|
@@ -972,6 +995,88 @@ test("runner resolves the pi command at each spawn after the entry disappears",
|
|
|
972
995
|
assert.deepEqual(h.spawnOptions[1].args, childArguments(request()));
|
|
973
996
|
});
|
|
974
997
|
|
|
998
|
+
test("piCommand fallback on win32 re-resolves cli.js via pi.cmd from PATH without shell (#2887)", () => {
|
|
999
|
+
const procWin = {
|
|
1000
|
+
execPath: "C:\\Program Files\\nodejs\\node.exe",
|
|
1001
|
+
argv: ["C:\\Program Files\\nodejs\\node.exe", "C:\\pnpm\\global\\node_modules\\@earendil-works\\pi-coding-agent\\dist\\cli.js"],
|
|
1002
|
+
env: { Path: "C:\\pnpm;C:\\Windows\\System32" },
|
|
1003
|
+
platform: "win32" as const,
|
|
1004
|
+
};
|
|
1005
|
+
const newCli = "C:\\pnpm\\global\\5\\node_modules\\@earendil-works\\pi-coding-agent\\dist\\cli.js";
|
|
1006
|
+
const cmdContent = `@ECHO off\r\nnode "${newCli}" %*\r\n`;
|
|
1007
|
+
const exists = (p: string) => p === "C:\\pnpm\\pi.cmd" || p === newCli;
|
|
1008
|
+
const readFile = (p: string) => (p === "C:\\pnpm\\pi.cmd" ? cmdContent : "");
|
|
1009
|
+
|
|
1010
|
+
// While original cli.js still exists, reuses it
|
|
1011
|
+
assert.deepEqual(piCommand(procWin, (p) => p === procWin.argv[1]), { command: procWin.execPath, args: [procWin.argv[1]] });
|
|
1012
|
+
// When original cli.js disappears after upgrade, resolves the new cli.js from pi.cmd on PATH
|
|
1013
|
+
assert.deepEqual(piCommand(procWin, exists, readFile), { command: procWin.execPath, args: [newCli] });
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
test("piCommand resolves npm and pnpm cmd-shims with relative paths on win32 (#2887)", () => {
|
|
1017
|
+
const procWin = {
|
|
1018
|
+
execPath: "C:\\Program Files\\nodejs\\node.exe",
|
|
1019
|
+
argv: ["C:\\Program Files\\nodejs\\node.exe", "C:\\missing\\cli.js"],
|
|
1020
|
+
env: { PATH: "C:\\AppData\\npm" },
|
|
1021
|
+
platform: "win32" as const,
|
|
1022
|
+
};
|
|
1023
|
+
// npm cmd-shim style with %dp0%
|
|
1024
|
+
const npmShim = `@ECHO off\r\n"%_prog%" "%dp0%\\node_modules\\@earendil-works\\pi-coding-agent\\dist\\cli.js" %*\r\n`;
|
|
1025
|
+
const targetJs = "C:\\AppData\\npm\\node_modules\\@earendil-works\\pi-coding-agent\\dist\\cli.js";
|
|
1026
|
+
const exists = (p: string) => p === "C:\\AppData\\npm\\pi.cmd" || p === targetJs;
|
|
1027
|
+
const readFile = (p: string) => (p === "C:\\AppData\\npm\\pi.cmd" ? npmShim : "");
|
|
1028
|
+
|
|
1029
|
+
assert.deepEqual(piCommand(procWin, exists, readFile), { command: procWin.execPath, args: [targetJs] });
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
test("piCommand honors GENTLE_PI_AGENTS_PI pointing to a .cmd shim by resolving its JS target (#2887)", () => {
|
|
1033
|
+
const procWin = {
|
|
1034
|
+
execPath: "C:\\Program Files\\nodejs\\node.exe",
|
|
1035
|
+
argv: ["C:\\Program Files\\nodejs\\node.exe", "C:\\missing\\cli.js"],
|
|
1036
|
+
env: { GENTLE_PI_AGENTS_PI: "C:\\custom\\pi.cmd --model gpt-5" },
|
|
1037
|
+
platform: "win32" as const,
|
|
1038
|
+
};
|
|
1039
|
+
const customShim = `@ECHO off\r\nnode "%~dp0pi-launcher.js" %*\r\n`;
|
|
1040
|
+
const targetLauncher = "C:\\custom\\pi-launcher.js";
|
|
1041
|
+
const exists = (p: string) => p === "C:\\custom\\pi.cmd" || p === targetLauncher;
|
|
1042
|
+
const readFile = (p: string) => (p === "C:\\custom\\pi.cmd" ? customShim : "");
|
|
1043
|
+
|
|
1044
|
+
assert.deepEqual(piCommand(procWin, exists, readFile), {
|
|
1045
|
+
command: procWin.execPath,
|
|
1046
|
+
args: [targetLauncher, "--model", "gpt-5"],
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
test("runner spawns fallback pi through Node on win32 after upgrade without shell (#2887)", async () => {
|
|
1051
|
+
let existsOld = true;
|
|
1052
|
+
const newCli = "C:\\pnpm\\dist\\cli.js";
|
|
1053
|
+
const procWin = {
|
|
1054
|
+
execPath: "C:\\Program Files\\nodejs\\node.exe",
|
|
1055
|
+
argv: ["C:\\Program Files\\nodejs\\node.exe", "C:\\pi\\dist\\cli.js"],
|
|
1056
|
+
env: { Path: "C:\\pnpm" },
|
|
1057
|
+
platform: "win32" as const,
|
|
1058
|
+
};
|
|
1059
|
+
const cmdContent = `@ECHO off\r\nnode "%~dp0dist\\cli.js" %*\r\n`;
|
|
1060
|
+
const exists = (p: string) => (existsOld && p === procWin.argv[1]) || p === "C:\\pnpm\\pi.cmd" || p === newCli;
|
|
1061
|
+
const readFile = (p: string) => (p === "C:\\pnpm\\pi.cmd" ? cmdContent : "");
|
|
1062
|
+
|
|
1063
|
+
const h = harness({ resolvePi: () => piCommand(procWin, exists, readFile) });
|
|
1064
|
+
// First run before upgrade
|
|
1065
|
+
h.runner.run(request({ agent: { ...explorer, instructions: "audit & verify | status %VAR%" } }));
|
|
1066
|
+
await tick();
|
|
1067
|
+
assert.equal(h.spawnOptions[0].command, procWin.execPath);
|
|
1068
|
+
assert.equal(h.spawnOptions[0].args[0], procWin.argv[1]);
|
|
1069
|
+
|
|
1070
|
+
// Upgrade: old cli.js disappears, piCommand re-resolves via pi.cmd
|
|
1071
|
+
existsOld = false;
|
|
1072
|
+
h.runner.run(request({ agent: { ...explorer, instructions: "audit & verify | status %VAR%" } }));
|
|
1073
|
+
await tick();
|
|
1074
|
+
assert.equal(h.spawnOptions[1].command, procWin.execPath);
|
|
1075
|
+
assert.equal(h.spawnOptions[1].args[0], newCli);
|
|
1076
|
+
// Arguments with &, |, % and spaces are preserved verbatim in argv, never joined by a shell
|
|
1077
|
+
assert.ok(h.spawnOptions[1].args.includes("audit & verify | status %VAR%"));
|
|
1078
|
+
});
|
|
1079
|
+
|
|
975
1080
|
test("JsonLines splits on LF only, tolerates CRLF, and skips lines that are not JSON", () => {
|
|
976
1081
|
const seen: unknown[] = [];
|
|
977
1082
|
const lines = new JsonLines((value) => seen.push(value));
|
|
@@ -1142,6 +1247,80 @@ test("AgentRunner escalates to SIGTERM and SIGKILL if orderly cleanup exceeds cl
|
|
|
1142
1247
|
assert.deepEqual(children[0].killed, ["SIGTERM", "SIGKILL"]);
|
|
1143
1248
|
});
|
|
1144
1249
|
|
|
1250
|
+
test("a child that reports a running background job drains one bounded window before the orderly shutdown", async () => {
|
|
1251
|
+
const { store, runner, children, timers, advance } = harness({ exitOnKill: false, drainTimeoutMs: 2_000, cleanupTimeoutMs: 3_000 });
|
|
1252
|
+
const task = runner.run(request({ agent: { ...explorer, tools: ["read", "bash_background"] }, env: { GENTLE_PI_BACKGROUND_SUBAGENTS: "on" } }));
|
|
1253
|
+
await tick();
|
|
1254
|
+
const child = children[0];
|
|
1255
|
+
child.message({ id: "j1", kind: "job", message: JSON.stringify({ running: 1, pending: true }) });
|
|
1256
|
+
assert.deepEqual(child.sent.at(-1), { id: "j1", kind: "ack", accepted: true });
|
|
1257
|
+
child.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "waiting on CI" }] }] });
|
|
1258
|
+
child.emit({ type: "agent_settled" });
|
|
1259
|
+
await tick();
|
|
1260
|
+
|
|
1261
|
+
// The drain holds the orderly shutdown open; nothing has been signalled yet.
|
|
1262
|
+
assert.equal(store.get(task.id)?.status, TASK_STATUS.RUNNING);
|
|
1263
|
+
assert.equal(store.get(task.id)?.lastStep, "draining background jobs");
|
|
1264
|
+
assert.equal(child.child.stdin.writableEnded, false, "stdin stays open while the job drains");
|
|
1265
|
+
assert.deepEqual(child.killed, []);
|
|
1266
|
+
const drainTimer = timers.find((timer) => !timer.cancelled && timer.ms === 2_000);
|
|
1267
|
+
assert.ok(drainTimer, "one bounded drain window is scheduled");
|
|
1268
|
+
|
|
1269
|
+
// The bounded window expires: the ordinary orderly shutdown begins and escalates.
|
|
1270
|
+
advance(2_000);
|
|
1271
|
+
await tick();
|
|
1272
|
+
assert.ok(drainTimer!.cancelled);
|
|
1273
|
+
assert.equal(child.child.stdin.writableEnded, true, "the drain is bounded and ends by settling");
|
|
1274
|
+
const cleanupTimer = timers.find((timer) => !timer.cancelled && timer.ms === 3_000);
|
|
1275
|
+
assert.ok(cleanupTimer, "the ordinary cleanup window follows the drain");
|
|
1276
|
+
cleanupTimer!.fn();
|
|
1277
|
+
await tick();
|
|
1278
|
+
assert.deepEqual(child.killed, ["SIGTERM"]);
|
|
1279
|
+
const killTimer = timers.find((timer) => !timer.cancelled && timer.ms === 250);
|
|
1280
|
+
assert.ok(killTimer, "SIGKILL follows the drain like today");
|
|
1281
|
+
killTimer!.fn();
|
|
1282
|
+
await tick();
|
|
1283
|
+
assert.deepEqual(child.killed, ["SIGTERM", "SIGKILL"]);
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1286
|
+
test("a child job that finishes inside the drain ends it early and only one extension is allowed", async () => {
|
|
1287
|
+
const { store, runner, children, timers } = harness({ exitOnKill: false, drainTimeoutMs: 2_000, cleanupTimeoutMs: 3_000 });
|
|
1288
|
+
const task = runner.run(request({ agent: { ...explorer, tools: ["read", "bash_background"] }, env: { GENTLE_PI_BACKGROUND_SUBAGENTS: "on" } }));
|
|
1289
|
+
await tick();
|
|
1290
|
+
const child = children[0];
|
|
1291
|
+
child.message({ id: "j1", kind: "job", message: JSON.stringify({ running: 1, pending: true }) });
|
|
1292
|
+
child.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "waiting" }] }] });
|
|
1293
|
+
child.emit({ type: "agent_settled" });
|
|
1294
|
+
await tick();
|
|
1295
|
+
const drainTimer = timers.find((timer) => !timer.cancelled && timer.ms === 2_000)!;
|
|
1296
|
+
assert.ok(drainTimer);
|
|
1297
|
+
|
|
1298
|
+
child.message({ id: "j2", kind: "job", message: JSON.stringify({ running: 0, pending: false }) });
|
|
1299
|
+
await tick();
|
|
1300
|
+
assert.ok(drainTimer.cancelled, "the drain ends early when the child reports no running jobs");
|
|
1301
|
+
assert.equal(child.child.stdin.writableEnded, true);
|
|
1302
|
+
|
|
1303
|
+
// A later report cannot open a second extension.
|
|
1304
|
+
const before = timers.filter((timer) => !timer.cancelled && timer.ms === 2_000).length;
|
|
1305
|
+
child.message({ id: "j3", kind: "job", message: JSON.stringify({ running: 1, pending: true }) });
|
|
1306
|
+
await tick();
|
|
1307
|
+
assert.equal(timers.filter((timer) => !timer.cancelled && timer.ms === 2_000).length, before, "no unbounded re-drain after the first extension");
|
|
1308
|
+
});
|
|
1309
|
+
|
|
1310
|
+
test("a job frame that is not a valid child state is refused and does not open a drain", async () => {
|
|
1311
|
+
const { runner, children, timers } = harness({ exitOnKill: false, drainTimeoutMs: 2_000 });
|
|
1312
|
+
runner.run(request({ agent: { ...explorer, tools: ["read", "bash_background"] }, env: { GENTLE_PI_BACKGROUND_SUBAGENTS: "on" } }));
|
|
1313
|
+
await tick();
|
|
1314
|
+
const child = children[0];
|
|
1315
|
+
child.message({ id: "j1", kind: "job", message: "not json" });
|
|
1316
|
+
assert.deepEqual(child.sent.at(-1), { id: "j1", kind: "ack", accepted: false, error: "invalid child job state" });
|
|
1317
|
+
child.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "done" }] }] });
|
|
1318
|
+
child.emit({ type: "agent_settled" });
|
|
1319
|
+
await tick();
|
|
1320
|
+
assert.equal(child.child.stdin.writableEnded, true, "an unparseable job report does not delay settlement");
|
|
1321
|
+
assert.equal(timers.filter((timer) => !timer.cancelled && timer.ms === 2_000).length, 0);
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1145
1324
|
test("orderly cleanup escalation retains the full exit confirmation deadline after SIGKILL (#1740)", async () => {
|
|
1146
1325
|
let groupAlive = true;
|
|
1147
1326
|
const { store, runner, children, timers, advance } = harness({
|
|
@@ -2256,3 +2435,165 @@ test("advisories S2: session shutdown keeps a running or quarantined subagent's
|
|
|
2256
2435
|
assert.equal(existsSync(scratch), false, "the startup sweep removes the kept scratch once its owner ended");
|
|
2257
2436
|
next.shutdown();
|
|
2258
2437
|
});
|
|
2438
|
+
|
|
2439
|
+
const quotaEnd = { type: "agent_end", messages: [{ role: "assistant", content: [], stopReason: "error", errorMessage: "429 insufficient_quota: monthly usage limit reached" }] };
|
|
2440
|
+
|
|
2441
|
+
test("a subagent that runs out of quota switches its child to the next model in place and continues", async () => {
|
|
2442
|
+
const fallbacks: Array<{ task: string; from: string; to: string; category: string }> = [];
|
|
2443
|
+
const h = harness({ state: { model: { provider: "fb-a", id: "primary" } }, onFallback: (task, change) => { fallbacks.push({ task: task.id, ...change }); } });
|
|
2444
|
+
const task = h.runner.run(request({ model: { provider: "fb-a", id: "primary" }, thinking: "high", fallbacks: [{ model: "fb-b/second", thinking: "medium" }, { model: "fb-c/third" }] }));
|
|
2445
|
+
await tick();
|
|
2446
|
+
h.children[0].emit(quotaEnd);
|
|
2447
|
+
h.children[0].emit({ type: "agent_settled" });
|
|
2448
|
+
await tick(); await tick(); await tick();
|
|
2449
|
+
assert.notEqual(h.store.get(task.id)?.status, TASK_STATUS.FAILED, "the task is still alive");
|
|
2450
|
+
const sent = h.children[0].written.map((command) => command.type);
|
|
2451
|
+
assert.deepEqual(h.children[0].written.filter((command) => command.type === "set_model").map((command) => [command.provider, command.modelId]), [["fb-b", "second"]]);
|
|
2452
|
+
assert.deepEqual(h.children[0].written.filter((command) => command.type === "set_thinking_level").map((command) => command.level), ["medium"]);
|
|
2453
|
+
assert.ok(sent.lastIndexOf("prompt") > sent.indexOf("set_model"), "the continue prompt follows the switch");
|
|
2454
|
+
assert.match(String(h.children[0].written.at(-1)?.message), /continue/i);
|
|
2455
|
+
assert.equal(h.store.get(task.id)?.model, "fb-b/second");
|
|
2456
|
+
assert.deepEqual(fallbacks, [{ task: task.id, from: "fb-a/primary", to: "fb-b/second", category: "quota" }]);
|
|
2457
|
+
assert.equal(h.spawnOptions.length, 1, "the same child keeps going");
|
|
2458
|
+
h.children[0].emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "done on the fallback" }], stopReason: "stop" }] });
|
|
2459
|
+
h.children[0].emit({ type: "agent_settled" });
|
|
2460
|
+
const done = await h.runner.waitFor(task.id);
|
|
2461
|
+
assert.equal(done.status, TASK_STATUS.COMPLETED);
|
|
2462
|
+
assert.equal(done.result, "done on the fallback");
|
|
2463
|
+
});
|
|
2464
|
+
|
|
2465
|
+
test("errors another model would repeat, or an exhausted chain, fail the subagent as before", async () => {
|
|
2466
|
+
const context = harness({ state: {} });
|
|
2467
|
+
const contextTask = context.runner.run(request({ model: { provider: "fb-d", id: "one" }, fallbacks: [{ model: "fb-e/two" }] }));
|
|
2468
|
+
await tick();
|
|
2469
|
+
context.children[0].emit({ type: "agent_end", messages: [{ role: "assistant", content: [], stopReason: "error", errorMessage: "prompt is too long: maximum context length" }] });
|
|
2470
|
+
context.children[0].emit({ type: "agent_settled" });
|
|
2471
|
+
const failed = await context.runner.waitFor(contextTask.id);
|
|
2472
|
+
assert.equal(failed.status, TASK_STATUS.FAILED);
|
|
2473
|
+
assert.equal(context.children[0].written.some((command) => command.type === "set_model"), false);
|
|
2474
|
+
|
|
2475
|
+
const none = harness({ state: {} });
|
|
2476
|
+
const noneTask = none.runner.run(request({ model: { provider: "fb-f", id: "only" } }));
|
|
2477
|
+
await tick();
|
|
2478
|
+
none.children[0].emit(quotaEnd);
|
|
2479
|
+
none.children[0].emit({ type: "agent_settled" });
|
|
2480
|
+
assert.equal((await none.runner.waitFor(noneTask.id)).status, TASK_STATUS.FAILED, "no chain, no fallback");
|
|
2481
|
+
|
|
2482
|
+
const spent = harness({ state: {} });
|
|
2483
|
+
const spentTask = spent.runner.run(request({ model: { provider: "fb-g", id: "one" }, fallbacks: [{ model: "fb-h/two" }] }));
|
|
2484
|
+
await tick();
|
|
2485
|
+
spent.children[0].emit(quotaEnd);
|
|
2486
|
+
spent.children[0].emit({ type: "agent_settled" });
|
|
2487
|
+
await tick(); await tick(); await tick();
|
|
2488
|
+
spent.children[0].emit(quotaEnd);
|
|
2489
|
+
spent.children[0].emit({ type: "agent_settled" });
|
|
2490
|
+
const exhausted = await spent.runner.waitFor(spentTask.id);
|
|
2491
|
+
assert.equal(exhausted.status, TASK_STATUS.FAILED, "the last model failing ends the task");
|
|
2492
|
+
assert.match(exhausted.error ?? "", /quota/);
|
|
2493
|
+
assert.equal(spent.children[0].written.filter((command) => command.type === "set_model").length, 1);
|
|
2494
|
+
});
|
|
2495
|
+
|
|
2496
|
+
test("a launch whose primary model is cooling down starts on the first usable fallback", async () => {
|
|
2497
|
+
const first = harness({ state: {} });
|
|
2498
|
+
const task = first.runner.run(request({ model: { provider: "fb-i", id: "cool" }, fallbacks: [{ model: "fb-j/warm" }] }));
|
|
2499
|
+
await tick();
|
|
2500
|
+
first.children[0].emit(quotaEnd);
|
|
2501
|
+
first.children[0].emit({ type: "agent_settled" });
|
|
2502
|
+
await tick(); await tick();
|
|
2503
|
+
const next = harness({ state: {} });
|
|
2504
|
+
next.runner.run(request({ model: { provider: "fb-i", id: "cool" }, thinking: "low", fallbacks: [{ model: "fb-j/warm", thinking: "high" }] }));
|
|
2505
|
+
await tick();
|
|
2506
|
+
const args = next.spawnOptions[0]!.args;
|
|
2507
|
+
assert.equal(args[args.indexOf("--model") + 1], "fb-j/warm:high", "the cooled primary is skipped at launch");
|
|
2508
|
+
assert.ok(task.id);
|
|
2509
|
+
});
|
|
2510
|
+
|
|
2511
|
+
test("a fallback Pi refuses (no key, unknown model) gives way to the next one, and only the model actually used is announced", async () => {
|
|
2512
|
+
const announced: string[] = [];
|
|
2513
|
+
const h = harness({ state: {}, reject: (command) => command.type === "set_model" && command.provider === "fb-l", onFallback: (_task, change) => { announced.push(`${change.from}->${change.to}`); } });
|
|
2514
|
+
const task = h.runner.run(request({ model: { provider: "fb-k", id: "one" }, fallbacks: [{ model: "fb-l/two" }, { model: "fb-m/three" }] }));
|
|
2515
|
+
await tick();
|
|
2516
|
+
h.children[0].emit(quotaEnd);
|
|
2517
|
+
h.children[0].emit({ type: "agent_settled" });
|
|
2518
|
+
for (let i = 0; i < 6; i++) await tick();
|
|
2519
|
+
assert.deepEqual(h.children[0].written.filter((command) => command.type === "set_model").map((command) => `${command.provider}/${command.modelId}`), ["fb-l/two", "fb-m/three"]);
|
|
2520
|
+
assert.deepEqual(announced, ["fb-k/one->fb-m/three"]);
|
|
2521
|
+
assert.equal(h.store.get(task.id)?.model, "fb-m/three");
|
|
2522
|
+
assert.notEqual(h.store.get(task.id)?.status, TASK_STATUS.FAILED);
|
|
2523
|
+
const none = harness({ state: {}, reject: (command) => command.type === "set_model" });
|
|
2524
|
+
const lost = none.runner.run(request({ model: { provider: "fb-n", id: "one" }, fallbacks: [{ model: "fb-o/two" }] }));
|
|
2525
|
+
await tick();
|
|
2526
|
+
none.children[0].emit(quotaEnd);
|
|
2527
|
+
none.children[0].emit({ type: "agent_settled" });
|
|
2528
|
+
const failed = await none.runner.waitFor(lost.id);
|
|
2529
|
+
assert.equal(failed.status, TASK_STATUS.FAILED);
|
|
2530
|
+
assert.match(failed.error ?? "", /could not switch to fb-o\/two: No API key/);
|
|
2531
|
+
});
|
|
2532
|
+
|
|
2533
|
+
test("starting on a fallback because the primary is cooling down is announced like any other switch", async () => {
|
|
2534
|
+
const first = harness({ state: {} });
|
|
2535
|
+
first.runner.run(request({ model: { provider: "fb-p", id: "cool" }, fallbacks: [{ model: "fb-q/warm" }] }));
|
|
2536
|
+
await tick();
|
|
2537
|
+
first.children[0].emit(quotaEnd);
|
|
2538
|
+
first.children[0].emit({ type: "agent_settled" });
|
|
2539
|
+
await tick(); await tick();
|
|
2540
|
+
const announced: Array<{ from: string; to: string; category: string; launch?: boolean }> = [];
|
|
2541
|
+
const next = harness({ state: {}, onFallback: (_task, change) => { announced.push(change); } });
|
|
2542
|
+
next.runner.run(request({ model: { provider: "fb-p", id: "cool" }, fallbacks: [{ model: "fb-q/warm" }] }));
|
|
2543
|
+
await tick();
|
|
2544
|
+
assert.deepEqual(announced, [{ from: "fb-p/cool", to: "fb-q/warm", category: "quota", launch: true }]);
|
|
2545
|
+
});
|
|
2546
|
+
|
|
2547
|
+
test("the task record remembers the model a fallback moved away from", async () => {
|
|
2548
|
+
const h = harness({ state: {} });
|
|
2549
|
+
const task = h.runner.run(request({ model: { provider: "fb-r", id: "one" }, fallbacks: [{ model: "fb-s/two" }] }));
|
|
2550
|
+
await tick();
|
|
2551
|
+
h.children[0].emit(quotaEnd);
|
|
2552
|
+
h.children[0].emit({ type: "agent_settled" });
|
|
2553
|
+
for (let i = 0; i < 4; i++) await tick();
|
|
2554
|
+
assert.equal(h.store.get(task.id)?.fallbackFrom, "fb-r/one");
|
|
2555
|
+
assert.equal(h.store.get(task.id)?.model, "fb-s/two");
|
|
2556
|
+
});
|
|
2557
|
+
|
|
2558
|
+
test("a fallback step without its own effort runs at the agent's configured effort", async () => {
|
|
2559
|
+
const h = harness({ state: {} });
|
|
2560
|
+
h.runner.run(request({ model: { provider: "fb-u", id: "one" }, thinking: "high", fallbacks: [{ model: "fb-v/two", thinking: "low" }, { model: "fb-w/three" }] }));
|
|
2561
|
+
await tick();
|
|
2562
|
+
for (let round = 0; round < 2; round++) {
|
|
2563
|
+
h.children[0].emit(quotaEnd);
|
|
2564
|
+
h.children[0].emit({ type: "agent_settled" });
|
|
2565
|
+
for (let i = 0; i < 6; i++) await tick();
|
|
2566
|
+
}
|
|
2567
|
+
assert.deepEqual(h.children[0].written.filter((command) => command.type === "set_thinking_level").map((command) => command.level), ["low", "high"]);
|
|
2568
|
+
});
|
|
2569
|
+
|
|
2570
|
+
test("a launch fallback is announced only once the child actually started", async () => {
|
|
2571
|
+
const first = harness({ state: {} });
|
|
2572
|
+
first.runner.run(request({ model: { provider: "fb-x", id: "cool" }, fallbacks: [{ model: "fb-y/warm" }] }));
|
|
2573
|
+
await tick();
|
|
2574
|
+
first.children[0].emit(quotaEnd);
|
|
2575
|
+
first.children[0].emit({ type: "agent_settled" });
|
|
2576
|
+
await tick(); await tick();
|
|
2577
|
+
const announced: string[] = [];
|
|
2578
|
+
const failing = harness({ failStart: true, onFallback: (_task, change) => { announced.push(change.to); } });
|
|
2579
|
+
const task = failing.runner.run(request({ model: { provider: "fb-x", id: "cool" }, fallbacks: [{ model: "fb-y/warm" }] }));
|
|
2580
|
+
await failing.runner.waitFor(task.id);
|
|
2581
|
+
assert.deepEqual(announced, [], "a spawn that failed announces nothing");
|
|
2582
|
+
const starting = harness({ state: {}, onFallback: (_task, change) => { announced.push(change.to); } });
|
|
2583
|
+
starting.runner.run(request({ model: { provider: "fb-x", id: "cool" }, fallbacks: [{ model: "fb-y/warm" }] }));
|
|
2584
|
+
await tick();
|
|
2585
|
+
assert.deepEqual(announced, ["fb-y/warm"]);
|
|
2586
|
+
});
|
|
2587
|
+
|
|
2588
|
+
test("a task cancelled after Pi accepted the new model records that model", async () => {
|
|
2589
|
+
const h = harness({ state: {}, hold: (command) => command.type === "set_thinking_level" });
|
|
2590
|
+
const task = h.runner.run(request({ model: { provider: "fb-z", id: "one" }, fallbacks: [{ model: "fb-za/two", thinking: "low" }] }));
|
|
2591
|
+
await tick();
|
|
2592
|
+
h.children[0].emit(quotaEnd);
|
|
2593
|
+
h.children[0].emit({ type: "agent_settled" });
|
|
2594
|
+
for (let i = 0; i < 4; i++) await tick();
|
|
2595
|
+
h.runner.cancel(task.id);
|
|
2596
|
+
const done = await h.runner.waitFor(task.id);
|
|
2597
|
+
assert.equal(done.model, "fb-za/two");
|
|
2598
|
+
assert.equal(done.fallbackFrom, "fb-z/one");
|
|
2599
|
+
});
|
|
@@ -298,6 +298,33 @@ test("AgentsView keys move the selection, scroll, follow, cancel, open, and clos
|
|
|
298
298
|
assert.deepEqual(events, ["cancel:a", "open:a", "close"]);
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
+
test("AgentsView clamps thread scrolling at the bottom so the first upward key moves", () => {
|
|
302
|
+
for (const [down, up] of [["\x0a", "\x0b"], ["\x1b[6~", "\x1b[5~"]]) {
|
|
303
|
+
const { store, view } = harness(8);
|
|
304
|
+
try {
|
|
305
|
+
store.add(task("a"));
|
|
306
|
+
for (let i = 0; i < 30; i++) store.apply("a", { type: TASK_EVENT.TEXT, text: `line ${i}\n` }, 2000);
|
|
307
|
+
const bottom = view.render(80).slice(1, 5);
|
|
308
|
+
assert.match(bottom.join("\n"), /line 29/);
|
|
309
|
+
view.handleInput(up);
|
|
310
|
+
const previousPage = view.render(80).slice(1, 5);
|
|
311
|
+
assert.notDeepEqual(previousPage, bottom, "ordinary upward scrolling still moves one page");
|
|
312
|
+
view.handleInput(down);
|
|
313
|
+
assert.deepEqual(view.render(80).slice(1, 5), bottom, "ordinary downward scrolling returns to the bottom");
|
|
314
|
+
for (let i = 0; i < 7; i++) {
|
|
315
|
+
view.handleInput(down);
|
|
316
|
+
assert.deepEqual(view.render(80).slice(1, 5), bottom, "extra downward presses leave the bottom visible");
|
|
317
|
+
}
|
|
318
|
+
view.handleInput(up);
|
|
319
|
+
assert.deepEqual(view.render(80).slice(1, 5), previousPage, "the first upward press moves immediately without consuming hidden offset");
|
|
320
|
+
view.handleInput("f");
|
|
321
|
+
assert.deepEqual(view.render(80).slice(1, 5), bottom, "follow still restores the tail");
|
|
322
|
+
} finally {
|
|
323
|
+
view.dispose();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
301
328
|
test("AgentsView subscribes only to the selected task and survives an empty store", () => {
|
|
302
329
|
const { store, view, renders } = harness(6);
|
|
303
330
|
assert.match(stripAnsi(view.render(60)[1]), /no tasks yet/);
|