Replace the @huggingface/transformers local embedder (~316MB ONNX cache) with an EmbeddingPort seam: graph.embeddingModel (nullable "provider:id" slug) selects an OpenRouter/OpenAI/Gemini adapter, resolved fresh per call from settings + the auth store so key rotations land immediately. - src/server/embeddings.ts rewritten: slug grammar, injected-fetch adapters (OpenRouter input_type, Gemini taskType batching, OpenAI index-ordered rows), honest resolution (null = skip-with-info, set model with missing key = honest error), embedNewNodes with model-change re-embed wipe + ghost pruning + usage steps, federated catalog (OpenRouter /api/v1/embeddings/models — VERIFIED live, the inverse path 404s; OpenAI text-embedding- filter; Gemini embedContent filter). - GET /api/models/embeddings: federated catalog, empty when no keys. - Extraction tail records stages.embedding usage into the run's money channel; EMBEDDING_PRICES overlay in core/prices.ts (outside the sync-generated block), callCost falls back to it; cost-summary folds the fourth stage; graph-context injection resolves its embedder per run, fails honestly when unconfigured, records query tokens. - Settings: GraphSettings.embeddingModel (null factory), section parser validates slug shape (id may contain colons — OpenRouter :free suffixes, live catalog fact). - Removal: @huggingface/transformers uninstalled, PATHS.modelCache and onnx tracing entries deleted, @huggingface tracing-excludes guard added, stale sharp/libvips comments updated to historical. Live-verified on port 3004: catalog federates 36 rows (33 OpenRouter + 3 OpenAI), embedNewNodes embedded 10 nodes via the free liquid/lfm-2.5 model (dim 1024, 435 prompt tokens, 1 call, $0), settings PUT rejects bad slugs with 400. Gates: typecheck, lint, 895/895 tests, build.
52 lines
2.4 KiB
TypeScript
52 lines
2.4 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
const nextConfig: NextConfig = {
|
|
// Desktop target (Electron wrapper, 2026-09-17): standalone output = a
|
|
// self-contained .next/standalone/server.js the Electron shell spawns
|
|
// on 127.0.0.1. Harmless for plain web deploys (extra build output).
|
|
// The manual copies the docs require — public/ and .next/static — are
|
|
// done by scripts/build-server.mjs.
|
|
output: "standalone",
|
|
// SAFETY (empirically verified 2026-09-17): without this, output file
|
|
// tracing sweeps the repo's real data/ — chat records, graph ledgers —
|
|
// INTO the standalone bundle. A shipped desktop app would carry the
|
|
// developer's session data inside it.
|
|
outputFileTracingExcludes: {
|
|
"*": [
|
|
"data/**/*",
|
|
// Wave 6 (2026-09-23): the local transformers embeddings died — any
|
|
// @huggingface copy (or its ~300MB model cache, if one ever
|
|
// reappears) must never sweep into the standalone bundle again.
|
|
"node_modules/@huggingface/**/*",
|
|
],
|
|
},
|
|
// Empirically verified gaps (2026-09-17 standalone smoke): the tracer
|
|
// misses JSON loaded via `import ... with { type: "json" }` attributes —
|
|
// pi-ai's provider catalog (39 JSON files) vanished from the trace and
|
|
// the server 500s on module load. Include the whole data dirs of the
|
|
// runtime-loaded engine packages.
|
|
// pdfjs-dist (sources v0 live smoke, 2026-09-19): its legacy build loads
|
|
// the node fake worker (pdf.worker.mjs) and our standard_fonts dir via
|
|
// runtime-resolved paths — invisible to the tracer. Bundling (without
|
|
// serverExternalPackages below) additionally breaks the worker's
|
|
// import.meta.url resolution inside .next/dev chunks — the live smoke
|
|
// caught it; unit tests run unbundled and never see it.
|
|
outputFileTracingIncludes: {
|
|
"*": [
|
|
"node_modules/pdfjs-dist/legacy/**/*",
|
|
"node_modules/pdfjs-dist/standard_fonts/**/*",
|
|
"node_modules/@earendil-works/pi-ai/dist/providers/data/**/*",
|
|
"node_modules/@earendil-works/pi-agent-core/dist/**/*.json",
|
|
],
|
|
},
|
|
// Framework-free core lives in src/ (plain TS, imported by routes and CLI alike).
|
|
// The pi engine must stay external: its providers are runtime-loaded Node
|
|
// code (undici streams, catalog data) that breaks when bundled into routes.
|
|
serverExternalPackages: [
|
|
"@earendil-works/pi-ai",
|
|
"@earendil-works/pi-agent-core",
|
|
"pdfjs-dist", // sources v0: bundling breaks its node fake-worker path
|
|
],
|
|
};
|
|
|
|
export default nextConfig; |