opencode-anthropic-auth 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/index.mjs +18 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -179,18 +179,33 @@ export async function AnthropicAuthPlugin({ client }) {
179
179
  );
180
180
  requestHeaders.delete("x-api-key");
181
181
 
182
- const TOOL_PREFIX = "oc_";
182
+ const TOOL_PREFIX = "mcp_";
183
183
  let body = requestInit.body;
184
184
  if (body && typeof body === "string") {
185
185
  try {
186
186
  const parsed = JSON.parse(body);
187
+ // Add prefix to tools definitions
187
188
  if (parsed.tools && Array.isArray(parsed.tools)) {
188
189
  parsed.tools = parsed.tools.map((tool) => ({
189
190
  ...tool,
190
191
  name: tool.name ? `${TOOL_PREFIX}${tool.name}` : tool.name,
191
192
  }));
192
- body = JSON.stringify(parsed);
193
193
  }
194
+ // Add prefix to tool_use blocks in messages
195
+ if (parsed.messages && Array.isArray(parsed.messages)) {
196
+ parsed.messages = parsed.messages.map((msg) => {
197
+ if (msg.content && Array.isArray(msg.content)) {
198
+ msg.content = msg.content.map((block) => {
199
+ if (block.type === "tool_use" && block.name) {
200
+ return { ...block, name: `${TOOL_PREFIX}${block.name}` };
201
+ }
202
+ return block;
203
+ });
204
+ }
205
+ return msg;
206
+ });
207
+ }
208
+ body = JSON.stringify(parsed);
194
209
  } catch (e) {
195
210
  // ignore parse errors
196
211
  }
@@ -241,7 +256,7 @@ export async function AnthropicAuthPlugin({ client }) {
241
256
  }
242
257
 
243
258
  let text = decoder.decode(value, { stream: true });
244
- text = text.replace(/"name"\s*:\s*"oc_([^"]+)"/g, '"name": "$1"');
259
+ text = text.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"');
245
260
  controller.enqueue(encoder.encode(text));
246
261
  },
247
262
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-anthropic-auth",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "main": "./index.mjs",
5
5
  "devDependencies": {
6
6
  "@opencode-ai/plugin": "^0.4.45"