@ank1015/providers 0.0.33 → 0.0.34
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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +10 -0
- package/dist/llm.js.map +1 -1
- package/dist/models.generated.d.ts +53 -0
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +53 -0
- package/dist/models.generated.js.map +1 -1
- package/dist/providers/anthropic/complete.d.ts +3 -0
- package/dist/providers/anthropic/complete.d.ts.map +1 -0
- package/dist/providers/anthropic/complete.js +53 -0
- package/dist/providers/anthropic/complete.js.map +1 -0
- package/dist/providers/anthropic/index.d.ts +4 -0
- package/dist/providers/anthropic/index.d.ts.map +1 -0
- package/dist/providers/anthropic/index.js +4 -0
- package/dist/providers/anthropic/index.js.map +1 -0
- package/dist/providers/anthropic/stream.d.ts +3 -0
- package/dist/providers/anthropic/stream.d.ts.map +1 -0
- package/dist/providers/anthropic/stream.js +258 -0
- package/dist/providers/anthropic/stream.js.map +1 -0
- package/dist/providers/anthropic/types.d.ts +9 -0
- package/dist/providers/anthropic/types.d.ts.map +1 -0
- package/dist/providers/anthropic/types.js +2 -0
- package/dist/providers/anthropic/types.js.map +1 -0
- package/dist/providers/anthropic/utils.d.ts +15 -0
- package/dist/providers/anthropic/utils.d.ts.map +1 -0
- package/dist/providers/anthropic/utils.js +318 -0
- package/dist/providers/anthropic/utils.js.map +1 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/oauth/anthropic.d.ts +16 -0
- package/dist/utils/oauth/anthropic.d.ts.map +1 -0
- package/dist/utils/oauth/anthropic.js +99 -0
- package/dist/utils/oauth/anthropic.js.map +1 -0
- package/dist/utils/oauth/index.d.ts +32 -0
- package/dist/utils/oauth/index.d.ts.map +1 -0
- package/dist/utils/oauth/index.js +70 -0
- package/dist/utils/oauth/index.js.map +1 -0
- package/dist/utils/oauth/types.d.ts +24 -0
- package/dist/utils/oauth/types.d.ts.map +1 -0
- package/dist/utils/oauth/types.js +2 -0
- package/dist/utils/oauth/types.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './llm.js';
|
|
|
6
6
|
export * from './providers/openai/index.js';
|
|
7
7
|
export * from './providers/google/index.js';
|
|
8
8
|
export * from './providers/deepseek/index.js';
|
|
9
|
+
export * from './providers/anthropic/index.js';
|
|
9
10
|
export * from './agent/conversation.js';
|
|
10
11
|
export * from './agent/utils.js';
|
|
11
12
|
export * from './utils/sanitize-unicode.js';
|
|
@@ -14,5 +15,6 @@ export * from './utils/validation.js';
|
|
|
14
15
|
export * from './utils/overflow.js';
|
|
15
16
|
export * from './utils/event-stream.js';
|
|
16
17
|
export * from './utils/json-parse.js';
|
|
18
|
+
export * from './utils/oauth/index.js';
|
|
17
19
|
export * from './agent/tools/index.js';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AAEtC,cAAc,UAAU,CAAC;AACzB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AAEtC,cAAc,UAAU,CAAC;AACzB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,wBAAwB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './llm.js';
|
|
|
6
6
|
export * from './providers/openai/index.js';
|
|
7
7
|
export * from './providers/google/index.js';
|
|
8
8
|
export * from './providers/deepseek/index.js';
|
|
9
|
+
export * from './providers/anthropic/index.js';
|
|
9
10
|
export * from './agent/conversation.js';
|
|
10
11
|
export * from './agent/utils.js';
|
|
11
12
|
export * from './utils/sanitize-unicode.js';
|
|
@@ -14,5 +15,6 @@ export * from './utils/validation.js';
|
|
|
14
15
|
export * from './utils/overflow.js';
|
|
15
16
|
export * from './utils/event-stream.js';
|
|
16
17
|
export * from './utils/json-parse.js';
|
|
18
|
+
export * from './utils/oauth/index.js';
|
|
17
19
|
export * from './agent/tools/index.js';
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AAEtC,cAAc,UAAU,CAAC;AACzB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AAEtC,cAAc,UAAU,CAAC;AACzB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,wBAAwB,CAAA"}
|
package/dist/llm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAatE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,sBAGxC;AAGD,wBAAsB,QAAQ,CAAC,IAAI,SAAS,GAAG,EAC3C,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,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,CAAC;IAItC,MAAM,CAAC,IAAI,SAAS,GAAG,EACnB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,EAC7B,EAAE,CAAC,EAAE,MAAM,GACZ,2BAA2B,CAAC,IAAI,CAAC;CAGvC"}
|
package/dist/llm.js
CHANGED
|
@@ -5,10 +5,13 @@ import { getMockOpenaiMessage } from "./providers/openai/utils.js";
|
|
|
5
5
|
import { completeDeepSeek, streamDeepSeek } from "./providers/deepseek/index.js";
|
|
6
6
|
import { getMockDeepSeekMessage } from "./providers/deepseek/utils.js";
|
|
7
7
|
import { generateUUID } from "./utils/uuid.js";
|
|
8
|
+
import { completeAnthropic, streamAnthropic } from "./providers/anthropic/index.js";
|
|
9
|
+
import { getMockAnthropicMessage } from "./providers/anthropic/utils.js";
|
|
8
10
|
const envMap = {
|
|
9
11
|
openai: "OPENAI_API_KEY",
|
|
10
12
|
google: "GEMINI_API_KEY",
|
|
11
13
|
deepseek: "DEEPSEEK_API_KEY",
|
|
14
|
+
anthropic: "ANTHROPIC_API_KEY"
|
|
12
15
|
};
|
|
13
16
|
export function getApiKeyFromEnv(api) {
|
|
14
17
|
const envVar = envMap[api];
|
|
@@ -30,6 +33,8 @@ export async function complete(model, context, options, id) {
|
|
|
30
33
|
return completeGoogle(model, context, providerOptions, messageId);
|
|
31
34
|
case 'deepseek':
|
|
32
35
|
return completeDeepSeek(model, context, providerOptions, messageId);
|
|
36
|
+
case 'anthropic':
|
|
37
|
+
return completeAnthropic(model, context, providerOptions, messageId);
|
|
33
38
|
default: {
|
|
34
39
|
const _exhaustive = model.api;
|
|
35
40
|
throw new Error(`Unhandled API: ${_exhaustive}`);
|
|
@@ -52,6 +57,8 @@ export function stream(model, context, options, id) {
|
|
|
52
57
|
return streamGoogle(model, context, providerOptions, messageId);
|
|
53
58
|
case 'deepseek':
|
|
54
59
|
return streamDeepSeek(model, context, providerOptions, messageId);
|
|
60
|
+
case 'anthropic':
|
|
61
|
+
return streamAnthropic(model, context, providerOptions, messageId);
|
|
55
62
|
default: {
|
|
56
63
|
const _exhaustive = model.api;
|
|
57
64
|
throw new Error(`Unhandled API: ${_exhaustive}`);
|
|
@@ -70,6 +77,9 @@ export function getMockMessage(model) {
|
|
|
70
77
|
else if (model.api === 'deepseek') {
|
|
71
78
|
message = getMockDeepSeekMessage();
|
|
72
79
|
}
|
|
80
|
+
else if (model.api === 'anthropic') {
|
|
81
|
+
message = getMockAnthropicMessage();
|
|
82
|
+
}
|
|
73
83
|
const baseMessage = {
|
|
74
84
|
role: 'assistant',
|
|
75
85
|
message: message,
|
package/dist/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAA2B,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM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E,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;SACvE;KACJ,CAAA;IACD,OAAO,WAAW,CAAA;AACtB,CAAC;AAkBD,MAAM,OAAO,gBAAgB;IACzB,KAAK,CAAC,QAAQ,CACV,KAAkB,EAClB,OAAgB,EAChB,OAA6B,EAC7B,EAAW;QAEX,OAAO,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CACF,KAAkB,EAClB,OAAgB,EAChB,OAA6B,EAC7B,EAAW;QAEX,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;CACJ"}
|
|
@@ -175,5 +175,58 @@ export declare const MODELS: {
|
|
|
175
175
|
tools: string[];
|
|
176
176
|
};
|
|
177
177
|
};
|
|
178
|
+
anthropic: {
|
|
179
|
+
"claude-haiku-4-5": {
|
|
180
|
+
id: string;
|
|
181
|
+
name: string;
|
|
182
|
+
api: "anthropic";
|
|
183
|
+
baseUrl: string;
|
|
184
|
+
reasoning: true;
|
|
185
|
+
input: ("text" | "image")[];
|
|
186
|
+
cost: {
|
|
187
|
+
input: number;
|
|
188
|
+
output: number;
|
|
189
|
+
cacheRead: number;
|
|
190
|
+
cacheWrite: number;
|
|
191
|
+
};
|
|
192
|
+
contextWindow: number;
|
|
193
|
+
maxTokens: number;
|
|
194
|
+
tools: string[];
|
|
195
|
+
};
|
|
196
|
+
"claude-opus-4-5": {
|
|
197
|
+
id: string;
|
|
198
|
+
name: string;
|
|
199
|
+
api: "anthropic";
|
|
200
|
+
baseUrl: string;
|
|
201
|
+
reasoning: true;
|
|
202
|
+
input: ("text" | "image")[];
|
|
203
|
+
cost: {
|
|
204
|
+
input: number;
|
|
205
|
+
output: number;
|
|
206
|
+
cacheRead: number;
|
|
207
|
+
cacheWrite: number;
|
|
208
|
+
};
|
|
209
|
+
contextWindow: number;
|
|
210
|
+
maxTokens: number;
|
|
211
|
+
tools: string[];
|
|
212
|
+
};
|
|
213
|
+
"claude-sonnet-4-5": {
|
|
214
|
+
id: string;
|
|
215
|
+
name: string;
|
|
216
|
+
api: "anthropic";
|
|
217
|
+
baseUrl: string;
|
|
218
|
+
reasoning: true;
|
|
219
|
+
input: ("text" | "image")[];
|
|
220
|
+
cost: {
|
|
221
|
+
input: number;
|
|
222
|
+
output: number;
|
|
223
|
+
cacheRead: number;
|
|
224
|
+
cacheWrite: number;
|
|
225
|
+
};
|
|
226
|
+
contextWindow: number;
|
|
227
|
+
maxTokens: number;
|
|
228
|
+
tools: string[];
|
|
229
|
+
};
|
|
230
|
+
};
|
|
178
231
|
};
|
|
179
232
|
//# sourceMappingURL=models.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.generated.d.ts","sourceRoot":"","sources":["../src/models.generated.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"models.generated.d.ts","sourceRoot":"","sources":["../src/models.generated.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuOlB,CAAA"}
|
package/dist/models.generated.js
CHANGED
|
@@ -174,6 +174,59 @@ export const MODELS = {
|
|
|
174
174
|
maxTokens: 64000,
|
|
175
175
|
tools: ['function_calling'],
|
|
176
176
|
},
|
|
177
|
+
},
|
|
178
|
+
anthropic: {
|
|
179
|
+
"claude-haiku-4-5": {
|
|
180
|
+
id: "claude-haiku-4-5",
|
|
181
|
+
name: "Claude Haiku 4.5 (latest)",
|
|
182
|
+
api: "anthropic",
|
|
183
|
+
baseUrl: "https://api.anthropic.com",
|
|
184
|
+
reasoning: true,
|
|
185
|
+
input: ["text", "image"],
|
|
186
|
+
cost: {
|
|
187
|
+
input: 1,
|
|
188
|
+
output: 5,
|
|
189
|
+
cacheRead: 0.1,
|
|
190
|
+
cacheWrite: 1.25,
|
|
191
|
+
},
|
|
192
|
+
contextWindow: 200000,
|
|
193
|
+
maxTokens: 64000,
|
|
194
|
+
tools: ['function_calling'],
|
|
195
|
+
},
|
|
196
|
+
"claude-opus-4-5": {
|
|
197
|
+
id: "claude-opus-4-5",
|
|
198
|
+
name: "Claude Opus 4.5 (latest)",
|
|
199
|
+
api: "anthropic",
|
|
200
|
+
baseUrl: "https://api.anthropic.com",
|
|
201
|
+
reasoning: true,
|
|
202
|
+
input: ["text", "image"],
|
|
203
|
+
cost: {
|
|
204
|
+
input: 5,
|
|
205
|
+
output: 25,
|
|
206
|
+
cacheRead: 0.5,
|
|
207
|
+
cacheWrite: 6.25,
|
|
208
|
+
},
|
|
209
|
+
contextWindow: 200000,
|
|
210
|
+
maxTokens: 64000,
|
|
211
|
+
tools: ['function_calling'],
|
|
212
|
+
},
|
|
213
|
+
"claude-sonnet-4-5": {
|
|
214
|
+
id: "claude-sonnet-4-5",
|
|
215
|
+
name: "Claude Sonnet 4.5 (latest)",
|
|
216
|
+
api: "anthropic",
|
|
217
|
+
baseUrl: "https://api.anthropic.com",
|
|
218
|
+
reasoning: true,
|
|
219
|
+
input: ["text", "image"],
|
|
220
|
+
cost: {
|
|
221
|
+
input: 3,
|
|
222
|
+
output: 15,
|
|
223
|
+
cacheRead: 0.3,
|
|
224
|
+
cacheWrite: 3.75,
|
|
225
|
+
},
|
|
226
|
+
contextWindow: 200000,
|
|
227
|
+
maxTokens: 64000,
|
|
228
|
+
tools: ['function_calling'],
|
|
229
|
+
},
|
|
177
230
|
}
|
|
178
231
|
};
|
|
179
232
|
//# sourceMappingURL=models.generated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.generated.js","sourceRoot":"","sources":["../src/models.generated.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,MAAM,EAAE;QACP,SAAS,EAAE;YACV,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,QAAQ;YACb,OAAO,EAAE,2BAA2B;YACpC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;YAChC,IAAI,EAAE;gBACL,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,KAAK;gBAChB,UAAU,EAAE,CAAC;aACb;YACD,aAAa,EAAE,MAAM;YACrB,SAAS,EAAE,MAAM;YACjB,KAAK,EAAE,CAAC,kBAAkB,CAAC;SACD;QAC3B,aAAa,EAAE;YACd,EAAE,EAAE,aAAa;YACjB,IAAI,EAAE,aAAa;YACnB,GAAG,EAAE,QAAQ;YACb,OAAO,EAAE,2BAA2B;YACpC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;YAChC,IAAI,EAAE;gBACL,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,GAAG;gBACX,SAAS,EAAE,EAAE;gBACb,UAAU,EAAE,CAAC;aACb;YACD,aAAa,EAAE,MAAM;YACrB,SAAS,EAAE,MAAM;YACjB,KAAK,EAAE,CAAC,kBAAkB,CAAC;SACD;QAC3B,mBAAmB,EAAE;YACpB,EAAE,EAAE,mBAAmB;YACvB,IAAI,EAAE,mBAAmB;YACzB,GAAG,EAAE,QAAQ;YACb,OAAO,EAAE,2BAA2B;YACpC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,CAAC,MAAM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3D,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YACxB,IAAI,EAAE;gBACL,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,CAAC;gBACZ,UAAU,EAAE,CAAC;aACb;YACD,aAAa,EAAE,KAAK;YACpB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACiB;KAC3B;IACD,QAAQ,EAAE;QACT,UAAU,EAAE;YACX,EAAE,EAAE,mBAAmB;YACvB,IAAI,EAAE,eAAe;YACrB,GAAG,EAAE,UAAU;YACf,OAAO,EAAE,0BAA0B;YACnC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,IAAI,EAAE;gBACL,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,KAAK;gBAChB,UAAU,EAAE,CAAC;aACb;YACD,aAAa,EAAE,MAAM;YACrB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,CAAC,kBAAkB,CAAC;SACC;KAC7B;CACD,CAAA"}
|
|
1
|
+
{"version":3,"file":"models.generated.js","sourceRoot":"","sources":["../src/models.generated.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,MAAM,EAAE;QACP,SAAS,EAAE;YACV,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,QAAQ;YACb,OAAO,EAAE,2BAA2B;YACpC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;YAChC,IAAI,EAAE;gBACL,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,KAAK;gBAChB,UAAU,EAAE,CAAC;aACb;YACD,aAAa,EAAE,MAAM;YACrB,SAAS,EAAE,MAAM;YACjB,KAAK,EAAE,CAAC,kBAAkB,CAAC;SACD;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B,KAAK,EAAE,CAAC,kBAAkB,CAAC;SACE;KAE9B;CACD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/complete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqC,MAAM,gBAAgB,CAAC;AAKrF,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,WAAW,CA8D3D,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createClient, buildParams, getResponseAssistantResponse, getResponseUsage, mapStopReason } from "./utils.js";
|
|
2
|
+
export const completeAnthropic = async (model, context, options, id) => {
|
|
3
|
+
const startTimestamp = Date.now();
|
|
4
|
+
const { client, isOAuthToken } = createClient(model, options?.apiKey, true);
|
|
5
|
+
const params = buildParams(model, context, options, isOAuthToken);
|
|
6
|
+
try {
|
|
7
|
+
const response = await client.messages.create(params, { signal: options?.signal });
|
|
8
|
+
// Cache processed content for performance and consistency
|
|
9
|
+
const content = getResponseAssistantResponse(response);
|
|
10
|
+
const usage = getResponseUsage(response, model);
|
|
11
|
+
let stopReason = mapStopReason(response.stop_reason);
|
|
12
|
+
return {
|
|
13
|
+
role: "assistant",
|
|
14
|
+
message: response,
|
|
15
|
+
id,
|
|
16
|
+
api: model.api,
|
|
17
|
+
model,
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
duration: Date.now() - startTimestamp,
|
|
20
|
+
stopReason,
|
|
21
|
+
content,
|
|
22
|
+
usage
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
27
|
+
const isAborted = options.signal?.aborted;
|
|
28
|
+
const stopReason = isAborted ? "aborted" : "error";
|
|
29
|
+
// Return error response with empty content and zero usage
|
|
30
|
+
const emptyUsage = {
|
|
31
|
+
input: 0,
|
|
32
|
+
output: 0,
|
|
33
|
+
cacheRead: 0,
|
|
34
|
+
cacheWrite: 0,
|
|
35
|
+
totalTokens: 0,
|
|
36
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
role: "assistant",
|
|
40
|
+
message: {}, // Empty response object for error case
|
|
41
|
+
id,
|
|
42
|
+
api: model.api,
|
|
43
|
+
model,
|
|
44
|
+
errorMessage,
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
duration: Date.now() - startTimestamp,
|
|
47
|
+
stopReason,
|
|
48
|
+
content: [],
|
|
49
|
+
usage: emptyUsage
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=complete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.js","sourceRoot":"","sources":["../../../src/providers/anthropic/complete.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,aAAa,EAA2B,MAAM,YAAY,CAAC;AAE/I,MAAM,CAAC,MAAM,iBAAiB,GAAkC,KAAK,EACpE,KAAyB,EACzB,OAAgB,EAChB,OAAiC,EACjC,EAAU,EACT,EAAE;IAEA,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5E,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAElE,IAAG,CAAC;QAEA,MAAM,QAAQ,GAAY,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAY,CAAA;QAEtG,0DAA0D;QAC1D,MAAM,OAAO,GA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,GAAG,EAAE;YACrB,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc;YACrC,UAAU;YACV,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,UAAU;SACpB,CAAC;IACN,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/anthropic/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAuJ,MAAM,gBAAgB,CAAA;AAUpM,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,WAAW,CA2QvD,CAAA"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { AssistantMessageEventStream } from "../../utils/event-stream.js";
|
|
2
|
+
import { buildParams, createClient, mapStopReason } from "./utils.js";
|
|
3
|
+
import { calculateCost } from "../../models.js";
|
|
4
|
+
import { parseStreamingJson } from "../../utils/json-parse.js";
|
|
5
|
+
export const streamAnthropic = (model, context, options, id) => {
|
|
6
|
+
const stream = new AssistantMessageEventStream();
|
|
7
|
+
(async () => {
|
|
8
|
+
const startTimestamp = Date.now();
|
|
9
|
+
const output = {
|
|
10
|
+
role: "assistant",
|
|
11
|
+
api: model.api,
|
|
12
|
+
model: model,
|
|
13
|
+
id,
|
|
14
|
+
content: [],
|
|
15
|
+
usage: {
|
|
16
|
+
input: 0,
|
|
17
|
+
output: 0,
|
|
18
|
+
cacheRead: 0,
|
|
19
|
+
cacheWrite: 0,
|
|
20
|
+
totalTokens: 0,
|
|
21
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
22
|
+
},
|
|
23
|
+
stopReason: "stop",
|
|
24
|
+
timestamp: startTimestamp,
|
|
25
|
+
duration: 0
|
|
26
|
+
};
|
|
27
|
+
let finalResponse = {
|
|
28
|
+
id: "msg_01XFDUDYJgAACzvnptvVoYEL",
|
|
29
|
+
type: "message",
|
|
30
|
+
role: "assistant",
|
|
31
|
+
content: [],
|
|
32
|
+
model: "claude-sonnet-4-5",
|
|
33
|
+
stop_reason: "end_turn",
|
|
34
|
+
stop_sequence: null,
|
|
35
|
+
usage: {
|
|
36
|
+
input_tokens: 0,
|
|
37
|
+
output_tokens: 0,
|
|
38
|
+
cache_creation_input_tokens: 0,
|
|
39
|
+
cache_read_input_tokens: 0,
|
|
40
|
+
cache_creation: null,
|
|
41
|
+
server_tool_use: null,
|
|
42
|
+
service_tier: null
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const blocks = output.content;
|
|
46
|
+
const accumulatedContent = [];
|
|
47
|
+
try {
|
|
48
|
+
const { client, isOAuthToken } = createClient(model, options?.apiKey, true);
|
|
49
|
+
const params = buildParams(model, context, options, isOAuthToken);
|
|
50
|
+
const paramsStreaming = { ...params, stream: true };
|
|
51
|
+
const anthropicStream = client.messages.stream(paramsStreaming, { signal: options?.signal });
|
|
52
|
+
stream.push({ type: "start", message: { ...output, timestamp: Date.now() } });
|
|
53
|
+
for await (const event of anthropicStream) {
|
|
54
|
+
if (event.type === "message_start") {
|
|
55
|
+
// Capture message metadata from message_start event
|
|
56
|
+
finalResponse.id = event.message.id;
|
|
57
|
+
finalResponse.model = event.message.model;
|
|
58
|
+
finalResponse.role = event.message.role;
|
|
59
|
+
finalResponse.type = event.message.type;
|
|
60
|
+
finalResponse.stop_sequence = event.message.stop_sequence;
|
|
61
|
+
// Capture initial token usage from message_start event
|
|
62
|
+
// This ensures we have input token counts even if the stream is aborted early
|
|
63
|
+
output.usage.input = event.message.usage.input_tokens || 0;
|
|
64
|
+
output.usage.output = event.message.usage.output_tokens || 0;
|
|
65
|
+
output.usage.cacheRead = event.message.usage.cache_read_input_tokens || 0;
|
|
66
|
+
output.usage.cacheWrite = event.message.usage.cache_creation_input_tokens || 0;
|
|
67
|
+
// Anthropic doesn't provide total_tokens, compute from components
|
|
68
|
+
output.usage.totalTokens =
|
|
69
|
+
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
70
|
+
calculateCost(model, output.usage);
|
|
71
|
+
}
|
|
72
|
+
else if (event.type === "content_block_start") {
|
|
73
|
+
accumulatedContent.push({ index: event.index, ...event.content_block });
|
|
74
|
+
if (event.content_block.type === "text") {
|
|
75
|
+
const block = {
|
|
76
|
+
type: "response",
|
|
77
|
+
content: [{ type: 'text', content: "" }],
|
|
78
|
+
index: event.index,
|
|
79
|
+
};
|
|
80
|
+
output.content.push(block);
|
|
81
|
+
stream.push({ type: "text_start", contentIndex: output.content.length - 1, message: output });
|
|
82
|
+
}
|
|
83
|
+
else if (event.content_block.type === "thinking") {
|
|
84
|
+
const block = {
|
|
85
|
+
type: "thinking",
|
|
86
|
+
thinkingText: "",
|
|
87
|
+
index: event.index,
|
|
88
|
+
};
|
|
89
|
+
output.content.push(block);
|
|
90
|
+
stream.push({ type: "thinking_start", contentIndex: output.content.length - 1, message: output });
|
|
91
|
+
}
|
|
92
|
+
else if (event.content_block.type === "tool_use") {
|
|
93
|
+
const block = {
|
|
94
|
+
type: "toolCall",
|
|
95
|
+
toolCallId: event.content_block.id,
|
|
96
|
+
name: event.content_block.name,
|
|
97
|
+
arguments: event.content_block.input,
|
|
98
|
+
partialJson: "",
|
|
99
|
+
index: event.index,
|
|
100
|
+
};
|
|
101
|
+
output.content.push(block);
|
|
102
|
+
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, message: output });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (event.type === "content_block_delta") {
|
|
106
|
+
const accumBlockIndex = accumulatedContent.findIndex(a => a.index === event.index);
|
|
107
|
+
if (event.delta.type === "text_delta") {
|
|
108
|
+
const index = blocks.findIndex((b) => b.index === event.index);
|
|
109
|
+
const block = blocks[index];
|
|
110
|
+
if (block && block.type === "response") {
|
|
111
|
+
const textContentIndex = block.content.findIndex((b) => b.type === 'text');
|
|
112
|
+
block.content[textContentIndex].content += event.delta.text;
|
|
113
|
+
stream.push({
|
|
114
|
+
type: "text_delta",
|
|
115
|
+
contentIndex: index,
|
|
116
|
+
delta: event.delta.text,
|
|
117
|
+
message: output,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (accumBlockIndex !== -1) {
|
|
121
|
+
accumulatedContent[accumBlockIndex].text += event.delta.text;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (event.delta.type === "thinking_delta") {
|
|
125
|
+
const index = blocks.findIndex((b) => b.index === event.index);
|
|
126
|
+
const block = blocks[index];
|
|
127
|
+
if (block && block.type === "thinking") {
|
|
128
|
+
block.thinkingText += event.delta.thinking;
|
|
129
|
+
stream.push({
|
|
130
|
+
type: "thinking_delta",
|
|
131
|
+
contentIndex: index,
|
|
132
|
+
delta: event.delta.thinking,
|
|
133
|
+
message: output,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (accumBlockIndex !== -1) {
|
|
137
|
+
accumulatedContent[accumBlockIndex].thinking += event.delta.thinking;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (event.delta.type === "input_json_delta") {
|
|
141
|
+
const index = blocks.findIndex((b) => b.index === event.index);
|
|
142
|
+
const block = blocks[index];
|
|
143
|
+
if (block && block.type === "toolCall") {
|
|
144
|
+
block.partialJson += event.delta.partial_json;
|
|
145
|
+
block.arguments = parseStreamingJson(block.partialJson);
|
|
146
|
+
stream.push({
|
|
147
|
+
type: "toolcall_delta",
|
|
148
|
+
contentIndex: index,
|
|
149
|
+
delta: event.delta.partial_json,
|
|
150
|
+
message: output,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (accumBlockIndex !== -1) {
|
|
154
|
+
(accumulatedContent[accumBlockIndex]).partialJson += event.delta.partial_json;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (event.delta.type === "signature_delta") {
|
|
158
|
+
if (accumBlockIndex !== -1) {
|
|
159
|
+
accumulatedContent[accumBlockIndex].signature += event.delta.signature;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (event.type === "content_block_stop") {
|
|
164
|
+
const index = blocks.findIndex((b) => b.index === event.index);
|
|
165
|
+
const block = blocks[index];
|
|
166
|
+
const accumBlockIndex = accumulatedContent.findIndex(a => a.index === event.index);
|
|
167
|
+
if (accumBlockIndex !== -1) {
|
|
168
|
+
if (accumulatedContent[accumBlockIndex].type === 'tool_use') {
|
|
169
|
+
const partialJson = accumulatedContent[accumBlockIndex].partialJson;
|
|
170
|
+
accumulatedContent[accumBlockIndex].input = parseStreamingJson(partialJson);
|
|
171
|
+
}
|
|
172
|
+
// Always delete index and partialJson - don't use truthy check as index can be 0
|
|
173
|
+
if (accumulatedContent[accumBlockIndex].index !== undefined)
|
|
174
|
+
delete accumulatedContent[accumBlockIndex].index;
|
|
175
|
+
if (accumulatedContent[accumBlockIndex].partialJson !== undefined)
|
|
176
|
+
delete accumulatedContent[accumBlockIndex].partialJson;
|
|
177
|
+
}
|
|
178
|
+
if (block) {
|
|
179
|
+
delete block.index;
|
|
180
|
+
if (block.type === "response") {
|
|
181
|
+
stream.push({
|
|
182
|
+
type: "text_end",
|
|
183
|
+
contentIndex: index,
|
|
184
|
+
content: block.content,
|
|
185
|
+
message: output,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else if (block.type === "thinking") {
|
|
189
|
+
stream.push({
|
|
190
|
+
type: "thinking_end",
|
|
191
|
+
contentIndex: index,
|
|
192
|
+
content: block.thinkingText,
|
|
193
|
+
message: output,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else if (block.type === "toolCall") {
|
|
197
|
+
block.arguments = parseStreamingJson(block.partialJson);
|
|
198
|
+
delete block.partialJson;
|
|
199
|
+
stream.push({
|
|
200
|
+
type: "toolcall_end",
|
|
201
|
+
contentIndex: index,
|
|
202
|
+
toolCall: block,
|
|
203
|
+
message: output,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else if (event.type === "message_delta") {
|
|
209
|
+
if (event.delta.stop_reason) {
|
|
210
|
+
output.stopReason = mapStopReason(event.delta.stop_reason);
|
|
211
|
+
finalResponse.stop_reason = event.delta.stop_reason;
|
|
212
|
+
}
|
|
213
|
+
finalResponse.usage = event.usage;
|
|
214
|
+
// message_delta only provides output_tokens, preserve input tokens from message_start
|
|
215
|
+
output.usage.output = event.usage.output_tokens || 0;
|
|
216
|
+
// Anthropic doesn't provide total_tokens, compute from components
|
|
217
|
+
output.usage.totalTokens =
|
|
218
|
+
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
219
|
+
calculateCost(model, output.usage);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (options?.signal?.aborted) {
|
|
223
|
+
throw new Error("Request was aborted");
|
|
224
|
+
}
|
|
225
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
226
|
+
throw new Error(`Stream ended with status: ${output.stopReason}${output.errorMessage ? ` - ${output.errorMessage}` : ""}`);
|
|
227
|
+
}
|
|
228
|
+
// Populate finalResponse.content with accumulated content blocks
|
|
229
|
+
finalResponse.content = accumulatedContent;
|
|
230
|
+
stream.push({ type: "done", reason: output.stopReason, message: { ...output, timestamp: Date.now() } });
|
|
231
|
+
const baseAssistantMessage = {
|
|
232
|
+
...output,
|
|
233
|
+
message: finalResponse,
|
|
234
|
+
timestamp: Date.now(),
|
|
235
|
+
duration: Date.now() - startTimestamp
|
|
236
|
+
};
|
|
237
|
+
stream.end(baseAssistantMessage);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
for (const block of output.content)
|
|
241
|
+
delete block.index;
|
|
242
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
243
|
+
output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
|
|
244
|
+
stream.push({ type: "error", reason: output.stopReason, message: { ...output, timestamp: Date.now() } });
|
|
245
|
+
// Populate finalResponse.content with accumulated content blocks even on error
|
|
246
|
+
finalResponse.content = accumulatedContent;
|
|
247
|
+
const baseAssistantMessage = {
|
|
248
|
+
...output,
|
|
249
|
+
message: finalResponse,
|
|
250
|
+
timestamp: Date.now(),
|
|
251
|
+
duration: Date.now() - startTimestamp
|
|
252
|
+
};
|
|
253
|
+
stream.end(baseAssistantMessage);
|
|
254
|
+
}
|
|
255
|
+
})();
|
|
256
|
+
return stream;
|
|
257
|
+
};
|
|
258
|
+
//# sourceMappingURL=stream.js.map
|