gentle-pi 4.7.0 → 4.9.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 +115 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +14 -13
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -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 +476 -0
- package/assets/design-canvas/canvas-boot.js +219 -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 +397 -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 +219 -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 +351 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +167 -0
- package/assets/design-canvas/canvas-theme.js +69 -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 +773 -17
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +120 -36
- package/assets/design-canvas/inspector.js +574 -21
- package/assets/design-canvas/theme-early.js +10 -0
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +30 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +5 -9
- package/assets/orchestrator-full-delegation-card.md +11 -16
- package/assets/orchestrator-full-delegation.md +9 -9
- package/assets/orchestrator-memory.md +4 -4
- package/assets/orchestrator-prompts.md +3 -31
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +13 -17
- package/assets/orchestrator-verification.md +12 -10
- package/assets/orchestrator-writer.md +13 -13
- package/assets/orchestrator.md +20 -24
- package/bin/gentle-shell.mjs +205 -10
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/orchestration/pi.md +2 -1
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/routing/pi.md +16 -16
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/assets/features/gentle-tower.png +0 -0
- package/docs/auto-permission-answers.md +1 -1
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +23 -5
- package/docs/desktop-feed.md +303 -0
- package/docs/desktop-rpc.md +1931 -0
- package/docs/fast-mode.md +2 -2
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell-desktop.md +465 -0
- package/docs/gentle-shell.md +102 -17
- package/docs/images/desktop/chat.png +0 -0
- package/docs/images/desktop/palette.png +0 -0
- package/docs/images/desktop/todo.png +0 -0
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +113 -32
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +19 -6
- package/extensions/ask-user-choice.ts +36 -18
- package/extensions/ask-user-question.ts +48 -9
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +436 -66
- package/extensions/gentle-ai.ts +809 -158
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-feed.ts +778 -0
- package/extensions/gentle-desktop-rpc.ts +276 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-herdr-desktop-status.ts +275 -0
- package/extensions/gentle-shell.ts +174 -59
- package/extensions/gentle-stats.ts +30 -1
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/gentle-tower.ts +305 -0
- package/extensions/skill-registry.ts +260 -225
- package/herdr/RECIPE.md +157 -0
- package/herdr/keys.json +14 -0
- package/herdr/layouts/gentle-shell.json +202 -0
- package/herdr/mods/gentle-agents/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-agents/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-agents/main.js +190 -0
- package/herdr/mods/gentle-agents/mod.json +1 -0
- package/herdr/mods/gentle-agents/snapshot.js +469 -0
- package/herdr/mods/gentle-agents/tokens.js +273 -0
- package/herdr/mods/gentle-chat/MINIMAL.md +69 -0
- package/herdr/mods/gentle-chat/actions.js +180 -0
- package/herdr/mods/gentle-chat/feed.js +321 -0
- package/herdr/mods/gentle-chat/icons/branch.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chat.svg +1 -0
- package/herdr/mods/gentle-chat/icons/check.svg +1 -0
- package/herdr/mods/gentle-chat/icons/chev.svg +1 -0
- package/herdr/mods/gentle-chat/icons/clip.svg +1 -0
- package/herdr/mods/gentle-chat/icons/down.svg +1 -0
- package/herdr/mods/gentle-chat/icons/folder.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-chat/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-chat/icons/mark.svg +1 -0
- package/herdr/mods/gentle-chat/icons/send.svg +1 -0
- package/herdr/mods/gentle-chat/icons/shield.svg +1 -0
- package/herdr/mods/gentle-chat/icons/stop.svg +1 -0
- package/herdr/mods/gentle-chat/icons/term.svg +1 -0
- package/herdr/mods/gentle-chat/icons/user.svg +1 -0
- package/herdr/mods/gentle-chat/icons/x.svg +1 -0
- package/herdr/mods/gentle-chat/main.js +968 -0
- package/herdr/mods/gentle-chat/mod.json +1 -0
- package/herdr/mods/gentle-chat/session.js +212 -0
- package/herdr/mods/gentle-chat/snapshot.js +469 -0
- package/herdr/mods/gentle-chat/tokens.js +137 -0
- package/herdr/mods/gentle-chat/ui.js +883 -0
- package/herdr/mods/gentle-confirm/main.js +60 -0
- package/herdr/mods/gentle-confirm/mod.json +1 -0
- package/herdr/mods/gentle-inspector/actions.js +180 -0
- package/herdr/mods/gentle-inspector/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/bot.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/check.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/db.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/diff.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/plug.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/review.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stats.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/stop.svg +1 -0
- package/herdr/mods/gentle-inspector/icons/todo.svg +1 -0
- package/herdr/mods/gentle-inspector/main.js +500 -0
- package/herdr/mods/gentle-inspector/mod.json +1 -0
- package/herdr/mods/gentle-inspector/snapshot.js +469 -0
- package/herdr/mods/gentle-inspector/tokens.js +273 -0
- package/herdr/mods/gentle-palette/actions.js +180 -0
- package/herdr/mods/gentle-palette/icons/bolt.svg +1 -0
- package/herdr/mods/gentle-palette/icons/bot.svg +1 -0
- package/herdr/mods/gentle-palette/icons/chat.svg +1 -0
- package/herdr/mods/gentle-palette/icons/check.svg +1 -0
- package/herdr/mods/gentle-palette/icons/cmd.svg +1 -0
- package/herdr/mods/gentle-palette/icons/diff.svg +1 -0
- package/herdr/mods/gentle-palette/icons/jobs.svg +1 -0
- package/herdr/mods/gentle-palette/icons/plus.svg +1 -0
- package/herdr/mods/gentle-palette/icons/review.svg +1 -0
- package/herdr/mods/gentle-palette/icons/search.svg +1 -0
- package/herdr/mods/gentle-palette/icons/shield.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stats.svg +1 -0
- package/herdr/mods/gentle-palette/icons/stop.svg +1 -0
- package/herdr/mods/gentle-palette/icons/term.svg +1 -0
- package/herdr/mods/gentle-palette/icons/todo.svg +1 -0
- package/herdr/mods/gentle-palette/main.js +333 -0
- package/herdr/mods/gentle-palette/mod.json +1 -0
- package/herdr/mods/gentle-palette/snapshot.js +469 -0
- package/herdr/mods/gentle-palette/tokens.js +273 -0
- package/herdr/mods/gentle-pane/icons/chat.svg +1 -0
- package/herdr/mods/gentle-pane/icons/close.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-pane/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-down.svg +1 -0
- package/herdr/mods/gentle-pane/icons/split-right.svg +1 -0
- package/herdr/mods/gentle-pane/icons/term.svg +1 -0
- package/herdr/mods/gentle-pane/icons/unzoom.svg +1 -0
- package/herdr/mods/gentle-pane/icons/zoom.svg +1 -0
- package/herdr/mods/gentle-pane/main.js +91 -0
- package/herdr/mods/gentle-pane/mod.json +1 -0
- package/herdr/mods/gentle-pane/snapshot.js +469 -0
- package/herdr/mods/gentle-pane/tokens.js +273 -0
- package/herdr/mods/gentle-sidebar/actions.js +180 -0
- package/herdr/mods/gentle-sidebar/icons/gear.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/mark.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/refresh.svg +1 -0
- package/herdr/mods/gentle-sidebar/icons/server-plus.svg +1 -0
- package/herdr/mods/gentle-sidebar/main.js +171 -0
- package/herdr/mods/gentle-sidebar/mod.json +1 -0
- package/herdr/mods/gentle-sidebar/snapshot.js +469 -0
- package/herdr/mods/gentle-sidebar/tokens.js +273 -0
- package/herdr/mods/gentle-spaces/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/monitor.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/plus.svg +1 -0
- package/herdr/mods/gentle-spaces/icons/server.svg +1 -0
- package/herdr/mods/gentle-spaces/machines.js +31 -0
- package/herdr/mods/gentle-spaces/main.js +299 -0
- package/herdr/mods/gentle-spaces/mod.json +1 -0
- package/herdr/mods/gentle-spaces/snapshot.js +469 -0
- package/herdr/mods/gentle-spaces/tokens.js +273 -0
- package/herdr/mods/gentle-status/actions.js +180 -0
- package/herdr/mods/gentle-status/main.js +192 -0
- package/herdr/mods/gentle-status/mod.json +1 -0
- package/herdr/mods/gentle-status/snapshot.js +469 -0
- package/herdr/mods/gentle-status/tokens.js +273 -0
- package/herdr/mods/gentle-tabs/icons/close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-herdr.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-remote.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/kind-tui.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/plus.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-close.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-max.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-min.svg +1 -0
- package/herdr/mods/gentle-tabs/icons/win-restore.svg +1 -0
- package/herdr/mods/gentle-tabs/main.js +171 -0
- package/herdr/mods/gentle-tabs/mod.json +1 -0
- package/herdr/mods/gentle-tabs/snapshot.js +469 -0
- package/herdr/mods/gentle-tabs/tokens.js +273 -0
- package/herdr/mods/gentle-tokens/main.js +20 -0
- package/herdr/mods/gentle-tokens/mod.json +1 -0
- package/herdr/mods/gentle-tokens/snapshot.js +469 -0
- package/herdr/mods/gentle-tokens/tokens.js +273 -0
- package/herdr/preview.png +0 -0
- package/herdr/themes/gentle-shell-dark.json +33 -0
- package/herdr/themes/gentle-shell-light.json +34 -0
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +17 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-rpc-publisher.ts +39 -12
- package/lib/agents-runner.ts +92 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-answers.ts +2 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/background-jobs.ts +22 -2
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/change-diff.ts +104 -0
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/commit-slice-signal.ts +1 -1
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +38 -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 +315 -0
- package/lib/desktop-changes-service.ts +171 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-feed-actions.ts +804 -0
- package/lib/desktop-feed-answers.ts +129 -0
- package/lib/desktop-feed-sources.ts +184 -0
- package/lib/desktop-feed-stats.ts +98 -0
- package/lib/desktop-feed-store.ts +124 -0
- package/lib/desktop-feed.ts +788 -0
- package/lib/desktop-jobs-service.ts +290 -0
- package/lib/desktop-review-service.ts +187 -0
- package/lib/desktop-rpc-agents.ts +403 -0
- package/lib/desktop-rpc-changes.ts +223 -0
- package/lib/desktop-rpc-config-watch.ts +285 -0
- package/lib/desktop-rpc-config.ts +885 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +290 -0
- package/lib/desktop-rpc-permissions.ts +328 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-review.ts +180 -0
- package/lib/desktop-rpc-session.ts +203 -0
- package/lib/desktop-rpc-sessions.ts +250 -0
- package/lib/desktop-rpc-stats.ts +187 -0
- package/lib/desktop-rpc-updates.ts +143 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +336 -0
- package/lib/desktop-session-service.ts +223 -0
- package/lib/desktop-sessions-service.ts +249 -0
- package/lib/desktop-stats-service.ts +142 -0
- package/lib/desktop-updates-service.ts +268 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/gentle-shell-desktop.ts +1370 -0
- package/lib/gentle-shell-launcher.ts +45 -3
- package/lib/herdr-desktop-events.ts +40 -0
- package/lib/herdr-desktop-status.ts +229 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/jobs-sidebar-state.ts +5 -0
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +86 -4
- package/lib/openai-fast-tier.ts +1 -0
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +13 -5
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/stats-collector.ts +56 -27
- package/lib/tower-actions.ts +100 -0
- package/lib/tower-hub.ts +73 -0
- package/lib/tower-launch.ts +111 -0
- package/lib/tower-open.ts +99 -0
- package/lib/tower-presence.ts +70 -0
- package/lib/tower-server.ts +234 -0
- package/lib/tower-snapshot.ts +298 -0
- package/lib/update-status.ts +238 -0
- package/lib/verifier-settle-reminder.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +14 -5
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +39 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/gentle-shell-desktop.mjs +1371 -0
- package/runtime/gentle-shell-launcher.mjs +44 -2
- package/runtime/native-review-cli.mjs +86 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/runtime/tower-actions.mjs +101 -0
- package/runtime/tower-hub.mjs +74 -0
- package/runtime/tower-launch.mjs +112 -0
- package/runtime/tower-open.mjs +100 -0
- package/runtime/tower-presence.mjs +71 -0
- package/runtime/tower-server.mjs +234 -0
- package/runtime/tower-snapshot.mjs +299 -0
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +5 -21
- package/scripts/build-runtime-modules.mjs +10 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +61 -20
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/provider-defect-report/SKILL.md +61 -0
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -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 +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- 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 +26 -7
- 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 +78 -21
- package/tests/ask-user-question.test.ts +61 -6
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-answers.test.ts +12 -1
- package/tests/background-jobs.test.ts +12 -0
- package/tests/bounded-stop-contract.test.ts +148 -27
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/change-diff.test.ts +75 -0
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/commit-slice-signal.test.ts +3 -2
- package/tests/decision-routing-contract.test.ts +390 -0
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- package/tests/delegated-key-learnings-contract.test.ts +21 -28
- package/tests/delivery-b-rendered-surfaces.test.ts +32 -0
- 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 -878
- 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 +528 -0
- package/tests/design-canvas-inspector.test.ts +1004 -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 +91 -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 +189 -0
- package/tests/design-canvas-theme.test.ts +198 -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-feed-actions-guards.test.ts +595 -0
- package/tests/desktop-feed-actions.test.ts +761 -0
- package/tests/desktop-feed-live-work.test.ts +209 -0
- package/tests/desktop-feed-performance.test.ts +369 -0
- package/tests/desktop-feed-plan-profiles.test.ts +509 -0
- package/tests/desktop-feed-send-prompt.test.ts +303 -0
- package/tests/desktop-feed-tool-summaries.test.ts +69 -0
- package/tests/desktop-feed.test.ts +615 -0
- package/tests/desktop-rpc-agents.test.ts +1319 -0
- package/tests/desktop-rpc-changes.test.ts +608 -0
- package/tests/desktop-rpc-config-watch.test.ts +1159 -0
- package/tests/desktop-rpc-config.test.ts +1462 -0
- package/tests/desktop-rpc-design.test.ts +672 -0
- package/tests/desktop-rpc-jobs.test.ts +1193 -0
- package/tests/desktop-rpc-permissions.test.ts +321 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-review.test.ts +678 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-session.test.ts +642 -0
- package/tests/desktop-rpc-sessions.test.ts +647 -0
- package/tests/desktop-rpc-stats.test.ts +431 -0
- package/tests/desktop-rpc-updates.test.ts +525 -0
- package/tests/desktop-rpc-usage.test.ts +707 -0
- package/tests/desktop-rpc.test.ts +293 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -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 +30 -41
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/replay.ts +4 -1
- package/tests/full-delegation-closure.test.ts +48 -0
- package/tests/gentle-agents.test.ts +848 -8
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +195 -21
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-fast.test.ts +15 -0
- package/tests/gentle-herdr-desktop-status.test.ts +595 -0
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-desktop-bin.test.ts +125 -0
- package/tests/gentle-shell-desktop.test.ts +927 -0
- package/tests/gentle-shell-launcher-tower.test.ts +104 -0
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +121 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/gentle-tower.test.ts +578 -0
- package/tests/herdr-desktop-status.test.ts +285 -0
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +35 -9
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +181 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +907 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +19 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- 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 +33 -15
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +10 -0
- package/tests/odd-routing-contract.test.ts +99 -31
- package/tests/orchestrator-budget.test.ts +32 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +12 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +249 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +15 -14
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- 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-routing-measured-values.test.ts +24 -0
- package/tests/pi-update-launcher.test.ts +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- 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 +25 -0
- package/tests/profile-fast-tier.test.ts +66 -1
- package/tests/provider-defect-handoff.test.ts +124 -99
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- 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 +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +2 -1
- package/tests/review-controller.test.ts +2 -1
- 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.test.ts +271 -4
- 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 +27 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- 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-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/sensitive-path-tools.test.ts +138 -4
- package/tests/session-profile-extension.test.ts +312 -18
- package/tests/session-profile-freeze.test.ts +26 -0
- package/tests/session-profile-v1-compat.test.ts +20 -0
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-collision-prefixes.test.ts +1 -0
- package/tests/skill-contradictions-contract.test.ts +124 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +983 -306
- package/tests/stats-collector.test.ts +109 -2
- package/tests/support/design-canvas-dom.ts +386 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +49 -14
- 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/tower-actions.test.ts +247 -0
- package/tests/tower-artifacts.test.ts +114 -0
- package/tests/tower-open.test.ts +97 -0
- package/tests/tower-presence.test.ts +175 -0
- package/tests/tower-server.test.ts +122 -0
- package/tests/tower-snapshot.test.ts +236 -0
- package/tests/tower-web-echo.test.ts +125 -0
- package/tests/tower-web-hover.test.ts +251 -0
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-scoped-stop-contract.test.ts +32 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verifier-settle-reminder.test.ts +2 -2
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +88 -12
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +136 -27
- 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 +184 -0
- package/tests/writer-rejection-next-step.test.ts +55 -0
- package/tests/writer-surface-authority-contract.test.ts +158 -0
- package/tests/yolo-mode.test.ts +39 -0
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.6.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -22,8 +22,10 @@ import { join, resolve, isAbsolute } from "node:path";
|
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
import { createLocalBashOperations, keyHint, SettingsManager, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
24
24
|
import { createJobRegistry, isStandaloneSleep, type JobExecOperations, type JobRecord } from "../lib/background-jobs.ts";
|
|
25
|
-
import { JOB_GLYPH, JOB_NOTICE_TYPE, jobDetails, jobNoticeText, monitorEventsText, monitorStoppedText, registerBackgroundJobTools } from "../lib/background-jobs-tools.ts";
|
|
25
|
+
import { JOB_GLYPH, JOB_NOTICE_TYPE, jobDetails, jobNoticeText, monitorEventsText, monitorStoppedText, registerBackgroundJobTools, type BackgroundJobsChange } from "../lib/background-jobs-tools.ts";
|
|
26
26
|
import { createMonitorController, mergeMonitorBatches, type MonitorNotice } from "../lib/background-monitor.ts";
|
|
27
|
+
import { DESKTOP_JOBS_SERVICE_CHANNEL, DESKTOP_JOBS_SERVICE_SCHEMA, projectDesktopJob, projectDesktopJobOutput, selectDesktopJobs, type DesktopJobsCancelOutcome, type DesktopJobsOutputOutcome, type DesktopJobsOwnerRead, type DesktopJobsService } from "../lib/desktop-rpc-jobs.ts";
|
|
28
|
+
import { DESKTOP_AGENTS_SERVICE_CHANNEL, DESKTOP_AGENTS_SERVICE_SCHEMA, accumulateTaskUsage, projectDesktopAgent, projectDesktopAgentThread, selectDesktopAgents, type DesktopAgentsCancelOutcome, type DesktopAgentsOwnerRead, type DesktopAgentsService, type DesktopAgentsThreadOutcome } from "../lib/desktop-rpc-agents.ts";
|
|
27
29
|
import { JobsView } from "../lib/jobs-view.ts";
|
|
28
30
|
import { JOBS_FINISHED_TTL_MS } from "../lib/jobs-widget.ts";
|
|
29
31
|
import { JOBS_SIDEBAR_EVENT, JOBS_STATUS_KEY } from "../lib/jobs-sidebar-state.ts";
|
|
@@ -34,6 +36,7 @@ import { NativePointerRegion } from "../lib/native-pointer-region.ts";
|
|
|
34
36
|
import { resolveVisualSettings } from "../lib/visual-customization-policy.ts";
|
|
35
37
|
import { createCompletionQueue } from "../lib/agents-completion-delivery.ts";
|
|
36
38
|
import { createAgentMessageQueue, type PendingAgentMessage } from "../lib/agents-message-delivery.ts";
|
|
39
|
+
import { capReport, withReportCap } from "../lib/agents-report-cap.ts";
|
|
37
40
|
import { parseModelRef, AGENT_MODE, PROFILE_SOURCE, PROVIDER_REVIEW_ROLES, discoverAgents, formatModelRef, loadAgentsConfig, resolveAgentProfile, unmatchedProfileKeys, withPinnedModelProfiles, type AgentDefinition, type AgentMode, type ProfileSource } from "../lib/agents-config.ts";
|
|
38
41
|
import { freezeSessionProfileAtStartup, inheritedProfileDriftNotice, resolveSessionProfile, sessionProfileRoutingAt, type InheritedProfileOptions, type SessionProfileResolution } from "../lib/session-profile-freeze.ts";
|
|
39
42
|
import { resolveProfilePin, resolveUnversionedProjectProfile } from "../lib/agent-profile-pin.ts";
|
|
@@ -43,7 +46,7 @@ import { installBackgroundCacheWarming } from "../lib/background-cache-warming.t
|
|
|
43
46
|
import { isFinished, MISSING_TOOLS_NOTE_PREFIX, TASK_EVENT, TASK_STATUS, TaskStore, type AskRequest, type TaskRecord } from "../lib/agents-protocol.ts";
|
|
44
47
|
import { AgentRunner, piCommand, abortReasonText, CHILD_JOBS_ENV, REQUESTED_TOOLS_ENV, type AskAnswer, type RunnerDeps, type TaskRequest } from "../lib/agents-runner.ts";
|
|
45
48
|
import { parseChildPackageInjection } from "../lib/child-package-injection.ts";
|
|
46
|
-
import { ChildMessenger, formatChildJobState, type IpcEndpoint } from "../lib/agents-messaging.ts";
|
|
49
|
+
import { CHILD_MESSAGE_MAX_BYTES, ChildMessenger, formatChildJobState, type IpcEndpoint } from "../lib/agents-messaging.ts";
|
|
47
50
|
import { ActiveSessionClient, ActiveSessionListener, SessionPresenceError, SessionPresenceRegistry, type PresenceRecord, type ReceivedNotification, type SentNotification, type SessionPresenceCandidate } from "../lib/agents-session-transport.ts";
|
|
48
51
|
import { WindowsActiveSessionClient, WindowsActiveSessionListener, WindowsSessionPresenceRegistry, WindowsSessionRegistryPhaseSequence, isWindowsSessionBootstrapDiagnosticCode, type WindowsSessionBootstrapDiagnosticCode, type WindowsSessionBootstrapDiagnosticObserver, type WindowsSessionRegistryPhaseObserver } from "../lib/windows-session-transport.ts";
|
|
49
52
|
import { hasReviewSessionPermission, resolveCanonicalGitRepositoryIdentitySync, type ReviewSessionManager } from "../lib/review-session-standing-permission.ts";
|
|
@@ -68,6 +71,7 @@ import { createRpcActivityPublisher, type RpcActivityPublisher } from "../lib/ag
|
|
|
68
71
|
import { isInteractiveRpcHost } from "../lib/rpc-host.ts";
|
|
69
72
|
import { createNativeFullscreenInteraction } from "../lib/native-fullscreen-interaction.ts";
|
|
70
73
|
import { HERDR_BUSY_CHANNEL, nextHerdrBusyAction, type HerdrBusyEmitted } from "../lib/herdr-busy.ts";
|
|
74
|
+
import { HERDR_DESKTOP_TASKS, HERDR_DESKTOP_TASKS_REQUEST, HERDR_DESKTOP_TASK_FINISHED, HERDR_DESKTOP_JOBS, HERDR_DESKTOP_JOB_SETTLED, HERDR_DESKTOP_CONSULT, HERDR_DESKTOP_SEND, HERDR_DESKTOP_INBOUND, type HerdrDesktopInbound, type HerdrDesktopJobSettled } from "../lib/herdr-desktop-events.ts";
|
|
71
75
|
import { AGENTS_GLYPH, agentsCardTone, agentsSpend, agentsSummary, renderAgentsAlert, renderAgentsCard, renderAgentsSection, widgetExpiryMs, widgetRows } from "../lib/agents-widget.ts";
|
|
72
76
|
import { CARD_TONE, cardAwaitingResult, cardBodyRows, cardBottom, cardInnerWidth, cardRunningLine, cardTop, floatRows, headingFits, markCardResult, panelHeaderRow, panelInnerWidth, renderCard, type CardRowContext, type CardTheme, type CardTone } from "../lib/shell-card.ts";
|
|
73
77
|
import { openInExternalEditor } from "./gentle-shell.ts";
|
|
@@ -77,6 +81,8 @@ import { allowedEditSurfaces, inheritAllowedEditSurfaces, isBoundedWriter, isDev
|
|
|
77
81
|
import { CHILD_METRICS_EVENT, CHILD_METRICS_REVOKED, childEvent, launchSelection, type LaunchSelection } from "../lib/runtime-metrics-children.ts";
|
|
78
82
|
import { runtimeMetricsEnvAllows, type RuntimeMetricsPolicyDeps } from "../lib/runtime-metrics-policy.ts";
|
|
79
83
|
import { publishTaskStatusChanges } from "../lib/notification-events.ts";
|
|
84
|
+
import { appendSystemPromptOnce } from "../lib/append-system-prompt.ts";
|
|
85
|
+
import { codemodeReaches, COORDINATION_TOOLS_ROUTE, hideBehindCodemode } from "../lib/hidden-tools.ts";
|
|
80
86
|
|
|
81
87
|
// Gentle Agents: subagents as isolated `pi --mode rpc` children, a task
|
|
82
88
|
// store that notifies per task, and a Gentle Shell card above the editor.
|
|
@@ -161,6 +167,8 @@ export const INPUT_PROMPT_GRACE_MS = 2000;
|
|
|
161
167
|
// after the grace at most this many times in a row, so a permanently broken
|
|
162
168
|
// runtime never retries forever.
|
|
163
169
|
const PARENT_DELIVERY_RETRY_LIMIT = 3;
|
|
170
|
+
// A swallowed wake or aborted delivery may never start a consuming turn.
|
|
171
|
+
const HERDR_INBOUND_TTL_MS = 300_000;
|
|
164
172
|
|
|
165
173
|
const retiredSddAgent = (name: string): boolean => /^sdd(?:-|$)/.test(name);
|
|
166
174
|
|
|
@@ -702,9 +710,9 @@ export function resolveDefaultSubagentMode(input: {
|
|
|
702
710
|
|
|
703
711
|
// What the model reads when a background task ends: the outcome first, then
|
|
704
712
|
// the answer itself. The expanded card shows the same text.
|
|
705
|
-
export function completionText(task: TaskRecord): string {
|
|
713
|
+
export function completionText(task: TaskRecord, report: string = finishedText(task)): string {
|
|
706
714
|
const outcome = task.status === "completed" ? "finished" : task.status.replace("_", " ");
|
|
707
|
-
return `Subagent ${task.agent} (task ${task.id}, "${task.label}") ${outcome}.\n\n${
|
|
715
|
+
return `Subagent ${task.agent} (task ${task.id}, "${task.label}") ${outcome}.\n\n${report}`;
|
|
708
716
|
}
|
|
709
717
|
|
|
710
718
|
const COMPLETION_HEADER = /^Subagent [^\n]+ \(task [^\n]*\) [^\n]+\.$/;
|
|
@@ -1198,11 +1206,100 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1198
1206
|
// conversation.
|
|
1199
1207
|
const completions = createCompletionQueue<TaskRecord>();
|
|
1200
1208
|
const messages = createAgentMessageQueue();
|
|
1209
|
+
// Display-only query tracking follows the runner's enqueue/settle hooks, not
|
|
1210
|
+
// the delivery queue: a delivered question still blocks until answered.
|
|
1211
|
+
const herdrQueries = new Map<string, Set<string>>();
|
|
1212
|
+
const emitHerdr = (name: string, data: unknown) => {
|
|
1213
|
+
try { pi.events.emit(name, data); } catch { /* Display must never affect a tool or runner. */ }
|
|
1214
|
+
};
|
|
1215
|
+
// Display-only correlation: idle messages are already in session context;
|
|
1216
|
+
// run-time follow-ups enter it only when Pi emits their custom message_start.
|
|
1217
|
+
type InboundDisplay = { event: Omit<HerdrDesktopInbound, "phase">; state: "held" | "idle" | "queued" | "consumed"; cancel: () => void };
|
|
1218
|
+
const inboundDisplay = new Map<string, InboundDisplay>();
|
|
1219
|
+
const inboundKey = (sessionId: string, peer: string, id: string) => JSON.stringify([sessionId, peer, id]);
|
|
1220
|
+
const inboundDetails = (message: Parameters<ExtensionAPI["sendMessage"]>[0], sessionId: string) => {
|
|
1221
|
+
const details = (message.details as { gentleAgents?: OrchestratorMessageDetails } | undefined)?.gentleAgents;
|
|
1222
|
+
if (message.customType !== AGENTS_ORCHESTRATOR_MESSAGE_TYPE || typeof details?.senderSessionId !== "string"
|
|
1223
|
+
|| typeof details.correlationId !== "string" || details.recipientSessionId !== sessionId) return undefined;
|
|
1224
|
+
return { sessionId, peer: details.senderSessionId, ...(details.senderLabel ? { peerName: details.senderLabel } : {}), id: details.correlationId };
|
|
1225
|
+
};
|
|
1226
|
+
const finishInboundDisplay = (key: string, entry: InboundDisplay) => {
|
|
1227
|
+
try {
|
|
1228
|
+
if (inboundDisplay.get(key) !== entry) return;
|
|
1229
|
+
inboundDisplay.delete(key);
|
|
1230
|
+
try { entry.cancel(); } catch { /* Display timer cleanup is best-effort. */ }
|
|
1231
|
+
emitHerdr(HERDR_DESKTOP_INBOUND, { ...entry.event, phase: "handled" });
|
|
1232
|
+
} catch { /* Display must never affect delivery or lifecycle. */ }
|
|
1233
|
+
};
|
|
1234
|
+
const receiveInboundDisplay = (message: Parameters<ExtensionAPI["sendMessage"]>[0], sessionId: string, state: InboundDisplay["state"]) => {
|
|
1235
|
+
try {
|
|
1236
|
+
const event = inboundDetails(message, sessionId);
|
|
1237
|
+
if (!event) return;
|
|
1238
|
+
const key = inboundKey(sessionId, event.peer, event.id);
|
|
1239
|
+
if (inboundDisplay.has(key)) return;
|
|
1240
|
+
let entry: InboundDisplay;
|
|
1241
|
+
const cancel = deps.schedule(() => finishInboundDisplay(key, entry), HERDR_INBOUND_TTL_MS);
|
|
1242
|
+
entry = { event, state, cancel }; inboundDisplay.set(key, entry);
|
|
1243
|
+
emitHerdr(HERDR_DESKTOP_INBOUND, { ...event, phase: "received" });
|
|
1244
|
+
} catch { /* Display must never affect delivery or lifecycle. */ }
|
|
1245
|
+
};
|
|
1246
|
+
const updateInboundDisplay = (message: Parameters<ExtensionAPI["sendMessage"]>[0], sessionId: string, state: InboundDisplay["state"] | "dropped") => {
|
|
1247
|
+
try {
|
|
1248
|
+
const event = inboundDetails(message, sessionId);
|
|
1249
|
+
if (!event) return;
|
|
1250
|
+
const key = inboundKey(sessionId, event.peer, event.id), entry = inboundDisplay.get(key);
|
|
1251
|
+
if (!entry) return;
|
|
1252
|
+
if (state === "dropped") finishInboundDisplay(key, entry); else entry.state = state;
|
|
1253
|
+
} catch { /* Display must never affect delivery or lifecycle. */ }
|
|
1254
|
+
};
|
|
1255
|
+
const settleInboundDisplay = () => {
|
|
1256
|
+
for (const [key, entry] of inboundDisplay) if (entry.state === "consumed") finishInboundDisplay(key, entry);
|
|
1257
|
+
};
|
|
1258
|
+
let herdrTaskSession: string | undefined;
|
|
1259
|
+
let herdrActiveTasks = new Set<string>();
|
|
1260
|
+
const emitHerdrTasks = (sessionId: string | undefined) => {
|
|
1261
|
+
if (!sessionId) return;
|
|
1262
|
+
try {
|
|
1263
|
+
if (sessionId !== activeSessionId()) return;
|
|
1264
|
+
const all = store.list(sessionId);
|
|
1265
|
+
const previous = herdrTaskSession === sessionId ? herdrActiveTasks : new Set<string>();
|
|
1266
|
+
const tasks = all.filter(task => !isFinished(task.status)).map(task => ({
|
|
1267
|
+
id: task.id, agent: task.agent, label: task.label, explicitLabel: task.explicitLabel, status: task.status,
|
|
1268
|
+
pendingQuery: (herdrQueries.get(task.id)?.size ?? 0) > 0,
|
|
1269
|
+
}));
|
|
1270
|
+
herdrTaskSession = sessionId;
|
|
1271
|
+
herdrActiveTasks = new Set(tasks.map(task => task.id));
|
|
1272
|
+
// Send the terminal edge before the active-only snapshot removes the
|
|
1273
|
+
// record; existing snapshot consumers retain their original contract.
|
|
1274
|
+
for (const task of all) if (previous.has(task.id) && (task.status === "failed" || task.status === "timed_out")) {
|
|
1275
|
+
emitHerdr(HERDR_DESKTOP_TASK_FINISHED, { sessionId, task: {
|
|
1276
|
+
id: task.id, agent: task.agent, label: task.label, explicitLabel: task.explicitLabel, status: task.status, pendingQuery: false,
|
|
1277
|
+
} });
|
|
1278
|
+
}
|
|
1279
|
+
emitHerdr(HERDR_DESKTOP_TASKS, { sessionId, tasks });
|
|
1280
|
+
} catch { /* A stale display observer never affects the owner. */ }
|
|
1281
|
+
};
|
|
1282
|
+
const removeHerdrQuery = (taskId: string, requestId: string) => {
|
|
1283
|
+
const queries = herdrQueries.get(taskId);
|
|
1284
|
+
if (!queries?.delete(requestId)) return;
|
|
1285
|
+
if (queries.size === 0) herdrQueries.delete(taskId);
|
|
1286
|
+
emitHerdrTasks(store.get(taskId)?.parentSessionId);
|
|
1287
|
+
};
|
|
1288
|
+
const unsubscribeHerdrTasks = pi.events.on(HERDR_DESKTOP_TASKS_REQUEST, (value: unknown) => {
|
|
1289
|
+
const sessionId = (value as { sessionId?: unknown } | null)?.sessionId;
|
|
1290
|
+
if (typeof sessionId === "string" && sessionId === activeSessionId()) {
|
|
1291
|
+
emitHerdrTasks(sessionId);
|
|
1292
|
+
emitHerdrJobs(sessionId);
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1201
1295
|
// A job's exit, or a monitor's line events and harness stop, waiting for
|
|
1202
1296
|
// the parent delivery router.
|
|
1203
1297
|
type JobNotice = { job: JobRecord; kind: "exit" } | MonitorNotice;
|
|
1204
1298
|
const jobNotices: JobNotice[] = [];
|
|
1205
1299
|
let jobOutputDir: string | undefined;
|
|
1300
|
+
// Shutdown stops every job through stopAll and then refreshes once; that
|
|
1301
|
+
// final refresh must not notify Desktop consumers (the channel is closing).
|
|
1302
|
+
let shuttingDown = false;
|
|
1206
1303
|
const jobs = createJobRegistry({
|
|
1207
1304
|
outputDir: deps.jobOutputDir ?? (() => (jobOutputDir ??= mkdtempSync(join(os.tmpdir(), "gentle-jobs-")))),
|
|
1208
1305
|
now: deps.now,
|
|
@@ -1212,12 +1309,178 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1212
1309
|
}),
|
|
1213
1310
|
onSettled: (job) => settleJob(job),
|
|
1214
1311
|
});
|
|
1312
|
+
// Replay the existing registry's running rows on status subscription or
|
|
1313
|
+
// resume; finished sidebar tails cannot contribute a Herdr record.
|
|
1314
|
+
const emitHerdrJobs = (sessionId: string) => {
|
|
1315
|
+
try {
|
|
1316
|
+
const running = jobs.list(sessionId).filter(job => job.status === "running")
|
|
1317
|
+
.sort((a, b) => b.startedAt - a.startedAt)
|
|
1318
|
+
.map(({ id, label, explicitLabel, kind, startedAt }) => ({ id, label, explicitLabel, kind, startedAt }));
|
|
1319
|
+
emitHerdr(HERDR_DESKTOP_JOBS, { sessionId, snapshot: { jobs: running } });
|
|
1320
|
+
} catch { /* Display-only replay. */ }
|
|
1321
|
+
};
|
|
1215
1322
|
const monitors = createMonitorController({
|
|
1216
1323
|
registry: jobs,
|
|
1217
1324
|
schedule: (fn, ms) => deps.schedule(fn, ms),
|
|
1218
1325
|
now: deps.now,
|
|
1219
1326
|
deliver: (notice) => queueJobNotice(notice),
|
|
1220
1327
|
});
|
|
1328
|
+
// Desktop's jobs slice reaches the single parent registry and monitor
|
|
1329
|
+
// controller only through this versioned, adapter-shaped seam — the jobs
|
|
1330
|
+
// analogue of the usage/design owner services. The adapter never runs or
|
|
1331
|
+
// stops a job itself: `cancel` is `job_stop`'s exact stop path
|
|
1332
|
+
// (`monitors.cancel` then `registry.stop`), `output` reads the registry's
|
|
1333
|
+
// own bounded in-memory tail, and `observe` is driven by the same actual
|
|
1334
|
+
// registry changes below. There is no second registry, process
|
|
1335
|
+
// manager, or store.
|
|
1336
|
+
const desktopJobsObservers = new Set<(sessionId: string) => void>();
|
|
1337
|
+
const notifyDesktopJobs = (sessionId: string): void => {
|
|
1338
|
+
if (desktopJobsObservers.size === 0) return;
|
|
1339
|
+
for (const observer of [...desktopJobsObservers]) {
|
|
1340
|
+
try { observer(sessionId); } catch { /* an observer never breaks jobs */ }
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
const unsubscribeDesktopJobsService = pi.events.on(DESKTOP_JOBS_SERVICE_CHANNEL, (payload: unknown) => {
|
|
1344
|
+
if (!payload || typeof payload !== "object") return;
|
|
1345
|
+
const request = payload as Partial<{ context: ExtensionContext; respond(service: DesktopJobsService): void }>;
|
|
1346
|
+
if (typeof request.respond !== "function" || !request.context) return;
|
|
1347
|
+
const ctx = request.context;
|
|
1348
|
+
try {
|
|
1349
|
+
let disposed = false;
|
|
1350
|
+
const subscriptions = new Set<(sessionId: string) => void>();
|
|
1351
|
+
const sessionId = ctx.sessionManager?.getSessionId?.() ?? "";
|
|
1352
|
+
const read = (): DesktopJobsOwnerRead => ({
|
|
1353
|
+
sessionId,
|
|
1354
|
+
jobs: disposed ? [] : selectDesktopJobs(jobs.list(sessionId), deps.now()),
|
|
1355
|
+
});
|
|
1356
|
+
const cancel = (id: string): DesktopJobsCancelOutcome => {
|
|
1357
|
+
if (disposed) return { kind: "not_found" };
|
|
1358
|
+
const job = jobs.get(id);
|
|
1359
|
+
// The same ownership check job_stop performs: a foreign or unknown
|
|
1360
|
+
// id is a typed not_found, never a stop of someone else's job.
|
|
1361
|
+
if (!job || job.ownerSessionId !== sessionId) return { kind: "not_found" };
|
|
1362
|
+
const wasRunning = job.status === "running";
|
|
1363
|
+
monitors.cancel(job.id);
|
|
1364
|
+
jobs.stop(job.id);
|
|
1365
|
+
return { kind: "ok", job: projectDesktopJob(job), changed: wasRunning };
|
|
1366
|
+
};
|
|
1367
|
+
const output = (id: string): DesktopJobsOutputOutcome => {
|
|
1368
|
+
if (disposed) return { kind: "not_found" };
|
|
1369
|
+
const job = jobs.get(id);
|
|
1370
|
+
// The same ownership rule list_jobs and cancel apply: a foreign or
|
|
1371
|
+
// unknown id is a typed not_found, never another session's output.
|
|
1372
|
+
if (!job || job.ownerSessionId !== sessionId) return { kind: "not_found" };
|
|
1373
|
+
return { kind: "ok", view: projectDesktopJobOutput(job) };
|
|
1374
|
+
};
|
|
1375
|
+
request.respond({
|
|
1376
|
+
schema: DESKTOP_JOBS_SERVICE_SCHEMA,
|
|
1377
|
+
read,
|
|
1378
|
+
cancel,
|
|
1379
|
+
output,
|
|
1380
|
+
observe: (onChange) => {
|
|
1381
|
+
if (disposed) return () => {};
|
|
1382
|
+
subscriptions.add(onChange);
|
|
1383
|
+
desktopJobsObservers.add(onChange);
|
|
1384
|
+
return () => {
|
|
1385
|
+
subscriptions.delete(onChange);
|
|
1386
|
+
desktopJobsObservers.delete(onChange);
|
|
1387
|
+
};
|
|
1388
|
+
},
|
|
1389
|
+
dispose: () => {
|
|
1390
|
+
disposed = true;
|
|
1391
|
+
for (const onChange of subscriptions) desktopJobsObservers.delete(onChange);
|
|
1392
|
+
subscriptions.clear();
|
|
1393
|
+
},
|
|
1394
|
+
});
|
|
1395
|
+
} catch {
|
|
1396
|
+
/* obsolete trusted context: discovery expires closed */
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
// Desktop subagents owner adapter: the agents analogue of the jobs/usage
|
|
1400
|
+
// owner services. The adapter never runs, stops, or spawns a subagent
|
|
1401
|
+
// itself: `cancel` is the exact `runner.cancel` stop path the agents panel
|
|
1402
|
+
// stop uses, `read` projects the single `TaskStore`, and `observe` is
|
|
1403
|
+
// driven by the same actual TaskStore transitions below. There is no second
|
|
1404
|
+
// store, runner, or process manager. `runner` is declared later in this
|
|
1405
|
+
// module; the adapter closes over the binding lazily.
|
|
1406
|
+
const desktopAgentsObservers = new Set<(sessionId: string) => void>();
|
|
1407
|
+
const notifyDesktopAgents = (sessionId: string): void => {
|
|
1408
|
+
if (desktopAgentsObservers.size === 0) return;
|
|
1409
|
+
for (const observer of [...desktopAgentsObservers]) {
|
|
1410
|
+
try { observer(sessionId); } catch { /* an observer never breaks agents */ }
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
const unsubscribeDesktopAgentsService = pi.events.on(DESKTOP_AGENTS_SERVICE_CHANNEL, (payload: unknown) => {
|
|
1414
|
+
if (!payload || typeof payload !== "object") return;
|
|
1415
|
+
const request = payload as Partial<{ context: ExtensionContext; respond(service: DesktopAgentsService): void }>;
|
|
1416
|
+
if (typeof request.respond !== "function" || !request.context) return;
|
|
1417
|
+
const ctx = request.context;
|
|
1418
|
+
try {
|
|
1419
|
+
let disposed = false;
|
|
1420
|
+
const subscriptions = new Set<(sessionId: string) => void>();
|
|
1421
|
+
const sessionId = ctx.sessionManager?.getSessionId?.() ?? "";
|
|
1422
|
+
const read = (): DesktopAgentsOwnerRead => ({
|
|
1423
|
+
sessionId,
|
|
1424
|
+
agents: disposed ? [] : selectDesktopAgents(store.list(sessionId)),
|
|
1425
|
+
});
|
|
1426
|
+
const cancel = (id: string): DesktopAgentsCancelOutcome => {
|
|
1427
|
+
if (disposed) return { kind: "not_found" };
|
|
1428
|
+
const before = store.get(id);
|
|
1429
|
+
// The same ownership check the agents panel stop performs: a foreign
|
|
1430
|
+
// or unknown id is a typed not_found, never a stop of someone else's task.
|
|
1431
|
+
if (!before || before.parentSessionId !== sessionId) return { kind: "not_found" };
|
|
1432
|
+
// The same owner path the agents panel stop uses: runner.cancel. Its
|
|
1433
|
+
// boolean is honored verbatim, and `changed` reflects the store's actual
|
|
1434
|
+
// synchronous transition, not the request. A queued task transitions to
|
|
1435
|
+
// cancelled here; a running task's cancellation is asynchronous (no
|
|
1436
|
+
// synchronous transition), so a repeated in-flight cancel is `changed:
|
|
1437
|
+
// false` and never emits an immediate fabricated event.
|
|
1438
|
+
const requested = runner.cancel(id, "cancelled: stopped from desktop");
|
|
1439
|
+
const after = store.get(id) ?? before;
|
|
1440
|
+
const changed = requested && after.status !== before.status;
|
|
1441
|
+
return { kind: "ok", agent: projectDesktopAgent(after), requested, changed };
|
|
1442
|
+
};
|
|
1443
|
+
// A pure read of the single TaskStore through the activity widget's own
|
|
1444
|
+
// projection, behind the same ownership check `cancel` applies: a foreign
|
|
1445
|
+
// or unknown id is a typed not_found, never another session's thread.
|
|
1446
|
+
const thread = (id: string): DesktopAgentsThreadOutcome => {
|
|
1447
|
+
if (disposed) return { kind: "not_found" };
|
|
1448
|
+
const task = store.get(id);
|
|
1449
|
+
if (!task || task.parentSessionId !== sessionId) return { kind: "not_found" };
|
|
1450
|
+
return { kind: "ok", thread: projectDesktopAgentThread(id, store.thread(id)) };
|
|
1451
|
+
};
|
|
1452
|
+
request.respond({
|
|
1453
|
+
schema: DESKTOP_AGENTS_SERVICE_SCHEMA,
|
|
1454
|
+
read,
|
|
1455
|
+
cancel,
|
|
1456
|
+
thread,
|
|
1457
|
+
observe: (onChange) => {
|
|
1458
|
+
if (disposed) return () => {};
|
|
1459
|
+
subscriptions.add(onChange);
|
|
1460
|
+
desktopAgentsObservers.add(onChange);
|
|
1461
|
+
return () => {
|
|
1462
|
+
subscriptions.delete(onChange);
|
|
1463
|
+
desktopAgentsObservers.delete(onChange);
|
|
1464
|
+
};
|
|
1465
|
+
},
|
|
1466
|
+
dispose: () => {
|
|
1467
|
+
disposed = true;
|
|
1468
|
+
for (const onChange of subscriptions) desktopAgentsObservers.delete(onChange);
|
|
1469
|
+
subscriptions.clear();
|
|
1470
|
+
},
|
|
1471
|
+
});
|
|
1472
|
+
} catch {
|
|
1473
|
+
/* obsolete trusted context: discovery expires closed */
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
// Actual TaskStore transitions (task add and every status change) notify the
|
|
1477
|
+
// Desktop bridge. Restored-from-disk snapshots are silent, matching the
|
|
1478
|
+
// status-change notification contract. The usage breakdown recorded at
|
|
1479
|
+
// completion is a status-unchanged update, so `onFinish` notifies it
|
|
1480
|
+
// explicitly; the bridge coalesces both into one event.
|
|
1481
|
+
const stopAgentsStatusNotifications = store.subscribeStatusChanges((change) => {
|
|
1482
|
+
notifyDesktopAgents(change.sessionId);
|
|
1483
|
+
});
|
|
1221
1484
|
// A parent that sleeps while background work runs only burns the turn: each
|
|
1222
1485
|
// completion already arrives as a session message (#1903). bash_background
|
|
1223
1486
|
// and monitor stay allowed because they are the sanctioned way to wait.
|
|
@@ -1241,6 +1504,10 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1241
1504
|
// session_start context is kept for it and dropped at shutdown; a stale
|
|
1242
1505
|
// context throws instead of answering, so delivery fails closed.
|
|
1243
1506
|
let parentCtx: ExtensionContext | undefined;
|
|
1507
|
+
const ownsInboundDisplay = (ctx: ExtensionContext) => {
|
|
1508
|
+
try { return !!parentCtx && ctx.sessionManager === parentCtx.sessionManager && ctx.sessionManager === sessions && ctx.sessionManager.getSessionId() === activeSessionId(); }
|
|
1509
|
+
catch { return false; }
|
|
1510
|
+
};
|
|
1244
1511
|
const helperPermission = new HelperCostPermission(() => parentCtx && activeTransportFor(parentCtx) ? parentCtx : undefined);
|
|
1245
1512
|
pi.on("session_before_switch", () => helperPermission.clear());
|
|
1246
1513
|
pi.on("session_before_fork", () => helperPermission.clear());
|
|
@@ -1473,7 +1740,11 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1473
1740
|
// Ownership is consulted at delivery time, matching onNotification and
|
|
1474
1741
|
// onQuery: a completion owned by another session is dropped, not delivered.
|
|
1475
1742
|
if (activeSessionId() !== task.parentSessionId) return;
|
|
1476
|
-
|
|
1743
|
+
// P9b: only the delivered copy is capped; subagent_result keeps the full text.
|
|
1744
|
+
let cwd = process.cwd();
|
|
1745
|
+
try { cwd = sessions?.getCwd() ?? cwd; } catch { /* A stale manager keeps the process directory, like the runner's config. */ }
|
|
1746
|
+
const capped = capReport(finishedText(task), loadAgentsConfig({ cwd, home: deps.home, agentHome }).reportMaxBytes, task.id, task.agent);
|
|
1747
|
+
sendToParent({ customType: AGENTS_RESULT_TYPE, content: completionText(task, capped.text), display: true, details: withReportCap(taskDetails(task), capped) }, route);
|
|
1477
1748
|
};
|
|
1478
1749
|
|
|
1479
1750
|
// Incoming orchestrator session messages. The transport has already
|
|
@@ -1488,9 +1759,11 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1488
1759
|
if (route === "hold") {
|
|
1489
1760
|
heldOrchestratorMessages.push({ message, recipientSessionId });
|
|
1490
1761
|
armHoldRecheck();
|
|
1762
|
+
receiveInboundDisplay(message, recipientSessionId, "held");
|
|
1491
1763
|
return;
|
|
1492
1764
|
}
|
|
1493
1765
|
sendToParent(message, route, "followUp");
|
|
1766
|
+
receiveInboundDisplay(message, recipientSessionId, route === "idle" ? "idle" : "queued");
|
|
1494
1767
|
};
|
|
1495
1768
|
const flushOrchestratorMessages = () => {
|
|
1496
1769
|
if (heldOrchestratorMessages.length === 0) return;
|
|
@@ -1500,8 +1773,13 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1500
1773
|
heldOrchestratorMessages = [];
|
|
1501
1774
|
for (const { message, recipientSessionId } of held) {
|
|
1502
1775
|
if (activeSessionId() !== recipientSessionId) continue;
|
|
1503
|
-
try {
|
|
1504
|
-
|
|
1776
|
+
try {
|
|
1777
|
+
sendToParent(message, route, "followUp");
|
|
1778
|
+
updateInboundDisplay(message, recipientSessionId, route === "idle" ? "idle" : "queued");
|
|
1779
|
+
} catch {
|
|
1780
|
+
updateInboundDisplay(message, recipientSessionId, "dropped");
|
|
1781
|
+
/* Best-effort delivery: at most once, even if forwarding fails. */
|
|
1782
|
+
}
|
|
1505
1783
|
}
|
|
1506
1784
|
};
|
|
1507
1785
|
|
|
@@ -1584,22 +1862,26 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1584
1862
|
const flushJobNotices = () => {
|
|
1585
1863
|
const route = deliveryRoute(false);
|
|
1586
1864
|
if (!route) return;
|
|
1587
|
-
const
|
|
1865
|
+
const retained: JobNotice[] = [];
|
|
1866
|
+
let deliveryFailed = false;
|
|
1588
1867
|
for (const notice of jobNotices.splice(0)) {
|
|
1589
1868
|
const { job } = notice;
|
|
1590
|
-
if (activeSessionId() !== job.ownerSessionId)
|
|
1869
|
+
if (activeSessionId() !== job.ownerSessionId) {
|
|
1870
|
+
retained.push(notice);
|
|
1871
|
+
continue;
|
|
1872
|
+
}
|
|
1591
1873
|
const content = notice.kind === "events" ? monitorEventsText(job, notice.batch)
|
|
1592
1874
|
: notice.kind === "stopped" ? monitorStoppedText(job, notice.reason) : jobNoticeText(job);
|
|
1593
1875
|
const event = notice.kind === "events" ? "events" : notice.kind === "stopped" ? notice.reason : undefined;
|
|
1594
1876
|
try {
|
|
1595
1877
|
sendToParent({ customType: JOB_NOTICE_TYPE, content, display: true, details: jobDetails(job, event) }, route);
|
|
1596
1878
|
} catch {
|
|
1597
|
-
|
|
1879
|
+
retained.push(notice);
|
|
1880
|
+
deliveryFailed = true;
|
|
1598
1881
|
}
|
|
1599
1882
|
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
if (route === "idle") armDeliveryRetry();
|
|
1883
|
+
jobNotices.unshift(...retained);
|
|
1884
|
+
if (deliveryFailed && route === "idle") armDeliveryRetry();
|
|
1603
1885
|
};
|
|
1604
1886
|
|
|
1605
1887
|
const flushAll = () => {
|
|
@@ -1625,6 +1907,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1625
1907
|
|
|
1626
1908
|
// Session changes discard every pending wake and boundary flush.
|
|
1627
1909
|
const resetParentDelivery = (ctx: ExtensionContext | undefined) => {
|
|
1910
|
+
herdrTaskSession = undefined; herdrActiveTasks.clear();
|
|
1628
1911
|
helperPermission.clear(); // Revoke before dropping old callback authority.
|
|
1629
1912
|
parentCtx = ctx;
|
|
1630
1913
|
restoreBridgeWakeIdentity(ctx);
|
|
@@ -1632,6 +1915,8 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1632
1915
|
parentRunActive = false;
|
|
1633
1916
|
wakeOwed = false;
|
|
1634
1917
|
heldOrchestratorMessages = [];
|
|
1918
|
+
for (const entry of inboundDisplay.values()) { try { entry.cancel(); } catch { /* Display only. */ } }
|
|
1919
|
+
inboundDisplay.clear();
|
|
1635
1920
|
completionsMaybePending = false;
|
|
1636
1921
|
endPromptStart();
|
|
1637
1922
|
stopHoldRecheck();
|
|
@@ -1656,10 +1941,15 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1656
1941
|
if (sessionId) {
|
|
1657
1942
|
try {
|
|
1658
1943
|
pi.events.emit(JOBS_SIDEBAR_EVENT, { sessionId, snapshot: { jobs: [
|
|
1659
|
-
...running.map(({ id, label, startedAt }) => ({ id, label, startedAt })),
|
|
1660
|
-
...finished.map(({ id, label, startedAt, status, endedAt, exitCode }) => ({ id, label, startedAt, status, endedAt, exitCode })),
|
|
1944
|
+
...running.map(({ id, label, explicitLabel, kind, startedAt }) => ({ id, label, explicitLabel, kind, startedAt })),
|
|
1945
|
+
...finished.map(({ id, label, explicitLabel, kind, startedAt, status, endedAt, exitCode }) => ({ id, label, explicitLabel, kind, startedAt, status, endedAt, exitCode })),
|
|
1661
1946
|
] } });
|
|
1662
1947
|
} catch { /* Display only. */ }
|
|
1948
|
+
// Every actual registry change funnels through this refresh, including
|
|
1949
|
+
// monitor self-timeout/flood stops (their `stopFor` delivers a notice
|
|
1950
|
+
// here). Notify Desktop consumers; the bridge dedupes byte-identical
|
|
1951
|
+
// lists so a stop that also flushes pending lines still emits once.
|
|
1952
|
+
if (!shuttingDown) notifyDesktopJobs(sessionId);
|
|
1663
1953
|
}
|
|
1664
1954
|
};
|
|
1665
1955
|
|
|
@@ -1682,6 +1972,11 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1682
1972
|
if (activeAgentRuns === 0) flushAll();
|
|
1683
1973
|
};
|
|
1684
1974
|
const settleJob = (job: JobRecord) => {
|
|
1975
|
+
if (job.status !== "running") {
|
|
1976
|
+
const { id, explicitLabel, kind, startedAt, status, endedAt, exitCode } = job;
|
|
1977
|
+
const event: HerdrDesktopJobSettled = { sessionId: job.ownerSessionId, job: { id, explicitLabel, kind, startedAt, status, endedAt, exitCode } };
|
|
1978
|
+
emitHerdr(HERDR_DESKTOP_JOB_SETTLED, event);
|
|
1979
|
+
}
|
|
1685
1980
|
// A monitor's pending lines are delivered before its end.
|
|
1686
1981
|
if (job.kind === "monitor") monitors.finish(job);
|
|
1687
1982
|
queueJobNotice({ job, kind: "exit" });
|
|
@@ -1710,12 +2005,15 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1710
2005
|
// compaction ran inside or right before the run. `before_agent_start`
|
|
1711
2006
|
// marks a prompt that is about to start a run, and the compaction events
|
|
1712
2007
|
// release content held while the parent compacted without a run.
|
|
1713
|
-
pi.on("before_agent_start", () => {
|
|
2008
|
+
pi.on("before_agent_start", (event) => {
|
|
1714
2009
|
if (!parentRunActive) beginPromptStart();
|
|
2010
|
+
const options = event?.systemPromptOptions;
|
|
2011
|
+
if (codemodeReaches(options?.selectedTools) && ["orchestrator_list", "orchestrator_consult", "orchestrator_send_message"].some((name) => options?.selectedTools?.includes(name))) appendSystemPromptOnce(options, COORDINATION_TOOLS_ROUTE);
|
|
1715
2012
|
});
|
|
1716
|
-
pi.on("agent_start", () => {
|
|
2013
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
1717
2014
|
activeAgentRuns += 1;
|
|
1718
2015
|
parentRunActive = true;
|
|
2016
|
+
if (ownsInboundDisplay(ctx)) for (const entry of inboundDisplay.values()) if (entry.state === "idle") entry.state = "consumed";
|
|
1719
2017
|
// The run carries everything stored while the parent was idle.
|
|
1720
2018
|
wakeOwed = false;
|
|
1721
2019
|
endDeliveryRetry();
|
|
@@ -1730,7 +2028,13 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1730
2028
|
flushAll();
|
|
1731
2029
|
lastRunMessages = event?.messages ?? [];
|
|
1732
2030
|
});
|
|
2031
|
+
pi.on("message_start", (event, ctx) => {
|
|
2032
|
+
if (!ownsInboundDisplay(ctx) || event.message.role !== "custom") return;
|
|
2033
|
+
const sessionId = activeSessionId();
|
|
2034
|
+
if (sessionId) updateInboundDisplay(event.message, sessionId, "consumed");
|
|
2035
|
+
});
|
|
1733
2036
|
pi.on("agent_settled", (event, ctx) => {
|
|
2037
|
+
if (ownsInboundDisplay(ctx)) settleInboundDisplay();
|
|
1734
2038
|
parentRunActive = false;
|
|
1735
2039
|
endPromptStart();
|
|
1736
2040
|
flushAll();
|
|
@@ -1739,7 +2043,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1739
2043
|
// A child's own failures are handled by the parent's runner, never by the child.
|
|
1740
2044
|
if (deps.env.GENTLE_PI_AGENTS_CHILD !== "1" && ctx) void orchestratorFallbackFor(ctx).onSettled(messages, { aborted: event?.aborted === true }).catch((error: unknown) => ui?.notify(`Model fallback failed: ${error instanceof Error ? error.message : String(error)}`, "error"));
|
|
1741
2045
|
});
|
|
1742
|
-
pi.on("turn_end", () => flushAll());
|
|
2046
|
+
pi.on("turn_end", (_event, ctx) => { if (ownsInboundDisplay(ctx)) settleInboundDisplay(); flushAll(); });
|
|
1743
2047
|
pi.on("session_compact", scheduleBoundaryFlush);
|
|
1744
2048
|
pi.on("session_compact_failed", scheduleBoundaryFlush);
|
|
1745
2049
|
pi.on("session_tree", scheduleBoundaryFlush);
|
|
@@ -1775,8 +2079,12 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1775
2079
|
try {
|
|
1776
2080
|
messages.enqueueQuery(task, requestId, message, deps.now());
|
|
1777
2081
|
if (activeAgentRuns === 0) flushMessages(true);
|
|
2082
|
+
const queries = herdrQueries.get(task.id) ?? new Set<string>();
|
|
2083
|
+
queries.add(requestId); herdrQueries.set(task.id, queries);
|
|
2084
|
+
emitHerdrTasks(task.parentSessionId);
|
|
1778
2085
|
return true;
|
|
1779
2086
|
} catch (error) {
|
|
2087
|
+
removeHerdrQuery(task.id, requestId);
|
|
1780
2088
|
messages.expireQuery(task.id, requestId);
|
|
1781
2089
|
if (task.mode === AGENT_MODE.TASK && !hadYield) yieldedTaskIds.delete(task.id);
|
|
1782
2090
|
throw error;
|
|
@@ -1784,7 +2092,9 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1784
2092
|
},
|
|
1785
2093
|
onQuerySettled: (taskId, requestId, outcome) => {
|
|
1786
2094
|
if (outcome === "replied") messages.consumeQuery(taskId, requestId);
|
|
1787
|
-
|
|
2095
|
+
// A busy parent still sees a question that expired in its queue (S15 P9a).
|
|
2096
|
+
else messages.markQueryExpired(taskId, requestId);
|
|
2097
|
+
removeHerdrQuery(taskId, requestId);
|
|
1788
2098
|
},
|
|
1789
2099
|
onFallback: (task, change) => announceFallback({ agent: task.agent, from: change.from, to: change.to, category: change.category, ...(change.launch ? { launch: true } : {}) }, task.parentSessionId, task.id),
|
|
1790
2100
|
onSuccessfulMutation: (task, tool) => {
|
|
@@ -1837,6 +2147,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1837
2147
|
if (!foreignTask) recordReviewMutation(pi, sessions, root, { source: "subagent", taskId: task.id, toolName: tool.toolName, toolCallId: tool.toolCallId, ...runtimeWriterProfile(task) });
|
|
1838
2148
|
},
|
|
1839
2149
|
onFinish: (task, observations) => {
|
|
2150
|
+
herdrQueries.delete(task.id);
|
|
1840
2151
|
// Completion is the only forwarding opportunity. No pending event, policy
|
|
1841
2152
|
// query or promise survives this callback; the receiver drops when busy.
|
|
1842
2153
|
const { id, parentSessionId, status } = task;
|
|
@@ -1850,18 +2161,31 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1850
2161
|
if (event && metrics.current()) pi.events.emit(CHILD_METRICS_EVENT, event);
|
|
1851
2162
|
}
|
|
1852
2163
|
} catch { /* Metrics must never interrupt task finalization. */ }
|
|
2164
|
+
try {
|
|
2165
|
+
// Record the final-assistant token breakdown so the Desktop list can
|
|
2166
|
+
// project per-helper usage; in-flight tasks stay without it. This is a
|
|
2167
|
+
// status-unchanged update, so the agents owner notifies explicitly and
|
|
2168
|
+
// the Desktop bridge coalesces it with the terminal status change.
|
|
2169
|
+
if (observations && observations.responses.length > 0) {
|
|
2170
|
+
store.update(task.id, { usage: accumulateTaskUsage(observations.responses) });
|
|
2171
|
+
notifyDesktopAgents(parentSessionId);
|
|
2172
|
+
}
|
|
2173
|
+
} catch { /* Best-effort usage bookkeeping cannot strand runner waiters. */ }
|
|
1853
2174
|
try {
|
|
1854
2175
|
ownedTaskIds.delete(task.id);
|
|
1855
2176
|
messages.invalidateTask(task.id);
|
|
1856
2177
|
requestRender();
|
|
1857
|
-
|
|
2178
|
+
// Persist the post-breakdown record so a restored finished task keeps
|
|
2179
|
+
// its final usage. `task` is the onFinish argument, which predates the
|
|
2180
|
+
// usage update above; the store now carries the merged record.
|
|
2181
|
+
persist(store.get(task.id) ?? task);
|
|
1858
2182
|
const yielded = yieldedTaskIds.delete(task.id);
|
|
1859
2183
|
if ((task.mode === AGENT_MODE.BACKGROUND && task.status !== TASK_STATUS.CANCELLED) || (yielded && task.status !== TASK_STATUS.CANCELLED && activeSessionId() === task.parentSessionId)) settleCompletion(task);
|
|
1860
2184
|
} catch { /* Best-effort completion bookkeeping cannot strand runner waiters. */ }
|
|
1861
2185
|
},
|
|
1862
2186
|
});
|
|
1863
2187
|
|
|
1864
|
-
registerBackgroundJobTools(pi, { registry: jobs, monitors, sessionId: (ctx) => ctx.sessionManager.getSessionId() ?? "", now: deps.now, onChange: () => { refreshJobStatus(); requestRender(); } });
|
|
2188
|
+
registerBackgroundJobTools(pi, { registry: jobs, monitors, sessionId: (ctx) => ctx.sessionManager.getSessionId() ?? "", now: deps.now, onChange: (change: BackgroundJobsChange) => { refreshJobStatus(); requestRender(); } });
|
|
1865
2189
|
|
|
1866
2190
|
pi.registerMessageRenderer(AGENTS_MESSAGE_TYPE, (message, options, theme) => {
|
|
1867
2191
|
const details = (message.details as { gentleAgents?: { taskId?: unknown; agent?: unknown } } | undefined)?.gentleAgents;
|
|
@@ -2145,6 +2469,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2145
2469
|
// A status change is worth a frame right away; deltas inside a task are
|
|
2146
2470
|
// coalesced so a chatty child cannot flood the terminal.
|
|
2147
2471
|
store.subscribeSummary(() => {
|
|
2472
|
+
emitHerdrTasks(activeSessionId());
|
|
2148
2473
|
refreshHerdrBusy();
|
|
2149
2474
|
publishActivity();
|
|
2150
2475
|
if (sidebarTui) invalidateSidebar(sidebarTui);
|
|
@@ -2270,7 +2595,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2270
2595
|
};
|
|
2271
2596
|
};
|
|
2272
2597
|
|
|
2273
|
-
const roots = (ctx: ExtensionContext) => ({ cwd: ctx.sessionManager.getCwd(), home: deps.home, agentHome });
|
|
2598
|
+
const roots = (ctx: ExtensionContext) => ({ cwd: ctx.sessionManager.getCwd(), home: deps.home, agentHome, configHome: gentlePiConfigHome(deps.env) });
|
|
2274
2599
|
// Issue #2400: parent sessions already told about model_profiles keys that
|
|
2275
2600
|
// match no agent and suggest none, so the notice fires once per session.
|
|
2276
2601
|
const unmatchedKeysNotifiedSessions = new Set<string>();
|
|
@@ -2579,7 +2904,8 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2579
2904
|
messages.invalidateTask(finished.id);
|
|
2580
2905
|
// The id rides in the text too: details never reach the model, which
|
|
2581
2906
|
// otherwise guesses ordinal ids for subagent_continue (#1731 T19).
|
|
2582
|
-
|
|
2907
|
+
const capped = capReport(finishedText(finished), loadAgentsConfig(roots(ctx)).reportMaxBytes, finished.id, finished.agent);
|
|
2908
|
+
return text(completionText(finished, capped.text), withReportCap(taskDetails(finished), capped));
|
|
2583
2909
|
} finally {
|
|
2584
2910
|
signal?.removeEventListener("abort", onAbort);
|
|
2585
2911
|
}
|
|
@@ -2742,11 +3068,11 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2742
3068
|
pi.registerTool({
|
|
2743
3069
|
name: "orchestrator_session_id",
|
|
2744
3070
|
label: "Orchestrator session ID",
|
|
2745
|
-
description: "Return this session's stable routing ID, Initial alias (FIRST TASK), Current alias (CURRENT TASK), and separate human Session name. Subject updates Current even when named; Initial is the first declared branch topic, unknown for legacy history. Without subject, explicit state.work.topic updates Current; keep it current as tasks change. Before delegation or cross-session coordination, declare a short recognizable non-sensitive subject, not a prompt. Do not require a subject declaration for small direct tasks. Do not query all peers. Names never authenticate. Existing Pi names and human renames are preserved. Progress is published automatically from the todo list; publish state only for objective, decisions, blockers or work, never just progress.
|
|
3071
|
+
description: "Return this session's stable routing ID, Initial alias (FIRST TASK), Current alias (CURRENT TASK), and separate human Session name. Subject updates Current even when named; Initial is the first declared branch topic, unknown for legacy history. Without subject, explicit state.work.topic updates Current; keep it current as tasks change. Before delegation or cross-session coordination, declare a short recognizable non-sensitive subject, not a prompt. Do not require a subject declaration for small direct tasks. Do not query all peers. Names never authenticate. Existing Pi names and human renames are preserved. Progress is published automatically from the todo list; publish state only for objective, decisions, blockers or work, never just progress. If you publish classified work, keep objective and work.topic/area current on each task-topic change; never retain old task state. Catalog flags never-published peers. Owner-curated state: 2048 UTF-8 bytes total; null withdraws, omission leaves unchanged. Never include credentials, internal instructions, or raw prompts. Historical notes are not consent or an owner reply.",
|
|
2746
3072
|
...orchestratorToolRenderers("session", expandHint),
|
|
2747
3073
|
parameters: { type: "object", additionalProperties: false, properties: {
|
|
2748
3074
|
subject: { type: "string", maxLength: 120, description: "Short task subject; updates aliases independently of human names and names unnamed Pi sessions." },
|
|
2749
|
-
state: { anyOf: [{ type: "null" }, { type: "object", additionalProperties: false, properties: {
|
|
3075
|
+
state: { anyOf: [{ type: "null" }, { type: "string" }, { type: "object", additionalProperties: false, properties: {
|
|
2750
3076
|
objective: { type: "string" }, progress: { type: "string" }, decisions: { type: "string" }, blockers: { type: "string" },
|
|
2751
3077
|
work: { type: "object", additionalProperties: false,
|
|
2752
3078
|
description: "Historical, non-authoritative; topic requires area. Text and work JSON share 2048 UTF-8 bytes. Reject exact duplicate tags/refs; no ref resolution or routing.",
|
|
@@ -2762,7 +3088,17 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2762
3088
|
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
2763
3089
|
const transport = activeTransportFor(ctx);
|
|
2764
3090
|
if (!transport) return text("Error: session messaging is not ready.", { error: "not ready" });
|
|
2765
|
-
const { subject, state } = params as { subject?: unknown; state?: unknown };
|
|
3091
|
+
const { subject, state: rawState } = params as { subject?: unknown; state?: unknown };
|
|
3092
|
+
// Agents sometimes serialize the state object as a JSON string; accept
|
|
3093
|
+
// it with the same rules instead of a cryptic schema rejection, and
|
|
3094
|
+
// name the nesting rule when the parsed shape is flat.
|
|
3095
|
+
let state = rawState;
|
|
3096
|
+
if (typeof rawState === "string") {
|
|
3097
|
+
try { state = JSON.parse(rawState); }
|
|
3098
|
+
catch { throw new Error("invalid-state-json: state must be a JSON object string with objective/progress/decisions/blockers and optional work{area,topic,tags,refs,tasks} nested under \"work\"."); }
|
|
3099
|
+
if (state !== null && (typeof state !== "object" || Array.isArray(state))) throw new Error("invalid-state-json: the JSON string must encode an object or null.");
|
|
3100
|
+
if (state && Object.keys(state).some(key => !["objective", "progress", "decisions", "blockers", "work"].includes(key))) throw new Error("invalid-state-json: unknown top-level fields; area/topic/tags/refs/tasks must be nested under \"work\", not at the top level of state.");
|
|
3101
|
+
}
|
|
2766
3102
|
const declared = normalizeTaskSubject(subject);
|
|
2767
3103
|
// An owner object without `progress` keeps the automatic todo progress still on
|
|
2768
3104
|
// display; null and an explicit `progress` win, and an over-budget merge does not fail the call.
|
|
@@ -2791,6 +3127,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2791
3127
|
pi.registerTool({
|
|
2792
3128
|
name: "orchestrator_consult",
|
|
2793
3129
|
label: "Consult published context",
|
|
3130
|
+
prepareLoadout: hideBehindCodemode("orchestrator_consult"),
|
|
2794
3131
|
...orchestratorToolRenderers("consult", expandHint),
|
|
2795
3132
|
description: "Read published metadata (default), request bounded helper reasoning with explicit UI model-cost permission and a question, or revoke-reasoning for an exact target. Never an owner reply, consent or private context access.",
|
|
2796
3133
|
parameters: { type: "object", additionalProperties: false, required: ["recipient_session_id"], properties: {
|
|
@@ -2810,37 +3147,44 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2810
3147
|
|| Buffer.byteLength(input.question) > 1024 || /[\p{Cc}\p{Cf}\p{Cs}]/u.test(input.question)))
|
|
2811
3148
|
|| (input.cursor !== undefined && (typeof input.cursor !== "string" || input.cursor.length > 1024))) throw new Error("Invalid metadata consultation parameters.");
|
|
2812
3149
|
const selection = { recipientSessionId: input.recipient_session_id, cursor: input.cursor as string | undefined };
|
|
2813
|
-
const
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
};
|
|
2818
|
-
if (!transport) return result(unavailableMetadata(selection.recipientSessionId, "not-ready"));
|
|
2819
|
-
const reply = (receipt: unknown) => text(JSON.stringify(receipt), { gentleAgents: { senderSessionId: transport.sessionId, receipt } });
|
|
2820
|
-
if (kind === "revoke-reasoning") {
|
|
2821
|
-
helperPermission.revoke(selection.recipientSessionId);
|
|
2822
|
-
return reply({ status: "revoked", source: "helper_advice", ownerReply: false, authority: "none" });
|
|
2823
|
-
}
|
|
3150
|
+
const consult = { sessionId: ctx.sessionManager.getSessionId() ?? "", target: selection.recipientSessionId, callId: randomUUID() };
|
|
3151
|
+
// Revoking prior reasoning is not a consultation; Herdr Desktop shows nothing for it.
|
|
3152
|
+
const reportsConsult = kind !== "revoke-reasoning";
|
|
3153
|
+
if (reportsConsult) emitHerdr(HERDR_DESKTOP_CONSULT, { ...consult, phase: "start" });
|
|
2824
3154
|
try {
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
const current = () => activeTransportFor(ctx) === transport && parentCtx?.sessionManager === ctx.sessionManager;
|
|
2830
|
-
const readSource = async () => {
|
|
2831
|
-
const peers = await transport.listener.registry.listActivations(transport.sessionId);
|
|
2832
|
-
return current() ? consultPublishedMetadata(agentHome, peers, selection)
|
|
2833
|
-
: unavailableMetadata(selection.recipientSessionId, "source-session-changed");
|
|
3155
|
+
const transport = activeTransportFor(ctx);
|
|
3156
|
+
const result = (receipt: MetadataReceipt) => {
|
|
3157
|
+
const output = kind === "metadata" ? receipt : { status: "unavailable", code: receipt.unknowns[0], source: "helper_advice", ownerReply: false, authority: "none" };
|
|
3158
|
+
return text(JSON.stringify(output), { gentleAgents: { senderSessionId: transport?.sessionId, receipt: output } });
|
|
2834
3159
|
};
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
3160
|
+
if (!transport) return result(unavailableMetadata(selection.recipientSessionId, "not-ready"));
|
|
3161
|
+
const reply = (receipt: unknown) => text(JSON.stringify(receipt), { gentleAgents: { senderSessionId: transport.sessionId, receipt } });
|
|
3162
|
+
if (kind === "revoke-reasoning") {
|
|
3163
|
+
helperPermission.revoke(selection.recipientSessionId);
|
|
3164
|
+
return reply({ status: "revoked", source: "helper_advice", ownerReply: false, authority: "none" });
|
|
3165
|
+
}
|
|
3166
|
+
try {
|
|
3167
|
+
const activations = await transport.listener.registry.listActivations(transport.sessionId);
|
|
3168
|
+
if (activeTransportFor(ctx) !== transport) return result(unavailableMetadata(selection.recipientSessionId, "source-session-changed"));
|
|
3169
|
+
const receipt = consultPublishedMetadata(agentHome, activations, selection);
|
|
3170
|
+
if (kind === "metadata") return result(receipt);
|
|
3171
|
+
const current = () => activeTransportFor(ctx) === transport && parentCtx?.sessionManager === ctx.sessionManager;
|
|
3172
|
+
const readSource = async () => {
|
|
3173
|
+
const peers = await transport.listener.registry.listActivations(transport.sessionId);
|
|
3174
|
+
return current() ? consultPublishedMetadata(agentHome, peers, selection)
|
|
3175
|
+
: unavailableMetadata(selection.recipientSessionId, "source-session-changed");
|
|
3176
|
+
};
|
|
3177
|
+
const advice = await helperPermission.run({ receipt, question: input.question as string, signal: _signal,
|
|
3178
|
+
readSource, isSourceCurrent: () => current() && consultPublishedMetadata(agentHome, activations, selection).digest === receipt.digest });
|
|
3179
|
+
return reply(advice);
|
|
3180
|
+
} catch { return result(unavailableMetadata(selection.recipientSessionId, "discovery-unavailable")); }
|
|
3181
|
+
} finally { if (reportsConsult) emitHerdr(HERDR_DESKTOP_CONSULT, { ...consult, phase: "settle" }); }
|
|
2839
3182
|
},
|
|
2840
3183
|
});
|
|
2841
3184
|
pi.registerTool({
|
|
2842
3185
|
name: "orchestrator_list",
|
|
2843
3186
|
label: "List orchestrators",
|
|
3187
|
+
prepareLoadout: hideBehindCodemode("orchestrator_list"),
|
|
2844
3188
|
...orchestratorToolRenderers("list", expandHint),
|
|
2845
3189
|
description: "List other sessions advertised by the trusted local profile. Omit filter for the existing list; filter searches published classified work only: bounded, non-exhaustive, no authority, unknown reachability. Classified work must publish at session start and each task-topic change; flag peers doing classified work who never published state.",
|
|
2846
3190
|
parameters: Type.Object({
|
|
@@ -2908,8 +3252,8 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2908
3252
|
});
|
|
2909
3253
|
if (peers.length === 0) return text("No other sessions are currently advertised. Advertisements have unknown reachability and do not guarantee a live session.");
|
|
2910
3254
|
const unlisted = peers.filter(peer => peer.freshness === "recent" && peer.legacyLabel === undefined && !peer.state && !peer.statePublished);
|
|
2911
|
-
const
|
|
2912
|
-
return text(`Advertised sessions (reachability is unknown):\n${rows.join("\n")}${
|
|
3255
|
+
const unpublishedNote = unlisted.length > 0 ? `\n${unlisted.length} of ${peers.length} advertised sessions have never published work state. Progress publishes automatically from the todo list; an owner session publishes objective, work.topic, decisions or blockers via orchestrator_session_id only when they change.` : "";
|
|
3256
|
+
return text(`Advertised sessions (reachability is unknown):\n${rows.join("\n")}${unpublishedNote}`, { gentleAgents: { candidates: peers } });
|
|
2913
3257
|
} catch (error) {
|
|
2914
3258
|
// SessionPresenceError codes are a fixed enum with no record content,
|
|
2915
3259
|
// so surfacing the reason is safe and keeps diagnosis possible.
|
|
@@ -2921,6 +3265,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2921
3265
|
pi.registerTool({
|
|
2922
3266
|
name: "orchestrator_send_message",
|
|
2923
3267
|
label: "Send orchestrator message",
|
|
3268
|
+
prepareLoadout: hideBehindCodemode("orchestrator_send_message"),
|
|
2924
3269
|
renderShell: "self",
|
|
2925
3270
|
renderCall(args, theme, context) {
|
|
2926
3271
|
return outgoingMessageCall(args as { message?: unknown }, theme, context, expandHint(context.expanded));
|
|
@@ -2989,8 +3334,15 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2989
3334
|
return text(`Error: ${error instanceof Error ? error.message : String(error)}`, { error: "denied" });
|
|
2990
3335
|
}
|
|
2991
3336
|
try {
|
|
3337
|
+
// Read the sender label while ctx is live: Pi invalidates it on session replacement.
|
|
3338
|
+
const senderLabel = sanitizeDisplayLabel(ctx.sessionManager.getSessionName?.() ?? "");
|
|
2992
3339
|
const accepted = await transport.client.sendNotification(recipient, message, { signal, expectedActivation: activation, beforeConnect: () => activeTransportFor(ctx) === transport });
|
|
2993
|
-
|
|
3340
|
+
// The peer already accepted: a replaced transport or stale ctx only suppresses the
|
|
3341
|
+
// display event, never the receipt, or a retry would duplicate the message.
|
|
3342
|
+
let current = false;
|
|
3343
|
+
try { current = activeTransportFor(ctx) === transport; } catch { /* stale ctx: the session was replaced */ }
|
|
3344
|
+
if (current) emitHerdr(HERDR_DESKTOP_SEND, { sessionId: transport.sessionId, target: recipient });
|
|
3345
|
+
return text(`Message ${accepted.id} from ${transport.sessionId} to ${recipient} accepted for delivery; it is not a delivery or read receipt.`, { gentleAgents: { messageId: accepted.id, senderSessionId: transport.sessionId, recipientSessionId: recipient, state: "accepted", message, reason, senderLabel, recipientLabel: messagePeerLabel(agentHome, recipient) } });
|
|
2994
3346
|
} catch {
|
|
2995
3347
|
return text("Error: session message was not accepted.", { error: "not accepted" });
|
|
2996
3348
|
}
|
|
@@ -2998,26 +3350,26 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2998
3350
|
});
|
|
2999
3351
|
|
|
3000
3352
|
tool("list_agents", "List the subagents defined for this project and user, with their descriptions and declared tool inventory.", { properties: {} }, async (_params, ctx) => {
|
|
3001
|
-
const { agents, errors } = discoverAgents(roots(ctx));
|
|
3353
|
+
const { agents, errors, notices } = discoverAgents(roots(ctx));
|
|
3002
3354
|
const lines = agents.map((agent) => `- ${agent.name} (${agent.scope}): ${agent.description || "no description"} ${declaredToolInventory(agent)}`);
|
|
3003
|
-
const problems = errors.map((
|
|
3355
|
+
const problems = [...errors, ...notices].map((problem) => `! ${problem}`);
|
|
3004
3356
|
return text(lines.length === 0 ? "No subagents defined." : [...lines, ...problems].join("\n"));
|
|
3005
3357
|
});
|
|
3006
3358
|
|
|
3007
3359
|
tool(
|
|
3008
3360
|
"run",
|
|
3009
|
-
"Delegate a task to a named subagent.
|
|
3361
|
+
"Delegate a task to a named subagent. Admission rejects writers without repository-relative `## Allowed edit surfaces`; below the context backstop, organic writers without `Spec: odd/tasks/<existing>.md, T<n>` (2+ disjoint writers alone in one message pass) and `gentle-ai-verify` without that or `Risk: item N`.",
|
|
3010
3362
|
{
|
|
3011
3363
|
required: ["agent", "task"],
|
|
3012
3364
|
properties: {
|
|
3013
3365
|
agent: { type: "string", description: "Subagent name from subagent_list_agents." },
|
|
3014
3366
|
task: { type: "string", description: "What the subagent must do, self-contained." },
|
|
3015
|
-
label: { type: "string", description: "Three to six words naming the work
|
|
3367
|
+
label: { type: "string", description: "Three to six words naming the work for the agents card, e.g. 'map footer data sources'." },
|
|
3016
3368
|
context: { type: "string", description: "Optional extra context appended to the task." },
|
|
3017
3369
|
work: workDescriptorSchema,
|
|
3018
|
-
workspace_root: { type: "string", description: "Optional canonical main or linked Git worktree within the parent's
|
|
3019
|
-
repository_root: { type: "string", description: "Optional canonical independent Git repository;
|
|
3020
|
-
mode: { type: "string", enum: ["task", "background"], description: "task waits for the result (default); background returns
|
|
3370
|
+
workspace_root: { type: "string", description: "Optional canonical main or linked Git worktree within the parent's clone only; exclusive with repository_root." },
|
|
3371
|
+
repository_root: { type: "string", description: "Optional canonical independent Git repository; needs direct interactive session-scoped consent before queueing; exclusive with workspace_root." },
|
|
3372
|
+
mode: { type: "string", enum: ["task", "background"], description: "task waits for the result (default); background returns a task id at once." },
|
|
3021
3373
|
},
|
|
3022
3374
|
},
|
|
3023
3375
|
async (params, ctx, signal) => {
|
|
@@ -3092,11 +3444,18 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
3092
3444
|
return text(reconciledTasks.length === 0 ? "No subagent tasks in this session." : reconciledTasks.map(describeTask).join("\n"));
|
|
3093
3445
|
});
|
|
3094
3446
|
|
|
3095
|
-
tool("reply", "Reply once to a
|
|
3447
|
+
tool("reply", "Reply once to a child query; a late reply arrives as a message.", { required: ["task_id", "request_id", "message"], properties: { task_id: { type: "string" }, request_id: { type: "string" }, message: { type: "string" } } }, async (params, ctx) => {
|
|
3096
3448
|
const taskId = String(params.task_id);
|
|
3097
3449
|
const requestId = String(params.request_id);
|
|
3098
|
-
const
|
|
3099
|
-
|
|
3450
|
+
const message = typeof params.message === "string" ? params.message : "";
|
|
3451
|
+
const sessionId = ctx.sessionManager.getSessionId() ?? "";
|
|
3452
|
+
if (await runner.reply(taskId, requestId, message, sessionId)) return text("Reply accepted for delivery.");
|
|
3453
|
+
// S15 P9a: a busy parent answers after the deadline; the answer still reaches a running child.
|
|
3454
|
+
const late = runner.replyLate(taskId, requestId, message, sessionId);
|
|
3455
|
+
if (late === "delivered") return text(`Query ${requestId} had expired; the answer was delivered to task ${taskId} as a message.`);
|
|
3456
|
+
if (late === "too large") return text(`Error: the reply exceeds the ${CHILD_MESSAGE_MAX_BYTES}-byte message limit and was not delivered; query ${requestId} can still be answered with a shorter reply.`, { error: "reply too large" });
|
|
3457
|
+
if (late === "not running") return text(`Error: query ${requestId} had expired and task ${taskId} is no longer running, so the answer was not delivered. Pass it with subagent_continue.`, { error: "query expired" });
|
|
3458
|
+
return text("Error: query is unavailable.", { error: "query unavailable" });
|
|
3100
3459
|
});
|
|
3101
3460
|
|
|
3102
3461
|
tool("cancel", "Cancel a queued or running subagent task.", { required: ["task_id"], properties: { task_id: { type: "string" } } }, async (params) => {
|
|
@@ -3196,6 +3555,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
3196
3555
|
publishActivityPrompt();
|
|
3197
3556
|
});
|
|
3198
3557
|
pi.on("session_start", async (event, ctx) => {
|
|
3558
|
+
shuttingDown = false;
|
|
3199
3559
|
// gentle-shell#1064 slice 3b-ii: a parent session that has no explicit
|
|
3200
3560
|
// profile binding freezes `p → P → G` now. This handler is parent-only (a
|
|
3201
3561
|
// child returns before registering it) and runs for every reason Pi
|
|
@@ -3212,15 +3572,17 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
3212
3572
|
});
|
|
3213
3573
|
} catch { /* A launch freezes lazily through the same resolver. */ }
|
|
3214
3574
|
stateCache.load(ctx.sessionManager);
|
|
3215
|
-
// A resumed, reloaded, or replaced session starts with
|
|
3216
|
-
//
|
|
3575
|
+
// A resumed, reloaded, or replaced session starts with empty completion
|
|
3576
|
+
// and message queues so nothing pending from another session can replay here.
|
|
3217
3577
|
completions.dropAll();
|
|
3218
3578
|
messages.dropAll();
|
|
3219
|
-
|
|
3579
|
+
// Job notices remain owner-scoped and survive until their session resumes.
|
|
3220
3580
|
resetParentDelivery(ctx);
|
|
3221
3581
|
presence?.dispose();
|
|
3222
3582
|
registryFor(ctx);
|
|
3223
3583
|
showWidget(ctx);
|
|
3584
|
+
emitHerdrTasks(activeSessionId());
|
|
3585
|
+
if (activeSessionId()) emitHerdrJobs(activeSessionId()!);
|
|
3224
3586
|
// An explicit in-session /resume always brings this session's own
|
|
3225
3587
|
// finished subagents back from disk. Pi also reports "startup" (not
|
|
3226
3588
|
// "resume") when the CLI is launched directly into an existing session
|
|
@@ -3275,6 +3637,14 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
3275
3637
|
pi.on("agent_start", (_event, ctx) => rearmSessionTransport(ctx));
|
|
3276
3638
|
pi.on("turn_end", (_event, ctx) => rearmSessionTransport(ctx));
|
|
3277
3639
|
pi.on("session_shutdown", async () => {
|
|
3640
|
+
shuttingDown = true;
|
|
3641
|
+
stopAgentsStatusNotifications();
|
|
3642
|
+
// Both Desktop owner services leave the bus with the session, so a
|
|
3643
|
+
// replaced runtime is never discovered through a stale owner.
|
|
3644
|
+
unsubscribeDesktopJobsService();
|
|
3645
|
+
unsubscribeDesktopAgentsService();
|
|
3646
|
+
unsubscribeHerdrTasks();
|
|
3647
|
+
herdrQueries.clear();
|
|
3278
3648
|
completions.dropAll();
|
|
3279
3649
|
messages.dropAll();
|
|
3280
3650
|
// No stale busy may survive the runtime.
|