@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.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/.pi/skills/browser/SKILL.md +84 -29
- package/.pi/skills/browser/UPSTREAM.md +13 -1
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +150 -0
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +305 -0
- package/.pi/skills/browser/references/web.agent.md +323 -0
- package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
- package/.pi/skills/doctor/SKILL.md +4 -9
- package/.pi/skills/doctor/_lib/checks.ts +133 -54
- package/.pi/skills/doctor/_lib/derive-tokens.ts +5 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +52 -0
- package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/pi-resolution.md +21 -1
- package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
- package/.pi/skills/pi-dashboard/SKILL.md +10 -3
- package/.pi/skills/pi-dashboard/references/api-reference.agent.md +69 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.md +41 -34
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
- package/README.md +19 -0
- package/agents/DoxTriage.md +80 -0
- package/package.json +30 -16
- package/src/ask-user-tool.ts +4 -0
- package/src/auto-session-namer.ts +486 -70
- package/src/autostart-guard.ts +99 -0
- package/src/autostart-lock.ts +258 -0
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +106 -23
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +1760 -350
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +392 -71
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +846 -17
- package/src/custom-entry-forward.ts +92 -0
- package/src/endpoint-resolution.ts +253 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -0
- package/src/git-dir-watcher.ts +79 -0
- package/src/git-poll.ts +45 -12
- package/src/git-probe-scheduler.ts +119 -0
- package/src/git-tracker.ts +284 -0
- package/src/instance-verification.ts +156 -0
- package/src/local-token-header.ts +44 -0
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +340 -0
- package/src/model-refresh.ts +95 -0
- package/src/model-tracker.ts +118 -35
- package/src/notify-proxy.ts +36 -0
- package/src/path-gate/decide.ts +149 -0
- package/src/path-gate/grant-cache.ts +71 -0
- package/src/path-gate/grant-link.ts +108 -0
- package/src/path-gate/handler.ts +307 -0
- package/src/path-gate/index.ts +155 -0
- package/src/path-gate/resolve.ts +126 -0
- package/src/path-gate/roots.ts +137 -0
- package/src/path-gate/suppression.ts +27 -0
- package/src/pending-prompt-emitter.ts +59 -0
- package/src/pi-env.d.ts +6 -10
- package/src/pi-retry-settings.ts +91 -0
- package/src/plugin-request-client.ts +114 -0
- package/src/poll-cost.ts +40 -0
- package/src/pr-status.ts +338 -0
- package/src/process-metrics.ts +77 -1
- package/src/process-scan-scheduler.ts +137 -0
- package/src/process-scanner.ts +226 -247
- package/src/project-init/dox-kb-config.ts +3 -0
- package/src/project-init/scaffold.ts +1 -4
- package/src/project-init/seed-doctrine.ts +23 -60
- package/src/prompt-bus.ts +13 -0
- package/src/provider-register.ts +92 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +258 -86
- package/src/role-manager.ts +38 -91
- package/src/role-model-tools.ts +44 -3
- package/src/server-auto-start.ts +331 -20
- package/src/server-launcher.ts +70 -34
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +75 -20
- package/src/slash-dispatch.ts +66 -81
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-forward-sites.ts +69 -0
- package/src/subagent-frame-buffer.ts +24 -3
- package/src/subagent-frame-strip.ts +109 -0
- package/src/subagent-saturation.ts +196 -0
- package/src/subagent-tick-throttle.ts +250 -0
- package/src/terminal-reload.ts +298 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/src/usage-drain.ts +167 -0
- package/src/vcs-info.ts +261 -63
- package/.pi/skills/doctor/AGENTS.md +0 -27
- package/.pi/skills/project-init/dox-doctrine.md +0 -104
- package/src/AGENTS.md +0 -57
- package/src/__tests__/abort-latch.test.ts +0 -97
- package/src/__tests__/agent-settled.test.ts +0 -82
- package/src/__tests__/artifact-roots.test.ts +0 -83
- package/src/__tests__/ask-user-attachments.test.ts +0 -106
- package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
- package/src/__tests__/ask-user-tool.test.ts +0 -571
- package/src/__tests__/auto-session-namer.test.ts +0 -339
- package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
- package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
- package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
- package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
- package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
- package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
- package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
- package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
- package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
- package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
- package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
- package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
- package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
- package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
- package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
- package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
- package/src/__tests__/bridge-system-followup.test.ts +0 -163
- package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
- package/src/__tests__/browser-skill-registered.test.ts +0 -84
- package/src/__tests__/build-provider-catalogue.test.ts +0 -210
- package/src/__tests__/command-handler.test.ts +0 -1180
- package/src/__tests__/commit-draft.test.ts +0 -100
- package/src/__tests__/connection-dropped-frames.test.ts +0 -78
- package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
- package/src/__tests__/connection.test.ts +0 -344
- package/src/__tests__/credentials-updated.test.ts +0 -26
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
- package/src/__tests__/cwd-missing-probe.test.ts +0 -82
- package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
- package/src/__tests__/dashboard-context-injector.test.ts +0 -190
- package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
- package/src/__tests__/dev-build.test.ts +0 -79
- package/src/__tests__/doctor/checks.test.ts +0 -121
- package/src/__tests__/doctor/modules.test.ts +0 -64
- package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
- package/src/__tests__/doctor/router.test.ts +0 -143
- package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
- package/src/__tests__/empty-actionable-guard.test.ts +0 -73
- package/src/__tests__/enrich-model-metadata.test.ts +0 -222
- package/src/__tests__/event-forwarder.test.ts +0 -119
- package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
- package/src/__tests__/filter-enabled-models.test.ts +0 -151
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
- package/src/__tests__/fork-entryid-timing.test.ts +0 -88
- package/src/__tests__/git-info-status.test.ts +0 -73
- package/src/__tests__/git-link-builder.test.ts +0 -102
- package/src/__tests__/git-poll.test.ts +0 -69
- package/src/__tests__/markdown-image-inliner.test.ts +0 -392
- package/src/__tests__/model-resolve.test.ts +0 -379
- package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
- package/src/__tests__/multiselect-list.test.ts +0 -137
- package/src/__tests__/multiselect-polyfill.test.ts +0 -92
- package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
- package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
- package/src/__tests__/openspec-activity-detector.test.ts +0 -337
- package/src/__tests__/openspec-cli-shim.test.ts +0 -145
- package/src/__tests__/openspec-poller.test.ts +0 -124
- package/src/__tests__/pi-version-tracker.test.ts +0 -109
- package/src/__tests__/process-metrics.test.ts +0 -47
- package/src/__tests__/process-scanner-kill.test.ts +0 -61
- package/src/__tests__/process-scanner.test.ts +0 -292
- package/src/__tests__/project-init-detect-stack.test.ts +0 -61
- package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
- package/src/__tests__/project-init-profiles.test.ts +0 -84
- package/src/__tests__/project-init-scaffold.test.ts +0 -139
- package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
- package/src/__tests__/project-trust.test.ts +0 -92
- package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
- package/src/__tests__/prompt-bus.test.ts +0 -513
- package/src/__tests__/prompt-expander.test.ts +0 -398
- package/src/__tests__/provider-register-native-models.test.ts +0 -182
- package/src/__tests__/provider-register-reload.test.ts +0 -498
- package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
- package/src/__tests__/retry-tracker.test.ts +0 -152
- package/src/__tests__/role-manager.test.ts +0 -585
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
- package/src/__tests__/role-model-tools.test.ts +0 -229
- package/src/__tests__/search-files-completeness.test.ts +0 -111
- package/src/__tests__/search-files-ranking.test.ts +0 -168
- package/src/__tests__/server-auto-start.test.ts +0 -375
- package/src/__tests__/server-launcher-launch.test.ts +0 -96
- package/src/__tests__/server-launcher.test.ts +0 -101
- package/src/__tests__/server-probe.test.ts +0 -25
- package/src/__tests__/session-switch.test.ts +0 -139
- package/src/__tests__/session-sync.test.ts +0 -243
- package/src/__tests__/single-derivation-guard.test.ts +0 -39
- package/src/__tests__/source-detector.test.ts +0 -88
- package/src/__tests__/stats-extractor.test.ts +0 -92
- package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
- package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
- package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
- package/src/__tests__/turn-actionability.test.ts +0 -86
- package/src/__tests__/ui-decorators.test.ts +0 -309
- package/src/__tests__/ui-modules.test.ts +0 -293
- package/src/__tests__/vcs-info.test.ts +0 -265
- package/src/__tests__/visibility-intent.test.ts +0 -43
- package/src/__tests__/watchdog.test.ts +0 -161
- package/src/abort-latch.ts.AGENTS.md +0 -3
- package/src/agent-settled.ts +0 -72
- package/src/agent-settled.ts.AGENTS.md +0 -3
- package/src/artifact-roots.ts.AGENTS.md +0 -3
- package/src/ask-user-attachments.ts.AGENTS.md +0 -3
- package/src/ask-user-tool.ts.AGENTS.md +0 -3
- package/src/auto-session-namer.ts.AGENTS.md +0 -3
- package/src/bridge-context.ts.AGENTS.md +0 -3
- package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
- package/src/bridge.ts.AGENTS.md +0 -3
- package/src/command-handler.ts.AGENTS.md +0 -3
- package/src/commit-draft-agent.ts.AGENTS.md +0 -3
- package/src/commit-draft.ts.AGENTS.md +0 -3
- package/src/connection.ts.AGENTS.md +0 -3
- package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
- package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
- package/src/dev-build.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
- package/src/event-forwarder.ts.AGENTS.md +0 -3
- package/src/flow-event-wiring.ts.AGENTS.md +0 -3
- package/src/git-link-builder.ts.AGENTS.md +0 -3
- package/src/git-poll.ts.AGENTS.md +0 -3
- package/src/hasui-flip.ts.AGENTS.md +0 -3
- package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
- package/src/model-tracker.ts.AGENTS.md +0 -3
- package/src/multiselect-decode.ts.AGENTS.md +0 -3
- package/src/multiselect-list.ts.AGENTS.md +0 -3
- package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
- package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
- package/src/process-metrics.ts.AGENTS.md +0 -3
- package/src/process-scanner.ts.AGENTS.md +0 -3
- package/src/project-init/AGENTS.md +0 -12
- package/src/project-trust.ts.AGENTS.md +0 -3
- package/src/prompt-bus.ts.AGENTS.md +0 -3
- package/src/prompt-expander.ts.AGENTS.md +0 -3
- package/src/provider-register.ts.AGENTS.md +0 -3
- package/src/retry-tracker.ts.AGENTS.md +0 -3
- package/src/role-manager.ts.AGENTS.md +0 -3
- package/src/role-model-tools.ts.AGENTS.md +0 -3
- package/src/server-auto-start.ts.AGENTS.md +0 -3
- package/src/server-launcher.ts.AGENTS.md +0 -3
- package/src/session-sync.ts.AGENTS.md +0 -3
- package/src/slash-dispatch.ts.AGENTS.md +0 -3
- package/src/source-detector.ts.AGENTS.md +0 -3
- package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
- package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
- package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
- package/src/turn-actionability.ts.AGENTS.md +0 -3
- package/src/ui-modules.ts.AGENTS.md +0 -3
- package/src/vcs-info.ts.AGENTS.md +0 -3
- package/src/visibility-intent.ts.AGENTS.md +0 -3
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridge abort-latch behaviour: a user abort must stop pi's in-flight retry
|
|
3
|
-
* even across a provider backoff that outlives the 2 s persistent-abort
|
|
4
|
-
* scheduler. The latch is abort-on-sight, cleared by a new user prompt or
|
|
5
|
-
* turn settle.
|
|
6
|
-
*
|
|
7
|
-
* `LatchSim` mirrors the bridge wiring (see bridge.ts): abort sets the latch
|
|
8
|
-
* and records the wrapper-abort; any observed resumption (assistant
|
|
9
|
-
* message_start / agent_start) while latched issues a fresh cachedCtx.abort();
|
|
10
|
-
* a new user prompt or agent_end clears the latch.
|
|
11
|
-
*
|
|
12
|
-
* See change: unify-error-retry-lifecycle.
|
|
13
|
-
*/
|
|
14
|
-
import { describe, it, expect } from "vitest";
|
|
15
|
-
import { AbortLatch } from "../abort-latch.js";
|
|
16
|
-
|
|
17
|
-
class LatchSim {
|
|
18
|
-
/** Ordered log of cachedCtx.abort() invocations: "wrapper" (initial) | "latch" (re-abort). */
|
|
19
|
-
readonly aborts: string[] = [];
|
|
20
|
-
private latch = new AbortLatch();
|
|
21
|
-
|
|
22
|
-
/** User pressed Stop/Dismiss → wrapper-abort once + latch on. */
|
|
23
|
-
userAbort(sessionId: string): void {
|
|
24
|
-
this.aborts.push("wrapper");
|
|
25
|
-
this.latch.request(sessionId);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Bridge observes the aborted turn resuming (retry attempt). */
|
|
29
|
-
resume(sessionId: string): void {
|
|
30
|
-
if (this.latch.shouldAbort(sessionId)) this.aborts.push("latch");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** A new user prompt is dispatched (deliberate new turn). */
|
|
34
|
-
userPrompt(sessionId: string): void {
|
|
35
|
-
this.latch.clear(sessionId);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The aborted turn settled (agent_end / idle). */
|
|
39
|
-
settle(sessionId: string): void {
|
|
40
|
-
this.latch.clear(sessionId);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
isLatched(sessionId: string): boolean {
|
|
44
|
-
return this.latch.isActive(sessionId);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
describe("AbortLatch", () => {
|
|
49
|
-
it("re-aborts a retry that wakes after the 2 s scheduler window", () => {
|
|
50
|
-
const sim = new LatchSim();
|
|
51
|
-
sim.userAbort("s1");
|
|
52
|
-
// ...30 s backoff elapses; the persistent-abort scheduler already stopped
|
|
53
|
-
// after 2 s. pi wakes and attempts to continue the same aborted turn.
|
|
54
|
-
sim.resume("s1");
|
|
55
|
-
expect(sim.aborts).toEqual(["wrapper", "latch"]);
|
|
56
|
-
expect(sim.isLatched("s1")).toBe(true); // still latched until settle / new prompt
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("re-aborts repeatedly across multiple resumption attempts", () => {
|
|
60
|
-
const sim = new LatchSim();
|
|
61
|
-
sim.userAbort("s1");
|
|
62
|
-
sim.resume("s1");
|
|
63
|
-
sim.resume("s1");
|
|
64
|
-
expect(sim.aborts).toEqual(["wrapper", "latch", "latch"]);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("clears on a new user prompt and does NOT kill the new turn", () => {
|
|
68
|
-
const sim = new LatchSim();
|
|
69
|
-
sim.userAbort("s1");
|
|
70
|
-
sim.userPrompt("s1"); // deliberate new turn → clears latch
|
|
71
|
-
sim.resume("s1"); // the new turn's first assistant message_start
|
|
72
|
-
expect(sim.aborts).toEqual(["wrapper"]); // no latch re-abort
|
|
73
|
-
expect(sim.isLatched("s1")).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("clears on settle (agent_end / idle)", () => {
|
|
77
|
-
const sim = new LatchSim();
|
|
78
|
-
sim.userAbort("s1");
|
|
79
|
-
sim.settle("s1");
|
|
80
|
-
sim.resume("s1"); // a later, unrelated turn
|
|
81
|
-
expect(sim.aborts).toEqual(["wrapper"]);
|
|
82
|
-
expect(sim.isLatched("s1")).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("latch is per-session — aborting s1 never re-aborts s2", () => {
|
|
86
|
-
const sim = new LatchSim();
|
|
87
|
-
sim.userAbort("s1");
|
|
88
|
-
sim.resume("s2");
|
|
89
|
-
expect(sim.aborts).toEqual(["wrapper"]);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("does not re-abort when no abort was requested", () => {
|
|
93
|
-
const sim = new LatchSim();
|
|
94
|
-
sim.resume("s1");
|
|
95
|
-
expect(sim.aborts).toEqual([]);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridge `agent_settled` normalization — pure decision logic.
|
|
3
|
-
*
|
|
4
|
-
* The bridge guarantees exactly ONE terminal `agent_settled` per run on every
|
|
5
|
-
* supported pi: native (≥ 0.80.4) is forwarded as-is with no synth; floor pi
|
|
6
|
-
* (< 0.80.4) gets a synthetic settle synchronously after each `agent_end`.
|
|
7
|
-
*
|
|
8
|
-
* See change: adopt-pi-074-080-features (A.1 — E1, E2, F8, X2).
|
|
9
|
-
*/
|
|
10
|
-
import { describe, expect, it } from "vitest";
|
|
11
|
-
import {
|
|
12
|
-
NATIVE_AGENT_SETTLED_FLOOR,
|
|
13
|
-
nativeAgentSettledSupported,
|
|
14
|
-
settleFollowUp,
|
|
15
|
-
synthesizeAgentSettledEvent,
|
|
16
|
-
} from "../agent-settled.js";
|
|
17
|
-
|
|
18
|
-
describe("nativeAgentSettledSupported", () => {
|
|
19
|
-
it("E1: 0.80.4 (boundary floor) supports native settle", () => {
|
|
20
|
-
expect(nativeAgentSettledSupported("0.80.4")).toBe(true);
|
|
21
|
-
expect(NATIVE_AGENT_SETTLED_FLOOR).toBe("0.80.4");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("E2: 0.80.3 (just below floor) does NOT support native settle", () => {
|
|
25
|
-
expect(nativeAgentSettledSupported("0.80.3")).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("F8: a modern pi (0.80.10) supports native settle", () => {
|
|
29
|
-
expect(nativeAgentSettledSupported("0.80.10")).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("older majors/minors defer to synth", () => {
|
|
33
|
-
expect(nativeAgentSettledSupported("0.78.0")).toBe(false);
|
|
34
|
-
expect(nativeAgentSettledSupported("0.79.10")).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("newer versions support native settle", () => {
|
|
38
|
-
expect(nativeAgentSettledSupported("0.81.0")).toBe(true);
|
|
39
|
-
expect(nativeAgentSettledSupported("1.0.0")).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("ignores pre-release / build suffixes", () => {
|
|
43
|
-
expect(nativeAgentSettledSupported("0.80.4-rc.1")).toBe(true);
|
|
44
|
-
expect(nativeAgentSettledSupported("0.80.3-beta")).toBe(false);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("unknown / unparseable version is treated as floor (synthesize)", () => {
|
|
48
|
-
expect(nativeAgentSettledSupported(undefined)).toBe(false);
|
|
49
|
-
expect(nativeAgentSettledSupported("")).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("settleFollowUp", () => {
|
|
54
|
-
it("E1/F8: native pi never synthesizes after agent_end", () => {
|
|
55
|
-
expect(settleFollowUp("agent_end", true, 100)).toBeNull();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("E2: floor pi synthesizes exactly one settle after agent_end", () => {
|
|
59
|
-
const synth = settleFollowUp("agent_end", false, 100);
|
|
60
|
-
expect(synth).toEqual({ eventType: "agent_settled", timestamp: 100, data: {} });
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("F8/X2: a real agent_settled never produces a follow-up synth", () => {
|
|
64
|
-
expect(settleFollowUp("agent_settled", true, 100)).toBeNull();
|
|
65
|
-
expect(settleFollowUp("agent_settled", false, 100)).toBeNull();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("other events never synthesize", () => {
|
|
69
|
-
expect(settleFollowUp("agent_start", false, 100)).toBeNull();
|
|
70
|
-
expect(settleFollowUp("turn_end", false, 100)).toBeNull();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("synthesizeAgentSettledEvent", () => {
|
|
75
|
-
it("carries no payload (agent_settled has no data)", () => {
|
|
76
|
-
expect(synthesizeAgentSettledEvent(42)).toEqual({
|
|
77
|
-
eventType: "agent_settled",
|
|
78
|
-
timestamp: 42,
|
|
79
|
-
data: {},
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the bridge's artifact-root allowlist (Fix B containment).
|
|
3
|
-
* See change: inline-agent-screenshot-artifacts.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from "vitest";
|
|
6
|
-
import { resolveArtifactRoots, isUnderArtifactRoot } from "../artifact-roots.js";
|
|
7
|
-
|
|
8
|
-
/** realpathSync stub: returns mapped value, throws ENOENT for unknown paths. */
|
|
9
|
-
function fakeRealpath(map: Record<string, string>) {
|
|
10
|
-
return (p: string): string => {
|
|
11
|
-
if (p in map) return map[p];
|
|
12
|
-
throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("resolveArtifactRoots", () => {
|
|
17
|
-
it("includes the default agent-browser tmp dir when it resolves", () => {
|
|
18
|
-
const roots = resolveArtifactRoots({
|
|
19
|
-
homedir: "/home/pi",
|
|
20
|
-
env: {},
|
|
21
|
-
realpathSync: fakeRealpath({ "/home/pi/.agent-browser/tmp": "/home/pi/.agent-browser/tmp" }),
|
|
22
|
-
});
|
|
23
|
-
expect(roots).toEqual(["/home/pi/.agent-browser/tmp"]);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("adds AGENT_BROWSER_SCREENSHOT_DIR when set", () => {
|
|
27
|
-
const roots = resolveArtifactRoots({
|
|
28
|
-
homedir: "/home/pi",
|
|
29
|
-
env: { AGENT_BROWSER_SCREENSHOT_DIR: "/shots" },
|
|
30
|
-
realpathSync: fakeRealpath({
|
|
31
|
-
"/home/pi/.agent-browser/tmp": "/home/pi/.agent-browser/tmp",
|
|
32
|
-
"/shots": "/real/shots",
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
expect(roots).toEqual(["/home/pi/.agent-browser/tmp", "/real/shots"]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("drops roots that do not resolve (missing dir)", () => {
|
|
39
|
-
const roots = resolveArtifactRoots({
|
|
40
|
-
homedir: "/home/pi",
|
|
41
|
-
env: {},
|
|
42
|
-
realpathSync: fakeRealpath({}), // nothing resolves
|
|
43
|
-
});
|
|
44
|
-
expect(roots).toEqual([]);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe("isUnderArtifactRoot", () => {
|
|
49
|
-
const roots = ["/home/pi/.agent-browser/tmp"];
|
|
50
|
-
const rp = fakeRealpath({
|
|
51
|
-
"/home/pi/.agent-browser/tmp/shot.png": "/home/pi/.agent-browser/tmp/shot.png",
|
|
52
|
-
"/home/pi/.agent-browser/tmp/sub/a.png": "/home/pi/.agent-browser/tmp/sub/a.png",
|
|
53
|
-
"/etc/passwd.png": "/etc/passwd.png",
|
|
54
|
-
"/home/pi/secret.png": "/home/pi/secret.png",
|
|
55
|
-
// symlink escape: realpath resolves outside the root
|
|
56
|
-
"/home/pi/.agent-browser/tmp/evil.png": "/etc/shadow.png",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("accepts a file directly inside a root", () => {
|
|
60
|
-
expect(isUnderArtifactRoot("/home/pi/.agent-browser/tmp/shot.png", roots, rp)).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("accepts a nested file", () => {
|
|
64
|
-
expect(isUnderArtifactRoot("/home/pi/.agent-browser/tmp/sub/a.png", roots, rp)).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("rejects a path outside every root", () => {
|
|
68
|
-
expect(isUnderArtifactRoot("/etc/passwd.png", roots, rp)).toBe(false);
|
|
69
|
-
expect(isUnderArtifactRoot("/home/pi/secret.png", roots, rp)).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("rejects a symlink whose realpath escapes the root", () => {
|
|
73
|
-
expect(isUnderArtifactRoot("/home/pi/.agent-browser/tmp/evil.png", roots, rp)).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("rejects a non-existent path (realpath throws)", () => {
|
|
77
|
-
expect(isUnderArtifactRoot("/home/pi/.agent-browser/tmp/missing.png", roots, rp)).toBe(false);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("rejects everything when the root list is empty", () => {
|
|
81
|
-
expect(isUnderArtifactRoot("/home/pi/.agent-browser/tmp/shot.png", [], rp)).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as os from "node:os";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
attachmentDirForSession,
|
|
7
|
-
extensionForMime,
|
|
8
|
-
hashBytes,
|
|
9
|
-
persistAttachment,
|
|
10
|
-
cleanupAttachmentsForSession,
|
|
11
|
-
MAX_PER_IMAGE_BYTES,
|
|
12
|
-
} from "../ask-user-attachments.js";
|
|
13
|
-
|
|
14
|
-
// Each test runs under a throwaway HOME so writes never touch the real ~/.pi.
|
|
15
|
-
let tmpHome: string;
|
|
16
|
-
let origHome: string | undefined;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
origHome = process.env.HOME;
|
|
20
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), "pi-attach-test-"));
|
|
21
|
-
process.env.HOME = tmpHome;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
process.env.HOME = origHome;
|
|
26
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const b64 = (s: string) => Buffer.from(s).toString("base64");
|
|
30
|
-
|
|
31
|
-
describe("ask-user-attachments", () => {
|
|
32
|
-
it("maps MIME to extension via the allowlist", () => {
|
|
33
|
-
expect(extensionForMime("image/png")).toBe(".png");
|
|
34
|
-
expect(extensionForMime("image/jpeg")).toBe(".jpg");
|
|
35
|
-
expect(extensionForMime("image/gif")).toBe(".gif");
|
|
36
|
-
expect(extensionForMime("image/webp")).toBe(".webp");
|
|
37
|
-
expect(extensionForMime("application/pdf")).toBeNull();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("hashBytes is deterministic and 16 hex chars", () => {
|
|
41
|
-
const h1 = hashBytes(Buffer.from("hello"));
|
|
42
|
-
const h2 = hashBytes(Buffer.from("hello"));
|
|
43
|
-
expect(h1).toBe(h2);
|
|
44
|
-
expect(h1).toMatch(/^[0-9a-f]{16}$/);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("persists an image and lazily creates the per-session dir", () => {
|
|
48
|
-
const sessionId = "sess-1";
|
|
49
|
-
const dir = attachmentDirForSession(sessionId);
|
|
50
|
-
expect(fs.existsSync(dir)).toBe(false);
|
|
51
|
-
|
|
52
|
-
const res = persistAttachment({
|
|
53
|
-
sessionId,
|
|
54
|
-
image: { type: "image", data: b64("PNGDATA"), mimeType: "image/png" },
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expect(res).not.toBeNull();
|
|
58
|
-
expect(res!.path.endsWith(".png")).toBe(true);
|
|
59
|
-
expect(res!.mimeType).toBe("image/png");
|
|
60
|
-
expect(res!.bytes).toBe(Buffer.from("PNGDATA").length);
|
|
61
|
-
expect(fs.existsSync(res!.path)).toBe(true);
|
|
62
|
-
expect(fs.existsSync(dir)).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("dedups by hash — same bytes write once", () => {
|
|
66
|
-
const sessionId = "sess-2";
|
|
67
|
-
const image = { type: "image" as const, data: b64("SAME"), mimeType: "image/png" };
|
|
68
|
-
const a = persistAttachment({ sessionId, image })!;
|
|
69
|
-
const mtimeA = fs.statSync(a.path).mtimeMs;
|
|
70
|
-
const b = persistAttachment({ sessionId, image })!;
|
|
71
|
-
expect(b.path).toBe(a.path);
|
|
72
|
-
// No rewrite — mtime unchanged.
|
|
73
|
-
expect(fs.statSync(b.path).mtimeMs).toBe(mtimeA);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("drops unsupported MIME types", () => {
|
|
77
|
-
const res = persistAttachment({
|
|
78
|
-
sessionId: "sess-3",
|
|
79
|
-
image: { type: "image", data: b64("X"), mimeType: "application/pdf" },
|
|
80
|
-
});
|
|
81
|
-
expect(res).toBeNull();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("drops images over the per-image cap", () => {
|
|
85
|
-
const big = Buffer.alloc(MAX_PER_IMAGE_BYTES + 1).toString("base64");
|
|
86
|
-
const res = persistAttachment({
|
|
87
|
-
sessionId: "sess-4",
|
|
88
|
-
image: { type: "image", data: big, mimeType: "image/png" },
|
|
89
|
-
});
|
|
90
|
-
expect(res).toBeNull();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("cleanup removes the session directory and tolerates a missing one", () => {
|
|
94
|
-
const sessionId = "sess-5";
|
|
95
|
-
persistAttachment({
|
|
96
|
-
sessionId,
|
|
97
|
-
image: { type: "image", data: b64("Y"), mimeType: "image/png" },
|
|
98
|
-
});
|
|
99
|
-
const dir = attachmentDirForSession(sessionId);
|
|
100
|
-
expect(fs.existsSync(dir)).toBe(true);
|
|
101
|
-
cleanupAttachmentsForSession(sessionId);
|
|
102
|
-
expect(fs.existsSync(dir)).toBe(false);
|
|
103
|
-
// Second call is a no-op (no throw).
|
|
104
|
-
expect(() => cleanupAttachmentsForSession(sessionId)).not.toThrow();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression guard for the `ask_user` tool's parameters JSON Schema shape.
|
|
3
|
-
*
|
|
4
|
-
* History:
|
|
5
|
-
* 1. Pre-a53933f — schema was `Type.Union` of per-method `Type.Object`
|
|
6
|
-
* arms (root-level `anyOf`). Anthropic loved it; OpenAI rejected it
|
|
7
|
-
* ("schema must be a JSON Schema of 'type: \"object\"', got
|
|
8
|
-
* 'type: \"None\"'").
|
|
9
|
-
*
|
|
10
|
-
* 2. a53933f — collapsed to a single flat `Type.Object` (root
|
|
11
|
-
* `type: "object"`, all fields optional). OpenAI happy. Anthropic
|
|
12
|
-
* lost its per-method strictness; Claude started emitting
|
|
13
|
-
* multiselect calls without `options` and the dashboard auto-
|
|
14
|
-
* cancelled them — the user-visible bug behind
|
|
15
|
-
* fix-multiselect-auto-cancel-on-dashboard.
|
|
16
|
-
*
|
|
17
|
-
* 3. Layer-2 attempt of fix-multiselect-auto-cancel-on-dashboard —
|
|
18
|
-
* tried to keep root `type: "object"` AND attach a body-level
|
|
19
|
-
* `oneOf` discriminator over `method`. Anthropic worked. Real
|
|
20
|
-
* OpenAI gpt-5 rejected it (verified 2026-04-30) with: "schema
|
|
21
|
-
* must have type 'object' and not have 'oneOf' / 'anyOf' / 'allOf'
|
|
22
|
-
* / 'enum' / 'not' at the top level." The fallback documented in
|
|
23
|
-
* tasks.md §9.7 was taken: Layer 2 dropped, Layer 1 (multiselect
|
|
24
|
-
* dashboard routing) ships alone — that's what actually fixes the
|
|
25
|
-
* user bug.
|
|
26
|
-
*
|
|
27
|
-
* This test pins the post-fallback shape so it cannot regress in
|
|
28
|
-
* either direction:
|
|
29
|
-
* • Root MUST be `type: "object"` (OpenAI rule).
|
|
30
|
-
* • Root MUST NOT have `oneOf`, `anyOf`, `allOf`, `enum`, `not`.
|
|
31
|
-
* • The same five forbidden keys MUST NOT appear on `SubQuestionSchema`
|
|
32
|
-
* either — OpenAI applies the rule recursively per the error message.
|
|
33
|
-
*
|
|
34
|
-
* Per-method strictness is enforced by `prepareArguments` rescue + the
|
|
35
|
-
* `execute` runtime switch (covered by `ask-user-tool.test.ts`).
|
|
36
|
-
*
|
|
37
|
-
* See change: fix-multiselect-auto-cancel-on-dashboard.
|
|
38
|
-
*/
|
|
39
|
-
import { describe, it, expect, vi } from "vitest";
|
|
40
|
-
import { registerAskUserTool } from "../ask-user-tool.js";
|
|
41
|
-
|
|
42
|
-
const FORBIDDEN_TOP_LEVEL_KEYS = ["oneOf", "anyOf", "allOf", "enum", "not"] as const;
|
|
43
|
-
|
|
44
|
-
interface PiSchema {
|
|
45
|
-
type?: string;
|
|
46
|
-
properties?: Record<string, any>;
|
|
47
|
-
required?: string[];
|
|
48
|
-
description?: string;
|
|
49
|
-
oneOf?: unknown;
|
|
50
|
-
anyOf?: unknown;
|
|
51
|
-
allOf?: unknown;
|
|
52
|
-
enum?: unknown;
|
|
53
|
-
not?: unknown;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function captureRegisteredTool() {
|
|
57
|
-
const calls: any[] = [];
|
|
58
|
-
const pi = {
|
|
59
|
-
registerTool: vi.fn((def: any) => calls.push(def)),
|
|
60
|
-
};
|
|
61
|
-
registerAskUserTool(pi as any);
|
|
62
|
-
expect(calls.length).toBe(1);
|
|
63
|
-
return calls[0];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function getSubQuestionSchema(parameters: PiSchema): PiSchema {
|
|
67
|
-
const items = parameters.properties?.questions?.items;
|
|
68
|
-
expect(items).toBeDefined();
|
|
69
|
-
return items as PiSchema;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Walk a Union<Literal> schema (typebox emits it as `anyOf` of `{const: ...}`)
|
|
73
|
-
// into a flat list of literal values.
|
|
74
|
-
function flattenUnionLiterals(s: any): string[] {
|
|
75
|
-
if (!s) return [];
|
|
76
|
-
if (Array.isArray(s.anyOf)) return s.anyOf.flatMap(flattenUnionLiterals);
|
|
77
|
-
if (s.const !== undefined) return [String(s.const)];
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
describe("ask_user parameters schema — OpenAI strict-mode shape", () => {
|
|
82
|
-
it("root is type:object", () => {
|
|
83
|
-
const tool = captureRegisteredTool();
|
|
84
|
-
const params = tool.parameters as PiSchema;
|
|
85
|
-
expect(params.type).toBe("object");
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it.each(FORBIDDEN_TOP_LEVEL_KEYS)(
|
|
89
|
-
"root has NO `%s` (OpenAI strict mode forbids it at the top level)",
|
|
90
|
-
(key) => {
|
|
91
|
-
const tool = captureRegisteredTool();
|
|
92
|
-
const params = tool.parameters as Record<string, unknown>;
|
|
93
|
-
expect(
|
|
94
|
-
params[key],
|
|
95
|
-
`parameters.${key} would break OpenAI gpt-5: "schema must have type 'object' and not have 'oneOf' / 'anyOf' / 'allOf' / 'enum' / 'not' at the top level."`,
|
|
96
|
-
).toBeUndefined();
|
|
97
|
-
},
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
it("declares the five method literals (regression guard for MethodEnum)", () => {
|
|
101
|
-
const tool = captureRegisteredTool();
|
|
102
|
-
const methodSchema = (tool.parameters as PiSchema).properties?.method;
|
|
103
|
-
expect(methodSchema).toBeDefined();
|
|
104
|
-
// typebox emits a Union<Literal> as `anyOf` UNDER `properties.method`
|
|
105
|
-
// (NOT at the schema root). That is OpenAI-legal because it isn't at
|
|
106
|
-
// the top level. We only assert the literal set is preserved.
|
|
107
|
-
const methods = flattenUnionLiterals(methodSchema);
|
|
108
|
-
expect(methods).toEqual(
|
|
109
|
-
expect.arrayContaining(["confirm", "select", "multiselect", "input", "batch"]),
|
|
110
|
-
);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe("ask_user SubQuestionSchema — OpenAI strict-mode shape", () => {
|
|
115
|
-
it("sub-question schema is type:object", () => {
|
|
116
|
-
const tool = captureRegisteredTool();
|
|
117
|
-
const sq = getSubQuestionSchema(tool.parameters);
|
|
118
|
-
expect(sq.type).toBe("object");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it.each(FORBIDDEN_TOP_LEVEL_KEYS)(
|
|
122
|
-
"sub-question schema has NO `%s` at top level (OpenAI rule applies recursively)",
|
|
123
|
-
(key) => {
|
|
124
|
-
const tool = captureRegisteredTool();
|
|
125
|
-
const sq = getSubQuestionSchema(tool.parameters) as Record<string, unknown>;
|
|
126
|
-
expect(sq[key]).toBeUndefined();
|
|
127
|
-
},
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
it("sub-question excludes 'batch' from method literals (no nesting)", () => {
|
|
131
|
-
const tool = captureRegisteredTool();
|
|
132
|
-
const sq = getSubQuestionSchema(tool.parameters);
|
|
133
|
-
const methodSchema = sq.properties?.method;
|
|
134
|
-
expect(methodSchema).toBeDefined();
|
|
135
|
-
const methods = flattenUnionLiterals(methodSchema);
|
|
136
|
-
expect(methods).toEqual(
|
|
137
|
-
expect.arrayContaining(["confirm", "select", "multiselect", "input"]),
|
|
138
|
-
);
|
|
139
|
-
expect(methods).not.toContain("batch");
|
|
140
|
-
});
|
|
141
|
-
});
|