squeezr-ai 1.14.2 → 1.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,9 @@ async function compressWithHaiku(text, apiKey) {
25
25
  // The Anthropic SDK accepts both: apiKey → x-api-key header,
26
26
  // authToken → Authorization: Bearer header.
27
27
  const authOpts = apiKey.startsWith('sk-') ? { apiKey } : { authToken: apiKey };
28
- const client = new Anthropic(authOpts);
28
+ // Force real API URL — ANTHROPIC_BASE_URL points to this proxy, which would cause
29
+ // infinite recursion if we let the SDK inherit it from the environment.
30
+ const client = new Anthropic({ ...authOpts, baseURL: 'https://api.anthropic.com' });
29
31
  const resp = await client.messages.create({
30
32
  model: 'claude-haiku-4-5-20251001',
31
33
  max_tokens: 300,
package/dist/server.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { homedir } from 'node:os';
1
4
  import { Hono } from 'hono';
2
5
  import { stream } from 'hono/streaming';
3
6
  import { config } from './config.js';
@@ -13,6 +16,15 @@ const ANTHROPIC_API = 'https://api.anthropic.com';
13
16
  const OPENAI_API = 'https://api.openai.com';
14
17
  const GOOGLE_API = 'https://generativelanguage.googleapis.com';
15
18
  const SKIP_REQ_HEADERS = new Set(['host', 'content-length', 'transfer-encoding', 'connection']);
19
+ function readCodexToken() {
20
+ try {
21
+ const d = JSON.parse(readFileSync(join(homedir(), '.codex', 'auth.json'), 'utf-8'));
22
+ return d?.tokens?.access_token ?? null;
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
16
28
  const SKIP_RESP_HEADERS = new Set(['content-encoding', 'transfer-encoding', 'connection', 'content-length']);
17
29
  export const stats = new Stats();
18
30
  function forwardHeaders(headers) {
@@ -245,13 +257,23 @@ app.post('/oauth/token', async (c) => {
245
257
  });
246
258
  // ── Catch-all ─────────────────────────────────────────────────────────────────
247
259
  app.all('*', async (c) => {
248
- const upstream = detectUpstream(c.req.raw.headers);
260
+ let upstream = detectUpstream(c.req.raw.headers);
249
261
  const url = new URL(c.req.url);
250
- const NEEDS_V1 = new Set(['/models', '/engines', '/files', '/embeddings', '/moderations', '/completions', '/edits']);
262
+ const NEEDS_V1 = new Set(['/models', '/engines', '/files', '/embeddings', '/moderations', '/completions', '/edits', '/responses']);
251
263
  const pathname = NEEDS_V1.has(url.pathname) ? `/v1${url.pathname}` : url.pathname;
264
+ // /responses is exclusively an OpenAI Codex endpoint — override upstream regardless
265
+ // of what detectUpstream inferred from headers (Codex sends no auth to custom base URLs).
266
+ if (pathname === '/v1/responses')
267
+ upstream = OPENAI_API;
252
268
  const targetUrl = `${upstream}${pathname}${url.search}`;
253
269
  const body = await c.req.arrayBuffer();
254
270
  const fwdHeaders = forwardHeaders(c.req.raw.headers);
271
+ // Inject Codex OAuth token from ~/.codex/auth.json when no auth header present.
272
+ if (upstream === OPENAI_API && !fwdHeaders['authorization']) {
273
+ const codexToken = readCodexToken();
274
+ if (codexToken)
275
+ fwdHeaders['authorization'] = `Bearer ${codexToken}`;
276
+ }
255
277
  const resp = await fetch(targetUrl, {
256
278
  method: c.req.method,
257
279
  headers: fwdHeaders,
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.14.2";
1
+ export declare const VERSION = "1.14.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.14.2';
1
+ export const VERSION = '1.14.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "AI proxy that compresses Claude Code, Codex, Aider, Gemini CLI and Ollama context windows to save thousands of tokens per session",
5
5
  "keywords": [
6
6
  "claude",