Dashboard › opencode-lore › Distillation
84c5b6df-581f-41d0-a13b-18a06113d87b["lore_tm_v1_XP2CY2TR7NYWrcShdMlHJvf_XEfRMEb9t2qDtWb0toI"]
Date: September 17, 2026
packages/gateway/script/bundle.ts:261-279 builds packages/core/src/vector-worker.ts as dist/vector-worker.cjs with esbuild settings bundle: true, format: "cjs", target: "node22", platform: "node", conditions: ["node"], external: ["node:*", "sqlite-vec"], sourcemap: false, minify: true, legalComments: "none", inject: [importMetaUrlShim], and "import.meta.url": "import_meta_url"; the Node condition resolves #db/driver to driver.node.ts using node:sqlite.packages/gateway/script/bundle.ts:281-300 builds packages/core/src/vector-worker.ts as the Bun ESM worker dist/vector-worker.js with bundle: true, format: "esm", target: "esnext", platform: "node", conditions: ["bun"], external: ["bun:*", "node:*", "sqlite-vec"], sourcemap: false, minify: true, and legalComments: "none"; under Bun, #db/driver resolves to driver.bun.ts using bun:sqlite, and the pool locates the worker through import.meta.url.packages/gateway/script/bundle.ts:303-325 copies ort-wasm-simd-threaded.mjs and ort-wasm-simd-threaded.wasm from the onnxruntime-web distribution into dist/; embedding-worker.ts sets __LORE_NPM_WASM_PATHS__ to these sibling files so transformers.js loads WASM locally rather than from the jsDelivr CDN.ort-wasm-simd-threaded.mjs, unlike the SEA binary, which patches pthread spawning to a no-op. This is safe only while embedding-worker.ts forces numThreads=1, because the single-thread path never calls its pthread new Worker(...); that call would crash under Node because the worker has no global Worker. If numThreads changes, the copied .mjs must be patched as build-binary-sea does.packages/gateway/script/bundle.ts:327-356 calls injectDebugId(jsPath, mapPath, { skipSnippet: true }); skipSnippet: true avoids an IIFE snippet that breaks mixed ESM/CJS output, while instrument.ts registers the debug ID through the build-time __SENTRY_DEBUG_ID__ constant.packages/gateway/script/bundle.ts:346-355 reads jsPath and applies content.replaceAll(PLACEHOLDER_DEBUG_ID, debugId); both UUIDs are 36 characters so sourcemap character positions remain valid, and replacement failures emit ⚠Debug ID placeholder replacement failed: ${msg}.packages/gateway/script/bundle.ts:337-344 logs ✓ Debug ID injected: ${debugId} on success or ⚠Debug ID injection failed: ${msg} on failure.packages/gateway/script/bundle.ts:358-391 uploads sourcemaps only when SENTRY_AUTH_TOKEN exists, using npx sentry sourcemap upload dist/ --release <pkg.version> --org byk --project loreai-gateway --url-prefix ~/ with cwd: packageDir and stdio: "inherit"; local development and fork PRs gracefully skip upload, logging No SENTRY_AUTH_TOKEN — skipping sourcemap upload..map files for retry. After a successful upload, packages/gateway/script/bundle.ts:393-401 deletes mapPath with unlinkSync(mapPath) so sourcemaps do not ship to users; failure to delete is ignored.packages/gateway/script/bundle.ts:404-437 generates executable dist/bin.cjs with mode 0o755. The wrapper requires Node.js 22.15 or later, recommends curl -fsSL https://lore.dev/install | bash when the runtime is too old, suppresses process warnings by overriding process.emit, and invokes require("./index.cjs").runCli(), setting process.exitCode = 1 on failure.packages/gateway/script/bundle.ts:443-462 declares GatewayConfig: port defaults to 3207 via LORE_LISTEN_PORT; portExplicit tracks LORE_LISTEN_PORT or --port; hosts defaults to ["127.0.0.1"] via comma-separated LORE_LISTEN_HOST; upstreamAnthropic defaults to https://api.anthropic.com via LORE_UPSTREAM_ANTHROPIC; upstreamOpenAI defaults to https://api.openai.com via LORE_UPSTREAM_OPENAI; idleTimeoutSeconds defaults to 60; and debug defaults to false via LORE_DEBUG.packages/gateway/script/bundle.ts:464-479 declares StartOptions with optional port, hosts, debug, and quiet, plus GatewayHandle with config, port, owned, and shutdown: () => Promise<void>; quiet suppresses the verbose banner in embedded mode, and shutdown is a no-op when owned is false.dist/index.d.cts declares DEFAULT_PORTS as readonly [3207, 5673], DEFAULT_PORT as 3207, and exports loadConfig(), startServer(config), startGateway(opts?), probeGateway(baseURL, timeoutMs?), readPortFile(), resetPipelineState(), and _cli().startGateway() for plugins and programmatic use because it handles port fallback, port-file management, and existing-instance reuse. startServer(config) returns stop, port, hosts, and a ready promise; probeGateway() tests /health and returns true for a 2xx response or false on error/timeout; readPortFile() returns a port number or null.packages/gateway/script/bundle.ts reports these build artifacts in order: 1. dist/index.cjs — Node.js CJS bundle using node:sqlite; 2. dist/index.bun.js — Bun ESM bundle using bun:sqlite; 3. dist/embedding-worker.cjs — Node.js embedding worker; 4. dist/embedding-worker.js — Bun embedding worker; 5. dist/vector-worker.cjs — Node.js vector-search worker; 6. dist/vector-worker.js — Bun vector-search worker; 7. dist/ort-wasm-simd-threaded.{mjs,wasm} — ONNX WASM runtime; 8. dist/bin.cjs — CLI wrapper; 9. dist/index.d.cts — type declarations.