UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

34 lines • 1.32 kB
export const OPENAI_BASE_URL = "https://api.openai.com/v1"; export function nonEmpty(value) { const trimmed = value?.trim(); return trimmed ? trimmed : undefined; } export function sameBaseUrl(left, right) { return left.replace(/\/+$/, "") === right.replace(/\/+$/, ""); } function resolvedHeaders(headers) { if (!headers) return undefined; const resolved = {}; for (const [name, value] of Object.entries(headers)) { if (typeof value === "string" && value.trim().length > 0) resolved[name] = value; } return Object.keys(resolved).length > 0 ? resolved : undefined; } /** * Seeded placeholder keys (`SK-SENTINEL-DO-NOT-LOG-*`) are not credentials. Left unfiltered, such a * value satisfies the stored-openai branch, pins `api.openai.com`, and every request 401s with * `Incorrect API key provided: SK-SENTI***OG-2` while a working gateway sits unused. */ export function isPlaceholderKey(apiKey) { return /^SK-SENTINEL-DO-NOT-LOG/i.test(apiKey); } export function credentialParts(auth) { const apiKey = nonEmpty(auth?.apiKey); if (!apiKey || isPlaceholderKey(apiKey)) return undefined; const headers = resolvedHeaders(auth?.headers); return { apiKey, ...(headers ? { headers } : {}) }; } //# sourceMappingURL=credentials.js.map