@agi-cli/sdk 0.1.138 → 0.1.140
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/package.json +1 -1
- package/src/core/src/index.ts +1 -1
- package/src/core/src/tools/builtin/bash.ts +1 -1
- package/src/core/src/tools/builtin/edit.ts +1 -1
- package/src/core/src/tools/builtin/finish.ts +1 -1
- package/src/core/src/tools/builtin/fs/cd.ts +1 -1
- package/src/core/src/tools/builtin/fs/ls.ts +1 -1
- package/src/core/src/tools/builtin/fs/pwd.ts +1 -1
- package/src/core/src/tools/builtin/fs/read.ts +1 -1
- package/src/core/src/tools/builtin/fs/tree.ts +1 -1
- package/src/core/src/tools/builtin/fs/write.ts +1 -1
- package/src/core/src/tools/builtin/git.ts +2 -2
- package/src/core/src/tools/builtin/glob.ts +1 -1
- package/src/core/src/tools/builtin/grep.ts +1 -1
- package/src/core/src/tools/builtin/patch.ts +1 -1
- package/src/core/src/tools/builtin/progress.ts +1 -1
- package/src/core/src/tools/builtin/ripgrep.ts +1 -1
- package/src/core/src/tools/builtin/terminal.ts +1 -1
- package/src/core/src/tools/builtin/todos.ts +1 -1
- package/src/core/src/tools/builtin/websearch.ts +1 -1
- package/src/core/src/tools/loader.ts +1 -1
- package/src/index.ts +5 -1
- package/src/prompts/src/providers.ts +17 -14
- package/src/providers/src/catalog.ts +268 -268
- package/src/providers/src/index.ts +4 -0
- package/src/providers/src/openai-oauth-client.ts +5 -1
- package/src/providers/src/opencode-client.ts +2 -18
- package/src/providers/src/openrouter-client.ts +3 -2
- package/src/providers/src/utils.ts +42 -2
- package/src/skills/tool.ts +1 -1
- package/src/types/src/provider.ts +1 -1
|
@@ -15,7 +15,11 @@ export {
|
|
|
15
15
|
getFastModelForAuth,
|
|
16
16
|
getModelNpmBinding,
|
|
17
17
|
isAnthropicBasedModel,
|
|
18
|
+
getUnderlyingProviderKey,
|
|
19
|
+
getModelInfo,
|
|
20
|
+
modelSupportsReasoning,
|
|
18
21
|
} from './utils.ts';
|
|
22
|
+
export type { UnderlyingProviderKey } from './utils.ts';
|
|
19
23
|
export { validateProviderModel } from './validate.ts';
|
|
20
24
|
export { estimateModelCostUsd } from './pricing.ts';
|
|
21
25
|
export { providerEnvVar, readEnvKey, setEnvKey } from './env.ts';
|
|
@@ -155,7 +155,7 @@ export function createOpenAIOAuthFetch(config: OpenAIOAuthConfig) {
|
|
|
155
155
|
parsed.include.push('reasoning.encrypted_content');
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
if (!parsed.
|
|
158
|
+
if (!parsed.reasoningText) {
|
|
159
159
|
const providerOpts = parsed.providerOptions?.openai || {};
|
|
160
160
|
parsed.reasoning = {
|
|
161
161
|
effort:
|
|
@@ -169,6 +169,9 @@ export function createOpenAIOAuthFetch(config: OpenAIOAuthConfig) {
|
|
|
169
169
|
};
|
|
170
170
|
} else {
|
|
171
171
|
const providerOpts = parsed.providerOptions?.openai || {};
|
|
172
|
+
if (!parsed.reasoning) {
|
|
173
|
+
parsed.reasoning = parsed.reasoningText;
|
|
174
|
+
}
|
|
172
175
|
if (!parsed.reasoning.effort) {
|
|
173
176
|
parsed.reasoning.effort =
|
|
174
177
|
providerOpts.reasoningEffort ||
|
|
@@ -181,6 +184,7 @@ export function createOpenAIOAuthFetch(config: OpenAIOAuthConfig) {
|
|
|
181
184
|
config.reasoningSummary ||
|
|
182
185
|
'auto';
|
|
183
186
|
}
|
|
187
|
+
delete parsed.reasoningText;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
delete parsed.max_output_tokens;
|
|
@@ -55,26 +55,10 @@ export function createOpencodeModel(
|
|
|
55
55
|
return instance(resolvedModelId);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
const cachingFetch = createAnthropicCachingFetch();
|
|
60
|
-
const ocAnthropic = createAnthropic({
|
|
61
|
-
apiKey,
|
|
62
|
-
baseURL,
|
|
63
|
-
fetch: cachingFetch as typeof fetch,
|
|
64
|
-
});
|
|
65
|
-
const ocCompat = createOpenAICompatible({
|
|
58
|
+
const defaultInstance = createOpenAICompatible({
|
|
66
59
|
name: entry?.label ?? 'opencode',
|
|
67
60
|
baseURL,
|
|
68
61
|
headers,
|
|
69
62
|
});
|
|
70
|
-
|
|
71
|
-
const id = resolvedModelId.toLowerCase();
|
|
72
|
-
if (id.includes('claude')) return ocAnthropic(resolvedModelId);
|
|
73
|
-
if (
|
|
74
|
-
id.includes('qwen3-coder') ||
|
|
75
|
-
id.includes('grok-code') ||
|
|
76
|
-
id.includes('kimi-k2')
|
|
77
|
-
)
|
|
78
|
-
return ocCompat(resolvedModelId);
|
|
79
|
-
return ocOpenAI(resolvedModelId);
|
|
63
|
+
return defaultInstance(resolvedModelId);
|
|
80
64
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createOpenRouter } from '@openrouter/ai-sdk-provider';
|
|
2
2
|
import { createConditionalCachingFetch } from './anthropic-caching.ts';
|
|
3
|
+
import { getModelNpmBinding } from './utils.ts';
|
|
3
4
|
|
|
4
5
|
export type OpenRouterProviderConfig = {
|
|
5
6
|
apiKey?: string;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
function isAnthropicModel(model: string): boolean {
|
|
9
|
-
const
|
|
10
|
-
return
|
|
10
|
+
const npm = getModelNpmBinding('openrouter', model);
|
|
11
|
+
return npm === '@ai-sdk/anthropic';
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function getOpenRouterInstance(
|
|
@@ -121,6 +121,46 @@ export function isAnthropicBasedModel(
|
|
|
121
121
|
if (provider === 'anthropic') return true;
|
|
122
122
|
const npm = getModelNpmBinding(provider, model);
|
|
123
123
|
if (npm === '@ai-sdk/anthropic') return true;
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type UnderlyingProviderKey =
|
|
128
|
+
| 'anthropic'
|
|
129
|
+
| 'openai'
|
|
130
|
+
| 'google'
|
|
131
|
+
| 'openai-compatible'
|
|
132
|
+
| null;
|
|
133
|
+
|
|
134
|
+
export function getUnderlyingProviderKey(
|
|
135
|
+
provider: ProviderId,
|
|
136
|
+
model: string,
|
|
137
|
+
): UnderlyingProviderKey {
|
|
138
|
+
if (provider === 'anthropic') return 'anthropic';
|
|
139
|
+
if (provider === 'openai') return 'openai';
|
|
140
|
+
if (provider === 'google') return 'google';
|
|
141
|
+
|
|
142
|
+
const npm = getModelNpmBinding(provider, model);
|
|
143
|
+
if (npm === '@ai-sdk/anthropic') return 'anthropic';
|
|
144
|
+
if (npm === '@ai-sdk/openai') return 'openai';
|
|
145
|
+
if (npm === '@ai-sdk/google') return 'google';
|
|
146
|
+
if (npm === '@ai-sdk/openai-compatible') return 'openai-compatible';
|
|
147
|
+
if (npm === '@openrouter/ai-sdk-provider') return 'openai-compatible';
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function getModelInfo(
|
|
152
|
+
provider: ProviderId,
|
|
153
|
+
model: string,
|
|
154
|
+
): ModelInfo | undefined {
|
|
155
|
+
const entry = catalog[provider];
|
|
156
|
+
if (!entry) return undefined;
|
|
157
|
+
return entry.models?.find((m) => m.id === model);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function modelSupportsReasoning(
|
|
161
|
+
provider: ProviderId,
|
|
162
|
+
model: string,
|
|
163
|
+
): boolean {
|
|
164
|
+
const info = getModelInfo(provider, model);
|
|
165
|
+
return info?.reasoningText === true;
|
|
126
166
|
}
|
package/src/skills/tool.ts
CHANGED