@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.
@@ -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.reasoning) {
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 ocOpenAI = createOpenAI({ apiKey, baseURL });
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 lower = model.toLowerCase();
10
- return lower.includes('anthropic') || lower.includes('claude');
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
- const lower = model.toLowerCase();
125
- return lower.includes('claude') || lower.includes('anthropic');
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
  }
@@ -1,5 +1,5 @@
1
1
  import { tool, type Tool } from 'ai';
2
- import { z } from 'zod';
2
+ import { z } from 'zod/v3';
3
3
  import { loadSkill, discoverSkills, findGitRoot } from './loader.ts';
4
4
  import type { DiscoveredSkill, SkillResult } from './types.ts';
5
5
 
@@ -26,7 +26,7 @@ export type ModelInfo = {
26
26
  label?: string;
27
27
  modalities?: { input?: string[]; output?: string[] };
28
28
  toolCall?: boolean;
29
- reasoning?: boolean;
29
+ reasoningText?: boolean;
30
30
  attachment?: boolean;
31
31
  temperature?: boolean | number;
32
32
  knowledge?: string;