Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
963 B · 34 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435import type { Message } from "../types.js";
export function inferCopilotInitiator(messages: Message[]): "user" | "agent" { const last = messages[messages.length - 1]; return last && last.role !== "user" ? "agent" : "user";}
export function hasCopilotVisionInput(messages: Message[]): boolean { return messages.some((msg) => { if (msg.role === "user" && Array.isArray(msg.content)) { return msg.content.some((c) => c.type === "image"); } if (msg.role === "toolResult" && Array.isArray(msg.content)) { return msg.content.some((c) => c.type === "image"); } return false; });}
export function buildCopilotDynamicHeaders(params: { messages: Message[]; hasImages: boolean;}): Record<string, string> { const headers: Record<string, string> = { "X-Initiator": inferCopilotInitiator(params.messages), "Openai-Intent": "conversation-edits", };
if (params.hasImages) { headers["Copilot-Vision-Request"] = "true"; }
return headers;}