UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

111 lines (110 loc) • 3.48 kB
import { g as normalizeUniqueStringEntries } from "../../string-normalization-DLmfYZXI.mjs"; import "../../string-coerce-runtime-BwAZZDf5.mjs"; import { t as definePluginEntry } from "../../plugin-entry-CiJdaHtx.mjs"; import "../../runtime-api-0Q8AdG-R.mjs"; //#region extensions/copilot-proxy/index.ts const DEFAULT_BASE_URL = "http://localhost:3000/v1"; const DEFAULT_API_KEY = "n/a"; const DEFAULT_CONTEXT_WINDOW = 128e3; const DEFAULT_MODEL_IDS = [ "gpt-5-mini", "claude-opus-4.6", "claude-opus-4.7", "claude-sonnet-4.6", "gemini-3-flash" ]; function normalizeBaseUrl(e) { const t = e.trim(); if (!t) return DEFAULT_BASE_URL; const n = t.replace(/\/+$/, ""); return n.endsWith("/v1") ? n : `${n}/v1`; } function validateBaseUrl(e) { const t = normalizeBaseUrl(e); return URL.canParse(t) ? void 0 : "Enter a valid URL"; } function parseModelIds(e) { return normalizeUniqueStringEntries(e.split(/[\n,]/)); } var copilot_proxy_default = definePluginEntry({ id: "copilot-proxy", name: "Copilot Proxy", description: "Local Copilot Proxy (VS Code LM) provider plugin", register(e) { e.registerProvider({ id: "copilot-proxy", label: "Copilot Proxy", docsPath: "/providers/models", auth: [{ id: "local", label: "Local proxy", hint: "Configure base URL + models for the Copilot Proxy server", kind: "custom", run: async (e) => { const t = await e.prompter.text({ message: "Copilot Proxy base URL", placeholder: DEFAULT_BASE_URL, validate: validateBaseUrl }); const n = await e.prompter.text({ message: "Model IDs (comma-separated)", initialValue: DEFAULT_MODEL_IDS.join(", "), validate: (e) => parseModelIds(e).length > 0 ? void 0 : "Enter at least one model id" }); const r = normalizeBaseUrl(t); const i = parseModelIds(n); const a = `copilot-proxy/${i[0] ?? DEFAULT_MODEL_IDS[0]}`; const { resolveDefaultModelMaxTokens: o } = await import("../../plugin-sdk/provider-model-shared.js"); return { profiles: [{ profileId: "copilot-proxy:local", credential: { type: "token", provider: "copilot-proxy", token: DEFAULT_API_KEY } }], configPatch: { models: { providers: { "copilot-proxy": { baseUrl: r, apiKey: DEFAULT_API_KEY, api: "openai-completions", authHeader: false, models: i.map((e) => ({ id: e, name: e, api: "openai-completions", reasoning: false, input: ["text", "image"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: DEFAULT_CONTEXT_WINDOW, maxTokens: o(DEFAULT_CONTEXT_WINDOW) })) } } }, agents: { defaults: { models: Object.fromEntries(i.map((e) => [`copilot-proxy/${e}`, {}])) } } }, defaultModel: a, notes: [ "Start the Copilot Proxy VS Code extension before using these models.", "Copilot Proxy serves /v1/chat/completions; base URL must include /v1.", "Model availability depends on your Copilot plan; edit models.providers.copilot-proxy if needed." ] }; } }], wizard: { setup: { choiceId: "copilot-proxy", choiceLabel: "Copilot Proxy", choiceHint: "Configure base URL + model ids", methodId: "local" } } }); } }); //#endregion export { copilot_proxy_default as default };