@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,498 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the provider-register hot-reload path.
|
|
3
|
-
*
|
|
4
|
-
* `reloadProviders(pi)` diffs the current providers.json against a
|
|
5
|
-
* last-registered snapshot and calls pi.registerProvider / pi.unregisterProvider
|
|
6
|
-
* as needed. Async model discovery is stubbed via a fetch mock.
|
|
7
|
-
*/
|
|
8
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
9
|
-
import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
|
|
10
|
-
import { tmpdir } from "node:os";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
|
|
13
|
-
// We re-import the module fresh in each test so module-level `lastRegistered`
|
|
14
|
-
// state starts empty.
|
|
15
|
-
async function importFresh() {
|
|
16
|
-
vi.resetModules();
|
|
17
|
-
return (await import("../provider-register.js")) as typeof import("../provider-register.js");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function makeMockPi() {
|
|
21
|
-
const registerProvider = vi.fn();
|
|
22
|
-
const unregisterProvider = vi.fn();
|
|
23
|
-
const pi = {
|
|
24
|
-
registerProvider,
|
|
25
|
-
unregisterProvider,
|
|
26
|
-
events: { on: vi.fn(), emit: vi.fn() },
|
|
27
|
-
on: vi.fn(),
|
|
28
|
-
} as any;
|
|
29
|
-
return { pi, registerProvider, unregisterProvider };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function writeProvidersJson(home: string, providers: Record<string, any>) {
|
|
33
|
-
const dir = join(home, ".pi", "agent");
|
|
34
|
-
mkdirSync(dir, { recursive: true });
|
|
35
|
-
writeFileSync(
|
|
36
|
-
join(dir, "providers.json"),
|
|
37
|
-
JSON.stringify({ providers }, null, 2),
|
|
38
|
-
"utf-8",
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
describe("reloadProviders", () => {
|
|
43
|
-
let tmpHome: string;
|
|
44
|
-
const originalHome = process.env.HOME;
|
|
45
|
-
const originalFetch = globalThis.fetch;
|
|
46
|
-
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
tmpHome = mkdtempSync(join(tmpdir(), "provider-reload-"));
|
|
49
|
-
process.env.HOME = tmpHome;
|
|
50
|
-
// Stub fetch to return 2 models so discovery succeeds cheaply
|
|
51
|
-
globalThis.fetch = vi.fn(async () =>
|
|
52
|
-
new Response(JSON.stringify({ data: [{ id: "m1" }, { id: "m2" }] }), { status: 200 }),
|
|
53
|
-
) as any;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
afterEach(() => {
|
|
57
|
-
globalThis.fetch = originalFetch;
|
|
58
|
-
process.env.HOME = originalHome;
|
|
59
|
-
rmSync(tmpHome, { recursive: true, force: true });
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("adds a new provider when providers.json gains an entry (snapshot was empty)", async () => {
|
|
63
|
-
const mod = await importFresh();
|
|
64
|
-
const { pi, registerProvider, unregisterProvider } = makeMockPi();
|
|
65
|
-
|
|
66
|
-
writeProvidersJson(tmpHome, {
|
|
67
|
-
"my-llm": {
|
|
68
|
-
baseUrl: "https://api.example.com/v1",
|
|
69
|
-
apiKey: "sk-abc",
|
|
70
|
-
api: "openai-completions",
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const diff = await mod.reloadProviders(pi);
|
|
75
|
-
expect(diff.added).toEqual(["my-llm"]);
|
|
76
|
-
expect(diff.removed).toEqual([]);
|
|
77
|
-
expect(diff.changed).toEqual([]);
|
|
78
|
-
expect(registerProvider).toHaveBeenCalledTimes(1);
|
|
79
|
-
expect(registerProvider).toHaveBeenCalledWith("my-llm", expect.objectContaining({
|
|
80
|
-
baseUrl: "https://api.example.com/v1",
|
|
81
|
-
api: "openai-completions",
|
|
82
|
-
}));
|
|
83
|
-
expect(unregisterProvider).not.toHaveBeenCalled();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// ── auth pre-registration race fix (see change: fix-flow-agent-model-resolution) ──
|
|
87
|
-
it("preRegisterProviderAuth registers the apiKey synchronously with NO models", async () => {
|
|
88
|
-
const mod = await importFresh();
|
|
89
|
-
const { pi, registerProvider } = makeMockPi();
|
|
90
|
-
|
|
91
|
-
mod.preRegisterProviderAuth(pi, "home-proxy", {
|
|
92
|
-
baseUrl: "http://localhost:20128/v1",
|
|
93
|
-
apiKey: "sk-literal-key",
|
|
94
|
-
api: "anthropic-messages",
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Exactly one call, carrying auth, and crucially WITHOUT `models` so the
|
|
98
|
-
// existing catalog is left untouched (storeProviderRequestConfig only).
|
|
99
|
-
expect(registerProvider).toHaveBeenCalledTimes(1);
|
|
100
|
-
const [name, config] = registerProvider.mock.calls[0];
|
|
101
|
-
expect(name).toBe("home-proxy");
|
|
102
|
-
expect(config.baseUrl).toBe("http://localhost:20128/v1");
|
|
103
|
-
expect(config.api).toBe("anthropic-messages");
|
|
104
|
-
expect(config.apiKey).toBe("sk-literal-key");
|
|
105
|
-
expect(config.models).toBeUndefined();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("removes a provider when its entry disappears from providers.json", async () => {
|
|
109
|
-
const mod = await importFresh();
|
|
110
|
-
const { pi, registerProvider, unregisterProvider } = makeMockPi();
|
|
111
|
-
|
|
112
|
-
writeProvidersJson(tmpHome, {
|
|
113
|
-
"my-llm": { baseUrl: "https://x", apiKey: "k", api: "openai-completions" },
|
|
114
|
-
});
|
|
115
|
-
await mod.reloadProviders(pi);
|
|
116
|
-
expect(registerProvider).toHaveBeenCalledTimes(1);
|
|
117
|
-
|
|
118
|
-
writeProvidersJson(tmpHome, {});
|
|
119
|
-
const diff = await mod.reloadProviders(pi);
|
|
120
|
-
|
|
121
|
-
expect(diff.removed).toEqual(["my-llm"]);
|
|
122
|
-
expect(diff.added).toEqual([]);
|
|
123
|
-
expect(unregisterProvider).toHaveBeenCalledTimes(1);
|
|
124
|
-
expect(unregisterProvider).toHaveBeenCalledWith("my-llm");
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("re-registers (unregister then register) when baseUrl changes", async () => {
|
|
128
|
-
const mod = await importFresh();
|
|
129
|
-
const { pi, registerProvider, unregisterProvider } = makeMockPi();
|
|
130
|
-
|
|
131
|
-
writeProvidersJson(tmpHome, {
|
|
132
|
-
"my-llm": { baseUrl: "https://old.example.com/v1", apiKey: "k", api: "openai-completions" },
|
|
133
|
-
});
|
|
134
|
-
await mod.reloadProviders(pi);
|
|
135
|
-
expect(registerProvider).toHaveBeenCalledTimes(1);
|
|
136
|
-
|
|
137
|
-
writeProvidersJson(tmpHome, {
|
|
138
|
-
"my-llm": { baseUrl: "https://new.example.com/v1", apiKey: "k", api: "openai-completions" },
|
|
139
|
-
});
|
|
140
|
-
const diff = await mod.reloadProviders(pi);
|
|
141
|
-
|
|
142
|
-
expect(diff.changed).toEqual(["my-llm"]);
|
|
143
|
-
// unregister must be called before the second register
|
|
144
|
-
const unregOrder = unregisterProvider.mock.invocationCallOrder[0];
|
|
145
|
-
const reg2Order = registerProvider.mock.invocationCallOrder[1];
|
|
146
|
-
expect(unregOrder).toBeLessThan(reg2Order);
|
|
147
|
-
expect(registerProvider).toHaveBeenLastCalledWith(
|
|
148
|
-
"my-llm",
|
|
149
|
-
expect.objectContaining({ baseUrl: "https://new.example.com/v1" }),
|
|
150
|
-
);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("unchanged providers.json produces no register/unregister calls on second reload", async () => {
|
|
154
|
-
const mod = await importFresh();
|
|
155
|
-
const { pi, registerProvider, unregisterProvider } = makeMockPi();
|
|
156
|
-
|
|
157
|
-
writeProvidersJson(tmpHome, {
|
|
158
|
-
"my-llm": { baseUrl: "https://x", apiKey: "k", api: "openai-completions" },
|
|
159
|
-
});
|
|
160
|
-
await mod.reloadProviders(pi);
|
|
161
|
-
registerProvider.mockClear();
|
|
162
|
-
unregisterProvider.mockClear();
|
|
163
|
-
|
|
164
|
-
const diff = await mod.reloadProviders(pi);
|
|
165
|
-
expect(diff.added).toEqual([]);
|
|
166
|
-
expect(diff.removed).toEqual([]);
|
|
167
|
-
expect(diff.changed).toEqual([]);
|
|
168
|
-
expect(registerProvider).not.toHaveBeenCalled();
|
|
169
|
-
expect(unregisterProvider).not.toHaveBeenCalled();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("malformed providers.json returns empty diff and does not throw", async () => {
|
|
173
|
-
const mod = await importFresh();
|
|
174
|
-
const { pi } = makeMockPi();
|
|
175
|
-
|
|
176
|
-
const dir = join(tmpHome, ".pi", "agent");
|
|
177
|
-
mkdirSync(dir, { recursive: true });
|
|
178
|
-
writeFileSync(join(dir, "providers.json"), "not valid json {", "utf-8");
|
|
179
|
-
|
|
180
|
-
await expect(mod.reloadProviders(pi)).resolves.toEqual({
|
|
181
|
-
added: [],
|
|
182
|
-
removed: [],
|
|
183
|
-
changed: [],
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("treats apiKey change as 'changed'", async () => {
|
|
188
|
-
const mod = await importFresh();
|
|
189
|
-
const { pi, registerProvider, unregisterProvider } = makeMockPi();
|
|
190
|
-
|
|
191
|
-
writeProvidersJson(tmpHome, {
|
|
192
|
-
"my-llm": { baseUrl: "https://x", apiKey: "old", api: "openai-completions" },
|
|
193
|
-
});
|
|
194
|
-
await mod.reloadProviders(pi);
|
|
195
|
-
|
|
196
|
-
writeProvidersJson(tmpHome, {
|
|
197
|
-
"my-llm": { baseUrl: "https://x", apiKey: "new", api: "openai-completions" },
|
|
198
|
-
});
|
|
199
|
-
const diff = await mod.reloadProviders(pi);
|
|
200
|
-
expect(diff.changed).toEqual(["my-llm"]);
|
|
201
|
-
expect(unregisterProvider).toHaveBeenCalledWith("my-llm");
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("treats api type change as 'changed'", async () => {
|
|
205
|
-
const mod = await importFresh();
|
|
206
|
-
const { pi } = makeMockPi();
|
|
207
|
-
|
|
208
|
-
writeProvidersJson(tmpHome, {
|
|
209
|
-
"my-llm": { baseUrl: "https://x", apiKey: "k", api: "openai-completions" },
|
|
210
|
-
});
|
|
211
|
-
await mod.reloadProviders(pi);
|
|
212
|
-
|
|
213
|
-
writeProvidersJson(tmpHome, {
|
|
214
|
-
"my-llm": { baseUrl: "https://x", apiKey: "k", api: "openai-responses" },
|
|
215
|
-
});
|
|
216
|
-
const diff = await mod.reloadProviders(pi);
|
|
217
|
-
expect(diff.changed).toEqual(["my-llm"]);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// ── input capability default (see change: enable-image-input-custom-providers) ─────
|
|
221
|
-
// Every discovered model must advertise `input: ["text", "image"]` so pi-ai does
|
|
222
|
-
// not strip pasted images via `downgradeUnsupportedImages` before the request
|
|
223
|
-
// leaves the bridge. This guards both the initial-registration path and the
|
|
224
|
-
// reloadProviders() re-register path.
|
|
225
|
-
|
|
226
|
-
it("discovered models default to input: [\"text\", \"image\"] on fresh register", async () => {
|
|
227
|
-
const mod = await importFresh();
|
|
228
|
-
const { pi, registerProvider } = makeMockPi();
|
|
229
|
-
|
|
230
|
-
writeProvidersJson(tmpHome, {
|
|
231
|
-
"my-llm": {
|
|
232
|
-
baseUrl: "https://api.example.com/v1",
|
|
233
|
-
apiKey: "sk-abc",
|
|
234
|
-
api: "openai-completions",
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
await mod.reloadProviders(pi);
|
|
239
|
-
|
|
240
|
-
expect(registerProvider).toHaveBeenCalledTimes(1);
|
|
241
|
-
const [, config] = registerProvider.mock.calls[0];
|
|
242
|
-
expect(Array.isArray(config.models)).toBe(true);
|
|
243
|
-
expect(config.models.length).toBe(2); // two models from the fetch stub
|
|
244
|
-
for (const m of config.models) {
|
|
245
|
-
expect(m.input).toEqual(["text", "image"]);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("re-registered models (after reload diff) retain input: [\"text\", \"image\"]", async () => {
|
|
250
|
-
const mod = await importFresh();
|
|
251
|
-
const { pi, registerProvider } = makeMockPi();
|
|
252
|
-
|
|
253
|
-
// Initial register
|
|
254
|
-
writeProvidersJson(tmpHome, {
|
|
255
|
-
"my-llm": { baseUrl: "https://old.example.com/v1", apiKey: "k", api: "openai-completions" },
|
|
256
|
-
});
|
|
257
|
-
await mod.reloadProviders(pi);
|
|
258
|
-
|
|
259
|
-
// Change baseUrl → triggers unregister + re-register
|
|
260
|
-
writeProvidersJson(tmpHome, {
|
|
261
|
-
"my-llm": { baseUrl: "https://new.example.com/v1", apiKey: "k", api: "openai-completions" },
|
|
262
|
-
});
|
|
263
|
-
const diff = await mod.reloadProviders(pi);
|
|
264
|
-
expect(diff.changed).toEqual(["my-llm"]);
|
|
265
|
-
|
|
266
|
-
// Second registerProvider call is the re-register; must carry same input default
|
|
267
|
-
expect(registerProvider).toHaveBeenCalledTimes(2);
|
|
268
|
-
const [, secondConfig] = registerProvider.mock.calls[1];
|
|
269
|
-
for (const m of secondConfig.models) {
|
|
270
|
-
expect(m.input).toEqual(["text", "image"]);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
// ── model metadata enrichment (see change: enrich-custom-provider-model-metadata) ──
|
|
275
|
-
// registerEntry() resolves per-model metadata via enrichModelMetadata() which
|
|
276
|
-
// consults pi-ai's bundled catalog. These tests verify the end-to-end path:
|
|
277
|
-
// discovered id → catalog match → registerProvider receives accurate fields.
|
|
278
|
-
|
|
279
|
-
it("captures ctx.modelRegistry from session_start and re-registers providers with enriched metadata", async () => {
|
|
280
|
-
const mod = await importFresh();
|
|
281
|
-
const { pi, registerProvider } = makeMockPi();
|
|
282
|
-
|
|
283
|
-
// Capture the session_start handler registered by activate().
|
|
284
|
-
const handlers = new Map<string, (event: any, ctx: any) => Promise<void> | void>();
|
|
285
|
-
pi.on = vi.fn((event: string, handler: any) => {
|
|
286
|
-
handlers.set(event, handler);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// Fake pi's ModelRegistry. `find(provider, id)` returns Opus 4.7's real
|
|
290
|
-
// metadata for the anthropic entry, simulating what pi passes via
|
|
291
|
-
// ctx.modelRegistry at session_start.
|
|
292
|
-
const fakeRegistry = {
|
|
293
|
-
find: vi.fn((provider: string, id: string) => {
|
|
294
|
-
if (provider === "anthropic" && id === "claude-opus-4-7") {
|
|
295
|
-
return {
|
|
296
|
-
contextWindow: 1_000_000,
|
|
297
|
-
maxTokens: 128_000,
|
|
298
|
-
reasoning: true,
|
|
299
|
-
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
300
|
-
input: ["text", "image"],
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
return null;
|
|
304
|
-
}),
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
// Fetch mock advertises the real model id.
|
|
308
|
-
globalThis.fetch = vi.fn(async () =>
|
|
309
|
-
new Response(
|
|
310
|
-
JSON.stringify({ data: [{ id: "cc/claude-opus-4-7" }] }),
|
|
311
|
-
{ status: 200 },
|
|
312
|
-
),
|
|
313
|
-
) as any;
|
|
314
|
-
|
|
315
|
-
writeProvidersJson(tmpHome, {
|
|
316
|
-
proxy: {
|
|
317
|
-
baseUrl: "https://llmproxy.example.com/v1",
|
|
318
|
-
apiKey: "sk-test",
|
|
319
|
-
api: "anthropic-messages",
|
|
320
|
-
},
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
// 1) activate() registers the provider BEFORE ctx.modelRegistry is
|
|
324
|
-
// available. It now issues TWO calls per provider: an auth-only
|
|
325
|
-
// pre-registration (no `models`, closes the spawn race — see change:
|
|
326
|
-
// fix-flow-agent-model-resolution) followed by the fire-and-forget
|
|
327
|
-
// registerEntry() fallback-enriched call.
|
|
328
|
-
mod.activate(pi);
|
|
329
|
-
// Wait a microtask for the fire-and-forget registerEntry inside activate.
|
|
330
|
-
await new Promise((r) => setTimeout(r, 10));
|
|
331
|
-
|
|
332
|
-
expect(registerProvider).toHaveBeenCalledTimes(2);
|
|
333
|
-
// call[0] = auth-only pre-registration: carries the apiKey, no models.
|
|
334
|
-
const preRegCall = registerProvider.mock.calls[0];
|
|
335
|
-
expect(preRegCall[0]).toBe("proxy");
|
|
336
|
-
expect(preRegCall[1].models).toBeUndefined();
|
|
337
|
-
// call[1] = registerEntry() fallback path (no captured registry yet).
|
|
338
|
-
const firstCall = registerProvider.mock.calls[1];
|
|
339
|
-
expect(firstCall[1].models[0].contextWindow).toBe(200_000); // fallback
|
|
340
|
-
|
|
341
|
-
// 2) Fire session_start with ctx.modelRegistry — the handler captures it
|
|
342
|
-
// and re-registers all known providers with the enriched metadata.
|
|
343
|
-
const sessionStartHandler = handlers.get("session_start");
|
|
344
|
-
expect(sessionStartHandler).toBeDefined();
|
|
345
|
-
await sessionStartHandler!({ type: "session_start" }, {
|
|
346
|
-
ui: { notify: vi.fn() },
|
|
347
|
-
modelRegistry: fakeRegistry,
|
|
348
|
-
model: undefined,
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
// 3) The re-registration should have issued a third registerProvider
|
|
352
|
-
// call, this time with the catalog-enriched metadata.
|
|
353
|
-
expect(registerProvider).toHaveBeenCalledTimes(3);
|
|
354
|
-
const secondCall = registerProvider.mock.calls[2];
|
|
355
|
-
const [name, config] = secondCall;
|
|
356
|
-
expect(name).toBe("proxy");
|
|
357
|
-
const [opus] = config.models;
|
|
358
|
-
expect(opus.id).toBe("cc/claude-opus-4-7");
|
|
359
|
-
expect(opus.contextWindow).toBe(1_000_000);
|
|
360
|
-
expect(opus.maxTokens).toBe(128_000);
|
|
361
|
-
expect(opus.reasoning).toBe(true);
|
|
362
|
-
expect(opus.cost.input).toBe(5);
|
|
363
|
-
expect(opus.cost.output).toBe(25);
|
|
364
|
-
// Probed with prefix-stripped bare id under `anthropic`.
|
|
365
|
-
expect(fakeRegistry.find).toHaveBeenCalledWith("anthropic", "claude-opus-4-7");
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it("without modelRegistry (never captured), discovered models fall back to api-appropriate defaults", async () => {
|
|
369
|
-
const mod = await importFresh();
|
|
370
|
-
const { pi, registerProvider } = makeMockPi();
|
|
371
|
-
|
|
372
|
-
// No session_start fires — modelRegistryRef stays null and the probe is
|
|
373
|
-
// null, so every discovered id hits the fallback table.
|
|
374
|
-
globalThis.fetch = vi.fn(async () =>
|
|
375
|
-
new Response(
|
|
376
|
-
JSON.stringify({ data: [{ id: "cc/claude-opus-4-7" }] }),
|
|
377
|
-
{ status: 200 },
|
|
378
|
-
),
|
|
379
|
-
) as any;
|
|
380
|
-
|
|
381
|
-
writeProvidersJson(tmpHome, {
|
|
382
|
-
proxy: {
|
|
383
|
-
baseUrl: "https://llmproxy.example.com/v1",
|
|
384
|
-
apiKey: "sk-test",
|
|
385
|
-
api: "anthropic-messages",
|
|
386
|
-
},
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
await mod.reloadProviders(pi);
|
|
390
|
-
|
|
391
|
-
const [, config] = registerProvider.mock.calls[0];
|
|
392
|
-
const [opus] = config.models;
|
|
393
|
-
// anthropic-messages fallback: 200k / 64k / no reasoning / zero cost / text+image.
|
|
394
|
-
expect(opus.contextWindow).toBe(200_000);
|
|
395
|
-
expect(opus.maxTokens).toBe(64_000);
|
|
396
|
-
expect(opus.reasoning).toBe(false);
|
|
397
|
-
expect(opus.input).toEqual(["text", "image"]);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// ── custom-flag race regression (see change: fix-custom-provider-flag-race) ──
|
|
401
|
-
// The bridge's first `providers_list` push fires from `session_start`
|
|
402
|
-
// shortly after `activate()` kicked off async `registerEntry()` calls.
|
|
403
|
-
// The catalogue's `custom: true` flag MUST be set on that first push,
|
|
404
|
-
// even when each provider's `/v1/models` endpoint hasn't responded yet —
|
|
405
|
-
// otherwise custom providers from `~/.pi/agent/providers.json` leak into
|
|
406
|
-
// Settings → Provider Authentication → API Keys (where they don't belong;
|
|
407
|
-
// the LLM Providers section already manages them).
|
|
408
|
-
|
|
409
|
-
it("custom flag is set on first providers_list push, before discoverModels resolves (regression)", async () => {
|
|
410
|
-
const mod = await importFresh();
|
|
411
|
-
const { pi } = makeMockPi();
|
|
412
|
-
|
|
413
|
-
// Capture event handlers so we can fire model_select to set modelRegistryRef.
|
|
414
|
-
const handlers = new Map<string, (event: any, ctx: any) => Promise<void> | void>();
|
|
415
|
-
pi.on = vi.fn((event: string, handler: any) => { handlers.set(event, handler); });
|
|
416
|
-
|
|
417
|
-
// Stub fetch with a never-resolving promise — simulates a slow or
|
|
418
|
-
// unreachable /v1/models endpoint. The fix's correctness does NOT depend
|
|
419
|
-
// on this resolving; the synchronous `lastRegistered.set` runs before the
|
|
420
|
-
// await.
|
|
421
|
-
let resolveFetch: ((value: Response) => void) | null = null;
|
|
422
|
-
globalThis.fetch = vi.fn(
|
|
423
|
-
() => new Promise<Response>((r) => { resolveFetch = r; }),
|
|
424
|
-
) as any;
|
|
425
|
-
|
|
426
|
-
// Two custom providers. With the fix, both end up in lastRegistered
|
|
427
|
-
// synchronously when activate() iterates them.
|
|
428
|
-
writeProvidersJson(tmpHome, {
|
|
429
|
-
proxy: { baseUrl: "https://example.com/v1", apiKey: "sk-test", api: "openai-completions" },
|
|
430
|
-
"your-llmproxy": { baseUrl: "https://example2.com/v1", apiKey: "sk-test", api: "openai-completions" },
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
// activate() fires registerEntry async (.catch(() => {})). The synchronous
|
|
434
|
-
// body runs to the first await before yielding.
|
|
435
|
-
mod.activate(pi);
|
|
436
|
-
|
|
437
|
-
// Capture modelRegistry via a model_select event — buildProviderCatalogue()
|
|
438
|
-
// returns [] when modelRegistryRef is null. We use model_select rather
|
|
439
|
-
// than session_start because session_start would re-register every entry
|
|
440
|
-
// (also stalling on the never-resolving fetch).
|
|
441
|
-
const fakeRegistry = {
|
|
442
|
-
find: () => null,
|
|
443
|
-
getAll: () => [
|
|
444
|
-
{ provider: "proxy", id: "some-model" },
|
|
445
|
-
{ provider: "your-llmproxy", id: "some-model" },
|
|
446
|
-
{ provider: "deepseek", id: "deepseek-chat" },
|
|
447
|
-
],
|
|
448
|
-
getProviderDisplayName: (id: string) => id,
|
|
449
|
-
authStorage: {
|
|
450
|
-
getOAuthProviders: () => [],
|
|
451
|
-
getAuthStatus: () => ({ configured: false }),
|
|
452
|
-
get: () => undefined,
|
|
453
|
-
},
|
|
454
|
-
};
|
|
455
|
-
const modelSelectHandler = handlers.get("model_select");
|
|
456
|
-
expect(modelSelectHandler).toBeDefined();
|
|
457
|
-
await modelSelectHandler!({}, { modelRegistry: fakeRegistry, model: undefined });
|
|
458
|
-
|
|
459
|
-
// Build the catalogue while discovery is still in flight. With the fix,
|
|
460
|
-
// both custom providers are flagged custom: true. Without it, lastRegistered
|
|
461
|
-
// is still empty (the post-await `lastRegistered.set` never runs because
|
|
462
|
-
// fetch never resolves) and the flags are missing.
|
|
463
|
-
const cat = mod.buildProviderCatalogue();
|
|
464
|
-
|
|
465
|
-
expect(cat.find((c) => c.id === "proxy")?.custom).toBe(true);
|
|
466
|
-
expect(cat.find((c) => c.id === "your-llmproxy")?.custom).toBe(true);
|
|
467
|
-
// Built-in pi-ai providers must remain unflagged.
|
|
468
|
-
expect(cat.find((c) => c.id === "deepseek")?.custom).toBeUndefined();
|
|
469
|
-
|
|
470
|
-
// Cleanup: settle the dangling fetches so the test process doesn't leak.
|
|
471
|
-
if (resolveFetch) (resolveFetch as (value: Response) => void)(new Response(JSON.stringify({ data: [] }), { status: 200 }));
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
it("discovered unknown model falls back to api-appropriate defaults (openai-completions → 128k)", async () => {
|
|
475
|
-
const mod = await importFresh();
|
|
476
|
-
const { pi, registerProvider } = makeMockPi();
|
|
477
|
-
|
|
478
|
-
// Default beforeEach fetch stub returns `m1` and `m2` — neither exists in catalog.
|
|
479
|
-
writeProvidersJson(tmpHome, {
|
|
480
|
-
"my-llm": {
|
|
481
|
-
baseUrl: "https://api.example.com/v1",
|
|
482
|
-
apiKey: "sk-abc",
|
|
483
|
-
api: "openai-completions",
|
|
484
|
-
},
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
await mod.reloadProviders(pi);
|
|
488
|
-
|
|
489
|
-
const [, config] = registerProvider.mock.calls[0];
|
|
490
|
-
for (const m of config.models) {
|
|
491
|
-
expect(m.contextWindow).toBe(128_000);
|
|
492
|
-
expect(m.maxTokens).toBe(16_384);
|
|
493
|
-
expect(m.reasoning).toBe(false);
|
|
494
|
-
expect(m.cost).toEqual({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
495
|
-
expect(m.input).toEqual(["text", "image"]);
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* toModelInfo projects pi 0.72+'s per-model `thinkingLevelMap` into
|
|
3
|
-
* `supportedThinkingLevels` via pi's canonical `getSupportedThinkingLevels`.
|
|
4
|
-
* The map is a SPARSE override table: unmentioned levels stay supported, `null`
|
|
5
|
-
* disables a level, `xhigh` needs an explicit non-null entry, and a
|
|
6
|
-
* non-reasoning model supports only `off`. Models with no thinking metadata →
|
|
7
|
-
* undefined (client falls back to all six).
|
|
8
|
-
*
|
|
9
|
-
* See change: fix-thinking-level-supported-projection.
|
|
10
|
-
*/
|
|
11
|
-
import { describe, expect, it } from "vitest";
|
|
12
|
-
import { deriveSupportedThinkingLevels, toModelInfo } from "../provider-register.js";
|
|
13
|
-
|
|
14
|
-
const ALL_SIX = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
15
|
-
|
|
16
|
-
describe("toModelInfo — supportedThinkingLevels projection", () => {
|
|
17
|
-
it("sparse reasoning map (Opus) surfaces all non-disabled levels", () => {
|
|
18
|
-
const info = toModelInfo({
|
|
19
|
-
provider: "anthropic",
|
|
20
|
-
id: "claude-opus-4-8",
|
|
21
|
-
reasoning: true,
|
|
22
|
-
thinkingLevelMap: { xhigh: "xhigh" },
|
|
23
|
-
});
|
|
24
|
-
expect(info.supportedThinkingLevels).toEqual(ALL_SIX);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("dense map drops only the null-disabled level (xhigh)", () => {
|
|
28
|
-
const info = toModelInfo({
|
|
29
|
-
provider: "anthropic",
|
|
30
|
-
id: "claude",
|
|
31
|
-
reasoning: true,
|
|
32
|
-
thinkingLevelMap: { medium: "medium", high: "high", xhigh: null },
|
|
33
|
-
});
|
|
34
|
-
expect(info.supportedThinkingLevels).toEqual(["off", "minimal", "low", "medium", "high"]);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("non-reasoning model supports only off", () => {
|
|
38
|
-
const info = toModelInfo({ provider: "openai", id: "gpt", reasoning: false });
|
|
39
|
-
expect(info.supportedThinkingLevels).toEqual(["off"]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("reasoning model with no map supports all but xhigh (xhigh needs an explicit entry)", () => {
|
|
43
|
-
const info = toModelInfo({ provider: "anthropic", id: "sonnet", reasoning: true });
|
|
44
|
-
expect(info.supportedThinkingLevels).toEqual(["off", "minimal", "low", "medium", "high"]);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("leaves supportedThinkingLevels undefined when no thinking metadata", () => {
|
|
48
|
-
const info = toModelInfo({ provider: "openai", id: "gpt" });
|
|
49
|
-
expect(info.supportedThinkingLevels).toBeUndefined();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("never projects compat or credential material into ModelInfo (S1/§7.1)", () => {
|
|
53
|
-
const info = toModelInfo({
|
|
54
|
-
provider: "newapi",
|
|
55
|
-
id: "glm-5.2",
|
|
56
|
-
reasoning: true,
|
|
57
|
-
thinkingLevelMap: { xhigh: "xhigh" },
|
|
58
|
-
compat: { thinkingFormat: "deepseek" },
|
|
59
|
-
apiKey: "sk-secret",
|
|
60
|
-
});
|
|
61
|
-
expect(JSON.stringify(info)).not.toMatch(/compat|thinkingFormat|deepseek|apiKey|sk-secret/i);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("native thinkingLevelMap flows through toModelInfo (F1)", () => {
|
|
65
|
-
// Test runtime is pi-ai 0.75.5 (no `max`), so `max` is never surfaced here.
|
|
66
|
-
const info = toModelInfo({
|
|
67
|
-
provider: "newapi",
|
|
68
|
-
id: "glm-5.2",
|
|
69
|
-
reasoning: true,
|
|
70
|
-
thinkingLevelMap: { xhigh: "xhigh" },
|
|
71
|
-
});
|
|
72
|
-
expect(info.supportedThinkingLevels).toEqual(ALL_SIX);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// SYNTHETIC table (NOT the pinned pi-ai 0.75.5 fn, which has no `max` branch):
|
|
77
|
-
// max is opt-in AND runtime-gated, fail-CLOSED. See change:
|
|
78
|
-
// honor-native-models-json-metadata (test-plan E11).
|
|
79
|
-
describe("deriveSupportedThinkingLevels — runtime-gated max (E11)", () => {
|
|
80
|
-
const MAX_ONLY = { minimal: null, low: null, medium: null, high: null, xhigh: null, max: "max" };
|
|
81
|
-
|
|
82
|
-
it("emits max only when maxSupported AND the map opts in", () => {
|
|
83
|
-
expect(deriveSupportedThinkingLevels(true, MAX_ONLY, true)).toEqual(["off", "max"]);
|
|
84
|
-
expect(deriveSupportedThinkingLevels(true, MAX_ONLY, false)).toEqual(["off"]);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("never emits max when the map omits it, even on a max-capable runtime", () => {
|
|
88
|
-
expect(deriveSupportedThinkingLevels(true, { xhigh: "xhigh" }, true)).toEqual(ALL_SIX);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("reasoning model with no map supports all levels except xhigh and max", () => {
|
|
92
|
-
expect(deriveSupportedThinkingLevels(true, undefined, true)).toEqual([
|
|
93
|
-
"off",
|
|
94
|
-
"minimal",
|
|
95
|
-
"low",
|
|
96
|
-
"medium",
|
|
97
|
-
"high",
|
|
98
|
-
]);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("non-reasoning model supports only off", () => {
|
|
102
|
-
expect(deriveSupportedThinkingLevels(false, MAX_ONLY, true)).toEqual(["off"]);
|
|
103
|
-
});
|
|
104
|
-
});
|