From 0572087edf5bc3a6b9acb1de0f29cbcfd5f06ed4 Mon Sep 17 00:00:00 2001 From: shaywiin Date: Thu, 17 Jul 2025 01:19:27 +0700 Subject: [PATCH 1/2] Fix image request failures --- package.json | 2 +- src/lib/api-config.ts | 8 +++----- src/routes/messages/anthropic-types.ts | 2 +- src/routes/messages/non-stream-translation.ts | 17 +++++++++-------- src/start.ts | 1 + 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 7d5204a..3629aa3 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ ], "scripts": { "build": "tsup", - "dev": "bun run --watch ./src/main.ts", + "dev": "bun run --watch ./src/main.ts start", "knip": "knip-bun", "lint": "eslint .", "prepack": "bun run build", diff --git a/src/lib/api-config.ts b/src/lib/api-config.ts index 83bce92..94d429d 100644 --- a/src/lib/api-config.ts +++ b/src/lib/api-config.ts @@ -7,16 +7,14 @@ export const standardHeaders = () => ({ accept: "application/json", }) -const COPILOT_VERSION = "0.26.7" +const COPILOT_VERSION = "0.29.0" const EDITOR_PLUGIN_VERSION = `copilot-chat/${COPILOT_VERSION}` const USER_AGENT = `GitHubCopilotChat/${COPILOT_VERSION}` -const API_VERSION = "2025-04-01" +const API_VERSION = "2025-05-01" export const copilotBaseUrl = (state: State) => - state.accountType === "individual" ? - "https://api.githubcopilot.com" - : `https://api.${state.accountType}.githubcopilot.com` + `https://api.${state.accountType}.githubcopilot.com` export const copilotHeaders = (state: State, vision: boolean = false) => { const headers: Record = { Authorization: `Bearer ${state.copilotToken}`, diff --git a/src/routes/messages/anthropic-types.ts b/src/routes/messages/anthropic-types.ts index 31c6e86..282ef8f 100644 --- a/src/routes/messages/anthropic-types.ts +++ b/src/routes/messages/anthropic-types.ts @@ -42,7 +42,7 @@ export interface AnthropicImageBlock { export interface AnthropicToolResultBlock { type: "tool_result" tool_use_id: string - content: string + content: string | Array is_error?: boolean } diff --git a/src/routes/messages/non-stream-translation.ts b/src/routes/messages/non-stream-translation.ts index 021f283..4eeb87b 100644 --- a/src/routes/messages/non-stream-translation.ts +++ b/src/routes/messages/non-stream-translation.ts @@ -83,6 +83,15 @@ function handleUserMessage(message: AnthropicUserMessage): Array { (block): block is AnthropicToolResultBlock => block.type === "tool_result", ) + + for (const block of toolResultBlocks) { + newMessages.push({ + role: "tool", + tool_call_id: block.tool_use_id, + content: mapContent(block.content), + }) + } + const otherBlocks = message.content.filter( (block) => block.type !== "tool_result", ) @@ -93,14 +102,6 @@ function handleUserMessage(message: AnthropicUserMessage): Array { content: mapContent(otherBlocks), }) } - - for (const block of toolResultBlocks) { - newMessages.push({ - role: "tool", - tool_call_id: block.tool_use_id, - content: block.content, - }) - } } else { newMessages.push({ role: "user", diff --git a/src/start.ts b/src/start.ts index a9cfe73..264f90c 100644 --- a/src/start.ts +++ b/src/start.ts @@ -99,6 +99,7 @@ export async function runServer(options: RunServerOptions): Promise { ) serve({ + hostname: "0.0.0.0", fetch: server.fetch as ServerHandler, port: options.port, }) From 7c2c478c950971ed924f8c81d5b16c9284249ec7 Mon Sep 17 00:00:00 2001 From: shaywiin Date: Thu, 17 Jul 2025 02:06:42 +0700 Subject: [PATCH 2/2] fix: add .idea/ to .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 577a4f1..d4b0e68 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ node_modules/ .eslintcache # build output -dist/ \ No newline at end of file +dist/ + +.idea/ \ No newline at end of file