@broberg/ai-sdk 0.70.1 → 0.71.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/dist/{chunk-ZGBDTAP7.js → chunk-6O6HO7M3.js} +7 -1
- package/dist/chunk-6O6HO7M3.js.map +1 -0
- package/dist/{chunk-ATCGVLAO.js → chunk-KCHMZ6P5.js} +2 -2
- package/dist/{chunk-4YQVYVTA.js → chunk-ZL6TFGZ2.js} +2 -2
- package/dist/index.d.ts +67 -4
- package/dist/index.js +201 -29
- package/dist/index.js.map +1 -1
- package/dist/pricing.js +2 -2
- package/dist/registry.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ZGBDTAP7.js.map +0 -1
- /package/dist/{chunk-ATCGVLAO.js.map → chunk-KCHMZ6P5.js.map} +0 -0
- /package/dist/{chunk-4YQVYVTA.js.map → chunk-ZL6TFGZ2.js.map} +0 -0
|
@@ -172,6 +172,9 @@ var PRICING = {
|
|
|
172
172
|
// OpenRouter call books usage.cost from the response anyway; this row is the fallback.
|
|
173
173
|
"openrouter:deepseek/deepseek-v4-pro": { inputPer1M: 0.2088, outputPer1M: 0.4176, version: "2026-10-02-openrouter-live" },
|
|
174
174
|
// F067.7: flash re-read 2026-10-20 — rose from 0.028/0.056.
|
|
175
|
+
"openrouter:openai/gpt-6-astra": { inputPer1M: 10, outputPer1M: 50, version: "2026-11-05-openrouter-live" },
|
|
176
|
+
"openrouter:openai/gpt-6.1-sol": { inputPer1M: 2, outputPer1M: 10, version: "2026-11-05-openrouter-live" },
|
|
177
|
+
"openrouter:deepseek/deepseek-v4.1-flash-1017": { inputPer1M: 0.15, outputPer1M: 0.6, version: "2026-11-05-openrouter-live" },
|
|
175
178
|
"openrouter:deepseek/deepseek-v4-flash": { inputPer1M: 0.091, outputPer1M: 0.182, version: "2026-10-20-openrouter-live" },
|
|
176
179
|
// DeepSeek DIRECT API (provider "deepseek", F030 non-PII secondary). Rates from
|
|
177
180
|
// api-docs.deepseek.com 2026-06-30 ($0.14/$0.28 per 1M; both map to deepseek-v4-flash).
|
|
@@ -204,6 +207,9 @@ var PRICING = {
|
|
|
204
207
|
// priced per-image in the adapter, not here.)
|
|
205
208
|
"gemini:gemini-2.5-flash": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 2.5, version: "2026-08-27-ai.google.dev" },
|
|
206
209
|
// flash-lite is the default `video` tier (F019) — cheap native video understanding.
|
|
210
|
+
// F088 — measured 2026-11-05: reachable with our GEMINI_API_KEY; price = OpenRouter's
|
|
211
|
+
// live google/gemini-4-argon row (passes Google's list price through).
|
|
212
|
+
"gemini:gemini-4-argon": { inputPer1M: 2, outputPer1M: 10, version: "2026-11-05-openrouter-live" },
|
|
207
213
|
"gemini:gemini-2.5-flash-lite": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: "2026-08-27-ai.google.dev" },
|
|
208
214
|
// Vertex AI (F038) — the EU-resident route to the SAME Gemini models, so Google's
|
|
209
215
|
// published Gemini token prices apply. Listed separately because cost lookups key on
|
|
@@ -301,4 +307,4 @@ export {
|
|
|
301
307
|
stripDatedSuffix,
|
|
302
308
|
getPrice
|
|
303
309
|
};
|
|
304
|
-
//# sourceMappingURL=chunk-
|
|
310
|
+
//# sourceMappingURL=chunk-6O6HO7M3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cost/pricing.ts"],"sourcesContent":["// Versioned per-(provider, model) pricing. F3.6 populates the table + adds tests\n// + MiniMax coverage. F3.1 ships the type + lookup with an empty table, so\n// computeCost returns 0 for every model until F3.6 lands (calls still complete).\nexport interface PricingEntry {\n /** USD per 1M input tokens. */\n inputPer1M: number;\n /** USD per 1M output tokens. */\n outputPer1M: number;\n /** USD per 1M cache-read tokens (falls back to input rate if unset). */\n cacheReadPer1M?: number;\n /** USD per 1M cache-write/creation tokens (falls back to input rate if unset). */\n cacheWritePer1M?: number;\n /** Pricing snapshot version (date or tag) so stale entries are detectable. */\n version: string;\n /** F075 — a second set of rates for prompts LONGER than `aboveTokens` (input +\n * cache-read + cache-write). Claude Haiku 5.5 costs 5x above 100k tokens; one row\n * could only be right for one side of that line. */\n longPrompt?: { aboveTokens: number; inputPer1M: number; outputPer1M: number; cacheReadPer1M?: number; cacheWritePer1M?: number };\n}\n\n// USD per 1M tokens. Anthropic cache multipliers follow the standard model:\n// cache-read ≈ 0.1× input, cache-write ≈ 1.25× input. Verified against the\n// pricing tables in cms (packages/cms-ai/src/providers) + trail (model-lab).\n// MiniMax M2.7 is an estimate pending confirmation against OpenRouter's live\n// price page — flagged in its version string.\nconst V = \"2026-06-02\";\n// Mistral prices come straight from mistral.ai/pricing (per Christian's CD report).\nconst MS = \"2026-06-04-mistral.ai\";\n// Anthropic's own price page, read for F075.\nconst AN = \"2026-10-08-platform.claude.com\";\n\n/** Keyed `${provider}:${model}`. Exported so the catalogue-research job (F014)\n * can enumerate every priced entry and diff it against the live provider lists. */\nconst OAI = \"2026-10-11-developers.openai.com\";\n\nexport const PRICING: Record<string, PricingEntry> = {\n // Anthropic (direct API). DEFAULT_TIER_MAP: fast/cheap=haiku, smart/vision=sonnet, powerful=opus.\n // $1.00/$5.00 — Anthropic's published Haiku 4.5 rate, confirmed against the\n // claude-api skill's model table 2026-09-03. F048: this row said $0.80/$4.00 while\n // \"openrouter:anthropic/claude-haiku-4.5\" said $1.00/$5.00 — the SAME model at two\n // prices, and the shorter, likelier id carried the wrong one. A consumer pricing\n // 68M haiku tokens (upmetrics' real volume) was told 20% under.\n \"anthropic:claude-haiku-4-5\": {\n inputPer1M: 1.0,\n outputPer1M: 5.0,\n cacheReadPer1M: 0.1,\n cacheWritePer1M: 1.25,\n version: \"2026-09-03\",\n },\n \"anthropic:claude-sonnet-4-6\": {\n inputPer1M: 3.0,\n outputPer1M: 15.0,\n cacheReadPer1M: 0.3,\n cacheWritePer1M: 3.75,\n version: V,\n },\n // $5.00/$25.00 — Anthropic's published Opus 4.8 rate, confirmed against the\n // claude-api skill's model table 2026-09-03.\n //\n // FOUND BY THE CONTRADICTION GUARD ON ITS FIRST RUN, not by a report. This row said\n // $15.00/$75.00 while \"openrouter:anthropic/claude-opus-4.8\" said $5.00/$25.00 —\n // THREE TIMES too high, the opposite direction from the haiku error and a larger\n // multiple. Nobody had noticed, because both numbers looked like answers.\n \"anthropic:claude-opus-4-8\": {\n inputPer1M: 5.0,\n outputPer1M: 25.0,\n cacheReadPer1M: 0.5,\n cacheWritePer1M: 6.25,\n version: \"2026-09-03\",\n },\n\n // F075 — the rest of what Anthropic's /v1/models lists for our key, read 2026-10-08\n // from platform.claude.com/docs/en/about-claude/pricing. Cache-read is NOT 0.1x\n // everywhere: Opus/Sonnet 5.5 are 0.05x and Fable 5.1 is 0.025x. cacheWrite is the\n // 5-minute rate (the only one the SDK writes).\n \"anthropic:claude-fable-5-1\": { inputPer1M: 10, outputPer1M: 50, cacheReadPer1M: 0.25, cacheWritePer1M: 12.5, version: AN },\n \"anthropic:claude-fable-5\": { inputPer1M: 10, outputPer1M: 50, cacheReadPer1M: 1, cacheWritePer1M: 12.5, version: AN },\n \"anthropic:claude-opus-5-5\": { inputPer1M: 4, outputPer1M: 20, cacheReadPer1M: 0.2, cacheWritePer1M: 5, version: AN },\n \"anthropic:claude-opus-5\": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },\n \"anthropic:claude-opus-4-7\": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },\n \"anthropic:claude-opus-4-6\": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },\n \"anthropic:claude-opus-4-5\": { inputPer1M: 5, outputPer1M: 25, cacheReadPer1M: 0.5, cacheWritePer1M: 6.25, version: AN },\n \"anthropic:claude-sonnet-5-5\": { inputPer1M: 2, outputPer1M: 10, cacheReadPer1M: 0.1, cacheWritePer1M: 2.5, version: AN },\n \"anthropic:claude-sonnet-5\": { inputPer1M: 2, outputPer1M: 10, cacheReadPer1M: 0.2, cacheWritePer1M: 2.5, version: AN },\n \"anthropic:claude-sonnet-4-5\": { inputPer1M: 3, outputPer1M: 15, cacheReadPer1M: 0.3, cacheWritePer1M: 3.75, version: AN },\n \"anthropic:claude-haiku-5-5\": {\n inputPer1M: 0.1, outputPer1M: 0.5, cacheReadPer1M: 0.01, cacheWritePer1M: 0.125, version: AN,\n longPrompt: { aboveTokens: 100_000, inputPer1M: 0.5, outputPer1M: 2.5, cacheReadPer1M: 0.05, cacheWritePer1M: 0.625 },\n },\n\n // OpenAI. embedding default tier = text-embedding-3-small (no output tokens).\n // Cached input is 50% of the input rate — $1.25 vs $2.50 (gpt-4o) and $0.075 vs\n // $0.15 (gpt-4o-mini), read from developers.openai.com/api/docs/pricing on\n // 2026-08-27. NOTE IT IS 50%, NOT the 10% Mistral and Gemini charge: assuming one\n // uniform discount across providers would have understated OpenAI's cost by 4x on\n // the cached half. Caching is automatic above 1,024 tokens — no key, no opt-in.\n // The embedding models list NO cached price (embeddings do not cache), so they\n // deliberately get no row here rather than a guessed one.\n \"openai:text-embedding-3-small\": { inputPer1M: 0.02, outputPer1M: 0, version: V },\n \"openai:text-embedding-3-large\": { inputPer1M: 0.13, outputPer1M: 0, version: V },\n \"openai:gpt-4o\": { inputPer1M: 2.5, cacheReadPer1M: 1.25, outputPer1M: 10.0, version: \"2026-08-27-developers.openai.com\" },\n \"openai:gpt-4o-mini\": { inputPer1M: 0.15, cacheReadPer1M: 0.075, outputPer1M: 0.6, version: \"2026-08-27-developers.openai.com\" },\n // F022.6 — chat models offered to pickers. Official standard (non-batch, non-flex)\n // rates from developers.openai.com/api/docs/pricing, read 2026-10-11. Long context\n // = >272K input tokens, as the page states for every model that has one. Dated ids\n // (gpt-5.4-mini-2026-03-17) price through stripDatedSuffix.\n \"openai:gpt-5.4-nano\": { inputPer1M: 0.2, cacheReadPer1M: 0.02, outputPer1M: 1.25, version: OAI },\n \"openai:gpt-5.4-mini\": { inputPer1M: 0.75, cacheReadPer1M: 0.075, outputPer1M: 4.5, version: OAI },\n \"openai:gpt-5.5\": {\n inputPer1M: 5, cacheReadPer1M: 0.5, outputPer1M: 30, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 10, cacheReadPer1M: 1, outputPer1M: 45 },\n },\n \"openai:gpt-6-luna\": {\n inputPer1M: 0.1, cacheReadPer1M: 0.01, cacheWritePer1M: 0.125, outputPer1M: 0.5, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 0.2, cacheReadPer1M: 0.02, cacheWritePer1M: 0.25, outputPer1M: 0.75 },\n },\n \"openai:gpt-6-sol\": {\n inputPer1M: 2, cacheReadPer1M: 0.2, cacheWritePer1M: 2.5, outputPer1M: 10, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 4, cacheReadPer1M: 0.4, cacheWritePer1M: 5, outputPer1M: 15 },\n },\n \"openai:gpt-6.1-sol\": {\n inputPer1M: 2, cacheReadPer1M: 0.1, cacheWritePer1M: 2.5, outputPer1M: 10, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 4, cacheReadPer1M: 0.2, cacheWritePer1M: 5, outputPer1M: 15 },\n },\n \"openai:gpt-6-astra\": {\n inputPer1M: 10, cacheReadPer1M: 1, cacheWritePer1M: 12.5, outputPer1M: 50, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 20, cacheReadPer1M: 2, cacheWritePer1M: 25, outputPer1M: 75 },\n },\n \"openai:gpt-5.6-luna\": {\n inputPer1M: 0.2, cacheReadPer1M: 0.02, cacheWritePer1M: 0.25, outputPer1M: 1.2, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 0.4, cacheReadPer1M: 0.04, cacheWritePer1M: 0.5, outputPer1M: 1.8 },\n },\n \"openai:gpt-5.6-terra\": {\n inputPer1M: 2, cacheReadPer1M: 0.2, cacheWritePer1M: 2.5, outputPer1M: 12, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 4, cacheReadPer1M: 0.4, cacheWritePer1M: 5, outputPer1M: 18 },\n },\n \"openai:gpt-5.6-sol\": {\n inputPer1M: 4, cacheReadPer1M: 0.4, cacheWritePer1M: 5, outputPer1M: 20, version: OAI,\n longPrompt: { aboveTokens: 272_000, inputPer1M: 8, cacheReadPer1M: 0.8, cacheWritePer1M: 10, outputPer1M: 30 },\n },\n // Whisper is priced per MINUTE — see MEDIA_PRICING in ./media-pricing.ts. It used to\n // sit here as 0/0 \"so token-based compute never charges it\", and inwardly that worked.\n // Outwardly it did not: getModelPrice(\"whisper-1\") answered `{unit:\"per_1m_tokens\",\n // inputPer1M: 0}` — i.e. \"this model is free\" — because media rows are consulted LAST\n // and a token row was already there. The per-minute price was unreachable by its own\n // id. computeCost still returns 0 for it (no entry) and transcribe still computes its\n // own cost, so nothing about billing changed; only the public answer stopped lying.\n\n // OpenRouter (meta-router — model slugs include the upstream vendor). Slugs use\n // dots (claude-sonnet-4.6) to match OpenRouter's live ids; the dashed forms\n // never matched a real call. Caught by the F014 catalogue research.\n \"openrouter:anthropic/claude-sonnet-4.6\": { inputPer1M: 3.0, outputPer1M: 15.0, version: V },\n // OpenRouter ground-truth $1/$5 — a markup over Anthropic-direct's $0.8/$4\n // (the `anthropic:` entry above). Was masked while the slug used dashes.\n \"openrouter:anthropic/claude-haiku-4.5\": { inputPer1M: 1.0, outputPer1M: 5.0, version: \"2026-06-04\" },\n \"openrouter:google/gemini-2.5-flash\": { inputPer1M: 0.3, outputPer1M: 2.5, version: V },\n // Ground-truth from OpenRouter /api/v1/models, re-read 2026-10-20 (F067.7; was 0.21/0.84).\n \"openrouter:minimax/minimax-m2.7\": {\n inputPer1M: 0.3,\n outputPer1M: 1.2,\n version: \"2026-10-20-openrouter-live\",\n },\n // DeepSeek V4 (CN-hosted — NOT GDPR-safe; non-personal-data workloads only).\n // On 2026-05-22 DeepSeek made the \"75% off\" promo the permanent official price.\n // V4-Pro $0.435/$0.87 is ~34x cheaper than GPT-5.5 on output; flash is cheaper\n // still. Numbers match OpenRouter /api/v1/models 1:1 (no router markup). A strong\n // cheap route for fleet background work once `claude -p` is API-billed (15 Jun).\n // Re-read from OpenRouter /api/v1/models 2026-10-02 (F067.5). These moved three\n // times in a month (Sep 3: pro 1.02, Oct 1: flash 0.042, Oct 2: flash 0.028) — an\n // OpenRouter call books usage.cost from the response anyway; this row is the fallback.\n \"openrouter:deepseek/deepseek-v4-pro\": { inputPer1M: 0.2088, outputPer1M: 0.4176, version: \"2026-10-02-openrouter-live\" },\n // F067.7: flash re-read 2026-10-20 — rose from 0.028/0.056.\n \"openrouter:openai/gpt-6-astra\": { inputPer1M: 10, outputPer1M: 50, version: \"2026-11-05-openrouter-live\" },\n \"openrouter:openai/gpt-6.1-sol\": { inputPer1M: 2, outputPer1M: 10, version: \"2026-11-05-openrouter-live\" },\n \"openrouter:deepseek/deepseek-v4.1-flash-1017\": { inputPer1M: 0.15, outputPer1M: 0.6, version: \"2026-11-05-openrouter-live\" },\n \"openrouter:deepseek/deepseek-v4-flash\": { inputPer1M: 0.091, outputPer1M: 0.182, version: \"2026-10-20-openrouter-live\" },\n // DeepSeek DIRECT API (provider \"deepseek\", F030 non-PII secondary). Rates from\n // api-docs.deepseek.com 2026-06-30 ($0.14/$0.28 per 1M; both map to deepseek-v4-flash).\n // `deepseek-chat` (non-thinking) + `deepseek-reasoner` (thinking) DEPRECATE 2026-07-24.\n // (The bare `deepseek-v4-flash` basename is already priced via the openrouter entry\n // above — kept distinct here to avoid a basename collision in the F027 pricing-API.)\n // Verify against a real key when it lands.\n \"deepseek:deepseek-chat\": { inputPer1M: 0.14, outputPer1M: 0.28, version: \"2026-06-30-deepseek-direct\" },\n \"deepseek:deepseek-reasoner\": { inputPer1M: 0.14, outputPer1M: 0.28, version: \"2026-06-30-deepseek-direct\" },\n // F066 — TypeSafe Jev. docs.typesafe.ai/models, read 2026-10-01: \"$42 per billion\n // tokens (input only)\", output free. Priced on the VERSIONED id because the response\n // reports the model that actually ran (\"jev-1.13.0\") even when you ask for\n // \"jev-latest\" — so a future version arrives unpriced and is booked as such, rather\n // than inheriting a number nobody checked for it.\n \"typesafe:jev-1.13.0\": { inputPer1M: 0.042, outputPer1M: 0, version: \"2026-10-01-typesafe-official\" },\n // F081 — Microsoft-Decision-1, Azure retail prices API (prices.azure.com, read\n // 2026-10-26): ONE meter, \"Microsoft Decision 1 1M Tokens\" = $0.042, effective\n // 2026-10-01, same in swedencentral as everywhere. A single meter does not say output\n // is free, so output is priced at the same rate — at ~3 output tokens per call that\n // over-counts by a rounding error rather than risking an under-count.\n \"microsoft-decision:microsoft-decision-1-v1\": { inputPer1M: 0.042, outputPer1M: 0.042, version: \"2026-10-26-azure-retail\" },\n\n // Cached input tokens cost 10% of the input rate — $0.03 vs $0.30 (2.5-flash) and\n // $0.01 vs $0.10 (2.5-flash-lite), read from ai.google.dev/gemini-api/docs/pricing\n // on 2026-08-27 rather than recalled. NB the storage fee on that page ($1/1M\n // tokens/hour) applies to EXPLICIT context caching, where you create a CachedContent\n // object with a TTL. We use IMPLICIT caching, which has no storage charge — so this\n // table is not silently under-billing.\n // Google Gemini (direct). Provider key is \"gemini\" — matches the adapter's\n // usage.provider + the override.provider callers pass. (Image-gen models are\n // priced per-image in the adapter, not here.)\n \"gemini:gemini-2.5-flash\": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 2.5, version: \"2026-08-27-ai.google.dev\" },\n // flash-lite is the default `video` tier (F019) — cheap native video understanding.\n // F088 — measured 2026-11-05: reachable with our GEMINI_API_KEY; price = OpenRouter's\n // live google/gemini-4-argon row (passes Google's list price through).\n \"gemini:gemini-4-argon\": { inputPer1M: 2, outputPer1M: 10, version: \"2026-11-05-openrouter-live\" },\n \"gemini:gemini-2.5-flash-lite\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: \"2026-08-27-ai.google.dev\" },\n\n // Vertex AI (F038) — the EU-resident route to the SAME Gemini models, so Google's\n // published Gemini token prices apply. Listed separately because cost lookups key on\n // `provider:model`: without these rows an EU vision/video call would silently log\n // $0, which is worse than no tracking (a confident wrong number).\n \"vertex:gemini-2.5-flash\": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 2.5, version: \"2026-08-27-ai.google.dev\" },\n \"vertex:gemini-2.5-flash-lite\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: \"2026-08-27-ai.google.dev\" },\n\n // Cached prompt tokens bill at 10% of the input rate (F039, measured 2026-08-27:\n // an 8,810-token prefix reported 8,784 cached on the second call WITH a\n // prompt_cache_key, and 0 without one at every size up to 57k).\n // Mistral (direct, La Plateforme). Official prices from mistral.ai/pricing\n // (2026-06-04, per Christian's CD report). EU/Paris-hosted — the designated\n // GDPR-safe provider for client/personal-data workloads (see F015). NB:\n // medium-3.5 is the premium \"Vibe\" coding tier ($1.5/$7.5); Large 3 ($0.5/$1.5)\n // is the cheaper frontier general-purpose model despite the higher number.\n \"mistral:mistral-large-latest\": { inputPer1M: 0.5, cacheReadPer1M: 0.05, outputPer1M: 1.5, version: MS },\n \"mistral:mistral-large-2512\": { inputPer1M: 0.5, cacheReadPer1M: 0.05, outputPer1M: 1.5, version: MS },\n // Large 4 (F074.1), measured 2026-10-08 on docs.mistral.ai/models/mistral-large-4:\n // LIST price. The page also shows a 50% \"Public Preview\" sale ($0.68/$0.07/$2.09)\n // with no end date; booking the sale would under-report the day it ends, unseen.\n // Cached input shows as \"$0.14\": that is 10% of $1.36 rounded to cents (the sale's\n // \"$0.07\" is 0.068 the same way), and 10% is the rate measured for Mistral (F039).\n // F085.1 — Mistral News 29/10 2026 («Le Chonk»): \"Starting today, Mistral Large 4 is priced at\n // $0.70 input / M, $0.07 cached input / M, and $2.10 output / M tokens.\" Was 1.36/4.18 (8/10).\n \"mistral:mistral-large-4\": { inputPer1M: 0.7, cacheReadPer1M: 0.07, outputPer1M: 2.1, version: \"2026-10-29-mistral-news-mail\" },\n \"mistral:mistral-large-4-0\": { inputPer1M: 0.7, cacheReadPer1M: 0.07, outputPer1M: 2.1, version: \"2026-10-29-mistral-news-mail\" },\n \"mistral:mistral-medium-latest\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: MS },\n \"mistral:mistral-medium-3.5\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: MS },\n // F076.2 — Mistral's model API now lists mistral-medium-3 as an alias of Medium 3.5\n // (measured 2026-10-08), so it bills at 3.5's price, not Medium 3's $0.40/$2.00.\n \"mistral:mistral-medium-3\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n // F076.1 — Small 4 (2603) is $0.15/$0.60, measured 2026-10-08 on\n // docs.mistral.ai/models/mistral-small-4-0-26-03 AND OpenRouter's mistral-small-2603.\n // This row said $0.10/$0.30 (Small 3's price, carried over when -latest moved to\n // 2603), so the fleet's fast/cheap tiers were booked at about half their cost.\n \"mistral:mistral-small-latest\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-small-2603\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:ministral-3b-latest\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.1, version: MS },\n \"mistral:ministral-8b-latest\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.15, version: MS },\n \"mistral:ministral-14b-latest\": { inputPer1M: 0.2, cacheReadPer1M: 0.02, outputPer1M: 0.2, version: MS },\n // F076.2 — both Magistral aliases now point at the unified models (measured\n // 2026-10-08 via /v1/models): magistral-medium-latest → Medium 3.5, magistral-small-\n // latest → Small 4. They bill at those models' prices, not the old Magistral rates.\n \"mistral:magistral-medium-latest\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:magistral-small-latest\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: \"2026-10-08-docs.mistral.ai\" },\n // F076.2 — ids Mistral's model API lists for our key that had no row (a call to any\n // of them was booked at $0). Prices from docs.mistral.ai, 2026-10-08; cache-read at\n // the measured 10% (F039).\n \"mistral:mistral-vibe-cli-fast\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.6, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-medium-3-5\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-medium\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-medium-2604\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-vibe-cli-latest\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-vibe-cli-with-tools\": { inputPer1M: 1.5, cacheReadPer1M: 0.15, outputPer1M: 7.5, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:ministral-14b-2512\": { inputPer1M: 0.2, cacheReadPer1M: 0.02, outputPer1M: 0.2, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:ministral-8b-2512\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.15, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:ministral-3b-2512\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.1, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:voxtral-small-2507\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:voxtral-small-latest\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0.4, version: \"2026-10-08-docs.mistral.ai\" },\n // F085.4 — Z.ai GLM 5.3 served by Mistral. Mistral deprecation mail 2026-10-30: \"$1.4 per 1M\n // input tokens, $0.14 per 1M cached input tokens, and $4.4 per 1M output tokens\". Aliases per\n // /v1/models (measured 30/10): zai-glm-5, zai-glm-latest → zai-glm-5-3.\n \"mistral:zai-glm-5-3\": { inputPer1M: 1.4, cacheReadPer1M: 0.14, outputPer1M: 4.4, version: \"2026-10-30-mistral-deprecation-mail\" },\n \"mistral:zai-glm-5\": { inputPer1M: 1.4, cacheReadPer1M: 0.14, outputPer1M: 4.4, version: \"2026-10-30-mistral-deprecation-mail\" },\n \"mistral:zai-glm-latest\": { inputPer1M: 1.4, cacheReadPer1M: 0.14, outputPer1M: 4.4, version: \"2026-10-30-mistral-deprecation-mail\" },\n \"mistral:codestral-2508\": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-code-latest\": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:mistral-code-fim-latest\": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: \"2026-10-08-docs.mistral.ai\" },\n \"mistral:devstral-latest\": { inputPer1M: 0.4, cacheReadPer1M: 0.04, outputPer1M: 2.0, version: MS },\n \"mistral:codestral-latest\": { inputPer1M: 0.3, cacheReadPer1M: 0.03, outputPer1M: 0.9, version: MS },\n \"mistral:open-mistral-nemo\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0.15, version: MS },\n // Moderation (F016.4) — per input token; output 0. (OCR is per-page in the adapter.)\n \"mistral:mistral-moderation-latest\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0, version: MS },\n \"mistral:mistral-moderation-2603\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0, version: MS }, // F077.4 pinned default\n // Embeddings (F016.5) — per input token.\n \"mistral:mistral-embed\": { inputPer1M: 0.1, cacheReadPer1M: 0.01, outputPer1M: 0, version: MS },\n \"mistral:codestral-embed\": { inputPer1M: 0.15, cacheReadPer1M: 0.015, outputPer1M: 0, version: MS },\n // F048 — reported by upmetrics as an unknown model (6 calls). Official mistral.ai/pricing.\n \"mistral:pixtral-large-latest\": { inputPer1M: 2.0, cacheReadPer1M: 0.2, outputPer1M: 6.0, version: \"2026-09-03\" },\n};\n\n/** Strip a provider's dated snapshot suffix: \"claude-haiku-4-5-20251001\" → \"claude-haiku-4-5\".\n * Returns the input unchanged when there is no suffix.\n *\n * ONE definition, used by BOTH lookups. F012 taught this rule to `getPrice` — the\n * internal cost path — and the exported catalogue never learned it, so for two years\n * `usage.costUsd` priced a dated id correctly while `getModelPrice` returned undefined\n * for the same string. Found by upmetrics, who use the catalogue and not our internals:\n * 19,456 calls of `claude-haiku-4-5-20251001` looked like an unknown model. Fixing the\n * instance and not the class is the shape; a copy of this regex in the other lookup\n * would have been the same mistake a third time. */\nexport function stripDatedSuffix(model: string): string {\n // Anthropic dates as -YYYYMMDD; OpenAI as -YYYY-MM-DD (F022.6).\n return model.replace(/-(\\d{8}|\\d{4}-\\d{2}-\\d{2})$/, \"\");\n}\n\nexport function getPrice(provider: string, model: string): PricingEntry | undefined {\n const exact = PRICING[`${provider}:${model}`];\n if (exact) return exact;\n // A real paid call must never be logged as $0 (F012).\n const base = stripDatedSuffix(model);\n if (base !== model) return PRICING[`${provider}:${base}`];\n return undefined;\n}\n"],"mappings":";AAyBA,IAAM,IAAI;AAEV,IAAM,KAAK;AAEX,IAAM,KAAK;AAIX,IAAM,MAAM;AAEL,IAAM,UAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnD,8BAA8B;AAAA,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a;AAClH;AAYO,SAAS,iBAAiB,OAAuB;AAEtD,SAAO,MAAM,QAAQ,+BAA+B,EAAE;AACxD;AAEO,SAAS,SAAS,UAAkB,OAAyC;AAClF,QAAM,QAAQ,QAAQ,GAAG,QAAQ,IAAI,KAAK,EAAE;AAC5C,MAAI,MAAO,QAAO;AAElB,QAAM,OAAO,iBAAiB,KAAK;AACnC,MAAI,SAAS,MAAO,QAAO,QAAQ,GAAG,QAAQ,IAAI,IAAI,EAAE;AACxD,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPrice
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6O6HO7M3.js";
|
|
4
4
|
|
|
5
5
|
// src/routing/tier-map.ts
|
|
6
6
|
var DEFAULT_TIER_MAP = {
|
|
@@ -306,4 +306,4 @@ export {
|
|
|
306
306
|
resolveModel,
|
|
307
307
|
describeTier
|
|
308
308
|
};
|
|
309
|
-
//# sourceMappingURL=chunk-
|
|
309
|
+
//# sourceMappingURL=chunk-KCHMZ6P5.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PRICING,
|
|
3
3
|
stripDatedSuffix
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6O6HO7M3.js";
|
|
5
5
|
|
|
6
6
|
// src/cost/media-pricing.ts
|
|
7
7
|
var MEDIA_PRICING_CHECKED_AT = "2026-10-11";
|
|
@@ -459,4 +459,4 @@ export {
|
|
|
459
459
|
resetPricingWarningForTests,
|
|
460
460
|
cheapestModels
|
|
461
461
|
};
|
|
462
|
-
//# sourceMappingURL=chunk-
|
|
462
|
+
//# sourceMappingURL=chunk-ZL6TFGZ2.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,68 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as Usage, C as CostSink, T as Tier, a as ChatResult, b as ChatStreamEvent, c as TranslateResult, I as ImageResult, A as AnimateResult, d as TrainStyleResult, E as EmbeddingResult, e as TranscribeResult, O as OcrResult, M as ModerationResult, J as JudgeResult, V as VectorizeResult, P as PodcastResult, B as BatchRequestItem, f as TierSpec, g as BatchJob, h as BatchResultItem, i as ProviderAdapter, j as ToolCall, k as Tool, l as Transport, m as Capability, R as Region, n as BudgetConfig, o as BudgetStore } from './registry-CCKJyveA.js';
|
|
2
2
|
export { p as AlignedWordTimings, q as AvailabilitySource, r as AvailabilityStatus, s as AzureWordBoundary, t as CallOptions, u as ChatRequest, v as ContentPart, D as DialogueRequest, w as DialogueTurn, x as EmbeddingRequest, y as ImageRequest, z as JudgeAnswer, F as JudgeChoiceAnswer, G as JudgeNoulAnswer, H as JudgeQuestion, K as JudgeScoreAnswer, L as LoraWeight, N as Message, Q as ModelStatus, S as ModelUnavailableError, W as ModerationItem, X as ModerationRequest, Y as OcrPage, Z as OcrRequest, _ as ResolveOptions, $ as ResolveResult, a0 as Role, a1 as TierDescription, a2 as TrainStyleRequest, a3 as TranscribeRequest, a4 as TtsRequest, a5 as WordTiming, a6 as alignWordTimings, a7 as classifyRegionName, a8 as describeTier, a9 as listModels, aa as regionOfHost, ab as regionOfProvider, ac as resolveModel } from './registry-CCKJyveA.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
export { CheapestQuery, CheapestResult, CheapestRow, DEFAULT_CLIP_SEC, MEDIA_PRICING_CHECKED_AT, MediaPrice, MediaUnit, PRICING_STALE_AFTER_DAYS, PriceKind, PricingFreshness, UnitFreshness, UpstreamStatus, cheapestModels, classifyKind, getMediaPrice, listMediaPrices, pricingFreshness, pricingGeneratedAt } from './pricing.js';
|
|
5
5
|
|
|
6
|
+
interface PanelMember {
|
|
7
|
+
label: string;
|
|
8
|
+
provider: string;
|
|
9
|
+
model: string;
|
|
10
|
+
}
|
|
11
|
+
/** Measured reachable with our keys 2026-11-05. Four of five are US/CN — hence the
|
|
12
|
+
* confirmNoPersonalData gate. DeepSeek goes via OpenRouter (no direct key here); so
|
|
13
|
+
* does GPT-6.1 Sol (owner chose it over Astra 2026-11-05 — 5x cheaper), because the direct OpenAI account answered 429 "no credits
|
|
14
|
+
* remaining" on 2026-11-05 — same model and list price on OpenRouter. */
|
|
15
|
+
declare const SECOND_OPINION_PANEL: readonly PanelMember[];
|
|
16
|
+
/** The synthesis step — EU. Large 4, not Large 3: the first live run (2026-11-05) had
|
|
17
|
+
* three of four reviewers call Large 3 too weak to condense five frontier answers,
|
|
18
|
+
* and it answered in English for a Danish plan. ~$0.01 a run. */
|
|
19
|
+
declare const SECOND_OPINION_SYNTH: PanelMember;
|
|
20
|
+
declare const SECOND_OPINION_INSTRUCTION: string;
|
|
21
|
+
declare const SECOND_OPINION_SYNTH_INSTRUCTION: string;
|
|
22
|
+
interface SecondOpinionInput {
|
|
23
|
+
content: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Extra steering, e.g. "focus on security and cost". */
|
|
26
|
+
focus?: string;
|
|
27
|
+
panel?: readonly PanelMember[];
|
|
28
|
+
/** Condense the reviews with SECOND_OPINION_SYNTH. Default FALSE — owner 2026-11-05
|
|
29
|
+
* answered "No" to a Mistral summary; the report carries the five reviews as-is. */
|
|
30
|
+
synthesize?: boolean;
|
|
31
|
+
maxTokens?: number;
|
|
32
|
+
/** USD→DKK rate for the price line. Omitted: the ECB reference rate is fetched. */
|
|
33
|
+
usdToDkk?: number;
|
|
34
|
+
/** Language of every review and the summary. Default "Danish" — the owner reads them. */
|
|
35
|
+
language?: string;
|
|
36
|
+
/** REQUIRED true: four of five panel models are US/CN-hosted. */
|
|
37
|
+
confirmNoPersonalData?: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface Opinion extends PanelMember {
|
|
40
|
+
text?: string;
|
|
41
|
+
error?: string;
|
|
42
|
+
usage?: Usage;
|
|
43
|
+
}
|
|
44
|
+
interface ReportCost {
|
|
45
|
+
usd: number;
|
|
46
|
+
dkk: number;
|
|
47
|
+
usdToDkk: number;
|
|
48
|
+
/** "ecb" = fetched ECB reference rate · "given" = caller's rate · "fallback" = fixed rate, fetch failed. */
|
|
49
|
+
rateSource: "ecb" | "given" | "fallback";
|
|
50
|
+
/** Date the rate applies to (YYYY-MM-DD). */
|
|
51
|
+
rateDate: string;
|
|
52
|
+
}
|
|
53
|
+
interface SecondOpinionResult {
|
|
54
|
+
opinions: Opinion[];
|
|
55
|
+
synthesis?: {
|
|
56
|
+
text?: string;
|
|
57
|
+
error?: string;
|
|
58
|
+
usage?: Usage;
|
|
59
|
+
};
|
|
60
|
+
totalCostUsd: number;
|
|
61
|
+
/** What the report cost, in USD and DKK — always present (owner, 2026-11-05). */
|
|
62
|
+
cost: ReportCost;
|
|
63
|
+
markdown: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
6
66
|
/** `tavily` is CMS-legacy only (F078.5): reachable by explicit provider, never routed to. */
|
|
7
67
|
type SearchProviderId = "brave" | "cloudflare:ceramic" | "cloudflare:linkup" | "cloudflare:exa" | "tavily";
|
|
8
68
|
/** Why the search runs — picks the route and the cache lifetime (F078.2). */
|
|
@@ -1137,6 +1197,9 @@ interface AiClient {
|
|
|
1137
1197
|
};
|
|
1138
1198
|
/** Prompt-contract capabilities (F5.5) layered on chat/vision. */
|
|
1139
1199
|
contracts: Contracts;
|
|
1200
|
+
/** F088 — five frontier models review the same material blind; one EU model condenses
|
|
1201
|
+
* them. Four of five are US/CN: requires confirmNoPersonalData:true. */
|
|
1202
|
+
secondOpinion(input: SecondOpinionInput): Promise<SecondOpinionResult>;
|
|
1140
1203
|
}
|
|
1141
1204
|
|
|
1142
1205
|
declare function createAI(config?: AiConfig): AiClient;
|
|
@@ -1499,8 +1562,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
1499
1562
|
* wires the live adapters. */
|
|
1500
1563
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
1501
1564
|
|
|
1502
|
-
declare const VERSION: "0.
|
|
1503
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.
|
|
1565
|
+
declare const VERSION: "0.71.0";
|
|
1566
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.71.0";
|
|
1504
1567
|
|
|
1505
1568
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
1506
1569
|
* per-call override.
|
|
@@ -2067,4 +2130,4 @@ declare function memorySearchCache(max?: number): SearchCache;
|
|
|
2067
2130
|
|
|
2068
2131
|
declare function search(req: SearchRequest, opts?: SearchOptions): Promise<SearchResult>;
|
|
2069
2132
|
|
|
2070
|
-
export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, BatchJob, BatchRequestItem, BatchResultItem, type BflAdapterConfig, type BflCredits, BudgetConfig, BudgetExceededError, BudgetGuard, BudgetStore, CONFIG_DERIVED_HOSTS, Capability, type ChatInput, ChatResult, ChatStreamEvent, type CheckVoiceOptions, type ClassifyInput, type ClassifyResult, type Contracts, type CostQuery, CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_BASE_URLS, DEFAULT_SEARCH_ROUTES, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type FixedHostProvider, type HttpResponse, INPUT_LIMITS, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, MICROSOFT_DECISION_DEFAULT_DEPLOYMENT, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, type PodcastInput, PodcastResult, type PriceDriftResult, type PriceDriftRow, type PricingEntry, ProviderAdapter, type RefreshOptions, type RefreshResult, Region, type RerankInput, type RerankResult, type RouteForecast, SDK_TAG, SEARCH_CACHE_TTL_MS, SEARCH_PRICE_USD, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, Tier, TierSpec, Tool, ToolCall, type TrainStyleInput, TrainStyleResult, type TranscribeInput, TranscribeResult, type TranslateInput, TranslateResult, Transport, type TransportRequest, type TransportResponse, type TtsInput, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSink, type UpmetricsSinkConfig, type UpmetricsSinkStats, Usage, VERSION, type VideoInput, type VisionInput, type VoiceInfo, type VoiceProvider, type VoiceResolveResult, type VoiceStatus, VoiceUnavailableError, type WebSearchContext, type WebSearchToolResult, ZDR_PROVIDERS, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, byokAdapter, chatInputSchema, checkPriceDrift, checkVoice, computeCost, createAI, deepinfraAdapter, deeplAdapter, deepseekAdapter, defaultBaseUrl, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, isByokKeyed, listAzureDanishVoices, listVoices, makeContracts, makeOpenAICompatibleAdapter, matchLabel, memorySearchCache, messageSchema, microsoftDecisionAdapter, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, recraftAdapter, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, routeSearch, runWebSearch, search, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, typesafeAdapter, upmetricsCostClient, upmetricsSink, usdFromMicro, vertexAdapter, visionInputSchema, webSearchTool, wouldProviderRouteTo, wouldRouteTo };
|
|
2133
|
+
export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, BatchJob, BatchRequestItem, BatchResultItem, type BflAdapterConfig, type BflCredits, BudgetConfig, BudgetExceededError, BudgetGuard, BudgetStore, CONFIG_DERIVED_HOSTS, Capability, type ChatInput, ChatResult, ChatStreamEvent, type CheckVoiceOptions, type ClassifyInput, type ClassifyResult, type Contracts, type CostQuery, CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_BASE_URLS, DEFAULT_SEARCH_ROUTES, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type FixedHostProvider, type HttpResponse, INPUT_LIMITS, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, MICROSOFT_DECISION_DEFAULT_DEPLOYMENT, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, type Opinion, type PanelMember, type PodcastInput, PodcastResult, type PriceDriftResult, type PriceDriftRow, type PricingEntry, ProviderAdapter, type RefreshOptions, type RefreshResult, Region, type RerankInput, type RerankResult, type RouteForecast, SDK_TAG, SEARCH_CACHE_TTL_MS, SEARCH_PRICE_USD, SECOND_OPINION_INSTRUCTION, SECOND_OPINION_PANEL, SECOND_OPINION_SYNTH, SECOND_OPINION_SYNTH_INSTRUCTION, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, type SecondOpinionInput, type SecondOpinionResult, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, Tier, TierSpec, Tool, ToolCall, type TrainStyleInput, TrainStyleResult, type TranscribeInput, TranscribeResult, type TranslateInput, TranslateResult, Transport, type TransportRequest, type TransportResponse, type TtsInput, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSink, type UpmetricsSinkConfig, type UpmetricsSinkStats, Usage, VERSION, type VideoInput, type VisionInput, type VoiceInfo, type VoiceProvider, type VoiceResolveResult, type VoiceStatus, VoiceUnavailableError, type WebSearchContext, type WebSearchToolResult, ZDR_PROVIDERS, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, byokAdapter, chatInputSchema, checkPriceDrift, checkVoice, computeCost, createAI, deepinfraAdapter, deeplAdapter, deepseekAdapter, defaultBaseUrl, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, isByokKeyed, listAzureDanishVoices, listVoices, makeContracts, makeOpenAICompatibleAdapter, matchLabel, memorySearchCache, messageSchema, microsoftDecisionAdapter, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, recraftAdapter, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, routeSearch, runWebSearch, search, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, typesafeAdapter, upmetricsCostClient, upmetricsSink, usdFromMicro, vertexAdapter, visionInputSchema, webSearchTool, wouldProviderRouteTo, wouldRouteTo };
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
resolveModel,
|
|
12
12
|
resolveTier,
|
|
13
13
|
setAvailability
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KCHMZ6P5.js";
|
|
15
15
|
import {
|
|
16
16
|
DEFAULT_CLIP_SEC,
|
|
17
17
|
MEDIA_PRICING,
|
|
@@ -23,11 +23,11 @@ import {
|
|
|
23
23
|
listMediaPrices,
|
|
24
24
|
pricingFreshness,
|
|
25
25
|
pricingGeneratedAt
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZL6TFGZ2.js";
|
|
27
27
|
import {
|
|
28
28
|
PRICING,
|
|
29
29
|
getPrice
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-6O6HO7M3.js";
|
|
31
31
|
|
|
32
32
|
// src/search/brave.ts
|
|
33
33
|
async function braveSearch(req, apiKey, f) {
|
|
@@ -264,14 +264,14 @@ var sharedCapStore = /* @__PURE__ */ (() => {
|
|
|
264
264
|
const m = /* @__PURE__ */ new Map();
|
|
265
265
|
return {
|
|
266
266
|
// Synchronous, so check-and-add cannot interleave with another call.
|
|
267
|
-
reserve: (k,
|
|
267
|
+
reserve: (k, usd2, cap) => {
|
|
268
268
|
const s = m.get(k) ?? 0;
|
|
269
|
-
if (s +
|
|
270
|
-
m.set(k, s +
|
|
269
|
+
if (s + usd2 > cap) return false;
|
|
270
|
+
m.set(k, s + usd2);
|
|
271
271
|
return true;
|
|
272
272
|
},
|
|
273
|
-
release: (k,
|
|
274
|
-
m.set(k, (m.get(k) ?? 0) -
|
|
273
|
+
release: (k, usd2) => {
|
|
274
|
+
m.set(k, (m.get(k) ?? 0) - usd2);
|
|
275
275
|
},
|
|
276
276
|
getSpent: (k) => m.get(k) ?? 0
|
|
277
277
|
};
|
|
@@ -3527,8 +3527,8 @@ var InMemoryBudgetStore = class {
|
|
|
3527
3527
|
getSpent() {
|
|
3528
3528
|
return this.spentUsd;
|
|
3529
3529
|
}
|
|
3530
|
-
addSpent(
|
|
3531
|
-
this.spentUsd +=
|
|
3530
|
+
addSpent(usd2) {
|
|
3531
|
+
this.spentUsd += usd2;
|
|
3532
3532
|
}
|
|
3533
3533
|
};
|
|
3534
3534
|
var BudgetExceededError = class extends Error {
|
|
@@ -3795,6 +3795,173 @@ ${JSON.stringify(input.items)}`,
|
|
|
3795
3795
|
};
|
|
3796
3796
|
}
|
|
3797
3797
|
|
|
3798
|
+
// src/capabilities/second-opinion.ts
|
|
3799
|
+
var SECOND_OPINION_PANEL = [
|
|
3800
|
+
{ label: "Anthropic Opus 5.5", provider: "anthropic", model: "claude-opus-5-5" },
|
|
3801
|
+
{ label: "OpenAI GPT-6.1 Sol", provider: "openrouter", model: "openai/gpt-6.1-sol" },
|
|
3802
|
+
{ label: "Google Gemini 4 Argon", provider: "gemini", model: "gemini-4-argon" },
|
|
3803
|
+
{ label: "Mistral Large 4", provider: "mistral", model: "mistral-large-4-0" },
|
|
3804
|
+
{ label: "DeepSeek V4.1 Flash 1017", provider: "openrouter", model: "deepseek/deepseek-v4.1-flash-1017" }
|
|
3805
|
+
];
|
|
3806
|
+
var SECOND_OPINION_SYNTH = {
|
|
3807
|
+
label: "Opsummering (Mistral Large 4)",
|
|
3808
|
+
provider: "mistral",
|
|
3809
|
+
model: "mistral-large-4-0"
|
|
3810
|
+
};
|
|
3811
|
+
var SECOND_OPINION_INSTRUCTION = [
|
|
3812
|
+
"You are an independent senior reviewer. You will receive a piece of material \u2014 a plan,",
|
|
3813
|
+
"an SDK or API design, a specification, or similar. You do not know who wrote it, and",
|
|
3814
|
+
"you have no stake in it.",
|
|
3815
|
+
"",
|
|
3816
|
+
"Give your impartial, qualitative and constructive assessment:",
|
|
3817
|
+
"1. Overall verdict in two or three sentences.",
|
|
3818
|
+
"2. Strengths \u2014 what is genuinely good and should be kept.",
|
|
3819
|
+
"3. Weaknesses and risks \u2014 gaps, wrong assumptions, missing pieces, things that will",
|
|
3820
|
+
" break or cost more than expected. Be specific; quote or point to the part you mean.",
|
|
3821
|
+
"4. Concrete suggestions for improvement, ordered by impact.",
|
|
3822
|
+
"5. Open questions you would ask the author before approving it.",
|
|
3823
|
+
"",
|
|
3824
|
+
"Be direct. Do not flatter, and do not invent problems to look thorough. If something",
|
|
3825
|
+
"is fine, say so briefly."
|
|
3826
|
+
].join("\n");
|
|
3827
|
+
var SECOND_OPINION_SYNTH_INSTRUCTION = [
|
|
3828
|
+
"You receive several independent reviews of the same material, each labelled with the",
|
|
3829
|
+
"model that wrote it. Condense them for a busy decision-maker:",
|
|
3830
|
+
"1. Consensus \u2014 points most reviewers agree on.",
|
|
3831
|
+
"2. Disagreements \u2014 where reviewers contradict each other, and who said what.",
|
|
3832
|
+
"3. The most important improvements, ranked, merged where reviewers overlap.",
|
|
3833
|
+
"4. Unique catches \u2014 a valuable point only one reviewer raised (name the reviewer).",
|
|
3834
|
+
"Do not add opinions of your own."
|
|
3835
|
+
].join("\n");
|
|
3836
|
+
var USD_DKK_RATE_URL = "https://api.frankfurter.dev/v1/latest?from=USD&to=DKK";
|
|
3837
|
+
var FALLBACK_USD_DKK = { rate: 6.6334, date: "2026-11-04" };
|
|
3838
|
+
async function getUsdToDkk(fetchImpl = fetch) {
|
|
3839
|
+
try {
|
|
3840
|
+
const res = await fetchImpl(USD_DKK_RATE_URL, { signal: AbortSignal.timeout(5e3) });
|
|
3841
|
+
if (!res.ok) throw new Error(`rate ${res.status}`);
|
|
3842
|
+
const data = await res.json();
|
|
3843
|
+
const rate = data.rates?.DKK;
|
|
3844
|
+
if (typeof rate !== "number" || !(rate > 0)) throw new Error("rate missing in response");
|
|
3845
|
+
return { rate, date: data.date ?? "", source: "ecb" };
|
|
3846
|
+
} catch {
|
|
3847
|
+
return { rate: FALLBACK_USD_DKK.rate, date: FALLBACK_USD_DKK.date, source: "fallback" };
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
var DEFAULT_MAX_TOKENS = 12e3;
|
|
3851
|
+
function override(m) {
|
|
3852
|
+
return { provider: m.provider, model: m.model, transport: "http" };
|
|
3853
|
+
}
|
|
3854
|
+
var SECRET_PATTERNS = [
|
|
3855
|
+
["private key", /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
|
|
3856
|
+
["OpenAI/Anthropic-style key", /\bsk-[A-Za-z0-9_-]{20,}/],
|
|
3857
|
+
["AWS access key", /\bAKIA[0-9A-Z]{16}\b/],
|
|
3858
|
+
["GitHub token", /\bgh[pousr]_[A-Za-z0-9]{30,}/],
|
|
3859
|
+
["Google API key", /\bAIza[0-9A-Za-z_-]{35}\b/],
|
|
3860
|
+
["Slack token", /\bxox[abprs]-[A-Za-z0-9-]{10,}/]
|
|
3861
|
+
];
|
|
3862
|
+
function findSecretKinds(text) {
|
|
3863
|
+
return SECRET_PATTERNS.filter(([, re]) => re.test(text)).map(([kind]) => kind);
|
|
3864
|
+
}
|
|
3865
|
+
function errText(e) {
|
|
3866
|
+
return e instanceof Error ? e.message : String(e);
|
|
3867
|
+
}
|
|
3868
|
+
async function runSecondOpinion(ai, input) {
|
|
3869
|
+
if (input.confirmNoPersonalData !== true) {
|
|
3870
|
+
throw new Error(
|
|
3871
|
+
"ai.secondOpinion: pass confirmNoPersonalData:true \u2014 four of the five panel models are US/CN-hosted, so the material must contain no personal, customer or health data. Nothing was sent."
|
|
3872
|
+
);
|
|
3873
|
+
}
|
|
3874
|
+
if (!input.content.trim()) throw new Error("ai.secondOpinion: content is empty");
|
|
3875
|
+
const secrets = findSecretKinds(input.content);
|
|
3876
|
+
if (secrets.length) {
|
|
3877
|
+
throw new Error(`ai.secondOpinion: the material looks like it contains a credential (${secrets.join(", ")}). Remove it first. Nothing was sent.`);
|
|
3878
|
+
}
|
|
3879
|
+
const lang = `
|
|
3880
|
+
|
|
3881
|
+
Write your entire answer in ${input.language ?? "Danish"}.`;
|
|
3882
|
+
const panel = input.panel ?? SECOND_OPINION_PANEL;
|
|
3883
|
+
if (panel.length === 0) throw new Error("ai.secondOpinion: panel is empty");
|
|
3884
|
+
const maxTokens = input.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
3885
|
+
const prompt = [
|
|
3886
|
+
input.title ? `Title: ${input.title}` : "",
|
|
3887
|
+
input.focus ? `Reviewer focus requested: ${input.focus}` : "",
|
|
3888
|
+
"Material to review:",
|
|
3889
|
+
"<material>",
|
|
3890
|
+
input.content,
|
|
3891
|
+
"</material>"
|
|
3892
|
+
].filter(Boolean).join("\n");
|
|
3893
|
+
const opinions = await Promise.all(
|
|
3894
|
+
panel.map(async (m) => {
|
|
3895
|
+
try {
|
|
3896
|
+
const r = await ai.chat({
|
|
3897
|
+
system: SECOND_OPINION_INSTRUCTION + lang,
|
|
3898
|
+
prompt,
|
|
3899
|
+
maxTokens,
|
|
3900
|
+
override: override(m),
|
|
3901
|
+
purpose: "second-opinion"
|
|
3902
|
+
});
|
|
3903
|
+
return { ...m, text: r.text, usage: r.usage };
|
|
3904
|
+
} catch (e) {
|
|
3905
|
+
return { ...m, error: errText(e) };
|
|
3906
|
+
}
|
|
3907
|
+
})
|
|
3908
|
+
);
|
|
3909
|
+
let synthesis;
|
|
3910
|
+
const answered = opinions.filter((o) => o.text);
|
|
3911
|
+
if (input.synthesize === true && answered.length > 0) {
|
|
3912
|
+
const reviews = answered.map((o) => `<review by="${o.label}">
|
|
3913
|
+
${o.text}
|
|
3914
|
+
</review>`).join("\n\n");
|
|
3915
|
+
try {
|
|
3916
|
+
const r = await ai.chat({
|
|
3917
|
+
system: SECOND_OPINION_SYNTH_INSTRUCTION + lang,
|
|
3918
|
+
prompt: reviews,
|
|
3919
|
+
maxTokens: 6e3,
|
|
3920
|
+
override: override(SECOND_OPINION_SYNTH),
|
|
3921
|
+
purpose: "second-opinion-synthesis"
|
|
3922
|
+
});
|
|
3923
|
+
synthesis = { text: r.text, usage: r.usage };
|
|
3924
|
+
} catch (e) {
|
|
3925
|
+
synthesis = { error: errText(e) };
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
const totalCostUsd = opinions.reduce((n, o) => n + (o.usage?.costUsd ?? 0), 0) + (synthesis?.usage?.costUsd ?? 0);
|
|
3929
|
+
const fx = input.usdToDkk ? { rate: input.usdToDkk, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), source: "given" } : await getUsdToDkk();
|
|
3930
|
+
const cost = {
|
|
3931
|
+
usd: totalCostUsd,
|
|
3932
|
+
dkk: totalCostUsd * fx.rate,
|
|
3933
|
+
usdToDkk: fx.rate,
|
|
3934
|
+
rateSource: fx.source,
|
|
3935
|
+
rateDate: fx.date
|
|
3936
|
+
};
|
|
3937
|
+
return { opinions, synthesis, totalCostUsd, cost, markdown: toMarkdown(input, opinions, synthesis, cost) };
|
|
3938
|
+
}
|
|
3939
|
+
function usd(n) {
|
|
3940
|
+
return n == null ? "\u2014" : `$${n.toFixed(4)}`;
|
|
3941
|
+
}
|
|
3942
|
+
function toMarkdown(input, opinions, synthesis, cost) {
|
|
3943
|
+
const lines = [];
|
|
3944
|
+
lines.push(`# Second opinion${input.title ? ` \u2014 ${input.title}` : ""}`, "");
|
|
3945
|
+
lines.push("| Model | Region | Pris | Status |", "|---|---|---|---|");
|
|
3946
|
+
for (const o of opinions) {
|
|
3947
|
+
lines.push(`| ${o.label} (\`${o.model}\`) | ${o.usage?.region ?? "\u2014"} | ${usd(o.usage?.costUsd)} | ${o.error ? "fejl" : "ok"} |`);
|
|
3948
|
+
}
|
|
3949
|
+
if (synthesis) {
|
|
3950
|
+
lines.push(`| ${SECOND_OPINION_SYNTH.label} | ${synthesis.usage?.region ?? "\u2014"} | ${usd(synthesis.usage?.costUsd)} | ${synthesis.error ? "fejl" : "ok"} |`);
|
|
3951
|
+
}
|
|
3952
|
+
const dkk = cost.dkk.toLocaleString("da-DK", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
3953
|
+
const src = { ecb: "ECB-kurs", given: "angivet kurs", fallback: "FAST kurs \u2014 ECB-kursen kunne ikke hentes" }[cost.rateSource];
|
|
3954
|
+
lines.push("", `**Rapporten kostede:** ${usd(cost.usd)} \u2248 ${dkk} kr. (1 USD = ${cost.usdToDkk} DKK, ${src} ${cost.rateDate})`, "");
|
|
3955
|
+
if (synthesis) {
|
|
3956
|
+
lines.push("## Opsummering", "", synthesis.text ? synthesis.text.replace(/^(#{1,4}) /gm, "$1## ") : `_Fejl: ${synthesis.error}_`, "");
|
|
3957
|
+
}
|
|
3958
|
+
for (const o of opinions) {
|
|
3959
|
+
const body = o.text ? o.text.replace(/^(#{1,4}) /gm, "$1## ") : `_Fejl: ${o.error}_`;
|
|
3960
|
+
lines.push(`## ${o.label}`, "", body, "");
|
|
3961
|
+
}
|
|
3962
|
+
return lines.join("\n");
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3798
3965
|
// src/voices/registry.ts
|
|
3799
3966
|
var CHECKED_AT = {
|
|
3800
3967
|
// All 5 curated ids confirmed by SYNTHESIS — POST /v1/text-to-speech/{id} returned
|
|
@@ -4264,8 +4431,8 @@ var aiConfigSchema = z.object({
|
|
|
4264
4431
|
import { randomUUID } from "crypto";
|
|
4265
4432
|
|
|
4266
4433
|
// src/version.ts
|
|
4267
|
-
var VERSION = "0.
|
|
4268
|
-
var SDK_TAG = "@broberg/ai-sdk@0.
|
|
4434
|
+
var VERSION = "0.71.0";
|
|
4435
|
+
var SDK_TAG = "@broberg/ai-sdk@0.71.0";
|
|
4269
4436
|
|
|
4270
4437
|
// src/cost/sinks/upmetrics.ts
|
|
4271
4438
|
function isRetryableStatus(status) {
|
|
@@ -4662,21 +4829,21 @@ function createAI(config = {}) {
|
|
|
4662
4829
|
if (budget) await budget.record(usage.costUsd);
|
|
4663
4830
|
}
|
|
4664
4831
|
const providerNames = Object.keys(providers);
|
|
4665
|
-
function withOverride(base,
|
|
4666
|
-
assertOverrideProvider(base,
|
|
4667
|
-
return { ...base, ...
|
|
4832
|
+
function withOverride(base, override2, label) {
|
|
4833
|
+
assertOverrideProvider(base, override2, label, providerNames);
|
|
4834
|
+
return { ...base, ...override2 };
|
|
4668
4835
|
}
|
|
4669
|
-
function mergeUnguarded(base,
|
|
4836
|
+
function mergeUnguarded(base, override2, why) {
|
|
4670
4837
|
void why;
|
|
4671
|
-
return { ...base, ...
|
|
4838
|
+
return { ...base, ...override2 };
|
|
4672
4839
|
}
|
|
4673
|
-
function voiceRoute(base,
|
|
4674
|
-
const spec = mergeUnguarded(base,
|
|
4675
|
-
if (!
|
|
4676
|
-
const model = defaults[
|
|
4840
|
+
function voiceRoute(base, override2, defaults, label) {
|
|
4841
|
+
const spec = mergeUnguarded(base, override2, "routes by voice, not by model \u2014 the adapter never sends spec.model");
|
|
4842
|
+
if (!override2?.provider || override2.provider === base.provider || override2.model) return spec;
|
|
4843
|
+
const model = defaults[override2.provider];
|
|
4677
4844
|
if (!model) {
|
|
4678
4845
|
throw new Error(
|
|
4679
|
-
`${label}: override:{provider:"${
|
|
4846
|
+
`${label}: override:{provider:"${override2.provider}"} needs a model \u2014 pass override:{ provider:"${override2.provider}", model:"\u2026" }.`
|
|
4680
4847
|
);
|
|
4681
4848
|
}
|
|
4682
4849
|
return { ...spec, model };
|
|
@@ -5253,21 +5420,22 @@ function createAI(config = {}) {
|
|
|
5253
5420
|
if (!adapter.batchSubmit) throw new Error(`createAI: provider "${spec.provider}" does not support batch`);
|
|
5254
5421
|
return adapter.batchSubmit({ items: input.requests, spec });
|
|
5255
5422
|
},
|
|
5256
|
-
async status(jobId,
|
|
5257
|
-
const spec = withOverride(DEFAULT_BATCH_SPEC,
|
|
5423
|
+
async status(jobId, override2) {
|
|
5424
|
+
const spec = withOverride(DEFAULT_BATCH_SPEC, override2, "batch.status");
|
|
5258
5425
|
const adapter = pickProvider(spec.provider);
|
|
5259
5426
|
if (!adapter.batchStatus) throw new Error(`createAI: provider "${spec.provider}" does not support batch`);
|
|
5260
5427
|
return adapter.batchStatus({ jobId, spec });
|
|
5261
5428
|
},
|
|
5262
|
-
async results(jobId,
|
|
5263
|
-
const spec = withOverride(DEFAULT_BATCH_SPEC,
|
|
5429
|
+
async results(jobId, override2) {
|
|
5430
|
+
const spec = withOverride(DEFAULT_BATCH_SPEC, override2, "batch.results");
|
|
5264
5431
|
const adapter = pickProvider(spec.provider);
|
|
5265
5432
|
if (!adapter.batchResults) throw new Error(`createAI: provider "${spec.provider}" does not support batch`);
|
|
5266
5433
|
return adapter.batchResults({ jobId, spec });
|
|
5267
5434
|
}
|
|
5268
5435
|
},
|
|
5269
5436
|
// Replaced below with the real prompt-contracts (needs the client itself).
|
|
5270
|
-
contracts: void 0
|
|
5437
|
+
contracts: void 0,
|
|
5438
|
+
secondOpinion: (input) => runSecondOpinion(client, input)
|
|
5271
5439
|
};
|
|
5272
5440
|
client.contracts = makeContracts(client);
|
|
5273
5441
|
return client;
|
|
@@ -5608,12 +5776,12 @@ function sqliteBudgetStore(config) {
|
|
|
5608
5776
|
const row = db.query(`SELECT spent_usd FROM budget_spend WHERE key = $key`).get({ $key: key });
|
|
5609
5777
|
return row?.spent_usd ?? 0;
|
|
5610
5778
|
},
|
|
5611
|
-
async addSpent(
|
|
5779
|
+
async addSpent(usd2) {
|
|
5612
5780
|
const db = await (ready ??= open());
|
|
5613
5781
|
db.run(
|
|
5614
5782
|
`INSERT INTO budget_spend (key, spent_usd) VALUES ($key, $usd)
|
|
5615
5783
|
ON CONFLICT(key) DO UPDATE SET spent_usd = spent_usd + $usd`,
|
|
5616
|
-
{ $key: key, $usd:
|
|
5784
|
+
{ $key: key, $usd: usd2 }
|
|
5617
5785
|
);
|
|
5618
5786
|
}
|
|
5619
5787
|
};
|
|
@@ -5879,6 +6047,10 @@ export {
|
|
|
5879
6047
|
SDK_TAG,
|
|
5880
6048
|
SEARCH_CACHE_TTL_MS,
|
|
5881
6049
|
SEARCH_PRICE_USD,
|
|
6050
|
+
SECOND_OPINION_INSTRUCTION,
|
|
6051
|
+
SECOND_OPINION_PANEL,
|
|
6052
|
+
SECOND_OPINION_SYNTH,
|
|
6053
|
+
SECOND_OPINION_SYNTH_INSTRUCTION,
|
|
5882
6054
|
SearchBudgetExceededError,
|
|
5883
6055
|
SearchKeyMissingError,
|
|
5884
6056
|
StreamHttpError,
|