@baique/pi-web-sky 0.1.35 → 0.1.36
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +16 -16
- package/.next/build-manifest.json +3 -3
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -1
- package/.next/server/app/api/agent/[id]/events/route.js +1 -1
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/app-update/route.js +1 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +1 -1
- package/.next/server/app/api/cwd/validate/route.js +1 -1
- package/.next/server/app/api/default-cwd/route.js +1 -1
- package/.next/server/app/api/file-index/route.js +1 -1
- package/.next/server/app/api/files/[...path]/route.js +1 -1
- package/.next/server/app/api/mcp/route.js +1 -1
- package/.next/server/app/api/models/route.js +1 -1
- package/.next/server/app/api/plugins/route.js +1 -1
- package/.next/server/app/api/project-trust/route.js +1 -1
- package/.next/server/app/api/search/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/export/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/todos/route.js +1 -1
- package/.next/server/app/api/sessions/route.js +1 -1
- package/.next/server/app/api/skills/check/route.js +1 -1
- package/.next/server/app/api/skills/check/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/install/route.js +1 -1
- package/.next/server/app/api/skills/route.js +2 -31
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/update/route.js +1 -1
- package/.next/server/app/api/skills/update/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +5 -5
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +5 -5
- package/.next/server/app/index.segments/_full.segment.rsc +5 -5
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +16 -16
- package/.next/server/chunks/2404.js +1 -1
- package/.next/server/chunks/3500.js +30 -0
- package/.next/server/chunks/4226.js +2 -2
- package/.next/server/chunks/542.js +10 -5
- package/.next/server/chunks/5794.js +1 -1
- package/.next/server/chunks/6429.js +1 -1
- package/.next/server/chunks/898.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/5315.7e72d26a3ad3bd9a.js +4 -0
- package/.next/static/chunks/app/{layout-1d9a7a44fbc92d2e.js → layout-ebbc0d287267b07b.js} +1 -1
- package/.next/static/chunks/app/{page-6d6779a81a0a7639.js → page-e568623a44c67606.js} +2 -2
- package/.next/static/chunks/{webpack-fa4f40085b1ec1ac.js → webpack-2e4e348867a555cd.js} +1 -1
- package/.next/static/css/422c7dc0faa04d89.css +1 -0
- package/.next/trace +8 -9
- package/.next/trace-build +1 -1
- package/bin/pi-web-sky.js +15 -20
- package/lib/agent-client.test.mjs +64 -0
- package/lib/agent-client.ts +53 -0
- package/lib/agent-event-connection.test.mjs +193 -0
- package/lib/agent-event-connection.ts +202 -0
- package/lib/agent-event-stream.test.mjs +155 -0
- package/lib/agent-event-stream.ts +132 -0
- package/lib/agent-event-wire.test.mjs +278 -0
- package/lib/agent-event-wire.ts +107 -0
- package/lib/agent-phase.ts +24 -0
- package/lib/allowed-roots.ts +31 -0
- package/lib/ansi.test.mjs +52 -0
- package/lib/ansi.ts +211 -0
- package/lib/api-types.ts +139 -0
- package/lib/app-update.test.mjs +27 -0
- package/lib/app-update.ts +28 -0
- package/lib/atomic-file.test.mjs +37 -0
- package/lib/atomic-file.ts +34 -0
- package/lib/audit-session.ts +235 -0
- package/lib/bash-output.test.mjs +63 -0
- package/lib/bash-output.ts +53 -0
- package/lib/bg-image.ts +129 -0
- package/lib/board-events.ts +83 -0
- package/lib/board-purge.test.mjs +66 -0
- package/lib/board-purge.ts +65 -0
- package/lib/board-search.test.mjs +110 -0
- package/lib/board-search.ts +63 -0
- package/lib/board-store.test.mjs +542 -0
- package/lib/board-store.ts +794 -0
- package/lib/board-types.ts +96 -0
- package/lib/board-utils.ts +17 -0
- package/lib/bounded-form-data.test.mjs +54 -0
- package/lib/bounded-form-data.ts +49 -0
- package/lib/browser-notifications.test.mjs +167 -0
- package/lib/browser-notifications.ts +104 -0
- package/lib/chat-lazy-load.test.mjs +140 -0
- package/lib/chat-lazy-load.ts +64 -0
- package/lib/clipboard-paths.test.mjs +140 -0
- package/lib/clipboard-paths.ts +192 -0
- package/lib/clipboard.ts +18 -0
- package/lib/compaction-summary.test.mjs +44 -0
- package/lib/compaction-summary.ts +34 -0
- package/lib/custom-ui-terminal.test.mjs +32 -0
- package/lib/custom-ui-terminal.ts +27 -0
- package/lib/deepseek-pricing.test.mjs +120 -0
- package/lib/deepseek-pricing.ts +71 -0
- package/lib/directory-browser.test.mjs +60 -0
- package/lib/directory-browser.ts +83 -0
- package/lib/draft-stash.test.mjs +91 -0
- package/lib/draft-stash.ts +102 -0
- package/lib/draft-store.ts +105 -0
- package/lib/dropdown-direction.ts +27 -0
- package/lib/extension-command.test.mjs +63 -0
- package/lib/extension-command.ts +81 -0
- package/lib/file-access.test.mjs +31 -0
- package/lib/file-access.ts +59 -0
- package/lib/file-dirent.test.mjs +56 -0
- package/lib/file-dirent.ts +17 -0
- package/lib/file-explorer-state.test.mjs +63 -0
- package/lib/file-explorer-state.ts +36 -0
- package/lib/file-fuzzy.test.mjs +29 -0
- package/lib/file-fuzzy.ts +189 -0
- package/lib/file-links.test.mjs +92 -0
- package/lib/file-links.ts +148 -0
- package/lib/file-paths.ts +43 -0
- package/lib/file-types.test.mjs +34 -0
- package/lib/file-types.ts +73 -0
- package/lib/file-upload.test.mjs +70 -0
- package/lib/file-upload.ts +59 -0
- package/lib/file-viewer-state.test.mjs +20 -0
- package/lib/file-viewer-state.ts +15 -0
- package/lib/frontmatter.test.mjs +55 -0
- package/lib/frontmatter.ts +87 -0
- package/lib/git-changes.test.mjs +52 -0
- package/lib/git-changes.ts +232 -0
- package/lib/git-status.ts +47 -0
- package/lib/git-types.ts +29 -0
- package/lib/http-dispatcher.test.mjs +83 -0
- package/lib/http-dispatcher.ts +86 -0
- package/lib/i18n/format.test.mjs +19 -0
- package/lib/i18n/format.ts +60 -0
- package/lib/i18n/messages/en.ts +662 -0
- package/lib/i18n/messages/zh-CN.ts +661 -0
- package/lib/i18n/registry.test.mjs +32 -0
- package/lib/i18n/registry.ts +43 -0
- package/lib/i18n/types.ts +15 -0
- package/lib/image-attachments.test.mjs +27 -0
- package/lib/image-attachments.ts +56 -0
- package/lib/initial-navigation.test.mjs +65 -0
- package/lib/initial-navigation.ts +15 -0
- package/lib/markdown.test.mjs +104 -0
- package/lib/markdown.ts +347 -0
- package/lib/message-display.test.mjs +130 -0
- package/lib/message-display.ts +47 -0
- package/lib/model-catalog.test.mjs +327 -0
- package/lib/model-catalog.ts +414 -0
- package/lib/model-discovery-auth.ts +58 -0
- package/lib/model-discovery.test.mjs +50 -0
- package/lib/model-discovery.ts +75 -0
- package/lib/model-id-preference.ts +46 -0
- package/lib/model-scope.test.mjs +193 -0
- package/lib/model-scope.ts +198 -0
- package/lib/models-cache.test.mjs +122 -0
- package/lib/models-cache.ts +90 -0
- package/lib/models-config-store.test.mjs +200 -0
- package/lib/models-config-store.ts +84 -0
- package/lib/next-config-esm.test.mjs +14 -0
- package/lib/next-config.test.mjs +13 -0
- package/lib/node-version.test.mjs +33 -0
- package/lib/normalize.test.mjs +54 -0
- package/lib/normalize.ts +63 -0
- package/lib/npx.ts +62 -0
- package/lib/panel-layout.test.mjs +56 -0
- package/lib/panel-layout.ts +52 -0
- package/lib/patch.test.mjs +110 -0
- package/lib/patch.ts +134 -0
- package/lib/path-security.ts +42 -0
- package/lib/paths.test.mjs +58 -0
- package/lib/paths.ts +71 -0
- package/lib/pi-types.ts +183 -0
- package/lib/pi-web-options.test.mjs +63 -0
- package/lib/process-lifecycle.test.mjs +83 -0
- package/lib/project-command-env.test.mjs +298 -0
- package/lib/project-command-env.ts +129 -0
- package/lib/project-groups.test.mjs +60 -0
- package/lib/project-groups.ts +53 -0
- package/lib/project-identity.test.mjs +37 -0
- package/lib/project-identity.ts +26 -0
- package/lib/project-tree.test.mjs +115 -0
- package/lib/project-tree.ts +176 -0
- package/lib/project-trust.test.mjs +117 -0
- package/lib/project-trust.ts +48 -0
- package/lib/prompt-recovery.test.mjs +33 -0
- package/lib/prompt-recovery.ts +47 -0
- package/lib/provider-api-key-route.test.mjs +12 -0
- package/lib/provider-credential-store.test.mjs +126 -0
- package/lib/provider-credential-store.ts +114 -0
- package/lib/provider-listing-runtime.ts +37 -0
- package/lib/provider-listing.test.mjs +114 -0
- package/lib/provider-listing.ts +118 -0
- package/lib/provider-services.ts +64 -0
- package/lib/request-security.test.mjs +256 -0
- package/lib/request-security.ts +136 -0
- package/lib/rpc-manager-shutdown.test.mjs +372 -0
- package/lib/rpc-manager-widgets.test.mjs +342 -0
- package/lib/rpc-manager.test.mjs +139 -0
- package/lib/rpc-manager.ts +1703 -0
- package/lib/rpc-session-info.test.mjs +93 -0
- package/lib/session-delete.test.mjs +53 -0
- package/lib/session-delete.ts +86 -0
- package/lib/session-file-references-core.ts +82 -0
- package/lib/session-file-references.test.mjs +91 -0
- package/lib/session-file-references.ts +29 -0
- package/lib/session-path.test.mjs +24 -0
- package/lib/session-path.ts +11 -0
- package/lib/session-reader.pagination.test.mjs +115 -0
- package/lib/session-reader.test.mjs +446 -0
- package/lib/session-reader.ts +548 -0
- package/lib/session-resolve.test.mjs +65 -0
- package/lib/session-row-context-menu.test.mjs +46 -0
- package/lib/session-row-context-menu.ts +29 -0
- package/lib/session-scanner.test.mjs +151 -0
- package/lib/session-scanner.ts +238 -0
- package/lib/session-search.test.mjs +173 -0
- package/lib/session-search.ts +284 -0
- package/lib/session-stats.ts +26 -0
- package/lib/session-timing.test.mjs +107 -0
- package/lib/session-timing.ts +45 -0
- package/lib/session-title.test.mjs +284 -0
- package/lib/session-title.ts +255 -0
- package/lib/skill-frontmatter.test.mjs +75 -0
- package/lib/skill-frontmatter.ts +40 -0
- package/lib/skill-lock.test.mjs +182 -0
- package/lib/skill-lock.ts +146 -0
- package/lib/skill-updates.test.mjs +182 -0
- package/lib/skill-updates.ts +263 -0
- package/lib/skills-service.ts +16 -0
- package/lib/slash-display.test.mjs +122 -0
- package/lib/slash-display.ts +30 -0
- package/lib/sqlite-db.test.mjs +140 -0
- package/lib/sqlite-db.ts +205 -0
- package/lib/startup-preferences.test.mjs +130 -0
- package/lib/startup-preferences.ts +65 -0
- package/lib/streaming-message.test.mjs +212 -0
- package/lib/streaming-message.ts +151 -0
- package/lib/subagent-widget.test.mjs +87 -0
- package/lib/subagent-widget.ts +109 -0
- package/lib/sync-room-server.mjs +137 -0
- package/lib/task-card-store.test.mjs +309 -0
- package/lib/task-card-store.ts +559 -0
- package/lib/task-scheduler.ts +498 -0
- package/lib/task-store.test.mjs +216 -0
- package/lib/task-store.ts +271 -0
- package/lib/terminal-input.test.mjs +46 -0
- package/lib/terminal-input.ts +63 -0
- package/lib/terminal-manager.test.mjs +71 -0
- package/lib/terminal-manager.ts +245 -0
- package/lib/tool-execution-progress.test.mjs +32 -0
- package/lib/tool-execution-progress.ts +29 -0
- package/lib/tool-names.ts +25 -0
- package/lib/tool-preset-preference.test.mjs +72 -0
- package/lib/tool-preset-preference.ts +41 -0
- package/lib/tool-presets.test.mjs +56 -0
- package/lib/tool-presets.ts +42 -0
- package/lib/turn-written-files.test.mjs +137 -0
- package/lib/turn-written-files.ts +60 -0
- package/lib/types.ts +349 -0
- package/lib/wallpaper-settings.ts +191 -0
- package/lib/web-auth.test.mjs +50 -0
- package/lib/web-auth.ts +45 -0
- package/lib/workspace-memory.test.mjs +129 -0
- package/lib/workspace-memory.ts +98 -0
- package/lib/worktree.test.mjs +50 -0
- package/lib/worktree.ts +250 -0
- package/package.json +3 -1
- package/server.mjs +34 -0
- package/.next/server/chunks/7513.js +0 -30
- package/.next/static/chunks/5315.03de3c6abd8b283e.js +0 -4
- package/.next/static/css/cf25164cb7c04d95.css +0 -1
- /package/.next/static/{Ud6Y2ONkGuPVFbo1xZQvk → EoBw3VYlygpr1EqlVOa5b}/_buildManifest.js +0 -0
- /package/.next/static/{Ud6Y2ONkGuPVFbo1xZQvk → EoBw3VYlygpr1EqlVOa5b}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
async function loadSubject() {
|
|
5
|
+
try {
|
|
6
|
+
const { createJiti } = await import("jiti");
|
|
7
|
+
return createJiti(import.meta.url).import("./model-catalog.ts");
|
|
8
|
+
} catch {
|
|
9
|
+
return import("./model-catalog.ts");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
flattenModelsDevCatalog,
|
|
15
|
+
recommendModelCatalogPreset,
|
|
16
|
+
searchModelCatalog,
|
|
17
|
+
} = await loadSubject();
|
|
18
|
+
|
|
19
|
+
const catalog = flattenModelsDevCatalog({
|
|
20
|
+
openai: {
|
|
21
|
+
name: "OpenAI",
|
|
22
|
+
models: {
|
|
23
|
+
"gpt-5": {
|
|
24
|
+
id: "gpt-5",
|
|
25
|
+
name: "GPT-5",
|
|
26
|
+
reasoning: true,
|
|
27
|
+
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
28
|
+
limit: { context: 400_000, output: 128_000 },
|
|
29
|
+
cost: { input: 1.25, output: 10, cache_read: 0.125 },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
openrouter: {
|
|
34
|
+
name: "OpenRouter",
|
|
35
|
+
api: "https://openrouter.ai/api/v1",
|
|
36
|
+
models: {
|
|
37
|
+
"openai/gpt-5": {
|
|
38
|
+
id: "openai/gpt-5",
|
|
39
|
+
name: "GPT-5 via OpenRouter",
|
|
40
|
+
limit: { context: 400_000, output: 128_000 },
|
|
41
|
+
cost: { input: 1.3, output: 10.5, cache_write: 2 },
|
|
42
|
+
},
|
|
43
|
+
"missing-price": {
|
|
44
|
+
id: "missing-price",
|
|
45
|
+
name: "No Price",
|
|
46
|
+
limit: { context: 32_000, output: 8_000 },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function priceConsensusCatalog(groups) {
|
|
53
|
+
let providerIndex = 0;
|
|
54
|
+
return flattenModelsDevCatalog(Object.fromEntries(groups.flatMap(({ count, input, output }) => (
|
|
55
|
+
Array.from({ length: count }, () => {
|
|
56
|
+
const providerId = `provider-${providerIndex++}`;
|
|
57
|
+
return [providerId, {
|
|
58
|
+
models: {
|
|
59
|
+
model: {
|
|
60
|
+
id: "model",
|
|
61
|
+
cost: { input, output, cache_read: input / 10, cache_write: input },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}];
|
|
65
|
+
})
|
|
66
|
+
))));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
test("flattens supported models.dev metadata and prices", () => {
|
|
70
|
+
assert.deepEqual(catalog[0], {
|
|
71
|
+
key: "openai/gpt-5",
|
|
72
|
+
providerId: "openai",
|
|
73
|
+
providerName: "OpenAI",
|
|
74
|
+
id: "gpt-5",
|
|
75
|
+
name: "GPT-5",
|
|
76
|
+
reasoning: true,
|
|
77
|
+
input: ["text", "image"],
|
|
78
|
+
contextWindow: 400_000,
|
|
79
|
+
maxTokens: 128_000,
|
|
80
|
+
cost: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: undefined },
|
|
81
|
+
});
|
|
82
|
+
assert.deepEqual(catalog[2].cost, {});
|
|
83
|
+
assert.equal(catalog[2].contextWindow, 32_000);
|
|
84
|
+
assert.equal(catalog.length, 3);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("ranks exact model IDs and provider hints first", () => {
|
|
88
|
+
assert.equal(searchModelCatalog(catalog, "gpt-5", "openai")[0].providerId, "openai");
|
|
89
|
+
assert.equal(searchModelCatalog(catalog, "openai/gpt-5", "openrouter")[0].providerId, "openrouter");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("prefers an exact Pi provider match", () => {
|
|
93
|
+
const recommendation = recommendModelCatalogPreset(
|
|
94
|
+
catalog,
|
|
95
|
+
"openai/gpt-5",
|
|
96
|
+
"openrouter",
|
|
97
|
+
"https://proxy.example.com/v1",
|
|
98
|
+
);
|
|
99
|
+
assert.equal(recommendation.metadataMethod, "provider");
|
|
100
|
+
assert.equal(recommendation.matchedProviderId, "openrouter");
|
|
101
|
+
assert.deepEqual(recommendation.price, {
|
|
102
|
+
status: "reliable",
|
|
103
|
+
method: "provider",
|
|
104
|
+
cost: { input: 1.3, output: 10.5, cacheRead: 0, cacheWrite: 2 },
|
|
105
|
+
providerId: "openrouter",
|
|
106
|
+
providerName: "OpenRouter",
|
|
107
|
+
support: 1,
|
|
108
|
+
total: 1,
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("matches canonical and catalog Base URLs by hostname", () => {
|
|
113
|
+
const openai = recommendModelCatalogPreset(
|
|
114
|
+
catalog,
|
|
115
|
+
"openai/gpt-5",
|
|
116
|
+
"custom-provider",
|
|
117
|
+
"https://api.openai.com/v1",
|
|
118
|
+
);
|
|
119
|
+
assert.equal(openai.metadataMethod, "base-url");
|
|
120
|
+
assert.equal(openai.matchedProviderId, "openai");
|
|
121
|
+
assert.equal(openai.price.status, "reliable");
|
|
122
|
+
assert.equal(openai.price.method, "base-url");
|
|
123
|
+
assert.deepEqual(openai.price.cost, {
|
|
124
|
+
input: 1.25,
|
|
125
|
+
output: 10,
|
|
126
|
+
cacheRead: 0.125,
|
|
127
|
+
cacheWrite: 0,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const openrouter = recommendModelCatalogPreset(
|
|
131
|
+
catalog,
|
|
132
|
+
"openai/gpt-5",
|
|
133
|
+
"custom-provider",
|
|
134
|
+
"https://api.openrouter.ai/api/v1",
|
|
135
|
+
);
|
|
136
|
+
assert.equal(openrouter.matchedProviderId, "openrouter");
|
|
137
|
+
assert.equal(openrouter.price.status, "reliable");
|
|
138
|
+
assert.equal(openrouter.price.cost.input, 1.3);
|
|
139
|
+
|
|
140
|
+
const lookalike = recommendModelCatalogPreset(
|
|
141
|
+
catalog,
|
|
142
|
+
"openai/gpt-5",
|
|
143
|
+
"custom-provider",
|
|
144
|
+
"https://openrouter.ai.example.com/v1",
|
|
145
|
+
);
|
|
146
|
+
assert.equal(lookalike.metadataMethod, "consensus");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("uses stable metadata and price consensus with cache modes", () => {
|
|
150
|
+
const consensusCatalog = flattenModelsDevCatalog({
|
|
151
|
+
alpha: {
|
|
152
|
+
models: {
|
|
153
|
+
shared: {
|
|
154
|
+
id: "shared",
|
|
155
|
+
name: "Shared Model",
|
|
156
|
+
reasoning: true,
|
|
157
|
+
modalities: { input: ["text", "image"] },
|
|
158
|
+
limit: { context: 128_000, output: 16_000 },
|
|
159
|
+
cost: { input: 2, output: 8, cache_read: 0.2, cache_write: 2 },
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
beta: {
|
|
164
|
+
models: {
|
|
165
|
+
shared: {
|
|
166
|
+
id: "shared",
|
|
167
|
+
name: "Shared Model",
|
|
168
|
+
reasoning: true,
|
|
169
|
+
modalities: { input: ["text", "image"] },
|
|
170
|
+
limit: { context: 128_000, output: 16_000 },
|
|
171
|
+
cost: { input: 2, output: 8, cache_read: 0.2, cache_write: 2 },
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
delta: {
|
|
176
|
+
models: {
|
|
177
|
+
shared: {
|
|
178
|
+
id: "shared",
|
|
179
|
+
name: "Shared Model",
|
|
180
|
+
reasoning: true,
|
|
181
|
+
modalities: { input: ["text", "image"] },
|
|
182
|
+
limit: { context: 128_000, output: 16_000 },
|
|
183
|
+
cost: { input: 2, output: 8, cache_read: 0.3, cache_write: 3 },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
gamma: {
|
|
188
|
+
models: {
|
|
189
|
+
shared: {
|
|
190
|
+
id: "shared",
|
|
191
|
+
name: "Other Name",
|
|
192
|
+
reasoning: false,
|
|
193
|
+
modalities: { input: ["text"] },
|
|
194
|
+
limit: { context: 64_000, output: 8_000 },
|
|
195
|
+
cost: { input: 3, output: 9, cache_read: 0.4, cache_write: 4 },
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
const recommendation = recommendModelCatalogPreset(consensusCatalog, "shared", "custom", "");
|
|
201
|
+
assert.equal(recommendation.metadataMethod, "consensus");
|
|
202
|
+
assert.deepEqual(recommendation.preset, {
|
|
203
|
+
name: "Shared Model",
|
|
204
|
+
reasoning: true,
|
|
205
|
+
input: ["text", "image"],
|
|
206
|
+
contextWindow: 128_000,
|
|
207
|
+
maxTokens: 16_000,
|
|
208
|
+
cost: { input: 2, output: 8, cacheRead: 0.2, cacheWrite: 2 },
|
|
209
|
+
});
|
|
210
|
+
assert.deepEqual(recommendation.price, {
|
|
211
|
+
status: "reliable",
|
|
212
|
+
method: "consensus",
|
|
213
|
+
cost: { input: 2, output: 8, cacheRead: 0.2, cacheWrite: 2 },
|
|
214
|
+
support: 3,
|
|
215
|
+
total: 4,
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("defaults omitted consensus cache prices to zero", () => {
|
|
220
|
+
const recommendation = recommendModelCatalogPreset(
|
|
221
|
+
flattenModelsDevCatalog({
|
|
222
|
+
alpha: { models: { model: { id: "model", cost: { input: 1, output: 2 } } } },
|
|
223
|
+
beta: { models: { model: { id: "model", cost: { input: 1, output: 2 } } } },
|
|
224
|
+
gamma: { models: { model: { id: "model", cost: { input: 1, output: 2 } } } },
|
|
225
|
+
}),
|
|
226
|
+
"model",
|
|
227
|
+
"custom",
|
|
228
|
+
"",
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const expectedCost = { input: 1, output: 2, cacheRead: 0, cacheWrite: 0 };
|
|
232
|
+
assert.deepEqual(recommendation.price, {
|
|
233
|
+
status: "reliable",
|
|
234
|
+
method: "consensus",
|
|
235
|
+
cost: expectedCost,
|
|
236
|
+
support: 3,
|
|
237
|
+
total: 3,
|
|
238
|
+
});
|
|
239
|
+
assert.deepEqual(recommendation.preset.cost, expectedCost);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test("accepts a unique five-record price plurality below 60 percent", () => {
|
|
243
|
+
const pluralityCatalog = priceConsensusCatalog([
|
|
244
|
+
{ count: 5, input: 1, output: 2 },
|
|
245
|
+
{ count: 4, input: 3, output: 4 },
|
|
246
|
+
{ count: 3, input: 5, output: 6 },
|
|
247
|
+
{ count: 2, input: 7, output: 8 },
|
|
248
|
+
{ count: 2, input: 9, output: 10 },
|
|
249
|
+
{ count: 2, input: 11, output: 12 },
|
|
250
|
+
{ count: 2, input: 13, output: 14 },
|
|
251
|
+
]);
|
|
252
|
+
|
|
253
|
+
assert.deepEqual(
|
|
254
|
+
recommendModelCatalogPreset(pluralityCatalog, "model", "custom", "").price,
|
|
255
|
+
{
|
|
256
|
+
status: "reliable",
|
|
257
|
+
method: "consensus",
|
|
258
|
+
cost: { input: 1, output: 2, cacheRead: 0.1, cacheWrite: 1 },
|
|
259
|
+
support: 5,
|
|
260
|
+
total: 20,
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("still rejects four-record pluralities and five-record ties", () => {
|
|
266
|
+
const fourVotes = recommendModelCatalogPreset(
|
|
267
|
+
priceConsensusCatalog([
|
|
268
|
+
{ count: 4, input: 1, output: 2 },
|
|
269
|
+
{ count: 3, input: 3, output: 4 },
|
|
270
|
+
{ count: 2, input: 5, output: 6 },
|
|
271
|
+
{ count: 1, input: 7, output: 8 },
|
|
272
|
+
]),
|
|
273
|
+
"model",
|
|
274
|
+
"custom",
|
|
275
|
+
"",
|
|
276
|
+
);
|
|
277
|
+
assert.deepEqual(fourVotes.price, {
|
|
278
|
+
status: "unreliable",
|
|
279
|
+
reason: "conflict",
|
|
280
|
+
support: 4,
|
|
281
|
+
total: 10,
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const tiedFiveVotes = recommendModelCatalogPreset(
|
|
285
|
+
priceConsensusCatalog([
|
|
286
|
+
{ count: 5, input: 1, output: 2 },
|
|
287
|
+
{ count: 5, input: 3, output: 4 },
|
|
288
|
+
]),
|
|
289
|
+
"model",
|
|
290
|
+
"custom",
|
|
291
|
+
"",
|
|
292
|
+
);
|
|
293
|
+
assert.deepEqual(tiedFiveVotes.price, {
|
|
294
|
+
status: "unreliable",
|
|
295
|
+
reason: "conflict",
|
|
296
|
+
support: 5,
|
|
297
|
+
total: 10,
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test("refuses tied or single-record fallback prices", () => {
|
|
302
|
+
const conflictCatalog = flattenModelsDevCatalog({
|
|
303
|
+
a: { models: { model: { id: "model", cost: { input: 1, output: 2 } } } },
|
|
304
|
+
b: { models: { model: { id: "model", cost: { input: 1, output: 2 } } } },
|
|
305
|
+
c: { models: { model: { id: "model", cost: { input: 3, output: 4 } } } },
|
|
306
|
+
d: { models: { model: { id: "model", cost: { input: 3, output: 4 } } } },
|
|
307
|
+
});
|
|
308
|
+
const conflict = recommendModelCatalogPreset(conflictCatalog, "model", "custom", "");
|
|
309
|
+
assert.deepEqual(conflict.price, {
|
|
310
|
+
status: "unreliable",
|
|
311
|
+
reason: "conflict",
|
|
312
|
+
support: 2,
|
|
313
|
+
total: 4,
|
|
314
|
+
});
|
|
315
|
+
assert.equal(conflict.preset.cost, undefined);
|
|
316
|
+
|
|
317
|
+
const single = recommendModelCatalogPreset(
|
|
318
|
+
flattenModelsDevCatalog({
|
|
319
|
+
only: { models: { model: { id: "model", cost: { input: 1, output: 2 } } } },
|
|
320
|
+
}),
|
|
321
|
+
"model",
|
|
322
|
+
"custom",
|
|
323
|
+
"",
|
|
324
|
+
);
|
|
325
|
+
assert.equal(single.price.status, "unreliable");
|
|
326
|
+
assert.equal(single.price.reason, "insufficient-support");
|
|
327
|
+
});
|