@ex-machina/opencode-anthropic-auth 1.3.0 → 1.4.1
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/README.md +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/transform.js +28 -0
- package/package.json +5 -4
package/README.md
CHANGED
package/dist/constants.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const OAUTH_SCOPES: string[];
|
|
|
9
9
|
export declare const TOOL_PREFIX = "mcp_";
|
|
10
10
|
export declare const REQUIRED_BETAS: string[];
|
|
11
11
|
export declare const OPENCODE_IDENTITY = "You are OpenCode, the best coding agent on the planet.";
|
|
12
|
-
export declare const CLAUDE_CODE_IDENTITY = "You are Claude
|
|
12
|
+
export declare const CLAUDE_CODE_IDENTITY = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
13
13
|
export declare const USER_AGENT = "claude-cli/2.1.2 (external, cli)";
|
|
14
14
|
/**
|
|
15
15
|
* Anchors that identify paragraphs to remove from the system prompt.
|
package/dist/constants.js
CHANGED
|
@@ -19,7 +19,7 @@ export const REQUIRED_BETAS = [
|
|
|
19
19
|
'interleaved-thinking-2025-05-14',
|
|
20
20
|
];
|
|
21
21
|
export const OPENCODE_IDENTITY = 'You are OpenCode, the best coding agent on the planet.';
|
|
22
|
-
export const CLAUDE_CODE_IDENTITY = "You are Claude
|
|
22
|
+
export const CLAUDE_CODE_IDENTITY = "You are a Claude agent, built on Anthropic's Claude Agent SDK.";
|
|
23
23
|
export const USER_AGENT = 'claude-cli/2.1.2 (external, cli)';
|
|
24
24
|
/**
|
|
25
25
|
* Anchors that identify paragraphs to remove from the system prompt.
|
package/dist/transform.js
CHANGED
|
@@ -267,6 +267,34 @@ export function rewriteRequestBody(body) {
|
|
|
267
267
|
const parsed = JSON.parse(body);
|
|
268
268
|
// Sanitize system prompt and prepend Claude Code identity
|
|
269
269
|
parsed.system = prependClaudeCodeIdentity(parsed.system);
|
|
270
|
+
// --- Relocate non-core system entries to user messages ---
|
|
271
|
+
// Anthropic's API validates system[] content for OAuth requests.
|
|
272
|
+
// Third-party system prompts trigger a 400 rejection when they
|
|
273
|
+
// appear in `system[]`. Keep only the identity block in `system[]`
|
|
274
|
+
// and prepend everything else to the first user message.
|
|
275
|
+
if (Array.isArray(parsed.system) && parsed.system.length > 1) {
|
|
276
|
+
const kept = [parsed.system[0]]; // identity block
|
|
277
|
+
const movedTexts = [];
|
|
278
|
+
for (let i = 1; i < parsed.system.length; i++) {
|
|
279
|
+
const entry = parsed.system[i];
|
|
280
|
+
const txt = typeof entry === 'string' ? entry : (entry?.text ?? '');
|
|
281
|
+
if (txt.length > 0)
|
|
282
|
+
movedTexts.push(txt);
|
|
283
|
+
}
|
|
284
|
+
if (movedTexts.length > 0 && Array.isArray(parsed.messages)) {
|
|
285
|
+
const firstUser = parsed.messages.find((m) => m.role === 'user');
|
|
286
|
+
if (firstUser) {
|
|
287
|
+
parsed.system = kept;
|
|
288
|
+
const prefix = movedTexts.join('\n\n');
|
|
289
|
+
if (typeof firstUser.content === 'string') {
|
|
290
|
+
firstUser.content = `${prefix}\n\n${firstUser.content}`;
|
|
291
|
+
}
|
|
292
|
+
else if (Array.isArray(firstUser.content)) {
|
|
293
|
+
firstUser.content.unshift({ type: 'text', text: prefix });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
270
298
|
// Prefix tool names
|
|
271
299
|
if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
272
300
|
parsed.tools = parsed.tools.map((tool) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ex-machina/opencode-anthropic-auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/ex-machina-co/opencode-anthropic-auth"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "tsc -p tsconfig.build.json",
|
|
16
16
|
"dev": "bun scripts/dev.ts",
|
|
17
17
|
"dev:clean": "bun scripts/dev-clean.ts",
|
|
18
|
+
"extract": "bun scripts/extract-system-prompt.ts",
|
|
18
19
|
"test": "bun test",
|
|
19
20
|
"types": "tsc",
|
|
20
21
|
"format": "biome format --write .",
|
|
@@ -24,14 +25,14 @@
|
|
|
24
25
|
"release": "bun run build && bun change publish"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@biomejs/biome": "2.4.
|
|
28
|
+
"@biomejs/biome": "2.4.11",
|
|
28
29
|
"@changesets/changelog-github": "^0.6.0",
|
|
29
30
|
"@changesets/cli": "^2.30.0",
|
|
30
|
-
"@opencode-ai/plugin": "1.3
|
|
31
|
+
"@opencode-ai/plugin": "1.4.3",
|
|
31
32
|
"@tsconfig/bun": "1.0.10",
|
|
32
33
|
"@types/bun": "1.3.11",
|
|
33
34
|
"dedent": "^1.7.2",
|
|
34
|
-
"lefthook": "2.1.
|
|
35
|
+
"lefthook": "2.1.5",
|
|
35
36
|
"typescript": "6.0.2"
|
|
36
37
|
}
|
|
37
38
|
}
|