Dashboard › opencode › Distillation
dc3a2ac4-6383-42ea-bfd5-1877ae8e6eba["lore_tm_v1_02u6kdmzFFS-woy7w5TNoz5UYFNMvuAxhg0DX2SMrRE","lore_tm_v1_DySRdSHE-AXXzY1oCXlosLkicjHQRQpeEYNLrLngStI","lore_tm_v1_n7SvpBdcItZsNtUyc7sUfq2nW4SReNX88jIbD_bxZ28","lore_tm_v1_iIqtDuy4hWJo38lyubtW9Rey5GMVNc4T787DdrpPuBg","lore_tm_v1_GB8PNd5sgFStKwyp4Ad64jr9ZGvksAItATjC9Eg3guE","lore_tm_v1_x8kxxXopcFMOt5aKexYEzXs_-RrPuPORk7wfywrWhXg","lore_tm_v1_G0vfjnnxiaagDdNRYUkoqP8dLmwL5c8kMHTAOVmPRpg","lore_tm_v1_ddafgRI_Ez9LhN1LMaZwUvMPRA_zfiiL6PSLFvF8ZN0","lore_tm_v1_JJdBNixk8tnxVYSmxMx7oW-mbE1v9fdELqN8YOA30cc","lore_tm_v1_Uw537lKJksONrAjpLCdOt86iY4BLL_86s_dN2vdLnpU","lore_tm_v1_GPIW7iNYuXRQVF94CAeIBiF1rPbZCuUV5mORMY9L7Xw","lore_tm_v1_heTNa3lMOJDTGQ2xNveF7zbXvR6NqqRl7S2xMdvbHOY","lore_tm_v1_k0EauhmLKY8b3JbKXMK8xq0CLoECbGxepwIimpgqUuw","lore_tm_v1_t_Bw13ZGCBEq6r-L0jrhO6sUKDKV2nphZsG7UzE1G3U","lore_tm_v1_HFmdXfnRB8GcD7mAY45Qd5zH_4DNWqc9342YvvGJ3pk","lore_tm_v1_ZsGNWRsxzy8GyRUufOrGHaks9gBe71omMW7Tb1A4cmg","lore_tm_v1_t5FMmoyw6Fi1NqAbQJBnhAb3eFknCQ6yEG9Bn6Oyeac","lore_tm_v1_iu8t3fg3x56__gz9vnq6Wqacfpjb3hB4tRmkY3oeaLw","lore_tm_v1__wCQkvoknwNURKl5cWYiQmvMeEgSTZQhMnEpx1NpTOw","lore_tm_v1_7dM9TeNZUjAvfBDeeqMFI2c0EMxHYd9gu0ZiKlDXDHU"]
/home/byk/Code/opencode-lore-v2/packages/core/src/log.ts documents silenceStderr(silenced = true) as process-global and idempotent via globalThis[STDERR_SILENCED_KEY]; it silences logger info/warn/notice/error output unconditionally, including under LORE_DEBUG=1, while the file sink and registered LogSink continue receiving everything. isStderrSilenced() returns readStderrSilenced().formatArgs(args: unknown[]) in /home/byk/Code/opencode-lore-v2/packages/core/src/log.ts maps strings directly, Error values to .message, all other values through String(), and joins them with spaces./home/byk/Code/opencode-lore/packages/gateway/src/server.ts makes stop() idempotent by memoizing stopPromise ??= Promise.all(servers.map(closeBoundServer)).then(() => {}).startServer() in /home/byk/Code/opencode-lore/packages/gateway/src/server.ts throws when no configured host can bind, reports only successfully bound hosts, and aggregates per-server readiness into ready: Promise.all(readyPromises).then(() => {}).startServer() defensively defines throwing getters for port, hosts, ready, and stop on its specific returned Promise. Access without awaiting throws a TypeError instructing callers to use const server = await startServer(config); this addresses LOREAI-GATEWAY-1Z, where a missing await produced http://127.0.0.1:undefined/health./home/byk/Code/opencode-lore/packages/gateway/src/server.ts tracks every server connection in serverSockets: WeakMap<Server, Set<Socket>>, adds sockets on "connection", and removes each on its one-time "close" event.closeServer(server, deadlineMs) stops accepting work and lets established requests drain, but after deadlineMs invokes server.closeIdleConnections(), server.closeAllConnections(), and explicitly destroys every tracked socket. Explicit socket tracking covers connections stalled in the HTTP parser—including partial headers that never become an IncomingMessage—and upgraded sockets.closeServer() clears its deadline timer when server.close() completes and treats ERR_SERVER_NOT_RUNNING like a successful close./home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts defines LLM_API_PATH_PATTERNS for: /v1/{messages,chat/completions,responses}, /api/v1/{messages,chat/completions,responses}, /api/{messages,chat/completions,responses}, proxy prefixes /openai/v1/... and /anthropic/v1/..., and Codex /codex/responses; each permits a trailing subpath."lore-config" bug to recur for providers using non-standard prefixes.NON_STANDARD_PATH_REWRITES maps known non-/v1 LLM suffixes to canonical gateway paths, including ChatGPT’s /codex/responses./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/agent.ts defines AgentEditor methods in this order: list(): readonly DeepMutable<Agent.Info>[], get(id), default(id | undefined), update(id, callback), and remove(id). AgentDomain extends AgentApi and exposes readonly transform: Transform<AgentEditor> and reload: () => Promise<void>./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/registration.ts defines Registration.dispose(): Promise<void>, provider-scoped ModelHookOptions.providerID?: string, Hooks<Spec> callbacks returning Promise<void> | void, conditional model-hook options only for specs containing readonly model, and Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>.update() editor APIs across both promise and effect plugin domains for tools, skills, catalogs/providers/models, agents, MCP servers, and integrations, with adapter implementations in /home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts./home/byk/Code/opencode-lore-v2/packages/core/src/fetch-interceptor.ts exports DynamicRequestHeaders = Readonly<Record<string, string>> and DynamicRequestHeadersSource = DynamicRequestHeaders | (() => DynamicRequestHeaders).interceptUrl(upstream, gateway) first uses the final /v1/ occurrence to preserve the upstream prefix/base and full pathname; otherwise it checks NON_STANDARD_PATH_REWRITES. The full upstreamPath, rather than a post-base suffix, lets the gateway reconstruct origin(base) + pathname, including GitHub Copilot /chat/completions from issue #1052./home/byk/Code/opencode-lore-v2/packages/opencode/tsconfig.json extends ../../tsconfig.base.json, sets noEmit: true, uses Bun types, maps @loreai/core to ../core/src/index.ts, and includes src, test, script, scripts, and eval./home/byk/Code/opencode-lore-v2/packages/opencode/src/server-runtime.ts defines LoreServerRuntime with gatewayBase, projectPath, gitRemote, gatewayHeaders, and idempotent asynchronous release().ServerRuntimeDependencies permits injected resolveGateway() and gitRemote(path) implementations; GatewayLease tracks refs, gateway address/headers, optional shutdown, and optional in-progress closing.resetServerRuntimeForTest() throws outside NODE_ENV=test, clears the global gatewayLeasePromise, awaits the prior lease if present, and invokes its optional shutdown.acquireServerRuntime() returns undefined during tests or when an argv entry includes .test., unless LORE_OPENCODE_FORCE_ACTIVE=1; it also returns undefined for LORE_DISABLED=1 or LORE_DISABLED=true.acquireServerRuntime(projectPath, dependencies) acquires a shared gateway lease, resolves gitRemote with injected logic or getGitRemote, substitutes "" for null, releases the lease if project identity resolution throws, and returns a release closure guarded by a released boolean.acquireGatewayLease() reuses gatewayLeasePromise, increments refs, clears a failed shared promise, and, when the current lease is closing, waits for closure before retrying acquisition so a replacement gateway cannot start until prior shutdown finishes.createGatewayLease() first calls resolveGatewayUrl(); when an existing gateway is found it creates an unowned lease with gatewayAccessHeadersForRemote(resolved). Otherwise it dynamically imports @loreai/gateway, calls startGateway({ quiet: true, local: true }), uses http://127.0.0.1:${handle.port}, and retains handle.shutdown only if handle.owned is true.resolveGatewayUrl() discovery order: 1. trimmed LORE_REMOTE_URL, falling through with an informational log if unreachable; 2. trimmed LORE_GATEWAY_URL; 3. the gateway package’s readPortFile() result if importable; 4. known ports 3207 and 5673. Port probes use http://127.0.0.1:${port}.releaseGatewayLease() decrements refs, returns while references remain, otherwise records a shared closing promise, awaits optional shutdown, and clears gatewayLeasePromise only if it still refers to that active lease.buildServerHeaders() emits gateway access headers plus x-lore-session-id, x-lore-agent, x-lore-project, x-lore-git-remote, and x-lore-provider; conditionally adds x-parent-session-id; and maps provider IDs to LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")} for x-lore-upstream-url.buildServerHeaders() parses LORE_UPSTREAM_EXTRA_HEADERS and includes only names accepted by shouldForwardUpstreamExtraHeader()./home/byk/Code/opencode-lore-v2/packages/opencode/test/server-runtime.test.ts verifies both LORE_DISABLED=1 and LORE_DISABLED=true keep the V2 runtime inactive./workspace/one and /workspace/two share one resolved owned gateway, retain distinct remotes one/repo and two/repo, do not shut down after the first release, shut down exactly once after the second, and keep repeated release idempotent."identity failed" error during git-remote resolution rejects acquisition and invokes gateway shutdown exactly once.http://127.0.0.1:3207, the replacement is http://127.0.0.1:5673, and resolveGateway is not called a second time until the first shutdown resolves.LORE_UPSTREAM_OPENAI=https://upstream.example/v1 and extra headers x-team: platform, authorization: Bearer secret, x-api-key: secret, and x-lore-forged: bad. The result preserves gateway token x-lore-access: gateway-token, session ses_1, parent ses_parent, agent build, project /workspace/project, git remote github.com/example/project, provider openai, upstream URL, and x-team: platform, while excluding authorization, x-api-key, and forged x-lore-*./home/byk/Code/opencode-lore/packages/gateway/src/cli/start.ts computes VECTOR_POOL_SHUTDOWN_DEADLINE_MS as Math.max(Math.min(DEFAULT_VECTOR_POOL_SHUTDOWN_DEADLINE_MS, SHUTDOWN_DEADLINE_MS - 500), 500).StartOptions supports port, hosts, debug, embedded-mode quiet, remoteUrl, local (--local/-l), allowRemoteManagement, daemonization through bg (--bg/--daemon), and internal processBoundary.processBoundary is “never set by in-process plugins”; it is an internal CLI-owned process-boundary option.GatewayHandle exposes config, port, owned, owner-only managementToken, shutdown() (a no-op when not owned), and internal one-shot processShutdown shared by signals and control.GatewayIdentityProbe variants are authenticated with a PID-bearing identity, rejected, unavailable, and timeout; GatewayShutdownRequestResult variants are "accepted", "unsupported", and "failed"./home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts exports a V2 plugin satisfying Plugin.Plugin, with ID "lore" and three ordered workers: 1. lore-distill — "Lore memory distillation worker"; 2. lore-curator — "Lore knowledge curator worker"; 3. lore-query-expand — "Lore query expansion worker".ctx.location.project.directory and returns immediately when runtime acquisition is inactive.agent.mode = "subagent", and sets agent.hidden = true."model.request" hook retrieves the session by event.sessionID, tolerates lookup failure, builds headers from runtime/session/optional parent/agent/provider context, assigns them into event.headers, and changes event.baseURL to ${runtime.gatewayBase}/v1 only when x-lore-upstream-url is present."http.request" hook replaces event.request with await rewriteRequest(event.request, runtime.gatewayBase, {})./home/byk/Code/opencode-lore-v2/packages/opencode/src/server.ts runs all completed registration disposals plus runtime.release() through Promise.allSettled() before rethrowing the original error.cleaned; it settles every registration disposal plus runtime release, collects all rejection reasons, and throws AggregateError(failures, "Lore plugin cleanup failed") when any cleanup operation fails./home/byk/Code/opencode-v2-pilot/packages/schema/src/agent.ts defines Agent.Info with id, name, optional model, request, optional system, optional description, mode "subagent" | "primary" | "all", hidden, optional color, optional positive steps, and permissions.Agent.Info.default(id) initializes name from the ID, empty request settings/headers/body, mode: "primary", hidden: false, and permission defaults that allow all actions, ask for external_directory, ask for reads of *.env and *.env.*, and allow reads of *.env.example.