opencode-cluade-auth 1.0.3 → 1.0.5
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/anthropic-compat.d.ts +1 -0
- package/dist/anthropic-compat.js +42 -2
- package/dist/fetch.js +1 -0
- package/package.json +1 -1
package/dist/anthropic-compat.js
CHANGED
|
@@ -83,7 +83,8 @@ export function extractAnthropicRequest(raw) {
|
|
|
83
83
|
tools.push({
|
|
84
84
|
name,
|
|
85
85
|
description: asText(tool.description).trim() || undefined,
|
|
86
|
-
inputSchema: isRecord(tool.
|
|
86
|
+
inputSchema: (isRecord(tool.inputSchema) ? tool.inputSchema : undefined) ??
|
|
87
|
+
(isRecord(tool.input_schema) ? tool.input_schema : undefined),
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -121,13 +122,52 @@ function buildToolSystemPrompt(params) {
|
|
|
121
122
|
}))));
|
|
122
123
|
return lines.join("\n").trim();
|
|
123
124
|
}
|
|
125
|
+
function buildToolResponseJsonSchema(tools) {
|
|
126
|
+
const toolCallVariants = tools.map((tool) => ({
|
|
127
|
+
type: "object",
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
required: ["id", "name", "arguments"],
|
|
130
|
+
properties: {
|
|
131
|
+
id: { type: "string", minLength: 1 },
|
|
132
|
+
name: { const: tool.name },
|
|
133
|
+
arguments: tool.inputSchema ?? { type: "object", properties: {} },
|
|
134
|
+
},
|
|
135
|
+
}));
|
|
136
|
+
return {
|
|
137
|
+
oneOf: [
|
|
138
|
+
{
|
|
139
|
+
type: "object",
|
|
140
|
+
additionalProperties: false,
|
|
141
|
+
required: ["type", "content"],
|
|
142
|
+
properties: {
|
|
143
|
+
type: { const: "final" },
|
|
144
|
+
content: { type: "string" },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: "object",
|
|
149
|
+
additionalProperties: false,
|
|
150
|
+
required: ["type", "tool_calls"],
|
|
151
|
+
properties: {
|
|
152
|
+
type: { const: "tool-calls" },
|
|
153
|
+
tool_calls: {
|
|
154
|
+
type: "array",
|
|
155
|
+
minItems: 1,
|
|
156
|
+
items: toolCallVariants.length === 1 ? toolCallVariants[0] : { oneOf: toolCallVariants },
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
124
163
|
export function buildClaudePreparedRequest(params) {
|
|
125
164
|
const userPrompt = buildClaudeUserPrompt(params.messages);
|
|
126
165
|
if (params.tools.length > 0) {
|
|
127
166
|
return {
|
|
128
167
|
systemPrompt: buildToolSystemPrompt({ system: params.system, tools: params.tools }),
|
|
129
168
|
userPrompt,
|
|
130
|
-
outputFormat: "
|
|
169
|
+
outputFormat: "json",
|
|
170
|
+
jsonSchema: buildToolResponseJsonSchema(params.tools),
|
|
131
171
|
};
|
|
132
172
|
}
|
|
133
173
|
return {
|
package/dist/fetch.js
CHANGED
|
@@ -36,6 +36,7 @@ export function createClaudeCodeFetch(deps = {}) {
|
|
|
36
36
|
prompt: prepared.userPrompt,
|
|
37
37
|
systemPrompt: prepared.systemPrompt,
|
|
38
38
|
outputFormat: prepared.outputFormat,
|
|
39
|
+
jsonSchema: prepared.jsonSchema,
|
|
39
40
|
model: request.model,
|
|
40
41
|
effort: effortFromRequest(parsed),
|
|
41
42
|
});
|