polpo-ai 0.5.1 → 0.5.2
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/llm/pi-client.d.ts +4 -254
- package/dist/llm/pi-client.d.ts.map +1 -1
- package/dist/llm/pi-client.js +4 -850
- package/dist/llm/pi-client.js.map +1 -1
- package/package.json +7 -6
package/dist/llm/pi-client.d.ts
CHANGED
|
@@ -1,258 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Polpo LLM abstraction —
|
|
3
|
-
* and provider-level failover built on Vercel AI SDK + AI Gateway.
|
|
2
|
+
* Polpo LLM abstraction — thin re-export shim.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
* - AI SDK generateText/streamText for completions
|
|
8
|
-
* - @ai-sdk/openai for custom OpenAI-compatible endpoints (Ollama, vLLM, etc.)
|
|
4
|
+
* All logic has been extracted to the @polpo-ai/llm package.
|
|
5
|
+
* This file re-exports everything for backward compatibility.
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
import type { LanguageModel } from "ai";
|
|
12
|
-
import type { ProviderConfig, ModelConfig, ModelAllowlistEntry, ReasoningLevel } from "../core/types.js";
|
|
13
|
-
export { PROVIDER_ENV_MAP } from "@polpo-ai/core";
|
|
14
|
-
/** Re-export for consumers that need usage info. */
|
|
15
|
-
export type { LanguageModelUsage };
|
|
16
|
-
/**
|
|
17
|
-
* A resolved model: metadata (from gateway catalog or custom provider config)
|
|
18
|
-
* plus an AI SDK LanguageModel instance ready for generateText/streamText.
|
|
19
|
-
*/
|
|
20
|
-
export interface ResolvedModel {
|
|
21
|
-
/** Model identifier (e.g. "claude-sonnet-4.5"). */
|
|
22
|
-
id: string;
|
|
23
|
-
/** Human-readable name. */
|
|
24
|
-
name: string;
|
|
25
|
-
/** Provider name (e.g. "anthropic", "openai"). */
|
|
26
|
-
provider: string;
|
|
27
|
-
/** Whether the model supports reasoning/thinking. */
|
|
28
|
-
reasoning: boolean;
|
|
29
|
-
/** Supported input modalities. */
|
|
30
|
-
input: string[];
|
|
31
|
-
/** Context window size in tokens. */
|
|
32
|
-
contextWindow: number;
|
|
33
|
-
/** Max output tokens. */
|
|
34
|
-
maxTokens: number;
|
|
35
|
-
/** Cost per token (in USD). */
|
|
36
|
-
cost: {
|
|
37
|
-
input: number;
|
|
38
|
-
output: number;
|
|
39
|
-
cacheRead: number;
|
|
40
|
-
cacheWrite: number;
|
|
41
|
-
};
|
|
42
|
-
/** The AI SDK model instance to pass to generateText/streamText. */
|
|
43
|
-
aiModel: LanguageModel;
|
|
44
|
-
}
|
|
45
|
-
export declare function setProviderOverrides(overrides: Record<string, ProviderConfig>): void;
|
|
46
|
-
export declare function getProviderOverrides(): Record<string, ProviderConfig>;
|
|
47
|
-
export declare function setModelAllowlist(allowlist: Record<string, ModelAllowlistEntry> | undefined): void;
|
|
48
|
-
export declare function getModelAllowlist(): Record<string, ModelAllowlistEntry> | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Check if a model spec is allowed by the allowlist.
|
|
51
|
-
* Returns true if no allowlist is set (everything allowed) or the model is in the list.
|
|
52
|
-
*/
|
|
53
|
-
export declare function isModelAllowed(spec: string): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Enforce model allowlist. Throws if the model is not allowed.
|
|
56
|
-
*/
|
|
57
|
-
export declare function enforceModelAllowlist(spec: string): void;
|
|
58
|
-
/**
|
|
59
|
-
* Resolve API key for a provider (synchronous).
|
|
60
|
-
* Reads from process.env using the PROVIDER_ENV_MAP.
|
|
61
|
-
*
|
|
62
|
-
* Also checks .polpo/.env via dotenv-style parsing if the env var isn't set.
|
|
63
|
-
*/
|
|
64
|
-
export declare function resolveApiKey(provider: string): string | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Resolve API key for a provider (async, full resolution chain).
|
|
67
|
-
* Priority: 1) polpo.json overrides (if they had apiKey), 2) env var lookup, 3) stored OAuth profiles.
|
|
68
|
-
*
|
|
69
|
-
* Returns the API key from env vars or provider config.
|
|
70
|
-
*/
|
|
71
|
-
export declare function resolveApiKeyAsync(provider: string): Promise<string | undefined>;
|
|
72
|
-
export type { ParsedModelSpec } from "@polpo-ai/core";
|
|
73
|
-
/**
|
|
74
|
-
* Parse a model spec string into provider + modelId.
|
|
75
|
-
* Falls back to POLPO_MODEL env var. Throws if no model is available.
|
|
76
|
-
*/
|
|
77
|
-
export declare function parseModelSpec(spec?: string): {
|
|
78
|
-
provider: string;
|
|
79
|
-
modelId: string;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Map Polpo's ReasoningLevel to AI SDK providerOptions for reasoning/thinking.
|
|
83
|
-
*
|
|
84
|
-
* Each provider has its own way of enabling extended thinking:
|
|
85
|
-
* - Anthropic: thinking.type + thinking.budgetTokens
|
|
86
|
-
* - OpenAI: reasoningEffort
|
|
87
|
-
* - Google: thinkingConfig.thinkingBudget
|
|
88
|
-
*/
|
|
89
|
-
export declare function mapReasoningToProviderOptions(provider: string, level: ReasoningLevel | undefined, maxTokens: number): Record<string, Record<string, unknown>> | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Resolve a model spec to a ResolvedModel with metadata + AI SDK model instance.
|
|
92
|
-
*
|
|
93
|
-
* Resolution order:
|
|
94
|
-
* 1. If provider has an override with custom baseUrl → create OpenAI-compatible model
|
|
95
|
-
* 2. Otherwise → use AI Gateway (provider/modelId format)
|
|
96
|
-
*
|
|
97
|
-
* This ensures custom providers (Ollama, vLLM, etc.) work without being in the gateway.
|
|
98
|
-
*/
|
|
99
|
-
export declare function resolveModel(spec?: string): ResolvedModel;
|
|
100
|
-
export interface ModelInfo {
|
|
101
|
-
id: string;
|
|
102
|
-
name: string;
|
|
103
|
-
provider: string;
|
|
104
|
-
reasoning: boolean;
|
|
105
|
-
input: string[];
|
|
106
|
-
contextWindow: number;
|
|
107
|
-
maxTokens: number;
|
|
108
|
-
cost: {
|
|
109
|
-
input: number;
|
|
110
|
-
output: number;
|
|
111
|
-
cacheRead: number;
|
|
112
|
-
cacheWrite: number;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* List all available providers from the AI Gateway catalog.
|
|
117
|
-
* Returns synchronously from the cache; triggers background refresh if stale.
|
|
118
|
-
*/
|
|
119
|
-
export declare function listProviders(): string[];
|
|
120
|
-
/**
|
|
121
|
-
* List all models for a given provider (or all providers if none specified).
|
|
122
|
-
*/
|
|
123
|
-
export declare function listModels(provider?: string): ModelInfo[];
|
|
124
|
-
/**
|
|
125
|
-
* Get detailed model info for a specific model spec.
|
|
126
|
-
*/
|
|
127
|
-
export declare function getModelInfo(spec: string): ModelInfo | undefined;
|
|
128
|
-
export interface CostEstimate {
|
|
129
|
-
inputCost: number;
|
|
130
|
-
outputCost: number;
|
|
131
|
-
cacheReadCost: number;
|
|
132
|
-
cacheWriteCost: number;
|
|
133
|
-
totalCost: number;
|
|
134
|
-
currency: string;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Calculate the cost of an LLM call from AI SDK usage data.
|
|
138
|
-
* Uses pricing from the resolved model metadata.
|
|
139
|
-
* Returns cost in USD.
|
|
140
|
-
*/
|
|
141
|
-
export declare function estimateCost(model: ResolvedModel, usage: LanguageModelUsage): CostEstimate;
|
|
142
|
-
export interface ProviderValidationResult {
|
|
143
|
-
provider: string;
|
|
144
|
-
modelSpec: string;
|
|
145
|
-
hasKey: boolean;
|
|
146
|
-
envVar?: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Validate that all required providers have API keys available.
|
|
150
|
-
* Returns detailed validation results for all model specs.
|
|
151
|
-
*/
|
|
152
|
-
export declare function validateProviderKeys(modelSpecs: string[]): {
|
|
153
|
-
provider: string;
|
|
154
|
-
modelSpec: string;
|
|
155
|
-
}[];
|
|
156
|
-
/**
|
|
157
|
-
* Get detailed validation for a set of model specs — including which env var to set.
|
|
158
|
-
*/
|
|
159
|
-
export declare function validateProviderKeysDetailed(modelSpecs: string[]): ProviderValidationResult[];
|
|
160
|
-
/**
|
|
161
|
-
* Build a dynamic model listing string for system prompts.
|
|
162
|
-
* Uses the gateway catalog instead of hardcoded lists.
|
|
163
|
-
*/
|
|
164
|
-
export declare function buildModelListingForPrompt(): string;
|
|
165
|
-
/**
|
|
166
|
-
* Resolve a model from a fallback chain (synchronous).
|
|
167
|
-
* Tries primary first, then each fallback in order.
|
|
168
|
-
* Returns the first model that has a valid API key.
|
|
169
|
-
*/
|
|
170
|
-
export declare function resolveModelWithFallback(config: ModelConfig): {
|
|
171
|
-
model: ResolvedModel;
|
|
172
|
-
spec: string;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Resolve a model from a fallback chain (async).
|
|
176
|
-
* Tries primary first, then each fallback in order.
|
|
177
|
-
* Checks the FULL API key resolution chain including OAuth profiles with auto-refresh.
|
|
178
|
-
*/
|
|
179
|
-
export declare function resolveModelWithFallbackAsync(config: ModelConfig): Promise<{
|
|
180
|
-
model: ResolvedModel;
|
|
181
|
-
spec: string;
|
|
182
|
-
}>;
|
|
183
|
-
/**
|
|
184
|
-
* Check if a provider is currently in cooldown.
|
|
185
|
-
*/
|
|
186
|
-
export declare function isProviderInCooldown(provider: string): boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Mark a provider as temporarily unavailable (cooldown).
|
|
189
|
-
*/
|
|
190
|
-
export declare function markProviderCooldown(provider: string, reason?: string): void;
|
|
191
|
-
/**
|
|
192
|
-
* Clear cooldown for a provider (e.g. after successful call).
|
|
193
|
-
*/
|
|
194
|
-
export declare function clearProviderCooldown(provider: string): void;
|
|
195
|
-
/**
|
|
196
|
-
* Get current cooldown state for all providers.
|
|
197
|
-
*/
|
|
198
|
-
export declare function getProviderCooldowns(): Record<string, {
|
|
199
|
-
until: number;
|
|
200
|
-
errorCount: number;
|
|
201
|
-
reason?: string;
|
|
202
|
-
}>;
|
|
203
|
-
/**
|
|
204
|
-
* Classify an error to determine if it should trigger cooldown or failover.
|
|
205
|
-
*/
|
|
206
|
-
export declare function classifyProviderError(err: unknown): {
|
|
207
|
-
shouldCooldown: boolean;
|
|
208
|
-
shouldFailover: boolean;
|
|
209
|
-
reason: string;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* Normalize a model spec that may be string or ModelConfig into a plain string.
|
|
213
|
-
* Useful for APIs that only accept a string model spec.
|
|
214
|
-
*/
|
|
215
|
-
export declare function resolveModelSpec(spec: string | ModelConfig | undefined): string | undefined;
|
|
216
|
-
/**
|
|
217
|
-
* Build AI SDK compatible options for generateText/streamText calls.
|
|
218
|
-
*
|
|
219
|
-
* Returns an object with:
|
|
220
|
-
* - providerOptions: reasoning/thinking configuration per provider
|
|
221
|
-
* - maxTokens: max output tokens
|
|
222
|
-
* - headers: additional headers (e.g. for API key passthrough)
|
|
223
|
-
*
|
|
224
|
-
* This replaces the old pi-ai `buildStreamOpts` — callers that need the raw
|
|
225
|
-
* options object for pi-agent-core Agent can still use this. The shape changed
|
|
226
|
-
* but the function signature is preserved for backward compat.
|
|
227
|
-
*/
|
|
228
|
-
export declare function buildStreamOpts(apiKey?: string, reasoning?: ReasoningLevel, maxTokens?: number): Record<string, unknown> | undefined;
|
|
229
|
-
/**
|
|
230
|
-
* Simple prompt -> text completion using AI SDK generateText.
|
|
231
|
-
* Integrates with the cooldown system: marks provider cooldown on classified errors,
|
|
232
|
-
* clears cooldown on success. Uses async API key resolution (includes OAuth profiles).
|
|
233
|
-
*/
|
|
234
|
-
export declare function queryText(prompt: string, model?: string, reasoning?: ReasoningLevel): Promise<{
|
|
235
|
-
text: string;
|
|
236
|
-
usage?: LanguageModelUsage;
|
|
237
|
-
model: ResolvedModel;
|
|
238
|
-
}>;
|
|
239
|
-
/**
|
|
240
|
-
* Streaming prompt -> text with progress callback.
|
|
241
|
-
* Integrates with the cooldown system. Uses async API key resolution.
|
|
242
|
-
*/
|
|
243
|
-
export declare function queryStream(prompt: string, model?: string, onProgress?: (text: string) => void, reasoning?: ReasoningLevel): Promise<{
|
|
244
|
-
text: string;
|
|
245
|
-
usage?: LanguageModelUsage;
|
|
246
|
-
model: ResolvedModel;
|
|
247
|
-
}>;
|
|
248
|
-
/**
|
|
249
|
-
* Query with model fallback chain — tries primary model, then fallbacks.
|
|
250
|
-
* On provider-level errors, marks cooldown and tries next model.
|
|
251
|
-
*/
|
|
252
|
-
export declare function queryTextWithFallback(prompt: string, modelConfig: ModelConfig): Promise<{
|
|
253
|
-
text: string;
|
|
254
|
-
usage?: LanguageModelUsage;
|
|
255
|
-
model: ResolvedModel;
|
|
256
|
-
usedSpec: string;
|
|
257
|
-
}>;
|
|
7
|
+
export * from "@polpo-ai/llm";
|
|
258
8
|
//# sourceMappingURL=pi-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-client.d.ts","sourceRoot":"","sources":["../../src/llm/pi-client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pi-client.d.ts","sourceRoot":"","sources":["../../src/llm/pi-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC"}
|
package/dist/llm/pi-client.js
CHANGED
|
@@ -1,854 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Polpo LLM abstraction —
|
|
3
|
-
* and provider-level failover built on Vercel AI SDK + AI Gateway.
|
|
2
|
+
* Polpo LLM abstraction — thin re-export shim.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
* - AI SDK generateText/streamText for completions
|
|
8
|
-
* - @ai-sdk/openai for custom OpenAI-compatible endpoints (Ollama, vLLM, etc.)
|
|
4
|
+
* All logic has been extracted to the @polpo-ai/llm package.
|
|
5
|
+
* This file re-exports everything for backward compatibility.
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { getGlobalPolpoDir } from "../core/constants.js";
|
|
13
|
-
import { generateText, streamText, gateway, } from "ai";
|
|
14
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
15
|
-
// ─── Constants ──────────────────────────────────────
|
|
16
|
-
// Re-export the canonical env map from @polpo-ai/core.
|
|
17
|
-
// It's duplicated here for backward compat (other files import PROVIDER_ENV_MAP from pi-client).
|
|
18
|
-
export { PROVIDER_ENV_MAP } from "@polpo-ai/core";
|
|
19
|
-
import { PROVIDER_ENV_MAP } from "@polpo-ai/core";
|
|
20
|
-
// ─── Gateway Model Catalog (lazy, cached) ───────────
|
|
21
|
-
/** Cached gateway catalog. */
|
|
22
|
-
let catalogCache = null;
|
|
23
|
-
let catalogFetchPromise = null;
|
|
24
|
-
let catalogFetchedAt = 0;
|
|
25
|
-
const CATALOG_TTL_MS = 60 * 60 * 1000; // 1 hour
|
|
26
|
-
/**
|
|
27
|
-
* Fetch and cache the AI Gateway model catalog.
|
|
28
|
-
* Uses the public endpoint (no auth required for listing).
|
|
29
|
-
*/
|
|
30
|
-
async function fetchCatalog() {
|
|
31
|
-
const now = Date.now();
|
|
32
|
-
if (catalogCache && now - catalogFetchedAt < CATALOG_TTL_MS) {
|
|
33
|
-
return catalogCache;
|
|
34
|
-
}
|
|
35
|
-
if (catalogFetchPromise && now - catalogFetchedAt < CATALOG_TTL_MS) {
|
|
36
|
-
return catalogFetchPromise;
|
|
37
|
-
}
|
|
38
|
-
catalogFetchPromise = (async () => {
|
|
39
|
-
try {
|
|
40
|
-
const resp = await fetch("https://ai-gateway.vercel.sh/v1/models");
|
|
41
|
-
if (!resp.ok) {
|
|
42
|
-
throw new Error(`Gateway catalog fetch failed: ${resp.status}`);
|
|
43
|
-
}
|
|
44
|
-
const data = (await resp.json());
|
|
45
|
-
const models = data.data ?? [];
|
|
46
|
-
catalogCache = models;
|
|
47
|
-
catalogFetchedAt = Date.now();
|
|
48
|
-
return models;
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
// On failure, return stale cache if available
|
|
52
|
-
if (catalogCache)
|
|
53
|
-
return catalogCache;
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
})();
|
|
57
|
-
return catalogFetchPromise;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get the cached catalog synchronously (returns empty array if not yet fetched).
|
|
61
|
-
* Triggers a background fetch if cache is stale.
|
|
62
|
-
*/
|
|
63
|
-
function getCatalogSync() {
|
|
64
|
-
const now = Date.now();
|
|
65
|
-
if (!catalogCache || now - catalogFetchedAt > CATALOG_TTL_MS) {
|
|
66
|
-
// Trigger background refresh — don't block
|
|
67
|
-
fetchCatalog().catch(() => { });
|
|
68
|
-
}
|
|
69
|
-
return catalogCache ?? [];
|
|
70
|
-
}
|
|
71
|
-
// ─── Provider override management ───────────────────
|
|
72
|
-
/** Provider overrides from polpo.json — set by the orchestrator at init time. */
|
|
73
|
-
let providerOverrides = {};
|
|
74
|
-
export function setProviderOverrides(overrides) {
|
|
75
|
-
providerOverrides = overrides;
|
|
76
|
-
}
|
|
77
|
-
export function getProviderOverrides() {
|
|
78
|
-
return { ...providerOverrides };
|
|
79
|
-
}
|
|
80
|
-
// ─── Model Allowlist ────────────────────────────────
|
|
81
|
-
/** Model allowlist — when set, only these models can be used. Set by orchestrator at init. */
|
|
82
|
-
let modelAllowlist;
|
|
83
|
-
export function setModelAllowlist(allowlist) {
|
|
84
|
-
modelAllowlist = allowlist;
|
|
85
|
-
}
|
|
86
|
-
export function getModelAllowlist() {
|
|
87
|
-
return modelAllowlist;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if a model spec is allowed by the allowlist.
|
|
91
|
-
* Returns true if no allowlist is set (everything allowed) or the model is in the list.
|
|
92
|
-
*/
|
|
93
|
-
export function isModelAllowed(spec) {
|
|
94
|
-
if (!modelAllowlist)
|
|
95
|
-
return true;
|
|
96
|
-
// Check exact match
|
|
97
|
-
if (spec in modelAllowlist)
|
|
98
|
-
return true;
|
|
99
|
-
// Check without provider prefix (e.g. "claude-opus-4.6" matches "anthropic:claude-opus-4.6")
|
|
100
|
-
const { provider, modelId } = parseModelSpec(spec);
|
|
101
|
-
const fullSpec = `${provider}:${modelId}`;
|
|
102
|
-
return fullSpec in modelAllowlist;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Enforce model allowlist. Throws if the model is not allowed.
|
|
106
|
-
*/
|
|
107
|
-
export function enforceModelAllowlist(spec) {
|
|
108
|
-
if (!isModelAllowed(spec)) {
|
|
109
|
-
const allowed = Object.keys(modelAllowlist).join(", ");
|
|
110
|
-
throw new Error(`Model "${spec}" is not in the allowlist. Allowed models: ${allowed}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// ─── API Key Resolution ─────────────────────────────
|
|
114
|
-
/**
|
|
115
|
-
* Resolve API key for a provider (synchronous).
|
|
116
|
-
* Reads from process.env using the PROVIDER_ENV_MAP.
|
|
117
|
-
*
|
|
118
|
-
* Also checks .polpo/.env via dotenv-style parsing if the env var isn't set.
|
|
119
|
-
*/
|
|
120
|
-
export function resolveApiKey(provider) {
|
|
121
|
-
const envVar = PROVIDER_ENV_MAP[provider];
|
|
122
|
-
if (!envVar)
|
|
123
|
-
return undefined;
|
|
124
|
-
return process.env[envVar] || undefined;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Resolve API key for a provider (async, full resolution chain).
|
|
128
|
-
* Priority: 1) polpo.json overrides (if they had apiKey), 2) env var lookup, 3) stored OAuth profiles.
|
|
129
|
-
*
|
|
130
|
-
* Returns the API key from env vars or provider config.
|
|
131
|
-
*/
|
|
132
|
-
export async function resolveApiKeyAsync(provider) {
|
|
133
|
-
return resolveApiKey(provider);
|
|
134
|
-
}
|
|
135
|
-
// ─── Model Spec Parsing ─────────────────────────────
|
|
136
|
-
// Core logic lives in @polpo-ai/core. Re-exported here for backward compat.
|
|
137
|
-
import { parseModelSpec as _parseModelSpec } from "@polpo-ai/core";
|
|
138
|
-
/**
|
|
139
|
-
* Parse a model spec string into provider + modelId.
|
|
140
|
-
* Falls back to POLPO_MODEL env var. Throws if no model is available.
|
|
141
|
-
*/
|
|
142
|
-
export function parseModelSpec(spec) {
|
|
143
|
-
return _parseModelSpec(spec, process.env.POLPO_MODEL);
|
|
144
|
-
}
|
|
145
|
-
// ─── Reasoning Level Mapping ────────────────────────
|
|
146
|
-
/**
|
|
147
|
-
* Map Polpo's ReasoningLevel to AI SDK providerOptions for reasoning/thinking.
|
|
148
|
-
*
|
|
149
|
-
* Each provider has its own way of enabling extended thinking:
|
|
150
|
-
* - Anthropic: thinking.type + thinking.budgetTokens
|
|
151
|
-
* - OpenAI: reasoningEffort
|
|
152
|
-
* - Google: thinkingConfig.thinkingBudget
|
|
153
|
-
*/
|
|
154
|
-
export function mapReasoningToProviderOptions(provider, level, maxTokens) {
|
|
155
|
-
if (!level || level === "off")
|
|
156
|
-
return undefined;
|
|
157
|
-
// Budget tokens as a fraction of maxTokens, scaling with reasoning level
|
|
158
|
-
const budgetMap = {
|
|
159
|
-
minimal: 0.1,
|
|
160
|
-
low: 0.25,
|
|
161
|
-
medium: 0.5,
|
|
162
|
-
high: 0.75,
|
|
163
|
-
xhigh: 1.0,
|
|
164
|
-
};
|
|
165
|
-
const fraction = budgetMap[level] ?? 0.5;
|
|
166
|
-
const budgetTokens = Math.round(maxTokens * fraction);
|
|
167
|
-
// OpenAI reasoning effort mapping
|
|
168
|
-
const effortMap = {
|
|
169
|
-
minimal: "low",
|
|
170
|
-
low: "low",
|
|
171
|
-
medium: "medium",
|
|
172
|
-
high: "high",
|
|
173
|
-
xhigh: "high",
|
|
174
|
-
};
|
|
175
|
-
if (provider === "anthropic") {
|
|
176
|
-
return {
|
|
177
|
-
anthropic: {
|
|
178
|
-
thinking: { type: "enabled", budgetTokens },
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
if (provider === "openai") {
|
|
183
|
-
return {
|
|
184
|
-
openai: {
|
|
185
|
-
reasoningEffort: effortMap[level] ?? "medium",
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
if (provider === "google") {
|
|
190
|
-
return {
|
|
191
|
-
google: {
|
|
192
|
-
thinkingConfig: {
|
|
193
|
-
thinkingBudget: budgetTokens,
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
// Unknown provider — return anthropic-style as best effort
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
// ─── Model Resolution ───────────────────────────────
|
|
202
|
-
/**
|
|
203
|
-
* Create an AI SDK LanguageModel for a custom (non-gateway) provider.
|
|
204
|
-
* Uses @ai-sdk/openai with a custom baseURL for OpenAI-compatible endpoints.
|
|
205
|
-
*/
|
|
206
|
-
function createCustomProviderModel(provider, modelId, override) {
|
|
207
|
-
const baseURL = override.baseUrl || "http://localhost:11434/v1";
|
|
208
|
-
const apiKey = resolveApiKey(provider) || "ollama"; // Ollama doesn't need a real key
|
|
209
|
-
// For anthropic-messages API, we'd need @ai-sdk/anthropic — but custom providers
|
|
210
|
-
// are typically Ollama/vLLM/LM Studio which all speak OpenAI-compatible.
|
|
211
|
-
const openaiProvider = createOpenAI({
|
|
212
|
-
baseURL,
|
|
213
|
-
apiKey,
|
|
214
|
-
name: provider,
|
|
215
|
-
});
|
|
216
|
-
return openaiProvider(modelId);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Resolve a model spec to a ResolvedModel with metadata + AI SDK model instance.
|
|
220
|
-
*
|
|
221
|
-
* Resolution order:
|
|
222
|
-
* 1. If provider has an override with custom baseUrl → create OpenAI-compatible model
|
|
223
|
-
* 2. Otherwise → use AI Gateway (provider/modelId format)
|
|
224
|
-
*
|
|
225
|
-
* This ensures custom providers (Ollama, vLLM, etc.) work without being in the gateway.
|
|
226
|
-
*/
|
|
227
|
-
export function resolveModel(spec) {
|
|
228
|
-
const { provider, modelId } = parseModelSpec(spec);
|
|
229
|
-
const override = providerOverrides[provider];
|
|
230
|
-
// Custom provider with baseUrl override → use @ai-sdk/openai with custom endpoint
|
|
231
|
-
if (override?.baseUrl) {
|
|
232
|
-
const customDef = override.models?.find(m => m.id === modelId);
|
|
233
|
-
const aiModel = createCustomProviderModel(provider, modelId, override);
|
|
234
|
-
if (customDef) {
|
|
235
|
-
return {
|
|
236
|
-
id: customDef.id,
|
|
237
|
-
name: customDef.name,
|
|
238
|
-
provider,
|
|
239
|
-
reasoning: customDef.reasoning ?? false,
|
|
240
|
-
input: customDef.input ?? ["text"],
|
|
241
|
-
cost: customDef.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
242
|
-
contextWindow: customDef.contextWindow ?? 200_000,
|
|
243
|
-
maxTokens: customDef.maxTokens ?? 8192,
|
|
244
|
-
aiModel,
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
// No custom def — construct minimal metadata
|
|
248
|
-
return {
|
|
249
|
-
id: modelId,
|
|
250
|
-
name: modelId,
|
|
251
|
-
provider,
|
|
252
|
-
reasoning: false,
|
|
253
|
-
input: ["text"],
|
|
254
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
255
|
-
contextWindow: 200_000,
|
|
256
|
-
maxTokens: 8192,
|
|
257
|
-
aiModel,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
// Standard provider → route through AI Gateway
|
|
261
|
-
// The gateway expects "provider/modelId" format
|
|
262
|
-
const gatewayModelId = `${provider}/${modelId}`;
|
|
263
|
-
const aiModel = gateway(gatewayModelId);
|
|
264
|
-
// Try to get metadata from cached catalog
|
|
265
|
-
const catalog = getCatalogSync();
|
|
266
|
-
const entry = catalog.find(m => m.id === gatewayModelId);
|
|
267
|
-
if (entry) {
|
|
268
|
-
const pricing = entry.pricing;
|
|
269
|
-
return {
|
|
270
|
-
id: modelId,
|
|
271
|
-
name: entry.name || modelId,
|
|
272
|
-
provider,
|
|
273
|
-
reasoning: false, // Gateway catalog doesn't expose this directly
|
|
274
|
-
input: ["text"],
|
|
275
|
-
contextWindow: 200_000, // Gateway doesn't expose this; use sensible default
|
|
276
|
-
maxTokens: 8192,
|
|
277
|
-
cost: {
|
|
278
|
-
input: pricing ? parseFloat(pricing.input) : 0,
|
|
279
|
-
output: pricing ? parseFloat(pricing.output) : 0,
|
|
280
|
-
cacheRead: pricing?.cachedInputTokens ? parseFloat(pricing.cachedInputTokens) : 0,
|
|
281
|
-
cacheWrite: pricing?.cacheCreationInputTokens ? parseFloat(pricing.cacheCreationInputTokens) : 0,
|
|
282
|
-
},
|
|
283
|
-
aiModel,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
// Not in catalog (yet) — return with defaults. The model may still work via gateway.
|
|
287
|
-
return {
|
|
288
|
-
id: modelId,
|
|
289
|
-
name: modelId,
|
|
290
|
-
provider,
|
|
291
|
-
reasoning: false,
|
|
292
|
-
input: ["text"],
|
|
293
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
294
|
-
contextWindow: 200_000,
|
|
295
|
-
maxTokens: 8192,
|
|
296
|
-
aiModel,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* List all available providers from the AI Gateway catalog.
|
|
301
|
-
* Returns synchronously from the cache; triggers background refresh if stale.
|
|
302
|
-
*/
|
|
303
|
-
export function listProviders() {
|
|
304
|
-
const catalog = getCatalogSync();
|
|
305
|
-
const providers = new Set();
|
|
306
|
-
for (const entry of catalog) {
|
|
307
|
-
// Gateway IDs are "provider/model" — extract the provider part
|
|
308
|
-
const slashIdx = entry.id.indexOf("/");
|
|
309
|
-
if (slashIdx > 0) {
|
|
310
|
-
providers.add(entry.id.slice(0, slashIdx));
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
// Also include custom provider overrides
|
|
314
|
-
for (const p of Object.keys(providerOverrides)) {
|
|
315
|
-
providers.add(p);
|
|
316
|
-
}
|
|
317
|
-
return Array.from(providers).sort();
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* List all models for a given provider (or all providers if none specified).
|
|
321
|
-
*/
|
|
322
|
-
export function listModels(provider) {
|
|
323
|
-
const catalog = getCatalogSync();
|
|
324
|
-
const models = [];
|
|
325
|
-
for (const entry of catalog) {
|
|
326
|
-
const slashIdx = entry.id.indexOf("/");
|
|
327
|
-
if (slashIdx <= 0)
|
|
328
|
-
continue;
|
|
329
|
-
const entryProvider = entry.id.slice(0, slashIdx);
|
|
330
|
-
const entryModelId = entry.id.slice(slashIdx + 1);
|
|
331
|
-
if (provider && entryProvider !== provider)
|
|
332
|
-
continue;
|
|
333
|
-
const pricing = entry.pricing;
|
|
334
|
-
models.push({
|
|
335
|
-
id: entryModelId,
|
|
336
|
-
name: entry.name || entryModelId,
|
|
337
|
-
provider: entryProvider,
|
|
338
|
-
reasoning: false,
|
|
339
|
-
input: ["text"],
|
|
340
|
-
contextWindow: 200_000,
|
|
341
|
-
maxTokens: 8192,
|
|
342
|
-
cost: {
|
|
343
|
-
input: pricing ? parseFloat(pricing.input) : 0,
|
|
344
|
-
output: pricing ? parseFloat(pricing.output) : 0,
|
|
345
|
-
cacheRead: pricing?.cachedInputTokens ? parseFloat(pricing.cachedInputTokens) : 0,
|
|
346
|
-
cacheWrite: pricing?.cacheCreationInputTokens ? parseFloat(pricing.cacheCreationInputTokens) : 0,
|
|
347
|
-
},
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
// Append custom models from provider overrides
|
|
351
|
-
const overrideProviders = provider ? [provider] : Object.keys(providerOverrides);
|
|
352
|
-
for (const p of overrideProviders) {
|
|
353
|
-
const override = providerOverrides[p];
|
|
354
|
-
if (!override?.models)
|
|
355
|
-
continue;
|
|
356
|
-
for (const m of override.models) {
|
|
357
|
-
models.push({
|
|
358
|
-
id: m.id,
|
|
359
|
-
name: m.name,
|
|
360
|
-
provider: p,
|
|
361
|
-
reasoning: m.reasoning ?? false,
|
|
362
|
-
input: m.input ?? ["text"],
|
|
363
|
-
contextWindow: m.contextWindow ?? 200_000,
|
|
364
|
-
maxTokens: m.maxTokens ?? 8192,
|
|
365
|
-
cost: m.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return models;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Get detailed model info for a specific model spec.
|
|
373
|
-
*/
|
|
374
|
-
export function getModelInfo(spec) {
|
|
375
|
-
try {
|
|
376
|
-
const model = resolveModel(spec);
|
|
377
|
-
return {
|
|
378
|
-
id: model.id,
|
|
379
|
-
name: model.name,
|
|
380
|
-
provider: model.provider,
|
|
381
|
-
reasoning: model.reasoning,
|
|
382
|
-
input: model.input,
|
|
383
|
-
contextWindow: model.contextWindow,
|
|
384
|
-
maxTokens: model.maxTokens,
|
|
385
|
-
cost: model.cost,
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
catch {
|
|
389
|
-
return undefined;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Calculate the cost of an LLM call from AI SDK usage data.
|
|
394
|
-
* Uses pricing from the resolved model metadata.
|
|
395
|
-
* Returns cost in USD.
|
|
396
|
-
*/
|
|
397
|
-
export function estimateCost(model, usage) {
|
|
398
|
-
const inputTokens = usage.inputTokens ?? 0;
|
|
399
|
-
const outputTokens = usage.outputTokens ?? 0;
|
|
400
|
-
const cacheReadTokens = usage.inputTokenDetails?.cacheReadTokens ?? 0;
|
|
401
|
-
const cacheWriteTokens = usage.inputTokenDetails?.cacheWriteTokens ?? 0;
|
|
402
|
-
// Cost per token (pricing is per-token from gateway)
|
|
403
|
-
const inputCost = inputTokens * model.cost.input;
|
|
404
|
-
const outputCost = outputTokens * model.cost.output;
|
|
405
|
-
const cacheReadCost = cacheReadTokens * model.cost.cacheRead;
|
|
406
|
-
const cacheWriteCost = cacheWriteTokens * model.cost.cacheWrite;
|
|
407
|
-
return {
|
|
408
|
-
inputCost,
|
|
409
|
-
outputCost,
|
|
410
|
-
cacheReadCost,
|
|
411
|
-
cacheWriteCost,
|
|
412
|
-
totalCost: inputCost + outputCost + cacheReadCost + cacheWriteCost,
|
|
413
|
-
currency: "USD",
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Validate that all required providers have API keys available.
|
|
418
|
-
* Returns detailed validation results for all model specs.
|
|
419
|
-
*/
|
|
420
|
-
export function validateProviderKeys(modelSpecs) {
|
|
421
|
-
const missing = [];
|
|
422
|
-
const seen = new Set();
|
|
423
|
-
for (const spec of modelSpecs) {
|
|
424
|
-
const { provider } = parseModelSpec(spec);
|
|
425
|
-
if (seen.has(provider))
|
|
426
|
-
continue;
|
|
427
|
-
seen.add(provider);
|
|
428
|
-
if (!resolveApiKey(provider) && !hasOAuthProfiles(provider)) {
|
|
429
|
-
missing.push({ provider, modelSpec: spec });
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return missing;
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Check if there are any stored OAuth profiles for a provider (synchronous).
|
|
436
|
-
* Used by the sync validation path so OAuth-based providers (openai-codex,
|
|
437
|
-
* github-copilot, anthropic, etc.) aren't rejected before spawn.
|
|
438
|
-
*
|
|
439
|
-
* Reads auth-profiles.json directly to stay synchronous in ESM context.
|
|
440
|
-
*/
|
|
441
|
-
function hasOAuthProfiles(provider) {
|
|
442
|
-
try {
|
|
443
|
-
const profilePath = join(getGlobalPolpoDir(), "auth-profiles.json");
|
|
444
|
-
if (!existsSync(profilePath))
|
|
445
|
-
return false;
|
|
446
|
-
const data = JSON.parse(readFileSync(profilePath, "utf-8"));
|
|
447
|
-
if (!data?.profiles)
|
|
448
|
-
return false;
|
|
449
|
-
return Object.values(data.profiles).some((p) => p.provider === provider);
|
|
450
|
-
}
|
|
451
|
-
catch {
|
|
452
|
-
return false;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Get detailed validation for a set of model specs — including which env var to set.
|
|
457
|
-
*/
|
|
458
|
-
export function validateProviderKeysDetailed(modelSpecs) {
|
|
459
|
-
const results = [];
|
|
460
|
-
const seen = new Set();
|
|
461
|
-
for (const spec of modelSpecs) {
|
|
462
|
-
const { provider } = parseModelSpec(spec);
|
|
463
|
-
if (seen.has(provider))
|
|
464
|
-
continue;
|
|
465
|
-
seen.add(provider);
|
|
466
|
-
results.push({
|
|
467
|
-
provider,
|
|
468
|
-
modelSpec: spec,
|
|
469
|
-
hasKey: !!resolveApiKey(provider),
|
|
470
|
-
envVar: PROVIDER_ENV_MAP[provider],
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
return results;
|
|
474
|
-
}
|
|
475
|
-
// ─── Dynamic prompt helpers ─────────────────────────
|
|
476
|
-
/**
|
|
477
|
-
* Build a dynamic model listing string for system prompts.
|
|
478
|
-
* Uses the gateway catalog instead of hardcoded lists.
|
|
479
|
-
*/
|
|
480
|
-
export function buildModelListingForPrompt() {
|
|
481
|
-
const lines = [
|
|
482
|
-
`Format: "provider:model" (e.g. "anthropic:claude-opus-4.6") or just "model" (auto-inferred from prefix).`,
|
|
483
|
-
];
|
|
484
|
-
const catalog = getCatalogSync();
|
|
485
|
-
// Group models by provider
|
|
486
|
-
const byProvider = new Map();
|
|
487
|
-
for (const entry of catalog) {
|
|
488
|
-
const slashIdx = entry.id.indexOf("/");
|
|
489
|
-
if (slashIdx <= 0)
|
|
490
|
-
continue;
|
|
491
|
-
const provider = entry.id.slice(0, slashIdx);
|
|
492
|
-
if (!byProvider.has(provider))
|
|
493
|
-
byProvider.set(provider, []);
|
|
494
|
-
byProvider.get(provider).push(entry);
|
|
495
|
-
}
|
|
496
|
-
// Show the most relevant providers with their top models
|
|
497
|
-
const FEATURED_PROVIDERS = [
|
|
498
|
-
{ provider: "anthropic", picks: 3 },
|
|
499
|
-
{ provider: "openai", picks: 4 },
|
|
500
|
-
{ provider: "google", picks: 3 },
|
|
501
|
-
{ provider: "mistral", picks: 2 },
|
|
502
|
-
{ provider: "groq", picks: 2 },
|
|
503
|
-
{ provider: "xai", picks: 1 },
|
|
504
|
-
];
|
|
505
|
-
for (const { provider, picks } of FEATURED_PROVIDERS) {
|
|
506
|
-
const models = byProvider.get(provider);
|
|
507
|
-
if (!models || models.length === 0)
|
|
508
|
-
continue;
|
|
509
|
-
const top = models.slice(0, picks);
|
|
510
|
-
const modelStr = top.map(m => {
|
|
511
|
-
const modelId = m.id.slice(m.id.indexOf("/") + 1);
|
|
512
|
-
const tags = [];
|
|
513
|
-
if (m.pricing && parseFloat(m.pricing.input) === 0 && parseFloat(m.pricing.output) === 0) {
|
|
514
|
-
tags.push("FREE");
|
|
515
|
-
}
|
|
516
|
-
const tagStr = tags.length > 0 ? ` (${tags.join(", ")})` : "";
|
|
517
|
-
return `${modelId}${tagStr}`;
|
|
518
|
-
}).join(", ");
|
|
519
|
-
lines.push(`- ${provider}: ${modelStr}`);
|
|
520
|
-
}
|
|
521
|
-
// Count totals
|
|
522
|
-
const totalProviders = byProvider.size + Object.keys(providerOverrides).length;
|
|
523
|
-
const totalModels = catalog.length;
|
|
524
|
-
lines.push(`- ... and ${totalProviders} total providers with ${totalModels}+ models (use "provider:model" format)`);
|
|
525
|
-
lines.push(`Configure your default model in .polpo/polpo.json or via the POLPO_MODEL env var.`);
|
|
526
|
-
return lines.join("\n");
|
|
527
|
-
}
|
|
528
|
-
// ─── Model Fallback Chain ───────────────────────────
|
|
529
|
-
/**
|
|
530
|
-
* Resolve a model from a fallback chain (synchronous).
|
|
531
|
-
* Tries primary first, then each fallback in order.
|
|
532
|
-
* Returns the first model that has a valid API key.
|
|
533
|
-
*/
|
|
534
|
-
export function resolveModelWithFallback(config) {
|
|
535
|
-
const primary = config.primary;
|
|
536
|
-
if (!primary) {
|
|
537
|
-
throw new Error("No primary model configured. Run 'polpo setup' or set POLPO_MODEL env var.");
|
|
538
|
-
}
|
|
539
|
-
const { provider: primaryProvider } = parseModelSpec(primary);
|
|
540
|
-
if (resolveApiKey(primaryProvider)) {
|
|
541
|
-
try {
|
|
542
|
-
return { model: resolveModel(primary), spec: primary };
|
|
543
|
-
}
|
|
544
|
-
catch {
|
|
545
|
-
// Primary model not found — try fallbacks
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
if (config.fallbacks) {
|
|
549
|
-
for (const fallback of config.fallbacks) {
|
|
550
|
-
const { provider: fbProvider } = parseModelSpec(fallback);
|
|
551
|
-
if (resolveApiKey(fbProvider)) {
|
|
552
|
-
try {
|
|
553
|
-
return { model: resolveModel(fallback), spec: fallback };
|
|
554
|
-
}
|
|
555
|
-
catch {
|
|
556
|
-
// Model not found — try next
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
// Last resort: try primary anyway (will fail at call time with a clear error)
|
|
562
|
-
return { model: resolveModel(primary), spec: primary };
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Resolve a model from a fallback chain (async).
|
|
566
|
-
* Tries primary first, then each fallback in order.
|
|
567
|
-
* Checks the FULL API key resolution chain including OAuth profiles with auto-refresh.
|
|
568
|
-
*/
|
|
569
|
-
export async function resolveModelWithFallbackAsync(config) {
|
|
570
|
-
const primary = config.primary;
|
|
571
|
-
if (!primary) {
|
|
572
|
-
throw new Error("No primary model configured. Run 'polpo setup' or set POLPO_MODEL env var.");
|
|
573
|
-
}
|
|
574
|
-
const { provider: primaryProvider } = parseModelSpec(primary);
|
|
575
|
-
if (await resolveApiKeyAsync(primaryProvider)) {
|
|
576
|
-
try {
|
|
577
|
-
return { model: resolveModel(primary), spec: primary };
|
|
578
|
-
}
|
|
579
|
-
catch {
|
|
580
|
-
// Primary model not found — try fallbacks
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
if (config.fallbacks) {
|
|
584
|
-
for (const fallback of config.fallbacks) {
|
|
585
|
-
const { provider: fbProvider } = parseModelSpec(fallback);
|
|
586
|
-
if (await resolveApiKeyAsync(fbProvider)) {
|
|
587
|
-
try {
|
|
588
|
-
return { model: resolveModel(fallback), spec: fallback };
|
|
589
|
-
}
|
|
590
|
-
catch {
|
|
591
|
-
// Model not found — try next
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
return { model: resolveModel(primary), spec: primary };
|
|
597
|
-
}
|
|
598
|
-
const providerCooldowns = new Map();
|
|
599
|
-
const COOLDOWN_STEPS = [60_000, 300_000, 1_500_000, 3_600_000]; // 1m, 5m, 25m, 1h
|
|
600
|
-
/**
|
|
601
|
-
* Check if a provider is currently in cooldown.
|
|
602
|
-
*/
|
|
603
|
-
export function isProviderInCooldown(provider) {
|
|
604
|
-
const entry = providerCooldowns.get(provider);
|
|
605
|
-
if (!entry)
|
|
606
|
-
return false;
|
|
607
|
-
if (Date.now() >= entry.until) {
|
|
608
|
-
providerCooldowns.delete(provider);
|
|
609
|
-
return false;
|
|
610
|
-
}
|
|
611
|
-
return true;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Mark a provider as temporarily unavailable (cooldown).
|
|
615
|
-
*/
|
|
616
|
-
export function markProviderCooldown(provider, reason) {
|
|
617
|
-
const existing = providerCooldowns.get(provider);
|
|
618
|
-
const errorCount = (existing?.errorCount ?? 0) + 1;
|
|
619
|
-
const stepIdx = Math.min(errorCount - 1, COOLDOWN_STEPS.length - 1);
|
|
620
|
-
const cooldownMs = COOLDOWN_STEPS[stepIdx];
|
|
621
|
-
providerCooldowns.set(provider, {
|
|
622
|
-
until: Date.now() + cooldownMs,
|
|
623
|
-
errorCount,
|
|
624
|
-
reason,
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Clear cooldown for a provider (e.g. after successful call).
|
|
629
|
-
*/
|
|
630
|
-
export function clearProviderCooldown(provider) {
|
|
631
|
-
providerCooldowns.delete(provider);
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Get current cooldown state for all providers.
|
|
635
|
-
*/
|
|
636
|
-
export function getProviderCooldowns() {
|
|
637
|
-
const result = {};
|
|
638
|
-
for (const [provider, entry] of providerCooldowns) {
|
|
639
|
-
if (Date.now() < entry.until) {
|
|
640
|
-
result[provider] = { ...entry };
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
return result;
|
|
644
|
-
}
|
|
645
|
-
// ─── Error Classification ───────────────────────────
|
|
646
|
-
/**
|
|
647
|
-
* Classify an error to determine if it should trigger cooldown or failover.
|
|
648
|
-
*/
|
|
649
|
-
export function classifyProviderError(err) {
|
|
650
|
-
if (!(err instanceof Error)) {
|
|
651
|
-
return { shouldCooldown: false, shouldFailover: false, reason: "unknown" };
|
|
652
|
-
}
|
|
653
|
-
const msg = err.message.toLowerCase();
|
|
654
|
-
// Auth errors — cooldown + failover
|
|
655
|
-
if (msg.includes("401") || msg.includes("unauthorized") || msg.includes("invalid api key") ||
|
|
656
|
-
msg.includes("authentication") || msg.includes("forbidden") || msg.includes("403")) {
|
|
657
|
-
return { shouldCooldown: true, shouldFailover: true, reason: "auth" };
|
|
658
|
-
}
|
|
659
|
-
// Rate limit — cooldown + failover
|
|
660
|
-
if (msg.includes("429") || msg.includes("rate limit") || msg.includes("too many requests") ||
|
|
661
|
-
msg.includes("quota exceeded")) {
|
|
662
|
-
return { shouldCooldown: true, shouldFailover: true, reason: "rate_limit" };
|
|
663
|
-
}
|
|
664
|
-
// Billing — long cooldown + failover
|
|
665
|
-
if (msg.includes("insufficient") || msg.includes("credit") || msg.includes("billing") ||
|
|
666
|
-
msg.includes("payment required") || msg.includes("402")) {
|
|
667
|
-
return { shouldCooldown: true, shouldFailover: true, reason: "billing" };
|
|
668
|
-
}
|
|
669
|
-
// Server errors — short cooldown, failover
|
|
670
|
-
if (msg.includes("500") || msg.includes("502") || msg.includes("503") || msg.includes("504") ||
|
|
671
|
-
msg.includes("overloaded") || msg.includes("service unavailable")) {
|
|
672
|
-
return { shouldCooldown: true, shouldFailover: true, reason: "server_error" };
|
|
673
|
-
}
|
|
674
|
-
// Transient network — no cooldown, retry
|
|
675
|
-
if (msg.includes("timeout") || msg.includes("econnreset") || msg.includes("econnrefused") ||
|
|
676
|
-
msg.includes("socket hang up")) {
|
|
677
|
-
return { shouldCooldown: false, shouldFailover: false, reason: "network" };
|
|
678
|
-
}
|
|
679
|
-
// Non-retryable errors (bad request, invalid model, etc.)
|
|
680
|
-
if (msg.includes("400") || msg.includes("invalid") || msg.includes("not found") ||
|
|
681
|
-
msg.includes("404")) {
|
|
682
|
-
return { shouldCooldown: false, shouldFailover: false, reason: "client_error" };
|
|
683
|
-
}
|
|
684
|
-
return { shouldCooldown: false, shouldFailover: false, reason: "unknown" };
|
|
685
|
-
}
|
|
686
|
-
// ─── ModelConfig Helpers ────────────────────────────
|
|
687
|
-
/**
|
|
688
|
-
* Normalize a model spec that may be string or ModelConfig into a plain string.
|
|
689
|
-
* Useful for APIs that only accept a string model spec.
|
|
690
|
-
*/
|
|
691
|
-
export function resolveModelSpec(spec) {
|
|
692
|
-
if (spec === undefined)
|
|
693
|
-
return undefined;
|
|
694
|
-
if (typeof spec === "string")
|
|
695
|
-
return spec;
|
|
696
|
-
return spec.primary;
|
|
697
|
-
}
|
|
698
|
-
// ─── Billing Disable Integration ────────────────────
|
|
699
|
-
/**
|
|
700
|
-
* Handle billing disable for a provider.
|
|
701
|
-
* OAuth profile store removed — this is now a no-op placeholder.
|
|
702
|
-
* Provider-level cooldown (markProviderCooldown) still applies.
|
|
703
|
-
*/
|
|
704
|
-
async function handleBillingDisable(_provider) {
|
|
705
|
-
// No-op: OAuth profile billing tracking removed.
|
|
706
|
-
// Provider-level cooldown is handled by markProviderCooldown() at the call site.
|
|
707
|
-
}
|
|
708
|
-
// ─── Stream Options Builder ─────────────────────────
|
|
709
|
-
/**
|
|
710
|
-
* Build AI SDK compatible options for generateText/streamText calls.
|
|
711
|
-
*
|
|
712
|
-
* Returns an object with:
|
|
713
|
-
* - providerOptions: reasoning/thinking configuration per provider
|
|
714
|
-
* - maxTokens: max output tokens
|
|
715
|
-
* - headers: additional headers (e.g. for API key passthrough)
|
|
716
|
-
*
|
|
717
|
-
* This replaces the old pi-ai `buildStreamOpts` — callers that need the raw
|
|
718
|
-
* options object for pi-agent-core Agent can still use this. The shape changed
|
|
719
|
-
* but the function signature is preserved for backward compat.
|
|
720
|
-
*/
|
|
721
|
-
export function buildStreamOpts(apiKey, reasoning, maxTokens) {
|
|
722
|
-
const reasoningVal = reasoning && reasoning !== "off" ? reasoning : undefined;
|
|
723
|
-
if (!apiKey && !reasoningVal && !maxTokens)
|
|
724
|
-
return undefined;
|
|
725
|
-
const opts = {};
|
|
726
|
-
if (apiKey)
|
|
727
|
-
opts.apiKey = apiKey;
|
|
728
|
-
if (reasoningVal)
|
|
729
|
-
opts.reasoning = reasoningVal;
|
|
730
|
-
if (maxTokens)
|
|
731
|
-
opts.maxTokens = maxTokens;
|
|
732
|
-
return opts;
|
|
733
|
-
}
|
|
734
|
-
// ─── Query Functions ────────────────────────────────
|
|
735
|
-
/**
|
|
736
|
-
* Simple prompt -> text completion using AI SDK generateText.
|
|
737
|
-
* Integrates with the cooldown system: marks provider cooldown on classified errors,
|
|
738
|
-
* clears cooldown on success. Uses async API key resolution (includes OAuth profiles).
|
|
739
|
-
*/
|
|
740
|
-
export async function queryText(prompt, model, reasoning) {
|
|
741
|
-
const m = resolveModel(model);
|
|
742
|
-
const provider = m.provider;
|
|
743
|
-
try {
|
|
744
|
-
const providerOptions = mapReasoningToProviderOptions(provider, reasoning, m.maxTokens);
|
|
745
|
-
const opts = {
|
|
746
|
-
model: m.aiModel,
|
|
747
|
-
prompt,
|
|
748
|
-
maxOutputTokens: m.maxTokens,
|
|
749
|
-
};
|
|
750
|
-
if (providerOptions)
|
|
751
|
-
opts.providerOptions = providerOptions;
|
|
752
|
-
const response = await generateText(opts);
|
|
753
|
-
const text = response.text.trim();
|
|
754
|
-
// Success — clear any cooldown for this provider
|
|
755
|
-
clearProviderCooldown(provider);
|
|
756
|
-
return {
|
|
757
|
-
text,
|
|
758
|
-
usage: response.usage,
|
|
759
|
-
model: m,
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
catch (err) {
|
|
763
|
-
// Classify and potentially cooldown the provider
|
|
764
|
-
const classified = classifyProviderError(err);
|
|
765
|
-
if (classified.reason === "billing") {
|
|
766
|
-
markProviderCooldown(provider, classified.reason);
|
|
767
|
-
handleBillingDisable(provider);
|
|
768
|
-
}
|
|
769
|
-
else if (classified.shouldCooldown) {
|
|
770
|
-
markProviderCooldown(provider, classified.reason);
|
|
771
|
-
}
|
|
772
|
-
throw err;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Streaming prompt -> text with progress callback.
|
|
777
|
-
* Integrates with the cooldown system. Uses async API key resolution.
|
|
778
|
-
*/
|
|
779
|
-
export async function queryStream(prompt, model, onProgress, reasoning) {
|
|
780
|
-
const m = resolveModel(model);
|
|
781
|
-
const provider = m.provider;
|
|
782
|
-
try {
|
|
783
|
-
const providerOptions = mapReasoningToProviderOptions(provider, reasoning, m.maxTokens);
|
|
784
|
-
const streamOpts = {
|
|
785
|
-
model: m.aiModel,
|
|
786
|
-
prompt,
|
|
787
|
-
maxOutputTokens: m.maxTokens,
|
|
788
|
-
};
|
|
789
|
-
if (providerOptions)
|
|
790
|
-
streamOpts.providerOptions = providerOptions;
|
|
791
|
-
const result = streamText(streamOpts);
|
|
792
|
-
for await (const chunk of result.textStream) {
|
|
793
|
-
if (onProgress) {
|
|
794
|
-
onProgress(chunk);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
// Wait for the full result to get usage data
|
|
798
|
-
const text = (await result.text).trim();
|
|
799
|
-
const usage = await result.usage;
|
|
800
|
-
// Success — clear cooldown
|
|
801
|
-
clearProviderCooldown(provider);
|
|
802
|
-
return {
|
|
803
|
-
text,
|
|
804
|
-
usage,
|
|
805
|
-
model: m,
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
catch (err) {
|
|
809
|
-
const classified = classifyProviderError(err);
|
|
810
|
-
if (classified.reason === "billing") {
|
|
811
|
-
markProviderCooldown(provider, classified.reason);
|
|
812
|
-
handleBillingDisable(provider);
|
|
813
|
-
}
|
|
814
|
-
else if (classified.shouldCooldown) {
|
|
815
|
-
markProviderCooldown(provider, classified.reason);
|
|
816
|
-
}
|
|
817
|
-
throw err;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Query with model fallback chain — tries primary model, then fallbacks.
|
|
822
|
-
* On provider-level errors, marks cooldown and tries next model.
|
|
823
|
-
*/
|
|
824
|
-
export async function queryTextWithFallback(prompt, modelConfig) {
|
|
825
|
-
if (!modelConfig.primary) {
|
|
826
|
-
throw new Error("No primary model configured. Run 'polpo setup' or set POLPO_MODEL env var.");
|
|
827
|
-
}
|
|
828
|
-
const specs = [modelConfig.primary, ...(modelConfig.fallbacks || [])];
|
|
829
|
-
let lastError;
|
|
830
|
-
for (const spec of specs) {
|
|
831
|
-
const { provider } = parseModelSpec(spec);
|
|
832
|
-
// Skip providers in cooldown
|
|
833
|
-
if (isProviderInCooldown(provider))
|
|
834
|
-
continue;
|
|
835
|
-
try {
|
|
836
|
-
const result = await queryText(prompt, spec);
|
|
837
|
-
clearProviderCooldown(provider);
|
|
838
|
-
return { ...result, usedSpec: spec };
|
|
839
|
-
}
|
|
840
|
-
catch (err) {
|
|
841
|
-
lastError = err;
|
|
842
|
-
const classified = classifyProviderError(err);
|
|
843
|
-
if (classified.shouldCooldown) {
|
|
844
|
-
markProviderCooldown(provider, classified.reason);
|
|
845
|
-
}
|
|
846
|
-
if (!classified.shouldFailover) {
|
|
847
|
-
throw err; // Non-retryable error — don't try other providers
|
|
848
|
-
}
|
|
849
|
-
// Continue to next fallback
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
throw lastError ?? new Error("All model providers failed or are in cooldown");
|
|
853
|
-
}
|
|
7
|
+
export * from "@polpo-ai/llm";
|
|
854
8
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C,6BAA6B;QAC7B,IAAI,oBAAoB,CAAC,QAAQ,CAAC;YAAE,SAAS;QAE7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC7C,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YAChC,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,CAAC;YAChB,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAC9C,IAAI,UAAU,CAAC,cAAc,EAAE,CAAC;gBAC9B,oBAAoB,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;gBAC/B,MAAM,GAAG,CAAC,CAAC,kDAAkD;YAC/D,CAAC;YACD,4BAA4B;QAC9B,CAAC;IACH,CAAC;IAED,MAAM,SAAS,IAAI,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AAChF,CAAC"}
|
|
1
|
+
{"version":3,"file":"pi-client.js","sourceRoot":"","sources":["../../src/llm/pi-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polpo-ai",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "The open backend for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,8 +70,9 @@
|
|
|
70
70
|
"nanoid": "^5.1.2",
|
|
71
71
|
"yaml": "^2.7.0",
|
|
72
72
|
"zod": "^4.3.6",
|
|
73
|
-
"@polpo-ai/
|
|
74
|
-
"@polpo-ai/
|
|
73
|
+
"@polpo-ai/core": "0.5.2",
|
|
74
|
+
"@polpo-ai/llm": "0.5.2",
|
|
75
|
+
"@polpo-ai/server": "0.5.2",
|
|
75
76
|
"@polpo-ai/vault-crypto": "0.4.3"
|
|
76
77
|
},
|
|
77
78
|
"optionalDependencies": {
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
"nodemailer": "^8.0.1",
|
|
81
82
|
"playwright-core": "^1.52.0",
|
|
82
83
|
"postgres": "^3.4.0",
|
|
83
|
-
"@polpo-ai/drizzle": "0.5.
|
|
84
|
+
"@polpo-ai/drizzle": "0.5.2"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/better-sqlite3": "^7.6.13",
|
|
@@ -92,12 +93,12 @@
|
|
|
92
93
|
"vitest": "^3.0.4"
|
|
93
94
|
},
|
|
94
95
|
"scripts": {
|
|
95
|
-
"build": "pnpm --filter @polpo-ai/core build && pnpm --filter @polpo-ai/vault-crypto build && pnpm --filter @polpo-ai/drizzle build && pnpm --filter @polpo-ai/tools build && pnpm --filter @polpo-ai/server build && tsc && pnpm --filter @polpo-ai/sdk build && pnpm --filter @polpo-ai/react build",
|
|
96
|
+
"build": "pnpm --filter @polpo-ai/core build && pnpm --filter @polpo-ai/vault-crypto build && pnpm --filter @polpo-ai/drizzle build && pnpm --filter @polpo-ai/llm build && pnpm --filter @polpo-ai/tools build && pnpm --filter @polpo-ai/server build && tsc && pnpm --filter @polpo-ai/sdk build && pnpm --filter @polpo-ai/react build",
|
|
96
97
|
"dev": "tsc --watch",
|
|
97
98
|
"start": "node dist/cli/index.js",
|
|
98
99
|
"test": "vitest",
|
|
99
100
|
"test:coverage": "vitest run --coverage",
|
|
100
|
-
"typecheck": "pnpm --filter @polpo-ai/core build && pnpm --filter @polpo-ai/vault-crypto build && pnpm --filter @polpo-ai/drizzle build && pnpm --filter @polpo-ai/tools build && pnpm --filter @polpo-ai/server build && ./node_modules/.bin/tsc --noEmit",
|
|
101
|
+
"typecheck": "pnpm --filter @polpo-ai/core build && pnpm --filter @polpo-ai/vault-crypto build && pnpm --filter @polpo-ai/drizzle build && pnpm --filter @polpo-ai/llm build && pnpm --filter @polpo-ai/tools build && pnpm --filter @polpo-ai/server build && ./node_modules/.bin/tsc --noEmit",
|
|
101
102
|
"clean": "rm -rf dist"
|
|
102
103
|
}
|
|
103
104
|
}
|