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.
@@ -12,6 +12,7 @@ export type ClaudePreparedRequest = {
12
12
  systemPrompt?: string;
13
13
  userPrompt: string;
14
14
  outputFormat: "text" | "json";
15
+ jsonSchema?: Record<string, unknown>;
15
16
  };
16
17
  type ClaudeResponseEnvelope = {
17
18
  type: "final";
@@ -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: "text",
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-cluade-auth",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Claude Code CLI-backed Anthropic auth plugin for OpenCode.",
5
5
  "license": "MIT",
6
6
  "type": "module",