gentle-pi 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -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 +6 -6
- 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 +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- 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 +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- 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 +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +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/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- 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 +79 -4
- 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/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- 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 +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -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 +40 -19
- 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/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 +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- 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/delegate-for-reason-contract.test.ts +30 -8
- 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 +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/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 +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- 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 +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- 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 +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -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 +11 -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 +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -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 +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -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 +11 -10
- 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-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/provider-defect-handoff.test.ts +9 -2
- 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 +1 -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 +26 -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/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- 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/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.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -28,6 +28,7 @@ import { OrchestratorScopeCache } from "../lib/orchestrator-scope.ts";
|
|
|
28
28
|
import { TODO_PROGRESS_EVENT } from "../lib/shell-todo.ts";
|
|
29
29
|
import { stripAnsi } from "../lib/terminal-theme.ts";
|
|
30
30
|
import { fakeChild, type FakeChild } from "./agents-fake-child.ts";
|
|
31
|
+
import { CHILD_QUERY_TIMEOUT_MS } from "../lib/agents-messaging.ts";
|
|
31
32
|
import { AgentRunner, REQUESTED_TOOLS_ENV, type TaskRequest } from "../lib/agents-runner.ts";
|
|
32
33
|
import { bindSessionRepositoryPreparation } from "../lib/bounded-writer-admission.ts";
|
|
33
34
|
import { bindSessionProfile, resetSessionProfileBindingsForTesting } from "../lib/session-profile-binding.ts";
|
|
@@ -300,6 +301,24 @@ for (const scenario of ["background", "task", "append-failure", "overflow", "byt
|
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
303
|
|
|
304
|
+
test("orchestrator_session_id accepts a JSON-string state with actionable errors", async t => {
|
|
305
|
+
const h = fakePi(), runtime = deps(), { ctx } = fakeContext();
|
|
306
|
+
gentleAgents(h.pi, {}, runtime.deps);
|
|
307
|
+
await h.fire("session_start", ctx);
|
|
308
|
+
const tool = h.tools.get("orchestrator_session_id")!;
|
|
309
|
+
const before = h.entries.length;
|
|
310
|
+
// A JSON-encoded string publishes exactly like the equivalent object.
|
|
311
|
+
const result = await tool.execute("string", { state: JSON.stringify({ objective: "From string", work: { area: "gentle-ai", topic: "string-state" } }) }, undefined, undefined, ctx);
|
|
312
|
+
assert.match(result.content[0].text, /Current alias \(CURRENT TASK\): string-state/);
|
|
313
|
+
const published = h.entries.at(-1)!.data as { state: { objective: string } };
|
|
314
|
+
assert.equal(published.state.objective, "From string");
|
|
315
|
+
assert.equal(h.entries.length, before + 1);
|
|
316
|
+
// Malformed JSON fails with an actionable message, never a schema riddle.
|
|
317
|
+
await assert.rejects(tool.execute("bad-json", { state: "{objective:" }, undefined, undefined, ctx), /JSON/);
|
|
318
|
+
// A valid JSON string with a flat shape names the nesting rule.
|
|
319
|
+
await assert.rejects(tool.execute("bad-shape", { state: JSON.stringify({ objective: "x", area: "flat" }) }, undefined, undefined, ctx), /work/);
|
|
320
|
+
});
|
|
321
|
+
|
|
303
322
|
test("invalid run work rejects before foreign consent or allocation", async t => {
|
|
304
323
|
const h = fakePi(), runtime = deps(), { ctx, dialogs } = fakeContext();
|
|
305
324
|
gentleAgents(h.pi, {}, runtime.deps);
|
|
@@ -685,6 +704,105 @@ test("host query delivery exposes correlation and accepts one current-session re
|
|
|
685
704
|
assert.match((await tools.get("subagent_reply")!.execute("duplicate", { task_id: taskId, request_id: "q1", message: "again" }, undefined, undefined, ctx)).content[0].text, /unavailable/);
|
|
686
705
|
});
|
|
687
706
|
|
|
707
|
+
// S15 P9a: a parent busy past the query deadline still gets its answer to the
|
|
708
|
+
// child, as a steering message, and the tool result says what happened.
|
|
709
|
+
function expiringQueryHarness() {
|
|
710
|
+
const h = fakePi();
|
|
711
|
+
const harness = deps();
|
|
712
|
+
const timers: Array<{ fn: () => void; ms: number }> = [];
|
|
713
|
+
harness.deps.schedule = (fn, ms) => { timers.push({ fn, ms }); return () => {}; };
|
|
714
|
+
gentleAgents(h.pi, {}, harness.deps);
|
|
715
|
+
const { ctx } = fakeContext();
|
|
716
|
+
const reply = async (requestId: string, message: string) => (await h.tools.get("subagent_reply")!.execute("reply", { task_id: taskId, request_id: requestId, message }, undefined, undefined, ctx));
|
|
717
|
+
let taskId = "";
|
|
718
|
+
let sessionStarted = false;
|
|
719
|
+
const begin = async () => { if (!sessionStarted) await h.fire("session_start", ctx); sessionStarted = true; };
|
|
720
|
+
const start = async () => {
|
|
721
|
+
await begin();
|
|
722
|
+
const started = await h.tools.get("subagent_run")!.execute("query", { agent: "explore", task: "Ask once", mode: "background" }, undefined, undefined, ctx);
|
|
723
|
+
taskId = (started.details.gentleAgents as { taskId: string }).taskId;
|
|
724
|
+
await tick();
|
|
725
|
+
harness.children[0].message({ id: "q1", kind: "query", message: "Which file?" });
|
|
726
|
+
await tick();
|
|
727
|
+
return taskId;
|
|
728
|
+
};
|
|
729
|
+
const expire = () => timers.filter((timer) => timer.ms === CHILD_QUERY_TIMEOUT_MS).at(-1)!.fn();
|
|
730
|
+
const steers = () => harness.children[0].written.filter((command) => command.type === "steer").map((command) => command.message);
|
|
731
|
+
return { h, ctx, harness, timers, reply, begin, start, expire, steers };
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
test("a query that expires while the parent is busy still reaches the parent once, marked expired", async () => {
|
|
735
|
+
const q = expiringQueryHarness();
|
|
736
|
+
await q.begin();
|
|
737
|
+
await q.h.fire("agent_start", q.ctx);
|
|
738
|
+
const sentBefore = q.h.sent.length;
|
|
739
|
+
const taskId = await q.start();
|
|
740
|
+
const asks = () => q.h.sent.slice(sentBefore).filter((entry) => String(entry.message.content).startsWith("Subagent "));
|
|
741
|
+
assert.equal(asks().length, 0, "a busy parent holds the question");
|
|
742
|
+
q.expire();
|
|
743
|
+
await q.h.fire("agent_end", q.ctx);
|
|
744
|
+
await tick();
|
|
745
|
+
assert.equal(asks().length, 1);
|
|
746
|
+
assert.equal(String(asks()[0]!.message.content), `Subagent explore asks:\nTask ID: ${taskId}\nRequest ID: q1\nQuestion: Which file?\nThis query expired before it reached you; a reply is delivered to the task as a message.`);
|
|
747
|
+
assert.equal((await q.reply("q1", "src/a.ts")).content[0].text, `Query q1 had expired; the answer was delivered to task ${taskId} as a message.`);
|
|
748
|
+
await q.h.fire("agent_settled", q.ctx);
|
|
749
|
+
await tick();
|
|
750
|
+
assert.equal(asks().length, 1, "shown once");
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
test("an oversize late reply says the limit and leaves the request answerable", async () => {
|
|
754
|
+
const q = expiringQueryHarness();
|
|
755
|
+
const taskId = await q.start();
|
|
756
|
+
q.expire();
|
|
757
|
+
assert.equal((await q.reply("q1", "x".repeat(8193))).content[0].text, "Error: the reply exceeds the 8192-byte message limit and was not delivered; query q1 can still be answered with a shorter reply.");
|
|
758
|
+
assert.equal((await q.reply("q1", "short")).content[0].text, `Query q1 had expired; the answer was delivered to task ${taskId} as a message.`);
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
test("a reply after the query expired is delivered to the running task as a prefixed message", async () => {
|
|
762
|
+
const h = expiringQueryHarness();
|
|
763
|
+
const taskId = await h.start();
|
|
764
|
+
h.expire();
|
|
765
|
+
const result = await h.reply("q1", "src/a.ts");
|
|
766
|
+
await tick();
|
|
767
|
+
assert.equal(result.content[0].text, `Query q1 had expired; the answer was delivered to task ${taskId} as a message.`);
|
|
768
|
+
assert.deepEqual(h.steers(), ["Answer to your earlier question (q1; it expired before the reply arrived): src/a.ts"]);
|
|
769
|
+
assert.equal(h.harness.children[0].sent.some((frame) => frame.kind === "reply" && "message" in frame), false, "no reply frame reaches a settled query");
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
test("a reply after the query expired and the task finished says it was not delivered", async () => {
|
|
773
|
+
const h = expiringQueryHarness();
|
|
774
|
+
const taskId = await h.start();
|
|
775
|
+
h.expire();
|
|
776
|
+
h.harness.children[0].emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "done" }], stopReason: "stop" }] });
|
|
777
|
+
h.harness.children[0].emit({ type: "agent_settled" });
|
|
778
|
+
for (let index = 0; index < 5; index += 1) await tick();
|
|
779
|
+
const result = await h.reply("q1", "src/a.ts");
|
|
780
|
+
await tick();
|
|
781
|
+
assert.equal(result.content[0].text, `Error: query q1 had expired and task ${taskId} is no longer running, so the answer was not delivered. Pass it with subagent_continue.`);
|
|
782
|
+
assert.deepEqual(h.steers(), []);
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
test("a second reply to an expired query is rejected", async () => {
|
|
786
|
+
const h = expiringQueryHarness();
|
|
787
|
+
await h.start();
|
|
788
|
+
h.expire();
|
|
789
|
+
await h.reply("q1", "src/a.ts");
|
|
790
|
+
assert.equal((await h.reply("q1", "again")).content[0].text, "Error: query is unavailable.");
|
|
791
|
+
await tick();
|
|
792
|
+
assert.equal(h.steers().length, 1);
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
test("a query waits 120 s and a reply before expiry keeps its exact result", async () => {
|
|
796
|
+
const h = expiringQueryHarness();
|
|
797
|
+
await h.start();
|
|
798
|
+
assert.equal(CHILD_QUERY_TIMEOUT_MS, 120_000);
|
|
799
|
+
assert.equal(h.timers.some((timer) => timer.ms === 120_000), true);
|
|
800
|
+
assert.equal((await h.reply("q1", "src/a.ts")).content[0].text, "Reply accepted for delivery.");
|
|
801
|
+
await tick();
|
|
802
|
+
assert.deepEqual(h.harness.children[0].sent.at(-1), { id: "q1", kind: "reply", message: "src/a.ts" });
|
|
803
|
+
assert.deepEqual(h.steers(), []);
|
|
804
|
+
});
|
|
805
|
+
|
|
688
806
|
test("first foreground query yields while its child runs and delivers one completion", async () => {
|
|
689
807
|
const { pi, tools, fire, sent } = fakePi();
|
|
690
808
|
const harness = deps();
|
|
@@ -4165,6 +4283,146 @@ test("once the last task is done the card asks for one frame when its finished r
|
|
|
4165
4283
|
assert.equal(timers.filter((timer) => !timer.cancelled && timer.ms === 60_000).length, 0, "nothing is rescheduled once the card is empty");
|
|
4166
4284
|
});
|
|
4167
4285
|
|
|
4286
|
+
// P9b: the report delivered into the parent's context is capped; the stored
|
|
4287
|
+
// result and subagent_result keep the full text.
|
|
4288
|
+
const reportNotice = (id: string, first: number, last: number, full: number) => `Report truncated: the first ${first} and the last ${last} of ${full} bytes were delivered. Call subagent_result with task_id ${id} for the full text.`;
|
|
4289
|
+
const finishChild = (child: FakeChild, answer: string) => {
|
|
4290
|
+
child.emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: answer }] }] });
|
|
4291
|
+
child.emit({ type: "agent_settled" });
|
|
4292
|
+
};
|
|
4293
|
+
|
|
4294
|
+
test("a background report over the cap is delivered truncated with the notice, and subagent_result returns the full text", async () => {
|
|
4295
|
+
const { pi, tools, fire, sent } = fakePi();
|
|
4296
|
+
const harness = deps();
|
|
4297
|
+
gentleAgents(pi, {}, harness.deps);
|
|
4298
|
+
const { ctx } = fakeContext();
|
|
4299
|
+
await fire("session_start", ctx);
|
|
4300
|
+
const started = await tools.get("subagent_run")!.execute("c1", { agent: "explore", task: "Big job", mode: "background" }, undefined, undefined, ctx);
|
|
4301
|
+
const id = (started.details.gentleAgents as { taskId: string }).taskId;
|
|
4302
|
+
await tick();
|
|
4303
|
+
const report = "row of a long table\n".repeat(1000); // 20,000 bytes
|
|
4304
|
+
finishChild(harness.children[0], report);
|
|
4305
|
+
await tick();
|
|
4306
|
+
const results = sent.filter((entry) => entry.message.customType === "gentle-agents.result");
|
|
4307
|
+
assert.equal(results.length, 1);
|
|
4308
|
+
const head = "row of a long table\n".repeat(818) + "row of a long table"; // cut back to the last line break inside the cap: 16,379 bytes
|
|
4309
|
+
const tail = "row of a long table\n".repeat(102); // the end of the report, from the first line break of its last 2,048 bytes: 2,040 bytes
|
|
4310
|
+
assert.equal(String(results[0]!.message.content), `Subagent explore (task ${id}, "Big job") finished.\n\n${head}\n\n${reportNotice(id, 16_379, 2040, 20_000)}\n\n${tail}`);
|
|
4311
|
+
const details = (results[0]!.message.details as { gentleAgents: Record<string, unknown> }).gentleAgents;
|
|
4312
|
+
assert.deepEqual([details.taskId, details.status, details.reportTruncated, details.reportBytes, details.reportDeliveredBytes], [id, "completed", true, 20_000, 16_379 + 2040]);
|
|
4313
|
+
const full = await tools.get("subagent_result")!.execute("c2", { task_id: id }, undefined, undefined, ctx);
|
|
4314
|
+
assert.equal(full.content[0].text, report, "subagent_result is the explicit uncapped route");
|
|
4315
|
+
assert.equal((full.details.gentleAgents as Record<string, unknown>).reportTruncated, undefined);
|
|
4316
|
+
await fire("session_shutdown", ctx);
|
|
4317
|
+
});
|
|
4318
|
+
|
|
4319
|
+
test("task-mode run and continue results over the cap are truncated without splitting a multi-byte character", async () => {
|
|
4320
|
+
const { pi, tools, fire } = fakePi();
|
|
4321
|
+
const harness = deps();
|
|
4322
|
+
gentleAgents(pi, {}, harness.deps);
|
|
4323
|
+
const { ctx } = fakeContext();
|
|
4324
|
+
await fire("session_start", ctx);
|
|
4325
|
+
const report = `${"a".repeat(16_383)}€${"z".repeat(3000)}€${"y".repeat(2046)}`; // a € straddles both cuts
|
|
4326
|
+
const run = tools.get("subagent_run")!.execute("c1", { agent: "explore", task: "Wide", mode: "task" }, undefined, undefined, ctx);
|
|
4327
|
+
await tick();
|
|
4328
|
+
finishChild(harness.children[0], report);
|
|
4329
|
+
const result = await run;
|
|
4330
|
+
const id = (result.details.gentleAgents as { taskId: string }).taskId;
|
|
4331
|
+
const notice = reportNotice(id, 16_383, 2046, 21_435);
|
|
4332
|
+
assert.equal(result.content[0].text, `Subagent explore (task ${id}, "Wide") finished.\n\n${"a".repeat(16_383)}\n\n${notice}\n\n${"y".repeat(2046)}`);
|
|
4333
|
+
assert.equal(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.from(result.content[0].text, "utf8")), result.content[0].text, "valid UTF-8");
|
|
4334
|
+
assert.deepEqual((({ reportTruncated, reportBytes, reportDeliveredBytes }) => [reportTruncated, reportBytes, reportDeliveredBytes])(result.details.gentleAgents as Record<string, unknown>), [true, 21_435, 16_383 + 2046]);
|
|
4335
|
+
assert.equal((await tools.get("subagent_result")!.execute("c2", { task_id: id }, undefined, undefined, ctx)).content[0].text, report);
|
|
4336
|
+
const resumed = tools.get("subagent_continue")!.execute("c3", { task_id: id, prompt: "Again", mode: "task" }, undefined, undefined, ctx);
|
|
4337
|
+
await tick();
|
|
4338
|
+
await tick();
|
|
4339
|
+
const closing = ["## Summary", "", "- The end of the report is kept."].join("\n"); // 44 bytes
|
|
4340
|
+
finishChild(harness.children[1], `${"line\n".repeat(4000)}${closing}`);
|
|
4341
|
+
const continued = await resumed;
|
|
4342
|
+
const continuedId = (continued.details.gentleAgents as { taskId: string }).taskId;
|
|
4343
|
+
const end = `${"line\n".repeat(400)}${closing}`; // the last 2,048 bytes start mid-line; the tail starts at the next line: 2,044 bytes
|
|
4344
|
+
assert.ok(continued.content[0].text.endsWith(`\n\n${reportNotice(continuedId, 16_379, 2044, 20_044)}\n\n${end}`));
|
|
4345
|
+
await fire("session_shutdown", ctx);
|
|
4346
|
+
});
|
|
4347
|
+
|
|
4348
|
+
test("reports at the cap or one byte under keep today's exact text and details in task mode and background delivery", async () => {
|
|
4349
|
+
for (const size of [16_384, 16_383, 9]) {
|
|
4350
|
+
const { pi, tools, fire, sent } = fakePi();
|
|
4351
|
+
const harness = deps();
|
|
4352
|
+
gentleAgents(pi, {}, harness.deps);
|
|
4353
|
+
const { ctx } = fakeContext();
|
|
4354
|
+
await fire("session_start", ctx);
|
|
4355
|
+
const report = size === 9 ? "All done." : "r".repeat(size);
|
|
4356
|
+
const run = tools.get("subagent_run")!.execute("c1", { agent: "explore", task: "Edge", mode: "task" }, undefined, undefined, ctx);
|
|
4357
|
+
await tick();
|
|
4358
|
+
finishChild(harness.children[0], report);
|
|
4359
|
+
const result = await run;
|
|
4360
|
+
const id = (result.details.gentleAgents as { taskId: string }).taskId;
|
|
4361
|
+
assert.equal(result.content[0].text, `Subagent explore (task ${id}, "Edge") finished.\n\n${report}`);
|
|
4362
|
+
assert.equal("reportTruncated" in (result.details.gentleAgents as object), false);
|
|
4363
|
+
const started = await tools.get("subagent_run")!.execute("c2", { agent: "explore", task: "Edge bg", mode: "background" }, undefined, undefined, ctx);
|
|
4364
|
+
const bgId = (started.details.gentleAgents as { taskId: string }).taskId;
|
|
4365
|
+
await tick();
|
|
4366
|
+
finishChild(harness.children[1], report);
|
|
4367
|
+
await tick();
|
|
4368
|
+
const delivered = sent.filter((entry) => entry.message.customType === "gentle-agents.result");
|
|
4369
|
+
assert.equal(String(delivered[0]!.message.content), `Subagent explore (task ${bgId}, "Edge bg") finished.\n\n${report}`);
|
|
4370
|
+
assert.equal("reportTruncated" in (delivered[0]!.message.details as { gentleAgents: object }).gentleAgents, false);
|
|
4371
|
+
await fire("session_shutdown", ctx);
|
|
4372
|
+
}
|
|
4373
|
+
});
|
|
4374
|
+
|
|
4375
|
+
test("report_max_bytes from subagents.json sets the delivered report cap", async () => {
|
|
4376
|
+
const agentHome = join(root, "report-cap-profile", "agent");
|
|
4377
|
+
mkdirSync(join(agentHome, "agents"), { recursive: true });
|
|
4378
|
+
copyFileSync(join(home, ".pi", "agent", "agents", "explore.md"), join(agentHome, "agents", "explore.md"));
|
|
4379
|
+
writeFileSync(join(agentHome, "subagents.json"), JSON.stringify({ report_max_bytes: 64 }));
|
|
4380
|
+
const { pi, tools, fire, sent } = fakePi();
|
|
4381
|
+
const harness = deps();
|
|
4382
|
+
gentleAgents(pi, {}, { ...harness.deps, agentHome });
|
|
4383
|
+
const { ctx } = fakeContext();
|
|
4384
|
+
await fire("session_start", ctx);
|
|
4385
|
+
const started = await tools.get("subagent_run")!.execute("c1", { agent: "explore", task: "Small cap", mode: "background" }, undefined, undefined, ctx);
|
|
4386
|
+
const id = (started.details.gentleAgents as { taskId: string }).taskId;
|
|
4387
|
+
await tick();
|
|
4388
|
+
// A line break at byte 2 is outside the 16-byte window of a 64-byte cap: the head keeps all 64 bytes.
|
|
4389
|
+
finishChild(harness.children[0], `ab\n${"x".repeat(3000)}`);
|
|
4390
|
+
await tick();
|
|
4391
|
+
const delivered = sent.filter((entry) => entry.message.customType === "gentle-agents.result");
|
|
4392
|
+
assert.equal(String(delivered[0]!.message.content), `Subagent explore (task ${id}, "Small cap") finished.\n\nab\n${"x".repeat(61)}\n\n${reportNotice(id, 64, 2048, 3003)}\n\n${"x".repeat(2048)}`);
|
|
4393
|
+
await fire("session_shutdown", ctx);
|
|
4394
|
+
});
|
|
4395
|
+
|
|
4396
|
+
// Verifier blocker 4: strict-JSON reports would arrive as invalid JSON plus a notice.
|
|
4397
|
+
test("strict-JSON agents and single JSON documents over the cap are delivered whole; prose is still truncated", async () => {
|
|
4398
|
+
const agentHome = join(root, "report-cap-json", "agent");
|
|
4399
|
+
mkdirSync(join(agentHome, "agents"), { recursive: true });
|
|
4400
|
+
for (const name of ["explore", "review-risk"]) copyFileSync(join(home, ".pi", "agent", "agents", "explore.md"), join(agentHome, "agents", `${name}.md`));
|
|
4401
|
+
writeFileSync(join(agentHome, "subagents.json"), JSON.stringify({ report_max_bytes: 64 }));
|
|
4402
|
+
const { pi, tools, fire } = fakePi();
|
|
4403
|
+
const harness = deps();
|
|
4404
|
+
gentleAgents(pi, {}, { ...harness.deps, agentHome });
|
|
4405
|
+
const { ctx } = fakeContext();
|
|
4406
|
+
await fire("session_start", ctx);
|
|
4407
|
+
const json = JSON.stringify({ schema: "compact-v2", findings: [{ id: "F1", text: "x".repeat(200) }] });
|
|
4408
|
+
const runOnce = async (agent: string, answer: string, child: number) => {
|
|
4409
|
+
const run = tools.get("subagent_run")!.execute(`c${child}`, { agent, task: "Judge", mode: "task" }, undefined, undefined, ctx);
|
|
4410
|
+
await tick();
|
|
4411
|
+
finishChild(harness.children[child], answer);
|
|
4412
|
+
const result = await run;
|
|
4413
|
+
return { text: result.content[0].text as string, id: (result.details.gentleAgents as { taskId: string }).taskId, details: result.details.gentleAgents as Record<string, unknown> };
|
|
4414
|
+
};
|
|
4415
|
+
const strict = await runOnce("review-risk", `\`\`\`json\n${json}\n\`\`\``, 0);
|
|
4416
|
+
assert.equal(strict.text, `Subagent review-risk (task ${strict.id}, "Judge") finished.\n\n\`\`\`json\n${json}\n\`\`\``);
|
|
4417
|
+
assert.deepEqual(JSON.parse(strict.text.split("\n\n").slice(1).join("\n\n").replace(/^```json\n|\n```$/g, "")), JSON.parse(json));
|
|
4418
|
+
assert.equal("reportTruncated" in strict.details, false);
|
|
4419
|
+
const generic = await runOnce("explore", json, 1);
|
|
4420
|
+
assert.equal(generic.text, `Subagent explore (task ${generic.id}, "Judge") finished.\n\n${json}`);
|
|
4421
|
+
const prose = await runOnce("explore", "x".repeat(3000), 2);
|
|
4422
|
+
assert.equal(prose.text, `Subagent explore (task ${prose.id}, "Judge") finished.\n\n${"x".repeat(64)}\n\n${reportNotice(prose.id, 64, 2048, 3000)}\n\n${"x".repeat(2048)}`);
|
|
4423
|
+
await fire("session_shutdown", ctx);
|
|
4424
|
+
});
|
|
4425
|
+
|
|
4168
4426
|
test("completionText names the outcome before the answer", () => {
|
|
4169
4427
|
const base = { id: "t1", agent: "explore", mode: "background", prompt: "p", label: "map lib", cwd: "/r", parentSessionId: "s", status: "failed" as const, createdAt: 1, startedAt: 1, endedAt: 2, model: "m", thinking: undefined, sessionPath: null, error: "pi exited with code 1", result: null, lastStep: "x", lastActivityAt: 2, turns: 0, toolCalls: 0, tokens: 0, cost: 0 };
|
|
4170
4428
|
assert.equal(completionText(base), 'Subagent explore (task t1, "map lib") failed.\n\nSubagent explore failed: pi exited with code 1');
|
|
@@ -4485,16 +4743,23 @@ test("a task that finishes live stays visible as history, in both scopes, and it
|
|
|
4485
4743
|
const started = await tools.get("subagent_run")!.execute("c1", { agent: "explore", task: "Persist me", mode: "background" }, undefined, undefined, ctx);
|
|
4486
4744
|
const id = (started.details.gentleAgents as { taskId: string }).taskId;
|
|
4487
4745
|
await tick();
|
|
4488
|
-
harness.children[0].emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "Kept." }] }] });
|
|
4489
|
-
harness.children[0].emit({ type: "agent_settled" });
|
|
4490
|
-
await tick();
|
|
4491
4746
|
const tasksDir = join(home, ".pi", "agent", "gentle-agents", "tasks");
|
|
4492
4747
|
let stored = await loadHistory(tasksDir);
|
|
4493
4748
|
for (let attempt = 0; attempt < 40 && !stored.some((entry) => entry.task.id === id); attempt += 1) {
|
|
4494
4749
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
4495
4750
|
stored = await loadHistory(tasksDir);
|
|
4496
4751
|
}
|
|
4497
|
-
assert.ok(stored.some((entry) => entry.task.id === id && entry.task.result
|
|
4752
|
+
assert.ok(stored.some((entry) => entry.task.id === id && entry.task.result !== "Kept."), "observe the launch record before the child finishes");
|
|
4753
|
+
harness.children[0].emit({ type: "agent_end", messages: [{ role: "assistant", content: [{ type: "text", text: "Kept." }] }] });
|
|
4754
|
+
harness.children[0].emit({ type: "agent_settled" });
|
|
4755
|
+
await tick();
|
|
4756
|
+
// The last observed history can still contain the durable launch record.
|
|
4757
|
+
const hasFinishedResult = () => stored.some((entry) => entry.task.id === id && entry.task.status === TASK_STATUS.COMPLETED && entry.task.result === "Kept.");
|
|
4758
|
+
for (let attempt = 0; attempt < 40 && !hasFinishedResult(); attempt += 1) {
|
|
4759
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
4760
|
+
stored = await loadHistory(tasksDir);
|
|
4761
|
+
}
|
|
4762
|
+
assert.ok(hasFinishedResult(), "the finished task is on disk");
|
|
4498
4763
|
|
|
4499
4764
|
// A completely different session still resolves it by id on demand, with
|
|
4500
4765
|
// nothing restored in advance.
|
|
@@ -7463,6 +7728,39 @@ test("bash_background returns at once, and an idle parent gets one stored exit n
|
|
|
7463
7728
|
}
|
|
7464
7729
|
});
|
|
7465
7730
|
|
|
7731
|
+
test("a job notice survives session switching and is delivered only to its owner (#3205)", async () => {
|
|
7732
|
+
const { pi, tools, fire, sent } = fakePi();
|
|
7733
|
+
const jobs = fakeJobShell();
|
|
7734
|
+
gentleAgents(pi, {}, { ...deps().deps, jobShell: jobs.shell, jobOutputDir: () => jobs.dir });
|
|
7735
|
+
const { ctx: owner } = fakeContext();
|
|
7736
|
+
const { ctx: other } = fakeContext();
|
|
7737
|
+
Object.assign(other.sessionManager, { getSessionId: () => "s2" });
|
|
7738
|
+
const notices = () => sent.filter((entry) => entry.message.customType === "gentle-jobs.notice");
|
|
7739
|
+
try {
|
|
7740
|
+
await fire("session_start", owner);
|
|
7741
|
+
await fire("agent_start", owner);
|
|
7742
|
+
await tools.get("bash_background")!.execute("b1", { command: "make build", label: "owner job" }, undefined, undefined, owner);
|
|
7743
|
+
jobs.runs[0]!.exit(0);
|
|
7744
|
+
await jobIo();
|
|
7745
|
+
assert.equal(notices().length, 0, "the busy owner holds the exit notice");
|
|
7746
|
+
|
|
7747
|
+
await fire("session_start", other, { reason: "new" });
|
|
7748
|
+
await fire("agent_settled", other);
|
|
7749
|
+
await fire("turn_end", other);
|
|
7750
|
+
assert.equal(notices().length, 0, "the inactive owner's notice is never delivered to another session");
|
|
7751
|
+
|
|
7752
|
+
await fire("session_start", owner, { reason: "resume" });
|
|
7753
|
+
await fire("turn_end", owner);
|
|
7754
|
+
await eventually(() => notices().length === 1, "resuming the owner delivers its retained notice");
|
|
7755
|
+
assert.match(String(notices()[0]!.message.content), /job-1 \(\"owner job\"\) exited with code 0/);
|
|
7756
|
+
await fire("turn_end", owner);
|
|
7757
|
+
assert.equal(notices().length, 1, "the retained notice is delivered exactly once");
|
|
7758
|
+
} finally {
|
|
7759
|
+
await fire("session_shutdown", owner);
|
|
7760
|
+
jobs.cleanup();
|
|
7761
|
+
}
|
|
7762
|
+
});
|
|
7763
|
+
|
|
7466
7764
|
test("a busy parent gets the exit notice steered into its run at the next turn boundary", async () => {
|
|
7467
7765
|
const { pi, tools, fire, sent, userMessages } = fakePi();
|
|
7468
7766
|
const jobs = fakeJobShell();
|
|
@@ -8577,3 +8875,30 @@ test("a job notice held for a parent busy without a run is delivered by the held
|
|
|
8577
8875
|
jobs.cleanup();
|
|
8578
8876
|
}
|
|
8579
8877
|
});
|
|
8878
|
+
|
|
8879
|
+
// P3 (tools by mode): the rarely used cross-session tools leave the primary
|
|
8880
|
+
// request only while codemode, which the appended route names, reaches them.
|
|
8881
|
+
test("cross-session coordination tools are hidden behind codemode and named by a route; direct without codemode", async () => {
|
|
8882
|
+
const { pi, tools, fire } = fakePi();
|
|
8883
|
+
gentleAgents(pi, {}, deps().deps);
|
|
8884
|
+
const { ctx } = fakeContext();
|
|
8885
|
+
await fire("session_start", ctx);
|
|
8886
|
+
try {
|
|
8887
|
+
type Hook = (loadout: { declared: Array<{ name: string }> }) => { hiddenDeclarations?: readonly string[] } | undefined;
|
|
8888
|
+
const registered = [...tools.keys()];
|
|
8889
|
+
const hidden = (names: string[]) => registered.flatMap((name) => ((tools.get(name) as unknown as { prepareLoadout?: Hook }).prepareLoadout?.({ declared: names.map((tool) => ({ name: tool })) })?.hiddenDeclarations ?? []));
|
|
8890
|
+
const coordination = ["orchestrator_consult", "orchestrator_list", "orchestrator_send_message"];
|
|
8891
|
+
assert.deepEqual(hidden([...registered, "codemode"]).sort(), coordination);
|
|
8892
|
+
assert.deepEqual(hidden(registered), [], "without codemode every tool stays declared");
|
|
8893
|
+
assert.deepEqual(hidden([...registered.filter((name) => name !== "orchestrator_list"), "codemode"]).sort(), ["orchestrator_consult", "orchestrator_send_message"], "an inactive tool is never hidden");
|
|
8894
|
+
const route = /Cross-session tools orchestrator_list, orchestrator_consult and orchestrator_send_message are not declared: call them from codemode as `tools\.<name>\(args\)`/;
|
|
8895
|
+
const withRoute = { appendSystemPrompt: "", selectedTools: [...registered, "codemode"] };
|
|
8896
|
+
await fire("before_agent_start", ctx, { type: "before_agent_start", prompt: "hi", systemPrompt: "", systemPromptOptions: withRoute });
|
|
8897
|
+
assert.match(withRoute.appendSystemPrompt, route);
|
|
8898
|
+
const direct = { appendSystemPrompt: "", selectedTools: registered };
|
|
8899
|
+
await fire("before_agent_start", ctx, { type: "before_agent_start", prompt: "hi", systemPrompt: "", systemPromptOptions: direct });
|
|
8900
|
+
assert.doesNotMatch(direct.appendSystemPrompt, route);
|
|
8901
|
+
} finally {
|
|
8902
|
+
await fire("session_shutdown", ctx);
|
|
8903
|
+
}
|
|
8904
|
+
});
|
|
@@ -99,7 +99,7 @@ async function writeWindowsSourceBinary(packageRoot: string): Promise<{ binaryPa
|
|
|
99
99
|
method: "go-sumdb-source-build",
|
|
100
100
|
package: "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
|
|
101
101
|
module: "github.com/gentleman-programming/gentle-ai/v4",
|
|
102
|
-
tag: "v4.
|
|
102
|
+
tag: "v4.5.0",
|
|
103
103
|
architecture: process.arch === "x64" ? "x64" : "arm64",
|
|
104
104
|
binarySha256: createHash("sha256").update(binary).digest("hex"),
|
|
105
105
|
moduleChecksum: GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM,
|
|
@@ -217,6 +217,7 @@ test("review tools called from inside another tool are refused; direct calls and
|
|
|
217
217
|
await h.handlers.get("session_start")!({ reason: "startup" }, h.ctx);
|
|
218
218
|
const call = (toolName: string, parentToolCallId?: string) => h.handlers.get("tool_call")!({ toolName, toolCallId: "call-1", input: { operation: "status" }, ...(parentToolCallId ? { parentToolCallId } : {}) }, h.ctx) as Promise<{ block?: boolean; reason?: string } | undefined>;
|
|
219
219
|
for (const tool of ["gentle_review", "gentle_review_capture", "gentle_review_capture_group", "gentle_review_scope"]) {
|
|
220
|
+
assert.equal(h.tools.get(tool)?.exposure, "model-only", `${tool} must not advertise a codemode route`);
|
|
220
221
|
const nested = await call(tool, "codemode-1");
|
|
221
222
|
assert.equal(nested?.block, true, tool);
|
|
222
223
|
assert.match(nested?.reason ?? "", /call it directly, never from codemode or another tool/, tool);
|