@rowan-agent/models 0.4.4 → 0.4.7
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 +169 -22
- package/dist/{chunk-J6S6ZJJA.js → chunk-C4RRYNAJ.js} +40 -26
- package/dist/{index-ChnUfIk1.d.cts → index-BGAiAdlQ.d.cts} +36 -33
- package/dist/{index-ChnUfIk1.d.ts → index-BGAiAdlQ.d.ts} +36 -33
- package/dist/index.cjs +67 -53
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +28 -28
- package/dist/providers/index.cjs +40 -26
- package/dist/providers/index.d.cts +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/package.json +7 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
streamAnthropic,
|
|
12
12
|
streamOpenAICompletions,
|
|
13
13
|
streamOpenAIResponses
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-C4RRYNAJ.js";
|
|
15
15
|
|
|
16
16
|
// src/protocol.ts
|
|
17
17
|
function textFromPartial(partial) {
|
|
@@ -85,7 +85,7 @@ var MODELS = {
|
|
|
85
85
|
"claude-sonnet-4-20250514": {
|
|
86
86
|
id: "claude-sonnet-4-20250514",
|
|
87
87
|
name: "Claude Sonnet 4",
|
|
88
|
-
|
|
88
|
+
protocol: "anthropic-messages",
|
|
89
89
|
provider: "anthropic",
|
|
90
90
|
baseUrl: "https://api.anthropic.com",
|
|
91
91
|
reasoning: true,
|
|
@@ -97,7 +97,7 @@ var MODELS = {
|
|
|
97
97
|
"claude-opus-4-20250514": {
|
|
98
98
|
id: "claude-opus-4-20250514",
|
|
99
99
|
name: "Claude Opus 4",
|
|
100
|
-
|
|
100
|
+
protocol: "anthropic-messages",
|
|
101
101
|
provider: "anthropic",
|
|
102
102
|
baseUrl: "https://api.anthropic.com",
|
|
103
103
|
reasoning: true,
|
|
@@ -109,7 +109,7 @@ var MODELS = {
|
|
|
109
109
|
"claude-haiku-4-20250514": {
|
|
110
110
|
id: "claude-haiku-4-20250514",
|
|
111
111
|
name: "Claude Haiku 4",
|
|
112
|
-
|
|
112
|
+
protocol: "anthropic-messages",
|
|
113
113
|
provider: "anthropic",
|
|
114
114
|
baseUrl: "https://api.anthropic.com",
|
|
115
115
|
reasoning: false,
|
|
@@ -123,7 +123,7 @@ var MODELS = {
|
|
|
123
123
|
"gpt-4o": {
|
|
124
124
|
id: "gpt-4o",
|
|
125
125
|
name: "GPT-4o",
|
|
126
|
-
|
|
126
|
+
protocol: "openai-completions",
|
|
127
127
|
provider: "openai",
|
|
128
128
|
baseUrl: "https://api.openai.com/v1",
|
|
129
129
|
reasoning: false,
|
|
@@ -135,7 +135,7 @@ var MODELS = {
|
|
|
135
135
|
"gpt-4o-mini": {
|
|
136
136
|
id: "gpt-4o-mini",
|
|
137
137
|
name: "GPT-4o Mini",
|
|
138
|
-
|
|
138
|
+
protocol: "openai-completions",
|
|
139
139
|
provider: "openai",
|
|
140
140
|
baseUrl: "https://api.openai.com/v1",
|
|
141
141
|
reasoning: false,
|
|
@@ -147,7 +147,7 @@ var MODELS = {
|
|
|
147
147
|
"o3": {
|
|
148
148
|
id: "o3",
|
|
149
149
|
name: "o3",
|
|
150
|
-
|
|
150
|
+
protocol: "openai-responses",
|
|
151
151
|
provider: "openai",
|
|
152
152
|
baseUrl: "https://api.openai.com/v1",
|
|
153
153
|
reasoning: true,
|
|
@@ -159,7 +159,7 @@ var MODELS = {
|
|
|
159
159
|
"o4-mini": {
|
|
160
160
|
id: "o4-mini",
|
|
161
161
|
name: "o4-mini",
|
|
162
|
-
|
|
162
|
+
protocol: "openai-responses",
|
|
163
163
|
provider: "openai",
|
|
164
164
|
baseUrl: "https://api.openai.com/v1",
|
|
165
165
|
reasoning: true,
|
|
@@ -171,7 +171,7 @@ var MODELS = {
|
|
|
171
171
|
"gpt-4.1": {
|
|
172
172
|
id: "gpt-4.1",
|
|
173
173
|
name: "GPT-4.1",
|
|
174
|
-
|
|
174
|
+
protocol: "openai-completions",
|
|
175
175
|
provider: "openai",
|
|
176
176
|
baseUrl: "https://api.openai.com/v1",
|
|
177
177
|
reasoning: false,
|
|
@@ -183,7 +183,7 @@ var MODELS = {
|
|
|
183
183
|
"gpt-4.1-mini": {
|
|
184
184
|
id: "gpt-4.1-mini",
|
|
185
185
|
name: "GPT-4.1 Mini",
|
|
186
|
-
|
|
186
|
+
protocol: "openai-completions",
|
|
187
187
|
provider: "openai",
|
|
188
188
|
baseUrl: "https://api.openai.com/v1",
|
|
189
189
|
reasoning: false,
|
|
@@ -197,7 +197,7 @@ var MODELS = {
|
|
|
197
197
|
"deepseek-chat": {
|
|
198
198
|
id: "deepseek-chat",
|
|
199
199
|
name: "DeepSeek V3",
|
|
200
|
-
|
|
200
|
+
protocol: "openai-completions",
|
|
201
201
|
provider: "deepseek",
|
|
202
202
|
baseUrl: "https://api.deepseek.com/v1",
|
|
203
203
|
reasoning: false,
|
|
@@ -209,7 +209,7 @@ var MODELS = {
|
|
|
209
209
|
"deepseek-reasoner": {
|
|
210
210
|
id: "deepseek-reasoner",
|
|
211
211
|
name: "DeepSeek R1",
|
|
212
|
-
|
|
212
|
+
protocol: "openai-completions",
|
|
213
213
|
provider: "deepseek",
|
|
214
214
|
baseUrl: "https://api.deepseek.com/v1",
|
|
215
215
|
reasoning: true,
|
|
@@ -223,7 +223,7 @@ var MODELS = {
|
|
|
223
223
|
"anthropic/claude-sonnet-4": {
|
|
224
224
|
id: "anthropic/claude-sonnet-4",
|
|
225
225
|
name: "Claude Sonnet 4 (OpenRouter)",
|
|
226
|
-
|
|
226
|
+
protocol: "openai-completions",
|
|
227
227
|
provider: "openrouter",
|
|
228
228
|
baseUrl: "https://openrouter.ai/api/v1",
|
|
229
229
|
reasoning: true,
|
|
@@ -238,10 +238,10 @@ var MODELS = {
|
|
|
238
238
|
// src/registry.ts
|
|
239
239
|
var apiProviderRegistry = /* @__PURE__ */ new Map();
|
|
240
240
|
function registerApiProvider(provider) {
|
|
241
|
-
apiProviderRegistry.set(provider.
|
|
241
|
+
apiProviderRegistry.set(provider.protocol, provider);
|
|
242
242
|
}
|
|
243
|
-
function getApiProvider(
|
|
244
|
-
return apiProviderRegistry.get(
|
|
243
|
+
function getApiProvider(protocol) {
|
|
244
|
+
return apiProviderRegistry.get(protocol);
|
|
245
245
|
}
|
|
246
246
|
function listApiProviders() {
|
|
247
247
|
return [...apiProviderRegistry.keys()];
|
|
@@ -249,30 +249,30 @@ function listApiProviders() {
|
|
|
249
249
|
function clearApiProviders() {
|
|
250
250
|
apiProviderRegistry.clear();
|
|
251
251
|
}
|
|
252
|
-
function unregisterApiProvider(
|
|
253
|
-
return apiProviderRegistry.delete(
|
|
252
|
+
function unregisterApiProvider(protocol) {
|
|
253
|
+
return apiProviderRegistry.delete(protocol);
|
|
254
254
|
}
|
|
255
255
|
function registerBuiltInApiProviders() {
|
|
256
|
-
registerApiProvider({
|
|
257
|
-
registerApiProvider({
|
|
258
|
-
registerApiProvider({
|
|
256
|
+
registerApiProvider({ protocol: "openai-completions", stream: streamOpenAICompletions });
|
|
257
|
+
registerApiProvider({ protocol: "openai-responses", stream: streamOpenAIResponses });
|
|
258
|
+
registerApiProvider({ protocol: "anthropic-messages", stream: streamAnthropic });
|
|
259
259
|
}
|
|
260
260
|
function stream(model, request, options) {
|
|
261
|
-
const provider = apiProviderRegistry.get(model.
|
|
261
|
+
const provider = apiProviderRegistry.get(model.protocol);
|
|
262
262
|
if (!provider) {
|
|
263
263
|
throw new Error(
|
|
264
|
-
`No API provider registered for
|
|
264
|
+
`No API provider registered for protocol "${model.protocol}". Registered: ${[...apiProviderRegistry.keys()].join(", ") || "(none)"}. Call registerBuiltInApiProviders() or registerApiProvider() first.`
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
267
|
return provider.stream(model, request, options);
|
|
268
268
|
}
|
|
269
269
|
function streamByRef(ref, request, options = {}) {
|
|
270
|
-
const model = typeof ref === "string" ? resolveModel(ref) : getModel(ref.provider, ref.
|
|
270
|
+
const model = typeof ref === "string" ? resolveModel(ref) : getModel(ref.provider, ref.id);
|
|
271
271
|
if (!model) {
|
|
272
|
-
const key = typeof ref === "string" ? ref : `${ref.provider}/${ref.
|
|
272
|
+
const key = typeof ref === "string" ? ref : `${ref.provider}/${ref.id}`;
|
|
273
273
|
throw new Error(`Model not found: "${key}". Register it with registerModel() first.`);
|
|
274
274
|
}
|
|
275
|
-
return stream(model, { ...request, model: { provider: model.provider,
|
|
275
|
+
return stream(model, { ...request, model: { provider: model.provider, id: model.id } }, options);
|
|
276
276
|
}
|
|
277
277
|
var legacyProviders = /* @__PURE__ */ new Map();
|
|
278
278
|
function registerProvider(name, factory) {
|
|
@@ -283,7 +283,7 @@ function createDispatchStream() {
|
|
|
283
283
|
registerBuiltInApiProviders();
|
|
284
284
|
}
|
|
285
285
|
return async function* dispatchStream(request, options) {
|
|
286
|
-
const model = getModel(request.model.provider, request.model.
|
|
286
|
+
const model = getModel(request.model.provider, request.model.id) ?? resolveModel(request.model.id);
|
|
287
287
|
if (model) {
|
|
288
288
|
yield* stream(model, request, options);
|
|
289
289
|
return;
|
|
@@ -295,7 +295,7 @@ function createDispatchStream() {
|
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
throw new Error(
|
|
298
|
-
`No provider for "${request.model.provider}/${request.model.
|
|
298
|
+
`No provider for "${request.model.provider}/${request.model.id}". Register a model with registerModel() or a provider with registerProvider().`
|
|
299
299
|
);
|
|
300
300
|
};
|
|
301
301
|
}
|
package/dist/providers/index.cjs
CHANGED
|
@@ -49,9 +49,6 @@ var ProviderError = class extends Error {
|
|
|
49
49
|
this.details = input.details;
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
function defaultEnv() {
|
|
53
|
-
return process.env;
|
|
54
|
-
}
|
|
55
52
|
function normalizeBaseUrl(baseUrl) {
|
|
56
53
|
return baseUrl.replace(/\/+$/, "");
|
|
57
54
|
}
|
|
@@ -188,6 +185,14 @@ function normalizeUsage(usage) {
|
|
|
188
185
|
function summarizeRequestUsage(request) {
|
|
189
186
|
return { inputMessages: request.messages.length + (request.system ? 1 : 0) };
|
|
190
187
|
}
|
|
188
|
+
function sanitizeToolInput(input) {
|
|
189
|
+
if (typeof input !== "string") return input;
|
|
190
|
+
try {
|
|
191
|
+
return JSON.parse(input);
|
|
192
|
+
} catch {
|
|
193
|
+
return input;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
191
196
|
|
|
192
197
|
// src/sse.ts
|
|
193
198
|
function flushSseEvent(state) {
|
|
@@ -283,14 +288,13 @@ async function* iterateSseMessages(body, signal) {
|
|
|
283
288
|
|
|
284
289
|
// src/providers/openai-completions.ts
|
|
285
290
|
function resolveOpenAICompletionsConfig(input = {}) {
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
const model = nonEmpty(input.model) ?? nonEmpty(env.ROWAN_MODEL);
|
|
291
|
+
const baseUrl = nonEmpty(input.baseUrl) ?? "https://api.openai.com/v1";
|
|
292
|
+
const apiKey = nonEmpty(input.apiKey);
|
|
293
|
+
const model = nonEmpty(input.model);
|
|
290
294
|
return {
|
|
291
295
|
baseUrl: normalizeBaseUrl(baseUrl),
|
|
292
|
-
apiKey: requireValue("API key", apiKey, "set
|
|
293
|
-
model: requireValue("model", model, "
|
|
296
|
+
apiKey: requireValue("API key", apiKey, "model.apiKey is required (set apiKey in config.yaml or pass --api-key)"),
|
|
297
|
+
model: requireValue("model", model, "model.id is required"),
|
|
294
298
|
...input.temperature !== void 0 ? { temperature: input.temperature } : {},
|
|
295
299
|
...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {},
|
|
296
300
|
...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {},
|
|
@@ -366,7 +370,7 @@ function convertMessages(messages) {
|
|
|
366
370
|
type: "function",
|
|
367
371
|
function: {
|
|
368
372
|
name: p.name,
|
|
369
|
-
arguments:
|
|
373
|
+
arguments: JSON.stringify(sanitizeToolInput(p.input))
|
|
370
374
|
}
|
|
371
375
|
}));
|
|
372
376
|
result.push({ role: "assistant", content: text, tool_calls: toolCalls });
|
|
@@ -618,7 +622,11 @@ function createOpenAICompletionsStream(config) {
|
|
|
618
622
|
var streamOpenAICompletions = (model, request, options) => {
|
|
619
623
|
const config = resolveOpenAICompletionsConfig({
|
|
620
624
|
baseUrl: model.baseUrl,
|
|
621
|
-
model: model.id
|
|
625
|
+
model: model.id,
|
|
626
|
+
apiKey: model.apiKey,
|
|
627
|
+
timeoutMs: model.timeoutMs,
|
|
628
|
+
maxRetries: model.maxRetries,
|
|
629
|
+
retryDelayMs: model.retryDelayMs
|
|
622
630
|
});
|
|
623
631
|
return streamChatCompletions(config, request, options);
|
|
624
632
|
};
|
|
@@ -656,14 +664,13 @@ async function callOpenAICompletions(config, request, options = {}) {
|
|
|
656
664
|
|
|
657
665
|
// src/providers/openai-responses.ts
|
|
658
666
|
function resolveOpenAIResponsesConfig(input = {}) {
|
|
659
|
-
const
|
|
660
|
-
const
|
|
661
|
-
const
|
|
662
|
-
const model = nonEmpty(input.model) ?? nonEmpty(env.ROWAN_MODEL);
|
|
667
|
+
const baseUrl = nonEmpty(input.baseUrl) ?? "https://api.openai.com/v1";
|
|
668
|
+
const apiKey = nonEmpty(input.apiKey);
|
|
669
|
+
const model = nonEmpty(input.model);
|
|
663
670
|
return {
|
|
664
671
|
baseUrl: normalizeBaseUrl(baseUrl),
|
|
665
|
-
apiKey: requireValue("API key", apiKey, "set
|
|
666
|
-
model: requireValue("model", model, "
|
|
672
|
+
apiKey: requireValue("API key", apiKey, "model.apiKey is required (set apiKey in config.yaml or pass --api-key)"),
|
|
673
|
+
model: requireValue("model", model, "model.id is required"),
|
|
667
674
|
...input.temperature !== void 0 ? { temperature: input.temperature } : {},
|
|
668
675
|
...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {},
|
|
669
676
|
...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {},
|
|
@@ -710,7 +717,7 @@ function convertMessages2(messages) {
|
|
|
710
717
|
type: "function_call",
|
|
711
718
|
id: part.id,
|
|
712
719
|
name: part.name,
|
|
713
|
-
arguments:
|
|
720
|
+
arguments: JSON.stringify(sanitizeToolInput(part.input))
|
|
714
721
|
});
|
|
715
722
|
}
|
|
716
723
|
}
|
|
@@ -941,7 +948,11 @@ function createOpenAIResponsesStream(config) {
|
|
|
941
948
|
var streamOpenAIResponses = (model, request, options) => {
|
|
942
949
|
const config = resolveOpenAIResponsesConfig({
|
|
943
950
|
baseUrl: model.baseUrl,
|
|
944
|
-
model: model.id
|
|
951
|
+
model: model.id,
|
|
952
|
+
apiKey: model.apiKey,
|
|
953
|
+
timeoutMs: model.timeoutMs,
|
|
954
|
+
maxRetries: model.maxRetries,
|
|
955
|
+
retryDelayMs: model.retryDelayMs
|
|
945
956
|
});
|
|
946
957
|
return streamResponses(config, request, options);
|
|
947
958
|
};
|
|
@@ -949,14 +960,13 @@ var streamOpenAIResponses = (model, request, options) => {
|
|
|
949
960
|
// src/providers/anthropic.ts
|
|
950
961
|
var DEFAULT_MAX_TOKENS = 8192;
|
|
951
962
|
function resolveAnthropicConfig(input = {}) {
|
|
952
|
-
const
|
|
953
|
-
const
|
|
954
|
-
const
|
|
955
|
-
const model = nonEmpty(input.model) ?? nonEmpty(env.ROWAN_MODEL);
|
|
963
|
+
const baseUrl = nonEmpty(input.baseUrl) ?? "https://api.anthropic.com";
|
|
964
|
+
const apiKey = nonEmpty(input.apiKey);
|
|
965
|
+
const model = nonEmpty(input.model);
|
|
956
966
|
return {
|
|
957
967
|
baseUrl: normalizeBaseUrl(baseUrl),
|
|
958
|
-
apiKey: requireValue("API key", apiKey, "set
|
|
959
|
-
model: requireValue("model", model, "
|
|
968
|
+
apiKey: requireValue("API key", apiKey, "model.apiKey is required (set apiKey in config.yaml or pass --api-key)"),
|
|
969
|
+
model: requireValue("model", model, "model.id is required"),
|
|
960
970
|
...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {},
|
|
961
971
|
...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : {},
|
|
962
972
|
...input.maxRetries !== void 0 ? { maxRetries: input.maxRetries } : {},
|
|
@@ -1242,7 +1252,11 @@ function createAnthropicStream(config) {
|
|
|
1242
1252
|
var streamAnthropic = (model, request, options) => {
|
|
1243
1253
|
const config = resolveAnthropicConfig({
|
|
1244
1254
|
baseUrl: model.baseUrl,
|
|
1245
|
-
model: model.id
|
|
1255
|
+
model: model.id,
|
|
1256
|
+
apiKey: model.apiKey,
|
|
1257
|
+
timeoutMs: model.timeoutMs,
|
|
1258
|
+
maxRetries: model.maxRetries,
|
|
1259
|
+
retryDelayMs: model.retryDelayMs
|
|
1246
1260
|
});
|
|
1247
1261
|
return streamAnthropicMessages(config, request, options);
|
|
1248
1262
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { h as AnthropicConfig, B as BaseProviderConfig, O as OpenAICompletionsConfig, z as OpenAIResponsesConfig, F as ProviderError, G as ProviderFetch, R as ResolveAnthropicConfigInput, I as ResolveOpenAICompletionsConfigInput, J as ResolveOpenAIResponsesConfigInput, X as callOpenAICompletions, Y as createAnthropicStream, Z as createOpenAICompletionsStream, _ as createOpenAIResponsesStream, $ as resolveAnthropicConfig, a0 as resolveOpenAICompletionsConfig, a1 as resolveOpenAIResponsesConfig, a2 as streamAnthropic, a3 as streamOpenAICompletions, a4 as streamOpenAIResponses } from '../index-BGAiAdlQ.cjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { h as AnthropicConfig, B as BaseProviderConfig, O as OpenAICompletionsConfig, z as OpenAIResponsesConfig, F as ProviderError, G as ProviderFetch, R as ResolveAnthropicConfigInput, I as ResolveOpenAICompletionsConfigInput, J as ResolveOpenAIResponsesConfigInput, X as callOpenAICompletions, Y as createAnthropicStream, Z as createOpenAICompletionsStream, _ as createOpenAIResponsesStream, $ as resolveAnthropicConfig, a0 as resolveOpenAICompletionsConfig, a1 as resolveOpenAIResponsesConfig, a2 as streamAnthropic, a3 as streamOpenAICompletions, a4 as streamOpenAIResponses } from '../index-BGAiAdlQ.js';
|
package/dist/providers/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowan-agent/models",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/aiirobyte/rowan-agent.git",
|
|
8
|
+
"directory": "packages/models"
|
|
9
|
+
},
|
|
4
10
|
"type": "module",
|
|
5
11
|
"main": "./dist/index.cjs",
|
|
6
12
|
"module": "./dist/index.js",
|