@avadisabelle/ava-pi-ai 0.64.9 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.d.ts +27 -171
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +58 -211
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +5 -2
- package/dist/models.js.map +1 -1
- package/dist/providers/amazon-bedrock.d.ts +23 -0
- package/dist/providers/amazon-bedrock.d.ts.map +1 -1
- package/dist/providers/amazon-bedrock.js +85 -11
- package/dist/providers/amazon-bedrock.js.map +1 -1
- package/dist/providers/anthropic.d.ts +16 -2
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +57 -25
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/dist/providers/azure-openai-responses.js +10 -14
- package/dist/providers/azure-openai-responses.js.map +1 -1
- package/dist/providers/faux.d.ts +56 -0
- package/dist/providers/faux.d.ts.map +1 -0
- package/dist/providers/faux.js +368 -0
- package/dist/providers/faux.js.map +1 -0
- package/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/dist/providers/google-gemini-cli.js +20 -1
- package/dist/providers/google-gemini-cli.js.map +1 -1
- package/dist/providers/google-shared.d.ts.map +1 -1
- package/dist/providers/google-shared.js +28 -1
- package/dist/providers/google-shared.js.map +1 -1
- package/dist/providers/google-vertex.d.ts.map +1 -1
- package/dist/providers/google-vertex.js +20 -2
- package/dist/providers/google-vertex.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +45 -4
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/mistral.d.ts +3 -0
- package/dist/providers/mistral.d.ts.map +1 -1
- package/dist/providers/mistral.js +37 -4
- package/dist/providers/mistral.js.map +1 -1
- package/dist/providers/openai-codex-responses.d.ts +2 -0
- package/dist/providers/openai-codex-responses.d.ts.map +1 -1
- package/dist/providers/openai-codex-responses.js +48 -11
- package/dist/providers/openai-codex-responses.js.map +1 -1
- package/dist/providers/openai-completions.d.ts.map +1 -1
- package/dist/providers/openai-completions.js +42 -13
- package/dist/providers/openai-completions.js.map +1 -1
- package/dist/providers/openai-responses-shared.d.ts +1 -0
- package/dist/providers/openai-responses-shared.d.ts.map +1 -1
- package/dist/providers/openai-responses-shared.js +39 -10
- package/dist/providers/openai-responses-shared.js.map +1 -1
- package/dist/providers/openai-responses.d.ts.map +1 -1
- package/dist/providers/openai-responses.js +19 -17
- package/dist/providers/openai-responses.js.map +1 -1
- package/dist/providers/simple-options.d.ts.map +1 -1
- package/dist/providers/simple-options.js +2 -1
- package/dist/providers/simple-options.js.map +1 -1
- package/dist/providers/transform-messages.d.ts.map +1 -1
- package/dist/providers/transform-messages.js +20 -32
- package/dist/providers/transform-messages.js.map +1 -1
- package/dist/types.d.ts +72 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/headers.d.ts +2 -0
- package/dist/utils/headers.d.ts.map +1 -0
- package/dist/utils/headers.js +8 -0
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/overflow.d.ts +4 -3
- package/dist/utils/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +28 -13
- package/dist/utils/overflow.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -636,6 +636,92 @@ The library uses a registry of API implementations. Built-in APIs include:
|
|
|
636
636
|
- **`azure-openai-responses`**: Azure OpenAI Responses API (`streamAzureOpenAIResponses`, `AzureOpenAIResponsesOptions`)
|
|
637
637
|
- **`bedrock-converse-stream`**: Amazon Bedrock Converse API (`streamBedrock`, `BedrockOptions`)
|
|
638
638
|
|
|
639
|
+
### Faux provider for tests
|
|
640
|
+
|
|
641
|
+
`registerFauxProvider()` registers a temporary in-memory provider for tests and demos. It is opt-in and not part of the built-in provider set.
|
|
642
|
+
|
|
643
|
+
```typescript
|
|
644
|
+
import {
|
|
645
|
+
complete,
|
|
646
|
+
fauxAssistantMessage,
|
|
647
|
+
fauxText,
|
|
648
|
+
fauxThinking,
|
|
649
|
+
fauxToolCall,
|
|
650
|
+
registerFauxProvider,
|
|
651
|
+
stream,
|
|
652
|
+
} from '@mariozechner/pi-ai';
|
|
653
|
+
|
|
654
|
+
const registration = registerFauxProvider({
|
|
655
|
+
tokensPerSecond: 50 // optional
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
const model = registration.getModel();
|
|
659
|
+
const context = {
|
|
660
|
+
messages: [{ role: 'user', content: 'Summarize package.json and then call echo', timestamp: Date.now() }]
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
registration.setResponses([
|
|
664
|
+
fauxAssistantMessage([
|
|
665
|
+
fauxThinking('Need to inspect package metadata first.'),
|
|
666
|
+
fauxToolCall('echo', { text: 'package.json' })
|
|
667
|
+
], { stopReason: 'toolUse' })
|
|
668
|
+
]);
|
|
669
|
+
|
|
670
|
+
const first = await complete(model, context, {
|
|
671
|
+
sessionId: 'session-1',
|
|
672
|
+
cacheRetention: 'short'
|
|
673
|
+
});
|
|
674
|
+
context.messages.push(first);
|
|
675
|
+
|
|
676
|
+
context.messages.push({
|
|
677
|
+
role: 'toolResult',
|
|
678
|
+
toolCallId: first.content.find((block) => block.type === 'toolCall')!.id,
|
|
679
|
+
toolName: 'echo',
|
|
680
|
+
content: [{ type: 'text', text: 'package.json contents here' }],
|
|
681
|
+
isError: false,
|
|
682
|
+
timestamp: Date.now()
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
registration.setResponses([
|
|
686
|
+
fauxAssistantMessage([
|
|
687
|
+
fauxThinking('Now I can summarize the tool output.'),
|
|
688
|
+
fauxText('Here is the summary.')
|
|
689
|
+
])
|
|
690
|
+
]);
|
|
691
|
+
|
|
692
|
+
const s = stream(model, context);
|
|
693
|
+
for await (const event of s) {
|
|
694
|
+
console.log(event.type);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// Optional: register multiple faux models for model-switching tests
|
|
698
|
+
const multiModel = registerFauxProvider({
|
|
699
|
+
models: [
|
|
700
|
+
{ id: 'faux-fast', reasoning: false },
|
|
701
|
+
{ id: 'faux-thinker', reasoning: true }
|
|
702
|
+
]
|
|
703
|
+
});
|
|
704
|
+
const thinker = multiModel.getModel('faux-thinker');
|
|
705
|
+
|
|
706
|
+
console.log(thinker?.reasoning);
|
|
707
|
+
console.log(registration.getPendingResponseCount());
|
|
708
|
+
console.log(registration.state.callCount);
|
|
709
|
+
registration.unregister();
|
|
710
|
+
multiModel.unregister();
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
Notes:
|
|
714
|
+
- Responses are consumed from a queue in request start order.
|
|
715
|
+
- If the queue is empty, the faux provider returns an assistant error message with `errorMessage: "No more faux responses queued"`.
|
|
716
|
+
- Use `registration.setResponses([...])` to replace the remaining queue and `registration.appendResponses([...])` to add more responses.
|
|
717
|
+
- `registration.models` exposes all registered faux models. `registration.getModel()` returns the first one, and `registration.getModel(id)` returns a specific one.
|
|
718
|
+
- Use `fauxAssistantMessage(...)` for scripted assistant replies. Use `fauxText(...)`, `fauxThinking(...)`, and `fauxToolCall(...)` to build content blocks without filling in low-level fields manually.
|
|
719
|
+
- `registration.unregister()` removes the temporary provider from the global API registry.
|
|
720
|
+
- Usage is estimated at roughly 1 token per 4 characters. When `sessionId` is present and `cacheRetention` is not `"none"`, prompt cache reads and writes are simulated automatically.
|
|
721
|
+
- Tool call arguments stream incrementally via `toolcall_delta` chunks.
|
|
722
|
+
- By default, each streamed chunk is emitted on its own microtask. Set `tokensPerSecond` to pace chunk delivery in real time.
|
|
723
|
+
- The intended use is one deterministic scripted flow per registration. If you need independent concurrent flows, register separate faux providers.
|
|
724
|
+
|
|
639
725
|
### Providers and Models
|
|
640
726
|
|
|
641
727
|
A **provider** offers models through a specific API. For example:
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n\nimport {
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n\nimport { createInterface } from \"node:readline\";\nimport { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport { getOAuthProvider, getOAuthProviders } from \"./utils/oauth/index.js\";\nimport type { OAuthCredentials, OAuthProviderId } from \"./utils/oauth/types.js\";\n\nconst AUTH_FILE = \"auth.json\";\nconst PROVIDERS = getOAuthProviders();\n\nfunction prompt(rl: ReturnType<typeof createInterface>, question: string): Promise<string> {\n\treturn new Promise((resolve) => rl.question(question, resolve));\n}\n\nfunction loadAuth(): Record<string, { type: \"oauth\" } & OAuthCredentials> {\n\tif (!existsSync(AUTH_FILE)) return {};\n\ttry {\n\t\treturn JSON.parse(readFileSync(AUTH_FILE, \"utf-8\"));\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nfunction saveAuth(auth: Record<string, { type: \"oauth\" } & OAuthCredentials>): void {\n\twriteFileSync(AUTH_FILE, JSON.stringify(auth, null, 2), \"utf-8\");\n}\n\nasync function login(providerId: OAuthProviderId): Promise<void> {\n\tconst provider = getOAuthProvider(providerId);\n\tif (!provider) {\n\t\tconsole.error(`Unknown provider: ${providerId}`);\n\t\tprocess.exit(1);\n\t}\n\n\tconst rl = createInterface({ input: process.stdin, output: process.stdout });\n\tconst promptFn = (msg: string) => prompt(rl, `${msg} `);\n\n\ttry {\n\t\tconst credentials = await provider.login({\n\t\t\tonAuth: (info) => {\n\t\t\t\tconsole.log(`\\nOpen this URL in your browser:\\n${info.url}`);\n\t\t\t\tif (info.instructions) console.log(info.instructions);\n\t\t\t\tconsole.log();\n\t\t\t},\n\t\t\tonPrompt: async (p) => {\n\t\t\t\treturn await promptFn(`${p.message}${p.placeholder ? ` (${p.placeholder})` : \"\"}:`);\n\t\t\t},\n\t\t\tonProgress: (msg) => console.log(msg),\n\t\t});\n\n\t\tconst auth = loadAuth();\n\t\tauth[providerId] = { type: \"oauth\", ...credentials };\n\t\tsaveAuth(auth);\n\n\t\tconsole.log(`\\nCredentials saved to ${AUTH_FILE}`);\n\t} finally {\n\t\trl.close();\n\t}\n}\n\nasync function main(): Promise<void> {\n\tconst args = process.argv.slice(2);\n\tconst command = args[0];\n\n\tif (!command || command === \"help\" || command === \"--help\" || command === \"-h\") {\n\t\tconst providerList = PROVIDERS.map((p) => ` ${p.id.padEnd(20)} ${p.name}`).join(\"\\n\");\n\t\tconsole.log(`Usage: npx @avadisabelle/ava-pi-ai <command> [provider]\n\nCommands:\n login [provider] Login to an OAuth provider\n list List available providers\n\nProviders:\n${providerList}\n\nExamples:\n npx @avadisabelle/ava-pi-ai login # interactive provider selection\n npx @avadisabelle/ava-pi-ai login anthropic # login to specific provider\n npx @avadisabelle/ava-pi-ai list # list providers\n`);\n\t\treturn;\n\t}\n\n\tif (command === \"list\") {\n\t\tconsole.log(\"Available OAuth providers:\\n\");\n\t\tfor (const p of PROVIDERS) {\n\t\t\tconsole.log(` ${p.id.padEnd(20)} ${p.name}`);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (command === \"login\") {\n\t\tlet provider = args[1] as OAuthProviderId | undefined;\n\n\t\tif (!provider) {\n\t\t\tconst rl = createInterface({ input: process.stdin, output: process.stdout });\n\t\t\tconsole.log(\"Select a provider:\\n\");\n\t\t\tfor (let i = 0; i < PROVIDERS.length; i++) {\n\t\t\t\tconsole.log(` ${i + 1}. ${PROVIDERS[i].name}`);\n\t\t\t}\n\t\t\tconsole.log();\n\n\t\t\tconst choice = await prompt(rl, `Enter number (1-${PROVIDERS.length}): `);\n\t\t\trl.close();\n\n\t\t\tconst index = parseInt(choice, 10) - 1;\n\t\t\tif (index < 0 || index >= PROVIDERS.length) {\n\t\t\t\tconsole.error(\"Invalid selection\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tprovider = PROVIDERS[index].id;\n\t\t}\n\n\t\tif (!PROVIDERS.some((p) => p.id === provider)) {\n\t\t\tconsole.error(`Unknown provider: ${provider}`);\n\t\t\tconsole.error(`Use 'npx @avadisabelle/ava-pi-ai list' to see available providers`);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconsole.log(`Logging in to ${provider}...`);\n\t\tawait login(provider);\n\t\treturn;\n\t}\n\n\tconsole.error(`Unknown command: ${command}`);\n\tconsole.error(`Use 'npx @avadisabelle/ava-pi-ai --help' for usage`);\n\tprocess.exit(1);\n}\n\nmain().catch((err) => {\n\tconsole.error(\"Error:\", err.message);\n\tprocess.exit(1);\n});\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
2
3
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
-
import { createInterface } from "readline";
|
|
4
4
|
import { getOAuthProvider, getOAuthProviders } from "./utils/oauth/index.js";
|
|
5
5
|
const AUTH_FILE = "auth.json";
|
|
6
6
|
const PROVIDERS = getOAuthProviders();
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7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AC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAAA,CAChB,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { createInterface } from \"node:readline\";\nimport { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport { getOAuthProvider, getOAuthProviders } from \"./utils/oauth/index.js\";\nimport type { OAuthCredentials, OAuthProviderId } from \"./utils/oauth/types.js\";\n\nconst AUTH_FILE = \"auth.json\";\nconst PROVIDERS = getOAuthProviders();\n\nfunction prompt(rl: ReturnType<typeof createInterface>, question: string): Promise<string> {\n\treturn new Promise((resolve) => rl.question(question, resolve));\n}\n\nfunction loadAuth(): Record<string, { type: \"oauth\" } & OAuthCredentials> {\n\tif (!existsSync(AUTH_FILE)) return {};\n\ttry {\n\t\treturn JSON.parse(readFileSync(AUTH_FILE, \"utf-8\"));\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nfunction saveAuth(auth: Record<string, { type: \"oauth\" } & OAuthCredentials>): void {\n\twriteFileSync(AUTH_FILE, JSON.stringify(auth, null, 2), \"utf-8\");\n}\n\nasync function login(providerId: OAuthProviderId): Promise<void> {\n\tconst provider = getOAuthProvider(providerId);\n\tif (!provider) {\n\t\tconsole.error(`Unknown provider: ${providerId}`);\n\t\tprocess.exit(1);\n\t}\n\n\tconst rl = createInterface({ input: process.stdin, output: process.stdout });\n\tconst promptFn = (msg: string) => prompt(rl, `${msg} `);\n\n\ttry {\n\t\tconst credentials = await provider.login({\n\t\t\tonAuth: (info) => {\n\t\t\t\tconsole.log(`\\nOpen this URL in your browser:\\n${info.url}`);\n\t\t\t\tif (info.instructions) console.log(info.instructions);\n\t\t\t\tconsole.log();\n\t\t\t},\n\t\t\tonPrompt: async (p) => {\n\t\t\t\treturn await promptFn(`${p.message}${p.placeholder ? ` (${p.placeholder})` : \"\"}:`);\n\t\t\t},\n\t\t\tonProgress: (msg) => console.log(msg),\n\t\t});\n\n\t\tconst auth = loadAuth();\n\t\tauth[providerId] = { type: \"oauth\", ...credentials };\n\t\tsaveAuth(auth);\n\n\t\tconsole.log(`\\nCredentials saved to ${AUTH_FILE}`);\n\t} finally {\n\t\trl.close();\n\t}\n}\n\nasync function main(): Promise<void> {\n\tconst args = process.argv.slice(2);\n\tconst command = args[0];\n\n\tif (!command || command === \"help\" || command === \"--help\" || command === \"-h\") {\n\t\tconst providerList = PROVIDERS.map((p) => ` ${p.id.padEnd(20)} ${p.name}`).join(\"\\n\");\n\t\tconsole.log(`Usage: npx @avadisabelle/ava-pi-ai <command> [provider]\n\nCommands:\n login [provider] Login to an OAuth provider\n list List available providers\n\nProviders:\n${providerList}\n\nExamples:\n npx @avadisabelle/ava-pi-ai login # interactive provider selection\n npx @avadisabelle/ava-pi-ai login anthropic # login to specific provider\n npx @avadisabelle/ava-pi-ai list # list providers\n`);\n\t\treturn;\n\t}\n\n\tif (command === \"list\") {\n\t\tconsole.log(\"Available OAuth providers:\\n\");\n\t\tfor (const p of PROVIDERS) {\n\t\t\tconsole.log(` ${p.id.padEnd(20)} ${p.name}`);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (command === \"login\") {\n\t\tlet provider = args[1] as OAuthProviderId | undefined;\n\n\t\tif (!provider) {\n\t\t\tconst rl = createInterface({ input: process.stdin, output: process.stdout });\n\t\t\tconsole.log(\"Select a provider:\\n\");\n\t\t\tfor (let i = 0; i < PROVIDERS.length; i++) {\n\t\t\t\tconsole.log(` ${i + 1}. ${PROVIDERS[i].name}`);\n\t\t\t}\n\t\t\tconsole.log();\n\n\t\t\tconst choice = await prompt(rl, `Enter number (1-${PROVIDERS.length}): `);\n\t\t\trl.close();\n\n\t\t\tconst index = parseInt(choice, 10) - 1;\n\t\t\tif (index < 0 || index >= PROVIDERS.length) {\n\t\t\t\tconsole.error(\"Invalid selection\");\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tprovider = PROVIDERS[index].id;\n\t\t}\n\n\t\tif (!PROVIDERS.some((p) => p.id === provider)) {\n\t\t\tconsole.error(`Unknown provider: ${provider}`);\n\t\t\tconsole.error(`Use 'npx @avadisabelle/ava-pi-ai list' to see available providers`);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconsole.log(`Logging in to ${provider}...`);\n\t\tawait login(provider);\n\t\treturn;\n\t}\n\n\tconsole.error(`Unknown command: ${command}`);\n\tconsole.error(`Use 'npx @avadisabelle/ava-pi-ai --help' for usage`);\n\tprocess.exit(1);\n}\n\nmain().catch((err) => {\n\tconsole.error(\"Error:\", err.message);\n\tprocess.exit(1);\n});\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ export { Type } from "@sinclair/typebox";
|
|
|
3
3
|
export * from "./api-registry.js";
|
|
4
4
|
export * from "./env-api-keys.js";
|
|
5
5
|
export * from "./models.js";
|
|
6
|
-
export type {
|
|
6
|
+
export type { BedrockOptions, BedrockThinkingDisplay } from "./providers/amazon-bedrock.js";
|
|
7
|
+
export type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from "./providers/anthropic.js";
|
|
7
8
|
export type { AzureOpenAIResponsesOptions } from "./providers/azure-openai-responses.js";
|
|
9
|
+
export * from "./providers/faux.js";
|
|
8
10
|
export type { GoogleOptions } from "./providers/google.js";
|
|
9
11
|
export type { GoogleGeminiCliOptions, GoogleThinkingLevel } from "./providers/google-gemini-cli.js";
|
|
10
12
|
export type { GoogleVertexOptions } from "./providers/google-vertex.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B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sourcesContent":["export type { Static, TSchema } from \"@sinclair/typebox\";\nexport { Type } from \"@sinclair/typebox\";\n\nexport * from \"./api-registry.js\";\nexport * from \"./env-api-keys.js\";\nexport * from \"./models.js\";\nexport type { BedrockOptions, BedrockThinkingDisplay } from \"./providers/amazon-bedrock.js\";\nexport type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from \"./providers/anthropic.js\";\nexport type { AzureOpenAIResponsesOptions } from \"./providers/azure-openai-responses.js\";\nexport * from \"./providers/faux.js\";\nexport type { GoogleOptions } from \"./providers/google.js\";\nexport type { GoogleGeminiCliOptions, GoogleThinkingLevel } from \"./providers/google-gemini-cli.js\";\nexport type { GoogleVertexOptions } from \"./providers/google-vertex.js\";\nexport type { MistralOptions } from \"./providers/mistral.js\";\nexport type { OpenAICodexResponsesOptions } from \"./providers/openai-codex-responses.js\";\nexport type { OpenAICompletionsOptions } from \"./providers/openai-completions.js\";\nexport type { OpenAIResponsesOptions } from \"./providers/openai-responses.js\";\nexport * from \"./providers/register-builtins.js\";\nexport * from \"./stream.js\";\nexport * from \"./types.js\";\nexport * from \"./utils/event-stream.js\";\nexport * from \"./utils/json-parse.js\";\nexport type {\n\tOAuthAuthInfo,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tOAuthPrompt,\n\tOAuthProvider,\n\tOAuthProviderId,\n\tOAuthProviderInfo,\n\tOAuthProviderInterface,\n} from \"./utils/oauth/types.js\";\nexport * from \"./utils/overflow.js\";\nexport * from \"./utils/typebox-helpers.js\";\nexport * from \"./utils/validation.js\";\n"]}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { Type } from "@sinclair/typebox";
|
|
|
2
2
|
export * from "./api-registry.js";
|
|
3
3
|
export * from "./env-api-keys.js";
|
|
4
4
|
export * from "./models.js";
|
|
5
|
+
export * from "./providers/faux.js";
|
|
5
6
|
export * from "./providers/register-builtins.js";
|
|
6
7
|
export * from "./stream.js";
|
|
7
8
|
export * from "./types.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAI5B,cAAc,qBAAqB,CAAC;AAQpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AAWtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC","sourcesContent":["export type { Static, TSchema } from \"@sinclair/typebox\";\nexport { Type } from \"@sinclair/typebox\";\n\nexport * from \"./api-registry.js\";\nexport * from \"./env-api-keys.js\";\nexport * from \"./models.js\";\nexport type { BedrockOptions, BedrockThinkingDisplay } from \"./providers/amazon-bedrock.js\";\nexport type { AnthropicEffort, AnthropicOptions, AnthropicThinkingDisplay } from \"./providers/anthropic.js\";\nexport type { AzureOpenAIResponsesOptions } from \"./providers/azure-openai-responses.js\";\nexport * from \"./providers/faux.js\";\nexport type { GoogleOptions } from \"./providers/google.js\";\nexport type { GoogleGeminiCliOptions, GoogleThinkingLevel } from \"./providers/google-gemini-cli.js\";\nexport type { GoogleVertexOptions } from \"./providers/google-vertex.js\";\nexport type { MistralOptions } from \"./providers/mistral.js\";\nexport type { OpenAICodexResponsesOptions } from \"./providers/openai-codex-responses.js\";\nexport type { OpenAICompletionsOptions } from \"./providers/openai-completions.js\";\nexport type { OpenAIResponsesOptions } from \"./providers/openai-responses.js\";\nexport * from \"./providers/register-builtins.js\";\nexport * from \"./stream.js\";\nexport * from \"./types.js\";\nexport * from \"./utils/event-stream.js\";\nexport * from \"./utils/json-parse.js\";\nexport type {\n\tOAuthAuthInfo,\n\tOAuthCredentials,\n\tOAuthLoginCallbacks,\n\tOAuthPrompt,\n\tOAuthProvider,\n\tOAuthProviderId,\n\tOAuthProviderInfo,\n\tOAuthProviderInterface,\n} from \"./utils/oauth/types.js\";\nexport * from \"./utils/overflow.js\";\nexport * from \"./utils/typebox-helpers.js\";\nexport * from \"./utils/validation.js\";\n"]}
|
package/dist/models.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usag
|
|
|
12
12
|
*
|
|
13
13
|
* Supported today:
|
|
14
14
|
* - GPT-5.2 / GPT-5.3 / GPT-5.4 model families
|
|
15
|
-
* - Opus 4.6 models (xhigh maps to adaptive effort "max" on Anthropic-compatible providers)
|
|
15
|
+
* - Opus 4.6+ models (xhigh maps to adaptive effort "max" on Anthropic-compatible providers)
|
|
16
16
|
*/
|
|
17
17
|
export declare function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean;
|
|
18
18
|
/**
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAanE,KAAK,QAAQ,CACZ,SAAS,SAAS,aAAa,EAC/B,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,IAC9C,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAA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AAC,QAAQ,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,CAAC,IAAI,SAAS,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEjH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,aAAa,EAAE,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,EAC1G,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,QAAQ,GACf,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAGtC;AAED,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAE9C;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,aAAa,EACxD,QAAQ,EAAE,SAAS,GACjB,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAGhE;AAED,wBAAgB,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAO/F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAe3E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,GAAG,EAC9C,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACjC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/B,OAAO,CAGT","sourcesContent":["import { MODELS } from \"./models.generated.js\";\nimport type { Api, KnownProvider, Model, Usage } from \"./types.js\";\n\nconst modelRegistry: Map<string, Map<string, Model<Api>>> = new Map();\n\n// Initialize registry from MODELS on module load\nfor (const [provider, models] of Object.entries(MODELS)) {\n\tconst providerModels = new Map<string, Model<Api>>();\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tproviderModels.set(id, model as Model<Api>);\n\t}\n\tmodelRegistry.set(provider, providerModels);\n}\n\ntype ModelApi<\n\tTProvider extends KnownProvider,\n\tTModelId extends keyof (typeof MODELS)[TProvider],\n> = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;\n\nexport function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(\n\tprovider: TProvider,\n\tmodelId: TModelId,\n): Model<ModelApi<TProvider, TModelId>> {\n\tconst providerModels = modelRegistry.get(provider);\n\treturn providerModels?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;\n}\n\nexport function getProviders(): KnownProvider[] {\n\treturn Array.from(modelRegistry.keys()) as KnownProvider[];\n}\n\nexport function getModels<TProvider extends KnownProvider>(\n\tprovider: TProvider,\n): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {\n\tconst models = modelRegistry.get(provider);\n\treturn models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite / 1000000) * usage.cacheWrite;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\n/**\n * Check if a model supports xhigh thinking level.\n *\n * Supported today:\n * - GPT-5.2 / GPT-5.3 / GPT-5.4 model families\n * - Opus 4.6+ models (xhigh maps to adaptive effort \"max\" on Anthropic-compatible providers)\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (model.id.includes(\"gpt-5.2\") || model.id.includes(\"gpt-5.3\") || model.id.includes(\"gpt-5.4\")) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\tmodel.id.includes(\"opus-4-6\") ||\n\t\tmodel.id.includes(\"opus-4.6\") ||\n\t\tmodel.id.includes(\"opus-4-7\") ||\n\t\tmodel.id.includes(\"opus-4.7\")\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
|
|
@@ -4230,6 +4230,23 @@ export declare const MODELS: {
|
|
|
4230
4230
|
contextWindow: number;
|
|
4231
4231
|
maxTokens: number;
|
|
4232
4232
|
};
|
|
4233
|
+
readonly "gemini-3.1-pro-preview-customtools": {
|
|
4234
|
+
id: string;
|
|
4235
|
+
name: string;
|
|
4236
|
+
api: "google-vertex";
|
|
4237
|
+
provider: string;
|
|
4238
|
+
baseUrl: string;
|
|
4239
|
+
reasoning: true;
|
|
4240
|
+
input: ("image" | "text")[];
|
|
4241
|
+
cost: {
|
|
4242
|
+
input: number;
|
|
4243
|
+
output: number;
|
|
4244
|
+
cacheRead: number;
|
|
4245
|
+
cacheWrite: number;
|
|
4246
|
+
};
|
|
4247
|
+
contextWindow: number;
|
|
4248
|
+
maxTokens: number;
|
|
4249
|
+
};
|
|
4233
4250
|
};
|
|
4234
4251
|
readonly groq: {
|
|
4235
4252
|
readonly "deepseek-r1-distill-llama-70b": {
|
|
@@ -4942,7 +4959,7 @@ export declare const MODELS: {
|
|
|
4942
4959
|
};
|
|
4943
4960
|
};
|
|
4944
4961
|
readonly "kimi-coding": {
|
|
4945
|
-
readonly
|
|
4962
|
+
readonly "kimi-for-coding": {
|
|
4946
4963
|
id: string;
|
|
4947
4964
|
name: string;
|
|
4948
4965
|
api: "anthropic-messages";
|
|
@@ -4978,91 +4995,6 @@ export declare const MODELS: {
|
|
|
4978
4995
|
};
|
|
4979
4996
|
};
|
|
4980
4997
|
readonly minimax: {
|
|
4981
|
-
readonly "MiniMax-M2": {
|
|
4982
|
-
id: string;
|
|
4983
|
-
name: string;
|
|
4984
|
-
api: "anthropic-messages";
|
|
4985
|
-
provider: string;
|
|
4986
|
-
baseUrl: string;
|
|
4987
|
-
reasoning: true;
|
|
4988
|
-
input: "text"[];
|
|
4989
|
-
cost: {
|
|
4990
|
-
input: number;
|
|
4991
|
-
output: number;
|
|
4992
|
-
cacheRead: number;
|
|
4993
|
-
cacheWrite: number;
|
|
4994
|
-
};
|
|
4995
|
-
contextWindow: number;
|
|
4996
|
-
maxTokens: number;
|
|
4997
|
-
};
|
|
4998
|
-
readonly "MiniMax-M2.1": {
|
|
4999
|
-
id: string;
|
|
5000
|
-
name: string;
|
|
5001
|
-
api: "anthropic-messages";
|
|
5002
|
-
provider: string;
|
|
5003
|
-
baseUrl: string;
|
|
5004
|
-
reasoning: true;
|
|
5005
|
-
input: "text"[];
|
|
5006
|
-
cost: {
|
|
5007
|
-
input: number;
|
|
5008
|
-
output: number;
|
|
5009
|
-
cacheRead: number;
|
|
5010
|
-
cacheWrite: number;
|
|
5011
|
-
};
|
|
5012
|
-
contextWindow: number;
|
|
5013
|
-
maxTokens: number;
|
|
5014
|
-
};
|
|
5015
|
-
readonly "MiniMax-M2.1-highspeed": {
|
|
5016
|
-
id: string;
|
|
5017
|
-
name: string;
|
|
5018
|
-
api: "anthropic-messages";
|
|
5019
|
-
provider: string;
|
|
5020
|
-
baseUrl: string;
|
|
5021
|
-
reasoning: true;
|
|
5022
|
-
input: "text"[];
|
|
5023
|
-
cost: {
|
|
5024
|
-
input: number;
|
|
5025
|
-
output: number;
|
|
5026
|
-
cacheRead: number;
|
|
5027
|
-
cacheWrite: number;
|
|
5028
|
-
};
|
|
5029
|
-
contextWindow: number;
|
|
5030
|
-
maxTokens: number;
|
|
5031
|
-
};
|
|
5032
|
-
readonly "MiniMax-M2.5": {
|
|
5033
|
-
id: string;
|
|
5034
|
-
name: string;
|
|
5035
|
-
api: "anthropic-messages";
|
|
5036
|
-
provider: string;
|
|
5037
|
-
baseUrl: string;
|
|
5038
|
-
reasoning: true;
|
|
5039
|
-
input: "text"[];
|
|
5040
|
-
cost: {
|
|
5041
|
-
input: number;
|
|
5042
|
-
output: number;
|
|
5043
|
-
cacheRead: number;
|
|
5044
|
-
cacheWrite: number;
|
|
5045
|
-
};
|
|
5046
|
-
contextWindow: number;
|
|
5047
|
-
maxTokens: number;
|
|
5048
|
-
};
|
|
5049
|
-
readonly "MiniMax-M2.5-highspeed": {
|
|
5050
|
-
id: string;
|
|
5051
|
-
name: string;
|
|
5052
|
-
api: "anthropic-messages";
|
|
5053
|
-
provider: string;
|
|
5054
|
-
baseUrl: string;
|
|
5055
|
-
reasoning: true;
|
|
5056
|
-
input: "text"[];
|
|
5057
|
-
cost: {
|
|
5058
|
-
input: number;
|
|
5059
|
-
output: number;
|
|
5060
|
-
cacheRead: number;
|
|
5061
|
-
cacheWrite: number;
|
|
5062
|
-
};
|
|
5063
|
-
contextWindow: number;
|
|
5064
|
-
maxTokens: number;
|
|
5065
|
-
};
|
|
5066
4998
|
readonly "MiniMax-M2.7": {
|
|
5067
4999
|
id: string;
|
|
5068
5000
|
name: string;
|
|
@@ -5099,91 +5031,6 @@ export declare const MODELS: {
|
|
|
5099
5031
|
};
|
|
5100
5032
|
};
|
|
5101
5033
|
readonly "minimax-cn": {
|
|
5102
|
-
readonly "MiniMax-M2": {
|
|
5103
|
-
id: string;
|
|
5104
|
-
name: string;
|
|
5105
|
-
api: "anthropic-messages";
|
|
5106
|
-
provider: string;
|
|
5107
|
-
baseUrl: string;
|
|
5108
|
-
reasoning: true;
|
|
5109
|
-
input: "text"[];
|
|
5110
|
-
cost: {
|
|
5111
|
-
input: number;
|
|
5112
|
-
output: number;
|
|
5113
|
-
cacheRead: number;
|
|
5114
|
-
cacheWrite: number;
|
|
5115
|
-
};
|
|
5116
|
-
contextWindow: number;
|
|
5117
|
-
maxTokens: number;
|
|
5118
|
-
};
|
|
5119
|
-
readonly "MiniMax-M2.1": {
|
|
5120
|
-
id: string;
|
|
5121
|
-
name: string;
|
|
5122
|
-
api: "anthropic-messages";
|
|
5123
|
-
provider: string;
|
|
5124
|
-
baseUrl: string;
|
|
5125
|
-
reasoning: true;
|
|
5126
|
-
input: "text"[];
|
|
5127
|
-
cost: {
|
|
5128
|
-
input: number;
|
|
5129
|
-
output: number;
|
|
5130
|
-
cacheRead: number;
|
|
5131
|
-
cacheWrite: number;
|
|
5132
|
-
};
|
|
5133
|
-
contextWindow: number;
|
|
5134
|
-
maxTokens: number;
|
|
5135
|
-
};
|
|
5136
|
-
readonly "MiniMax-M2.1-highspeed": {
|
|
5137
|
-
id: string;
|
|
5138
|
-
name: string;
|
|
5139
|
-
api: "anthropic-messages";
|
|
5140
|
-
provider: string;
|
|
5141
|
-
baseUrl: string;
|
|
5142
|
-
reasoning: true;
|
|
5143
|
-
input: "text"[];
|
|
5144
|
-
cost: {
|
|
5145
|
-
input: number;
|
|
5146
|
-
output: number;
|
|
5147
|
-
cacheRead: number;
|
|
5148
|
-
cacheWrite: number;
|
|
5149
|
-
};
|
|
5150
|
-
contextWindow: number;
|
|
5151
|
-
maxTokens: number;
|
|
5152
|
-
};
|
|
5153
|
-
readonly "MiniMax-M2.5": {
|
|
5154
|
-
id: string;
|
|
5155
|
-
name: string;
|
|
5156
|
-
api: "anthropic-messages";
|
|
5157
|
-
provider: string;
|
|
5158
|
-
baseUrl: string;
|
|
5159
|
-
reasoning: true;
|
|
5160
|
-
input: "text"[];
|
|
5161
|
-
cost: {
|
|
5162
|
-
input: number;
|
|
5163
|
-
output: number;
|
|
5164
|
-
cacheRead: number;
|
|
5165
|
-
cacheWrite: number;
|
|
5166
|
-
};
|
|
5167
|
-
contextWindow: number;
|
|
5168
|
-
maxTokens: number;
|
|
5169
|
-
};
|
|
5170
|
-
readonly "MiniMax-M2.5-highspeed": {
|
|
5171
|
-
id: string;
|
|
5172
|
-
name: string;
|
|
5173
|
-
api: "anthropic-messages";
|
|
5174
|
-
provider: string;
|
|
5175
|
-
baseUrl: string;
|
|
5176
|
-
reasoning: true;
|
|
5177
|
-
input: "text"[];
|
|
5178
|
-
cost: {
|
|
5179
|
-
input: number;
|
|
5180
|
-
output: number;
|
|
5181
|
-
cacheRead: number;
|
|
5182
|
-
cacheWrite: number;
|
|
5183
|
-
};
|
|
5184
|
-
contextWindow: number;
|
|
5185
|
-
maxTokens: number;
|
|
5186
|
-
};
|
|
5187
5034
|
readonly "MiniMax-M2.7": {
|
|
5188
5035
|
id: string;
|
|
5189
5036
|
name: string;
|
|
@@ -14577,6 +14424,7 @@ export declare const MODELS: {
|
|
|
14577
14424
|
compat: {
|
|
14578
14425
|
supportsDeveloperRole: false;
|
|
14579
14426
|
thinkingFormat: "zai";
|
|
14427
|
+
zaiToolStream: true;
|
|
14580
14428
|
};
|
|
14581
14429
|
reasoning: true;
|
|
14582
14430
|
input: "text"[];
|
|
@@ -14598,6 +14446,7 @@ export declare const MODELS: {
|
|
|
14598
14446
|
compat: {
|
|
14599
14447
|
supportsDeveloperRole: false;
|
|
14600
14448
|
thinkingFormat: "zai";
|
|
14449
|
+
zaiToolStream: true;
|
|
14601
14450
|
};
|
|
14602
14451
|
reasoning: true;
|
|
14603
14452
|
input: ("image" | "text")[];
|
|
@@ -14619,6 +14468,7 @@ export declare const MODELS: {
|
|
|
14619
14468
|
compat: {
|
|
14620
14469
|
supportsDeveloperRole: false;
|
|
14621
14470
|
thinkingFormat: "zai";
|
|
14471
|
+
zaiToolStream: true;
|
|
14622
14472
|
};
|
|
14623
14473
|
reasoning: true;
|
|
14624
14474
|
input: "text"[];
|
|
@@ -14640,6 +14490,7 @@ export declare const MODELS: {
|
|
|
14640
14490
|
compat: {
|
|
14641
14491
|
supportsDeveloperRole: false;
|
|
14642
14492
|
thinkingFormat: "zai";
|
|
14493
|
+
zaiToolStream: true;
|
|
14643
14494
|
};
|
|
14644
14495
|
reasoning: true;
|
|
14645
14496
|
input: "text"[];
|
|
@@ -14661,6 +14512,7 @@ export declare const MODELS: {
|
|
|
14661
14512
|
compat: {
|
|
14662
14513
|
supportsDeveloperRole: false;
|
|
14663
14514
|
thinkingFormat: "zai";
|
|
14515
|
+
zaiToolStream: true;
|
|
14664
14516
|
};
|
|
14665
14517
|
reasoning: true;
|
|
14666
14518
|
input: "text"[];
|
|
@@ -14682,6 +14534,7 @@ export declare const MODELS: {
|
|
|
14682
14534
|
compat: {
|
|
14683
14535
|
supportsDeveloperRole: false;
|
|
14684
14536
|
thinkingFormat: "zai";
|
|
14537
|
+
zaiToolStream: true;
|
|
14685
14538
|
};
|
|
14686
14539
|
reasoning: true;
|
|
14687
14540
|
input: "text"[];
|
|
@@ -14703,6 +14556,7 @@ export declare const MODELS: {
|
|
|
14703
14556
|
compat: {
|
|
14704
14557
|
supportsDeveloperRole: false;
|
|
14705
14558
|
thinkingFormat: "zai";
|
|
14559
|
+
zaiToolStream: true;
|
|
14706
14560
|
};
|
|
14707
14561
|
reasoning: true;
|
|
14708
14562
|
input: "text"[];
|
|
@@ -14724,6 +14578,7 @@ export declare const MODELS: {
|
|
|
14724
14578
|
compat: {
|
|
14725
14579
|
supportsDeveloperRole: false;
|
|
14726
14580
|
thinkingFormat: "zai";
|
|
14581
|
+
zaiToolStream: true;
|
|
14727
14582
|
};
|
|
14728
14583
|
reasoning: true;
|
|
14729
14584
|
input: "text"[];
|
|
@@ -14745,6 +14600,7 @@ export declare const MODELS: {
|
|
|
14745
14600
|
compat: {
|
|
14746
14601
|
supportsDeveloperRole: false;
|
|
14747
14602
|
thinkingFormat: "zai";
|
|
14603
|
+
zaiToolStream: true;
|
|
14748
14604
|
};
|
|
14749
14605
|
reasoning: true;
|
|
14750
14606
|
input: ("image" | "text")[];
|