Skip to content

Commit a931d12

Browse files
committed
add spoof
1 parent 8872d7d commit a931d12

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

index.mjs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ async function exchange(code, verifier) {
7070
*/
7171
export async function AnthropicAuthPlugin({ client }) {
7272
return {
73+
"experimental.chat.system.transform": (input, output) => {
74+
if (input.model.providerID === "anthropic") {
75+
output.system.unshift(
76+
"You are Claude Code, Anthropic's official CLI for Claude.",
77+
);
78+
}
79+
},
7380
auth: {
7481
provider: "anthropic",
7582
async loader(getAuth, provider) {
@@ -147,7 +154,9 @@ export async function AnthropicAuthPlugin({ client }) {
147154
}
148155
}
149156
} else {
150-
for (const [key, value] of Object.entries(requestInit.headers)) {
157+
for (const [key, value] of Object.entries(
158+
requestInit.headers,
159+
)) {
151160
if (typeof value !== "undefined") {
152161
requestHeaders.set(key, String(value));
153162
}
@@ -187,13 +196,13 @@ export async function AnthropicAuthPlugin({ client }) {
187196

188197
// Sanitize system prompt - server blocks "OpenCode" string
189198
if (parsed.system && Array.isArray(parsed.system)) {
190-
parsed.system = parsed.system.map(item => {
191-
if (item.type === 'text' && item.text) {
199+
parsed.system = parsed.system.map((item) => {
200+
if (item.type === "text" && item.text) {
192201
return {
193202
...item,
194203
text: item.text
195-
.replace(/OpenCode/g, 'Claude Code')
196-
.replace(/opencode/gi, 'Claude')
204+
.replace(/OpenCode/g, "Claude Code")
205+
.replace(/opencode/gi, "Claude"),
197206
};
198207
}
199208
return item;
@@ -204,7 +213,9 @@ export async function AnthropicAuthPlugin({ client }) {
204213
if (parsed.tools && Array.isArray(parsed.tools)) {
205214
parsed.tools = parsed.tools.map((tool) => ({
206215
...tool,
207-
name: tool.name ? `${TOOL_PREFIX}${tool.name}` : tool.name,
216+
name: tool.name
217+
? `${TOOL_PREFIX}${tool.name}`
218+
: tool.name,
208219
}));
209220
}
210221
// Add prefix to tool_use blocks in messages
@@ -213,7 +224,10 @@ export async function AnthropicAuthPlugin({ client }) {
213224
if (msg.content && Array.isArray(msg.content)) {
214225
msg.content = msg.content.map((block) => {
215226
if (block.type === "tool_use" && block.name) {
216-
return { ...block, name: `${TOOL_PREFIX}${block.name}` };
227+
return {
228+
...block,
229+
name: `${TOOL_PREFIX}${block.name}`,
230+
};
217231
}
218232
return block;
219233
});
@@ -272,7 +286,10 @@ export async function AnthropicAuthPlugin({ client }) {
272286
}
273287

274288
let text = decoder.decode(value, { stream: true });
275-
text = text.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"');
289+
text = text.replace(
290+
/"name"\s*:\s*"mcp_([^"]+)"/g,
291+
'"name": "$1"',
292+
);
276293
controller.enqueue(encoder.encode(text));
277294
},
278295
});

0 commit comments

Comments
 (0)