Dashboard › opencode › Distillation
4f675165-2193-4632-b3f4-bec0f35de4d8["lore_tm_v1_51FxZOakR6cxr3DnJPHUJxT3TanoGuugf-poMZ52yqU"]
/home/byk/Code/opencode-lore/packages/gateway/src/index.ts imports ../instrument and exposes the gateway library API: loadConfig, DEFAULT_PORTS, DEFAULT_PORT, GatewayConfig, startServer, handleRequest, resetPipelineState, readPortFile, readGatewayProcessFile, startGateway, probeGateway, probeGatewayProcess, probeGatewayProcessHost, probeUrlFor, GatewayHandle, and StartOptions.packages/gateway/src/index.ts exports Stricli-driven runCli from ./cli/cli and legacy _cli from ./cli/main; runCli dispatches help, version, whoami, logs, stop, log, and diff through the typed tree, while falling back to _cli() for commands not yet migrated, and _cli() remains exported for migration-window compatibility.__filename is always defined in CJS; packages/gateway/src/index.ts therefore detects direct CJS execution by checking typeof __filename === "string" and comparing process.argv[1] === __filename.process.argv[1] === fileURLToPath(import.meta.url) for ESM under Bun or tsx, returns false on exceptions, and stores the result in isMainModule.packages/gateway/script/bundle.ts rewrites import.meta.url in CJS bundles to an injected import_meta_url shim implemented by packages/gateway/script/import-meta-url.js; the CJS import.meta.url branch is unreachable because __filename is always defined there, but the shim avoids esbuild’s empty-import-meta static warning.packages/gateway/src/index.ts directly starts the embedded gateway only when isMainModule is true, dynamically importing commandStart from ./cli/start and invoking commandStart({ quiet: true }).bun run src/index.ts from the OpenCode plugin defaults to start, not run, because the embedded-server launch has no TTY and should not auto-detect or auto-launch agents.