| ... | ... | @@ -37,6 +37,17 @@ import { resolveSpawnCommand } from "@t3tools/shared/shell"; |
| 37 | 37 | const encodeUnknownJsonStringExit = Schema.encodeUnknownExit(Schema.fromJsonString(Schema.Unknown)); |
| 38 | 38 | const OPENCODE_EMPTY_CONFIG_CONTENT = "{}"; |
| 39 | 39 | |
| 40 | export function resolveOpenCodeConfigContent( |
| 41 | inputEnvironment: Readonly<Record<string, string | undefined>> | undefined, |
| 42 | inheritedEnvironment: Readonly<Record<string, string | undefined>> = process.env, |
| 43 | ): string { |
| 44 | return ( |
| 45 | inputEnvironment?.OPENCODE_CONFIG_CONTENT ?? |
| 46 | inheritedEnvironment.OPENCODE_CONFIG_CONTENT ?? |
| 47 | OPENCODE_EMPTY_CONFIG_CONTENT |
| 48 | ); |
| 49 | } |
| 50 | |
| 40 | 51 | const OPENCODE_SERVER_READY_PREFIX = "opencode server listening"; |
| 41 | 52 | const DEFAULT_OPENCODE_SERVER_TIMEOUT_MS = 30_000; |
| 42 | 53 | const DEFAULT_HOSTNAME = "127.0.0.1"; |
| ... | ... | @@ -467,7 +478,14 @@ const makeOpenCodeRuntime = Effect.gen(function* () { |
| 467 | 478 | shell: spawnCommand.shell, |
| 468 | 479 | env: { |
| 469 | 480 | ...input.environment, |
| 470 | | OPENCODE_CONFIG_CONTENT: OPENCODE_EMPTY_CONFIG_CONTENT, |
| 481 | // Respect an OPENCODE_CONFIG_CONTENT provided by the caller or |
| 482 | // the inherited process environment, only falling back to the |
| 483 | // empty config when neither is set. Setting it unconditionally |
| 484 | // previously clobbered the user's opencode config, hiding their |
| 485 | // providers/models. The value is set explicitly (rather than |
| 486 | // relying on inheritance) because `extendEnv` is false whenever |
| 487 | // `input.environment` is provided. |
| 488 | OPENCODE_CONFIG_CONTENT: resolveOpenCodeConfigContent(input.environment), |
| 471 | 489 | }, |
| 472 | 490 | extendEnv: input.environment === undefined, |
| 473 | 491 | }), |