gentle-pi 4.9.0 → 5.1.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 +2 -2
- package/assets/agents/gentle-ai-explore.md +3 -6
- package/assets/agents/gentle-ai-verify.md +2 -2
- package/assets/agents/gentle-ai-worker.md +9 -9
- package/assets/agents/jd-fix-agent.md +2 -2
- package/assets/agents/jd-judge-a.md +0 -1
- package/assets/agents/jd-judge-b.md +0 -1
- package/assets/migrations/agent-body-history.json +9 -0
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation.md +1 -1
- package/assets/orchestrator-maintenance.md +11 -0
- package/assets/orchestrator-quota-recovery.md +1 -1
- package/assets/orchestrator-skills.md +10 -0
- package/assets/orchestrator-tracking.md +2 -2
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator.md +2 -2
- package/bin/gentle-shell.mjs +69 -17
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +11 -10
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/manifest.json +5 -5
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/orchestration/pi.md +5 -3
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/routing/pi.md +2 -2
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/lens.schema.json +3 -3
- package/contracts/review-provider-contract-mirror/v1.7.0/bundle/vectors/lens.json +1 -0
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-roles.baseline.json +3 -3
- package/docs/bundled-install.md +2 -2
- package/docs/delegated-verification.md +10 -6
- package/docs/desktop-feed.md +15 -6
- package/docs/desktop-rpc.md +298 -30
- package/docs/gentle-shell-desktop.md +10 -3
- package/docs/gentle-shell.md +25 -19
- package/docs/install-wizard.md +7 -5
- package/docs/native-authority-architecture.md +3 -3
- package/docs/odd-preparation-continuity.md +2 -2
- package/docs/permission-modes.md +10 -2
- package/docs/readme-reference.md +53 -24
- package/docs/review-coordinator.md +4 -2
- package/docs/session-profile-format.md +33 -7
- package/docs/sound-notifications.md +1 -1
- package/docs/work-continuity.md +7 -7
- package/docs/yolo-mode.md +1 -1
- package/extensions/ask-user-choice.ts +2 -2
- package/extensions/ask-user-question.ts +1 -1
- package/extensions/child-context.ts +2 -11
- package/extensions/gentle-agents.ts +86 -30
- package/extensions/gentle-ai.ts +918 -632
- package/extensions/gentle-desktop-feed.ts +13 -3
- package/extensions/gentle-desktop-rpc.ts +51 -2
- package/extensions/gentle-fast.ts +9 -2
- package/extensions/gentle-music.ts +2 -0
- package/extensions/gentle-notifications.ts +12 -4
- package/extensions/gentle-shell.ts +157 -62
- package/extensions/gentle-star-prompt.ts +3 -0
- package/extensions/gentle-tps.ts +7 -0
- package/extensions/history/index.ts +1 -1
- package/extensions/quiet-tools.ts +13 -22
- package/extensions/skill-registry.ts +9 -1
- package/extensions/startup-banner.ts +8 -13
- package/herdr/mods/gentle-agents/snapshot.js +30 -23
- package/herdr/mods/gentle-chat/feed.js +6 -0
- package/herdr/mods/gentle-chat/main.js +76 -16
- package/herdr/mods/gentle-chat/session.js +13 -5
- package/herdr/mods/gentle-chat/snapshot.js +30 -23
- package/herdr/mods/gentle-chat/ui.js +7 -1
- package/herdr/mods/gentle-inspector/main.js +2 -0
- package/herdr/mods/gentle-inspector/snapshot.js +30 -23
- package/herdr/mods/gentle-palette/main.js +1 -1
- package/herdr/mods/gentle-palette/snapshot.js +30 -23
- package/herdr/mods/gentle-pane/snapshot.js +30 -23
- package/herdr/mods/gentle-sidebar/snapshot.js +30 -23
- package/herdr/mods/gentle-spaces/snapshot.js +30 -23
- package/herdr/mods/gentle-status/snapshot.js +30 -23
- package/herdr/mods/gentle-tabs/main.js +3 -2
- package/herdr/mods/gentle-tabs/new-tab.js +9 -0
- package/herdr/mods/gentle-tabs/snapshot.js +30 -23
- package/herdr/mods/gentle-tokens/snapshot.js +30 -23
- package/lib/agent-profiles.ts +50 -10
- package/lib/agents-config.ts +69 -5
- package/lib/agents-runner.ts +34 -1
- package/lib/auto-permission-runtime.ts +2 -1
- package/lib/background-jobs-tools.ts +24 -16
- package/lib/banner-config.ts +69 -0
- package/lib/child-session.ts +6 -0
- package/lib/claude-bridge-config.ts +41 -0
- package/lib/codex-turn-continuation.ts +40 -0
- package/lib/compaction-threshold.ts +46 -0
- package/lib/context-threshold.ts +5 -5
- package/lib/desktop-agent-definitions-service.ts +93 -0
- package/lib/desktop-auth-service.ts +102 -0
- package/lib/desktop-background-subagents-service.ts +155 -0
- package/lib/desktop-command-rpc.ts +71 -0
- package/lib/desktop-feed-sources.ts +44 -1
- package/lib/desktop-feed.ts +41 -29
- package/lib/desktop-rpc-agent-definitions.ts +119 -0
- package/lib/desktop-rpc-agents.ts +44 -3
- package/lib/desktop-rpc-auth.ts +103 -0
- package/lib/desktop-rpc-background-subagents.ts +126 -0
- package/lib/desktop-rpc-changes.ts +13 -4
- package/lib/desktop-rpc-config.ts +287 -13
- package/lib/desktop-rpc-profile-binding.ts +212 -0
- package/lib/desktop-rpc-profiles.ts +2 -0
- package/lib/desktop-rpc-stats.ts +16 -4
- package/lib/desktop-rpc-status.ts +103 -0
- package/lib/desktop-status-service.ts +86 -0
- package/lib/destructive-command-guard.ts +9 -185
- package/lib/exploration-budget.ts +3 -7
- package/lib/gentle-design.ts +23 -4
- package/lib/gentle-shell-desktop.ts +85 -0
- package/lib/gentle-shell-launcher.ts +120 -8
- package/lib/mcp-config.ts +214 -0
- package/lib/native-choice-list.ts +1 -1
- package/lib/native-fullscreen-interaction.ts +3 -0
- package/lib/native-pointer-region.ts +1 -1
- package/lib/native-review-cli.ts +213 -397
- package/lib/odd-phase-inference.ts +1 -1
- package/lib/orchestrator-mode-policy.ts +25 -12
- package/lib/path-consent-fence.ts +113 -0
- package/lib/persona-config.ts +77 -0
- package/lib/pi-settings.ts +157 -0
- package/lib/questionnaire/questionnaire-view.ts +1 -1
- package/lib/review-continuation-registry.ts +9 -26
- package/lib/review-coordinator.ts +13 -2
- package/lib/review-host-relay.ts +2 -35
- package/lib/review-integration-v2.ts +129 -180
- package/lib/review-object-store.ts +0 -57
- package/lib/review-repository.ts +0 -44
- package/lib/review-risk-assessment.ts +11 -36
- package/lib/review-start-context.ts +2 -1
- package/lib/review-transaction.ts +6 -6
- package/lib/sensitive-paths.ts +45 -0
- package/lib/session-profile-binding.ts +29 -0
- package/lib/session-profile-freeze.ts +11 -4
- package/lib/session-worktree-registry.ts +11 -5
- package/lib/shell-bar.ts +41 -18
- package/lib/shell-card.ts +27 -1
- package/lib/shell-changes-view.ts +6 -2
- package/lib/shell-changes.ts +94 -37
- package/lib/shell-git-worker.ts +158 -0
- package/lib/shell-idle-changes.ts +88 -0
- package/lib/shell-untracked-cache.ts +142 -0
- package/lib/shell-untracked-lines.ts +178 -0
- package/lib/stats-collector.ts +24 -0
- package/lib/tower-open.ts +8 -1
- package/lib/tps-policy.ts +85 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/voice-artifacts.ts +8 -1
- package/lib/voice-install.ts +7 -3
- package/lib/yolo-session-policy.ts +2 -2
- package/package.json +1 -1
- package/runtime/gentle-shell-desktop.mjs +85 -0
- package/runtime/gentle-shell-launcher.mjs +120 -8
- package/runtime/native-review-cli.mjs +206 -390
- package/runtime/review-integration-v2.mjs +129 -180
- package/runtime/review-risk-assessment.mjs +11 -36
- package/runtime/sensitive-paths.mjs +46 -0
- package/runtime/tower-open.mjs +8 -1
- package/scripts/build-runtime-modules.mjs +2 -0
- package/scripts/gentle-ai-installer.mjs +13 -14
- package/scripts/installer-preflight.mjs +1 -1
- package/scripts/main-channel.mjs +47 -11
- package/scripts/pi-update.mjs +10 -4
- package/scripts/prepare-verifier.mjs +14 -4
- package/scripts/verify-package-files.mjs +45 -13
- package/skills/judgment-day/SKILL.md +1 -1
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/provider-defect-report/SKILL.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +2 -2
- package/skills/skill-creator/SKILL.md +4 -4
- package/skills/skill-improver/SKILL.md +4 -4
- package/skills/skill-registry/SKILL.md +2 -2
- package/tests/agent-profiles-workflow.test.ts +102 -0
- package/tests/agent-risk-escalation.test.ts +15 -0
- package/tests/agents-config.test.ts +22 -2
- package/tests/agents-protocol.test.ts +1 -1
- package/tests/agents-runner.test.ts +94 -2
- package/tests/append-system-prompt-route.test.ts +16 -11
- package/tests/ask-user-choice.test.ts +19 -0
- package/tests/ask-user-question.test.ts +23 -4
- package/tests/auto-permission-runtime.test.ts +4 -4
- package/tests/bounded-stop-contract.test.ts +50 -62
- package/tests/built-web-guard.test.ts +32 -0
- package/tests/child-context-files.test.ts +6 -6
- package/tests/child-ui-extensions.test.ts +125 -0
- package/tests/child-web-package.test.ts +1 -1
- package/tests/codex-turn-continuation.test.ts +183 -0
- package/tests/committed-range-untracked-exclusion.test.ts +18 -0
- package/tests/controlled-engineering-editor.test.ts +192 -0
- package/tests/controlled-engineering-launch.test.ts +136 -0
- package/tests/controlled-engineering.test.ts +244 -0
- package/tests/delegate-for-reason-contract.test.ts +1 -1
- package/tests/delivery-b-rendered-surfaces.test.ts +1 -1
- package/tests/delivery-conflict-markers.test.ts +2 -3
- package/tests/desktop-feed-tool-summaries.test.ts +1 -1
- package/tests/desktop-feed-transcript.test.ts +17 -0
- package/tests/desktop-feed.test.ts +141 -7
- package/tests/desktop-liveness.test.ts +125 -0
- package/tests/desktop-persona.test.ts +17 -0
- package/tests/desktop-rpc-agent-definitions.test.ts +219 -0
- package/tests/desktop-rpc-agents.test.ts +113 -3
- package/tests/desktop-rpc-auth.test.ts +278 -0
- package/tests/desktop-rpc-background-subagents.test.ts +186 -0
- package/tests/desktop-rpc-changes.test.ts +81 -4
- package/tests/desktop-rpc-config-mcp-fidelity.test.ts +106 -0
- package/tests/desktop-rpc-config-readonly-stores.test.ts +458 -0
- package/tests/desktop-rpc-config-settings.test.ts +234 -0
- package/tests/desktop-rpc-config.test.ts +17 -3
- package/tests/desktop-rpc-design.test.ts +30 -1
- package/tests/desktop-rpc-jobs.test.ts +9 -1
- package/tests/desktop-rpc-permissions.test.ts +9 -1
- package/tests/desktop-rpc-profile-binding.test.ts +195 -0
- package/tests/desktop-rpc-review.test.ts +1 -1
- package/tests/desktop-rpc-session-snapshot-commands.test.ts +50 -0
- package/tests/desktop-rpc-session.test.ts +2 -2
- package/tests/desktop-rpc-stats.test.ts +42 -11
- package/tests/desktop-rpc-status.test.ts +195 -0
- package/tests/desktop-rpc-updates.test.ts +1 -1
- package/tests/desktop-rpc-usage.test.ts +9 -1
- package/tests/desktop-rpc.test.ts +2 -2
- package/tests/desktop-session-switch.test.ts +237 -0
- package/tests/desktop-target-session.test.ts +104 -0
- package/tests/destructive-command-guard.test.ts +187 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +73 -9
- package/tests/exploration-budget.test.ts +2 -26
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +15 -11
- package/tests/full-delegation-closure.test.ts +19 -9
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agents.test.ts +215 -10
- package/tests/gentle-ai-binary.test.ts +3 -3
- package/tests/gentle-ai-exploration-budget.test.ts +3 -2
- package/tests/gentle-ai-installer.test.ts +60 -59
- package/tests/gentle-ai.test.ts +30 -59
- package/tests/gentle-chat-read-failure.test.ts +74 -0
- package/tests/gentle-chat-session-read.test.ts +127 -0
- package/tests/gentle-design.test.ts +39 -0
- package/tests/gentle-notifications.test.ts +43 -5
- package/tests/gentle-shell-desktop.test.ts +108 -0
- package/tests/gentle-shell-launcher-auto-provision.test.ts +152 -0
- package/tests/gentle-shell-launcher-machine-output.test.ts +356 -0
- package/tests/gentle-shell-launcher-tower.test.ts +7 -1
- package/tests/gentle-shell.test.ts +163 -15
- package/tests/gentle-tps.test.ts +57 -0
- package/tests/independent-recovery-delivery.test.ts +15 -13
- package/tests/installer-preflight.test.ts +3 -2
- package/tests/installer-server.test.ts +3 -2
- package/tests/installer-windows-bootstrap.test.ts +6 -0
- package/tests/job-turn-end-texts.test.ts +57 -0
- package/tests/judgment-day-dispatch-diagnostics.test.ts +87 -0
- package/tests/lazy-module-contradictions-contract.test.ts +2 -3
- package/tests/main-channel-upgrade.test.ts +14 -7
- package/tests/main-channel.test.ts +78 -23
- package/tests/maintainer/desktop-rpc.maintest.ts +4 -4
- package/tests/native-fullscreen-interaction.test.ts +37 -1
- package/tests/native-review-capability-contract.test.ts +13 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +9 -84
- package/tests/native-review-cli.test.ts +199 -21
- package/tests/native-review-consent.test.ts +20 -3
- package/tests/native-review-start-escalation-real-binary.test.ts +42 -0
- package/tests/no-self-pause-contract.test.ts +8 -7
- package/tests/odd-phase-inference.test.ts +2 -2
- package/tests/odd-routing-canonical-ratchet.test.ts +1 -1
- package/tests/odd-routing-contract.test.ts +2 -2
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +5 -5
- package/tests/orchestrator-skills-inline-contract.test.ts +26 -0
- package/tests/package-manifest.test.ts +11 -16
- package/tests/packaged-agent-codemode.test.ts +79 -0
- package/tests/path-consent-fence.test.ts +326 -0
- package/tests/persona-config.test.ts +42 -0
- package/tests/pi-update-launcher.test.ts +1 -1
- package/tests/pi-update-source.test.ts +48 -2
- package/tests/primary-session-prompt.test.ts +9 -7
- package/tests/profile-fast-tier.test.ts +79 -4
- package/tests/progress-rule-contract.test.ts +54 -0
- package/tests/rdd-delivery-warning.test.ts +109 -0
- package/tests/review-actor-tool-deny.test.ts +1 -2
- package/tests/review-agent-end-preflight.test.ts +3 -1
- package/tests/review-assess-escalation-forwarding.test.ts +99 -0
- package/tests/review-authority-recovery-docs.test.ts +9 -12
- package/tests/review-continuation-registry.test.ts +24 -25
- package/tests/review-controller-native-recovery.test.ts +165 -178
- package/tests/review-controller-native-routing.test.ts +352 -27
- package/tests/review-coordinator-correction-gate.test.ts +5 -9
- package/tests/review-coordinator-runtime.test.ts +3 -2
- package/tests/review-coordinator.test.ts +14 -0
- package/tests/review-due-compaction.test.ts +1 -1
- package/tests/review-failure-facts.test.ts +2 -2
- package/tests/review-host-relay-restart-parity.test.ts +2 -52
- package/tests/review-host-relay-routing.test.ts +59 -298
- package/tests/review-host-relay.test.ts +0 -46
- package/tests/review-integration-nonblocking-findings.test.ts +3 -6
- package/tests/review-integration-v2-forward.test.ts +114 -234
- package/tests/review-integration-v2.test.ts +85 -39
- package/tests/review-json-arguments.test.ts +30 -9
- package/tests/review-legacy-check.test.ts +38 -0
- package/tests/review-object-store.test.ts +2 -57
- package/tests/review-one-call-findings.test.ts +1 -0
- package/tests/review-one-call.test.ts +56 -0
- package/tests/review-risk-assessment.test.ts +14 -43
- package/tests/review-run-escalate-forwarding.test.ts +59 -0
- package/tests/review-sidebar-state.test.ts +2 -1
- package/tests/review-untracked-inventory-replay.test.ts +181 -0
- package/tests/runtime-harness.mjs +30 -4
- package/tests/sensitive-path-tools.test.ts +210 -5
- package/tests/session-profile-binding-observers.test.ts +47 -0
- package/tests/session-profile-extension.test.ts +109 -11
- package/tests/session-profile-freeze.test.ts +49 -2
- package/tests/session-profile-v1-compat.test.ts +11 -3
- package/tests/session-worktree-registry.test.ts +23 -0
- package/tests/shell-bar.test.ts +21 -3
- package/tests/shell-changes-idle-start.test.ts +510 -0
- package/tests/shell-changes-untracked-bound.test.ts +230 -0
- package/tests/shell-changes-view.test.ts +8 -2
- package/tests/shell-changes.test.ts +134 -0
- package/tests/shell-git-runner-stall.test.ts +74 -0
- package/tests/shell-git-worker-fallback.test.ts +140 -0
- package/tests/shell-git-worker-lifetime.test.ts +91 -0
- package/tests/shell-render-cache-runtime.test.ts +256 -3
- package/tests/shell-sidebar-layout.test.ts +1 -1
- package/tests/shell-sidebar-scroll-benchmark.test.ts +14 -5
- package/tests/shell-untracked-cache.test.ts +213 -0
- package/tests/short-check-routing-contract.test.ts +11 -7
- package/tests/skill-references.test.ts +39 -0
- package/tests/skill-registry.test.ts +4 -4
- package/tests/startup-banner.test.ts +2 -1
- package/tests/status-timing-diagnostics.test.ts +2 -1
- package/tests/support/capabilities-v26.ts +22 -0
- package/tests/support/chat-ui.ts +39 -0
- package/tests/support/review-coordinator-runtime.ts +11 -2
- package/tests/support/status-v9.ts +8 -0
- package/tests/t7-recovery-preservation.test.ts +68 -0
- package/tests/tower-open.test.ts +24 -0
- package/tests/tower-pack.test.ts +48 -0
- package/tests/tps-policy.test.ts +96 -0
- package/tests/turn-end-rule-contract.test.ts +155 -0
- package/tests/turn-end-scope.test.ts +39 -0
- package/tests/verification-proportionality.test.ts +1 -1
- package/tests/verification-scoped-stop-contract.test.ts +1 -1
- package/tests/verification-tiers-contract.test.ts +4 -3
- package/tests/verifier-admission.test.ts +1 -1
- package/tests/verifier-preparation.test.ts +94 -1
- package/tests/verifier-settle-reminder.test.ts +1 -1
- package/tests/verify-first-launch-contract.test.ts +19 -7
- package/tests/vim-editor-adapter.test.ts +12 -2
- package/tests/voice-install.test.ts +97 -11
- package/tests/windows-hidden-processes.test.ts +11 -44
- package/tests/work-continuity-contract.test.ts +48 -55
- package/tests/yolo-session-policy.test.ts +2 -0
- package/web/tower/dist/assets/BatchableSprite-BJ_TQxjN.js +217 -0
- package/web/tower/dist/assets/BufferResource-DeJpHuO6.js +139 -0
- package/web/tower/dist/assets/CanvasPool-cwc03T_x.js +23 -0
- package/web/tower/dist/assets/CanvasRenderer-DO84oP5R.js +1 -0
- package/web/tower/dist/assets/Filter-BKhT9lO8.js +1 -0
- package/web/tower/dist/assets/GlUniformGroupSystem-DluI7cqd.js +130 -0
- package/web/tower/dist/assets/GpuUboSystem-CM4Dys0F.js +17 -0
- package/web/tower/dist/assets/Graphics-3OyUtCzC.js +1 -0
- package/web/tower/dist/assets/RenderTargetSystem-X-9GAQ1C.js +184 -0
- package/web/tower/dist/assets/WebGLRenderer-I0fqIX1w.js +20 -0
- package/web/tower/dist/assets/WebGPURenderer-BRWSXotK.js +79 -0
- package/web/tower/dist/assets/_commonjsHelpers-CqkleIqs.js +1 -0
- package/web/tower/dist/assets/abnfDiagram-VCTEODGH-C4iBBhTL.js +1 -0
- package/web/tower/dist/assets/architectureDiagram-5GKGNRK7-Ih-qvfTu.js +36 -0
- package/web/tower/dist/assets/blockDiagram-I7D4REHJ-I9z_u3wb.js +129 -0
- package/web/tower/dist/assets/browserAll-gmBFNIA4.js +14 -0
- package/web/tower/dist/assets/c4Diagram-7LVT6UL2-DOyk2rEJ.js +38 -0
- package/web/tower/dist/assets/canvasUtils-DTaMcbkN.js +1 -0
- package/web/tower/dist/assets/channel-wuxBkGGz.js +1 -0
- package/web/tower/dist/assets/chunk-2Q5K7J3B-BaJ-OrJ_.js +1 -0
- package/web/tower/dist/assets/chunk-5VM5RSS4-wICrhvyw.js +15 -0
- package/web/tower/dist/assets/chunk-F27PBJKO-DUQ_JqvZ.js +1 -0
- package/web/tower/dist/assets/chunk-IMKFNOWR-DKfgQrGM.js +231 -0
- package/web/tower/dist/assets/chunk-JWPE2WC7-1k1LW87d.js +1 -0
- package/web/tower/dist/assets/chunk-POPQ4Y6H-Df8cN2w9.js +1 -0
- package/web/tower/dist/assets/chunk-SVP7TREG-CxU5LDj8.js +88 -0
- package/web/tower/dist/assets/chunk-TICWLB2K-CEuHEBi0.js +206 -0
- package/web/tower/dist/assets/chunk-XXDRQBXY-CbSAjj9l.js +1 -0
- package/web/tower/dist/assets/classDiagram-ZZMXUADV-DbRmVQRX.js +1 -0
- package/web/tower/dist/assets/classDiagram-v2-VYDZK3BY-DbRmVQRX.js +1 -0
- package/web/tower/dist/assets/cose-bilkent-JH36ORCC-8xZLSHER.js +1 -0
- package/web/tower/dist/assets/cynefin-OW5HDTMX-Cw4XG9Zj.js +166 -0
- package/web/tower/dist/assets/cynefinDiagram-5FMLGOSQ-CcQdokUv.js +62 -0
- package/web/tower/dist/assets/cytoscape.esm-BHa1VTXv.js +321 -0
- package/web/tower/dist/assets/d3-scale-4DPf7zan.js +1 -0
- package/web/tower/dist/assets/dagre-GXQ25YYZ-D-Xv7L9X.js +4 -0
- package/web/tower/dist/assets/diagram-S7CK7UJ4-Bqy2eT2c.js +30 -0
- package/web/tower/dist/assets/diagram-UQ7AKVKN-B2wK2GHj.js +41 -0
- package/web/tower/dist/assets/diagram-VSXAHHWV-CIZqh7BH.js +3 -0
- package/web/tower/dist/assets/diagram-VX7I27RA-BGX4HBj2.js +24 -0
- package/web/tower/dist/assets/diagram-Z3DM3KII-DYpsfaJW.js +24 -0
- package/web/tower/dist/assets/ebnfDiagram-PWID7BFC-BNnwCZNv.js +1 -0
- package/web/tower/dist/assets/erDiagram-RLTQ6QDP-_MN9W-1E.js +99 -0
- package/web/tower/dist/assets/flowDiagram-HODETNUW-D_ndx1UC.js +168 -0
- package/web/tower/dist/assets/ganttDiagram-EL5Y4UJY-C8chdEiZ.js +292 -0
- package/web/tower/dist/assets/getPo2TextureFromSource-CqJsdi0J.js +1 -0
- package/web/tower/dist/assets/getTexelRangeRects-DN3N5aFp.js +57 -0
- package/web/tower/dist/assets/getTextureBatchBindGroup-RNSiAVH3.js +1 -0
- package/web/tower/dist/assets/gitGraphDiagram-WWUBYQGX-B5ijv7LI.js +106 -0
- package/web/tower/dist/assets/index-B1Ho-Igs.css +1 -0
- package/web/tower/dist/assets/index-CfNjH1Wr.js +45 -0
- package/web/tower/dist/assets/infoDiagram-27XIBGKW-AYbp5ElT.js +2 -0
- package/web/tower/dist/assets/ishikawaDiagram-5VMMS53U-DnmwARuR.js +70 -0
- package/web/tower/dist/assets/journeyDiagram-3NMN7TZE-CK737kko.js +139 -0
- package/web/tower/dist/assets/kanban-definition-UXKFOSKX-0AhM3axC.js +89 -0
- package/web/tower/dist/assets/katex-HP8lGamR.js +257 -0
- package/web/tower/dist/assets/layout-wOIeK9c_.js +1 -0
- package/web/tower/dist/assets/mermaid.core-CGYyw6G7.js +310 -0
- package/web/tower/dist/assets/mindmap-definition-YA3MSWOX-CkZ_JOdx.js +96 -0
- package/web/tower/dist/assets/pegDiagram-XKGWAZYB-CHAPspih.js +1 -0
- package/web/tower/dist/assets/pieDiagram-E7YTZNPT-LwCcZl5o.js +39 -0
- package/web/tower/dist/assets/preload-helper-PPVm8Dsz.js +1 -0
- package/web/tower/dist/assets/quadrantDiagram-AXDQQJYC-Cm4uijV2.js +7 -0
- package/web/tower/dist/assets/railroadDiagram-O6MQD6OU-BPQHZ2b5.js +1 -0
- package/web/tower/dist/assets/requirementDiagram-BXWQKSXE-JLtSUDfS.js +84 -0
- package/web/tower/dist/assets/sankeyDiagram-P5KCCOFB-DJsYv9ii.js +40 -0
- package/web/tower/dist/assets/sequenceDiagram-WJ2MYXX4-Ca8T8sT0.js +162 -0
- package/web/tower/dist/assets/sizeCapture-INFHLROL-Ch4i2dS-.js +1 -0
- package/web/tower/dist/assets/stateDiagram-D77RDMKH-DDSkncYm.js +1 -0
- package/web/tower/dist/assets/stateDiagram-v2-MP3YSRHH-BkO_9mIH.js +1 -0
- package/web/tower/dist/assets/swimlanes-42K2YHIH-Bns5iI3y.js +1 -0
- package/web/tower/dist/assets/swimlanesDiagram-VR7AAH4N--LEBb1ti.js +8 -0
- package/web/tower/dist/assets/timeline-definition-24CTP7MA-QJDuVTb3.js +120 -0
- package/web/tower/dist/assets/vennDiagram-4TSXK5OY-pBNxKxOV.js +34 -0
- package/web/tower/dist/assets/wardleyDiagram-VM6X3IG4-1PEarjN1.js +78 -0
- package/web/tower/dist/assets/webworkerAll-D_Np003p.js +83 -0
- package/web/tower/dist/assets/xychartDiagram-S5SC5T6Z-CLwsvOg7.js +7 -0
- package/web/tower/dist/index.html +41 -0
- package/contracts/review-provider-contract-mirror/v1.6.0/bundle/vectors/lens.json +0 -1
- package/docs/review-delivery-preflight.md +0 -22
- package/extensions/codegraph-tools.ts +0 -437
- package/lib/native-review-authority-quarantine.ts +0 -2
- package/lib/review-delivery-preflight.ts +0 -85
- package/lib/review-legacy-detector.ts +0 -81
- package/tests/child-codegraph-bootstrap.test.ts +0 -74
- package/tests/codegraph-tools.test.ts +0 -554
- package/tests/fixtures/devbinary/capabilities-v2.1.derived.json +0 -331
- package/tests/fixtures/refusal-identity.probe.mjs +0 -139
- package/tests/native-review-authority-quarantine.test.ts +0 -10
- package/tests/native-review-refusal-identity.test.ts +0 -25
- package/tests/review-delivery-preflight.test.ts +0 -462
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -210,6 +210,8 @@ test("projectDesktopAgent keeps only the whitelist and never prompt/cwd/path/res
|
|
|
210
210
|
thinking: "high",
|
|
211
211
|
lastStep: "running",
|
|
212
212
|
usage: { total: 1234, cost: 0.005, input: 100, output: 40, cache: 40, reasoning: 5 },
|
|
213
|
+
turns: 1,
|
|
214
|
+
toolCalls: 2,
|
|
213
215
|
});
|
|
214
216
|
|
|
215
217
|
const projected = JSON.stringify(projectDesktopAgent(record));
|
|
@@ -229,6 +231,8 @@ test("projectDesktopAgent omits optional fields and the breakdown when absent",
|
|
|
229
231
|
thinking: "high",
|
|
230
232
|
lastStep: "running",
|
|
231
233
|
usage: { total: 1234, cost: 0.005 },
|
|
234
|
+
turns: 1,
|
|
235
|
+
toolCalls: 2,
|
|
232
236
|
});
|
|
233
237
|
});
|
|
234
238
|
|
|
@@ -877,8 +881,16 @@ test("the Desktop transport advertises the agents methods and event", (t) => {
|
|
|
877
881
|
"set_review_mode",
|
|
878
882
|
"get_usage_stats",
|
|
879
883
|
"get_update_status",
|
|
884
|
+
"list_agent_definitions",
|
|
885
|
+
"get_status",
|
|
886
|
+
"get_background_subagents",
|
|
887
|
+
"set_background_subagents",
|
|
888
|
+
"get_profile_binding",
|
|
889
|
+
"clear_profile_binding",
|
|
890
|
+
"get_auth_status",
|
|
891
|
+
"reload_credentials",
|
|
880
892
|
]);
|
|
881
|
-
assert.deepEqual(response.data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed"]);
|
|
893
|
+
assert.deepEqual(response.data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed", "profile_binding_changed"]);
|
|
882
894
|
});
|
|
883
895
|
|
|
884
896
|
test("get_subagent_thread answers agents_unavailable through the transport without an owner extension", async (t) => {
|
|
@@ -929,7 +941,7 @@ interface RealOwnerHarness {
|
|
|
929
941
|
* `worker` agent definition is written into the agent home so `subagent_run`
|
|
930
942
|
* can launch a real background task.
|
|
931
943
|
*/
|
|
932
|
-
async function realOwnerHarness(t: test.TestContext): Promise<RealOwnerHarness> {
|
|
944
|
+
async function realOwnerHarness(t: test.TestContext, options: { schedule?: (fn: () => void, ms: number) => () => void } = {}): Promise<RealOwnerHarness> {
|
|
933
945
|
const root = mkdtempSync(join(tmpdir(), "desktop-rpc-agents-real-"));
|
|
934
946
|
t.after(() => rmSync(root, { recursive: true, force: true, maxRetries: 3, retryDelay: 50 }));
|
|
935
947
|
const home = join(root, "home");
|
|
@@ -1005,7 +1017,7 @@ async function realOwnerHarness(t: test.TestContext): Promise<RealOwnerHarness>
|
|
|
1005
1017
|
home,
|
|
1006
1018
|
agentHome,
|
|
1007
1019
|
env: { GENTLE_PI_CONFIG_HOME: configHome, PATH: process.env.PATH ?? "" },
|
|
1008
|
-
schedule: () => () => {},
|
|
1020
|
+
schedule: options.schedule ?? (() => () => {}),
|
|
1009
1021
|
now: () => 1000,
|
|
1010
1022
|
jobShell: () => { throw new Error("real-owner agents harness must not run jobs"); },
|
|
1011
1023
|
jobOutputDir: () => jobOutputDir,
|
|
@@ -1317,3 +1329,101 @@ test("probe: sinceVersion: equal returns [], other values return the window; in-
|
|
|
1317
1329
|
const higher: any = await b.handle("get_subagent_thread", { id: "t", sinceVersion: v + 100 });
|
|
1318
1330
|
assert.equal(higher.data.items.length, 1);
|
|
1319
1331
|
});
|
|
1332
|
+
|
|
1333
|
+
// ---- Progress (gentle-shell-gpui parity, T6) ----
|
|
1334
|
+
|
|
1335
|
+
function toolThread(name: string, running: boolean) {
|
|
1336
|
+
return { items: [{ kind: "tool" as const, callId: "c1", name, args: { command: "rm -rf /secret" }, output: "", running, isError: false }], dropped: 0, version: 1, limits: { maxItems: 400, maxOutputChars: 16000 } };
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
test("projectDesktopAgent carries turns, tool calls, and the running tool name, never its arguments", () => {
|
|
1340
|
+
const running = probeAgents.projectDesktopAgent(task("t1", "session-a", { status: TASK_STATUS.RUNNING, turns: 2, toolCalls: 3 }), toolThread("bash", true));
|
|
1341
|
+
assert.equal(running.turns, 2);
|
|
1342
|
+
assert.equal(running.toolCalls, 3);
|
|
1343
|
+
assert.equal(running.activeTool, "bash");
|
|
1344
|
+
assert.equal(JSON.stringify(running).includes("rm -rf"), false);
|
|
1345
|
+
assert.equal(probeAgents.projectDesktopAgent(task("t1", "session-a", { status: TASK_STATUS.RUNNING }), toolThread("bash", false)).activeTool, undefined, "a finished tool call is not active");
|
|
1346
|
+
assert.equal(probeAgents.projectDesktopAgent(task("t1", "session-a", { status: TASK_STATUS.RUNNING }), toolThread("not a name; rm", true)).activeTool, undefined, "only a plain identifier crosses");
|
|
1347
|
+
assert.equal(probeAgents.projectDesktopAgent(task("t1", "session-a", { status: TASK_STATUS.COMPLETED, endedAt: 2 }), toolThread("bash", true)).activeTool, undefined, "a finished task has no active tool");
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
test("parseDesktopAgentEntry accepts the progress fields and rejects malformed ones", () => {
|
|
1351
|
+
const base = probeAgents.projectDesktopAgent(task("t1", "session-a", { status: TASK_STATUS.RUNNING, turns: 1, toolCalls: 1 }), toolThread("read", true));
|
|
1352
|
+
assert.deepEqual(probeAgents.parseDesktopAgentEntry(base), base);
|
|
1353
|
+
for (const bad of [{ turns: -1 }, { toolCalls: 1.5 }, { activeTool: "two words" }, { activeTool: 7 }]) {
|
|
1354
|
+
assert.equal(probeAgents.parseDesktopAgentEntry({ ...base, ...bad }), undefined, JSON.stringify(bad));
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
test("the real owner pushes in-turn progress as one throttled agents_update with turns, tool calls, and the running tool", async (t) => {
|
|
1359
|
+
const owner = recordedScheduler();
|
|
1360
|
+
const h = await realOwnerHarness(t, { schedule: owner.schedule });
|
|
1361
|
+
await launchBackgroundTask(h);
|
|
1362
|
+
const scheduler = recordedScheduler();
|
|
1363
|
+
const bridge = new DesktopAgentsBridge(h.pi, { discover: async () => h.service, schedule: scheduler.schedule, coalesceMs: 10 });
|
|
1364
|
+
bridge.attach(h.ctx);
|
|
1365
|
+
const events: Array<{ event: string; data: Record<string, unknown> }> = [];
|
|
1366
|
+
bridge.wire((event, data) => events.push({ event, data }));
|
|
1367
|
+
await bridge.start();
|
|
1368
|
+
scheduler.flushAll();
|
|
1369
|
+
const before = events.length;
|
|
1370
|
+
|
|
1371
|
+
h.children[0]!.emit({ type: "turn_end" });
|
|
1372
|
+
h.children[0]!.emit({ type: "tool_execution_start", toolCallId: "c1", toolName: "bash", args: { command: "cat /secret/path" } });
|
|
1373
|
+
await tick();
|
|
1374
|
+
scheduler.flushAll();
|
|
1375
|
+
assert.equal(events.length, before, "progress waits for the owner's throttle");
|
|
1376
|
+
const throttles = owner.entries.filter((entry) => entry.ms === 500 && !entry.cancelled);
|
|
1377
|
+
assert.equal(throttles.length, 1, "two progress changes schedule one notification");
|
|
1378
|
+
|
|
1379
|
+
owner.flushAll();
|
|
1380
|
+
scheduler.flushAll();
|
|
1381
|
+
assert.equal(events.length, before + 1);
|
|
1382
|
+
const [agent] = (events.at(-1)!.data as { agents: DesktopAgentEntry[] }).agents;
|
|
1383
|
+
assert.equal(agent!.status, TASK_STATUS.RUNNING);
|
|
1384
|
+
assert.equal(agent!.turns, 1);
|
|
1385
|
+
assert.equal(agent!.toolCalls, 1);
|
|
1386
|
+
assert.equal(agent!.activeTool, "bash");
|
|
1387
|
+
assert.equal(JSON.stringify(events.at(-1)).includes("/secret/path"), false);
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
test("activeTool skips finished tool items and reports the most recent running one", () => {
|
|
1391
|
+
const thread = { items: [
|
|
1392
|
+
{ kind: "tool" as const, callId: "c1", name: "bash", args: {}, output: "", running: true, isError: false },
|
|
1393
|
+
{ kind: "tool" as const, callId: "c2", name: "read", args: {}, output: "", running: false, isError: false },
|
|
1394
|
+
], dropped: 0, version: 2, limits: { maxItems: 400, maxOutputChars: 16000 } };
|
|
1395
|
+
assert.equal(probeAgents.activeToolName(thread), "bash");
|
|
1396
|
+
});
|
|
1397
|
+
|
|
1398
|
+
/** Fire only the owner's pending progress throttle (500 ms), never its stall timers. */
|
|
1399
|
+
function flushProgress(owner: ReturnType<typeof recordedScheduler>): void {
|
|
1400
|
+
for (const entry of [...owner.entries]) {
|
|
1401
|
+
if (entry.cancelled || entry.ms !== 500) continue;
|
|
1402
|
+
entry.cancelled = true;
|
|
1403
|
+
entry.fn();
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
test("streamed text alone emits no agents_update", async (t) => {
|
|
1408
|
+
const owner = recordedScheduler();
|
|
1409
|
+
const h = await realOwnerHarness(t, { schedule: owner.schedule });
|
|
1410
|
+
await launchBackgroundTask(h);
|
|
1411
|
+
const scheduler = recordedScheduler();
|
|
1412
|
+
const bridge = new DesktopAgentsBridge(h.pi, { discover: async () => h.service, schedule: scheduler.schedule, coalesceMs: 10 });
|
|
1413
|
+
bridge.attach(h.ctx);
|
|
1414
|
+
const events: unknown[] = [];
|
|
1415
|
+
bridge.wire((_event, data) => events.push(data));
|
|
1416
|
+
await bridge.start();
|
|
1417
|
+
h.children[0]!.emit({ type: "turn_end" });
|
|
1418
|
+
// The first delta moves the step to `writing`, a real projected change.
|
|
1419
|
+
h.children[0]!.emit({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: "start" } });
|
|
1420
|
+
await tick();
|
|
1421
|
+
flushProgress(owner);
|
|
1422
|
+
scheduler.flushAll();
|
|
1423
|
+
const before = events.length;
|
|
1424
|
+
for (const delta of ["a", "b", "c"]) h.children[0]!.emit({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta } });
|
|
1425
|
+
await tick();
|
|
1426
|
+
flushProgress(owner);
|
|
1427
|
+
scheduler.flushAll();
|
|
1428
|
+
assert.equal(events.length, before, "text deltas change no projected field");
|
|
1429
|
+
});
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import desktopRpc from "../extensions/gentle-desktop-rpc.ts";
|
|
5
|
+
import { DESKTOP_RPC_SCHEMA } from "../lib/desktop-rpc.ts";
|
|
6
|
+
import {
|
|
7
|
+
AUTH_UNAVAILABLE,
|
|
8
|
+
DESKTOP_AUTH_EVENTS,
|
|
9
|
+
DESKTOP_AUTH_LIMITS,
|
|
10
|
+
DESKTOP_AUTH_METHODS,
|
|
11
|
+
INVALID_GET_AUTH_STATUS,
|
|
12
|
+
INVALID_RELOAD_CREDENTIALS,
|
|
13
|
+
RELOAD_FAILED,
|
|
14
|
+
projectAuthStatus,
|
|
15
|
+
} from "../lib/desktop-rpc-auth.ts";
|
|
16
|
+
import { INTERACTIVE_HOST_ENV } from "../lib/rpc-host.ts";
|
|
17
|
+
import { DesktopAuthBridge } from "../lib/desktop-auth-service.ts";
|
|
18
|
+
|
|
19
|
+
// get_auth_status / reload_credentials: which providers have credentials and of
|
|
20
|
+
// which kind, from Pi's model registry, through the real Desktop transport over
|
|
21
|
+
// a fake registry. The fake also exposes the secret-returning calls so the
|
|
22
|
+
// tests prove they are never used.
|
|
23
|
+
|
|
24
|
+
const SECRET = "sk-live-SECRET-VALUE";
|
|
25
|
+
|
|
26
|
+
function fakeRegistry(options: { configured?: Record<string, { source: string; oauth?: boolean; label?: string }>; refresh?: () => Promise<{ aborted: boolean; errors: Map<string, Error> }> } = {}) {
|
|
27
|
+
const configured = { ...(options.configured ?? {}) };
|
|
28
|
+
const calls = { refresh: [] as unknown[], secretReads: 0 };
|
|
29
|
+
const registry = {
|
|
30
|
+
getAll: () => [
|
|
31
|
+
{ provider: "openai-codex", id: "gpt-5.6-terra" },
|
|
32
|
+
{ provider: "anthropic", id: "claude-luna" },
|
|
33
|
+
{ provider: "anthropic", id: "claude-sol" },
|
|
34
|
+
{ provider: "C:\\evil\\path", id: "x" },
|
|
35
|
+
],
|
|
36
|
+
getProviderAuthStatus(provider: string) {
|
|
37
|
+
const entry = configured[provider];
|
|
38
|
+
return entry ? { configured: true, source: entry.source, label: entry.label ?? `~/.secret/${provider}` } : { configured: false };
|
|
39
|
+
},
|
|
40
|
+
getProviderDisplayName: (provider: string) => ({ "openai-codex": "OpenAI Codex", anthropic: "Anthropic" })[provider] ?? provider,
|
|
41
|
+
isUsingOAuth: (model: { provider: string }) => configured[model.provider]?.oauth === true,
|
|
42
|
+
async refresh(refreshOptions: unknown) {
|
|
43
|
+
calls.refresh.push(refreshOptions);
|
|
44
|
+
return options.refresh ? options.refresh() : { aborted: false, errors: new Map() };
|
|
45
|
+
},
|
|
46
|
+
getApiKeyForProvider() { calls.secretReads += 1; return SECRET; },
|
|
47
|
+
getProviderAuth() { calls.secretReads += 1; return { auth: { apiKey: SECRET } }; },
|
|
48
|
+
getApiKeyAndHeaders() { calls.secretReads += 1; return { apiKey: SECRET }; },
|
|
49
|
+
/** Test hook: another process signs in. */
|
|
50
|
+
signIn(provider: string, source: string, oauth = false) { configured[provider] = { source, oauth }; },
|
|
51
|
+
};
|
|
52
|
+
return { registry, calls };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function harness(t: test.TestContext, registry: unknown) {
|
|
56
|
+
const previous = process.env[INTERACTIVE_HOST_ENV];
|
|
57
|
+
process.env[INTERACTIVE_HOST_ENV] = "1";
|
|
58
|
+
t.after(() => {
|
|
59
|
+
if (previous === undefined) delete process.env[INTERACTIVE_HOST_ENV];
|
|
60
|
+
else process.env[INTERACTIVE_HOST_ENV] = previous;
|
|
61
|
+
});
|
|
62
|
+
const commands = new Map<string, { handler: (args: string, ctx: any) => Promise<void> }>();
|
|
63
|
+
const handlers = new Map<string, Array<(event: unknown, ctx: any) => unknown>>();
|
|
64
|
+
const pi = {
|
|
65
|
+
registerCommand(name: string, command: any) { commands.set(name, command); },
|
|
66
|
+
registerShortcut() {},
|
|
67
|
+
on(name: string, handler: any) { handlers.set(name, [...(handlers.get(name) ?? []), handler]); },
|
|
68
|
+
events: { on() { return () => {}; }, emit() {} },
|
|
69
|
+
} as unknown as ExtensionAPI;
|
|
70
|
+
desktopRpc(pi);
|
|
71
|
+
const widgets: string[] = [];
|
|
72
|
+
const ctx = {
|
|
73
|
+
mode: "rpc",
|
|
74
|
+
cwd: "/x",
|
|
75
|
+
modelRegistry: registry,
|
|
76
|
+
sessionManager: { getCwd: () => "/x", getSessionId: () => "s", getEntries: () => [] },
|
|
77
|
+
ui: { setWidget(_key: string, lines: string[]) { widgets.push(...lines); } },
|
|
78
|
+
};
|
|
79
|
+
for (const handler of handlers.get("session_start") ?? []) handler({}, ctx);
|
|
80
|
+
return {
|
|
81
|
+
widgets,
|
|
82
|
+
invoke(requestId: string, method: string, params: Record<string, unknown> = {}) {
|
|
83
|
+
return commands.get("gentle:desktop")!.handler(JSON.stringify({ schema: DESKTOP_RPC_SCHEMA, requestId, method, params }), ctx);
|
|
84
|
+
},
|
|
85
|
+
last() { return JSON.parse(widgets.at(-1)!); },
|
|
86
|
+
async shutdown() { for (const handler of handlers.get("session_shutdown") ?? []) await handler({}, ctx); },
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ---- Capabilities ----
|
|
91
|
+
|
|
92
|
+
test("the Desktop transport advertises both methods once and no new event", async (t) => {
|
|
93
|
+
assert.deepEqual([...DESKTOP_AUTH_METHODS], ["get_auth_status", "reload_credentials"]);
|
|
94
|
+
assert.deepEqual([...DESKTOP_AUTH_EVENTS], []);
|
|
95
|
+
const app = harness(t, fakeRegistry().registry);
|
|
96
|
+
await app.invoke("cap", "capabilities");
|
|
97
|
+
const data = app.last().data;
|
|
98
|
+
for (const method of DESKTOP_AUTH_METHODS) assert.equal(data.methods.filter((name: string) => name === method).length, 1);
|
|
99
|
+
assert.deepEqual(data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed", "profile_binding_changed"]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// ---- get_auth_status ----
|
|
103
|
+
|
|
104
|
+
test("get_auth_status lists providers with configured, type, and source, and never a credential, label, or secret call", async (t) => {
|
|
105
|
+
const fake = fakeRegistry({ configured: { anthropic: { source: "stored", oauth: true }, "openai-codex": { source: "models_json_command", label: "!op read secret" } } });
|
|
106
|
+
const app = harness(t, fake.registry);
|
|
107
|
+
await app.invoke("auth-1", "get_auth_status");
|
|
108
|
+
assert.deepEqual(app.last(), {
|
|
109
|
+
schema: DESKTOP_RPC_SCHEMA,
|
|
110
|
+
kind: "response",
|
|
111
|
+
requestId: "auth-1",
|
|
112
|
+
ok: true,
|
|
113
|
+
data: {
|
|
114
|
+
providers: [
|
|
115
|
+
{ provider: "anthropic", displayName: "Anthropic", configured: true, type: "oauth", source: "stored" },
|
|
116
|
+
{ provider: "openai-codex", displayName: "OpenAI Codex", configured: true, type: "api_key", source: "models_json" },
|
|
117
|
+
],
|
|
118
|
+
truncated: false,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const raw = app.widgets.at(-1)!;
|
|
122
|
+
for (const leak of [SECRET, "!op read", "~/.secret", "evil"]) assert.equal(raw.includes(leak), false, `no ${leak} on the wire`);
|
|
123
|
+
assert.equal(fake.calls.secretReads, 0, "no secret-returning registry call");
|
|
124
|
+
assert.deepEqual(fake.calls.refresh, [], "a read never refreshes");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("an unconfigured provider has no type and no source", async (t) => {
|
|
128
|
+
const app = harness(t, fakeRegistry().registry);
|
|
129
|
+
await app.invoke("auth-2", "get_auth_status");
|
|
130
|
+
assert.deepEqual(app.last().data.providers[0], { provider: "anthropic", displayName: "Anthropic", configured: false, type: null, source: null });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("get_auth_status rejects params and answers auth_unavailable without a registry", async (t) => {
|
|
134
|
+
const app = harness(t, fakeRegistry().registry);
|
|
135
|
+
await app.invoke("bad-1", "get_auth_status", { providers: ["anthropic"] });
|
|
136
|
+
assert.deepEqual(app.last().error, INVALID_GET_AUTH_STATUS);
|
|
137
|
+
const bare = harness(t, undefined);
|
|
138
|
+
await bare.invoke("none-1", "get_auth_status");
|
|
139
|
+
assert.deepEqual(bare.last().error, AUTH_UNAVAILABLE);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// ---- reload_credentials ----
|
|
143
|
+
|
|
144
|
+
test("reload_credentials refreshes the registry offline and answers the new state", async (t) => {
|
|
145
|
+
const fake = fakeRegistry();
|
|
146
|
+
const app = harness(t, fake.registry);
|
|
147
|
+
await app.invoke("before", "get_auth_status");
|
|
148
|
+
assert.equal(app.last().data.providers.find((row: { provider: string }) => row.provider === "anthropic").configured, false);
|
|
149
|
+
fake.registry.signIn("anthropic", "stored", true);
|
|
150
|
+
fake.registry.refresh = async (options: unknown) => { fake.calls.refresh.push(options); return { aborted: false, errors: new Map([["openai-codex", new Error("GET https://example.invalid/C:/Users/secret failed")]]) }; };
|
|
151
|
+
await app.invoke("reload-1", "reload_credentials");
|
|
152
|
+
const response = app.last();
|
|
153
|
+
assert.equal(response.ok, true);
|
|
154
|
+
assert.deepEqual(fake.calls.refresh, [{ allowNetwork: false }]);
|
|
155
|
+
assert.equal(response.data.reloaded, true);
|
|
156
|
+
assert.equal(response.data.aborted, false);
|
|
157
|
+
assert.deepEqual(response.data.failedProviders, ["openai-codex"]);
|
|
158
|
+
assert.deepEqual(response.data.providers.find((row: { provider: string }) => row.provider === "anthropic"), { provider: "anthropic", displayName: "Anthropic", configured: true, type: "oauth", source: "stored" });
|
|
159
|
+
assert.equal(app.widgets.at(-1)!.includes("example.invalid"), false, "refresh error text never crosses");
|
|
160
|
+
assert.equal(fake.calls.secretReads, 0);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("concurrent reloads share one refresh", async (t) => {
|
|
164
|
+
let release: () => void = () => {};
|
|
165
|
+
const fake = fakeRegistry({ refresh: () => new Promise((resolve) => { release = () => resolve({ aborted: false, errors: new Map() }); }) });
|
|
166
|
+
const app = harness(t, fake.registry);
|
|
167
|
+
const first = app.invoke("r-1", "reload_credentials");
|
|
168
|
+
const second = app.invoke("r-2", "reload_credentials");
|
|
169
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
170
|
+
release();
|
|
171
|
+
await Promise.all([first, second]);
|
|
172
|
+
assert.equal(fake.calls.refresh.length, 1);
|
|
173
|
+
assert.deepEqual(app.widgets.map((line) => JSON.parse(line).ok), [true, true]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("a failing refresh answers reload_failed without its message", async (t) => {
|
|
177
|
+
const app = harness(t, fakeRegistry({ refresh: () => Promise.reject(new Error("EACCES C:\\Users\\secret\\auth.json")) }).registry);
|
|
178
|
+
await app.invoke("r-fail", "reload_credentials");
|
|
179
|
+
assert.deepEqual(app.last().error, RELOAD_FAILED);
|
|
180
|
+
assert.equal(app.widgets.at(-1)!.includes("secret"), false);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("reload_credentials rejects params before refreshing", async (t) => {
|
|
184
|
+
const fake = fakeRegistry();
|
|
185
|
+
const app = harness(t, fake.registry);
|
|
186
|
+
await app.invoke("r-bad", "reload_credentials", { force: true });
|
|
187
|
+
assert.deepEqual(app.last().error, INVALID_RELOAD_CREDENTIALS);
|
|
188
|
+
assert.deepEqual(fake.calls.refresh, []);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// ---- Bounds ----
|
|
192
|
+
|
|
193
|
+
test("the projection bounds the provider list and skips ids that are not plain names", () => {
|
|
194
|
+
const models = Array.from({ length: DESKTOP_AUTH_LIMITS.providers + 5 }, (_, index) => ({ provider: `p${String(index).padStart(4, "0")}` }));
|
|
195
|
+
const result = projectAuthStatus({
|
|
196
|
+
getAll: () => [...models, { provider: "../etc" }, { provider: "a b" }],
|
|
197
|
+
getProviderAuthStatus: () => ({ configured: false }),
|
|
198
|
+
isUsingOAuth: () => false,
|
|
199
|
+
refresh: async () => ({ aborted: false, errors: new Map() }),
|
|
200
|
+
});
|
|
201
|
+
assert.equal(result.providers.length, DESKTOP_AUTH_LIMITS.providers);
|
|
202
|
+
assert.equal(result.truncated, true);
|
|
203
|
+
assert.equal(result.providers.some((row) => row.provider === "../etc" || row.provider === "a b"), false);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// ---- Independent verification follow-ups (L27) ----
|
|
207
|
+
|
|
208
|
+
test("a reset during a reload drops the answer", async (t) => {
|
|
209
|
+
let release: () => void = () => {};
|
|
210
|
+
const fake = fakeRegistry({ refresh: () => new Promise((resolve) => { release = () => resolve({ aborted: false, errors: new Map() }); }) });
|
|
211
|
+
const app = harness(t, fake.registry);
|
|
212
|
+
const pending = app.invoke("r-reset", "reload_credentials");
|
|
213
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
214
|
+
await app.shutdown();
|
|
215
|
+
release();
|
|
216
|
+
await pending;
|
|
217
|
+
assert.equal(app.widgets.some((line) => JSON.parse(line).ok === true), false);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("an environment label never crosses and repeated reads never refresh", async (t) => {
|
|
221
|
+
const fake = fakeRegistry({ configured: { anthropic: { source: "environment", label: "ANTHROPIC_API_KEY" } } });
|
|
222
|
+
const app = harness(t, fake.registry);
|
|
223
|
+
for (let i = 0; i < 3; i++) await app.invoke(`g${i}`, "get_auth_status");
|
|
224
|
+
assert.deepEqual(fake.calls.refresh, []);
|
|
225
|
+
assert.equal(app.widgets.some((line) => line.includes("ANTHROPIC_API_KEY")), false);
|
|
226
|
+
assert.deepEqual(app.last().data.providers[0], { provider: "anthropic", displayName: "Anthropic", configured: true, type: "api_key", source: "environment" });
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("an unknown source is null and a throwing display name falls back to the id", () => {
|
|
230
|
+
const result = projectAuthStatus({ getAll: () => [{ provider: "x" }], getProviderAuthStatus: () => ({ configured: true, source: "configured provider" }), getProviderDisplayName: () => { throw new Error("boom"); }, isUsingOAuth: () => false, refresh: async () => ({ aborted: false, errors: new Map() }) });
|
|
231
|
+
assert.deepEqual(result.providers, [{ provider: "x", displayName: "x", configured: true, type: "api_key", source: null }]);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// ---- Native review advisories (review-00bf531659b82903) ----
|
|
235
|
+
|
|
236
|
+
test("a completed reload with an unexpected result shape still answers the reloaded state", async (t) => {
|
|
237
|
+
for (const shape of [undefined, { aborted: true, errors: "not a map" }]) {
|
|
238
|
+
const fake = fakeRegistry({ refresh: async () => shape as never });
|
|
239
|
+
const app = harness(t, fake.registry);
|
|
240
|
+
await app.invoke("odd-shape", "reload_credentials");
|
|
241
|
+
const response = app.last();
|
|
242
|
+
assert.equal(response.ok, true, JSON.stringify(shape));
|
|
243
|
+
assert.equal(response.data.reloaded, true);
|
|
244
|
+
assert.equal(response.data.aborted, shape?.aborted === true);
|
|
245
|
+
assert.deepEqual(response.data.failedProviders, []);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("the bridge itself drops a reload answer when a reset lands mid-refresh", async () => {
|
|
250
|
+
let release: () => void = () => {};
|
|
251
|
+
const fake = fakeRegistry({ refresh: () => new Promise((resolve) => { release = () => resolve({ aborted: false, errors: new Map() }); }) });
|
|
252
|
+
const bridge = new DesktopAuthBridge();
|
|
253
|
+
bridge.attach({ modelRegistry: fake.registry } as never);
|
|
254
|
+
const pending = bridge.handle("reload_credentials", {});
|
|
255
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
256
|
+
bridge.reset();
|
|
257
|
+
bridge.attach({ modelRegistry: fake.registry } as never);
|
|
258
|
+
release();
|
|
259
|
+
assert.deepEqual(await pending, { ok: false, error: AUTH_UNAVAILABLE });
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// ---- Follow-ups (review-6198081762928a6d advisories, CodeRabbit on #3475) ----
|
|
263
|
+
|
|
264
|
+
test("an inherited property name as the auth source never crosses as a source", () => {
|
|
265
|
+
for (const source of ["constructor", "__proto__", "toString"]) {
|
|
266
|
+
const result = projectAuthStatus({ getAll: () => [{ provider: "x" }], getProviderAuthStatus: () => ({ configured: true, source }), isUsingOAuth: () => false, refresh: async () => ({ aborted: false, errors: new Map() }) });
|
|
267
|
+
assert.equal(result.providers[0]!.source, null, source);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test("get_auth_status answers auth_unavailable when the registry throws, without its message", async (t) => {
|
|
272
|
+
const fake = fakeRegistry();
|
|
273
|
+
fake.registry.getProviderAuthStatus = () => { throw new Error("C:\Users\secret\auth.json is locked"); };
|
|
274
|
+
const app = harness(t, fake.registry);
|
|
275
|
+
await app.invoke("throws", "get_auth_status");
|
|
276
|
+
assert.deepEqual(app.last().error, AUTH_UNAVAILABLE);
|
|
277
|
+
assert.equal(app.widgets.at(-1)!.includes("secret"), false);
|
|
278
|
+
});
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { test } from "node:test";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import desktopRpc from "../extensions/gentle-desktop-rpc.ts";
|
|
8
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
9
|
+
import { DESKTOP_RPC_SCHEMA } from "../lib/desktop-rpc.ts";
|
|
10
|
+
import {
|
|
11
|
+
BACKGROUND_SUBAGENTS_BUSY,
|
|
12
|
+
BACKGROUND_SUBAGENTS_UNAVAILABLE,
|
|
13
|
+
DESKTOP_BACKGROUND_SUBAGENTS_EVENTS,
|
|
14
|
+
DESKTOP_BACKGROUND_SUBAGENTS_METHODS,
|
|
15
|
+
DESKTOP_BACKGROUND_SUBAGENTS_SERVICE_CHANNEL,
|
|
16
|
+
DESKTOP_BACKGROUND_SUBAGENTS_SERVICE_SCHEMA,
|
|
17
|
+
INVALID_SET_BACKGROUND_SUBAGENTS,
|
|
18
|
+
type DesktopBackgroundSubagentsState,
|
|
19
|
+
} from "../lib/desktop-rpc-background-subagents.ts";
|
|
20
|
+
import { DesktopBackgroundSubagentsBridge } from "../lib/desktop-background-subagents-service.ts";
|
|
21
|
+
import { BACKGROUND_SUBAGENTS_FILE, BACKGROUND_SUBAGENTS_SCHEMA } from "../lib/background-subagents-policy.ts";
|
|
22
|
+
import { INTERACTIVE_HOST_ENV } from "../lib/rpc-host.ts";
|
|
23
|
+
|
|
24
|
+
// get/set_background_subagents: the `/gentle:background-subagents` policy read
|
|
25
|
+
// and written through its owner in `extensions/gentle-ai.ts`, with the same
|
|
26
|
+
// two-call confirmation as `set_review_mode`.
|
|
27
|
+
|
|
28
|
+
function bus() {
|
|
29
|
+
const listeners = new Map<string, Array<(payload: unknown) => void>>();
|
|
30
|
+
return {
|
|
31
|
+
on(channel: string, listener: (payload: unknown) => void) { listeners.set(channel, [...(listeners.get(channel) ?? []), listener]); return () => {}; },
|
|
32
|
+
emit(channel: string, payload: unknown) { for (const listener of listeners.get(channel) ?? []) listener(payload); },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The real owner over temporary config and project directories. */
|
|
37
|
+
function realOwner(t: test.TestContext, processEnv: NodeJS.ProcessEnv = {}) {
|
|
38
|
+
const root = mkdtempSync(join(tmpdir(), "desktop-rpc-bg-"));
|
|
39
|
+
const configHome = join(root, "config");
|
|
40
|
+
const cwd = join(root, "repo");
|
|
41
|
+
mkdirSync(configHome, { recursive: true });
|
|
42
|
+
mkdirSync(join(cwd, ".pi", "gentle-ai"), { recursive: true });
|
|
43
|
+
const saved = { config: process.env.GENTLE_PI_CONFIG_HOME, policy: process.env.GENTLE_PI_BACKGROUND_SUBAGENTS };
|
|
44
|
+
process.env.GENTLE_PI_CONFIG_HOME = configHome;
|
|
45
|
+
delete process.env.GENTLE_PI_BACKGROUND_SUBAGENTS;
|
|
46
|
+
t.after(() => {
|
|
47
|
+
if (saved.config === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
|
|
48
|
+
else process.env.GENTLE_PI_CONFIG_HOME = saved.config;
|
|
49
|
+
if (saved.policy !== undefined) process.env.GENTLE_PI_BACKGROUND_SUBAGENTS = saved.policy;
|
|
50
|
+
rmSync(root, { recursive: true, force: true });
|
|
51
|
+
});
|
|
52
|
+
const events = bus();
|
|
53
|
+
const pi = { on() {}, registerCommand() {}, registerTool() {}, getActiveTools: () => ["read", "subagent_run"], events } as unknown as ExtensionAPI;
|
|
54
|
+
createGentleAiExtension({ nativeReviewCli: null, processEnv: { GENTLE_AI_TELEMETRY: "0", ...processEnv } })(pi);
|
|
55
|
+
const bridge = new DesktopBackgroundSubagentsBridge(pi);
|
|
56
|
+
bridge.attach({ cwd, mode: "rpc", sessionManager: { getCwd: () => cwd } } as unknown as ExtensionContext);
|
|
57
|
+
return { bridge, globalFile: join(configHome, BACKGROUND_SUBAGENTS_FILE), projectFile: join(cwd, ".pi", "gentle-ai", BACKGROUND_SUBAGENTS_FILE) };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const DEFAULT_STATE: DesktopBackgroundSubagentsState = { effective: "off", source: "default", malformed: false, projectFile: "absent", globalFile: "absent", capability: "ready" };
|
|
61
|
+
|
|
62
|
+
async function token(bridge: DesktopBackgroundSubagentsBridge, policy: "on" | "off"): Promise<string> {
|
|
63
|
+
const outcome = await bridge.handle("set_background_subagents", { policy });
|
|
64
|
+
assert.ok(outcome?.ok);
|
|
65
|
+
return ((outcome.data as { confirmation: { token: string } }).confirmation).token;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---- Capabilities ----
|
|
69
|
+
|
|
70
|
+
test("the Desktop transport advertises both methods once and no new event", async (t) => {
|
|
71
|
+
assert.deepEqual([...DESKTOP_BACKGROUND_SUBAGENTS_METHODS], ["get_background_subagents", "set_background_subagents"]);
|
|
72
|
+
assert.deepEqual([...DESKTOP_BACKGROUND_SUBAGENTS_EVENTS], []);
|
|
73
|
+
const previous = process.env[INTERACTIVE_HOST_ENV];
|
|
74
|
+
process.env[INTERACTIVE_HOST_ENV] = "1";
|
|
75
|
+
t.after(() => {
|
|
76
|
+
if (previous === undefined) delete process.env[INTERACTIVE_HOST_ENV];
|
|
77
|
+
else process.env[INTERACTIVE_HOST_ENV] = previous;
|
|
78
|
+
});
|
|
79
|
+
const commands = new Map<string, { handler: (args: string, ctx: any) => Promise<void> }>();
|
|
80
|
+
const handlers = new Map<string, Array<(event: unknown, ctx: any) => unknown>>();
|
|
81
|
+
const pi = {
|
|
82
|
+
registerCommand(name: string, command: any) { commands.set(name, command); },
|
|
83
|
+
registerShortcut() {},
|
|
84
|
+
on(name: string, handler: any) { handlers.set(name, [...(handlers.get(name) ?? []), handler]); },
|
|
85
|
+
events: { on() { return () => {}; }, emit() {} },
|
|
86
|
+
} as unknown as ExtensionAPI;
|
|
87
|
+
desktopRpc(pi);
|
|
88
|
+
const widgets: string[] = [];
|
|
89
|
+
const host = { mode: "rpc", cwd: "/x", sessionManager: { getCwd: () => "/x", getSessionId: () => "s", getEntries: () => [] }, ui: { setWidget(_k: string, lines: string[]) { widgets.push(...lines); } } };
|
|
90
|
+
for (const handler of handlers.get("session_start") ?? []) handler({}, host);
|
|
91
|
+
await commands.get("gentle:desktop")!.handler(JSON.stringify({ schema: DESKTOP_RPC_SCHEMA, requestId: "cap", method: "capabilities", params: {} }), host);
|
|
92
|
+
const data = JSON.parse(widgets.at(-1)!).data;
|
|
93
|
+
for (const method of DESKTOP_BACKGROUND_SUBAGENTS_METHODS) assert.equal(data.methods.filter((name: string) => name === method).length, 1);
|
|
94
|
+
assert.deepEqual(data.events, ["config_changed", "permission_mode_changed", "rate_limit", "design_canvas", "jobs_update", "profile_applied", "agents_update", "review_mode_changed", "profile_binding_changed"]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// ---- The real owner ----
|
|
98
|
+
|
|
99
|
+
test("get_background_subagents reads the owner's resolution without paths", async (t) => {
|
|
100
|
+
const owner = realOwner(t);
|
|
101
|
+
assert.deepEqual(await owner.bridge.handle("get_background_subagents", {}), { ok: true, data: DEFAULT_STATE });
|
|
102
|
+
writeFileSync(owner.projectFile, "{ broken");
|
|
103
|
+
assert.deepEqual(await owner.bridge.handle("get_background_subagents", {}), { ok: true, data: { ...DEFAULT_STATE, source: "project", malformed: true, projectFile: "present" } });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("set_background_subagents asks first, writes the global file only with the shown token, and answers the re-read", async (t) => {
|
|
107
|
+
const owner = realOwner(t);
|
|
108
|
+
const first = await owner.bridge.handle("set_background_subagents", { policy: "on" });
|
|
109
|
+
assert.ok(first?.ok);
|
|
110
|
+
const asked = first.data as { status: string; policy: string; state: unknown; confirmation: { title: string; message: string; token: string } };
|
|
111
|
+
assert.equal(asked.status, "confirmation_required");
|
|
112
|
+
assert.deepEqual(asked.state, DEFAULT_STATE);
|
|
113
|
+
assert.equal(asked.confirmation.title, "Turn background subagents on machine-wide?");
|
|
114
|
+
assert.match(asked.confirmation.token, /^[0-9a-f]{64}$/);
|
|
115
|
+
assert.equal(existsSync(owner.globalFile), false, "asking never writes");
|
|
116
|
+
|
|
117
|
+
const applied = await owner.bridge.handle("set_background_subagents", { policy: "on", confirmationToken: asked.confirmation.token });
|
|
118
|
+
assert.deepEqual(applied, { ok: true, data: { status: "applied", policy: "on", changed: true, state: { ...DEFAULT_STATE, effective: "on", source: "global", globalFile: "present" } } });
|
|
119
|
+
assert.deepEqual(JSON.parse(readFileSync(owner.globalFile, "utf8")), { schema: BACKGROUND_SUBAGENTS_SCHEMA, policy: "on" });
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("a token shown before the state changed asks again and writes nothing", async (t) => {
|
|
123
|
+
const owner = realOwner(t);
|
|
124
|
+
const stale = await token(owner.bridge, "on");
|
|
125
|
+
writeFileSync(owner.projectFile, JSON.stringify({ schema: BACKGROUND_SUBAGENTS_SCHEMA, policy: "off" }));
|
|
126
|
+
const outcome = await owner.bridge.handle("set_background_subagents", { policy: "on", confirmationToken: stale });
|
|
127
|
+
assert.ok(outcome?.ok);
|
|
128
|
+
const data = outcome.data as { status: string; confirmation: { message: string } };
|
|
129
|
+
assert.equal(data.status, "confirmation_required");
|
|
130
|
+
assert.match(data.confirmation.message, /this project's file decides here/);
|
|
131
|
+
assert.equal(existsSync(owner.globalFile), false);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("a write a project file outranks reports the unchanged effective policy", async (t) => {
|
|
135
|
+
const owner = realOwner(t);
|
|
136
|
+
writeFileSync(owner.projectFile, JSON.stringify({ schema: BACKGROUND_SUBAGENTS_SCHEMA, policy: "off" }));
|
|
137
|
+
const outcome = await owner.bridge.handle("set_background_subagents", { policy: "on", confirmationToken: await token(owner.bridge, "on") });
|
|
138
|
+
assert.deepEqual(outcome, { ok: true, data: { status: "applied", policy: "on", changed: true, state: { ...DEFAULT_STATE, source: "project", projectFile: "present", globalFile: "present" } } });
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("malformed set params are rejected before the owner and write nothing", async (t) => {
|
|
142
|
+
const owner = realOwner(t);
|
|
143
|
+
for (const params of [{}, { policy: "yes" }, { policy: "on", scope: "project" }, { policy: "on", confirmationToken: "" }, { policy: "on", confirmationToken: 7 }]) {
|
|
144
|
+
assert.deepEqual(await owner.bridge.handle("set_background_subagents", params), { ok: false, error: INVALID_SET_BACKGROUND_SUBAGENTS });
|
|
145
|
+
}
|
|
146
|
+
assert.equal(existsSync(owner.globalFile), false);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("a subagent process never answers the owner channel", async (t) => {
|
|
150
|
+
const owner = realOwner(t, { GENTLE_PI_AGENTS_CHILD: "1" });
|
|
151
|
+
assert.deepEqual(await owner.bridge.handle("get_background_subagents", {}), { ok: false, error: BACKGROUND_SUBAGENTS_UNAVAILABLE });
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// ---- Gate ----
|
|
155
|
+
|
|
156
|
+
test("a second change while one is pending answers background_subagents_busy", async () => {
|
|
157
|
+
const events = bus();
|
|
158
|
+
let release: () => void = () => {};
|
|
159
|
+
events.on(DESKTOP_BACKGROUND_SUBAGENTS_SERVICE_CHANNEL, (payload) => {
|
|
160
|
+
(payload as { respond(service: unknown): void }).respond({
|
|
161
|
+
schema: DESKTOP_BACKGROUND_SUBAGENTS_SERVICE_SCHEMA,
|
|
162
|
+
read: () => new Promise((resolve) => { release = () => resolve({ kind: "status", state: DEFAULT_STATE }); }),
|
|
163
|
+
write: async () => ({ kind: "failed" }),
|
|
164
|
+
dispose() {},
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
const bridge = new DesktopBackgroundSubagentsBridge({ events } as unknown as ExtensionAPI);
|
|
168
|
+
bridge.attach({ cwd: "/x" } as unknown as ExtensionContext);
|
|
169
|
+
const first = bridge.handle("set_background_subagents", { policy: "on" });
|
|
170
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
171
|
+
assert.deepEqual(await bridge.handle("set_background_subagents", { policy: "off" }), { ok: false, error: BACKGROUND_SUBAGENTS_BUSY });
|
|
172
|
+
release();
|
|
173
|
+
const settled = await first;
|
|
174
|
+
assert.ok(settled?.ok);
|
|
175
|
+
assert.equal((settled.data as { status: string }).status, "confirmation_required");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("a change dispatched before a session reset is refused and writes nothing", async (t) => {
|
|
179
|
+
const owner = realOwner(t);
|
|
180
|
+
const dispatched = owner.bridge.dispatchGeneration();
|
|
181
|
+
const shown = await token(owner.bridge, "on");
|
|
182
|
+
owner.bridge.reset();
|
|
183
|
+
owner.bridge.attach({ cwd: "/replacement" } as unknown as ExtensionContext);
|
|
184
|
+
assert.deepEqual(await owner.bridge.handle("set_background_subagents", { policy: "on", confirmationToken: shown }, dispatched), { ok: false, error: BACKGROUND_SUBAGENTS_UNAVAILABLE });
|
|
185
|
+
assert.equal(existsSync(owner.globalFile), false);
|
|
186
|
+
});
|