Skip to content

Add support for image processing #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ node_modules/
.eslintcache

# build output
dist/
dist/

.idea/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 3 additions & 5 deletions src/lib/api-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Comment on lines 16 to +17
Copy link
Preview

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simplified URL configuration removes the special case for 'individual' account types. This could break existing functionality if individual accounts require the 'api.githubcopilot.com' endpoint instead of 'api.individual.githubcopilot.com'.

Copilot uses AI. Check for mistakes.

export const copilotHeaders = (state: State, vision: boolean = false) => {
const headers: Record<string, string> = {
Authorization: `Bearer ${state.copilotToken}`,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/messages/anthropic-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface AnthropicImageBlock {
export interface AnthropicToolResultBlock {
type: "tool_result"
tool_use_id: string
content: string
content: string | Array<AnthropicTextBlock | AnthropicImageBlock>
is_error?: boolean
}

Expand Down
17 changes: 9 additions & 8 deletions src/routes/messages/non-stream-translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ function handleUserMessage(message: AnthropicUserMessage): Array<Message> {
(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",
)
Expand All @@ -93,14 +102,6 @@ function handleUserMessage(message: AnthropicUserMessage): Array<Message> {
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",
Expand Down
1 change: 1 addition & 0 deletions src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export async function runServer(options: RunServerOptions): Promise<void> {
)

serve({
hostname: "0.0.0.0",
Copy link
Preview

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binding to '0.0.0.0' exposes the server to all network interfaces, which may introduce security risks if the server is intended for localhost development only. Consider using '127.0.0.1' or making this configurable.

Suggested change
hostname: "0.0.0.0",
hostname: options.hostname || "127.0.0.1", // Use configurable hostname with default

Copilot uses AI. Check for mistakes.

fetch: server.fetch as ServerHandler,
port: options.port,
})
Expand Down