@xtruder/opencode-claude-max-plugin 0.1.15 → 0.1.16
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/build/index.d.ts +2 -2
- package/build/index.js +69 -40
- package/build/model.d.ts +7 -7
- package/build/model.d.ts.map +1 -1
- package/build/prompt.d.ts +2 -2
- package/build/stream.d.ts +2 -2
- package/build/stream.d.ts.map +1 -1
- package/build/tools.d.ts +3 -3
- package/build/tools.d.ts.map +1 -1
- package/package.json +2 -2
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV3 } from "@ai-sdk/provider";
|
|
2
2
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
3
3
|
export interface AnthropicSDKProviderOptions {
|
|
4
4
|
/**
|
|
@@ -35,7 +35,7 @@ export interface AnthropicSDKProvider {
|
|
|
35
35
|
/**
|
|
36
36
|
* Get a language model by model ID.
|
|
37
37
|
*/
|
|
38
|
-
languageModel(modelId: string):
|
|
38
|
+
languageModel(modelId: string): LanguageModelV3;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Create an Anthropic SDK provider for use with OpenCode / Vercel AI SDK.
|
package/build/index.js
CHANGED
|
@@ -237,12 +237,15 @@ function convertAssistantMessage(message) {
|
|
|
237
237
|
function convertToolMessage(message) {
|
|
238
238
|
const content = [];
|
|
239
239
|
for (const part of message.content) {
|
|
240
|
-
|
|
240
|
+
if (part.type !== "tool-result")
|
|
241
|
+
continue;
|
|
242
|
+
const output = part.output;
|
|
243
|
+
const resultContent = formatToolResultContent(output);
|
|
241
244
|
content.push({
|
|
242
245
|
type: "tool_result",
|
|
243
246
|
tool_use_id: part.toolCallId,
|
|
244
247
|
content: resultContent,
|
|
245
|
-
is_error:
|
|
248
|
+
is_error: output.type === "error-text" || output.type === "error-json" ? true : undefined
|
|
246
249
|
});
|
|
247
250
|
}
|
|
248
251
|
return { role: "user", content };
|
|
@@ -504,18 +507,20 @@ function generateId() {
|
|
|
504
507
|
return `block-${Date.now()}-${idCounter++}`;
|
|
505
508
|
}
|
|
506
509
|
function mapFinishReason(stopReason) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
510
|
+
const unified = (() => {
|
|
511
|
+
switch (stopReason) {
|
|
512
|
+
case "end_turn":
|
|
513
|
+
case "stop_sequence":
|
|
514
|
+
return "stop";
|
|
515
|
+
case "max_tokens":
|
|
516
|
+
return "length";
|
|
517
|
+
case "tool_use":
|
|
518
|
+
return "tool-calls";
|
|
519
|
+
default:
|
|
520
|
+
return "other";
|
|
521
|
+
}
|
|
522
|
+
})();
|
|
523
|
+
return { unified, raw: stopReason ?? undefined };
|
|
519
524
|
}
|
|
520
525
|
function convertStream(anthropicStream, modelId) {
|
|
521
526
|
const blockStates = new Map;
|
|
@@ -542,10 +547,17 @@ function convertStream(anthropicStream, modelId) {
|
|
|
542
547
|
type: "finish",
|
|
543
548
|
finishReason,
|
|
544
549
|
usage: {
|
|
545
|
-
inputTokens:
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
550
|
+
inputTokens: {
|
|
551
|
+
total: inputTokens ?? 0,
|
|
552
|
+
noCache: undefined,
|
|
553
|
+
cacheRead: cachedInputTokens ?? 0,
|
|
554
|
+
cacheWrite: cacheCreationTokens ?? 0
|
|
555
|
+
},
|
|
556
|
+
outputTokens: {
|
|
557
|
+
total: outputTokens ?? 0,
|
|
558
|
+
text: undefined,
|
|
559
|
+
reasoning: undefined
|
|
560
|
+
}
|
|
549
561
|
},
|
|
550
562
|
providerMetadata: {
|
|
551
563
|
anthropic: {
|
|
@@ -691,18 +703,20 @@ function handleApiError(error) {
|
|
|
691
703
|
throw error;
|
|
692
704
|
}
|
|
693
705
|
function mapFinishReason2(stopReason) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
+
const unified = (() => {
|
|
707
|
+
switch (stopReason) {
|
|
708
|
+
case "end_turn":
|
|
709
|
+
case "stop_sequence":
|
|
710
|
+
return "stop";
|
|
711
|
+
case "max_tokens":
|
|
712
|
+
return "length";
|
|
713
|
+
case "tool_use":
|
|
714
|
+
return "tool-calls";
|
|
715
|
+
default:
|
|
716
|
+
return "other";
|
|
717
|
+
}
|
|
718
|
+
})();
|
|
719
|
+
return { unified, raw: stopReason ?? undefined };
|
|
706
720
|
}
|
|
707
721
|
var BILLING_SYSTEM_BLOCK = {
|
|
708
722
|
type: "text",
|
|
@@ -791,7 +805,7 @@ class AnthropicSDKModel {
|
|
|
791
805
|
client;
|
|
792
806
|
providerName;
|
|
793
807
|
isOAuth;
|
|
794
|
-
specificationVersion = "
|
|
808
|
+
specificationVersion = "v3";
|
|
795
809
|
provider;
|
|
796
810
|
modelId;
|
|
797
811
|
supportedUrls = {};
|
|
@@ -806,13 +820,13 @@ class AnthropicSDKModel {
|
|
|
806
820
|
const { system, messages } = convertPrompt(options.prompt);
|
|
807
821
|
const warnings = [];
|
|
808
822
|
if (options.presencePenalty != null) {
|
|
809
|
-
warnings.push({ type: "
|
|
823
|
+
warnings.push({ type: "compatibility", feature: "presencePenalty" });
|
|
810
824
|
}
|
|
811
825
|
if (options.frequencyPenalty != null) {
|
|
812
|
-
warnings.push({ type: "
|
|
826
|
+
warnings.push({ type: "compatibility", feature: "frequencyPenalty" });
|
|
813
827
|
}
|
|
814
828
|
if (options.seed != null) {
|
|
815
|
-
warnings.push({ type: "
|
|
829
|
+
warnings.push({ type: "compatibility", feature: "seed" });
|
|
816
830
|
}
|
|
817
831
|
const tools = options.toolChoice?.type === "none" ? undefined : convertTools(options.tools);
|
|
818
832
|
const toolChoice = options.toolChoice?.type === "none" ? undefined : convertToolChoice(options.toolChoice);
|
|
@@ -974,10 +988,17 @@ class AnthropicSDKModel {
|
|
|
974
988
|
content,
|
|
975
989
|
finishReason: mapFinishReason2(response.stop_reason),
|
|
976
990
|
usage: {
|
|
977
|
-
inputTokens:
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
991
|
+
inputTokens: {
|
|
992
|
+
total: response.usage.input_tokens,
|
|
993
|
+
noCache: undefined,
|
|
994
|
+
cacheRead: cacheReadTokens,
|
|
995
|
+
cacheWrite: cacheCreateTokens
|
|
996
|
+
},
|
|
997
|
+
outputTokens: {
|
|
998
|
+
total: response.usage.output_tokens,
|
|
999
|
+
text: undefined,
|
|
1000
|
+
reasoning: undefined
|
|
1001
|
+
}
|
|
981
1002
|
},
|
|
982
1003
|
providerMetadata: {
|
|
983
1004
|
anthropic: {
|
|
@@ -1010,8 +1031,16 @@ class AnthropicSDKModel {
|
|
|
1010
1031
|
controller.enqueue({ type: "stream-start", warnings });
|
|
1011
1032
|
controller.enqueue({
|
|
1012
1033
|
type: "finish",
|
|
1013
|
-
finishReason: "stop",
|
|
1014
|
-
usage: {
|
|
1034
|
+
finishReason: { unified: "stop", raw: undefined },
|
|
1035
|
+
usage: {
|
|
1036
|
+
inputTokens: {
|
|
1037
|
+
total: 0,
|
|
1038
|
+
noCache: undefined,
|
|
1039
|
+
cacheRead: undefined,
|
|
1040
|
+
cacheWrite: undefined
|
|
1041
|
+
},
|
|
1042
|
+
outputTokens: { total: 0, text: undefined, reasoning: undefined }
|
|
1043
|
+
}
|
|
1015
1044
|
});
|
|
1016
1045
|
controller.close();
|
|
1017
1046
|
}
|
package/build/model.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from "@ai-sdk/provider";
|
|
2
2
|
import type Anthropic from "@anthropic-ai/sdk";
|
|
3
|
-
type DoGenerateResult =
|
|
4
|
-
type DoStreamResult =
|
|
5
|
-
export declare class AnthropicSDKModel implements
|
|
3
|
+
type DoGenerateResult = LanguageModelV3GenerateResult;
|
|
4
|
+
type DoStreamResult = LanguageModelV3StreamResult;
|
|
5
|
+
export declare class AnthropicSDKModel implements LanguageModelV3 {
|
|
6
6
|
private client;
|
|
7
7
|
private providerName;
|
|
8
8
|
private isOAuth;
|
|
9
|
-
readonly specificationVersion: "
|
|
9
|
+
readonly specificationVersion: "v3";
|
|
10
10
|
readonly provider: string;
|
|
11
11
|
readonly modelId: string;
|
|
12
12
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
13
13
|
constructor(modelId: string, client: Anthropic, providerName: string, isOAuth?: boolean);
|
|
14
14
|
private buildParams;
|
|
15
|
-
doGenerate(options:
|
|
16
|
-
doStream(options:
|
|
15
|
+
doGenerate(options: LanguageModelV3CallOptions): Promise<DoGenerateResult>;
|
|
16
|
+
doStream(options: LanguageModelV3CallOptions): Promise<DoStreamResult>;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=model.d.ts.map
|
package/build/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAI1B,6BAA6B,EAC7B,2BAA2B,EAE5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAU9C,KAAK,gBAAgB,GAAG,6BAA6B,CAAA;AACrD,KAAK,cAAc,GAAG,2BAA2B,CAAA;AAwLjD,qBAAa,iBAAkB,YAAW,eAAe;IAQrD,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IATjB,QAAQ,CAAC,oBAAoB,EAAG,IAAI,CAAS;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAK;gBAGnD,OAAO,EAAE,MAAM,EACP,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,OAAe;IAMlC,OAAO,CAAC,WAAW;IA2Lb,UAAU,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuF1E,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,cAAc,CAAC;CA6E7E"}
|
package/build/prompt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV3Prompt } from "@ai-sdk/provider";
|
|
2
2
|
import type Anthropic from "@anthropic-ai/sdk";
|
|
3
3
|
type AnthropicMessage = Anthropic.MessageCreateParams["messages"][number];
|
|
4
4
|
type AnthropicSystemParam = Anthropic.MessageCreateParams["system"];
|
|
@@ -6,6 +6,6 @@ export interface ConvertedPrompt {
|
|
|
6
6
|
system: AnthropicSystemParam;
|
|
7
7
|
messages: AnthropicMessage[];
|
|
8
8
|
}
|
|
9
|
-
export declare function convertPrompt(prompt:
|
|
9
|
+
export declare function convertPrompt(prompt: LanguageModelV3Prompt): ConvertedPrompt;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=prompt.d.ts.map
|
package/build/stream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV3StreamPart } from "@ai-sdk/provider";
|
|
2
2
|
import type Anthropic from "@anthropic-ai/sdk";
|
|
3
3
|
type MessageStreamEvent = Anthropic.MessageStreamEvent;
|
|
4
|
-
export declare function convertStream(anthropicStream: AsyncIterable<MessageStreamEvent>, modelId: string): ReadableStream<
|
|
4
|
+
export declare function convertStream(anthropicStream: AsyncIterable<MessageStreamEvent>, modelId: string): ReadableStream<LanguageModelV3StreamPart>;
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=stream.d.ts.map
|
package/build/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAA+B,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAG9C,KAAK,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAA+B,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAG9C,KAAK,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAA;AAmCtD,wBAAgB,aAAa,CAC3B,eAAe,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAClD,OAAO,EAAE,MAAM,GACd,cAAc,CAAC,yBAAyB,CAAC,CAwD3C"}
|
package/build/tools.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, LanguageModelV3ToolChoice } from "@ai-sdk/provider";
|
|
2
2
|
import type Anthropic from "@anthropic-ai/sdk";
|
|
3
3
|
type AnthropicTool = Anthropic.Tool;
|
|
4
4
|
type AnthropicToolChoice = Anthropic.MessageCreateParams["tool_choice"];
|
|
5
|
-
export declare function convertTools(tools: Array<
|
|
6
|
-
export declare function convertToolChoice(toolChoice:
|
|
5
|
+
export declare function convertTools(tools: Array<LanguageModelV3FunctionTool | LanguageModelV3ProviderTool> | undefined): AnthropicTool[] | undefined;
|
|
6
|
+
export declare function convertToolChoice(toolChoice: LanguageModelV3ToolChoice | undefined): AnthropicToolChoice | undefined;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=tools.d.ts.map
|
package/build/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAA;AAG9C,KAAK,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AACnC,KAAK,mBAAmB,GAAG,SAAS,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAA;AAwBvE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,CAAC,2BAA2B,GAAG,2BAA2B,CAAC,GAAG,SAAS,GAClF,aAAa,EAAE,GAAG,SAAS,CAY7B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,yBAAyB,GAAG,SAAS,GAChD,mBAAmB,GAAG,SAAS,CAcjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtruder/opencode-claude-max-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "OpenCode plugin for Claude Max/Pro subscription via @anthropic-ai/sdk - uses Claude Code OAuth credentials",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-sdk",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@anthropic-ai/sdk": "0.74.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ai-sdk/provider": "
|
|
40
|
+
"@ai-sdk/provider": "3.0.8",
|
|
41
41
|
"@ai-sdk/provider-utils": "3.0.2",
|
|
42
42
|
"@opencode-ai/plugin": "^1.3.0",
|
|
43
43
|
"ai": "5.0.124",
|