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
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
// idle using `deliverAs: "steer"`.
|
|
14
14
|
|
|
15
15
|
export const STALE_NOTIFICATION_MS = 90_000;
|
|
16
|
+
/** Appended to a query that expired before the parent's turn boundary. */
|
|
17
|
+
export const EXPIRED_QUERY_LINE = "This query expired before it reached you; a reply is delivered to the task as a message.";
|
|
16
18
|
|
|
17
19
|
export type AgentMessageKind = "notification" | "query";
|
|
18
20
|
|
|
@@ -50,6 +52,10 @@ export interface AgentMessageQueue {
|
|
|
50
52
|
/** Mark a query as expired (timed out or errored). Prevents delivery. */
|
|
51
53
|
expireQuery(taskId: string, requestId: string): void;
|
|
52
54
|
|
|
55
|
+
/** A query that timed out: one the parent never saw is still delivered once,
|
|
56
|
+
* marked expired, so a late reply can reach the task; otherwise like expireQuery. */
|
|
57
|
+
markQueryExpired(taskId: string, requestId: string): void;
|
|
58
|
+
|
|
53
59
|
/** Invalidate all pending messages (notifications and queries) for a settled or cancelled task. */
|
|
54
60
|
invalidateTask(taskId: string): void;
|
|
55
61
|
|
|
@@ -139,6 +145,17 @@ export function createAgentMessageQueue(): AgentMessageQueue {
|
|
|
139
145
|
pending = pending.filter((msg) => !(msg.kind === "query" && msg.taskId === taskId && msg.requestId === requestId));
|
|
140
146
|
},
|
|
141
147
|
|
|
148
|
+
markQueryExpired(taskId, requestId) {
|
|
149
|
+
const queued = pending.find((msg) => msg.kind === "query" && msg.taskId === taskId && msg.requestId === requestId);
|
|
150
|
+
if (!queued) {
|
|
151
|
+
expiredQueries.add(queryKey(taskId, requestId));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (queued.details.gentleAgents && (queued.details.gentleAgents as { expired?: boolean }).expired) return;
|
|
155
|
+
queued.content = `${queued.content}\n${EXPIRED_QUERY_LINE}`;
|
|
156
|
+
queued.details = { gentleAgents: { ...(queued.details.gentleAgents as Record<string, unknown>), expired: true } };
|
|
157
|
+
},
|
|
158
|
+
|
|
142
159
|
invalidateTask(taskId) {
|
|
143
160
|
invalidatedTasks.add(taskId);
|
|
144
161
|
pending = pending.filter((msg) => msg.taskId !== taskId);
|
package/lib/agents-messaging.ts
CHANGED
|
@@ -4,7 +4,13 @@ export const CHILD_QUERY_ERROR_MAX_BYTES = 256;
|
|
|
4
4
|
export const CHILD_MESSAGE_MAX_INFLIGHT = 8;
|
|
5
5
|
export const CHILD_MESSAGE_TIMEOUT_MS = 2_000;
|
|
6
6
|
export const CHILD_QUERY_MAX_INFLIGHT = 4;
|
|
7
|
-
|
|
7
|
+
// A busy parent answers after its current model call and tool batch, which
|
|
8
|
+
// routinely takes one to two minutes. The child's query is an in-flight tool
|
|
9
|
+
// call meanwhile, so the stall watchdog applies its tool ceiling, not idle silence.
|
|
10
|
+
export const CHILD_QUERY_TIMEOUT_MS = 120_000;
|
|
11
|
+
// What the child reads when the deadline passes; both the child's own deadline
|
|
12
|
+
// and the runner's reply frame use it, so it must fit CHILD_QUERY_ERROR_MAX_BYTES.
|
|
13
|
+
export const CHILD_QUERY_TIMEOUT_ERROR = "Parent query timed out: the parent did not answer in time. A late answer may still arrive as a message; continue with work that does not depend on it and state the open question in your report.";
|
|
8
14
|
|
|
9
15
|
export interface NotificationFrame {
|
|
10
16
|
id: string;
|
|
@@ -182,7 +188,7 @@ export class ChildMessenger {
|
|
|
182
188
|
if (!validChildMessage(message)) return Promise.reject(new Error("query is not well-formed UTF-16 or exceeds 8KiB"));
|
|
183
189
|
if (this.queries.size >= CHILD_QUERY_MAX_INFLIGHT) return Promise.reject(new Error("too many pending parent queries"));
|
|
184
190
|
if (this.nextQueryId >= Number.MAX_SAFE_INTEGER) return Promise.reject(new Error("parent query correlation exhausted"));
|
|
185
|
-
return this.send(this.queries, `q${++this.nextQueryId}`, "query", message, CHILD_QUERY_TIMEOUT_MS,
|
|
191
|
+
return this.send(this.queries, `q${++this.nextQueryId}`, "query", message, CHILD_QUERY_TIMEOUT_MS, CHILD_QUERY_TIMEOUT_ERROR);
|
|
186
192
|
}
|
|
187
193
|
|
|
188
194
|
close(reason = "parent notification channel closed"): void {
|
package/lib/agents-protocol.ts
CHANGED
|
@@ -126,6 +126,19 @@ export interface TaskThread {
|
|
|
126
126
|
limits: ThreadLimits;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Per-helper token breakdown accumulated from the final-assistant observations
|
|
131
|
+
* the runner delivers at completion. Absent while a task is in flight: the
|
|
132
|
+
* runner only releases that breakdown once the run settled.
|
|
133
|
+
*/
|
|
134
|
+
export interface TaskUsage {
|
|
135
|
+
input: number;
|
|
136
|
+
output: number;
|
|
137
|
+
cacheRead: number;
|
|
138
|
+
cacheWrite: number;
|
|
139
|
+
reasoning: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
129
142
|
export interface TaskRecord {
|
|
130
143
|
/** Retained legacy payload, never interpreted or replayed as launch authority. */
|
|
131
144
|
sddRemediation?: unknown;
|
|
@@ -137,6 +150,8 @@ export interface TaskRecord {
|
|
|
137
150
|
prompt: string;
|
|
138
151
|
/** One line for the card: what the subagent is doing. */
|
|
139
152
|
label: string;
|
|
153
|
+
/** Explicit, normalized label only; unlike label, never derived from the prompt. */
|
|
154
|
+
explicitLabel?: string;
|
|
140
155
|
cwd: string;
|
|
141
156
|
parentSessionId: string;
|
|
142
157
|
status: TaskStatus;
|
|
@@ -159,6 +174,8 @@ export interface TaskRecord {
|
|
|
159
174
|
toolCalls: number;
|
|
160
175
|
tokens: number;
|
|
161
176
|
cost: number;
|
|
177
|
+
/** Final-assistant token breakdown, recorded by the owner at completion. */
|
|
178
|
+
usage?: TaskUsage;
|
|
162
179
|
}
|
|
163
180
|
|
|
164
181
|
export interface TaskSummary {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Gentle Agents report cap (P9b).
|
|
2
|
+
//
|
|
3
|
+
// A finished child's report is pushed into the parent's conversation (the
|
|
4
|
+
// background completion message, or the task-mode subagent_run and
|
|
5
|
+
// subagent_continue result) and stays there for the rest of the session.
|
|
6
|
+
// This module bounds that delivered copy only: the stored task result, the
|
|
7
|
+
// task file, and subagent_result keep the full text. Under the cap the report
|
|
8
|
+
// is returned unchanged, so every path stays byte-identical.
|
|
9
|
+
|
|
10
|
+
export const DEFAULT_REPORT_MAX_BYTES = 16_384;
|
|
11
|
+
/** A cut moves to a line boundary when one lies within this many bytes of it (see lineWindowBytes). */
|
|
12
|
+
export const REPORT_LINE_WINDOW_BYTES = 512;
|
|
13
|
+
/** Over the cap, the last bytes of the report (at most this many) follow the truncation line. */
|
|
14
|
+
export const REPORT_TAIL_BYTES = 2_048;
|
|
15
|
+
|
|
16
|
+
/** The line-boundary search window for a cut of `budget` bytes: at most 512, and at most a quarter of the budget, so a small cap cannot shrink a cut to a few bytes. */
|
|
17
|
+
export const lineWindowBytes = (budget: number): number => Math.min(REPORT_LINE_WINDOW_BYTES, budget >> 2);
|
|
18
|
+
|
|
19
|
+
export interface CappedReport {
|
|
20
|
+
text: string;
|
|
21
|
+
truncated: boolean;
|
|
22
|
+
reportBytes: number;
|
|
23
|
+
deliveredBytes: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const encoder = new TextEncoder();
|
|
27
|
+
const utf8Bytes = (value: string): number => encoder.encode(value).length;
|
|
28
|
+
|
|
29
|
+
// Byte length of one code point as TextEncoder writes it; a lone surrogate
|
|
30
|
+
// becomes U+FFFD (3 bytes), and a pair is one 4-byte code point.
|
|
31
|
+
function codePointBytes(codePoint: number): number {
|
|
32
|
+
if (codePoint < 0x80) return 1;
|
|
33
|
+
if (codePoint < 0x800) return 2;
|
|
34
|
+
if (codePoint < 0x10000) return 3;
|
|
35
|
+
return 4;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The longest prefix of `value` whose UTF-8 encoding fits `maxBytes`, never splitting a code point or a surrogate pair. */
|
|
39
|
+
export function utf8Head(value: string, maxBytes: number): string {
|
|
40
|
+
let bytes = 0;
|
|
41
|
+
let end = 0;
|
|
42
|
+
for (const char of value) {
|
|
43
|
+
const size = codePointBytes(char.codePointAt(0)!);
|
|
44
|
+
if (bytes + size > maxBytes) break;
|
|
45
|
+
bytes += size;
|
|
46
|
+
end += char.length;
|
|
47
|
+
}
|
|
48
|
+
return value.slice(0, end);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The longest suffix of `value` whose UTF-8 encoding fits `maxBytes`, never splitting a code point or a surrogate pair. */
|
|
52
|
+
export function utf8Tail(value: string, maxBytes: number): string {
|
|
53
|
+
let bytes = 0;
|
|
54
|
+
let start = value.length;
|
|
55
|
+
while (start > 0) {
|
|
56
|
+
const low = value.charCodeAt(start - 1);
|
|
57
|
+
const pair = start >= 2 && low >= 0xdc00 && low <= 0xdfff && value.charCodeAt(start - 2) >= 0xd800 && value.charCodeAt(start - 2) <= 0xdbff;
|
|
58
|
+
const size = pair ? 4 : codePointBytes(low);
|
|
59
|
+
if (bytes + size > maxBytes) break;
|
|
60
|
+
bytes += size;
|
|
61
|
+
start -= pair ? 2 : 1;
|
|
62
|
+
}
|
|
63
|
+
return value.slice(start);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Agents whose whole answer must be one JSON document: the Judgment Day roles (`jd-*`) and the review lens
|
|
67
|
+
// roles (`review-*`). The same rule as STRICT_JSON_PREFIX in the delegation contract test, which keeps the
|
|
68
|
+
// closing-block instruction out of these agents.
|
|
69
|
+
const STRICT_JSON_AGENT = /^(jd-|review-)/;
|
|
70
|
+
export const isStrictJsonAgent = (agent: string): boolean => STRICT_JSON_AGENT.test(agent);
|
|
71
|
+
|
|
72
|
+
// One valid JSON object or array after trimming, optionally inside one fenced block: cutting it would
|
|
73
|
+
// deliver invalid JSON, so it is never truncated.
|
|
74
|
+
function singleJsonDocument(report: string): boolean {
|
|
75
|
+
const body = report.trim().replace(/^```[\w-]*\n([\s\S]*)\n```$/, "$1").trim();
|
|
76
|
+
if (!/^[[{]/.test(body)) return false;
|
|
77
|
+
try { JSON.parse(body); return true; } catch { return false; }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// The head: up to `maxBytes`, moved back to the last line break when one lies in the final window.
|
|
81
|
+
function head(source: string, maxBytes: number): string {
|
|
82
|
+
const cut = utf8Head(source, maxBytes);
|
|
83
|
+
const newline = cut.lastIndexOf("\n");
|
|
84
|
+
return newline >= 0 && utf8Bytes(cut.slice(newline)) <= lineWindowBytes(maxBytes) ? cut.slice(0, newline) : cut;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The tail: the last REPORT_TAIL_BYTES at most, starting after the first line break in the opening window
|
|
88
|
+
// when there is one, otherwise at a code point boundary. The text is not inspected beyond line breaks.
|
|
89
|
+
function tail(source: string): string {
|
|
90
|
+
const cut = utf8Tail(source, REPORT_TAIL_BYTES);
|
|
91
|
+
const newline = cut.indexOf("\n");
|
|
92
|
+
return newline >= 0 && utf8Bytes(cut.slice(0, newline + 1)) <= lineWindowBytes(REPORT_TAIL_BYTES) ? cut.slice(newline + 1) : cut;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Bound the report delivered into the parent's context: its head, a truncation line, then the end of the report. The full text stays available through subagent_result. */
|
|
96
|
+
export function capReport(report: string, maxBytes: number, taskId: string, agent = ""): CappedReport {
|
|
97
|
+
const reportBytes = utf8Bytes(report);
|
|
98
|
+
const whole = { text: report, truncated: false, reportBytes, deliveredBytes: reportBytes };
|
|
99
|
+
if (reportBytes <= maxBytes || isStrictJsonAgent(agent) || singleJsonDocument(report)) return whole;
|
|
100
|
+
const first = head(report, maxBytes);
|
|
101
|
+
const firstBytes = utf8Bytes(first);
|
|
102
|
+
// What the head leaves out fits the tail allowance: deliver everything, so head and tail never overlap.
|
|
103
|
+
if (reportBytes - firstBytes <= REPORT_TAIL_BYTES) return whole;
|
|
104
|
+
const last = tail(report);
|
|
105
|
+
const lastBytes = utf8Bytes(last);
|
|
106
|
+
const notice = `Report truncated: the first ${firstBytes} and the last ${lastBytes} of ${reportBytes} bytes were delivered. Call subagent_result with task_id ${taskId} for the full text.`;
|
|
107
|
+
return { text: `${first}\n\n${notice}\n\n${last}`, truncated: true, reportBytes, deliveredBytes: firstBytes + lastBytes };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Additive details for the UI: the existing fields stay as they are, and nothing is added under the cap. */
|
|
111
|
+
export function withReportCap(details: Record<string, unknown>, capped: CappedReport): Record<string, unknown> {
|
|
112
|
+
if (!capped.truncated) return details;
|
|
113
|
+
const agents = (details.gentleAgents ?? {}) as Record<string, unknown>;
|
|
114
|
+
return { ...details, gentleAgents: { ...agents, reportTruncated: true, reportBytes: capped.reportBytes, reportDeliveredBytes: capped.deliveredBytes } };
|
|
115
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFinished, THREAD_ITEM, TASK_STATUS, type TaskRecord, type TaskStatus, type TaskStore, type TaskSummary, type ThreadItem } from "./agents-protocol.ts";
|
|
1
|
+
import { isFinished, THREAD_ITEM, TASK_STATUS, type TaskRecord, type TaskStatus, type TaskStore, type TaskSummary, type TaskThread, type ThreadItem } from "./agents-protocol.ts";
|
|
2
2
|
|
|
3
3
|
// Publishes live Gentle Agents subagent state to an interactive RPC host
|
|
4
4
|
// (the desktop app), the RPC equivalent of the above-editor TUI card. Pi's
|
|
@@ -18,14 +18,14 @@ export const ACTIVITY_WIDGET_KEY = "gentle-agents";
|
|
|
18
18
|
/** Prompts are the field most likely to carry a long user request; keep only a preview. */
|
|
19
19
|
const PROMPT_LIMIT = 200;
|
|
20
20
|
/** Tool args/output can be arbitrarily large; bound each independently. */
|
|
21
|
-
const TOOL_ARGS_LIMIT = 500;
|
|
22
|
-
const TOOL_OUTPUT_LIMIT = 500;
|
|
21
|
+
export const TOOL_ARGS_LIMIT = 500;
|
|
22
|
+
export const TOOL_OUTPUT_LIMIT = 500;
|
|
23
23
|
/** Text/thinking/note thread item text can be arbitrarily large (a whole streamed reply); bound it too. */
|
|
24
|
-
const TEXT_ITEM_LIMIT = 2000;
|
|
24
|
+
export const TEXT_ITEM_LIMIT = 2000;
|
|
25
25
|
/** Summary fields that can carry a long, freeform diagnostic or step name. */
|
|
26
26
|
const SUMMARY_FIELD_LIMIT = 500;
|
|
27
27
|
/** Thread items kept per task in one push, most recent last. */
|
|
28
|
-
const DEFAULT_THREAD_ITEMS = 40;
|
|
28
|
+
export const DEFAULT_THREAD_ITEMS = 40;
|
|
29
29
|
/** Total payload bound before shrinking kicks in. */
|
|
30
30
|
export const DEFAULT_MAX_BYTES = 256 * 1024;
|
|
31
31
|
/** How long a burst of task/summary changes is coalesced before one push. */
|
|
@@ -93,7 +93,7 @@ function safeStringify(value: unknown): string {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
function projectThreadItem(item: ThreadItem): RpcThreadItem {
|
|
96
|
+
export function projectThreadItem(item: ThreadItem): RpcThreadItem {
|
|
97
97
|
if (item.kind === THREAD_ITEM.TOOL) {
|
|
98
98
|
return {
|
|
99
99
|
kind: item.kind,
|
|
@@ -125,6 +125,17 @@ function projectTaskSummary(task: TaskRecord): RpcTaskSummary {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* The bounded thread projection one task carries in `gentle-agents.activity/v1`:
|
|
130
|
+
* the store's `version` and `dropped` verbatim and the last `maxThreadItems`
|
|
131
|
+
* items, each through `projectThreadItem`. Shared by the widget and Desktop
|
|
132
|
+
* RPC's `get_subagent_thread`, so the two never disagree.
|
|
133
|
+
*/
|
|
134
|
+
export function projectRpcThread(thread: TaskThread, maxThreadItems: number = DEFAULT_THREAD_ITEMS): RpcThread {
|
|
135
|
+
const kept = maxThreadItems >= thread.items.length ? thread.items : thread.items.slice(thread.items.length - maxThreadItems);
|
|
136
|
+
return { version: thread.version, dropped: thread.dropped, items: kept.map(projectThreadItem) };
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
/** Ordering rank: running, then waiting, then queued, ahead of every finished status. */
|
|
129
140
|
const STATUS_RANK: Partial<Record<TaskStatus, number>> = {
|
|
130
141
|
[TASK_STATUS.RUNNING]: 0,
|
|
@@ -159,9 +170,7 @@ export function projectRpcActivity(store: TaskStore, opts: ProjectRpcActivityOpt
|
|
|
159
170
|
schema: ACTIVITY_SCHEMA,
|
|
160
171
|
summary: store.summary(parentSessionId),
|
|
161
172
|
tasks: tasks.map((task) => {
|
|
162
|
-
|
|
163
|
-
const kept = maxThreadItems >= thread.items.length ? thread.items : thread.items.slice(thread.items.length - maxThreadItems);
|
|
164
|
-
return { summary: projectTaskSummary(task), thread: { version: thread.version, dropped: thread.dropped, items: kept.map(projectThreadItem) } };
|
|
173
|
+
return { summary: projectTaskSummary(task), thread: projectRpcThread(store.thread(task.id), maxThreadItems) };
|
|
165
174
|
}),
|
|
166
175
|
};
|
|
167
176
|
}
|
|
@@ -170,10 +179,28 @@ function byteLength(value: string): number {
|
|
|
170
179
|
return Buffer.byteLength(value, "utf8");
|
|
171
180
|
}
|
|
172
181
|
|
|
182
|
+
/** Keep the most recent half of a thread's items (never fewer than one). */
|
|
183
|
+
function halveRpcThread(thread: RpcThread): RpcThread {
|
|
184
|
+
if (thread.items.length <= 1) return thread;
|
|
185
|
+
const nextLength = Math.max(1, Math.floor(thread.items.length / 2));
|
|
186
|
+
return { ...thread, items: thread.items.slice(thread.items.length - nextLength) };
|
|
187
|
+
}
|
|
188
|
+
|
|
173
189
|
function halveThreadItems(task: RpcTask): RpcTask {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
190
|
+
const thread = halveRpcThread(task.thread);
|
|
191
|
+
return thread === task.thread ? task : { ...task, thread };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Bounds one projected thread under `maxBytes` with the same first shrinking
|
|
196
|
+
* step `encodeActivityLines` applies per task: halve the kept items, most
|
|
197
|
+
* recent last, down to one item. Never throws; a single item that still does
|
|
198
|
+
* not fit is returned as-is (each item is already bounded by its field limits).
|
|
199
|
+
*/
|
|
200
|
+
export function boundRpcThread(thread: RpcThread, maxBytes: number = DEFAULT_MAX_BYTES): RpcThread {
|
|
201
|
+
let working = thread;
|
|
202
|
+
while (working.items.length > 1 && byteLength(JSON.stringify(working)) > maxBytes) working = halveRpcThread(working);
|
|
203
|
+
return working;
|
|
177
204
|
}
|
|
178
205
|
|
|
179
206
|
function emptyFinishedThread(task: RpcTask): RpcTask {
|
package/lib/agents-runner.ts
CHANGED
|
@@ -5,15 +5,16 @@ import { isSessionChangeEvidence, type SessionChangeEvidence } from "./session-c
|
|
|
5
5
|
import { chmodSync, existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { DefaultPackageManager, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { tmpdir, userInfo } from "node:os";
|
|
8
|
-
import { dirname, isAbsolute, join, resolve, win32 } from "node:path";
|
|
8
|
+
import { basename, dirname, isAbsolute, join, resolve, win32 } from "node:path";
|
|
9
9
|
import { Duplex, type Readable, type Writable } from "node:stream";
|
|
10
10
|
import { stripVTControlCharacters } from "node:util";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
11
12
|
import { withoutInteractiveHost } from "./rpc-host.ts";
|
|
12
13
|
import { gentlePiConfigHome } from "./agent-home.ts";
|
|
13
14
|
import { resolveBackgroundSubagentsPolicy } from "./background-subagents-policy.ts";
|
|
14
15
|
import { childPackageExtensionArgs } from "./child-package-injection.ts";
|
|
15
16
|
import { AGENT_MODE, formatModelRef, parseModelRef, type AgentDefinition, type AgentMode, type ModelRef } from "./agents-config.ts";
|
|
16
|
-
import { CHILD_QUERY_MAX_INFLIGHT, CHILD_QUERY_TIMEOUT_MS, parseChildFrame, parseChildJobState, validChildMessage, validChildQueryId } from "./agents-messaging.ts";
|
|
17
|
+
import { CHILD_MESSAGE_MAX_BYTES, CHILD_QUERY_MAX_INFLIGHT, CHILD_QUERY_TIMEOUT_ERROR, CHILD_QUERY_TIMEOUT_MS, parseChildFrame, parseChildJobState, validChildMessage, validChildQueryId } from "./agents-messaging.ts";
|
|
17
18
|
import { ParentStandingReviewPermissionBroker } from "./review-session-standing-permission-ipc.ts";
|
|
18
19
|
import { isFinished, normalizeRpcEvent, ToolArgumentProgress, TASK_EVENT, TASK_STATUS, taskLabel, type AskRequest, type ChildResponseObservation, type TaskRecord, type TaskStore, type TerminalErrorCategory } from "./agents-protocol.ts";
|
|
19
20
|
import { WriterSurfaceRegistry, writerSurfaceConflictMessage } from "./writer-surfaces.ts";
|
|
@@ -202,6 +203,8 @@ interface Pending {
|
|
|
202
203
|
interface PendingQuery {
|
|
203
204
|
cancel: () => void;
|
|
204
205
|
replying: boolean;
|
|
206
|
+
/** When the query expires; the stall watchdog never fires before it. */
|
|
207
|
+
deadline: number;
|
|
205
208
|
}
|
|
206
209
|
|
|
207
210
|
interface PendingReply {
|
|
@@ -222,6 +225,8 @@ interface LiveTask {
|
|
|
222
225
|
queries: Map<string, PendingQuery>;
|
|
223
226
|
replies: Map<string, PendingReply>;
|
|
224
227
|
cancelStall: () => void;
|
|
228
|
+
/** True while the armed stall budget was lengthened to cover a pending query. */
|
|
229
|
+
stallCoversQuery?: boolean;
|
|
225
230
|
cancelGrace: () => void;
|
|
226
231
|
processGroup: number | undefined;
|
|
227
232
|
terminal: { status: TaskRecord["status"]; error: string | null } | undefined;
|
|
@@ -266,6 +271,8 @@ export const CHILD_JOBS_ENV = "GENTLE_PI_AGENTS_CHILD_JOBS";
|
|
|
266
271
|
const PARENT_NOTIFICATION_TOOL = "subagent_parent_message";
|
|
267
272
|
/** The exact --tools list, so the child can report requested names Pi dropped silently (#1690). */
|
|
268
273
|
export const REQUESTED_TOOLS_ENV = "GENTLE_PI_AGENTS_REQUESTED_TOOLS";
|
|
274
|
+
/** Set only for the package-owned generic agents: the child drops Pi's skills catalog. */
|
|
275
|
+
export const CHILD_SKILLS_CATALOG_ENV = "GENTLE_PI_AGENTS_NO_SKILLS_CATALOG";
|
|
269
276
|
const DEFAULT_TOOLS: readonly string[] = [];
|
|
270
277
|
const TERMINATION_GRACE_MS = 250;
|
|
271
278
|
const GROUP_CONFIRM_MS = 25;
|
|
@@ -284,10 +291,25 @@ const QUERY_REJECTION_ERRORS = new Set([
|
|
|
284
291
|
"task parent is not the active host session",
|
|
285
292
|
"duplicate query request",
|
|
286
293
|
"too many pending parent queries",
|
|
287
|
-
|
|
294
|
+
CHILD_QUERY_TIMEOUT_ERROR,
|
|
288
295
|
"parent rejected query",
|
|
289
296
|
]);
|
|
290
297
|
const QUERY_REJECTION = Symbol("query rejection");
|
|
298
|
+
// Queries that settled unanswered (expired or closed) stay answerable once as a
|
|
299
|
+
// steering message; bounded per task and across tasks.
|
|
300
|
+
const CLOSED_QUERIES_PER_TASK = 16;
|
|
301
|
+
const CLOSED_QUERY_TASKS = 64;
|
|
302
|
+
// A child waiting on its query is not stalled: the watchdog waits for the
|
|
303
|
+
// query's own deadline plus this margin, then the normal budget returns.
|
|
304
|
+
export const QUERY_STALL_MARGIN_MS = 5_000;
|
|
305
|
+
|
|
306
|
+
/** What a late answer to a closed query became; see `AgentRunner.replyLate`. */
|
|
307
|
+
export type LateReply = "delivered" | "not running" | "too large";
|
|
308
|
+
|
|
309
|
+
/** The steering text a late answer reaches the child with. */
|
|
310
|
+
export function lateQueryAnswer(requestId: string, message: string): string {
|
|
311
|
+
return `Answer to your earlier question (${requestId}; it expired before the reply arrived): ${message}`;
|
|
312
|
+
}
|
|
291
313
|
|
|
292
314
|
function rejectQuery(error: string): never {
|
|
293
315
|
throw { [QUERY_REJECTION]: error };
|
|
@@ -340,6 +362,18 @@ function requestedWebPackagePaths(request: TaskRequest): string[] {
|
|
|
340
362
|
}
|
|
341
363
|
}
|
|
342
364
|
|
|
365
|
+
// The package-owned generic agents receive the exact skill paths they need in
|
|
366
|
+
// the task and read them with `read`, so their children drop Pi's skills
|
|
367
|
+
// catalog (extensions/child-context.ts). Identified by name plus the global
|
|
368
|
+
// `agents/` directory the package installs into; a project or `subagents/`
|
|
369
|
+
// agent reusing a name keeps the catalog.
|
|
370
|
+
const NO_SKILLS_CATALOG_AGENTS = new Set(["gentle-ai-worker", "gentle-ai-explore", "gentle-ai-verify"]);
|
|
371
|
+
|
|
372
|
+
function dropsSkillsCatalog(agent: TaskRequest["agent"]): boolean {
|
|
373
|
+
return NO_SKILLS_CATALOG_AGENTS.has(agent.name) && agent.scope === "global" &&
|
|
374
|
+
basename(dirname(agent.filePath)) === "agents" && basename(agent.filePath) === `${agent.name}.md`;
|
|
375
|
+
}
|
|
376
|
+
|
|
343
377
|
export function childArguments(request: TaskRequest, instructionsPath?: string): string[] {
|
|
344
378
|
const args = ["--mode", "rpc", "--session-dir", request.sessionDir];
|
|
345
379
|
const extensionPaths = [...new Set(request.extensionPaths ?? [])];
|
|
@@ -526,6 +560,7 @@ export class AgentRunner {
|
|
|
526
560
|
private readonly waiters = new Map<string, Array<(task: TaskRecord) => void>>();
|
|
527
561
|
private readonly queryWaiters = new Map<string, Array<(query: TaskQuery | undefined) => void>>();
|
|
528
562
|
private readonly firstQueries = new Map<string, TaskQuery>();
|
|
563
|
+
private readonly closedQueries = new Map<string, string[]>();
|
|
529
564
|
private readonly writers = new WriterSurfaceRegistry();
|
|
530
565
|
private counter = 0;
|
|
531
566
|
|
|
@@ -546,6 +581,7 @@ export class AgentRunner {
|
|
|
546
581
|
mode: request.mode,
|
|
547
582
|
prompt: request.prompt,
|
|
548
583
|
label: taskLabel(request.prompt, request.label),
|
|
584
|
+
explicitLabel: taskLabel("", request.label) || undefined,
|
|
549
585
|
cwd: request.cwd,
|
|
550
586
|
parentSessionId: request.parentSessionId,
|
|
551
587
|
status: TASK_STATUS.QUEUED,
|
|
@@ -619,10 +655,34 @@ export class AgentRunner {
|
|
|
619
655
|
query.cancel();
|
|
620
656
|
live.queries.delete(requestId);
|
|
621
657
|
this.hooks.onQuerySettled?.(id, requestId, "replied");
|
|
658
|
+
this.restoreStall(id, live);
|
|
622
659
|
}
|
|
623
660
|
return accepted;
|
|
624
661
|
}
|
|
625
662
|
|
|
663
|
+
/** A reply to a query that settled unanswered: delivered once through `steer`
|
|
664
|
+
* while the task runs; otherwise reported as not running. Undefined when the
|
|
665
|
+
* request was never a closed query of this owner, or was already answered. */
|
|
666
|
+
replyLate(id: string, requestId: string, message: string, parentSessionId: string): LateReply | undefined {
|
|
667
|
+
const task = this.store.get(id);
|
|
668
|
+
const closed = this.closedQueries.get(id);
|
|
669
|
+
if (!task || task.parentSessionId !== parentSessionId || !closed?.includes(requestId)) return undefined;
|
|
670
|
+
// Too large is reported, not consumed: a shorter answer can still go.
|
|
671
|
+
if (Buffer.byteLength(message, "utf8") > CHILD_MESSAGE_MAX_BYTES) return "too large";
|
|
672
|
+
if (!validChildMessage(message)) return undefined;
|
|
673
|
+
closed.splice(closed.indexOf(requestId), 1);
|
|
674
|
+
const live = this.live.get(id);
|
|
675
|
+
if (!live || live.terminal || isFinished(task.status)) return "not running";
|
|
676
|
+
return this.steer(id, lateQueryAnswer(requestId, message)) ? "delivered" : "not running";
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
private recordClosedQuery(taskId: string, requestId: string): void {
|
|
680
|
+
const closed = this.closedQueries.get(taskId) ?? [];
|
|
681
|
+
this.closedQueries.delete(taskId);
|
|
682
|
+
this.closedQueries.set(taskId, [...closed.filter((id) => id !== requestId), requestId].slice(-CLOSED_QUERIES_PER_TASK));
|
|
683
|
+
if (this.closedQueries.size > CLOSED_QUERY_TASKS) this.closedQueries.delete(this.closedQueries.keys().next().value!);
|
|
684
|
+
}
|
|
685
|
+
|
|
626
686
|
cancel(id: string, reason = "cancelled"): boolean {
|
|
627
687
|
const queued = this.queue.findIndex((entry) => entry.task.id === id);
|
|
628
688
|
if (queued >= 0) {
|
|
@@ -688,6 +748,8 @@ export class AgentRunner {
|
|
|
688
748
|
// Do not forward stale legacy child selection or authorization.
|
|
689
749
|
delete env.GENTLE_PI_SDD_REMEDIATION_PLAN;
|
|
690
750
|
delete env.GENTLE_PI_RESEARCH_SELECTION;
|
|
751
|
+
if (request.agent.name === "gentle-ai-verify") env.GENTLE_PI_VERIFIER_PREPARER = fileURLToPath(new URL("../scripts/prepare-verifier.mjs", import.meta.url));
|
|
752
|
+
else delete env.GENTLE_PI_VERIFIER_PREPARER;
|
|
691
753
|
const tools = requestedTools(request);
|
|
692
754
|
if (request.agent.tools.includes("bash_background")) {
|
|
693
755
|
const policy = resolveBackgroundSubagentsPolicy(request.cwd, { env: request.env, gentlePiConfigHome: gentlePiConfigHome(request.env) });
|
|
@@ -703,6 +765,8 @@ export class AgentRunner {
|
|
|
703
765
|
} else delete env[CHILD_JOBS_ENV];
|
|
704
766
|
if (tools !== undefined) env[REQUESTED_TOOLS_ENV] = tools;
|
|
705
767
|
else delete env[REQUESTED_TOOLS_ENV];
|
|
768
|
+
if (dropsSkillsCatalog(request.agent)) env[CHILD_SKILLS_CATALOG_ENV] = "1";
|
|
769
|
+
else delete env[CHILD_SKILLS_CATALOG_ENV];
|
|
706
770
|
let instructionsTransportDir: string | undefined;
|
|
707
771
|
let instructionsTransportPath: string | undefined;
|
|
708
772
|
if (Buffer.byteLength(request.agent.instructions, "utf8") > MAX_INLINE_INSTRUCTIONS_BYTES) {
|
|
@@ -850,7 +914,12 @@ export class AgentRunner {
|
|
|
850
914
|
private armStall(id: string, live: LiveTask): void {
|
|
851
915
|
live.cancelStall();
|
|
852
916
|
const tool = live.inFlightTools.values().next().value;
|
|
853
|
-
const
|
|
917
|
+
const base = tool === undefined ? this.limits.stallTimeoutMs : Math.max(this.limits.toolStallTimeoutMs ?? this.limits.stallTimeoutMs, this.limits.stallTimeoutMs);
|
|
918
|
+
const now = this.deps.now();
|
|
919
|
+
let queryWait = 0;
|
|
920
|
+
for (const query of live.queries.values()) queryWait = Math.max(queryWait, query.deadline - now + QUERY_STALL_MARGIN_MS);
|
|
921
|
+
const budget = Math.max(base, queryWait);
|
|
922
|
+
live.stallCoversQuery = budget > base;
|
|
854
923
|
live.cancelStall = this.deps.schedule(() => {
|
|
855
924
|
const lastStep = this.store.get(id)?.lastStep ?? "starting";
|
|
856
925
|
const minutes = Math.round(budget / 60_000);
|
|
@@ -996,8 +1065,12 @@ export class AgentRunner {
|
|
|
996
1065
|
try {
|
|
997
1066
|
if (live.queries.has(parsed.frame.id)) rejectQuery("duplicate query request");
|
|
998
1067
|
if (live.queries.size >= CHILD_QUERY_MAX_INFLIGHT) rejectQuery("too many pending parent queries");
|
|
999
|
-
query = { replying: false,
|
|
1068
|
+
query = { replying: false, deadline: this.deps.now() + CHILD_QUERY_TIMEOUT_MS, cancel: () => {} };
|
|
1000
1069
|
live.queries.set(parsed.frame.id, query);
|
|
1070
|
+
// Lengthen the stall budget first, so the query's own deadline stays the last timer armed.
|
|
1071
|
+
this.armStall(id, live);
|
|
1072
|
+
const admitted = query;
|
|
1073
|
+
admitted.cancel = this.deps.schedule(() => this.expireQuery(id, live, parsed.frame!.id), CHILD_QUERY_TIMEOUT_MS);
|
|
1001
1074
|
if (!this.hooks.onQuery) rejectQuery("task parent cannot accept queries");
|
|
1002
1075
|
if (this.hooks.onQuery(task, parsed.frame.id, parsed.frame.message) === false) rejectQuery("task parent is not the active host session");
|
|
1003
1076
|
if (task.mode === AGENT_MODE.TASK && !this.firstQueries.has(id)) {
|
|
@@ -1010,6 +1083,7 @@ export class AgentRunner {
|
|
|
1010
1083
|
if (query && live.queries.get(parsed.frame.id) === query) {
|
|
1011
1084
|
query.cancel();
|
|
1012
1085
|
live.queries.delete(parsed.frame.id);
|
|
1086
|
+
this.restoreStall(id, live);
|
|
1013
1087
|
}
|
|
1014
1088
|
this.sendQueryError(live, parsed.frame.id, queryRejection(error));
|
|
1015
1089
|
}
|
|
@@ -1021,7 +1095,16 @@ export class AgentRunner {
|
|
|
1021
1095
|
live.queries.delete(id);
|
|
1022
1096
|
this.hooks.onQuerySettled?.(taskId, id, "expired");
|
|
1023
1097
|
if (query.replying) this.settleReply(live, id, false);
|
|
1024
|
-
else
|
|
1098
|
+
else {
|
|
1099
|
+
this.recordClosedQuery(taskId, id);
|
|
1100
|
+
this.sendQueryError(live, id, CHILD_QUERY_TIMEOUT_ERROR);
|
|
1101
|
+
}
|
|
1102
|
+
this.restoreStall(taskId, live);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/** After a query settles, a stall budget lengthened for it returns to normal. */
|
|
1106
|
+
private restoreStall(taskId: string, live: LiveTask): void {
|
|
1107
|
+
if (live.stallCoversQuery && !live.terminal && this.live.get(taskId) === live) this.armStall(taskId, live);
|
|
1025
1108
|
}
|
|
1026
1109
|
|
|
1027
1110
|
private sendQueryError(live: LiveTask, id: string, error: string): void {
|
|
@@ -1059,8 +1142,11 @@ export class AgentRunner {
|
|
|
1059
1142
|
private closeIpc(live: LiveTask): void {
|
|
1060
1143
|
if (live.ipcClosed) return;
|
|
1061
1144
|
live.ipcClosed = true;
|
|
1145
|
+
const taskId = [...this.live].find(([, entry]) => entry === live)?.[0];
|
|
1146
|
+
for (const [requestId, query] of live.queries) if (taskId !== undefined && !query.replying) this.recordClosedQuery(taskId, requestId);
|
|
1062
1147
|
for (const query of live.queries.values()) query.cancel();
|
|
1063
1148
|
live.queries.clear();
|
|
1149
|
+
if (taskId !== undefined) this.restoreStall(taskId, live);
|
|
1064
1150
|
for (const pending of live.replies.values()) pending.resolve(false);
|
|
1065
1151
|
live.replies.clear();
|
|
1066
1152
|
live.child.channel?.unref?.();
|
|
@@ -184,7 +184,23 @@ export class SessionPresenceRegistry {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
} catch (error) { boundary(error); }
|
|
187
|
-
|
|
187
|
+
// gentle-shell#1443: advertises() only proves the socket file exists, not
|
|
188
|
+
// that its listener is alive — a session killed without unlinking would
|
|
189
|
+
// stay advertised forever otherwise. Probe each candidate once, bounded,
|
|
190
|
+
// with the sweep's own refusal-only liveness: provably dead records are
|
|
191
|
+
// excluded and purged; ambiguous outcomes stay advertised.
|
|
192
|
+
const advertised = [...newest.values()];
|
|
193
|
+
const live = new Set<string>();
|
|
194
|
+
let next = 0;
|
|
195
|
+
const worker = async () => {
|
|
196
|
+
while (next < advertised.length) {
|
|
197
|
+
const record = advertised[next++];
|
|
198
|
+
if (await this.liveness(record.endpoint) !== "dead") live.add(record.sessionId);
|
|
199
|
+
else await this.removeOwn(record).catch(() => {});
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
await Promise.all(Array.from({ length: Math.min(SWEEP_PROBE_CONCURRENCY, advertised.length) }, worker));
|
|
203
|
+
return advertised.filter((record) => live.has(record.sessionId)).sort((left, right) => left.sessionId.localeCompare(right.sessionId));
|
|
188
204
|
}
|
|
189
205
|
|
|
190
206
|
resolve(id: string): Promise<PresenceRecord> {
|
|
@@ -82,7 +82,8 @@ interface ChoicePrompt {
|
|
|
82
82
|
}
|
|
83
83
|
export function captureChoiceAnswer(ctx: AnswerContext, toolCallId: string, params: ChoicePrompt, signal?: AbortSignal) {
|
|
84
84
|
const options = params.options.map((option) => ({ ...option }));
|
|
85
|
-
|
|
85
|
+
// Effective value: ask_user_choice offers free text unless the call passes false.
|
|
86
|
+
const allowCustom = params.allowCustomResponse !== false;
|
|
86
87
|
const prompt = JSON.stringify({ question: params.question,
|
|
87
88
|
options: options.map(({ label, description }) => ({ label, description })), allowCustomResponse: allowCustom });
|
|
88
89
|
const publish = beginCapture(ctx, "ask_user_choice", toolCallId, [{ question: params.question, prompt }], signal);
|
|
@@ -24,6 +24,11 @@ const quoted = (job: JobRecord) => `${job.id} ("${job.label}")`;
|
|
|
24
24
|
const noun = (job: JobRecord) => (job.kind === "monitor" ? "Monitor" : "Background job");
|
|
25
25
|
const plural = (count: number, word: string) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
26
26
|
|
|
27
|
+
/** What changed on the registry, so a listener can ignore a no-op stop. */
|
|
28
|
+
export type BackgroundJobsChange =
|
|
29
|
+
| { kind: "start"; job: JobRecord }
|
|
30
|
+
| { kind: "stop"; job: JobRecord; changed: boolean };
|
|
31
|
+
|
|
27
32
|
/** One-line outcome, shared by the notice, the list, and the jobs view. */
|
|
28
33
|
export function jobOutcome(job: JobRecord): string {
|
|
29
34
|
if (job.status === "running") return "running";
|
|
@@ -79,7 +84,7 @@ export interface BackgroundJobToolsOptions {
|
|
|
79
84
|
sessionId(ctx: ExtensionContext): string;
|
|
80
85
|
now(): number;
|
|
81
86
|
/** Called after a job starts or stops, so views can refresh. */
|
|
82
|
-
onChange?(): void;
|
|
87
|
+
onChange?(change: BackgroundJobsChange): void;
|
|
83
88
|
/** Starts and stops monitors; without it the monitor tool is not offered. */
|
|
84
89
|
monitors?: MonitorController;
|
|
85
90
|
}
|
|
@@ -113,7 +118,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
113
118
|
const input = params as { command?: unknown; label?: unknown };
|
|
114
119
|
if (typeof input.command !== "string" || !input.command.trim()) throw new Error("bash_background requires a non-empty command");
|
|
115
120
|
const job = registry.start({ command: input.command, cwd: ctx.cwd, ownerSessionId: options.sessionId(ctx), label: typeof input.label === "string" ? input.label : undefined });
|
|
116
|
-
options.onChange?.();
|
|
121
|
+
options.onChange?.({ kind: "start", job });
|
|
117
122
|
return text(
|
|
118
123
|
`Started background job ${quoted(job)}.\nOutput: ${job.outputPath}\nYou will be notified once when it exits; keep working or end your turn. Stop it with job_stop.`,
|
|
119
124
|
jobDetails(job),
|
|
@@ -146,7 +151,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
146
151
|
if (typeof input.command !== "string" || !input.command.trim()) throw new Error("monitor requires a non-empty command");
|
|
147
152
|
const timeoutSeconds = typeof input.timeout_seconds === "number" ? input.timeout_seconds : Number.NaN;
|
|
148
153
|
const job = monitors.start({ command: input.command, cwd: ctx.cwd, ownerSessionId: options.sessionId(ctx), label: typeof input.label === "string" ? input.label : undefined, timeoutSeconds });
|
|
149
|
-
options.onChange?.();
|
|
154
|
+
options.onChange?.({ kind: "start", job });
|
|
150
155
|
return text(
|
|
151
156
|
`Started monitor ${quoted(job)} for up to ${timeoutSeconds}s.\nOutput: ${job.outputPath}\nEach new output line reaches you as an event; keep working or end your turn. Stop it with job_stop.`,
|
|
152
157
|
jobDetails(job),
|
|
@@ -166,7 +171,7 @@ export function registerBackgroundJobTools(pi: ExtensionAPI, options: Background
|
|
|
166
171
|
const wasRunning = job.status === "running";
|
|
167
172
|
options.monitors?.cancel(job.id);
|
|
168
173
|
registry.stop(job.id);
|
|
169
|
-
options.onChange?.();
|
|
174
|
+
options.onChange?.({ kind: "stop", job, changed: wasRunning });
|
|
170
175
|
return text(wasRunning ? `Stopped ${quoted(job)}.` : `${quoted(job)} was already ${jobOutcome(job)}.`, jobDetails(job));
|
|
171
176
|
},
|
|
172
177
|
});
|