Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

opencode-agentrouter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencode-agentrouter - npm Package Compare versions

Comparing version
1.0.0
to
1.1.0
+6
-0
dist/index.d.ts

@@ -15,2 +15,8 @@ /**

*
* Additionally, for Claude models proxied through AgentRouter, the
* plugin strips the `reasoning_effort` field from request bodies.
* AgentRouter rejects this field with:
* "***.***.enabled" is not supported for this model.
* Use "***.***.adaptive" and "output_config.effort"
*
* Headers were captured from a verified, working RooCode session:

@@ -17,0 +23,0 @@ * - RooCode identity: HTTP-Referer, X-Title, User-Agent

+38
-4

@@ -15,2 +15,8 @@ /**

*
* Additionally, for Claude models proxied through AgentRouter, the
* plugin strips the `reasoning_effort` field from request bodies.
* AgentRouter rejects this field with:
* "***.***.enabled" is not supported for this model.
* Use "***.***.adaptive" and "output_config.effort"
*
* Headers were captured from a verified, working RooCode session:

@@ -43,4 +49,8 @@ * - RooCode identity: HTTP-Referer, X-Title, User-Agent

/**
* Models that need `reasoning_effort` stripped from request body.
* AgentRouter rejects this field for Claude models with HTTP 400.
*/
const STRIP_REASONING_MODELS = ["claude-opus", "claude-sonnet", "claude-haiku"];
/**
* Safely extract a URL from any fetch input.
* Returns null if the input cannot be parsed.
*/

@@ -61,2 +71,24 @@ function getURL(input) {

}
/**
* Check if request body contains a Claude model and strip
* incompatible fields (reasoning_effort) if so.
* Returns the original or modified body.
*/
function sanitizeBody(body) {
if (!body || typeof body !== "string")
return body;
try {
const json = JSON.parse(body);
const model = json.model || "";
const needsStrip = STRIP_REASONING_MODELS.some((prefix) => model.includes(prefix));
if (needsStrip) {
delete json.reasoning_effort;
return JSON.stringify(json);
}
return body;
}
catch {
return body;
}
}
// --- Patch globalThis.fetch at module load time ---

@@ -78,3 +110,6 @@ const originalFetch = globalThis.fetch;

}
const patchedInit = { ...init, headers };
// Sanitize body: strip incompatible fields for Claude models
const originalBody = init?.body ?? (input instanceof Request ? input.body : undefined);
const sanitizedBody = sanitizeBody(originalBody);
const patchedInit = { ...init, headers, body: sanitizedBody };
// Rebuild Request object when the input is a Request instance

@@ -84,3 +119,2 @@ if (input instanceof Request) {

method: input.method,
body: input.body,
redirect: input.redirect,

@@ -100,3 +134,3 @@ signal: init?.signal ?? input.signal,

level: "info",
message: "AgentRouter plugin loaded — client identity headers active",
message: "AgentRouter plugin loaded — client identity headers active, Claude body sanitizer active",
},

@@ -103,0 +137,0 @@ });

+4
-4
{
"name": "opencode-agentrouter",
"version": "1.0.0",
"version": "1.1.0",
"description": "OpenCode plugin to use models from agentrouter.org",

@@ -30,7 +30,7 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/github-47303/opencode-agentrouter.git"
"url": "git+https://github.com/TVD-00/opencode-agentrouter.git"
},
"homepage": "https://github.com/github-47303/opencode-agentrouter#readme",
"homepage": "https://github.com/TVD-00/opencode-agentrouter#readme",
"bugs": {
"url": "https://github.com/github-47303/opencode-agentrouter/issues"
"url": "https://github.com/TVD-00/opencode-agentrouter/issues"
},

@@ -37,0 +37,0 @@ "devDependencies": {