Lines 1-27javascript
1// claude-mem-lite: Unified LLM call wrapper
2// Shared by memory (hook.mjs) and dispatch modules
3// Provider priority: ANTHROPIC_API_KEY (direct Anthropic API) →
4// OPENROUTER_API_KEY (OpenRouter, OpenAI-compatible) → claude CLI fallback
5// Model configurable via CLAUDE_MEM_MODEL (haiku|sonnet); OpenRouter slug
6// overridable via OPENROUTER_MODEL
8import { execFileSync, spawn } from 'child_process';
9import http from 'node:http';
HighChild Process
Package source references child process execution.
haiku-client.mjsView on unpkg · L7 10import https from 'node:https';
11import tls from 'node:tls';
12import { readFileSync } from 'fs';
13import { join } from 'path';
14import { randomUUID } from 'crypto';
15import { debugLog, debugCatch, parseJsonFromLLM } from './utils.mjs';
16import { DB_DIR } from './schema.mjs';
18// ─── Proxy support (native fetch ignores HTTP(S)_PROXY) ──────────────────────
20// Node's global fetch (undici) does NOT honour HTTP(S)_PROXY env vars, and
21// undici's ProxyAgent isn't importable without adding a dependency. In an env
22// that requires a local proxy to reach external APIs (e.g.
23// HTTPS_PROXY=http://127.0.0.1:PORT), a direct fetch to openrouter.ai
24// hangs/times out. We tunnel HTTPS through the HTTP CONNECT proxy using built-ins
25// only. No proxy var (or a NO_PROXY host) → null → callers keep native fetch,
26// unchanged (zero behaviour change when no proxy is configured).
27function httpConnectProxyFor(targetUrl) {