@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.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/.pi/skills/browser/SKILL.md +28 -14
- package/.pi/skills/browser/UPSTREAM.md +10 -1
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +299 -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 +3 -9
- package/.pi/skills/doctor/_lib/checks.ts +14 -68
- package/.pi/skills/doctor/_lib/derive-tokens.ts +1 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +51 -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/pi-dashboard/references/api-reference.agent.md +69 -0
- package/.pi/skills/project-init/SKILL.md +1 -7
- package/.pi/skills/project-init/dox-doctrine.md +42 -0
- 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 +22 -11
- package/src/agent-settled.ts +27 -9
- 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-context.ts +86 -5
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +917 -213
- package/src/command-handler.ts +332 -57
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +371 -7
- package/src/endpoint-resolution.ts +221 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -0
- package/src/instance-verification.ts +125 -0
- package/src/local-token-header.ts +44 -0
- package/src/model-refresh.ts +95 -0
- package/src/notify-proxy.ts +33 -0
- package/src/pi-env.d.ts +4 -0
- package/src/pi-retry-settings.ts +91 -0
- package/src/provider-register.ts +86 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +265 -86
- package/src/role-manager.ts +20 -0
- package/src/role-model-tools.ts +38 -3
- package/src/server-auto-start.ts +144 -2
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +24 -5
- 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-tick-throttle.ts +250 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transcript-request-guard.ts +76 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/.pi/skills/doctor/AGENTS.md +0 -27
- 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.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,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the system-originated follow-up enqueue path
|
|
3
|
-
* (`enqueueSystemFollowup`) added for the goal-continuation plugin.
|
|
4
|
-
*
|
|
5
|
-
* Pure mirror of bridge.ts `enqueueSystemFollowup()` + its interaction with
|
|
6
|
-
* the shared `bridgeFollowUp` buffer / `drainFollowupQueue` (same harness
|
|
7
|
-
* style as bridge-followup-queue-drain.test.ts — no bridge import).
|
|
8
|
-
*
|
|
9
|
-
* Contract (spec: bridge-followup-queue — "System-originated follow-up
|
|
10
|
-
* enqueue bypasses the streaming gate"):
|
|
11
|
-
* 1. Ungated push — survives `isAgentStreaming === false` (the gate that
|
|
12
|
-
* `bufferFollowupSend` applies would discard it).
|
|
13
|
-
* 2. Schedules `drainFollowupQueue(0)` via setTimeout so the drain re-runs
|
|
14
|
-
* after the bridge's own agent_end drain already ran on an empty buffer.
|
|
15
|
-
* 3. Respects FOLLOWUP_QUEUE_CAP (drop + warn).
|
|
16
|
-
* 4. Shares ONE buffer + ONE drain with user follow-ups — one entry per
|
|
17
|
-
* agent_end under the isDraining lock, no double sendUserMessage race.
|
|
18
|
-
*
|
|
19
|
-
* See change: add-goal-continuation-plugin.
|
|
20
|
-
*/
|
|
21
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
22
|
-
|
|
23
|
-
const FOLLOWUP_QUEUE_CAP = 20;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Mirror harness: the shared buffer plus the two enqueue paths and the
|
|
27
|
-
* single drain, 1:1 with bridge.ts.
|
|
28
|
-
*/
|
|
29
|
-
function makeHarness(opts: { isAgentStreaming: boolean; idle?: boolean } = { isAgentStreaming: false }) {
|
|
30
|
-
const buffer: string[] = [];
|
|
31
|
-
const sendUserMessage = vi.fn();
|
|
32
|
-
const emit = vi.fn();
|
|
33
|
-
let isDraining = false;
|
|
34
|
-
let isAgentStreaming = opts.isAgentStreaming;
|
|
35
|
-
const idle = opts.idle ?? true;
|
|
36
|
-
|
|
37
|
-
// Mirror of bufferFollowupSend — GATED on isAgentStreaming.
|
|
38
|
-
function bufferFollowupSend(text: string): void {
|
|
39
|
-
if (!isAgentStreaming) return;
|
|
40
|
-
if (buffer.length >= FOLLOWUP_QUEUE_CAP) return;
|
|
41
|
-
buffer.push(text);
|
|
42
|
-
emit();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Mirror of drainFollowupQueue — one entry per call under the lock.
|
|
46
|
-
function drainFollowupQueue(): void {
|
|
47
|
-
if (isDraining) return;
|
|
48
|
-
if (buffer.length === 0) return;
|
|
49
|
-
if (!idle) return;
|
|
50
|
-
isDraining = true;
|
|
51
|
-
try {
|
|
52
|
-
const entry = buffer.shift()!;
|
|
53
|
-
emit();
|
|
54
|
-
sendUserMessage(entry);
|
|
55
|
-
} finally {
|
|
56
|
-
isDraining = false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Mirror of enqueueSystemFollowup — UNGATED, schedules drain.
|
|
61
|
-
function enqueueSystemFollowup(text: string): void {
|
|
62
|
-
if (typeof text !== "string" || text.length === 0) return;
|
|
63
|
-
if (buffer.length >= FOLLOWUP_QUEUE_CAP) {
|
|
64
|
-
console.warn("[dashboard] follow-up buffer at soft cap; dropping system entry");
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
buffer.push(text);
|
|
68
|
-
emit();
|
|
69
|
-
setTimeout(() => drainFollowupQueue(), 0);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
buffer, sendUserMessage, emit,
|
|
74
|
-
bufferFollowupSend, enqueueSystemFollowup, drainFollowupQueue,
|
|
75
|
-
setStreaming: (v: boolean) => { isAgentStreaming = v; },
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
describe("enqueueSystemFollowup: ungated push", () => {
|
|
80
|
-
beforeEach(() => vi.useFakeTimers());
|
|
81
|
-
afterEach(() => vi.useRealTimers());
|
|
82
|
-
|
|
83
|
-
it("pushes the entry even when isAgentStreaming is false (gate closed)", () => {
|
|
84
|
-
const h = makeHarness({ isAgentStreaming: false });
|
|
85
|
-
h.enqueueSystemFollowup("continue");
|
|
86
|
-
expect(h.buffer).toEqual(["continue"]);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("contrast: bufferFollowupSend DISCARDS the same entry when gate closed", () => {
|
|
90
|
-
const h = makeHarness({ isAgentStreaming: false });
|
|
91
|
-
h.bufferFollowupSend("continue");
|
|
92
|
-
expect(h.buffer).toEqual([]); // gated path drops it
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("schedules a drain that ships exactly one fresh-turn sendUserMessage", () => {
|
|
96
|
-
const h = makeHarness({ isAgentStreaming: false, idle: true });
|
|
97
|
-
h.enqueueSystemFollowup("continue");
|
|
98
|
-
expect(h.sendUserMessage).not.toHaveBeenCalled(); // deferred via setTimeout
|
|
99
|
-
vi.runAllTimers();
|
|
100
|
-
expect(h.sendUserMessage).toHaveBeenCalledTimes(1);
|
|
101
|
-
expect(h.sendUserMessage).toHaveBeenCalledWith("continue");
|
|
102
|
-
expect(h.sendUserMessage.mock.calls[0]).toHaveLength(1); // no deliverAs
|
|
103
|
-
expect(h.buffer).toEqual([]);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("ignores empty / non-string text", () => {
|
|
107
|
-
const h = makeHarness();
|
|
108
|
-
h.enqueueSystemFollowup("");
|
|
109
|
-
h.enqueueSystemFollowup(undefined as unknown as string);
|
|
110
|
-
expect(h.buffer).toEqual([]);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe("enqueueSystemFollowup: cap honoured", () => {
|
|
115
|
-
it("drops the new entry with a warning at FOLLOWUP_QUEUE_CAP", () => {
|
|
116
|
-
const h = makeHarness();
|
|
117
|
-
for (let i = 0; i < FOLLOWUP_QUEUE_CAP; i++) h.buffer.push(`x${i}`);
|
|
118
|
-
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
119
|
-
h.enqueueSystemFollowup("overflow");
|
|
120
|
-
expect(h.buffer).toHaveLength(FOLLOWUP_QUEUE_CAP);
|
|
121
|
-
expect(h.buffer).not.toContain("overflow");
|
|
122
|
-
expect(warn).toHaveBeenCalled();
|
|
123
|
-
warn.mockRestore();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe("collision safety: user + system follow-up at same agent_end", () => {
|
|
128
|
-
beforeEach(() => vi.useFakeTimers());
|
|
129
|
-
afterEach(() => vi.useRealTimers());
|
|
130
|
-
|
|
131
|
-
it("ship one-per-agent_end through the single drain, no double send", () => {
|
|
132
|
-
// A user follow-up was buffered DURING the goal-driven turn (gate open),
|
|
133
|
-
// then the judge resolves post-agent_end and enqueues a system follow-up.
|
|
134
|
-
const h = makeHarness({ isAgentStreaming: true, idle: true });
|
|
135
|
-
h.bufferFollowupSend("user ask"); // buffered mid-turn
|
|
136
|
-
h.setStreaming(false); // agent_end flips the gate
|
|
137
|
-
h.enqueueSystemFollowup("continue"); // judge verdict after agent_end
|
|
138
|
-
|
|
139
|
-
expect(h.buffer).toEqual(["user ask", "continue"]); // both in ONE buffer
|
|
140
|
-
|
|
141
|
-
// First agent_end drain ships exactly one (FIFO: user ask wins).
|
|
142
|
-
vi.runAllTimers();
|
|
143
|
-
expect(h.sendUserMessage).toHaveBeenCalledTimes(1);
|
|
144
|
-
expect(h.sendUserMessage).toHaveBeenCalledWith("user ask");
|
|
145
|
-
expect(h.buffer).toEqual(["continue"]);
|
|
146
|
-
|
|
147
|
-
// Next agent_end drains the goal continuation — still one per turn.
|
|
148
|
-
h.drainFollowupQueue();
|
|
149
|
-
expect(h.sendUserMessage).toHaveBeenCalledTimes(2);
|
|
150
|
-
expect(h.sendUserMessage).toHaveBeenNthCalledWith(2, "continue");
|
|
151
|
-
expect(h.buffer).toEqual([]);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("re-entrant drain during a send does not double-ship", () => {
|
|
155
|
-
const h = makeHarness({ isAgentStreaming: false, idle: true });
|
|
156
|
-
h.buffer.push("a", "b");
|
|
157
|
-
// Make sendUserMessage attempt a synchronous re-drain (lock must block it).
|
|
158
|
-
h.sendUserMessage.mockImplementation(() => h.drainFollowupQueue());
|
|
159
|
-
h.drainFollowupQueue();
|
|
160
|
-
expect(h.sendUserMessage).toHaveBeenCalledTimes(1);
|
|
161
|
-
expect(h.buffer).toEqual(["b"]); // only one consumed
|
|
162
|
-
});
|
|
163
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridge thinking_level_select wiring (shape contract).
|
|
3
|
-
*
|
|
4
|
-
* Pi 0.71+ fires a dedicated `thinking_level_select` event when the thinking
|
|
5
|
-
* level changes alone. The bridge handler calls `sendModelUpdateIfChanged`,
|
|
6
|
-
* which pushes ONE `model_update` per distinct (model, thinkingLevel) pair.
|
|
7
|
-
* A repeat event with the same level is a no-op via the dedup gate.
|
|
8
|
-
*
|
|
9
|
-
* See change: adopt-pi-071-072-073-features (A.3).
|
|
10
|
-
*/
|
|
11
|
-
import { describe, it, expect } from "vitest";
|
|
12
|
-
import { sendModelUpdateIfChanged } from "../model-tracker.js";
|
|
13
|
-
import type { BridgeContext } from "../bridge-context.js";
|
|
14
|
-
|
|
15
|
-
function makeBc(thinkingLevel: string): { bc: BridgeContext; sent: any[] } {
|
|
16
|
-
const sent: any[] = [];
|
|
17
|
-
const bc = {
|
|
18
|
-
sessionId: "S1",
|
|
19
|
-
cachedCtx: { model: { provider: "anthropic", id: "claude" } },
|
|
20
|
-
pi: { getThinkingLevel: () => thinkingLevel },
|
|
21
|
-
connection: { send: (m: any) => sent.push(m) },
|
|
22
|
-
lastModel: undefined,
|
|
23
|
-
lastThinkingLevel: undefined,
|
|
24
|
-
} as unknown as BridgeContext;
|
|
25
|
-
return { bc, sent };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe("bridge thinking_level_select → model_update", () => {
|
|
29
|
-
it("fires one model_update on a new thinking level", () => {
|
|
30
|
-
const { bc, sent } = makeBc("high");
|
|
31
|
-
// Simulate the bridge's thinking_level_select handler.
|
|
32
|
-
sendModelUpdateIfChanged(bc);
|
|
33
|
-
expect(sent).toHaveLength(1);
|
|
34
|
-
expect(sent[0]).toMatchObject({
|
|
35
|
-
type: "model_update",
|
|
36
|
-
sessionId: "S1",
|
|
37
|
-
model: "anthropic/claude",
|
|
38
|
-
thinkingLevel: "high",
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("does not re-emit when the thinking level is unchanged", () => {
|
|
43
|
-
const { bc, sent } = makeBc("high");
|
|
44
|
-
sendModelUpdateIfChanged(bc); // first push
|
|
45
|
-
sendModelUpdateIfChanged(bc); // same value → dedup no-op
|
|
46
|
-
expect(sent).toHaveLength(1);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("re-emits when only the thinking level changes (model unchanged)", () => {
|
|
50
|
-
const sent: any[] = [];
|
|
51
|
-
let level = "medium";
|
|
52
|
-
const bc = {
|
|
53
|
-
sessionId: "S2",
|
|
54
|
-
cachedCtx: { model: { provider: "anthropic", id: "claude" } },
|
|
55
|
-
pi: { getThinkingLevel: () => level },
|
|
56
|
-
connection: { send: (m: any) => sent.push(m) },
|
|
57
|
-
lastModel: undefined,
|
|
58
|
-
lastThinkingLevel: undefined,
|
|
59
|
-
} as unknown as BridgeContext;
|
|
60
|
-
|
|
61
|
-
sendModelUpdateIfChanged(bc);
|
|
62
|
-
level = "high";
|
|
63
|
-
sendModelUpdateIfChanged(bc);
|
|
64
|
-
|
|
65
|
-
expect(sent).toHaveLength(2);
|
|
66
|
-
expect(sent[1].thinkingLevel).toBe("high");
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Asserts the universal `browser` skill is registered in the extension
|
|
3
|
-
* package and ships in the published tarball.
|
|
4
|
-
*
|
|
5
|
-
* Spec: `default-browser-skill` — "Required files present" + "pi.skills[]
|
|
6
|
-
* declares the skill" + "Skill files ship in the published package".
|
|
7
|
-
*
|
|
8
|
-
* See change: ship-browser-skill-and-electron-cdp.
|
|
9
|
-
*/
|
|
10
|
-
import { describe, it, expect } from "vitest";
|
|
11
|
-
import fs from "node:fs";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import url from "node:url";
|
|
14
|
-
|
|
15
|
-
const here = path.dirname(url.fileURLToPath(import.meta.url));
|
|
16
|
-
const pkgDir = path.resolve(here, "..", "..");
|
|
17
|
-
const skillDir = path.join(pkgDir, ".pi", "skills", "browser");
|
|
18
|
-
const pkgJsonPath = path.join(pkgDir, "package.json");
|
|
19
|
-
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")) as {
|
|
20
|
-
pi?: { skills?: string[] };
|
|
21
|
-
files?: string[];
|
|
22
|
-
dependencies?: Record<string, string>;
|
|
23
|
-
peerDependencies?: Record<string, string>;
|
|
24
|
-
optionalDependencies?: Record<string, string>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
describe("browser skill — required files present", () => {
|
|
28
|
-
for (const rel of [
|
|
29
|
-
"SKILL.md",
|
|
30
|
-
"UPSTREAM.md",
|
|
31
|
-
"LICENSE",
|
|
32
|
-
"references/web.md",
|
|
33
|
-
"references/electron.md",
|
|
34
|
-
"scripts/detect-dashboard.sh",
|
|
35
|
-
]) {
|
|
36
|
-
it(`ships ${rel}`, () => {
|
|
37
|
-
const full = path.join(skillDir, rel);
|
|
38
|
-
expect(fs.existsSync(full), `missing ${rel}`).toBe(true);
|
|
39
|
-
const stat = fs.statSync(full);
|
|
40
|
-
expect(stat.size).toBeGreaterThan(0);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("browser skill — SKILL.md frontmatter", () => {
|
|
46
|
-
const src = fs.readFileSync(path.join(skillDir, "SKILL.md"), "utf-8");
|
|
47
|
-
|
|
48
|
-
it("declares name: browser", () => {
|
|
49
|
-
expect(src).toMatch(/^name:\s*browser\s*$/m);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("declares allowed-tools with agent-browser bash patterns", () => {
|
|
53
|
-
expect(src).toMatch(/allowed-tools:.*Bash\(agent-browser:\*\)/);
|
|
54
|
-
expect(src).toMatch(/Bash\(npx agent-browser:\*\)/);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("documents the Step-0 preflight halt message", () => {
|
|
58
|
-
expect(src).toMatch(/pi install npm:pi-agent-browser/);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("browser skill — package.json registration", () => {
|
|
63
|
-
it("pi.skills[] includes .pi/skills/browser", () => {
|
|
64
|
-
expect(pkgJson.pi?.skills).toContain(".pi/skills/browser");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("files[] ships .pi/skills/browser/", () => {
|
|
68
|
-
expect(pkgJson.files).toContain(".pi/skills/browser/");
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("browser skill — no bundled CLI", () => {
|
|
73
|
-
it("agent-browser is NOT a runtime dep", () => {
|
|
74
|
-
expect(pkgJson.dependencies?.["agent-browser"]).toBeUndefined();
|
|
75
|
-
expect(pkgJson.peerDependencies?.["agent-browser"]).toBeUndefined();
|
|
76
|
-
expect(pkgJson.optionalDependencies?.["agent-browser"]).toBeUndefined();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("pi-agent-browser is NOT a runtime dep", () => {
|
|
80
|
-
expect(pkgJson.dependencies?.["pi-agent-browser"]).toBeUndefined();
|
|
81
|
-
expect(pkgJson.peerDependencies?.["pi-agent-browser"]).toBeUndefined();
|
|
82
|
-
expect(pkgJson.optionalDependencies?.["pi-agent-browser"]).toBeUndefined();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for `_buildProviderCatalogue` — the bridge-side pure helper that
|
|
3
|
-
* derives ProviderInfo[] from a captured ModelRegistry.
|
|
4
|
-
* See change: replace-hardcoded-provider-lists.
|
|
5
|
-
*/
|
|
6
|
-
import { describe, it, expect } from "vitest";
|
|
7
|
-
import { _buildProviderCatalogue } from "../provider-register.js";
|
|
8
|
-
|
|
9
|
-
function makeRegistry(opts: {
|
|
10
|
-
oauthIds?: string[];
|
|
11
|
-
models?: Array<{ provider: string; id: string }>;
|
|
12
|
-
authStatus?: Record<string, { configured: boolean; source?: string }>;
|
|
13
|
-
registryAuthStatus?: Record<string, { configured: boolean; source?: string }>;
|
|
14
|
-
credentials?: Record<string, { type: "oauth" | "api_key"; expires?: number; key?: string }>;
|
|
15
|
-
displayNames?: Record<string, string>;
|
|
16
|
-
}): any {
|
|
17
|
-
const reg: any = {
|
|
18
|
-
authStorage: {
|
|
19
|
-
getOAuthProviders: () => (opts.oauthIds ?? []).map((id) => ({ id, name: id })),
|
|
20
|
-
getAuthStatus: (id: string) => opts.authStatus?.[id] ?? { configured: false },
|
|
21
|
-
get: (id: string) => opts.credentials?.[id],
|
|
22
|
-
},
|
|
23
|
-
getAll: () => opts.models ?? [],
|
|
24
|
-
getProviderDisplayName: (id: string) => opts.displayNames?.[id] ?? id,
|
|
25
|
-
};
|
|
26
|
-
// Only attach the registry-level status method when the test opts in, so the
|
|
27
|
-
// existing scenarios exercise the authStorage fallback path (older pi).
|
|
28
|
-
if (opts.registryAuthStatus) {
|
|
29
|
-
reg.getProviderAuthStatus = (id: string) => opts.registryAuthStatus?.[id];
|
|
30
|
-
}
|
|
31
|
-
return reg;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
describe("_buildProviderCatalogue", () => {
|
|
35
|
-
it("returns [] when registry is null", () => {
|
|
36
|
-
expect(_buildProviderCatalogue(null, {})).toEqual([]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("includes every OAuth id and every distinct model.provider, deduplicated", () => {
|
|
40
|
-
const reg = makeRegistry({
|
|
41
|
-
oauthIds: ["anthropic", "openai-codex"],
|
|
42
|
-
models: [
|
|
43
|
-
{ provider: "anthropic", id: "claude-4" },
|
|
44
|
-
{ provider: "deepseek", id: "deepseek-chat" },
|
|
45
|
-
{ provider: "deepseek", id: "deepseek-coder" },
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
49
|
-
const ids = cat.map((c) => c.id).sort();
|
|
50
|
-
expect(ids).toEqual(["anthropic", "deepseek", "openai-codex"]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("sets hasOAuth true only for ids in the OAuth provider set", () => {
|
|
54
|
-
const reg = makeRegistry({
|
|
55
|
-
oauthIds: ["anthropic"],
|
|
56
|
-
models: [{ provider: "anthropic", id: "x" }, { provider: "deepseek", id: "y" }],
|
|
57
|
-
});
|
|
58
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
59
|
-
expect(cat.find((c) => c.id === "anthropic")?.hasOAuth).toBe(true);
|
|
60
|
-
expect(cat.find((c) => c.id === "deepseek")?.hasOAuth).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("populates displayName from getProviderDisplayName, falling back to id", () => {
|
|
64
|
-
const reg = makeRegistry({
|
|
65
|
-
models: [{ provider: "deepseek", id: "x" }, { provider: "custom-llm", id: "y" }],
|
|
66
|
-
displayNames: { deepseek: "DeepSeek" },
|
|
67
|
-
});
|
|
68
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
69
|
-
expect(cat.find((c) => c.id === "deepseek")?.displayName).toBe("DeepSeek");
|
|
70
|
-
expect(cat.find((c) => c.id === "custom-llm")?.displayName).toBe("custom-llm");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("populates configured + source from authStorage.getAuthStatus", () => {
|
|
74
|
-
const reg = makeRegistry({
|
|
75
|
-
models: [{ provider: "openai", id: "gpt-4" }],
|
|
76
|
-
authStatus: { openai: { configured: false, source: "environment" } },
|
|
77
|
-
});
|
|
78
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
79
|
-
const row = cat.find((c) => c.id === "openai")!;
|
|
80
|
-
expect(row.configured).toBe(false);
|
|
81
|
-
expect(row.source).toBe("environment");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("populates expires for OAuth credentials in auth.json", () => {
|
|
85
|
-
const reg = makeRegistry({
|
|
86
|
-
oauthIds: ["anthropic"],
|
|
87
|
-
models: [{ provider: "anthropic", id: "x" }],
|
|
88
|
-
credentials: { anthropic: { type: "oauth", expires: 1234567890 } },
|
|
89
|
-
});
|
|
90
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
91
|
-
expect(cat.find((c) => c.id === "anthropic")?.expires).toBe(1234567890);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("api_key credentials do not surface expires", () => {
|
|
95
|
-
const reg = makeRegistry({
|
|
96
|
-
models: [{ provider: "openai", id: "x" }],
|
|
97
|
-
credentials: { openai: { type: "api_key", key: "sk-..." } },
|
|
98
|
-
});
|
|
99
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
100
|
-
expect(cat.find((c) => c.id === "openai")?.expires).toBeUndefined();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("populates envVar from piAi.findEnvKeys (first entry)", () => {
|
|
104
|
-
const reg = makeRegistry({ models: [{ provider: "openai", id: "x" }] });
|
|
105
|
-
const cat = _buildProviderCatalogue(reg, {
|
|
106
|
-
findEnvKeys: (id) => (id === "openai" ? ["OPENAI_API_KEY"] : undefined),
|
|
107
|
-
});
|
|
108
|
-
expect(cat.find((c) => c.id === "openai")?.envVar).toBe("OPENAI_API_KEY");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("sets ambient when piAi.getEnvApiKey returns '<authenticated>'", () => {
|
|
112
|
-
const reg = makeRegistry({ models: [{ provider: "google-vertex", id: "x" }] });
|
|
113
|
-
const cat = _buildProviderCatalogue(reg, {
|
|
114
|
-
getEnvApiKey: (id) => (id === "google-vertex" ? "<authenticated>" : undefined),
|
|
115
|
-
});
|
|
116
|
-
expect(cat.find((c) => c.id === "google-vertex")?.ambient).toBe(true);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("ambient stays undefined for ordinary api keys", () => {
|
|
120
|
-
const reg = makeRegistry({ models: [{ provider: "openai", id: "x" }] });
|
|
121
|
-
const cat = _buildProviderCatalogue(reg, {
|
|
122
|
-
getEnvApiKey: () => "sk-real-key",
|
|
123
|
-
});
|
|
124
|
-
expect(cat.find((c) => c.id === "openai")?.ambient).toBeUndefined();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("does not throw when pi-ai helpers are missing", () => {
|
|
128
|
-
const reg = makeRegistry({ models: [{ provider: "openai", id: "x" }] });
|
|
129
|
-
expect(() => _buildProviderCatalogue(reg, {})).not.toThrow();
|
|
130
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
131
|
-
expect(cat[0].envVar).toBeUndefined();
|
|
132
|
-
expect(cat[0].ambient).toBeUndefined();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("marks ids in customIds set with custom:true; catalogue stays complete", () => {
|
|
136
|
-
const reg = makeRegistry({
|
|
137
|
-
models: [
|
|
138
|
-
{ provider: "deepseek", id: "deepseek-chat" },
|
|
139
|
-
{ provider: "proxy", id: "opus-4" }, // custom (registered via providers.json)
|
|
140
|
-
{ provider: "your-llmproxy", id: "foo" }, // custom
|
|
141
|
-
],
|
|
142
|
-
});
|
|
143
|
-
const customIds = new Set(["proxy", "your-llmproxy"]);
|
|
144
|
-
const cat = _buildProviderCatalogue(reg, {}, customIds);
|
|
145
|
-
// ALL providers present — the catalogue does not filter; consumers do.
|
|
146
|
-
const ids = cat.map((c) => c.id).sort();
|
|
147
|
-
expect(ids).toEqual(["deepseek", "proxy", "your-llmproxy"]);
|
|
148
|
-
// Custom flag is set only for custom providers.
|
|
149
|
-
expect(cat.find((c) => c.id === "deepseek")?.custom).toBeUndefined();
|
|
150
|
-
expect(cat.find((c) => c.id === "proxy")?.custom).toBe(true);
|
|
151
|
-
expect(cat.find((c) => c.id === "your-llmproxy")?.custom).toBe(true);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("OAuth-handler ids carry custom:true when in customIds (custom OAuth provider)", () => {
|
|
155
|
-
const reg = makeRegistry({
|
|
156
|
-
oauthIds: ["corporate-sso"],
|
|
157
|
-
models: [{ provider: "corporate-sso", id: "x" }, { provider: "deepseek", id: "y" }],
|
|
158
|
-
});
|
|
159
|
-
const cat = _buildProviderCatalogue(reg, {}, new Set(["corporate-sso"]));
|
|
160
|
-
expect(cat.find((c) => c.id === "corporate-sso")?.hasOAuth).toBe(true);
|
|
161
|
-
expect(cat.find((c) => c.id === "corporate-sso")?.custom).toBe(true);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("empty customIds = no provider marked custom (default behaviour)", () => {
|
|
165
|
-
const reg = makeRegistry({
|
|
166
|
-
models: [{ provider: "deepseek", id: "x" }, { provider: "proxy", id: "y" }],
|
|
167
|
-
});
|
|
168
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
169
|
-
const ids = cat.map((c) => c.id).sort();
|
|
170
|
-
expect(ids).toEqual(["deepseek", "proxy"]);
|
|
171
|
-
expect(cat.every((c) => !c.custom)).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("derives configured/source from getProviderAuthStatus when present (custom provider)", () => {
|
|
175
|
-
// The proxy key lives only in pi's providerRequestConfigs (registerProvider),
|
|
176
|
-
// so authStorage is blind to it (configured:false) but the registry-level
|
|
177
|
-
// getProviderAuthStatus reports it configured. The catalogue MUST follow the
|
|
178
|
-
// registry-level status. See change: fix-custom-provider-save-and-auth.
|
|
179
|
-
const reg = makeRegistry({
|
|
180
|
-
models: [{ provider: "proxy", id: "opus-4" }],
|
|
181
|
-
authStatus: { proxy: { configured: false } },
|
|
182
|
-
registryAuthStatus: { proxy: { configured: true, source: "models_json_key" } },
|
|
183
|
-
});
|
|
184
|
-
const cat = _buildProviderCatalogue(reg, {}, new Set(["proxy"]));
|
|
185
|
-
const row = cat.find((c) => c.id === "proxy")!;
|
|
186
|
-
expect(row.configured).toBe(true);
|
|
187
|
-
expect(row.source).toBe("models_json_key");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("falls back to authStorage.getAuthStatus when getProviderAuthStatus is absent", () => {
|
|
191
|
-
// No registryAuthStatus → method absent → fallback path (regression).
|
|
192
|
-
const reg = makeRegistry({
|
|
193
|
-
models: [{ provider: "openai", id: "gpt-4" }],
|
|
194
|
-
authStatus: { openai: { configured: true, source: "environment" } },
|
|
195
|
-
});
|
|
196
|
-
const row = _buildProviderCatalogue(reg, {}).find((c) => c.id === "openai")!;
|
|
197
|
-
expect(row.configured).toBe(true);
|
|
198
|
-
expect(row.source).toBe("environment");
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("does not throw when getProviderDisplayName throws", () => {
|
|
202
|
-
const reg = {
|
|
203
|
-
authStorage: { getOAuthProviders: () => [], getAuthStatus: () => ({ configured: false }), get: () => undefined },
|
|
204
|
-
getAll: () => [{ provider: "weird", id: "x" }],
|
|
205
|
-
getProviderDisplayName: () => { throw new Error("boom"); },
|
|
206
|
-
};
|
|
207
|
-
const cat = _buildProviderCatalogue(reg, {});
|
|
208
|
-
expect(cat[0].displayName).toBe("weird");
|
|
209
|
-
});
|
|
210
|
-
});
|