gentle-pi 4.6.0 → 4.8.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 +65 -55
- package/assets/agents/gentle-ai-explore.md +4 -3
- package/assets/agents/gentle-ai-verify.md +23 -6
- package/assets/agents/gentle-ai-worker.md +9 -6
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +2 -3
- package/assets/agents/jd-judge-b.md +2 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +759 -16
- package/assets/design-canvas/canvas.js +2 -1497
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +6 -1
- package/assets/migrations/agent-body-history.json +40 -1
- package/assets/orchestrator-delegation-reference.md +10 -16
- package/assets/orchestrator-delegation.md +5 -5
- package/assets/orchestrator-full-delegation-card.md +64 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +5 -5
- package/assets/orchestrator-prompts.md +2 -2
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +14 -13
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +12 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +21 -25
- package/bin/gentle-shell.mjs +292 -65
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/agent-status.md +61 -0
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +20 -10
- package/docs/delegated-verification.md +46 -8
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +40 -0
- package/docs/gentle-shell.md +91 -30
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +17 -4
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +142 -45
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +53 -0
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +11 -1
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +3 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +559 -66
- package/extensions/gentle-ai.ts +2001 -518
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +398 -115
- package/extensions/gentle-todo.ts +66 -27
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +349 -167
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +93 -6
- package/lib/agents-history.ts +24 -5
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +55 -7
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +272 -16
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +197 -32
- package/lib/card-content-policy.ts +8 -6
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +236 -17
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +204 -14
- package/lib/gentle-shell-bundled.ts +106 -28
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +358 -144
- package/lib/jobs-view.ts +198 -11
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +31 -4
- package/lib/nan-provider.ts +42 -28
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +172 -20
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +129 -0
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +116 -0
- package/lib/review-coordinator.ts +407 -0
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +63 -4
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/verifier-admission.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +46 -16
- package/package.json +3 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +106 -28
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +169 -17
- package/runtime/review-integration-v2.mjs +63 -4
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +179 -0
- package/scripts/build-runtime-modules.mjs +1 -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-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +33 -22
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +46 -16
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- 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 +40 -28
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +50 -19
- package/scripts/voice-worker.cjs +32 -6
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +16 -13
- package/skills/gentle-ai/SKILL.md +7 -7
- 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/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -11
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +10 -11
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +106 -1
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +215 -3
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +12 -1
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +99 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +51 -3
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +31 -6
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-safety.test.ts +11 -0
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +32 -10
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -695
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +160 -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 +1403 -20
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +135 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +233 -43
- package/tests/gentle-design.test.ts +386 -1
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +293 -31
- package/tests/gentle-shell-launcher.test.ts +78 -11
- package/tests/gentle-shell.test.ts +1017 -146
- package/tests/gentle-todo.test.ts +51 -11
- 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 +8 -4
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +97 -0
- package/tests/inprocess-reviewer.test.ts +249 -4
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +115 -14
- package/tests/installer-preflight.test.ts +54 -5
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +215 -13
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/jobs-view.test.ts +260 -6
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +17 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +13 -2
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +35 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +154 -0
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +13 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +4 -3
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +16 -13
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +372 -0
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +25 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/questionnaire-view.test.ts +115 -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 +17 -12
- 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 +112 -1
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +189 -0
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +80 -2
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +66 -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 +107 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +98 -12
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +462 -0
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +105 -11
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- 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 +39 -2
- package/tests/review-reviewer-evidence.test.ts +223 -0
- package/tests/review-risk-assessment.test.ts +126 -8
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +53 -3
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +122 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +1461 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +264 -0
- package/tests/task-size-routing-contract.test.ts +45 -12
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +162 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +77 -6
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +276 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +62 -18
- package/tests/yolo-session-policy.test.ts +270 -1
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
package/lib/agents-runner.ts
CHANGED
|
@@ -2,18 +2,19 @@ import { pickModel, sharedCooldown, shouldFallBack, type ModelCooldown } from ".
|
|
|
2
2
|
import type { FallbackChain } from "./model-fallback-store.ts";
|
|
3
3
|
import { fallbackContinuePrompt } from "./model-fallback-notice.ts";
|
|
4
4
|
import { isSessionChangeEvidence, type SessionChangeEvidence } from "./session-changes.ts";
|
|
5
|
-
import { chmodSync, existsSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { chmodSync, existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { DefaultPackageManager, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { tmpdir, userInfo } from "node:os";
|
|
8
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
8
|
+
import { basename, dirname, isAbsolute, join, resolve, win32 } from "node:path";
|
|
9
9
|
import { Duplex, type Readable, type Writable } from "node:stream";
|
|
10
10
|
import { stripVTControlCharacters } from "node:util";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
11
12
|
import { withoutInteractiveHost } from "./rpc-host.ts";
|
|
12
13
|
import { gentlePiConfigHome } from "./agent-home.ts";
|
|
13
14
|
import { resolveBackgroundSubagentsPolicy } from "./background-subagents-policy.ts";
|
|
14
15
|
import { childPackageExtensionArgs } from "./child-package-injection.ts";
|
|
15
16
|
import { AGENT_MODE, formatModelRef, parseModelRef, type AgentDefinition, type AgentMode, type ModelRef } from "./agents-config.ts";
|
|
16
|
-
import { CHILD_QUERY_MAX_INFLIGHT, CHILD_QUERY_TIMEOUT_MS, parseChildFrame, validChildMessage, validChildQueryId } from "./agents-messaging.ts";
|
|
17
|
+
import { CHILD_MESSAGE_MAX_BYTES, CHILD_QUERY_MAX_INFLIGHT, CHILD_QUERY_TIMEOUT_ERROR, CHILD_QUERY_TIMEOUT_MS, parseChildFrame, parseChildJobState, validChildMessage, validChildQueryId } from "./agents-messaging.ts";
|
|
17
18
|
import { ParentStandingReviewPermissionBroker } from "./review-session-standing-permission-ipc.ts";
|
|
18
19
|
import { isFinished, normalizeRpcEvent, ToolArgumentProgress, TASK_EVENT, TASK_STATUS, taskLabel, type AskRequest, type ChildResponseObservation, type TaskRecord, type TaskStore, type TerminalErrorCategory } from "./agents-protocol.ts";
|
|
19
20
|
import { WriterSurfaceRegistry, writerSurfaceConflictMessage } from "./writer-surfaces.ts";
|
|
@@ -79,6 +80,8 @@ export interface RunnerLimits {
|
|
|
79
80
|
toolStallTimeoutMs?: number;
|
|
80
81
|
// Bounded asynchronous cleanup window allowed after settlement before escalating to SIGTERM/SIGKILL.
|
|
81
82
|
cleanupTimeoutMs?: number;
|
|
83
|
+
// One bounded drain granted when agent_settled arrives while a child background job still runs.
|
|
84
|
+
drainTimeoutMs?: number;
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
export interface AskAnswer {
|
|
@@ -190,6 +193,7 @@ interface ProcessLike {
|
|
|
190
193
|
execPath: string;
|
|
191
194
|
argv: string[];
|
|
192
195
|
env: NodeJS.ProcessEnv;
|
|
196
|
+
platform?: NodeJS.Platform;
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
interface Pending {
|
|
@@ -199,6 +203,8 @@ interface Pending {
|
|
|
199
203
|
interface PendingQuery {
|
|
200
204
|
cancel: () => void;
|
|
201
205
|
replying: boolean;
|
|
206
|
+
/** When the query expires; the stall watchdog never fires before it. */
|
|
207
|
+
deadline: number;
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
interface PendingReply {
|
|
@@ -219,6 +225,8 @@ interface LiveTask {
|
|
|
219
225
|
queries: Map<string, PendingQuery>;
|
|
220
226
|
replies: Map<string, PendingReply>;
|
|
221
227
|
cancelStall: () => void;
|
|
228
|
+
/** True while the armed stall budget was lengthened to cover a pending query. */
|
|
229
|
+
stallCoversQuery?: boolean;
|
|
222
230
|
cancelGrace: () => void;
|
|
223
231
|
processGroup: number | undefined;
|
|
224
232
|
terminal: { status: TaskRecord["status"]; error: string | null } | undefined;
|
|
@@ -228,6 +236,10 @@ interface LiveTask {
|
|
|
228
236
|
/** The child's own TMPDIR, removed when the child ends unless its exit is unconfirmed. */
|
|
229
237
|
scratchDir?: string;
|
|
230
238
|
cleanupDeadlineAt: number | undefined;
|
|
239
|
+
/** The child's last reported background-job state, if any (#2266). */
|
|
240
|
+
childJobState?: { running: number; pending: boolean };
|
|
241
|
+
/** One bounded post-settlement drain while the child's background jobs finish (#2266). */
|
|
242
|
+
drain?: { status: TaskRecord["status"]; error: string | null; cancel: () => void };
|
|
231
243
|
quarantined: boolean;
|
|
232
244
|
nextId: number;
|
|
233
245
|
permissionBroker?: ParentStandingReviewPermissionBroker;
|
|
@@ -254,15 +266,21 @@ export const MAX_INLINE_INSTRUCTIONS_BYTES = 1000;
|
|
|
254
266
|
const MAX_TRANSPORT_PREFIX_CHARS = 64;
|
|
255
267
|
const CHILD_MARKER = "GENTLE_PI_AGENTS_CHILD";
|
|
256
268
|
const IPC_MARKER = "GENTLE_PI_AGENTS_OWNED_IPC";
|
|
269
|
+
/** Forwarded to the child only when a declared `bash_background` admitted its policy (#2266). */
|
|
270
|
+
export const CHILD_JOBS_ENV = "GENTLE_PI_AGENTS_CHILD_JOBS";
|
|
257
271
|
const PARENT_NOTIFICATION_TOOL = "subagent_parent_message";
|
|
258
272
|
/** The exact --tools list, so the child can report requested names Pi dropped silently (#1690). */
|
|
259
273
|
export const REQUESTED_TOOLS_ENV = "GENTLE_PI_AGENTS_REQUESTED_TOOLS";
|
|
274
|
+
/** Set only for the package-owned generic agents: the child drops Pi's skills catalog. */
|
|
275
|
+
export const CHILD_SKILLS_CATALOG_ENV = "GENTLE_PI_AGENTS_NO_SKILLS_CATALOG";
|
|
260
276
|
const DEFAULT_TOOLS: readonly string[] = [];
|
|
261
277
|
const TERMINATION_GRACE_MS = 250;
|
|
262
278
|
const GROUP_CONFIRM_MS = 25;
|
|
263
279
|
const GROUP_CONFIRM_DEADLINE_MS = 1_000;
|
|
264
280
|
const QUARANTINE_PROBE_MS = 1_000;
|
|
265
281
|
export const DEFAULT_CLEANUP_TIMEOUT_MS = 5_000;
|
|
282
|
+
// One bounded drain window for a child's own background jobs at settlement (#2266).
|
|
283
|
+
export const DEFAULT_DRAIN_TIMEOUT_MS = 5_000;
|
|
266
284
|
const QUERY_REJECTION_ERRORS = new Set([
|
|
267
285
|
"invalid child IPC frame",
|
|
268
286
|
"invalid child IPC correlation",
|
|
@@ -273,10 +291,25 @@ const QUERY_REJECTION_ERRORS = new Set([
|
|
|
273
291
|
"task parent is not the active host session",
|
|
274
292
|
"duplicate query request",
|
|
275
293
|
"too many pending parent queries",
|
|
276
|
-
|
|
294
|
+
CHILD_QUERY_TIMEOUT_ERROR,
|
|
277
295
|
"parent rejected query",
|
|
278
296
|
]);
|
|
279
297
|
const QUERY_REJECTION = Symbol("query rejection");
|
|
298
|
+
// Queries that settled unanswered (expired or closed) stay answerable once as a
|
|
299
|
+
// steering message; bounded per task and across tasks.
|
|
300
|
+
const CLOSED_QUERIES_PER_TASK = 16;
|
|
301
|
+
const CLOSED_QUERY_TASKS = 64;
|
|
302
|
+
// A child waiting on its query is not stalled: the watchdog waits for the
|
|
303
|
+
// query's own deadline plus this margin, then the normal budget returns.
|
|
304
|
+
export const QUERY_STALL_MARGIN_MS = 5_000;
|
|
305
|
+
|
|
306
|
+
/** What a late answer to a closed query became; see `AgentRunner.replyLate`. */
|
|
307
|
+
export type LateReply = "delivered" | "not running" | "too large";
|
|
308
|
+
|
|
309
|
+
/** The steering text a late answer reaches the child with. */
|
|
310
|
+
export function lateQueryAnswer(requestId: string, message: string): string {
|
|
311
|
+
return `Answer to your earlier question (${requestId}; it expired before the reply arrived): ${message}`;
|
|
312
|
+
}
|
|
280
313
|
|
|
281
314
|
function rejectQuery(error: string): never {
|
|
282
315
|
throw { [QUERY_REJECTION]: error };
|
|
@@ -329,6 +362,18 @@ function requestedWebPackagePaths(request: TaskRequest): string[] {
|
|
|
329
362
|
}
|
|
330
363
|
}
|
|
331
364
|
|
|
365
|
+
// The package-owned generic agents receive the exact skill paths they need in
|
|
366
|
+
// the task and read them with `read`, so their children drop Pi's skills
|
|
367
|
+
// catalog (extensions/child-context.ts). Identified by name plus the global
|
|
368
|
+
// `agents/` directory the package installs into; a project or `subagents/`
|
|
369
|
+
// agent reusing a name keeps the catalog.
|
|
370
|
+
const NO_SKILLS_CATALOG_AGENTS = new Set(["gentle-ai-worker", "gentle-ai-explore", "gentle-ai-verify"]);
|
|
371
|
+
|
|
372
|
+
function dropsSkillsCatalog(agent: TaskRequest["agent"]): boolean {
|
|
373
|
+
return NO_SKILLS_CATALOG_AGENTS.has(agent.name) && agent.scope === "global" &&
|
|
374
|
+
basename(dirname(agent.filePath)) === "agents" && basename(agent.filePath) === `${agent.name}.md`;
|
|
375
|
+
}
|
|
376
|
+
|
|
332
377
|
export function childArguments(request: TaskRequest, instructionsPath?: string): string[] {
|
|
333
378
|
const args = ["--mode", "rpc", "--session-dir", request.sessionDir];
|
|
334
379
|
const extensionPaths = [...new Set(request.extensionPaths ?? [])];
|
|
@@ -353,16 +398,124 @@ export function childArguments(request: TaskRequest, instructionsPath?: string):
|
|
|
353
398
|
return args;
|
|
354
399
|
}
|
|
355
400
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Resolves the underlying JavaScript entry point targeted by a Windows .cmd or .bat shim.
|
|
403
|
+
*
|
|
404
|
+
* Scans the shim text for referenced .js/.mjs/.cjs files (such as npm or pnpm cmd-shims)
|
|
405
|
+
* or inspects adjacent package metadata without invoking cmd.exe or a shell.
|
|
406
|
+
*/
|
|
407
|
+
export function resolvePiScriptFromCmd(
|
|
408
|
+
cmdPath: string,
|
|
409
|
+
exists: (path: string) => boolean = existsSync,
|
|
410
|
+
readFile: (path: string) => string = (p) => readFileSync(p, "utf8"),
|
|
411
|
+
): string | undefined {
|
|
412
|
+
const baseDir = win32.dirname(cmdPath);
|
|
413
|
+
let text = "";
|
|
414
|
+
try {
|
|
415
|
+
text = readFile(cmdPath);
|
|
416
|
+
} catch {
|
|
417
|
+
text = "";
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (text) {
|
|
421
|
+
const targetMatch = /^#\s*cmd-shim-target\s*=\s*([^\r\n]+)$/m.exec(text);
|
|
422
|
+
if (targetMatch) {
|
|
423
|
+
const candidate = targetMatch[1].trim();
|
|
424
|
+
const resolved = win32.isAbsolute(candidate) ? candidate : win32.resolve(baseDir, candidate);
|
|
425
|
+
if (exists(resolved)) return resolved;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const scriptMatches = text.matchAll(/(?:["'])([^"']+\.[cm]?js)(?:["'])|(?:^|\s)((?:%~?dp0|%dp0%)\\?[^\s"']+\.[cm]?js)(?:\s|$)/gi);
|
|
429
|
+
for (const m of scriptMatches) {
|
|
430
|
+
const raw = (m[1] ?? m[2])?.trim();
|
|
431
|
+
if (!raw) continue;
|
|
432
|
+
const stripped = raw.replace(/^(?:%~?dp0|%dp0%)\\?/i, "");
|
|
433
|
+
const candidate = /^(?:%~?dp0|%dp0%)/i.test(raw) || !win32.isAbsolute(stripped)
|
|
434
|
+
? win32.resolve(baseDir, stripped)
|
|
435
|
+
: stripped;
|
|
436
|
+
if (exists(candidate)) return candidate;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const standardPaths = [
|
|
441
|
+
win32.join(baseDir, "node_modules", "@earendil-works", "pi-coding-agent", "dist", "cli.js"),
|
|
442
|
+
win32.join(baseDir, "node_modules", "@earendil-works", "pi-coding-agent", "dist", "bundle", "cli.js"),
|
|
443
|
+
win32.join(baseDir, "pi-launcher.js"),
|
|
444
|
+
win32.join(baseDir, "dist", "cli.js"),
|
|
445
|
+
win32.join(baseDir, "dist", "bundle", "cli.js"),
|
|
446
|
+
];
|
|
447
|
+
for (const candidate of standardPaths) {
|
|
448
|
+
if (exists(candidate)) return candidate;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Searches the Windows PATH and known locations for an installed pi command,
|
|
456
|
+
* resolving .cmd shims to their direct Node script entry points to avoid cmd.exe shell invocation.
|
|
457
|
+
*/
|
|
458
|
+
export function findWindowsPiCommand(
|
|
459
|
+
proc: ProcessLike = process,
|
|
460
|
+
exists: (path: string) => boolean = existsSync,
|
|
461
|
+
readFile: (path: string) => string = (p) => readFileSync(p, "utf8"),
|
|
462
|
+
): PiCommand | undefined {
|
|
463
|
+
const pathEnv = proc.env.Path ?? proc.env.PATH ?? "";
|
|
464
|
+
for (const entry of pathEnv.split(";")) {
|
|
465
|
+
const dir = entry.length >= 2 && entry.startsWith('"') && entry.endsWith('"')
|
|
466
|
+
? entry.slice(1, -1)
|
|
467
|
+
: entry;
|
|
468
|
+
if (!dir) continue;
|
|
469
|
+
|
|
470
|
+
const candidateExe = win32.join(dir, "pi.exe");
|
|
471
|
+
if (exists(candidateExe)) {
|
|
472
|
+
return { command: candidateExe, args: [] };
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
for (const ext of [".cmd", ".bat"]) {
|
|
476
|
+
const candidateCmd = win32.join(dir, `pi${ext}`);
|
|
477
|
+
if (exists(candidateCmd)) {
|
|
478
|
+
const script = resolvePiScriptFromCmd(candidateCmd, exists, readFile);
|
|
479
|
+
if (script) {
|
|
480
|
+
return { command: proc.execPath, args: [script] };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return undefined;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Resolves the pi invocation command for subagent execution.
|
|
490
|
+
*
|
|
491
|
+
* Reuses the running pi CLI entry point while it exists on disk.
|
|
492
|
+
* When the running entry point disappears (e.g. after a package upgrade on Windows),
|
|
493
|
+
* re-resolves the current installation from PATH and returns Node plus the target script
|
|
494
|
+
* so arguments are never passed through an unescaped shell wrapper.
|
|
495
|
+
*/
|
|
496
|
+
export function piCommand(
|
|
497
|
+
proc: ProcessLike = process,
|
|
498
|
+
exists: (path: string) => boolean = existsSync,
|
|
499
|
+
readFile: (path: string) => string = (p) => readFileSync(p, "utf8"),
|
|
500
|
+
): PiCommand {
|
|
359
501
|
const override = proc.env.GENTLE_PI_AGENTS_PI?.trim();
|
|
360
502
|
if (override) {
|
|
361
503
|
const [command, ...args] = override.split(/\s+/);
|
|
504
|
+
if (/\.(?:cmd|bat)$/i.test(command) && exists(command)) {
|
|
505
|
+
const script = resolvePiScriptFromCmd(command, exists, readFile);
|
|
506
|
+
if (script) return { command: proc.execPath, args: [script, ...args] };
|
|
507
|
+
}
|
|
362
508
|
return { command, args };
|
|
363
509
|
}
|
|
364
510
|
const entry = proc.argv[1];
|
|
365
511
|
if (entry && /(^|[\\/])cli\.js$/.test(entry) && exists(entry)) return { command: proc.execPath, args: [entry] };
|
|
512
|
+
const isWin32 = proc.platform !== undefined
|
|
513
|
+
? proc.platform === "win32"
|
|
514
|
+
: (proc === process ? process.platform === "win32" : /^[a-zA-Z]:\\/i.test(proc.execPath) || /\\/.test(proc.execPath));
|
|
515
|
+
if (isWin32) {
|
|
516
|
+
const resolved = findWindowsPiCommand(proc, exists, readFile);
|
|
517
|
+
if (resolved) return resolved;
|
|
518
|
+
}
|
|
366
519
|
return { command: "pi", args: [] };
|
|
367
520
|
}
|
|
368
521
|
|
|
@@ -407,6 +560,7 @@ export class AgentRunner {
|
|
|
407
560
|
private readonly waiters = new Map<string, Array<(task: TaskRecord) => void>>();
|
|
408
561
|
private readonly queryWaiters = new Map<string, Array<(query: TaskQuery | undefined) => void>>();
|
|
409
562
|
private readonly firstQueries = new Map<string, TaskQuery>();
|
|
563
|
+
private readonly closedQueries = new Map<string, string[]>();
|
|
410
564
|
private readonly writers = new WriterSurfaceRegistry();
|
|
411
565
|
private counter = 0;
|
|
412
566
|
|
|
@@ -500,10 +654,34 @@ export class AgentRunner {
|
|
|
500
654
|
query.cancel();
|
|
501
655
|
live.queries.delete(requestId);
|
|
502
656
|
this.hooks.onQuerySettled?.(id, requestId, "replied");
|
|
657
|
+
this.restoreStall(id, live);
|
|
503
658
|
}
|
|
504
659
|
return accepted;
|
|
505
660
|
}
|
|
506
661
|
|
|
662
|
+
/** A reply to a query that settled unanswered: delivered once through `steer`
|
|
663
|
+
* while the task runs; otherwise reported as not running. Undefined when the
|
|
664
|
+
* request was never a closed query of this owner, or was already answered. */
|
|
665
|
+
replyLate(id: string, requestId: string, message: string, parentSessionId: string): LateReply | undefined {
|
|
666
|
+
const task = this.store.get(id);
|
|
667
|
+
const closed = this.closedQueries.get(id);
|
|
668
|
+
if (!task || task.parentSessionId !== parentSessionId || !closed?.includes(requestId)) return undefined;
|
|
669
|
+
// Too large is reported, not consumed: a shorter answer can still go.
|
|
670
|
+
if (Buffer.byteLength(message, "utf8") > CHILD_MESSAGE_MAX_BYTES) return "too large";
|
|
671
|
+
if (!validChildMessage(message)) return undefined;
|
|
672
|
+
closed.splice(closed.indexOf(requestId), 1);
|
|
673
|
+
const live = this.live.get(id);
|
|
674
|
+
if (!live || live.terminal || isFinished(task.status)) return "not running";
|
|
675
|
+
return this.steer(id, lateQueryAnswer(requestId, message)) ? "delivered" : "not running";
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
private recordClosedQuery(taskId: string, requestId: string): void {
|
|
679
|
+
const closed = this.closedQueries.get(taskId) ?? [];
|
|
680
|
+
this.closedQueries.delete(taskId);
|
|
681
|
+
this.closedQueries.set(taskId, [...closed.filter((id) => id !== requestId), requestId].slice(-CLOSED_QUERIES_PER_TASK));
|
|
682
|
+
if (this.closedQueries.size > CLOSED_QUERY_TASKS) this.closedQueries.delete(this.closedQueries.keys().next().value!);
|
|
683
|
+
}
|
|
684
|
+
|
|
507
685
|
cancel(id: string, reason = "cancelled"): boolean {
|
|
508
686
|
const queued = this.queue.findIndex((entry) => entry.task.id === id);
|
|
509
687
|
if (queued >= 0) {
|
|
@@ -569,6 +747,8 @@ export class AgentRunner {
|
|
|
569
747
|
// Do not forward stale legacy child selection or authorization.
|
|
570
748
|
delete env.GENTLE_PI_SDD_REMEDIATION_PLAN;
|
|
571
749
|
delete env.GENTLE_PI_RESEARCH_SELECTION;
|
|
750
|
+
if (request.agent.name === "gentle-ai-verify") env.GENTLE_PI_VERIFIER_PREPARER = fileURLToPath(new URL("../scripts/prepare-verifier.mjs", import.meta.url));
|
|
751
|
+
else delete env.GENTLE_PI_VERIFIER_PREPARER;
|
|
572
752
|
const tools = requestedTools(request);
|
|
573
753
|
if (request.agent.tools.includes("bash_background")) {
|
|
574
754
|
const policy = resolveBackgroundSubagentsPolicy(request.cwd, { env: request.env, gentlePiConfigHome: gentlePiConfigHome(request.env) });
|
|
@@ -578,9 +758,14 @@ export class AgentRunner {
|
|
|
578
758
|
this.finish(id, TASK_STATUS.FAILED, `could not start pi: explicit tool bash_background requires background-subagents policy on. Set ${file} to {"schema":"gentle-pi.background-subagents/v1","policy":"on"}; inspect or change policy with /gentle:background-subagents enable|disable|status.`);
|
|
579
759
|
return;
|
|
580
760
|
}
|
|
581
|
-
|
|
761
|
+
// Admission passed: the child registers its own private job tools and is
|
|
762
|
+
// trusted to report job state for the settlement drain.
|
|
763
|
+
env[CHILD_JOBS_ENV] = "1";
|
|
764
|
+
} else delete env[CHILD_JOBS_ENV];
|
|
582
765
|
if (tools !== undefined) env[REQUESTED_TOOLS_ENV] = tools;
|
|
583
766
|
else delete env[REQUESTED_TOOLS_ENV];
|
|
767
|
+
if (dropsSkillsCatalog(request.agent)) env[CHILD_SKILLS_CATALOG_ENV] = "1";
|
|
768
|
+
else delete env[CHILD_SKILLS_CATALOG_ENV];
|
|
584
769
|
let instructionsTransportDir: string | undefined;
|
|
585
770
|
let instructionsTransportPath: string | undefined;
|
|
586
771
|
if (Buffer.byteLength(request.agent.instructions, "utf8") > MAX_INLINE_INSTRUCTIONS_BYTES) {
|
|
@@ -728,7 +913,12 @@ export class AgentRunner {
|
|
|
728
913
|
private armStall(id: string, live: LiveTask): void {
|
|
729
914
|
live.cancelStall();
|
|
730
915
|
const tool = live.inFlightTools.values().next().value;
|
|
731
|
-
const
|
|
916
|
+
const base = tool === undefined ? this.limits.stallTimeoutMs : Math.max(this.limits.toolStallTimeoutMs ?? this.limits.stallTimeoutMs, this.limits.stallTimeoutMs);
|
|
917
|
+
const now = this.deps.now();
|
|
918
|
+
let queryWait = 0;
|
|
919
|
+
for (const query of live.queries.values()) queryWait = Math.max(queryWait, query.deadline - now + QUERY_STALL_MARGIN_MS);
|
|
920
|
+
const budget = Math.max(base, queryWait);
|
|
921
|
+
live.stallCoversQuery = budget > base;
|
|
732
922
|
live.cancelStall = this.deps.schedule(() => {
|
|
733
923
|
const lastStep = this.store.get(id)?.lastStep ?? "starting";
|
|
734
924
|
const minutes = Math.round(budget / 60_000);
|
|
@@ -846,8 +1036,8 @@ export class AgentRunner {
|
|
|
846
1036
|
}
|
|
847
1037
|
const task = this.store.get(id);
|
|
848
1038
|
if (!task || live.terminal || isFinished(task.status) || task.parentSessionId === "") {
|
|
849
|
-
if (parsed.frame.kind === "
|
|
850
|
-
else this.
|
|
1039
|
+
if (parsed.frame.kind === "query") this.sendQueryError(live, parsed.frame.id, "task is not a live owned recipient");
|
|
1040
|
+
else this.acknowledge(live, parsed.frame.id, false, "task is not a live owned recipient");
|
|
851
1041
|
return;
|
|
852
1042
|
}
|
|
853
1043
|
if (parsed.frame.kind === "notification") {
|
|
@@ -858,12 +1048,28 @@ export class AgentRunner {
|
|
|
858
1048
|
} catch { this.acknowledge(live, parsed.frame.id, false, "parent rejected notification"); }
|
|
859
1049
|
return;
|
|
860
1050
|
}
|
|
1051
|
+
if (parsed.frame.kind === "job") {
|
|
1052
|
+
const state = parseChildJobState(parsed.frame.message);
|
|
1053
|
+
if (!state) {
|
|
1054
|
+
this.acknowledge(live, parsed.frame.id, false, "invalid child job state");
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
// Ack before the report can open a drain that closes IPC.
|
|
1058
|
+
this.acknowledge(live, parsed.frame.id, true);
|
|
1059
|
+
live.childJobState = state;
|
|
1060
|
+
if (live.drain && state.running === 0 && !state.pending) this.beginSettle(id, live);
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
861
1063
|
let query: PendingQuery | undefined;
|
|
862
1064
|
try {
|
|
863
1065
|
if (live.queries.has(parsed.frame.id)) rejectQuery("duplicate query request");
|
|
864
1066
|
if (live.queries.size >= CHILD_QUERY_MAX_INFLIGHT) rejectQuery("too many pending parent queries");
|
|
865
|
-
query = { replying: false,
|
|
1067
|
+
query = { replying: false, deadline: this.deps.now() + CHILD_QUERY_TIMEOUT_MS, cancel: () => {} };
|
|
866
1068
|
live.queries.set(parsed.frame.id, query);
|
|
1069
|
+
// Lengthen the stall budget first, so the query's own deadline stays the last timer armed.
|
|
1070
|
+
this.armStall(id, live);
|
|
1071
|
+
const admitted = query;
|
|
1072
|
+
admitted.cancel = this.deps.schedule(() => this.expireQuery(id, live, parsed.frame!.id), CHILD_QUERY_TIMEOUT_MS);
|
|
867
1073
|
if (!this.hooks.onQuery) rejectQuery("task parent cannot accept queries");
|
|
868
1074
|
if (this.hooks.onQuery(task, parsed.frame.id, parsed.frame.message) === false) rejectQuery("task parent is not the active host session");
|
|
869
1075
|
if (task.mode === AGENT_MODE.TASK && !this.firstQueries.has(id)) {
|
|
@@ -876,6 +1082,7 @@ export class AgentRunner {
|
|
|
876
1082
|
if (query && live.queries.get(parsed.frame.id) === query) {
|
|
877
1083
|
query.cancel();
|
|
878
1084
|
live.queries.delete(parsed.frame.id);
|
|
1085
|
+
this.restoreStall(id, live);
|
|
879
1086
|
}
|
|
880
1087
|
this.sendQueryError(live, parsed.frame.id, queryRejection(error));
|
|
881
1088
|
}
|
|
@@ -887,7 +1094,16 @@ export class AgentRunner {
|
|
|
887
1094
|
live.queries.delete(id);
|
|
888
1095
|
this.hooks.onQuerySettled?.(taskId, id, "expired");
|
|
889
1096
|
if (query.replying) this.settleReply(live, id, false);
|
|
890
|
-
else
|
|
1097
|
+
else {
|
|
1098
|
+
this.recordClosedQuery(taskId, id);
|
|
1099
|
+
this.sendQueryError(live, id, CHILD_QUERY_TIMEOUT_ERROR);
|
|
1100
|
+
}
|
|
1101
|
+
this.restoreStall(taskId, live);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/** After a query settles, a stall budget lengthened for it returns to normal. */
|
|
1105
|
+
private restoreStall(taskId: string, live: LiveTask): void {
|
|
1106
|
+
if (live.stallCoversQuery && !live.terminal && this.live.get(taskId) === live) this.armStall(taskId, live);
|
|
891
1107
|
}
|
|
892
1108
|
|
|
893
1109
|
private sendQueryError(live: LiveTask, id: string, error: string): void {
|
|
@@ -925,8 +1141,11 @@ export class AgentRunner {
|
|
|
925
1141
|
private closeIpc(live: LiveTask): void {
|
|
926
1142
|
if (live.ipcClosed) return;
|
|
927
1143
|
live.ipcClosed = true;
|
|
1144
|
+
const taskId = [...this.live].find(([, entry]) => entry === live)?.[0];
|
|
1145
|
+
for (const [requestId, query] of live.queries) if (taskId !== undefined && !query.replying) this.recordClosedQuery(taskId, requestId);
|
|
928
1146
|
for (const query of live.queries.values()) query.cancel();
|
|
929
1147
|
live.queries.clear();
|
|
1148
|
+
if (taskId !== undefined) this.restoreStall(taskId, live);
|
|
930
1149
|
for (const pending of live.replies.values()) pending.resolve(false);
|
|
931
1150
|
live.replies.clear();
|
|
932
1151
|
live.child.channel?.unref?.();
|
|
@@ -1021,9 +1240,9 @@ export class AgentRunner {
|
|
|
1021
1240
|
if (live.observations) live.observations.agentSettled = true;
|
|
1022
1241
|
const terminal = this.store.get(id);
|
|
1023
1242
|
if (terminal?.error && this.fallBack(id, request, live)) { /* The child keeps going on its next model. */ }
|
|
1024
|
-
else if (terminal?.error) this.
|
|
1025
|
-
else if (terminal?.result) this.
|
|
1026
|
-
else this.
|
|
1243
|
+
else if (terminal?.error) this.settleOrDrain(id, TASK_STATUS.FAILED, terminal.error, live);
|
|
1244
|
+
else if (terminal?.result) this.settleOrDrain(id, TASK_STATUS.COMPLETED, null, live);
|
|
1245
|
+
else this.settleOrDrain(id, TASK_STATUS.FAILED, "assistant settled without a final report", live);
|
|
1027
1246
|
}
|
|
1028
1247
|
}
|
|
1029
1248
|
if (!live.terminal && progress) this.armStall(id, live);
|
|
@@ -1064,6 +1283,34 @@ export class AgentRunner {
|
|
|
1064
1283
|
}
|
|
1065
1284
|
}
|
|
1066
1285
|
|
|
1286
|
+
/**
|
|
1287
|
+
* Settles a task, but when the child still reports running background jobs
|
|
1288
|
+
* (#2266) it grants one bounded drain window first so the jobs can finish;
|
|
1289
|
+
* the drain ends early when the child reports nothing left.
|
|
1290
|
+
*/
|
|
1291
|
+
private settleOrDrain(id: string, status: TaskRecord["status"], error: string | null, live: LiveTask): void {
|
|
1292
|
+
if (live.drain || live.terminal) return;
|
|
1293
|
+
const state = live.childJobState;
|
|
1294
|
+
// No child job work, or the child already reports none: settle as before.
|
|
1295
|
+
if (!state || (state.running === 0 && !state.pending)) {
|
|
1296
|
+
this.settleOrderly(id, status, error);
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
// One bounded extension: the child keeps running its jobs, and the drain
|
|
1300
|
+
// ends early on a report with nothing left. A late report cannot re-open it.
|
|
1301
|
+
const cancel = this.deps.schedule(() => this.beginSettle(id, live), this.limits.drainTimeoutMs ?? DEFAULT_DRAIN_TIMEOUT_MS);
|
|
1302
|
+
live.drain = { status, error, cancel };
|
|
1303
|
+
if (this.store.get(id)?.status === TASK_STATUS.RUNNING) this.store.update(id, { lastStep: "draining background jobs" });
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
private beginSettle(id: string, live: LiveTask): void {
|
|
1307
|
+
const drain = live.drain;
|
|
1308
|
+
if (!drain || this.live.get(id) !== live) return;
|
|
1309
|
+
live.drain = undefined;
|
|
1310
|
+
drain.cancel();
|
|
1311
|
+
this.settleOrderly(id, drain.status, drain.error);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1067
1314
|
/**
|
|
1068
1315
|
* Requests orderly child shutdown via stdin upon settlement and schedules
|
|
1069
1316
|
* bounded signal escalation if the child process does not exit within cleanupTimeoutMs.
|
|
@@ -1071,6 +1318,8 @@ export class AgentRunner {
|
|
|
1071
1318
|
private settleOrderly(id: string, status: TaskRecord["status"], error: string | null): void {
|
|
1072
1319
|
const live = this.live.get(id);
|
|
1073
1320
|
if (!live || live.terminal) return;
|
|
1321
|
+
live.drain?.cancel();
|
|
1322
|
+
live.drain = undefined;
|
|
1074
1323
|
live.terminal = { status, error };
|
|
1075
1324
|
live.mutationStarts.clear();
|
|
1076
1325
|
live.inFlightTools.clear();
|
|
@@ -1102,6 +1351,8 @@ export class AgentRunner {
|
|
|
1102
1351
|
private requestStop(id: string, status: TaskRecord["status"], error: string | null, abort = false): void {
|
|
1103
1352
|
const live = this.live.get(id);
|
|
1104
1353
|
if (!live || live.terminal) return;
|
|
1354
|
+
live.drain?.cancel();
|
|
1355
|
+
live.drain = undefined;
|
|
1105
1356
|
live.terminal = { status, error };
|
|
1106
1357
|
live.mutationStarts.clear();
|
|
1107
1358
|
live.inFlightTools.clear();
|
|
@@ -1181,6 +1432,8 @@ export class AgentRunner {
|
|
|
1181
1432
|
this.closeIpc(live);
|
|
1182
1433
|
live.cancelStall();
|
|
1183
1434
|
live.cancelGrace();
|
|
1435
|
+
live.drain?.cancel();
|
|
1436
|
+
live.drain = undefined;
|
|
1184
1437
|
if (live.instructionsTransportDir) {
|
|
1185
1438
|
try { rmSync(live.instructionsTransportDir, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
1186
1439
|
live.instructionsTransportDir = undefined;
|
|
@@ -1213,6 +1466,9 @@ export class AgentRunner {
|
|
|
1213
1466
|
if (!live) return;
|
|
1214
1467
|
live.childExit = code;
|
|
1215
1468
|
live.childExitSignal = signal ?? null;
|
|
1469
|
+
// A child that exits mid-drain still settles on the run agent_settled already
|
|
1470
|
+
// produced; the ordinary orderly shutdown then owns the exit.
|
|
1471
|
+
if (live.drain) this.beginSettle(id, live);
|
|
1216
1472
|
const exitDesc = formatChildExit(code, signal);
|
|
1217
1473
|
if (this.groupExists(live)) {
|
|
1218
1474
|
if (!live.terminal) this.requestStop(id, TASK_STATUS.FAILED, `pi exited with ${exitDesc} before agent_settled${this.stderrSuffix(live)}`);
|
|
@@ -184,7 +184,23 @@ export class SessionPresenceRegistry {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
} catch (error) { boundary(error); }
|
|
187
|
-
|
|
187
|
+
// gentle-shell#1443: advertises() only proves the socket file exists, not
|
|
188
|
+
// that its listener is alive — a session killed without unlinking would
|
|
189
|
+
// stay advertised forever otherwise. Probe each candidate once, bounded,
|
|
190
|
+
// with the sweep's own refusal-only liveness: provably dead records are
|
|
191
|
+
// excluded and purged; ambiguous outcomes stay advertised.
|
|
192
|
+
const advertised = [...newest.values()];
|
|
193
|
+
const live = new Set<string>();
|
|
194
|
+
let next = 0;
|
|
195
|
+
const worker = async () => {
|
|
196
|
+
while (next < advertised.length) {
|
|
197
|
+
const record = advertised[next++];
|
|
198
|
+
if (await this.liveness(record.endpoint) !== "dead") live.add(record.sessionId);
|
|
199
|
+
else await this.removeOwn(record).catch(() => {});
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
await Promise.all(Array.from({ length: Math.min(SWEEP_PROBE_CONCURRENCY, advertised.length) }, worker));
|
|
203
|
+
return advertised.filter((record) => live.has(record.sessionId)).sort((left, right) => left.sessionId.localeCompare(right.sessionId));
|
|
188
204
|
}
|
|
189
205
|
|
|
190
206
|
resolve(id: string): Promise<PresenceRecord> {
|
|
@@ -38,7 +38,7 @@ type BranchItem = {id: string; type: string; message?: {role: string; content: u
|
|
|
38
38
|
type AuthoredInput = {text: string; order:number; before: Set<string>; entryId?: string; prompt?: string};
|
|
39
39
|
// These are independent authority/dialog/delegation surfaces, not Auto approvals.
|
|
40
40
|
const OWNED_CONTROL_TOOLS = new Set([
|
|
41
|
-
"ask_user_choice", "ask_user_question", "gentle_review", "gentle_review_capture", "gentle_review_capture_group",
|
|
41
|
+
"ask_user_choice", "ask_user_question", "gentle_review", "gentle_review_capture", "gentle_review_capture_group", "gentle_review_run",
|
|
42
42
|
"subagent_run", "subagent_continue", "subagent_reply", "subagent_cancel", "subagent_send_message",
|
|
43
43
|
"subagent_status", "subagent_result", "subagent_list_tasks", "subagent_list_agents",
|
|
44
44
|
"gentle_odd_phase", "todo",
|
|
@@ -24,6 +24,11 @@ const quoted = (job: JobRecord) => `${job.id} ("${job.label}")`;
|
|
|
24
24
|
const noun = (job: JobRecord) => (job.kind === "monitor" ? "Monitor" : "Background job");
|
|
25
25
|
const plural = (count: number, word: string) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
26
26
|
|
|
27
|
+
/** What changed on the registry, so a listener can ignore a no-op stop. */
|
|
28
|
+
export type BackgroundJobsChange =
|
|
29
|
+
| { kind: "start"; job: JobRecord }
|
|
30
|
+
| { kind: "stop"; job: JobRecord; changed: boolean };
|
|
31
|
+
|
|
27
32
|
/** One-line outcome, shared by the notice, the list, and the jobs view. */
|
|
28
33
|
export function jobOutcome(job: JobRecord): string {
|
|
29
34
|
if (job.status === "running") return "running";
|
|
@@ -79,7 +84,7 @@ export interface BackgroundJobToolsOptions {
|
|
|
79
84
|
sessionId(ctx: ExtensionContext): string;
|
|
80
85
|
now(): number;
|
|
81
86
|
/** Called after a job starts or stops, so views can refresh. */
|
|
82
|
-
onChange?(): void;
|
|
87
|
+
onChange?(change: BackgroundJobsChange): void;
|
|
83
88
|
/** Starts and stops monitors; without it the monitor tool is not offered. */
|
|
84
89
|
monitors?: MonitorController;
|
|
85
90
|
}
|
|
@@ -113,7 +118,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
113
118
|
const input = params as { command?: unknown; label?: unknown };
|
|
114
119
|
if (typeof input.command !== "string" || !input.command.trim()) throw new Error("bash_background requires a non-empty command");
|
|
115
120
|
const job = registry.start({ command: input.command, cwd: ctx.cwd, ownerSessionId: options.sessionId(ctx), label: typeof input.label === "string" ? input.label : undefined });
|
|
116
|
-
options.onChange?.();
|
|
121
|
+
options.onChange?.({ kind: "start", job });
|
|
117
122
|
return text(
|
|
118
123
|
`Started background job ${quoted(job)}.\nOutput: ${job.outputPath}\nYou will be notified once when it exits; keep working or end your turn. Stop it with job_stop.`,
|
|
119
124
|
jobDetails(job),
|
|
@@ -146,7 +151,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
146
151
|
if (typeof input.command !== "string" || !input.command.trim()) throw new Error("monitor requires a non-empty command");
|
|
147
152
|
const timeoutSeconds = typeof input.timeout_seconds === "number" ? input.timeout_seconds : Number.NaN;
|
|
148
153
|
const job = monitors.start({ command: input.command, cwd: ctx.cwd, ownerSessionId: options.sessionId(ctx), label: typeof input.label === "string" ? input.label : undefined, timeoutSeconds });
|
|
149
|
-
options.onChange?.();
|
|
154
|
+
options.onChange?.({ kind: "start", job });
|
|
150
155
|
return text(
|
|
151
156
|
`Started monitor ${quoted(job)} for up to ${timeoutSeconds}s.\nOutput: ${job.outputPath}\nEach new output line reaches you as an event; keep working or end your turn. Stop it with job_stop.`,
|
|
152
157
|
jobDetails(job),
|
|
@@ -166,7 +171,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
166
171
|
const wasRunning = job.status === "running";
|
|
167
172
|
options.monitors?.cancel(job.id);
|
|
168
173
|
registry.stop(job.id);
|
|
169
|
-
options.onChange?.();
|
|
174
|
+
options.onChange?.({ kind: "stop", job, changed: wasRunning });
|
|
170
175
|
return text(wasRunning ? `Stopped ${quoted(job)}.` : `${quoted(job)} was already ${jobOutcome(job)}.`, jobDetails(job));
|
|
171
176
|
},
|
|
172
177
|
});
|