opencode-cluade-auth 1.0.4 → 1.0.6
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 +48 -1
- package/dist/fetch.js +1 -0
- package/package.json +1 -1
package/dist/anthropic-compat.js
CHANGED
|
@@ -122,13 +122,60 @@ function buildToolSystemPrompt(params) {
|
|
|
122
122
|
}))));
|
|
123
123
|
return lines.join("\n").trim();
|
|
124
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
|
+
type: "object",
|
|
138
|
+
additionalProperties: false,
|
|
139
|
+
required: ["type"],
|
|
140
|
+
properties: {
|
|
141
|
+
type: { type: "string", enum: ["final", "tool-calls"] },
|
|
142
|
+
content: { type: "string" },
|
|
143
|
+
tool_calls: {
|
|
144
|
+
type: "array",
|
|
145
|
+
minItems: 1,
|
|
146
|
+
items: toolCallVariants.length === 1 ? toolCallVariants[0] : { oneOf: toolCallVariants },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
oneOf: [
|
|
150
|
+
{
|
|
151
|
+
required: ["type", "content"],
|
|
152
|
+
properties: {
|
|
153
|
+
type: { const: "final" },
|
|
154
|
+
content: { type: "string" },
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
required: ["type", "tool_calls"],
|
|
159
|
+
properties: {
|
|
160
|
+
type: { const: "tool-calls" },
|
|
161
|
+
tool_calls: {
|
|
162
|
+
type: "array",
|
|
163
|
+
minItems: 1,
|
|
164
|
+
items: toolCallVariants.length === 1 ? toolCallVariants[0] : { oneOf: toolCallVariants },
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
125
171
|
export function buildClaudePreparedRequest(params) {
|
|
126
172
|
const userPrompt = buildClaudeUserPrompt(params.messages);
|
|
127
173
|
if (params.tools.length > 0) {
|
|
128
174
|
return {
|
|
129
175
|
systemPrompt: buildToolSystemPrompt({ system: params.system, tools: params.tools }),
|
|
130
176
|
userPrompt,
|
|
131
|
-
outputFormat: "
|
|
177
|
+
outputFormat: "json",
|
|
178
|
+
jsonSchema: buildToolResponseJsonSchema(params.tools),
|
|
132
179
|
};
|
|
133
180
|
}
|
|
134
181
|
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
|
});
|