gentle-pi 4.6.0 → 4.7.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 +10 -11
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +5 -2
- package/assets/agents/gentle-ai-worker.md +3 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +16 -1
- package/assets/orchestrator-delegation-reference.md +4 -4
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +7 -5
- package/assets/orchestrator.md +3 -3
- package/bin/gentle-shell.mjs +164 -56
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/delegated-verification.md +29 -7
- package/docs/gentle-agents-activity.md +14 -0
- package/docs/gentle-shell.md +54 -16
- package/docs/install-wizard.md +1 -1
- package/docs/permission-modes.md +9 -4
- package/docs/readme-reference.md +75 -30
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +326 -34
- package/extensions/gentle-ai.ts +1496 -454
- package/extensions/gentle-shell.ts +293 -63
- package/extensions/gentle-todo.ts +18 -2
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +175 -18
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +46 -0
- package/lib/agents-history.ts +24 -5
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-runner.ts +183 -12
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/card-content-policy.ts +8 -6
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +270 -140
- package/lib/jobs-view.ts +198 -11
- package/lib/model-routing-authority.ts +22 -4
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +96 -19
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +46 -10
- package/lib/review-integration-v2.ts +7 -1
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/verifier-admission.ts +1 -1
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +40 -15
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +93 -16
- package/runtime/review-integration-v2.mjs +7 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +5 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/verify-package-files.mjs +12 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +178 -2
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +30 -5
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +3 -3
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1070 -12
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +113 -38
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +77 -10
- package/tests/gentle-shell.test.ts +899 -59
- package/tests/gentle-todo.test.ts +19 -2
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +176 -4
- package/tests/installer-posix-bootstrap.test.ts +1 -1
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/jobs-view.test.ts +260 -6
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +4 -1
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +3 -1
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +11 -9
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/pi-update-launcher.test.ts +8 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +1 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/skill-registry.test.ts +838 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +5 -3
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verify-first-launch-contract.test.ts +78 -3
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +28 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +23 -18
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
+
import { getEventListeners } from "node:events";
|
|
3
|
+
import { setImmediate as nextTurn } from "node:timers/promises";
|
|
2
4
|
import test from "node:test";
|
|
3
5
|
import type { Api, AssistantMessage, Context, Model, SimpleStreamOptions } from "@earendil-works/pi-ai";
|
|
4
6
|
import type { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
@@ -221,6 +223,11 @@ test("refuses when the reviewer attempts a tool call", async () => {
|
|
|
221
223
|
assert.equal(refused.code, INPROCESS_REVIEWER_FAILURE.TOOL_CALL_ATTEMPTED);
|
|
222
224
|
});
|
|
223
225
|
|
|
226
|
+
function withoutRunTiming(evidence: Record<string, unknown> | undefined): Record<string, unknown> {
|
|
227
|
+
const { durationMs, authDurationMs, completionDurationMs, ...facts } = evidence ?? {};
|
|
228
|
+
return facts;
|
|
229
|
+
}
|
|
230
|
+
|
|
224
231
|
test("refuses empty assistant text with safe completion evidence", async () => {
|
|
225
232
|
const assistant = assistantText("", { content: [], stopReason: "stop" });
|
|
226
233
|
const outcome = await runInProcessReviewer(baseRequest(), {
|
|
@@ -229,9 +236,11 @@ test("refuses empty assistant text with safe completion evidence", async () => {
|
|
|
229
236
|
});
|
|
230
237
|
const refused = expectRefused(outcome);
|
|
231
238
|
assert.equal(refused.code, INPROCESS_REVIEWER_FAILURE.EMPTY_OUTPUT);
|
|
232
|
-
assert.deepEqual(refused.evidence, {
|
|
239
|
+
assert.deepEqual(withoutRunTiming(refused.evidence), {
|
|
240
|
+
phase: "completion", provider: "openai",
|
|
233
241
|
reviewerModel: "openai/gpt-5", stopReason: "stop",
|
|
234
242
|
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 },
|
|
243
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
235
244
|
content: { blocks: 0, textBlocks: 0, thinkingBlocks: 0, textChars: 0, thinkingChars: 0 },
|
|
236
245
|
});
|
|
237
246
|
});
|
|
@@ -249,7 +258,8 @@ test("empty-output diagnostics allowlist facts, not provider secrets, and comple
|
|
|
249
258
|
}));
|
|
250
259
|
assert.equal(refused.code, INPROCESS_REVIEWER_FAILURE.EMPTY_OUTPUT);
|
|
251
260
|
assert.equal(calls.length, 1);
|
|
252
|
-
assert.deepEqual(refused.evidence, {
|
|
261
|
+
assert.deepEqual(withoutRunTiming(refused.evidence), {
|
|
262
|
+
phase: "completion", provider: "nan",
|
|
253
263
|
reviewerModel: "nan/deepseek-v4-flash", stopReason: "length",
|
|
254
264
|
usage: { input: 12, output: 64, reasoning: 64, cacheRead: 0, cacheWrite: 0, totalTokens: 76 },
|
|
255
265
|
content: { blocks: 2, textBlocks: 1, thinkingBlocks: 1, textChars: 0, thinkingChars: 16 },
|
|
@@ -377,6 +387,166 @@ test("refuses with ABORTED when the provider resolves partial text after the cal
|
|
|
377
387
|
});
|
|
378
388
|
|
|
379
389
|
// ---------------------------------------------------------------------------
|
|
390
|
+
// Host deadlines must settle even when an auth/provider implementation ignores
|
|
391
|
+
// cancellation. The independent watchdog makes a broken implementation fail
|
|
392
|
+
// without leaving this suite waiting indefinitely.
|
|
393
|
+
function deferred<T>() {
|
|
394
|
+
let resolve!: (value: T) => void;
|
|
395
|
+
let reject!: (reason: unknown) => void;
|
|
396
|
+
const promise = new Promise<T>((yes, no) => { resolve = yes; reject = no; });
|
|
397
|
+
return { promise, resolve, reject };
|
|
398
|
+
}
|
|
399
|
+
// Capture real timers before per-test mocks: a broken handshake must still
|
|
400
|
+
// fail independently even while the reviewer deadline is driven manually.
|
|
401
|
+
const watchdogSetTimeout = setTimeout;
|
|
402
|
+
const watchdogClearTimeout = clearTimeout;
|
|
403
|
+
async function bounded<T>(promise: Promise<T>): Promise<T> {
|
|
404
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
405
|
+
try {
|
|
406
|
+
return await Promise.race([promise, new Promise<never>((_, reject) => {
|
|
407
|
+
timer = watchdogSetTimeout(() => reject(new Error("reviewer did not settle within the independent 250ms watchdog")), 250);
|
|
408
|
+
})]);
|
|
409
|
+
} finally { watchdogClearTimeout(timer!); }
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
test("host deadline bounds authentication that never resolves", async () => {
|
|
413
|
+
let completions = 0;
|
|
414
|
+
const outcome = await bounded(runInProcessReviewer(baseRequest({ timeoutMs: 15 }), {
|
|
415
|
+
registry: fakeRegistry([fakeModel()], async () => await new Promise(() => {})),
|
|
416
|
+
complete: (async () => { completions++; return assistantText("must not run"); }) as typeof completeSimple,
|
|
417
|
+
}));
|
|
418
|
+
assert.equal(expectRefused(outcome).code, INPROCESS_REVIEWER_FAILURE.TIMED_OUT);
|
|
419
|
+
assert.equal(completions, 0);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
test("host deadline skips auth and dispatch for an already cancelled caller", async () => {
|
|
423
|
+
const caller = new AbortController(); caller.abort();
|
|
424
|
+
let authentications = 0, completions = 0;
|
|
425
|
+
const outcome = await runInProcessReviewer(baseRequest({ signal: caller.signal }), {
|
|
426
|
+
registry: fakeRegistry([fakeModel()], async () => { authentications++; return { ok: true, apiKey: "fixture" }; }),
|
|
427
|
+
complete: (async () => { completions++; return assistantText("must not run"); }) as typeof completeSimple,
|
|
428
|
+
});
|
|
429
|
+
assert.equal(expectRefused(outcome).code, INPROCESS_REVIEWER_FAILURE.ABORTED);
|
|
430
|
+
assert.equal(authentications, 0); assert.equal(completions, 0);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
for (const stop of ["caller", "deadline"] as const) {
|
|
434
|
+
test(`host deadline does not dispatch after late authentication following ${stop}`, async () => {
|
|
435
|
+
const auth = deferred<Awaited<ReturnType<InProcessReviewerRegistry["getApiKeyAndHeaders"]>>>();
|
|
436
|
+
const caller = new AbortController();
|
|
437
|
+
let completions = 0;
|
|
438
|
+
const pending = runInProcessReviewer(baseRequest({ signal: caller.signal, timeoutMs: stop === "deadline" ? 15 : 30_000 }), {
|
|
439
|
+
registry: fakeRegistry([fakeModel()], () => auth.promise),
|
|
440
|
+
complete: (async () => { completions++; return assistantText("must not run"); }) as typeof completeSimple,
|
|
441
|
+
});
|
|
442
|
+
if (stop === "caller") caller.abort();
|
|
443
|
+
try {
|
|
444
|
+
const outcome = await bounded(pending);
|
|
445
|
+
assert.equal(expectRefused(outcome).code, stop === "caller" ? INPROCESS_REVIEWER_FAILURE.ABORTED : INPROCESS_REVIEWER_FAILURE.TIMED_OUT);
|
|
446
|
+
} finally { auth.resolve({ ok: true, apiKey: "fixture" }); }
|
|
447
|
+
await nextTurn();
|
|
448
|
+
assert.equal(completions, 0);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
for (const composed of [false, true]) {
|
|
453
|
+
for (const late of ["fulfill", "reject"] as const) {
|
|
454
|
+
test(`host deadline settles non-cooperative ${composed ? "composed" : "compat"} completion and consumes late ${late}`, { timeout: 5_000 }, async t => {
|
|
455
|
+
let clock = 0;
|
|
456
|
+
t.mock.method(performance, "now", () => clock);
|
|
457
|
+
t.mock.timers.enable({ apis: ["setTimeout"] });
|
|
458
|
+
const completion = deferred<AssistantMessage>(), entered = deferred<void>();
|
|
459
|
+
const registry = fakeRegistry([fakeModel()]);
|
|
460
|
+
let calls = 0, providerSignal: AbortSignal | undefined;
|
|
461
|
+
const complete = (async (_model, _context, options) => { calls++; providerSignal = options?.signal; entered.resolve(); return await completion.promise; }) as typeof completeSimple;
|
|
462
|
+
if (composed) registry.getProvider = () => ({ streamSimple: (model, context, options) => ({ result: () => complete(model, context, options) }) });
|
|
463
|
+
const pending = runInProcessReviewer(baseRequest({ timeoutMs: 15 }), { registry, complete });
|
|
464
|
+
try {
|
|
465
|
+
// This test targets a completion already dispatched. Contention
|
|
466
|
+
// before auth/dispatch must not expire its deadline accidentally.
|
|
467
|
+
await bounded(entered.promise);
|
|
468
|
+
assert.equal(calls, 1);
|
|
469
|
+
clock = 15; t.mock.timers.tick(15);
|
|
470
|
+
const outcome = await bounded(pending);
|
|
471
|
+
assert.equal(expectRefused(outcome).code, INPROCESS_REVIEWER_FAILURE.TIMED_OUT);
|
|
472
|
+
assert.equal(providerSignal?.aborted, true); assert.equal(calls, 1);
|
|
473
|
+
} finally {
|
|
474
|
+
if (late === "fulfill" || calls === 0) completion.resolve(assistantText("late text must never be admitted"));
|
|
475
|
+
else completion.reject(new Error("late provider rejection must be consumed"));
|
|
476
|
+
}
|
|
477
|
+
await nextTurn();
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
test(`host deadline bounds caller cancellation of a non-cooperative ${composed ? "composed" : "compat"} completion`, async () => {
|
|
481
|
+
const completion = deferred<AssistantMessage>(), entered = deferred<void>();
|
|
482
|
+
const caller = new AbortController(), registry = fakeRegistry([fakeModel()]);
|
|
483
|
+
let providerSignal: AbortSignal | undefined;
|
|
484
|
+
const complete = (async (_model, _context, options) => { providerSignal = options?.signal; entered.resolve(); return await completion.promise; }) as typeof completeSimple;
|
|
485
|
+
if (composed) registry.getProvider = () => ({ streamSimple: (model, context, options) => ({ result: () => complete(model, context, options) }) });
|
|
486
|
+
const pending = runInProcessReviewer(baseRequest({ signal: caller.signal }), { registry, complete });
|
|
487
|
+
try {
|
|
488
|
+
await bounded(entered.promise);
|
|
489
|
+
caller.abort();
|
|
490
|
+
assert.equal(expectRefused(await bounded(pending)).code, INPROCESS_REVIEWER_FAILURE.ABORTED);
|
|
491
|
+
assert.equal(providerSignal?.aborted, true);
|
|
492
|
+
assert.equal(getEventListeners(caller.signal, "abort").length, 0);
|
|
493
|
+
assert.equal(getEventListeners(providerSignal!, "abort").length, 0);
|
|
494
|
+
} finally { caller.abort(); completion.resolve(assistantText("late text")); }
|
|
495
|
+
await nextTurn();
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
test("host deadline checks monotonic elapsed time after auth before the timer can run", async t => {
|
|
500
|
+
let clock = 0, calls = 0;
|
|
501
|
+
t.mock.method(performance, "now", () => clock);
|
|
502
|
+
const auth = deferred<Awaited<ReturnType<InProcessReviewerRegistry["getApiKeyAndHeaders"]>>>();
|
|
503
|
+
const pending = runInProcessReviewer(baseRequest({ timeoutMs: 100 }), {
|
|
504
|
+
registry: fakeRegistry([fakeModel()], () => auth.promise),
|
|
505
|
+
complete: (async () => { calls++; return assistantText("must not run"); }) as typeof completeSimple,
|
|
506
|
+
});
|
|
507
|
+
clock = 101;
|
|
508
|
+
auth.resolve({ ok: true, apiKey: "fixture" });
|
|
509
|
+
assert.equal(expectRefused(await bounded(pending)).code, INPROCESS_REVIEWER_FAILURE.TIMED_OUT);
|
|
510
|
+
assert.equal(calls, 0);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
test("host deadline takes precedence when caller cancellation is observed after expiry", async t => {
|
|
514
|
+
let clock = 0;
|
|
515
|
+
t.mock.method(performance, "now", () => clock);
|
|
516
|
+
const caller = new AbortController();
|
|
517
|
+
const pending = runInProcessReviewer(baseRequest({ timeoutMs: 100, signal: caller.signal }), {
|
|
518
|
+
registry: fakeRegistry([fakeModel()], async () => await new Promise(() => {})), complete: unreachableComplete,
|
|
519
|
+
});
|
|
520
|
+
clock = 100;
|
|
521
|
+
caller.abort();
|
|
522
|
+
assert.equal(expectRefused(await bounded(pending)).code, INPROCESS_REVIEWER_FAILURE.TIMED_OUT);
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
test("host deadline removes its caller listener when authentication throws", async () => {
|
|
526
|
+
const caller = new AbortController(), expected = new Error("auth fixture");
|
|
527
|
+
await assert.rejects(runInProcessReviewer(baseRequest({ signal: caller.signal }), {
|
|
528
|
+
registry: fakeRegistry([fakeModel()], async () => { throw expected; }), complete: unreachableComplete,
|
|
529
|
+
}), error => error === expected);
|
|
530
|
+
assert.equal(getEventListeners(caller.signal, "abort").length, 0);
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
test("host deadline cleans caller/provider listeners and its timer after success", async t => {
|
|
534
|
+
t.mock.timers.enable({ apis: ["setTimeout"] });
|
|
535
|
+
const caller = new AbortController();
|
|
536
|
+
let providerSignal: AbortSignal | undefined;
|
|
537
|
+
const outcome = await runInProcessReviewer(baseRequest({ signal: caller.signal }), {
|
|
538
|
+
registry: fakeRegistry([fakeModel()]),
|
|
539
|
+
complete: (async (_model, _context, options) => { providerSignal = options?.signal; return assistantText("done"); }) as typeof completeSimple,
|
|
540
|
+
});
|
|
541
|
+
assert.equal(expectText(outcome).text, "done");
|
|
542
|
+
assert.equal(getEventListeners(caller.signal, "abort").length, 0);
|
|
543
|
+
assert.equal(getEventListeners(providerSignal!, "abort").length, 0);
|
|
544
|
+
t.mock.timers.tick(30_000);
|
|
545
|
+
assert.equal(providerSignal?.aborted, false, "a completed call must not retain a deadline timer");
|
|
546
|
+
caller.abort();
|
|
547
|
+
assert.equal(providerSignal?.aborted, false, "a completed call must detach its caller signal");
|
|
548
|
+
});
|
|
549
|
+
|
|
380
550
|
// Exact Context passed to complete
|
|
381
551
|
// ---------------------------------------------------------------------------
|
|
382
552
|
|
|
@@ -713,7 +883,7 @@ test("refuses instead of falling back when getProvider returns undefined for a m
|
|
|
713
883
|
const refused = expectRefused(outcome);
|
|
714
884
|
assert.equal(refused.code, INPROCESS_REVIEWER_FAILURE.MODEL_NOT_FOUND);
|
|
715
885
|
assert.match(refused.message, /review-risk/);
|
|
716
|
-
assert.deepEqual(refused.evidence, { provider: "openai", api: "openai-responses" }, "the evidence separates this cause from a plain unresolved selection");
|
|
886
|
+
assert.deepEqual(withoutRunTiming(refused.evidence), { provider: "openai", api: "openai-responses", reviewerModel: "openai/gpt-5", phase: "configuration" }, "the evidence separates this cause from a plain unresolved selection");
|
|
717
887
|
});
|
|
718
888
|
|
|
719
889
|
// ---------------------------------------------------------------------------
|
|
@@ -833,7 +1003,9 @@ for (const transport of ["sse", "websocket", "websocket-cached", "auto", undefin
|
|
|
833
1003
|
streamSimple: (model, context, options) => ({ result: () => captured.complete(model, context, options) }),
|
|
834
1004
|
});
|
|
835
1005
|
const outcome = await runInProcessReviewer(baseRequest({ transport }), { registry, complete: captured.complete });
|
|
836
|
-
|
|
1006
|
+
const { evidence, ...completion } = outcome;
|
|
1007
|
+
assert.deepEqual(completion, { kind: "text", text: "review result", reviewerModel: "openai/gpt-5" });
|
|
1008
|
+
assert.equal(evidence?.phase, "completion");
|
|
837
1009
|
assert.equal(captured.calls.length, 1);
|
|
838
1010
|
assert.equal(captured.calls[0]!.options?.transport, transport);
|
|
839
1011
|
assert.equal(Object.hasOwn(captured.calls[0]!.options!, "transport"), transport !== undefined);
|
|
@@ -945,7 +945,7 @@ posixTest("production Node process adapter propagates ordinary nonzero tar exit
|
|
|
945
945
|
try {
|
|
946
946
|
writeFileSync(join(f.home, "unrelated.txt"), "preserve");
|
|
947
947
|
f.executable("tar", "exit 7");
|
|
948
|
-
const result = await guardedFixture(node, [productionPnpmRunner(f.root, f.home, f.bin)], {},
|
|
948
|
+
const result = await guardedFixture(node, [productionPnpmRunner(f.root, f.home, f.bin)], {}, 15000);
|
|
949
949
|
assert.equal(result.guardKilled, false);
|
|
950
950
|
assert.equal(result.status, 1);
|
|
951
951
|
assert.match(result.stderr, /acquisition rejected/);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { cpSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
5
|
-
import {
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
6
7
|
import { artifactFor } from "../scripts/installer-downloads.mjs";
|
|
7
8
|
import test from "node:test";
|
|
8
|
-
import {
|
|
9
|
+
import { collectInventory, goAcquisition, planPreflight, pnpmGlobalBin, requirements } from "../scripts/installer-preflight.mjs";
|
|
9
10
|
|
|
10
11
|
const absent = { available: false };
|
|
11
12
|
const tool = (version: string) => ({ available: true, version, usable: true });
|
|
@@ -32,7 +33,7 @@ test("requirements follow repository metadata and native installer pin", () => {
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
test("preflight imports a packed manifest without packageManager using the verified pnpm pin", () => {
|
|
35
|
-
const root = mkdtempSync(
|
|
36
|
+
const root = mkdtempSync(join(tmpdir(), "gentle-preflight-packed-"));
|
|
36
37
|
try {
|
|
37
38
|
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
38
39
|
delete pkg.packageManager;
|
|
@@ -295,7 +296,7 @@ test("an older Pi that pnpm or npm owns is updated before Gentle Shell is instal
|
|
|
295
296
|
assert.deepEqual(plan.blockers, [], owner);
|
|
296
297
|
assert.deepEqual(plan.tools.pi, { status: "needs-update", required: requirements.pi, version: "0.87.1", owner });
|
|
297
298
|
assert.deepEqual(updateIds(plan), ["update-pi", "install-shell", "setup-shell", "verify-readiness"]);
|
|
298
|
-
assert.deepEqual(plan.actions[0], { id: "update-pi", kind: "upgrade", target: "pi", version:
|
|
299
|
+
assert.deepEqual(plan.actions[0], { id: "update-pi", kind: "upgrade", target: "pi", version: "latest" });
|
|
299
300
|
assert.equal(plan.ready, false);
|
|
300
301
|
}
|
|
301
302
|
});
|