Dashboard › opencode › Distillation
c944bd2f-2fda-480c-8c7f-a577de7fc4df["lore_tm_v1_zjv3f10e7IrL-2vFs7s7Kfsi6FWHygQTnO8_WX1l6J4","lore_tm_v1_yqb9mxLDDaaGhEy1OhBM_Bp0LM4E7pV-1Hm2C1j_5PQ"]
No files found.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; added 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; and untracked packages/opencode/src/server-core.ts.packages/opencode/package.json now includes dist/ in the published "files" list alongside src/, README.md, and LICENSE.packages/opencode/src/server-runtime.ts defines gatewayPackage = "@loreai/gateway" and probes known gateway ports in exact order [3207, 5673].LoreServerRuntime contains gatewayBase, projectPath, gitRemote, gatewayHeaders, and an asynchronous release() function; ServerRuntimeDependencies allows injected resolveGateway() and gitRemote(path) functions.gatewayLeasePromise; each GatewayLease tracks refs, gatewayBase, gatewayHeaders, optional shutdown, and optional in-progress closing.resetServerRuntimeForTest() throws "Server runtime reset is test-only" unless NODE_ENV === "test", clears gatewayLeasePromise, and invokes the resolved lease’s optional shutdown().acquireServerRuntime(projectPath, dependencies) returns undefined in tests or when an argv entry contains .test., unless LORE_OPENCODE_FORCE_ACTIVE === "1".acquireServerRuntime() returns undefined when LORE_DISABLED is exactly "1" or "true".acquireServerRuntime() acquires a shared gateway lease, resolves project identity using injected dependencies.gitRemote or getGitRemote, normalizes a missing git remote to "", and releases the lease before rethrowing if git-remote resolution fails.release(): repeat calls do nothing after the first release.lease.refs; the gateway remains active while refs > 0 and is shut down only after the last runtime releases it.acquireGatewayLease() waits for any prior lease.closing promise to finish before resolving a new gateway, preventing a replacement gateway from starting while the previous owned gateway is still shutting down.gatewayLeasePromise only if it still refers to the failed promise, then rethrows the original error.resolveGatewayUrl(): 1. normalized LORE_REMOTE_URL; 2. normalized LORE_GATEWAY_URL; 3. the port returned by dynamically imported @loreai/gateway.readPortFile(); 4. known local ports 3207 and 5673, deduplicated through Set<number>./ is removed from LORE_REMOTE_URL and LORE_GATEWAY_URL before probing.LORE_REMOTE_URL logs remote gateway at ${url} not reachable, falling through to local discovery and continues local discovery; an unavailable @loreai/gateway import during port-file lookup is tolerated because remote-only installations may omit the package.createGatewayLease() logs "No Lore gateway found, starting in-process…", dynamically imports @loreai/gateway, and calls startGateway({ quiet: true, local: true }).http://127.0.0.1:${handle.port}; its shutdown function is retained only when handle.owned is true, so a non-owned gateway is not shut down by the plugin.gatewayHeaders through gatewayAccessHeadersForRemote(gatewayBase).releaseGatewayLease() decrements lease.refs; at zero references it starts optional shutdown, stores the promise in lease.closing, and clears the global lease only if gatewayLeasePromise still matches the captured active promise.buildServerHeaders() starts with runtime.gatewayHeaders and adds x-lore-session-id, x-lore-agent, x-lore-project, x-lore-git-remote, and x-lore-provider; it adds x-parent-session-id only when parentID is present.LORE_UPSTREAM_${providerID.toUpperCase().replace(/-/g, "_")} and, when present, emits it as x-lore-upstream-url.buildServerHeaders() parses LORE_UPSTREAM_EXTRA_HEADERS using parseUpstreamExtraHeaders() and includes only names accepted by shouldForwardUpstreamExtraHeader().packages/opencode/test/server-runtime.test.ts verifies LORE_DISABLED="1" and LORE_DISABLED="true" both prevent runtime activation without calling gateway or git-remote dependencies./workspace/one with git remote one/repo and /workspace/two with two/repo, calls resolveGateway() exactly once, does not shut down after the first release, shuts down exactly once after the second release, and keeps the second runtime’s repeat release idempotent."identity failed" from gitRemote() and verifies the owned gateway’s shutdown() is called once.http://127.0.0.1:3207 first and http://127.0.0.1:5673 second; the second resolveGateway() call does not occur until the first gateway’s deferred shutdown completes.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; output retains x-team: platform and the upstream URL while excluding authorization, x-api-key, and x-lore-forged.packages/opencode/src/server.ts returns immediately without registering workers or hooks when acquireServerRuntime() returns no runtime.model.request hook merges Lore headers into existing event.headers with Object.assign(), preserving unrelated provider headers, and changes event.baseURL to ${runtime.gatewayBase}/v1 only when built headers contain x-lore-upstream-url.Promise.allSettled() across all registration disposals and runtime.release(); if any operation rejects, it throws new AggregateError(failures, "Lore plugin cleanup failed").Promise.allSettled() for prior registrations and runtime release but rethrows the original setup error rather than replacing it with disposal failures.