Dashboard › opencode › Distillation
13b8b8f3-33f6-4c6a-b79f-d0b8856af445["lore_tm_v1_p_4jxO22MdokCWQ1AOIVlZCsCx2zyooqAujD1DEs8Qg","lore_tm_v1_VlXDj1_IrugWWtEokv5sgtPa_8g0VkosbWo47JBCe1E","lore_tm_v1_PUH5M_2ZGUrpz8b-wScxzjsAh4nHVZIuGEVIlChXWDs"]
resolveGatewayUrl, startInProcess, and processBoundary across /home/byk/Code/opencode-lore: packages/pi/test/internal.test.ts (lines 9, 347, 360, 399), packages/pi/test/gateway-discovery.test.ts (lines 4, 8, 63, 67, 73), packages/pi/src/internal.ts (lines 181, 233), packages/pi/src/index.ts (lines 40, 44, 83, 91), packages/opencode/test/gateway-smoke.test.ts (line 8), packages/opencode/src/index.ts (lines 44, 89, 265, 272), packages/gateway/src/cli/start.ts (lines 105, 1214, 1312), packages/gateway/src/cli/run.ts (lines 488, 577), packages/gateway/src/cli/shutdown.ts (line 320), and packages/gateway/test/shutdown-active-stream.test.ts (line 112)./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts adapts Promise-plugin APIs to Effect host APIs: reload() methods call run(host.*.reload()); endpoint methods use adaptApiMethod(...); hooks wrap callbacks with Effect.promise(() => Promise.resolve(callback(event))); transform registrations use register(...)./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts, permission assertions run host.permission.assert(input) and convert caught typed errors into defects via Effect.catch((error) => Effect.die(new TypedFailure(error)))./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts, tool transforms expose list, get, namespace, add, update, and remove; Promise executors are converted with promiseExecutor(...) or executePromiseTool(...). update creates a Promise-facing Info, invokes the update callback, then copies output, options, and an adapted execute back onto the host tool with Object.assign./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts, VCS definitions adapt info, optional bound base, branches, status, and diff through attempt((signal) => ...); web-search definitions adapt execute; worktree definitions adapt create, remove, and list./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts invokes plugin.setup(context2) inside Effect.acquireRelease; a truthy cleanup returned from setup is invoked during release and both setup and cleanup accept synchronous or Promise-like results through Promise.resolve(...)./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts defines attempt<A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) as Effect.tryPromise({ try: evaluate, catch: (cause) => cause })./home/byk/Code/opencode-lore/packages/pi/src/internal.ts defines probeGateway(baseURL, timeoutMs = 1500): it probes ${baseURL}/health, uses probeLoopback(...) for loopback URLs and fetch(...) otherwise, aborts after 1500 ms by default, returns false on errors, and always clears its timeout./home/byk/Code/opencode-lore/packages/pi/src/internal.ts defines resolveGatewayUrl() discovery order as: 1. LORE_REMOTE_URL, 2. LORE_GATEWAY_URL, 3. the gateway port file via dynamically imported @loreai/gateway and readPortFile(), 4. KNOWN_GATEWAY_PORTS, documented as ports 3207 and 5673. It strips a trailing slash from environment URLs, validates them with gatewayUrlForLog(...), probes candidates, deduplicates ports with Set<number>, uses http://127.0.0.1:${port} for local probes, and returns null if none is reachable.LORE_REMOTE_URL is invalid or unreachable, resolveGatewayUrl() logs pi: remote gateway at ${url} not reachable, falling through to local discovery; an unreachable LORE_GATEWAY_URL also falls through to discovery without being returned./home/byk/Code/opencode-lore/packages/pi/src/internal.ts defines startInProcess() by dynamically importing @loreai/gateway through the variable gw with /* webpackIgnore: true */, then calling startGateway({ quiet: true, local: true }). It returns http://127.0.0.1:${handle.port}, logs reuse when handle.owned is false, and on failure logs pi: failed to start gateway in-process and returns null.startInProcess() documentation states that the published CJS gateway bundle supplies Node.js polyfills mapping Bun.serve() to node:http.createServer(), and that startGateway() handles port fallback 3207 → 5673 → random plus port-file management./home/byk/Code/opencode-lore/packages/pi/src/internal.ts defines sessionIDFor(sessionFile): absent a session file it returns pi-ephemeral-${process.pid}; otherwise it returns pi- plus the first 24 hexadecimal characters of the SHA-256 hash of the session-file path./home/byk/Code/opencode-lore/packages/pi/src/internal.ts defines gatewayAccessHeadersForRemote(gatewayBase, env = process.env): after trimming trailing slashes, it injects { [GATEWAY_AUTH_HEADER]: env.LORE_GATEWAY_AUTH_TOKEN } only when gatewayBase exactly matches LORE_REMOTE_URL and LORE_GATEWAY_AUTH_TOKEN is set; otherwise it returns {}.