@code-yeongyu/senpi-ai 2026.9.30 → 2026.10.1
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/README.md +189 -19
- package/dist/api/anthropic-messages.js +168 -32
- package/dist/api/azure-openai-responses.js +23 -10
- package/dist/api/bedrock-converse-stream.js +12 -4
- package/dist/api/cloudflare-workers-ai-system-one.d.ts +4 -0
- package/dist/api/cloudflare-workers-ai-system-one.js +43 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.d.ts +3 -0
- package/dist/api/cloudflare-workers-ai-system-one.lazy.js +4 -0
- package/dist/api/cloudflare.d.ts +2 -0
- package/dist/api/cloudflare.js +2 -0
- package/dist/api/context-room.d.ts +2 -2
- package/dist/api/cursor-agent.js +19 -10
- package/dist/api/devin-agent/request.d.ts +9 -9
- package/dist/api/devin-agent/request.js +14 -10
- package/dist/api/google-generative-ai.js +20 -80
- package/dist/api/google-shared.d.ts +13 -4
- package/dist/api/google-shared.js +54 -4
- package/dist/api/google-vertex.js +19 -62
- package/dist/api/llama-cpp-classify.d.ts +33 -0
- package/dist/api/llama-cpp-classify.js +365 -0
- package/dist/api/llama-cpp-classify.lazy.d.ts +3 -0
- package/dist/api/llama-cpp-classify.lazy.js +4 -0
- package/dist/api/mistral-conversations.d.ts +1 -1
- package/dist/api/mistral-conversations.js +36 -29
- package/dist/api/openai-codex-responses.d.ts +1 -1
- package/dist/api/openai-codex-responses.js +72 -37
- package/dist/api/openai-completions.d.ts +3 -2
- package/dist/api/openai-completions.js +76 -50
- package/dist/api/openai-images-params.d.ts +2 -2
- package/dist/api/openai-images.d.ts +1 -1
- package/dist/api/openai-responses-shared.d.ts +31 -8
- package/dist/api/openai-responses-shared.js +115 -27
- package/dist/api/openai-responses.d.ts +1 -1
- package/dist/api/openai-responses.js +38 -33
- package/dist/api/openrouter-images.d.ts +2 -1
- package/dist/api/openrouter-images.js +1 -0
- package/dist/api/pi-messages.d.ts +3 -3
- package/dist/api/pi-messages.js +3 -2
- package/dist/api/simple-options.d.ts +2 -2
- package/dist/api/simple-options.js +1 -0
- package/dist/api/system-one-shared.d.ts +23 -0
- package/dist/api/system-one-shared.js +183 -0
- package/dist/api/transform-messages.js +5 -2
- package/dist/api/typesafe-system-one.d.ts +4 -0
- package/dist/api/typesafe-system-one.js +19 -0
- package/dist/api/typesafe-system-one.lazy.d.ts +3 -0
- package/dist/api/typesafe-system-one.lazy.js +4 -0
- package/dist/api-registry.d.ts +3 -3
- package/dist/auth/helpers.js +1 -1
- package/dist/auth/oauth/anthropic-callback-listener.js +1 -1
- package/dist/auth/oauth/callback-server.d.ts +55 -0
- package/dist/auth/oauth/callback-server.js +146 -0
- package/dist/auth/oauth/chatgpt-subscription.d.ts +1 -1
- package/dist/auth/oauth/chatgpt-subscription.js +20 -124
- package/dist/auth/oauth/devin-callback.js +1 -1
- package/dist/auth/oauth/load.d.ts +4 -0
- package/dist/auth/oauth/load.js +10 -0
- package/dist/auth/oauth/meta.d.ts +17 -0
- package/dist/auth/oauth/meta.js +190 -0
- package/dist/auth/oauth/openai-chatgpt.d.ts +9 -0
- package/dist/auth/oauth/openai-chatgpt.js +266 -0
- package/dist/auth/oauth/openrouter.d.ts +1 -1
- package/dist/auth/oauth/openrouter.js +19 -138
- package/dist/auth/oauth/radius.d.ts +1 -1
- package/dist/auth/oauth/radius.js +21 -89
- package/dist/auth/resolve.d.ts +3 -8
- package/dist/auth/resolve.js +3 -18
- package/dist/auth/types.d.ts +10 -1
- package/dist/bun-oauth.js +4 -0
- package/dist/cli.js +3 -1
- package/dist/compat.js +17 -14
- package/dist/env-api-keys.js +2 -0
- package/dist/image-models.d.ts +19 -8
- package/dist/image-models.js +14 -13
- package/dist/images-api-registry.d.ts +8 -8
- package/dist/images.d.ts +7 -2
- package/dist/images.js +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/model-catalog.d.ts +27 -9
- package/dist/model-catalog.js +24 -2
- package/dist/model.d.ts +13 -13
- package/dist/models-store.d.ts +3 -2
- package/dist/models.d.ts +106 -36
- package/dist/models.generated.d.ts +142 -42
- package/dist/models.generated.js +142 -42
- package/dist/models.js +174 -36
- package/dist/providers/alibaba-token-plan.models.d.ts +4 -2
- package/dist/providers/alibaba-token-plan.models.js +4 -2
- package/dist/providers/all.d.ts +72 -19
- package/dist/providers/all.js +28 -22
- package/dist/providers/amazon-bedrock.models.d.ts +4 -2
- package/dist/providers/amazon-bedrock.models.js +4 -2
- package/dist/providers/ant-ling.models.d.ts +4 -2
- package/dist/providers/ant-ling.models.js +4 -2
- package/dist/providers/anthropic.models.d.ts +4 -2
- package/dist/providers/anthropic.models.js +4 -2
- package/dist/providers/azure-openai-responses.models.d.ts +4 -2
- package/dist/providers/azure-openai-responses.models.js +4 -2
- package/dist/providers/bai.models.d.ts +4 -2
- package/dist/providers/bai.models.js +4 -2
- package/dist/providers/baseten.models.d.ts +4 -2
- package/dist/providers/baseten.models.js +4 -2
- package/dist/providers/cerebras.models.d.ts +4 -2
- package/dist/providers/cerebras.models.js +4 -2
- package/dist/providers/chatgpt-subscription.models.d.ts +4 -2
- package/dist/providers/chatgpt-subscription.models.js +4 -2
- package/dist/providers/cloudflare-ai-gateway.models.d.ts +4 -2
- package/dist/providers/cloudflare-ai-gateway.models.js +4 -2
- package/dist/providers/cloudflare-stream.d.ts +6 -2
- package/dist/providers/cloudflare-stream.js +6 -0
- package/dist/providers/cloudflare-workers-ai.js +10 -3
- package/dist/providers/cloudflare-workers-ai.models.d.ts +4 -2
- package/dist/providers/cloudflare-workers-ai.models.js +4 -2
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/alibaba-token-plan.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/ant-ling.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure-openai-responses.json +1 -1
- package/dist/providers/data/bai.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cerebras.json +1 -1
- package/dist/providers/data/chatgpt-subscription.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/deepseek.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/google-vertex.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/groq.json +1 -1
- package/dist/providers/data/huggingface.json +1 -1
- package/dist/providers/data/meta.json +1 -0
- package/dist/providers/data/minimax-cn.json +1 -1
- package/dist/providers/data/minimax.json +1 -1
- package/dist/providers/data/mistral.json +1 -1
- package/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/providers/data/moonshotai.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/opengateway.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/providers/data/radius.json +1 -0
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/typesafe.json +1 -0
- package/dist/providers/data/venice.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xai.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/dist/providers/deepseek.models.d.ts +4 -2
- package/dist/providers/deepseek.models.js +4 -2
- package/dist/providers/faux.d.ts +7 -2
- package/dist/providers/faux.js +31 -22
- package/dist/providers/fireworks.models.d.ts +4 -2
- package/dist/providers/fireworks.models.js +4 -2
- package/dist/providers/github-copilot.models.d.ts +4 -2
- package/dist/providers/github-copilot.models.js +4 -2
- package/dist/providers/google-vertex.models.d.ts +4 -2
- package/dist/providers/google-vertex.models.js +4 -2
- package/dist/providers/google.models.d.ts +4 -2
- package/dist/providers/google.models.js +4 -2
- package/dist/providers/groq.models.d.ts +4 -2
- package/dist/providers/groq.models.js +4 -2
- package/dist/providers/huggingface.models.d.ts +4 -2
- package/dist/providers/huggingface.models.js +4 -2
- package/dist/providers/images/register-builtins.d.ts +2 -2
- package/dist/providers/kimi-coding.models.d.ts +54 -7
- package/dist/providers/kimi-coding.models.js +34 -7
- package/dist/providers/meta.d.ts +3 -0
- package/dist/providers/meta.js +24 -0
- package/dist/providers/meta.models.d.ts +6 -0
- package/dist/providers/meta.models.js +8 -0
- package/dist/providers/minimax-cn.models.d.ts +4 -2
- package/dist/providers/minimax-cn.models.js +4 -2
- package/dist/providers/minimax.models.d.ts +4 -2
- package/dist/providers/minimax.models.js +4 -2
- package/dist/providers/mistral.models.d.ts +4 -2
- package/dist/providers/mistral.models.js +4 -2
- package/dist/providers/moonshotai-cn.models.d.ts +4 -2
- package/dist/providers/moonshotai-cn.models.js +4 -2
- package/dist/providers/moonshotai.models.d.ts +4 -2
- package/dist/providers/moonshotai.models.js +4 -2
- package/dist/providers/nvidia.models.d.ts +4 -2
- package/dist/providers/nvidia.models.js +4 -2
- package/dist/providers/openai.js +4 -2
- package/dist/providers/openai.models.d.ts +4 -2
- package/dist/providers/openai.models.js +4 -2
- package/dist/providers/opencode-go.models.d.ts +4 -2
- package/dist/providers/opencode-go.models.js +4 -2
- package/dist/providers/opencode.d.ts +3 -1
- package/dist/providers/opencode.js +5 -2
- package/dist/providers/opencode.models.d.ts +4 -2
- package/dist/providers/opencode.models.js +4 -2
- package/dist/providers/opengateway.models.d.ts +4 -2
- package/dist/providers/opengateway.models.js +4 -2
- package/dist/providers/openrouter.js +11 -2
- package/dist/providers/openrouter.models.d.ts +4 -2
- package/dist/providers/openrouter.models.js +4 -2
- package/dist/providers/qwen-token-plan-cn.models.d.ts +4 -2
- package/dist/providers/qwen-token-plan-cn.models.js +4 -2
- package/dist/providers/qwen-token-plan-individual.models.d.ts +4 -2
- package/dist/providers/qwen-token-plan-individual.models.js +4 -2
- package/dist/providers/qwen-token-plan.models.d.ts +4 -2
- package/dist/providers/qwen-token-plan.models.js +4 -2
- package/dist/providers/radius.js +19 -5
- package/dist/providers/radius.models.d.ts +6 -0
- package/dist/providers/radius.models.js +8 -0
- package/dist/providers/together.models.d.ts +4 -2
- package/dist/providers/together.models.js +4 -2
- package/dist/providers/typesafe.d.ts +3 -0
- package/dist/providers/typesafe.js +18 -0
- package/dist/providers/typesafe.models.d.ts +6 -0
- package/dist/providers/typesafe.models.js +8 -0
- package/dist/providers/venice.models.d.ts +4 -2
- package/dist/providers/venice.models.js +4 -2
- package/dist/providers/vercel-ai-gateway.js +5 -2
- package/dist/providers/vercel-ai-gateway.models.d.ts +4 -2
- package/dist/providers/vercel-ai-gateway.models.js +4 -2
- package/dist/providers/xai.models.d.ts +4 -2
- package/dist/providers/xai.models.js +4 -2
- package/dist/providers/xiaomi-token-plan-ams.models.d.ts +4 -2
- package/dist/providers/xiaomi-token-plan-ams.models.js +4 -2
- package/dist/providers/xiaomi-token-plan-cn.models.d.ts +4 -2
- package/dist/providers/xiaomi-token-plan-cn.models.js +4 -2
- package/dist/providers/xiaomi-token-plan-sgp.models.d.ts +4 -2
- package/dist/providers/xiaomi-token-plan-sgp.models.js +4 -2
- package/dist/providers/xiaomi.models.d.ts +4 -2
- package/dist/providers/xiaomi.models.js +4 -2
- package/dist/providers/zai-coding-cn.models.d.ts +4 -2
- package/dist/providers/zai-coding-cn.models.js +4 -2
- package/dist/providers/zai.models.d.ts +4 -2
- package/dist/providers/zai.models.js +4 -2
- package/dist/tool-call-middleware/context-transformer.d.ts +8 -5
- package/dist/tool-call-middleware/context-transformer.js +44 -15
- package/dist/types.d.ts +262 -28
- package/dist/utils/diagnostics.d.ts +3 -2
- package/dist/utils/estimate.d.ts +2 -2
- package/dist/utils/estimate.js +22 -30
- package/dist/utils/headers.d.ts +1 -1
- package/dist/utils/headers.js +10 -8
- package/dist/utils/model-operations.d.ts +11 -0
- package/dist/utils/model-operations.js +47 -0
- package/dist/utils/models-error.d.ts +8 -0
- package/dist/utils/models-error.js +18 -0
- package/dist/utils/overflow.d.ts +1 -0
- package/dist/utils/overflow.js +11 -5
- package/dist/utils/prompt-cache-ttl.js +10 -3
- package/dist/utils/retry.js +9 -0
- package/dist/utils/text.d.ts +9 -1
- package/dist/utils/text.js +26 -0
- package/dist/utils/transcript.d.ts +85 -0
- package/dist/utils/transcript.js +205 -0
- package/package.json +3 -4
- package/dist/image-models.generated.d.ts +0 -925
- package/dist/image-models.generated.js +0 -927
- package/dist/images-models.d.ts +0 -95
- package/dist/images-models.js +0 -141
- package/dist/providers/openai-images.d.ts +0 -3
- package/dist/providers/openai-images.js +0 -16
- package/dist/providers/openrouter-images.d.ts +0 -3
- package/dist/providers/openrouter-images.js +0 -22
- /package/dist/{auth/oauth → utils}/oauth-page.d.ts +0 -0
- /package/dist/{auth/oauth → utils}/oauth-page.js +0 -0
package/dist/auth/resolve.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { operationSignal, raceWithAbortSignal } from "../utils/abort.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ModelsError } from "../utils/models-error.js";
|
|
3
3
|
import { OAuthRefreshExchangeError, OAuthRefreshStoreError, projectOAuthSlot, refreshOAuthCredential, } from "./oauth-refresh.js";
|
|
4
4
|
import { projectSlot } from "./pool/slots.js";
|
|
5
|
+
export { ModelsError } from "../utils/models-error.js";
|
|
5
6
|
/**
|
|
6
7
|
* Prefix of the auth-miss every resolution site raises when a provider has no
|
|
7
8
|
* usable credential. Consumers key recovery decisions off this exact wording,
|
|
@@ -12,24 +13,8 @@ export const PROVIDER_NOT_CONFIGURED_PREFIX = "Provider is not configured: ";
|
|
|
12
13
|
export function providerNotConfiguredMessage(providerId) {
|
|
13
14
|
return `${PROVIDER_NOT_CONFIGURED_PREFIX}${providerId}`;
|
|
14
15
|
}
|
|
15
|
-
export class ModelsError extends Error {
|
|
16
|
-
constructor(code, message, options) {
|
|
17
|
-
super(withCauseDetail(message, options?.cause), options);
|
|
18
|
-
this.name = "ModelsError";
|
|
19
|
-
this.code = code;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Callers surface `error.message` only, so keep the underlying reason in it. */
|
|
23
|
-
function withCauseDetail(message, cause) {
|
|
24
|
-
if (cause === undefined || cause === null)
|
|
25
|
-
return message;
|
|
26
|
-
const detail = formatThrownValue(cause).trim();
|
|
27
|
-
if (!detail || message.includes(detail))
|
|
28
|
-
return message;
|
|
29
|
-
return `${message}: ${detail}`;
|
|
30
|
-
}
|
|
31
16
|
/**
|
|
32
|
-
* Auth resolution shared by
|
|
17
|
+
* Auth resolution shared by all operations in a `Models` collection.
|
|
33
18
|
* A stored credential owns the provider: ambient/env is consulted only when
|
|
34
19
|
* nothing is stored. No silent env fallback after a failed refresh or for a
|
|
35
20
|
* credential type without a matching handler.
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -212,6 +212,15 @@ export interface ApiKeyAuth {
|
|
|
212
212
|
signal: AbortSignal;
|
|
213
213
|
}): Promise<AuthResult | undefined>;
|
|
214
214
|
}
|
|
215
|
+
/** App-supplied context for `Models.login`. */
|
|
216
|
+
export interface LoginOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Returns the stable ID of this app installation, e.g. sent to OpenAI as its
|
|
219
|
+
* agent host ID. Called only by login flows that need it, so apps can create
|
|
220
|
+
* the ID on first use and must return the same ID on every later call.
|
|
221
|
+
*/
|
|
222
|
+
getDeviceId?: () => string;
|
|
223
|
+
}
|
|
215
224
|
/**
|
|
216
225
|
* OAuth auth. The `refresh`/`toAuth` split lets `Models` own the locked
|
|
217
226
|
* refresh pattern: `refresh` produces a credential, `toAuth` derives request
|
|
@@ -231,7 +240,7 @@ export interface OAuthAuth {
|
|
|
231
240
|
* request before surfacing the failure.
|
|
232
241
|
*/
|
|
233
242
|
rejectedTokenStatuses?: readonly number[];
|
|
234
|
-
login(interaction: ProviderAuthInteraction): Promise<OAuthCredential>;
|
|
243
|
+
login(interaction: ProviderAuthInteraction, options?: LoginOptions): Promise<OAuthCredential>;
|
|
235
244
|
/**
|
|
236
245
|
* Exchange the refresh token. Network call; throws on failure
|
|
237
246
|
* (invalid_grant etc.). `Models` runs this under the store lock.
|
package/dist/bun-oauth.js
CHANGED
|
@@ -5,6 +5,8 @@ import { devinOAuth } from "./auth/oauth/devin.js";
|
|
|
5
5
|
import { githubCopilotOAuth } from "./auth/oauth/github-copilot.js";
|
|
6
6
|
import { kimiCodingOAuth } from "./auth/oauth/kimi-coding.js";
|
|
7
7
|
import { registerBundledOAuthFlowLoaders } from "./auth/oauth/load.js";
|
|
8
|
+
import { metaOAuth } from "./auth/oauth/meta.js";
|
|
9
|
+
import { openaiChatGPTOAuth } from "./auth/oauth/openai-chatgpt.js";
|
|
8
10
|
import { openRouterOAuth } from "./auth/oauth/openrouter.js";
|
|
9
11
|
import { createRadiusOAuth } from "./auth/oauth/radius.js";
|
|
10
12
|
import { xaiOAuth } from "./auth/oauth/xai.js";
|
|
@@ -13,9 +15,11 @@ export function registerBunOAuthFlows() {
|
|
|
13
15
|
registerBundledOAuthFlowLoaders({
|
|
14
16
|
anthropic: () => anthropicOAuth,
|
|
15
17
|
chatgptSubscription: () => chatgptSubscriptionOAuth,
|
|
18
|
+
openaiChatGPT: () => openaiChatGPTOAuth,
|
|
16
19
|
githubCopilot: () => githubCopilotOAuth,
|
|
17
20
|
openrouter: () => openRouterOAuth,
|
|
18
21
|
kimiCoding: () => kimiCodingOAuth,
|
|
22
|
+
meta: () => metaOAuth,
|
|
19
23
|
xai: () => xaiOAuth,
|
|
20
24
|
cursor: () => cursorOAuth,
|
|
21
25
|
devin: () => devinOAuth,
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { createInterface } from "node:readline";
|
|
4
5
|
import { builtinProviders } from "./providers/all.js";
|
|
@@ -40,6 +41,7 @@ async function login(providerId) {
|
|
|
40
41
|
throw new Error(`Unknown provider: ${providerId}`);
|
|
41
42
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
42
43
|
try {
|
|
44
|
+
// This dev CLI does not persist an installation ID; apps should reuse one across logins.
|
|
43
45
|
const credential = await provider.auth.oauth.login({
|
|
44
46
|
signal: new AbortController().signal,
|
|
45
47
|
prompt: (authPrompt) => answerPrompt(rl, authPrompt),
|
|
@@ -60,7 +62,7 @@ async function login(providerId) {
|
|
|
60
62
|
break;
|
|
61
63
|
}
|
|
62
64
|
},
|
|
63
|
-
});
|
|
65
|
+
}, { getDeviceId: randomUUID });
|
|
64
66
|
const auth = loadAuth();
|
|
65
67
|
auth[providerId] = credential;
|
|
66
68
|
saveAuth(auth);
|
package/dist/compat.js
CHANGED
|
@@ -46,6 +46,7 @@ import { getEnvApiKey } from "./env-api-keys.js";
|
|
|
46
46
|
import { builtinModels, getBuiltinModel, getBuiltinModels, getBuiltinProviders } from "./providers/all.js";
|
|
47
47
|
import { createFauxCore } from "./providers/faux.js";
|
|
48
48
|
import { getProtocol, getToolCallFormat, transformContext, wrapStreamWithToolCallMiddleware, } from "./tool-call-middleware/index.js";
|
|
49
|
+
import { getCurrentTools, normalizeContext } from "./utils/transcript.js";
|
|
49
50
|
/** @deprecated Static catalog read. Use `getBuiltinModel` from "@earendil-works/pi-ai/providers/all" or `Models.getModel()`. */
|
|
50
51
|
export const getModel = getBuiltinModel;
|
|
51
52
|
/** @deprecated Static catalog read. Use `getBuiltinModels` from "@earendil-works/pi-ai/providers/all" or `Models.getModels()`. */
|
|
@@ -137,44 +138,46 @@ function resolveApiProvider(api) {
|
|
|
137
138
|
return provider;
|
|
138
139
|
}
|
|
139
140
|
export function stream(model, context, options) {
|
|
141
|
+
const transcript = normalizeContext(context);
|
|
140
142
|
const format = getToolCallFormat(model);
|
|
141
|
-
|
|
143
|
+
const tools = getCurrentTools(transcript.messages);
|
|
144
|
+
if (format && tools.length > 0) {
|
|
142
145
|
const protocol = getProtocol(format);
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
return wrapStreamWithToolCallMiddleware(innerStream, protocol, context.tools);
|
|
146
|
+
const innerStream = stream(model, transformContext(transcript, protocol), options);
|
|
147
|
+
return wrapStreamWithToolCallMiddleware(innerStream, protocol, tools);
|
|
146
148
|
}
|
|
147
149
|
const builtinProvider = getBuiltinProviderForModel(model);
|
|
148
150
|
if (builtinProvider) {
|
|
149
151
|
if (model.provider.startsWith("cloudflare-") && !hasResolvedCloudflareAuth(options)) {
|
|
150
|
-
return compatModels.stream(model,
|
|
152
|
+
return compatModels.stream(model, transcript, options);
|
|
151
153
|
}
|
|
152
|
-
return builtinProvider.stream(model,
|
|
154
|
+
return builtinProvider.stream(model, transcript, withEnvApiKey(model, options));
|
|
153
155
|
}
|
|
154
156
|
const provider = resolveApiProvider(model.api);
|
|
155
|
-
return provider.stream(model,
|
|
157
|
+
return provider.stream(model, transcript, withEnvApiKey(model, options));
|
|
156
158
|
}
|
|
157
159
|
export async function complete(model, context, options) {
|
|
158
160
|
const s = stream(model, context, options);
|
|
159
161
|
return s.result();
|
|
160
162
|
}
|
|
161
163
|
export function streamSimple(model, context, options) {
|
|
164
|
+
const transcript = normalizeContext(context);
|
|
162
165
|
const format = getToolCallFormat(model);
|
|
163
|
-
|
|
166
|
+
const tools = getCurrentTools(transcript.messages);
|
|
167
|
+
if (format && tools.length > 0) {
|
|
164
168
|
const protocol = getProtocol(format);
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
return wrapStreamWithToolCallMiddleware(innerStream, protocol, context.tools);
|
|
169
|
+
const innerStream = streamSimple(model, transformContext(transcript, protocol), options);
|
|
170
|
+
return wrapStreamWithToolCallMiddleware(innerStream, protocol, tools);
|
|
168
171
|
}
|
|
169
172
|
const builtinProvider = getBuiltinProviderForModel(model);
|
|
170
173
|
if (builtinProvider) {
|
|
171
174
|
if (model.provider.startsWith("cloudflare-") && !hasResolvedCloudflareAuth(options)) {
|
|
172
|
-
return compatModels.streamSimple(model,
|
|
175
|
+
return compatModels.streamSimple(model, transcript, options);
|
|
173
176
|
}
|
|
174
|
-
return builtinProvider.streamSimple(model,
|
|
177
|
+
return builtinProvider.streamSimple(model, transcript, withEnvApiKey(model, options));
|
|
175
178
|
}
|
|
176
179
|
const provider = resolveApiProvider(model.api);
|
|
177
|
-
return provider.streamSimple(model,
|
|
180
|
+
return provider.streamSimple(model, transcript, withEnvApiKey(model, options));
|
|
178
181
|
}
|
|
179
182
|
export async function completeSimple(model, context, options) {
|
|
180
183
|
const s = streamSimple(model, context, options);
|
package/dist/env-api-keys.js
CHANGED
|
@@ -91,6 +91,7 @@ export function getApiKeyEnvVars(provider) {
|
|
|
91
91
|
cerebras: "CEREBRAS_API_KEY",
|
|
92
92
|
venice: "VENICE_API_KEY",
|
|
93
93
|
xai: "XAI_API_KEY",
|
|
94
|
+
typesafe: "TYPESAFE_API_KEY",
|
|
94
95
|
radius: "RADIUS_API_KEY",
|
|
95
96
|
openrouter: "OPENROUTER_API_KEY",
|
|
96
97
|
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
|
@@ -110,6 +111,7 @@ export function getApiKeyEnvVars(provider) {
|
|
|
110
111
|
opencode: "OPENCODE_API_KEY",
|
|
111
112
|
"opencode-go": "OPENCODE_API_KEY",
|
|
112
113
|
"kimi-coding": "KIMI_API_KEY",
|
|
114
|
+
meta: "META_API_KEY",
|
|
113
115
|
"cloudflare-workers-ai": "CLOUDFLARE_API_KEY",
|
|
114
116
|
"cloudflare-ai-gateway": "CLOUDFLARE_API_KEY",
|
|
115
117
|
xiaomi: "XIAOMI_API_KEY",
|
package/dist/image-models.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { IMAGE_MODELS } from "./
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { IMAGE_MODELS } from "./models.generated.ts";
|
|
2
|
+
import type { ImageApi, ImageModel } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Compat reads of the generated catalog restricted to image models. New code
|
|
5
|
+
* uses `Models.getModelOfType("image", ...)` or `getBuiltinImageModel()` from `providers/all`.
|
|
6
|
+
*/
|
|
7
|
+
type Catalog = typeof IMAGE_MODELS;
|
|
8
|
+
type ImageModelIds<TProvider extends keyof Catalog> = keyof Catalog[TProvider];
|
|
9
|
+
/** Built-in providers with at least one image model in the generated catalog. */
|
|
10
|
+
export type BuiltinImageProvider = {
|
|
11
|
+
[TProvider in keyof Catalog]: [ImageModelIds<TProvider>] extends [never] ? never : TProvider;
|
|
12
|
+
}[keyof Catalog];
|
|
13
|
+
type BuiltinImageModel<TProvider extends BuiltinImageProvider, TModelId extends ImageModelIds<TProvider>> = Catalog[TProvider][TModelId] extends ImageModel<infer TApi extends ImageApi> ? ImageModel<TApi> : never;
|
|
14
|
+
/** @deprecated Static catalog read. Use `getBuiltinImageModel` from "@earendil-works/pi-ai/providers/all" or `Models.getModelOfType("image", ...)`. */
|
|
15
|
+
export declare function getImageModel<TProvider extends BuiltinImageProvider, TModelId extends ImageModelIds<TProvider>>(provider: TProvider, modelId: TModelId): BuiltinImageModel<TProvider, TModelId>;
|
|
16
|
+
/** @deprecated Static catalog read. Use `Models.getProviders()`. */
|
|
17
|
+
export declare function getImageProviders(): BuiltinImageProvider[];
|
|
18
|
+
/** @deprecated Static catalog read. Use `getBuiltinImageModels` from "@earendil-works/pi-ai/providers/all" or `Models.getModelsOfType("image")`. */
|
|
19
|
+
export declare function getImageModels<TProvider extends BuiltinImageProvider>(provider: TProvider): BuiltinImageModel<TProvider, ImageModelIds<TProvider>>[];
|
|
9
20
|
export {};
|
|
10
21
|
//# sourceMappingURL=image-models.d.ts.map
|
package/dist/image-models.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { IMAGE_MODELS } from "./
|
|
2
|
-
const
|
|
1
|
+
import { IMAGE_MODELS } from "./models.generated.js";
|
|
2
|
+
const imageModelsByProvider = new Map();
|
|
3
3
|
for (const [provider, models] of Object.entries(IMAGE_MODELS)) {
|
|
4
|
-
const
|
|
5
|
-
for (const
|
|
6
|
-
|
|
4
|
+
const imageModels = new Map();
|
|
5
|
+
for (const model of Object.values(models)) {
|
|
6
|
+
imageModels.set(model.id, model);
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
if (imageModels.size > 0)
|
|
9
|
+
imageModelsByProvider.set(provider, imageModels);
|
|
9
10
|
}
|
|
11
|
+
/** @deprecated Static catalog read. Use `getBuiltinImageModel` from "@earendil-works/pi-ai/providers/all" or `Models.getModelOfType("image", ...)`. */
|
|
10
12
|
export function getImageModel(provider, modelId) {
|
|
11
|
-
|
|
12
|
-
return providerModels?.get(modelId);
|
|
13
|
+
return imageModelsByProvider.get(provider)?.get(modelId);
|
|
13
14
|
}
|
|
15
|
+
/** @deprecated Static catalog read. Use `Models.getProviders()`. */
|
|
14
16
|
export function getImageProviders() {
|
|
15
|
-
return Array.from(
|
|
17
|
+
return Array.from(imageModelsByProvider.keys());
|
|
16
18
|
}
|
|
19
|
+
/** @deprecated Static catalog read. Use `getBuiltinImageModels` from "@earendil-works/pi-ai/providers/all" or `Models.getModelsOfType("image")`. */
|
|
17
20
|
export function getImageModels(provider) {
|
|
18
|
-
const models =
|
|
19
|
-
return models
|
|
20
|
-
? Array.from(models.values())
|
|
21
|
-
: [];
|
|
21
|
+
const models = imageModelsByProvider.get(provider);
|
|
22
|
+
return models ? Array.from(models.values()) : [];
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=image-models.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AssistantImages,
|
|
2
|
-
export type ImagesApiFunction = (model:
|
|
3
|
-
export interface ImagesApiProvider<TApi extends
|
|
1
|
+
import type { AssistantImages, ImageApi, ImageModel, ImagesContext, ImagesFunction, ImagesOptions } from "./types.ts";
|
|
2
|
+
export type ImagesApiFunction = (model: ImageModel<ImageApi>, context: ImagesContext, options?: ImagesOptions) => Promise<AssistantImages>;
|
|
3
|
+
export interface ImagesApiProvider<TApi extends ImageApi = ImageApi, TOptions extends ImagesOptions = ImagesOptions> {
|
|
4
4
|
api: TApi;
|
|
5
|
-
generateImages: ImagesFunction<
|
|
5
|
+
generateImages: ImagesFunction<TOptions>;
|
|
6
6
|
}
|
|
7
7
|
export interface ImagesApiProviderInternal {
|
|
8
|
-
api:
|
|
8
|
+
api: ImageApi;
|
|
9
9
|
generateImages: ImagesApiFunction;
|
|
10
10
|
}
|
|
11
11
|
export type RegisteredImagesApiProvider = {
|
|
@@ -20,10 +20,10 @@ export interface ImagesProviderScopeAccess {
|
|
|
20
20
|
/** Installs the optional node-only scope lookup without importing node APIs here. */
|
|
21
21
|
export declare function installImagesProviderScopeAccessor(accessor: () => ImagesProviderScopeAccess | undefined): void;
|
|
22
22
|
export declare function setImagesProviderScopeStrictMode(enabled: boolean): void;
|
|
23
|
-
export declare function registerImagesApiProvider<TApi extends
|
|
23
|
+
export declare function registerImagesApiProvider<TApi extends ImageApi, TOptions extends ImagesOptions>(provider: ImagesApiProvider<TApi, TOptions>, sourceId?: string): void;
|
|
24
24
|
/** Registers a builtin once, retaining its immutable identity for active scopes. */
|
|
25
|
-
export declare function registerBuiltinImagesApiProvider<TApi extends
|
|
26
|
-
export declare function getImagesApiProvider(api:
|
|
25
|
+
export declare function registerBuiltinImagesApiProvider<TApi extends ImageApi, TOptions extends ImagesOptions>(provider: ImagesApiProvider<TApi, TOptions>): void;
|
|
26
|
+
export declare function getImagesApiProvider(api: ImageApi): ImagesApiProviderInternal | undefined;
|
|
27
27
|
export declare function getImagesApiProviders(): ImagesApiProviderInternal[];
|
|
28
28
|
export declare function unregisterImagesApiProviders(sourceId: string): void;
|
|
29
29
|
export declare function clearImagesApiProviders(): void;
|
package/dist/images.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import "./providers/images/register-builtins.ts";
|
|
2
|
-
import type { AssistantImages,
|
|
2
|
+
import type { AssistantImages, ImageApi, ImageModel, ImagesContext, ProviderImagesOptions } from "./types.ts";
|
|
3
3
|
export { type OpenAIImageBackground, type OpenAIImageModeration, type OpenAIImageOutputFormat, type OpenAIImageOutputOptions, type OpenAIImageQuality, type OpenAIImageSize, type OpenAIImagesOptions, parseOpenAIImageOutputOptions, parseOpenAIImageSize, } from "./api/openai-images-params.ts";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Global image generation dispatched on `model.api` through the images api
|
|
6
|
+
* registry. Auth must be passed explicitly via `options.apiKey`; prefer
|
|
7
|
+
* `Models.generateImages()`, which resolves provider auth.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateImages(model: ImageModel<ImageApi>, context: ImagesContext, options?: ProviderImagesOptions): Promise<AssistantImages>;
|
|
5
10
|
//# sourceMappingURL=images.d.ts.map
|
package/dist/images.js
CHANGED
|
@@ -8,6 +8,11 @@ function resolveImagesApiProvider(api) {
|
|
|
8
8
|
}
|
|
9
9
|
return provider;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Global image generation dispatched on `model.api` through the images api
|
|
13
|
+
* registry. Auth must be passed explicitly via `options.apiKey`; prefer
|
|
14
|
+
* `Models.generateImages()`, which resolves provider auth.
|
|
15
|
+
*/
|
|
11
16
|
export async function generateImages(model, context, options) {
|
|
12
17
|
const provider = resolveImagesApiProvider(model.api);
|
|
13
18
|
return provider.generateImages(model, context, options);
|
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export { CURSOR_MODEL_CAPABILITIES, type CursorCapabilityEvidence, type CursorLe
|
|
|
32
32
|
export { type CursorResolvedSelection, renderCursorCliModelString, resolveCursorSelectionDescriptor, } from "./cursor/selection-descriptor.ts";
|
|
33
33
|
export * from "./endpoint-reasoning-efforts.ts";
|
|
34
34
|
export * from "./env-api-keys.ts";
|
|
35
|
-
export * from "./images-models.ts";
|
|
36
35
|
export * from "./legacy-provider-ids.ts";
|
|
37
36
|
export * from "./models.ts";
|
|
38
37
|
export * from "./models-store.ts";
|
|
@@ -59,8 +58,9 @@ export * from "./utils/provider-failure-description.ts";
|
|
|
59
58
|
export * from "./utils/retry.ts";
|
|
60
59
|
export * from "./utils/server-fallback-receipt.ts";
|
|
61
60
|
export * from "./utils/stop-details.ts";
|
|
62
|
-
export { contentText } from "./utils/text.ts";
|
|
61
|
+
export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./utils/text.ts";
|
|
63
62
|
export * from "./utils/tool-pair-repair.ts";
|
|
63
|
+
export * from "./utils/transcript.ts";
|
|
64
64
|
export * from "./utils/typebox-helpers.ts";
|
|
65
65
|
export { uuidv7 } from "./utils/uuid.ts";
|
|
66
66
|
export * from "./utils/validation.ts";
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@ export { CURSOR_MODEL_CAPABILITIES, getCursorBaseIdForVariant, getCursorCapabili
|
|
|
18
18
|
export { renderCursorCliModelString, resolveCursorSelectionDescriptor, } from "./cursor/selection-descriptor.js";
|
|
19
19
|
export * from "./endpoint-reasoning-efforts.js";
|
|
20
20
|
export * from "./env-api-keys.js";
|
|
21
|
-
export * from "./images-models.js";
|
|
22
21
|
export * from "./legacy-provider-ids.js";
|
|
23
22
|
export * from "./models.js";
|
|
24
23
|
export * from "./models-store.js";
|
|
@@ -45,8 +44,9 @@ export * from "./utils/provider-failure-description.js";
|
|
|
45
44
|
export * from "./utils/retry.js";
|
|
46
45
|
export * from "./utils/server-fallback-receipt.js";
|
|
47
46
|
export * from "./utils/stop-details.js";
|
|
48
|
-
export { contentText } from "./utils/text.js";
|
|
47
|
+
export { contentText, getSystemMessageText, renderSystemMessageUpdate } from "./utils/text.js";
|
|
49
48
|
export * from "./utils/tool-pair-repair.js";
|
|
49
|
+
export * from "./utils/transcript.js";
|
|
50
50
|
export * from "./utils/typebox-helpers.js";
|
|
51
51
|
export { uuidv7 } from "./utils/uuid.js";
|
|
52
52
|
export * from "./utils/validation.js";
|
package/dist/model-catalog.d.ts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
import type { Api, Model, ProviderId } from "./types.ts";
|
|
1
|
+
import type { Api, ClassifierApi, ClassifierModel, ImageApi, ImageModel, Model, ModelType, ProviderId } from "./types.ts";
|
|
2
2
|
export type ModelGroups = Record<string, Record<string, object>>;
|
|
3
|
-
|
|
3
|
+
/** Exact-id lookup, matching getBuiltinModel(): provider namespaces remain part of the model id. */
|
|
4
|
+
export declare function builtinCatalogAdvertisesMax(modelId: string): boolean;
|
|
5
|
+
type ModelKey<TGroups extends ModelGroups> = {
|
|
4
6
|
[TApi in keyof TGroups]: keyof TGroups[TApi];
|
|
5
7
|
}[keyof TGroups] & string;
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
type KeyForType<TGroups extends ModelGroups, TType extends ModelType> = Extract<ModelKey<TGroups>, `${TType}:${string}`>;
|
|
9
|
+
type ModelId<TKey extends string> = TKey extends `${ModelType}:${infer TModelId}` ? TModelId : never;
|
|
10
|
+
type ApiForKey<TGroups extends ModelGroups, TKey extends ModelKey<TGroups>> = {
|
|
11
|
+
[TApi in keyof TGroups]: TKey extends keyof TGroups[TApi] ? TApi : never;
|
|
12
|
+
}[keyof TGroups];
|
|
13
|
+
export type ChatModelCatalog<TGroups extends ModelGroups, TProvider extends ProviderId> = {
|
|
14
|
+
[TKey in KeyForType<TGroups, "chat"> as ModelId<TKey>]: Model<ApiForKey<TGroups, TKey> & Api> & {
|
|
15
|
+
id: ModelId<TKey>;
|
|
12
16
|
provider: TProvider;
|
|
13
17
|
};
|
|
14
18
|
};
|
|
15
|
-
export
|
|
19
|
+
export type ImageModelCatalog<TGroups extends ModelGroups, TProvider extends ProviderId> = {
|
|
20
|
+
[TKey in KeyForType<TGroups, "image"> as ModelId<TKey>]: ImageModel<ApiForKey<TGroups, TKey> & ImageApi> & {
|
|
21
|
+
id: ModelId<TKey>;
|
|
22
|
+
provider: TProvider;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type ClassifierModelCatalog<TGroups extends ModelGroups, TProvider extends ProviderId> = {
|
|
26
|
+
[TKey in KeyForType<TGroups, "classifier"> as ModelId<TKey>]: ClassifierModel<ApiForKey<TGroups, TKey> & ClassifierApi> & {
|
|
27
|
+
id: ModelId<TKey>;
|
|
28
|
+
provider: TProvider;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare function flattenChatModelCatalog<const TProvider extends ProviderId, const TGroups extends ModelGroups>(_provider: TProvider, groups: TGroups): ChatModelCatalog<TGroups, TProvider>;
|
|
32
|
+
export declare function flattenImageModelCatalog<const TProvider extends ProviderId, const TGroups extends ModelGroups>(_provider: TProvider, groups: TGroups): ImageModelCatalog<TGroups, TProvider>;
|
|
33
|
+
export declare function flattenClassifierModelCatalog<const TProvider extends ProviderId, const TGroups extends ModelGroups>(_provider: TProvider, groups: TGroups): ClassifierModelCatalog<TGroups, TProvider>;
|
|
16
34
|
export {};
|
|
17
35
|
//# sourceMappingURL=model-catalog.d.ts.map
|
package/dist/model-catalog.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const MAX_EFFORT_MODEL_IDS = new Set();
|
|
2
|
+
/** Exact-id lookup, matching getBuiltinModel(): provider namespaces remain part of the model id. */
|
|
3
|
+
export function builtinCatalogAdvertisesMax(modelId) {
|
|
4
|
+
return MAX_EFFORT_MODEL_IDS.has(modelId);
|
|
5
|
+
}
|
|
6
|
+
function flattenModelCatalog(groups, type) {
|
|
7
|
+
return Object.fromEntries(Object.values(groups)
|
|
8
|
+
.flatMap((models) => Object.values(models))
|
|
9
|
+
.filter((model) => model.type === type)
|
|
10
|
+
.map((model) => [model.id, model]));
|
|
11
|
+
}
|
|
12
|
+
export function flattenChatModelCatalog(_provider, groups) {
|
|
13
|
+
const catalog = flattenModelCatalog(groups, "chat");
|
|
14
|
+
for (const model of Object.values(catalog)) {
|
|
15
|
+
if (typeof model.thinkingLevelMap?.max === "string")
|
|
16
|
+
MAX_EFFORT_MODEL_IDS.add(model.id);
|
|
17
|
+
}
|
|
18
|
+
return catalog;
|
|
19
|
+
}
|
|
20
|
+
export function flattenImageModelCatalog(_provider, groups) {
|
|
21
|
+
return flattenModelCatalog(groups, "image");
|
|
22
|
+
}
|
|
23
|
+
export function flattenClassifierModelCatalog(_provider, groups) {
|
|
24
|
+
return flattenModelCatalog(groups, "classifier");
|
|
3
25
|
}
|
|
4
26
|
//# sourceMappingURL=model-catalog.js.map
|
package/dist/model.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { AnthropicMessagesCompat, Api, BedrockCompat, CacheRetention,
|
|
2
|
-
/**
|
|
3
|
-
export interface Model<TApi extends Api> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { AnthropicMessagesCompat, Api, BaseModel, BedrockCompat, CacheRetention, MistralConversationsCompat, ModelPromptCache, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, ThinkingLevelMap } from "./types.ts";
|
|
2
|
+
/** Chat model: usable with `stream()` and friends. */
|
|
3
|
+
export interface Model<TApi extends Api> extends BaseModel<TApi> {
|
|
4
|
+
/**
|
|
5
|
+
* Optional: chat is the default model type, so models without `type` are chat
|
|
6
|
+
* models. Narrow mixed model lists with `isModelType()` instead of comparing
|
|
7
|
+
* `type` directly.
|
|
8
|
+
*/
|
|
9
|
+
type?: "chat";
|
|
9
10
|
reasoning: boolean;
|
|
10
11
|
/**
|
|
11
12
|
* Maps pi thinking levels to provider/model-specific values.
|
|
@@ -18,13 +19,12 @@ export interface Model<TApi extends Api> {
|
|
|
18
19
|
* OpenAI-compatible endpoint advertises. Clamped to the supported levels like any other request.
|
|
19
20
|
*/
|
|
20
21
|
defaultThinkingLevel?: ModelThinkingLevel;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
/** Prompt cache lifetimes per retention tier. Unset when the provider's cache behavior is unknown. */
|
|
23
|
+
promptCache?: ModelPromptCache;
|
|
23
24
|
contextWindow: number;
|
|
24
25
|
maxTokens: number;
|
|
25
26
|
/** Default sampling parameters; per-request values override these by key. */
|
|
26
27
|
samplingParams?: Record<string, unknown>;
|
|
27
|
-
headers?: Record<string, string>;
|
|
28
28
|
/** Default prompt-cache retention preference when the request omits one. */
|
|
29
29
|
cacheRetention?: CacheRetention;
|
|
30
30
|
/**
|
|
@@ -33,11 +33,11 @@ export interface Model<TApi extends Api> {
|
|
|
33
33
|
*/
|
|
34
34
|
upstreamModelId?: string;
|
|
35
35
|
/** Service tier requested by default for this model (for example `-fast` variants). */
|
|
36
|
-
serviceTier?: "auto" | "flex" | "priority";
|
|
36
|
+
serviceTier?: "auto" | "flex" | "priority" | "ultrafast";
|
|
37
37
|
/** Whether to recover supported text-encoded tool calls from assistant text. */
|
|
38
38
|
recoverTextToolCalls?: boolean;
|
|
39
39
|
/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */
|
|
40
|
-
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" | "openai-codex-responses" | "azure-openai-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : TApi extends "bedrock-converse-stream" ? BedrockCompat : TApi extends "cursor-agent" ? CursorAgentCompat : TApi extends "devin-agent" ? DevinAgentCompat : never;
|
|
40
|
+
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" | "openai-codex-responses" | "azure-openai-responses" ? OpenAIResponsesCompat : TApi extends "anthropic-messages" ? AnthropicMessagesCompat : TApi extends "bedrock-converse-stream" ? BedrockCompat : TApi extends "mistral-conversations" ? MistralConversationsCompat : TApi extends "cursor-agent" ? CursorAgentCompat : TApi extends "devin-agent" ? DevinAgentCompat : never;
|
|
41
41
|
}
|
|
42
42
|
/** Devin (Cascade) model metadata the transport branches on. */
|
|
43
43
|
export interface DevinAgentCompat {
|
package/dist/models-store.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyModel } from "./types.ts";
|
|
2
2
|
export interface ModelsStoreEntry {
|
|
3
|
-
models
|
|
3
|
+
/** Persisted models of every type. */
|
|
4
|
+
models: readonly AnyModel[];
|
|
4
5
|
/** Unix timestamp from the remote catalog's Last-Modified header. */
|
|
5
6
|
lastModified?: number;
|
|
6
7
|
/** Unix timestamp of the last completed remote check. */
|