opencode-cluade-auth 1.0.4 → 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 +40 -1
- package/dist/fetch.js +1 -0
- package/package.json +1 -1
package/dist/anthropic-compat.js
CHANGED
|
@@ -122,13 +122,52 @@ 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
|
+
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
|
+
}
|
|
125
163
|
export function buildClaudePreparedRequest(params) {
|
|
126
164
|
const userPrompt = buildClaudeUserPrompt(params.messages);
|
|
127
165
|
if (params.tools.length > 0) {
|
|
128
166
|
return {
|
|
129
167
|
systemPrompt: buildToolSystemPrompt({ system: params.system, tools: params.tools }),
|
|
130
168
|
userPrompt,
|
|
131
|
-
outputFormat: "
|
|
169
|
+
outputFormat: "json",
|
|
170
|
+
jsonSchema: buildToolResponseJsonSchema(params.tools),
|
|
132
171
|
};
|
|
133
172
|
}
|
|
134
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
|
});
|