Dashboard › opencode › Distillation
9bdbc9b5-fe40-4161-905d-3fcb9c276e52["lore_tm_v1_Ac25jbkNcdZNr6S3GBVJ8eruTSHX9BzHP69-QbeQuPg","lore_tm_v1_oqU7XCTB9lAfvNLMbskLQjKEQG7gJmyxmoc5AJPPxzM","lore_tm_v1_k1Nw_3NP-z-E3203r4kckO6XzWHa58qJJEQsfLrWLTA","lore_tm_v1_0mPMHV5AB6QMeSFn2ph1rQxTGHJNYsKa_7SYzl4Byv8","lore_tm_v1_0bRxjzcjZeE2FMg3IPh8KX1vErixbBF3uYo7Rkjs7EM","lore_tm_v1_yJFrg8cek6gt1vbTAMDJHCKQ9R6OXjjXwuFG4iI8nds","lore_tm_v1_0o1-h-Twttro_zvpejE1SuJ1kKqlDSy1UykLJN43xio","lore_tm_v1_m1OkDHjyLvRRnwj4eLyN42RkdP1kOkPlfp01ecCfKrA","lore_tm_v1_nuhU4rpsUs-i5yk8IozQVAPZ4fEDErnrezC3x4ONmU0","lore_tm_v1_XiXa1x37PxUWssHmQU_cJTstfTKMckOwwAneQla6ft4","lore_tm_v1_u2DmXUxjTaPDRCaw_XyTxHVPjnGzGrpK8MEjLg8kZB4","lore_tm_v1_mWsi6xMmnw8l_nJpAw_rc8qCeUSKt8jtqNhXFTGZmd0","lore_tm_v1_T5kNy9y-AQgnbcMAEW4o1aCWTd8e-IfeyQ_XpIt6ty0","lore_tm_v1_33M0M-EMNPB6pqFNtUYk2GMx556O1_fDWyuy0T460bE","lore_tm_v1_7oM5Tr2mtPT9ZJbzyQLKhb9TeQtjxbqgHkKCJS0UAPg","lore_tm_v1_mVqWyCN2PLsqM4vhZdHPVm1EPNbJ8UlRzuLKHVSlna4"]
/home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:380-448, the "chat.headers" hook injects per-request gateway access headers, stable x-lore-session-id from OpenCode’s persistent input.sessionID, and x-lore-agent from input.agent./home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:389-400 calls resolveParentSession(ctx.client, input.sessionID) and, when found, sends the parent as x-parent-session-id, matching the signal Claude Code sends natively so the gateway can size LTM injection for issue #1300. Resolution is cached and “never blocks or throws on failure.”"chat.headers" hook sets x-lore-project from thisProjectPath and x-lore-git-remote from thisGitRemote for the current plugin request, preventing concurrent sub-agents or sibling projects in one OpenCode process from clobbering project context. The fetch interceptor’s getHeaders() remains a fallback for requests bypassing this hook, such as embedding/image generation./home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:414-433 reads runtime input.provider.id through a cast to Record<string, unknown> because OpenCode’s plugin SDK types omit .id, then sends it as x-lore-provider so routing uses provider protocol/upstream rather than model-prefix guessing.vllm, ollama, and llamacpp, the OpenCode hook derives an environment variable as LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")} and sets its value as x-lore-upstream-url only if that header is not already present; this matches the Pi plugin’s registerProviders() convention.LORE_UPSTREAM_EXTRA_HEADERS with parseUpstreamExtraHeaders() and forwards values as literal headers when shouldForwardUpstreamExtraHeader(name) permits them, supporting corporate proxies, LiteLLM, and Cloudflare AI Gateway auth/team-routing tokens without clobbering gateway-managed headers. The gateway applies the same environment variable as a safety net when the plugin is bypassed.log, remains visible through lore logs, and logs active: ${projectPath}, routing through ${gatewayBase}, and dashboard: ${gatewayBase}/ui./home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:462-477 adds gatewayAccessHeadersForRemote(gatewayBase) and reads currentProject; it emits x-lore-project only when cur?.path exists and emits x-lore-git-remote only from the same cur record. User required that it is “never a remote left over from a different project's plugin call.”/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts:101-124 establishes that any stdout/stderr byte from an in-process gateway corrupts the Pi or OpenCode full-screen TUI; this includes log.error, raw console.*, and the Pi-on-Windows failure class where console lines bled into rendering.silenceStderr() once on activation. Thereafter the core logger writes only to its persistent log file and registered LogSink such as Sentry—never stderr at any level, including error and even with LORE_DEBUG=1. Standalone lore/CLI processes do not call it and retain stderr visibility.globalThis key __loreStderrSilenced, not a module-level variable, because the gateway’s Node/CJS dist/index.cjs bundles a second @loreai/core instance while only the Bun bundle keeps core external via gateway script/bundle.ts. Sharing globalThis ensures one plugin-side silenceStderr() call also suppresses the bundled gateway core./home/byk/Code/opencode-lore-v2/packages/core/src/log.ts:127-147 implements readStderrSilenced(), idempotent silenceStderr(silenced = true), and isStderrSilenced(). Suppression applies unconditionally to info/warn/notice/error, while file and LogSink output continue./home/byk/Code/opencode-lore-v2/packages/opencode/src/index.ts:243-279 calls log.silenceStderr() for a real OpenCode process but skips it under isInertTestEnv() so unrelated test suites retain console output.LORE_DISABLED is exactly "1" or "true". When enabled outside inert test mode, loreInitPromise memoizes initialization so concurrent LorePlugin calls cannot race during probe→spawn.resolveGatewayUrl() to probe the port file and known ports. If an existing gateway is found, it logs gateway detected at ${existingUrl}; otherwise it logs starting gateway in-process…, calls startInProcess(), and on success logs gateway started in-process at ${startedUrl}./home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js confirmed that Promise plugins receive context2.session.get, implemented as adaptApiMethod(SessionEndpoints["session.get"], host.session.get), alongside session.create, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, and context.adaptApiMethod() compiles endpoint schemas, JSON-normalizes input, decodes it through endpoint schemas, invokes the host method, returns undefined for no-content endpoints, and otherwise encodes the result. Compiled endpoint metadata is cached in compiledEndpoints, a WeakMap.close() callbacks in subscriptions, removes abort listeners on close, handles already-aborted signals, and registers a scope finalizer that closes all active subscriptions when the plugin unloads./home/byk/Code/opencode-lore-v2/packages/opencode/node_modules/@opencode/plugin/dist/promise/adapter.js:413-428 maps the session API exactly as: hook, create, get, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, and context.plugin.setup(context2) under Effect.acquireRelease; if setup returns cleanup, unloading resolves and invokes that cleanup. attempt(evaluate) wraps calls with Effect.tryPromise, and executePromiseTool() forwards tool progress through Effect.runPromise(context.progress(update)).pnpm ran @loreai/opencode@0.40.0 typecheck in /home/byk/Code/opencode-lore-v2/packages/opencode using tsc --noEmit; it completed successfully with no errors./home/byk/Code/opencode-lore-v2: 1 test file passed and 2 tests passed; start time 14:39:31, total duration 9.56s, with transform 544ms, setup 608ms, import 8ms, tests 8.73s, and environment 0ms.packages/core/src/fetch-interceptor.ts, packages/core/src/index.ts, packages/opencode/package.json, packages/opencode/src/index.ts, packages/opencode/src/internal.ts, packages/opencode/test/internal.test.ts, and pnpm-lock.yaml.packages/core/test/fetch-interceptor-request.test.ts, packages/opencode/script/build.ts, packages/opencode/src/server-runtime.ts, packages/opencode/src/server.ts, packages/opencode/test/package.test.ts, packages/opencode/test/server-runtime.test.ts, and packages/opencode/test/server.test.ts./home/byk/Code/opencode-v2-pilot/packages/core/src/session/schema.ts; it re-exports SessionSchema from @opencode/schema/session and aliases Session.ID and Session.Info as runtime exports and TypeScript types./home/byk/Code/opencode-v2-pilot/packages/schema/src/session.ts:34 defines parentID: ID.pipe(optional). The v1 schema also contains parent identifiers at /home/byk/Code/opencode-v2-pilot/packages/schema/src/v1/session.ts:461 (parentID: MessageID) and line 550 (parentID: optional(SessionID))./home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:207-210 constructs session headers from session fields "id" | "parentID" | "projectID" and conditionally emits "x-parent-session-id": session.parentID./home/byk/Code/opencode-v2-pilot/packages/core/src/session/transfer.ts, projector.ts, store.ts, info.ts, stats.ts, runner/llm.ts, and execution/restart.ts; the search returned 21 matches across the session implementation.true for all three non-exact gateway URLs: https://gateway.example.com.evil/v1/messages, https://gateway.example.com:444/v1/messages, and https://gateway.example.com/v11/messages. This demonstrates hostname-suffix, different-port, and path-prefix false positives caused by string-prefix matching rather than parsed origin/path-boundary comparison.