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/native-review-cli.ts
CHANGED
|
@@ -3,12 +3,13 @@ import { chmod, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, isAbsolute, join, posix, win32 } from "node:path";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
|
-
import { gentleAiIsolationEnv, PackageLocalGentleAiBinaryMissingError, resolveGentleAiBinary } from "./gentle-ai-binary.ts";
|
|
6
|
+
import { binaryDigest, gentleAiIsolationEnv, PackageLocalGentleAiBinaryMissingError, resolveGentleAiBinary } from "./gentle-ai-binary.ts";
|
|
7
7
|
import { GENTLE_PI_REVIEW_RELAY_CONTRACT, GENTLE_PI_REVIEW_RELAY_CONTRACT_ENV } from "./review-relay-contract.ts";
|
|
8
8
|
import { decodeReviewAssessmentV1, type ReviewAssessmentV1 } from "./review-risk-assessment.ts";
|
|
9
9
|
import {
|
|
10
10
|
REVIEW_INTEGRATION_CONTRACT,
|
|
11
11
|
decodeReviewAcknowledgedV1,
|
|
12
|
+
decodeReviewCapabilitiesV2,
|
|
12
13
|
decodeReviewConsentV2,
|
|
13
14
|
decodeReviewConsentV3,
|
|
14
15
|
decodeReviewFailureV2,
|
|
@@ -158,10 +159,13 @@ export const NATIVE_REVIEW_MODE_SCOPE = {
|
|
|
158
159
|
BOTH: "both",
|
|
159
160
|
} as const;
|
|
160
161
|
export type NativeReviewModeScope = (typeof NATIVE_REVIEW_MODE_SCOPE)[keyof typeof NATIVE_REVIEW_MODE_SCOPE];
|
|
162
|
+
export type NativeReviewModeMutationScope = typeof NATIVE_REVIEW_MODE_SCOPE.CLONE | typeof NATIVE_REVIEW_MODE_SCOPE.GLOBAL;
|
|
161
163
|
|
|
162
164
|
export interface NativeReviewModeRequest {
|
|
163
165
|
cwd: string;
|
|
164
166
|
operation: NativeReviewModeOperation;
|
|
167
|
+
/** Mutation scope is explicit when global; omitted mutations remain clone-local. Status takes no scope. */
|
|
168
|
+
scope?: NativeReviewModeMutationScope;
|
|
165
169
|
signal?: AbortSignal;
|
|
166
170
|
}
|
|
167
171
|
|
|
@@ -488,6 +492,45 @@ const NATIVE_REVIEW_UNKNOWN_UNACHIEVABLE_VERB_REFUSAL = /unknown review command
|
|
|
488
492
|
// flags with this exact typed preflight cause, before reading the repository.
|
|
489
493
|
const NATIVE_REVIEW_UNKNOWN_LENS_FLAG_CAUSE = /^flag provided but not defined: -lenses(?:-reason)?$/;
|
|
490
494
|
|
|
495
|
+
// A provider older than gentle-ai#6088 refuses the STATUS opt-in with this
|
|
496
|
+
// exact typed preflight cause, before reading the repository.
|
|
497
|
+
const NATIVE_REVIEW_UNKNOWN_NON_BLOCKING_FLAG_CAUSE = /^flag provided but not defined: -non-blocking-findings$/;
|
|
498
|
+
|
|
499
|
+
/** Reports a not-started STATUS refusal caused only by an unknown --non-blocking-findings flag. */
|
|
500
|
+
function isNativeReviewNonBlockingFindingsUnsupported(error: unknown): boolean {
|
|
501
|
+
if (!(error instanceof NativeReviewIntegrationError)) return false;
|
|
502
|
+
const failure = error.failureEnvelope;
|
|
503
|
+
return failure.code === "invalid_request" && failure.mutationOutcome === "not_started" &&
|
|
504
|
+
typeof failure.cause === "string" && NATIVE_REVIEW_UNKNOWN_NON_BLOCKING_FLAG_CAUSE.test(failure.cause);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Provider binaries (executable path to its sha256) that refused
|
|
508
|
+
// --non-blocking-findings in this process. A replaced binary at the same path
|
|
509
|
+
// has another digest and is asked again. Never a capability claim.
|
|
510
|
+
const nonBlockingFindingsRefusals = new Map<string, string>();
|
|
511
|
+
|
|
512
|
+
function nonBlockingFindingsRefused(executable: string): boolean {
|
|
513
|
+
const digest = nonBlockingFindingsRefusals.get(executable);
|
|
514
|
+
if (digest === undefined) return false;
|
|
515
|
+
try {
|
|
516
|
+
return binaryDigest(executable) === digest;
|
|
517
|
+
} catch {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function nonBlockingExecutableDigest(executable: string): string | undefined {
|
|
523
|
+
try { return binaryDigest(executable); } catch { return undefined; }
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function rememberNonBlockingFindingsRefusal(executable: string, digest: string | undefined): void {
|
|
527
|
+
// An old in-flight refusal must neither label a replacement unsupported
|
|
528
|
+
// nor erase a newer request's cache entry when identity cannot be read.
|
|
529
|
+
if (digest !== undefined && nonBlockingExecutableDigest(executable) === digest) {
|
|
530
|
+
nonBlockingFindingsRefusals.set(executable, digest);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
491
534
|
/** Reports a not-started STATUS refusal caused only by an unknown --lenses flag. */
|
|
492
535
|
export function isNativeReviewLensSelectionUnsupported(error: unknown): boolean {
|
|
493
536
|
if (!(error instanceof NativeReviewIntegrationError)) return false;
|
|
@@ -538,7 +581,20 @@ export interface NativeLensSelectionRequest {
|
|
|
538
581
|
lensesReason?: string;
|
|
539
582
|
}
|
|
540
583
|
|
|
541
|
-
|
|
584
|
+
/** Explicit request file; native owns reading, freezing, sizing and identity. */
|
|
585
|
+
interface NativeRequestContextSelection {
|
|
586
|
+
requestContextPath?: string;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
export const NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE = "provider does not support request context";
|
|
590
|
+
|
|
591
|
+
function nativeRequestContextArguments(request: NativeRequestContextSelection): readonly string[] {
|
|
592
|
+
if (request.requestContextPath === undefined) return [];
|
|
593
|
+
if (!isCanonicalProcessString(request.requestContextPath)) throw new TypeError("Native requestContextPath must be a non-empty, trimmed, NUL-free string");
|
|
594
|
+
return ["--request-context", request.requestContextPath];
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export interface NativeStartRequest extends NativeUntrackedSelectionRequest, NativeLensSelectionRequest, NativeRequestContextSelection {
|
|
542
598
|
cwd: string;
|
|
543
599
|
baseRef?: string;
|
|
544
600
|
committedOnly?: boolean;
|
|
@@ -551,7 +607,7 @@ export interface NativeStartRequest extends NativeUntrackedSelectionRequest, Nat
|
|
|
551
607
|
}
|
|
552
608
|
export const NATIVE_REVIEW_CONSENT_ANSWER = { GRANTED: "granted", DECLINED: "declined" } as const;
|
|
553
609
|
export type NativeReviewConsentAnswer = (typeof NATIVE_REVIEW_CONSENT_ANSWER)[keyof typeof NATIVE_REVIEW_CONSENT_ANSWER];
|
|
554
|
-
export interface NativeReviewConsentAnswerRequest { cwd: string; consent: ReviewConsentEnvelope; answer: NativeReviewConsentAnswer; signal?: AbortSignal; }
|
|
610
|
+
export interface NativeReviewConsentAnswerRequest extends NativeRequestContextSelection { cwd: string; consent: ReviewConsentEnvelope; answer: NativeReviewConsentAnswer; signal?: AbortSignal; }
|
|
555
611
|
export interface NativeReviewConsentDeclinedResult {
|
|
556
612
|
kind: "declined";
|
|
557
613
|
targetIdentity: string;
|
|
@@ -565,7 +621,7 @@ export interface NativeReviewConsentDeclinedResult {
|
|
|
565
621
|
export interface NativeReviewConsentStartedResult { kind: "started"; start: NativeStartResult; }
|
|
566
622
|
export type NativeReviewConsentAnswerResult = NativeReviewConsentStartedResult | NativeReviewConsentDeclinedResult;
|
|
567
623
|
export interface NativeReviewStatusRequest { cwd: string; signal?: AbortSignal; }
|
|
568
|
-
export interface NativeTargetStatusRequest extends NativeUntrackedSelectionRequest, NativeLensSelectionRequest {
|
|
624
|
+
export interface NativeTargetStatusRequest extends NativeUntrackedSelectionRequest, NativeLensSelectionRequest, NativeRequestContextSelection {
|
|
569
625
|
cwd: string;
|
|
570
626
|
lineageId?: string;
|
|
571
627
|
baseRef?: string;
|
|
@@ -581,6 +637,14 @@ export interface NativeTargetStatusRequest extends NativeUntrackedSelectionReque
|
|
|
581
637
|
* back rather than version-sniff.
|
|
582
638
|
*/
|
|
583
639
|
agent?: "pi";
|
|
640
|
+
/**
|
|
641
|
+
* Ask the provider for the opt-in `non_blocking_findings` of a compact
|
|
642
|
+
* correction_required or escalated authority (`--non-blocking-findings`,
|
|
643
|
+
* gentle-ai#6088). Sent only on this client's own contracted STATUS. A
|
|
644
|
+
* provider that refuses the unknown flag is asked once more without it, and
|
|
645
|
+
* that binary is not sent the flag again in this process.
|
|
646
|
+
*/
|
|
647
|
+
nonBlockingFindings?: true;
|
|
584
648
|
signal?: AbortSignal;
|
|
585
649
|
}
|
|
586
650
|
export const NATIVE_REVIEW_AUTHORITY_STATUS = {
|
|
@@ -1098,6 +1162,23 @@ export const NATIVE_CLI_CONTRACTS = Object.freeze({
|
|
|
1098
1162
|
// The v4.3.0 tag has no release and is never pinned.
|
|
1099
1163
|
// No new negotiated capability identity is asserted.
|
|
1100
1164
|
"4.3.1": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1165
|
+
// v4.4.0 repeats 4.3.1: the published binary still advertises
|
|
1166
|
+
// capabilities/v2.6 under review-integration/v2 with the same capabilities
|
|
1167
|
+
// payload apart from build identity, and the provider contract stays at
|
|
1168
|
+
// 1.4.0, with published tarball SHA-256
|
|
1169
|
+
// 58450471280aeb357443d6a28c819132d8c8eb78dd25b12bac64296b2f8c27c2.
|
|
1170
|
+
// No new negotiated capability identity is asserted.
|
|
1171
|
+
"4.4.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1172
|
+
// v4.5.0 repeats 4.4.0: the published binary still advertises
|
|
1173
|
+
// capabilities/v2.6 (protocol minor 6) under review-integration/v2, and the
|
|
1174
|
+
// provider contract moved from 1.4.0 to 1.5.0 additively (one stop reason,
|
|
1175
|
+
// no negotiated START/STATUS field), with published provider-contract tarball
|
|
1176
|
+
// SHA-256 08fdb65329b47a2cd2563edfa62b5781fd5ec7b0d1e8812e8e29a01a486da838.
|
|
1177
|
+
// Ground truth: `review capabilities --contract gentle-ai.review-integration/v2`
|
|
1178
|
+
// on the released darwin/arm64 v4.5.0 binary reports schema
|
|
1179
|
+
// gentle-ai.review-integration.capabilities/v2.6 with protocol minor 6.
|
|
1180
|
+
// No new negotiated capability identity is asserted.
|
|
1181
|
+
"4.5.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
|
|
1101
1182
|
});
|
|
1102
1183
|
|
|
1103
1184
|
export interface NativeReviewProcessDiagnostics {
|
|
@@ -1476,6 +1557,16 @@ function decodeNativeReviewStatus(value: unknown): NativeReviewStatusResult {
|
|
|
1476
1557
|
raw: body,
|
|
1477
1558
|
};
|
|
1478
1559
|
}
|
|
1560
|
+
function nativeReviewModeScopeArguments(operation: NativeReviewModeOperation, scope: NativeReviewModeMutationScope | undefined): string[] {
|
|
1561
|
+
if (scope !== undefined && scope !== NATIVE_REVIEW_MODE_SCOPE.CLONE && scope !== NATIVE_REVIEW_MODE_SCOPE.GLOBAL) {
|
|
1562
|
+
throw new TypeError("Native review mode scope must be clone or global");
|
|
1563
|
+
}
|
|
1564
|
+
if (scope !== undefined && operation !== NATIVE_REVIEW_MODE_OPERATION.ENABLE && operation !== NATIVE_REVIEW_MODE_OPERATION.DISABLE) {
|
|
1565
|
+
throw new TypeError("Native review mode scope is only valid for enable or disable");
|
|
1566
|
+
}
|
|
1567
|
+
return operation === NATIVE_REVIEW_MODE_OPERATION.STATUS ? [] : ["--scope", scope ?? NATIVE_REVIEW_MODE_SCOPE.CLONE];
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1479
1570
|
function isWindowsRepositoryPath(value: string): boolean { return /^[A-Za-z]:[\\/]/.test(value) || /^\\\\/.test(value); }
|
|
1480
1571
|
export function normalizeNativeReviewCwd(value: string, platform: NodeJS.Platform = process.platform): string {
|
|
1481
1572
|
if (platform !== "win32") return value;
|
|
@@ -1667,22 +1758,21 @@ class NativeReviewPlainCli {
|
|
|
1667
1758
|
return status;
|
|
1668
1759
|
}
|
|
1669
1760
|
|
|
1670
|
-
//
|
|
1671
|
-
//
|
|
1672
|
-
// exact fixed argv per the design's data flow); `enable`/`disable` mutate
|
|
1673
|
-
// and always pass `--scope clone` so Pi's own kill-switch command surface
|
|
1674
|
-
// never mutates the operator's global gentle-ai state across other clones.
|
|
1761
|
+
// Status stays read-only; mutation defaults to clone unless the caller
|
|
1762
|
+
// explicitly supplies global. Validate scope before cwd or process access.
|
|
1675
1763
|
async reviewMode(request: NativeReviewModeRequest): Promise<NativeReviewModeResult> {
|
|
1764
|
+
const operation = request.operation;
|
|
1765
|
+
const scopeArguments = nativeReviewModeScopeArguments(operation, request.scope);
|
|
1676
1766
|
const cwd = await canonicalNativeReviewCwd(request.cwd);
|
|
1677
|
-
const mutating =
|
|
1767
|
+
const mutating = operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
|
|
1678
1768
|
const { body } = await this.execute(
|
|
1679
1769
|
NATIVE_REVIEW_OPERATION.MODE,
|
|
1680
1770
|
cwd,
|
|
1681
|
-
["review", "mode",
|
|
1771
|
+
["review", "mode", operation, "--cwd", cwd, ...scopeArguments, "--json"],
|
|
1682
1772
|
mutating,
|
|
1683
1773
|
request.signal,
|
|
1684
1774
|
);
|
|
1685
|
-
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(body,
|
|
1775
|
+
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(body, operation));
|
|
1686
1776
|
}
|
|
1687
1777
|
|
|
1688
1778
|
async reclaim(request: NativeReviewReclaimRequest): Promise<NativeReviewRecoveryResult> {
|
|
@@ -1928,12 +2018,14 @@ export class NativeReviewIntegrationError extends Error {
|
|
|
1928
2018
|
// answer only through one of the exact invocations carried by the envelope.
|
|
1929
2019
|
export class NativeReviewConsentRequiredError extends Error {
|
|
1930
2020
|
readonly consent: ReviewConsentEnvelope;
|
|
2021
|
+
readonly requestContextPath?: string;
|
|
1931
2022
|
readonly launchAttempted = true;
|
|
1932
2023
|
readonly mutationOutcome = "none";
|
|
1933
|
-
constructor(consent: ReviewConsentEnvelope) {
|
|
2024
|
+
constructor(consent: ReviewConsentEnvelope, requestContextPath?: string) {
|
|
1934
2025
|
super(consent.headline);
|
|
1935
2026
|
this.name = "NativeReviewConsentRequiredError";
|
|
1936
2027
|
this.consent = consent;
|
|
2028
|
+
this.requestContextPath = requestContextPath;
|
|
1937
2029
|
}
|
|
1938
2030
|
}
|
|
1939
2031
|
|
|
@@ -2064,6 +2156,10 @@ function consentInvocationArguments(request: NativeReviewConsentAnswerRequest):
|
|
|
2064
2156
|
const words = splitNativeConsentInvocation(choice.invocation);
|
|
2065
2157
|
if (words[0] !== "gentle-ai" || words[1] !== "review" || words[2] !== "start") throw new NativeReviewConsentBindingError("consent-invocation-not-start", "Native consent invocation is not a provider review START");
|
|
2066
2158
|
const arguments_ = words.slice(1);
|
|
2159
|
+
if (request.requestContextPath !== undefined) {
|
|
2160
|
+
const values = arguments_.flatMap((token, index) => token === "--request-context" ? [arguments_[index + 1]] : token.startsWith("--request-context=") ? [token.slice("--request-context=".length)] : []);
|
|
2161
|
+
if (values.length !== 1 || values[0] !== request.requestContextPath) throw new NativeReviewConsentBindingError("consent-invocation-request-context-changed", "Native consent invocation did not retain the requested context file");
|
|
2162
|
+
}
|
|
2067
2163
|
if (exactConsentOption(arguments_, "--contract") !== REVIEW_INTEGRATION_CONTRACT) throw new NativeReviewConsentBindingError("consent-invocation-contract-changed", "Native consent invocation contract changed");
|
|
2068
2164
|
const providerCwd = exactConsentOption(arguments_, "--cwd");
|
|
2069
2165
|
const requestedCwd = normalizeNativeReviewCwd(request.cwd);
|
|
@@ -2165,6 +2261,8 @@ function decodeNativeUnachievableLensCaptureArtifact(value: unknown): NativeRevi
|
|
|
2165
2261
|
}
|
|
2166
2262
|
|
|
2167
2263
|
export class NativeReviewCliV216 implements NativeReviewCli {
|
|
2264
|
+
// Only executable capabilities are reusable. STATUS and authority remain fresh.
|
|
2265
|
+
private contextCapabilities?: { executable: string; digest: string; value: ReturnType<typeof decodeReviewCapabilitiesV2> };
|
|
2168
2266
|
private readonly plain: NativeReviewPlainCli;
|
|
2169
2267
|
private readonly adapter: ExecFileAdapter;
|
|
2170
2268
|
private readonly executable: string | (() => string);
|
|
@@ -2267,6 +2365,7 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2267
2365
|
const selection = nativeUntrackedSelection(request);
|
|
2268
2366
|
const statusRequest: NativeTargetStatusRequest = {
|
|
2269
2367
|
cwd: request.cwd,
|
|
2368
|
+
...(request.requestContextPath === undefined ? {} : { requestContextPath: request.requestContextPath }),
|
|
2270
2369
|
projection,
|
|
2271
2370
|
...(request.baseRef === undefined ? {} : { baseRef: request.baseRef, committedOnly: true }),
|
|
2272
2371
|
...(request.lineageId === undefined ? {} : { lineageId: request.lineageId }),
|
|
@@ -2300,6 +2399,10 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2300
2399
|
return argument.token;
|
|
2301
2400
|
});
|
|
2302
2401
|
const targetIdentity = status.targetIdentity;
|
|
2402
|
+
if (request.requestContextPath !== undefined) {
|
|
2403
|
+
const values = transitionTokens.flatMap((token, index) => token === "--request-context" ? [transitionTokens[index + 1]] : token.startsWith("--request-context=") ? [token.slice("--request-context=".length)] : []);
|
|
2404
|
+
if (values.length !== 1 || values[0] !== request.requestContextPath) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, false, "native START transition did not retain the requested context file", undefined, false);
|
|
2405
|
+
}
|
|
2303
2406
|
const execution = await this.negotiated(NATIVE_REVIEW_OPERATION.START, request.cwd, ["review", "start", ...transitionTokens], true, request.signal);
|
|
2304
2407
|
// A negotiated v2 START may answer a consent question (action:
|
|
2305
2408
|
// "consent_required") instead of `start/v3` when the provider needs an
|
|
@@ -2317,7 +2420,10 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2317
2420
|
return decoded;
|
|
2318
2421
|
});
|
|
2319
2422
|
if (consent.targetIdentity !== targetIdentity || consent.projection !== projection) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, true, "native consent target binding mismatch");
|
|
2320
|
-
|
|
2423
|
+
if (request.requestContextPath !== undefined) {
|
|
2424
|
+
for (const choice of consent.choices) consentInvocationArguments({ cwd: request.cwd, consent, answer: choice.answer, requestContextPath: request.requestContextPath });
|
|
2425
|
+
}
|
|
2426
|
+
throw new NativeReviewConsentRequiredError(consent, request.requestContextPath);
|
|
2321
2427
|
}
|
|
2322
2428
|
const result = decode(NATIVE_REVIEW_OPERATION.START, true, () => decodeReviewStartResponse(execution.body));
|
|
2323
2429
|
if (request.lineageId !== undefined && result.lineageId !== request.lineageId) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, true, "native start lineage mismatch");
|
|
@@ -2387,6 +2493,9 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2387
2493
|
}
|
|
2388
2494
|
|
|
2389
2495
|
private async observedTargetStatus(request: NativeTargetStatusRequest): Promise<ReviewStatusV3> {
|
|
2496
|
+
// Validate locally before discovery; never probe support by sending an
|
|
2497
|
+
// unknown flag or retrying the review without its requested intent.
|
|
2498
|
+
const requestContextArguments = nativeRequestContextArguments(request);
|
|
2390
2499
|
if (request.baseRef !== undefined && !isCanonicalProcessString(request.baseRef)) throw new TypeError("Native STATUS baseRef must be a non-empty, trimmed, NUL-free string");
|
|
2391
2500
|
if (request.baseRef !== undefined && request.committedOnly !== true) throw new TypeError("Native STATUS baseRef requires explicit committedOnly acknowledgement");
|
|
2392
2501
|
if (request.baseRef === undefined && request.committedOnly !== undefined) throw new TypeError("Native STATUS committedOnly requires an explicit baseRef");
|
|
@@ -2422,7 +2531,32 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2422
2531
|
...(submittedHasCommittedOnly ? [] : ["--committed-only"]),
|
|
2423
2532
|
];
|
|
2424
2533
|
const forwardedLineage = request.lineageId === undefined || submittedLineageValue !== undefined ? [] : ["--lineage", request.lineageId];
|
|
2425
|
-
|
|
2534
|
+
let contextExecutable: string | undefined;
|
|
2535
|
+
if (requestContextArguments.length > 0) {
|
|
2536
|
+
contextExecutable = this.executablePath(NATIVE_REVIEW_OPERATION.STATUS, false);
|
|
2537
|
+
const digest = binaryDigest(contextExecutable);
|
|
2538
|
+
let capabilities = this.contextCapabilities?.executable === contextExecutable && this.contextCapabilities.digest === digest
|
|
2539
|
+
? this.contextCapabilities.value : undefined;
|
|
2540
|
+
if (capabilities === undefined) {
|
|
2541
|
+
this.contextCapabilities = undefined;
|
|
2542
|
+
const discovery = await this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd,
|
|
2543
|
+
["review", "capabilities", "--contract", REVIEW_INTEGRATION_CONTRACT], false, request.signal, contextExecutable);
|
|
2544
|
+
capabilities = decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewCapabilitiesV2(discovery.body, digest));
|
|
2545
|
+
if (binaryDigest(contextExecutable) !== digest) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH,
|
|
2546
|
+
NATIVE_REVIEW_OPERATION.STATUS, false, "native executable changed during capability discovery", undefined, false);
|
|
2547
|
+
this.contextCapabilities = { executable: contextExecutable, digest, value: capabilities };
|
|
2548
|
+
}
|
|
2549
|
+
if (!["start_request_context", "start_options_preflight"].every(feature => capabilities.optionalFeatures.has(feature))) {
|
|
2550
|
+
throw nativeError(NATIVE_REVIEW_ERROR_CODE.VERSION_INCOMPATIBLE, NATIVE_REVIEW_OPERATION.STATUS, false,
|
|
2551
|
+
NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE, undefined, false);
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
// The opt-in rides only this client's own contracted STATUS, never a
|
|
2555
|
+
// provider-issued selection submission.
|
|
2556
|
+
const nonBlockingExecutable = request.nonBlockingFindings === true && submittedTokens === undefined
|
|
2557
|
+
? contextExecutable ?? measureStatusSync("resolution", () => this.executablePath(NATIVE_REVIEW_OPERATION.STATUS, false))
|
|
2558
|
+
: undefined;
|
|
2559
|
+
const statusArguments = (nonBlockingFindings: boolean) => submittedTokens === undefined ? [
|
|
2426
2560
|
"review", "status", "--contract", REVIEW_INTEGRATION_CONTRACT, "--cwd", request.cwd,
|
|
2427
2561
|
"--projection", request.projection ?? "workspace",
|
|
2428
2562
|
...nativeUntrackedSelectionArguments(selection),
|
|
@@ -2430,9 +2564,25 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2430
2564
|
...(request.lineageId === undefined ? [] : ["--lineage", request.lineageId]),
|
|
2431
2565
|
...(request.agent === undefined ? [] : ["--agent", request.agent]),
|
|
2432
2566
|
...nativeLensSelectionArguments(request),
|
|
2567
|
+
...requestContextArguments,
|
|
2568
|
+
...(nonBlockingFindings ? ["--non-blocking-findings"] : []),
|
|
2433
2569
|
"--next-transition",
|
|
2434
|
-
] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request)];
|
|
2435
|
-
const
|
|
2570
|
+
] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request), ...requestContextArguments];
|
|
2571
|
+
const executable = nonBlockingExecutable ?? contextExecutable;
|
|
2572
|
+
const run = (nonBlockingFindings: boolean) => executable === undefined
|
|
2573
|
+
? this.negotiated(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments(nonBlockingFindings), false, request.signal)
|
|
2574
|
+
: this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments(nonBlockingFindings), false, request.signal, executable);
|
|
2575
|
+
const sendNonBlocking = nonBlockingExecutable !== undefined && !nonBlockingFindingsRefused(nonBlockingExecutable);
|
|
2576
|
+
const nonBlockingDigest = sendNonBlocking ? nonBlockingExecutableDigest(nonBlockingExecutable!) : undefined;
|
|
2577
|
+
let execution: NegotiatedExecution;
|
|
2578
|
+
try {
|
|
2579
|
+
execution = await run(sendNonBlocking);
|
|
2580
|
+
} catch (error) {
|
|
2581
|
+
// Only the unknown-flag refusal falls back, once; every other failure is the caller's.
|
|
2582
|
+
if (!sendNonBlocking || !isNativeReviewNonBlockingFindingsUnsupported(error)) throw error;
|
|
2583
|
+
rememberNonBlockingFindingsRefusal(nonBlockingExecutable!, nonBlockingDigest);
|
|
2584
|
+
execution = await run(false);
|
|
2585
|
+
}
|
|
2436
2586
|
measureStatusSync("decode", () => assertSupportedNextTransitionOperation(execution.body));
|
|
2437
2587
|
return decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewStatusV3(execution.body));
|
|
2438
2588
|
}
|
|
@@ -2640,17 +2790,19 @@ export class NativeReviewCliV216 implements NativeReviewCli {
|
|
|
2640
2790
|
}
|
|
2641
2791
|
|
|
2642
2792
|
async reviewMode(request: NativeReviewModeRequest): Promise<NativeReviewModeResult> {
|
|
2793
|
+
const operation = request.operation;
|
|
2794
|
+
const scopeArguments = nativeReviewModeScopeArguments(operation, request.scope);
|
|
2643
2795
|
const cwd = await canonicalNativeReviewCwd(request.cwd);
|
|
2644
|
-
const mutating =
|
|
2796
|
+
const mutating = operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
|
|
2645
2797
|
const execution = await this.invoke(
|
|
2646
2798
|
NATIVE_REVIEW_OPERATION.MODE,
|
|
2647
2799
|
cwd,
|
|
2648
|
-
["review", "mode",
|
|
2800
|
+
["review", "mode", operation, "--cwd", cwd, ...scopeArguments, "--json"],
|
|
2649
2801
|
mutating,
|
|
2650
2802
|
request.signal,
|
|
2651
2803
|
this.executablePath(NATIVE_REVIEW_OPERATION.MODE, mutating),
|
|
2652
2804
|
);
|
|
2653
|
-
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(execution.body,
|
|
2805
|
+
return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(execution.body, operation));
|
|
2654
2806
|
}
|
|
2655
2807
|
|
|
2656
2808
|
// Read-only risk assessment (gentle-ai#4295, gentle-pi#662). Never mutates;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readCatalog, type CatalogPage } from "./orchestrator-catalog.ts";
|
|
2
2
|
import type { PublishedWork } from "./orchestrator-work.ts";
|
|
3
3
|
import type { PresenceRecord } from "./agents-session-transport.ts";
|
|
4
|
-
import { activationHash, discoveryAbsent,
|
|
4
|
+
import { activationHash, discoveryAbsent, PresenceCursor, readDiscovery, sessionHash, type DiscoveryMetadata, type PresencePage } from "./orchestrator-presence.ts";
|
|
5
5
|
|
|
6
6
|
export interface OrchestratorCandidate {
|
|
7
7
|
sessionId: string;
|
|
@@ -27,11 +27,48 @@ export interface OrchestratorCandidate {
|
|
|
27
27
|
publication?: { incarnation: string; activation: string; heartbeat: number };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** Total directory-entry budget for one discovery scan. A directory this large
|
|
31
|
+
* is treated as flooded and fails closed; aligns with SWEEP_MAX_FILES in
|
|
32
|
+
* agents-session-transport.ts. */
|
|
33
|
+
const SCAN_MAX_ENTRIES = 4096;
|
|
34
|
+
|
|
35
|
+
/** Mirrors orchestrator-presence's reason() for the cursor constructor's throw,
|
|
36
|
+
* which next() would otherwise report as an unavailable page. */
|
|
37
|
+
function presenceUnavailable(error: unknown): string {
|
|
38
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
39
|
+
return code === "ENOENT" ? "missing" : code ? "io-error" : error instanceof SyntaxError ? "malformed" : (error as Error).message;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Full pagination over PresenceCursor instead of the first-page-only listPresence:
|
|
43
|
+
* legitimate busy directories (hundreds of header + activity + discovery sidecars)
|
|
44
|
+
* must not blind every peer behind the 128-entry first page (#3185). Overflow is
|
|
45
|
+
* reported only when the total directory-entry budget is exceeded; any per-page
|
|
46
|
+
* unavailable result still fails closed. */
|
|
47
|
+
function scanPresence(profile: string, now: number): PresencePage {
|
|
48
|
+
let cursor: PresenceCursor;
|
|
49
|
+
try { cursor = new PresenceCursor(profile); }
|
|
50
|
+
catch (error) { return { entries: [], scanned: 0, rejected: 0, overflow: false, unavailable: presenceUnavailable(error) }; }
|
|
51
|
+
const entries: PresencePage["entries"] = [];
|
|
52
|
+
let scanned = 0;
|
|
53
|
+
let rejected = 0;
|
|
54
|
+
try {
|
|
55
|
+
for (;;) {
|
|
56
|
+
const page = cursor.next(now);
|
|
57
|
+
entries.push(...page.entries);
|
|
58
|
+
scanned += page.scanned;
|
|
59
|
+
rejected += page.rejected;
|
|
60
|
+
if (page.unavailable) return { entries, scanned, rejected, overflow: false, unavailable: page.unavailable };
|
|
61
|
+
if (!page.overflow) return { entries, scanned, rejected, overflow: false };
|
|
62
|
+
if (scanned >= SCAN_MAX_ENTRIES) return { entries, scanned, rejected, overflow: true };
|
|
63
|
+
}
|
|
64
|
+
} finally { cursor.close(); }
|
|
65
|
+
}
|
|
66
|
+
|
|
30
67
|
/** One bounded metadata page, no thread reads or transport probes. The registry
|
|
31
68
|
* selects a canonical routing activation; metadata must bind to that exact one.
|
|
32
69
|
* Incomplete scans and duplicate presence headers fail closed. */
|
|
33
70
|
export function discoverOrchestrators(profile: string, peers: readonly PresenceRecord[], now = Date.now(), selection?: { recipientSessionId?: string; cursor?: string; consultation?: boolean; includeWork?: boolean; stateOnly?: boolean }): OrchestratorCandidate[] {
|
|
34
|
-
const page =
|
|
71
|
+
const page = scanPresence(profile, now);
|
|
35
72
|
const ids = [...new Set(peers.map(peer => peer.sessionId))];
|
|
36
73
|
return ids.filter(id => selection?.recipientSessionId === undefined || selection.recipientSessionId === id).map(sessionId => {
|
|
37
74
|
const unknown: OrchestratorCandidate = { sessionId, reachability: "unknown", freshness: "unknown" };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Effective orchestrator workflow mode (full-delegation-mode S2/S7).
|
|
2
|
+
//
|
|
3
|
+
// Pure resolver, extracted so the prompt builder can read the mode without
|
|
4
|
+
// owning profile plumbing. No pi imports belong in this file.
|
|
5
|
+
//
|
|
6
|
+
// Resolution order (first hit wins):
|
|
7
|
+
// 1. Env `GENTLE_PI_ORCHESTRATOR_MODE` ("organic" | "full-delegation")
|
|
8
|
+
// 2. The session's profile, read live through `resolveSessionProfile`
|
|
9
|
+
// 3. Default "organic"
|
|
10
|
+
//
|
|
11
|
+
// The profile is READ LIVE on every call, never from the startup freeze: the
|
|
12
|
+
// whole point of a per-profile switch is that pressing Enter on another profile
|
|
13
|
+
// changes the orchestrator's rules on the next turn, in both directions. The
|
|
14
|
+
// freeze pins the `inherited` defaults so a shared default changed mid-session
|
|
15
|
+
// does not silently re-route work; it is not meant to pin the profile a session
|
|
16
|
+
// deliberately switched to, and `resolveSessionProfile` already returns an
|
|
17
|
+
// explicit `origin: "user"` binding before any frozen snapshot.
|
|
18
|
+
//
|
|
19
|
+
// The env override is deliberate and reported: an ambient override that changes
|
|
20
|
+
// behaviour while the panel shows something else is exactly the "I edited it and
|
|
21
|
+
// nothing happened" trap, so `source` is part of the result and the panel shows
|
|
22
|
+
// it rather than re-deriving it.
|
|
23
|
+
|
|
24
|
+
import { profilesFilePath, readProfileWorkflow, readProfilesFileResult, DEFAULT_ORCHESTRATOR_MODE, type OrchestratorMode } from "./agent-profiles.ts";
|
|
25
|
+
import { resolveSessionProfile } from "./session-profile-freeze.ts";
|
|
26
|
+
|
|
27
|
+
export const ORCHESTRATOR_MODE_ENV = "GENTLE_PI_ORCHESTRATOR_MODE";
|
|
28
|
+
|
|
29
|
+
/** Which layer decided the effective mode. */
|
|
30
|
+
export type OrchestratorModeSource = "environment" | "session_profile" | "default";
|
|
31
|
+
|
|
32
|
+
export interface OrchestratorModeResolution {
|
|
33
|
+
mode: OrchestratorMode;
|
|
34
|
+
source: OrchestratorModeSource;
|
|
35
|
+
/** The profile that was consulted, when the session had one. */
|
|
36
|
+
profileName?: string;
|
|
37
|
+
/** The raw env value, reported even when it is unrecognized and inert. */
|
|
38
|
+
envValue?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ResolveOrchestratorModeOptions {
|
|
42
|
+
cwd: string;
|
|
43
|
+
/** Gentle Pi config home directory (honors GENTLE_PI_CONFIG_HOME at the call site). */
|
|
44
|
+
configHome: string;
|
|
45
|
+
sessionId: string | undefined;
|
|
46
|
+
/** Override the environment lookup (used in tests). */
|
|
47
|
+
env?: NodeJS.ProcessEnv;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The profile name a session resolution points at, or undefined for no profile. */
|
|
51
|
+
function resolvedProfileName(resolution: ReturnType<typeof resolveSessionProfile>): string | undefined {
|
|
52
|
+
return resolution.kind === "explicit" ? resolution.name : resolution.profile?.name;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The mode a profile stores, or the raised default when the store cannot
|
|
57
|
+
* answer. Never throws: this runs inside the prompt build, and a broken store
|
|
58
|
+
* must degrade to today's behaviour instead of breaking the orchestrator.
|
|
59
|
+
*/
|
|
60
|
+
function modeFromProfile(configHome: string, profileName: string): OrchestratorMode {
|
|
61
|
+
try {
|
|
62
|
+
const read = readProfilesFileResult(profilesFilePath(configHome));
|
|
63
|
+
if (read.status !== "valid") return DEFAULT_ORCHESTRATOR_MODE;
|
|
64
|
+
return readProfileWorkflow(read.file, profileName).orchestratorMode;
|
|
65
|
+
} catch {
|
|
66
|
+
return DEFAULT_ORCHESTRATOR_MODE;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function resolveOrchestratorMode(
|
|
71
|
+
options: ResolveOrchestratorModeOptions,
|
|
72
|
+
): OrchestratorModeResolution {
|
|
73
|
+
const env = options.env ?? process.env;
|
|
74
|
+
const envValue = env[ORCHESTRATOR_MODE_ENV];
|
|
75
|
+
const overridden = envValue === "organic" || envValue === "full-delegation";
|
|
76
|
+
let profileName: string | undefined;
|
|
77
|
+
try {
|
|
78
|
+
profileName = resolvedProfileName(
|
|
79
|
+
resolveSessionProfile({
|
|
80
|
+
cwd: options.cwd,
|
|
81
|
+
configHome: options.configHome,
|
|
82
|
+
sessionId: options.sessionId,
|
|
83
|
+
...(options.env === undefined ? {} : { env: options.env }),
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
} catch {
|
|
87
|
+
// A profile layer that cannot answer leaves the session in today's mode;
|
|
88
|
+
// it must not take the prompt build down with it.
|
|
89
|
+
profileName = undefined;
|
|
90
|
+
}
|
|
91
|
+
const reported = {
|
|
92
|
+
...(profileName === undefined ? {} : { profileName }),
|
|
93
|
+
...(envValue === undefined ? {} : { envValue }),
|
|
94
|
+
};
|
|
95
|
+
if (overridden) return { mode: envValue, source: "environment", ...reported };
|
|
96
|
+
if (profileName !== undefined) {
|
|
97
|
+
return { mode: modeFromProfile(options.configHome, profileName), source: "session_profile", ...reported };
|
|
98
|
+
}
|
|
99
|
+
return { mode: DEFAULT_ORCHESTRATOR_MODE, source: "default", ...reported };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Whether the effective mode requires the supervisor-only workflow. */
|
|
103
|
+
export function isFullDelegationMode(resolution: OrchestratorModeResolution): boolean {
|
|
104
|
+
return resolution.mode === "full-delegation";
|
|
105
|
+
}
|