@devries-cameron20 / t3code Mirror · read-only / commits / de77e61281
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 18:30 UTC

fix(provider): make readiness probe timeouts configurable (#33275)

Co-authored-by: johan.thomas <johan.thomas@inceptionai.ai> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Johan John Thomas committed Nov 13, 2026 at 03:23 UTC de77e61281312709520cb7ee75b97f2fc090fcfb
25 files changed +347 -66
apps/server/src/provider/AntigravityProvider.ts
+9 -5
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 ANTIGRAVITY_DEFAULT_MODEL,
4 ProviderDriverKind,
@@ -40,7 +41,7 @@ import { antigravityThinkingConfig } from "./acp/AntigravityAcpSupport.ts";
41
42 const EMPTY_MODEL_CAPABILITIES = createModelCapabilities({ optionDescriptors: [] });
43 const MAX_WORKSPACE_SNAPSHOTS = 32;
43 -const HEALTH_CHECK_TIMEOUT = "90 seconds";
44 +const HEALTH_CHECK_TIMEOUT_MS = 90_000;
45 const SIGN_IN_MESSAGE = "Sign in with Google to use Antigravity.";
46 const AUTH_UNCHECKED_MESSAGE =
47 "Antigravity is installed. Google account access is not checked yet.";
@@ -155,6 +156,7 @@ interface AntigravityProviderState {
156 }
157
158 interface AntigravityProviderOptions {
159 + readonly environment?: NodeJS.ProcessEnv;
160 readonly stampIdentity: (snapshot: ServerProviderDraft) => Effect.Effect<ServerProvider>;
161 readonly probe: Effect.Effect<
162 EffectAcpSchema.InitializeResponse,
@@ -271,10 +273,12 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
273 const checkProvider = Effect.fn("checkAntigravityProvider")(function* () {
274 if (!settings.enabled) return yield* getSnapshot;
275 const before = yield* SubscriptionRef.get(metadata);
274 - const result = yield* options.probe.pipe(
275 - Effect.timeoutOption(HEALTH_CHECK_TIMEOUT),
276 - Effect.result,
276 + const timeoutMs = resolveProviderProbeTimeoutMs(
277 + "antigravity",
278 + HEALTH_CHECK_TIMEOUT_MS,
279 + options.environment,
280 );
281 + const result = yield* options.probe.pipe(Effect.timeoutOption(timeoutMs), Effect.result);
282 const initialized =
283 Result.isSuccess(result) && Option.isSome(result.success) ? result.success.value : undefined;
284 const version = initialized?.agentInfo?.version;
@@ -289,7 +293,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
293 ? "Antigravity ACP runtime is not installed or its executable could not be found."
294 : failure
295 ? "Antigravity could not complete its local health check."
292 - : `Antigravity did not respond to its local health check within ${HEALTH_CHECK_TIMEOUT}.`;
296 + : `Antigravity did not respond to its local health check within ${timeoutMs / 1_000} seconds.`;
297 const supportsTextGeneration =
298 initialized !== undefined ? yield* options.supportsTextGeneration : false;
299 const updatedAt = DateTime.formatIso(yield* DateTime.now);
apps/server/src/provider/ClaudeProvider.ts
+11 -3
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 type ClaudeSettings,
4 type ModelCapabilities,
@@ -484,7 +485,9 @@ const probeClaudeCapabilities = (
485 catch: (cause) => new ClaudeCapabilitiesProbeSdkError({ operation: "initialize", cause }),
486 });
487 }).pipe(
487 - Effect.timeout(CAPABILITIES_PROBE_TIMEOUT_MS),
488 + Effect.timeout(
489 + resolveProviderProbeTimeoutMs("claude", CAPABILITIES_PROBE_TIMEOUT_MS, environment),
490 + ),
491 Effect.flatMap(({ q, init, graceMs }) =>
492 Effect.gen(function* () {
493 // Usage has its own deadline so a slow optional request cannot discard initialization.
@@ -651,7 +654,12 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
654 ["--version"],
655 providerProbeEnvironment(resolvedEnvironment),
656 cwd,
654 - ).pipe(Effect.timeoutOption(CLAUDE_VERSION_CHECK_TIMEOUT_MS), Effect.result);
657 + ).pipe(
658 + Effect.timeoutOption(
659 + resolveProviderProbeTimeoutMs("claude", CLAUDE_VERSION_CHECK_TIMEOUT_MS, resolvedEnvironment),
660 + ),
661 + Effect.result,
662 + );
663
664 if (Result.isFailure(versionProbe)) {
665 const error = versionProbe.failure;
@@ -756,7 +764,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
764 auth: { status: "unknown" },
765 message: probeFailure
766 ? Cause.isTimeoutError(probeFailure)
759 - ? `Timed out after ${CAPABILITIES_PROBE_TIMEOUT_MS / 1_000}s while checking Claude account status.`
767 + ? `Timed out after ${resolveProviderProbeTimeoutMs("claude", CAPABILITIES_PROBE_TIMEOUT_MS, resolvedEnvironment) / 1_000}s while checking Claude account status.`
768 : "Claude Agent CLI failed while checking account status."
769 : "Could not verify Claude authentication status from initialization result.",
770 },
apps/server/src/provider/CodexProvider.ts
+17 -3
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import { pipe } from "effect/Function";
3 import * as DateTime from "effect/DateTime";
4 import * as Duration from "effect/Duration";
@@ -692,6 +693,7 @@ const readCodexRateLimits = (
693 );
694
695 const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(function* (input: {
696 + readonly probeTimeoutMs: number;
697 readonly binaryPath: string;
698 readonly homePath?: string;
699 readonly launchArgs?: string;
@@ -716,7 +718,7 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
718 }
719
720 // Optional discovery must finish before the outer timeout can discard the account result.
719 - const deadlineMs = spawnedAtMs + CODEX_AUTH_PROBE_TIMEOUT_MS - CODEX_DISCOVERY_MARGIN_MS;
721 + const deadlineMs = spawnedAtMs + input.probeTimeoutMs - CODEX_DISCOVERY_MARGIN_MS;
722 const [skillsResponse, models, { config, nativeUsage, rateLimits }] = yield* Effect.all(
723 [
724 withCodexDiscoveryDeadline(client.request("skills/list", { cwds: [input.cwd] }), deadlineMs),
@@ -800,7 +802,12 @@ const probeCodexCliVersion = Effect.fn("probeCodexCliVersion")(
802 if (result.code !== 0) return null;
803 return CODEX_CLI_VERSION_PATTERN.exec(result.stdout)?.[1] ?? null;
804 },
803 - Effect.timeoutOption(Duration.millis(DEFAULT_TIMEOUT_MS)),
805 + (effect, input) =>
806 + effect.pipe(
807 + Effect.timeoutOption(
808 + resolveProviderProbeTimeoutMs("codex", DEFAULT_TIMEOUT_MS, input.environment),
809 + ),
810 + ),
811 Effect.map(Option.getOrNull),
812 Effect.catch((cause) =>
813 Effect.logDebug("Codex --version fallback failed.", { cause }).pipe(Effect.as(null)),
@@ -909,6 +916,7 @@ function accountProbeStatus(
916 export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(function* (
917 codexSettings: CodexSettings,
918 probe: (input: {
919 + readonly probeTimeoutMs: number;
920 readonly binaryPath: string;
921 readonly homePath?: string;
922 readonly launchArgs?: string;
@@ -948,7 +956,13 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
956 });
957 }
958
959 + const probeTimeoutMs = resolveProviderProbeTimeoutMs(
960 + "codex",
961 + CODEX_AUTH_PROBE_TIMEOUT_MS,
962 + resolvedEnvironment,
963 + );
964 const probeResult = yield* probe({
965 + probeTimeoutMs,
966 binaryPath: codexSettings.binaryPath,
967 homePath: codexSettings.homePath,
968 launchArgs: resolveCodexLaunchArgs(codexSettings.launchArgs, resolvedEnvironment),
@@ -957,7 +971,7 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
971 ...(managedAuth ? { skipNativeUsage: true } : {}),
972 }).pipe(
973 // Process teardown can outlast the work budget without discarding a completed snapshot.
960 - Effect.timeoutOption(Duration.millis(CODEX_AUTH_PROBE_TIMEOUT_MS)),
974 + Effect.timeoutOption(Duration.millis(probeTimeoutMs)),
975 Effect.scoped,
976 Effect.result,
977 );
apps/server/src/provider/Drivers/AntigravityDriver.ts
+1
@@ -434,6 +434,7 @@ export const AntigravityDriver: ProviderDriver<
434 Effect.provideService(HttpClient.HttpClient, httpClient),
435 );
436 const provider = yield* makeAntigravityProvider(settings, {
437 + environment: processEnvironment,
438 stampIdentity: classifyModels,
439 probe,
440 probeUsage: usage.probe,
apps/server/src/provider/Drivers/CodexDriver.ts
+2 -1
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import { CodexSettings, ProviderDriverKind } from "@t3tools/contracts";
3 import * as Digest from "effect/crypto/Digest";
4 import * as SecureRandom from "effect/crypto/SecureRandom";
@@ -333,7 +334,7 @@ export const CodexDriver: ProviderDriver<
334 environment: processEnv,
335 }).pipe(
336 Effect.scoped,
336 - Effect.timeout("20 seconds"),
337 + Effect.timeout(resolveProviderProbeTimeoutMs("codex", 20_000, processEnv)),
338 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
339 ),
340 ]).pipe(
apps/server/src/provider/ProviderRegistry.test.ts
+14
@@ -504,6 +504,20 @@ it.layer(
504 }),
505 );
506
507 + it.effect("allows a slow successful Codex probe with a configured budget", () =>
508 + Effect.gen(function* () {
509 + const fiber = yield* checkCodexProviderStatus(
510 + defaultCodexSettings,
511 + () => Effect.sleep("22 seconds").pipe(Effect.as(makeCodexProbeSnapshot())),
512 + { T3CODE_CODEX_PROBE_TIMEOUT_MS: "60000" },
513 + ).pipe(Effect.forkChild);
514 + yield* TestClock.adjust("22 seconds");
515 + const status = yield* Fiber.join(fiber);
516 + assert.strictEqual(status.status, "ready");
517 + assert.strictEqual(status.auth.status, "authenticated");
518 + }),
519 + );
520 +
521 it.effect("labels the plan the usage read reports over the cached login plan", () =>
522 Effect.gen(function* () {
523 const statusWithUsagePlan = (planType: string | null) =>
docs/user/install.md
+41
@@ -247,6 +247,47 @@ For provider-specific setup and accounts, see [Codex](./providers-codex.md),
247 [Antigravity](./providers-antigravity.md), [Kiro](./providers-kiro.md),
248 [Pi](./providers-pi.md), [Muse Code](./providers-muse.md), and [fx](./providers-fx.md).
249
250 +### Provider check timeouts
251 +
252 +If a provider works in its CLI but T3 Code reports a timeout while checking it,
253 +allow more time in the T3 server's environment. For example, give Codex and
254 +Claude readiness checks 60 seconds:
255 +
256 +```bash
257 +T3CODE_CODEX_PROBE_TIMEOUT_MS=60000 T3CODE_CLAUDE_PROBE_TIMEOUT_MS=60000 t3 serve
258 +```
259 +
260 +For a remote environment, set these on the machine running the T3 server.
261 +Keep them in your launcher or service configuration to retain them across
262 +updates, then restart the server. For systemd, add
263 +`Environment=T3CODE_CODEX_PROBE_TIMEOUT_MS=60000` under `[Service]` in a service
264 +override, reload systemd, and restart the service. Provider instances can also
265 +set their own overrides in Settings → Providers.
266 +
267 +Each variable extends that provider's readiness-probe deadlines; a phase whose
268 +default is already longer keeps its default. Providers with several phases can
269 +take longer than one deadline in total. Values must be whole milliseconds no
270 +greater than 2147483647; unset or invalid values keep the defaults.
271 +
272 +| Provider | Environment variable |
273 +| ------------------- | -------------------------------------- |
274 +| Codex | `T3CODE_CODEX_PROBE_TIMEOUT_MS` |
275 +| Claude | `T3CODE_CLAUDE_PROBE_TIMEOUT_MS` |
276 +| Cursor | `T3CODE_CURSOR_PROBE_TIMEOUT_MS` |
277 +| Antigravity | `T3CODE_ANTIGRAVITY_PROBE_TIMEOUT_MS` |
278 +| Grok | `T3CODE_GROK_PROBE_TIMEOUT_MS` |
279 +| Kiro | `T3CODE_KIRO_PROBE_TIMEOUT_MS` |
280 +| fx | `T3CODE_FX_PROBE_TIMEOUT_MS` |
281 +| Pi | `T3CODE_PI_PROBE_TIMEOUT_MS` |
282 +| Muse Code | `T3CODE_MUSE_PROBE_TIMEOUT_MS` |
283 +| OpenCode | `T3CODE_OPENCODE_PROBE_TIMEOUT_MS` |
284 +| ACP Registry agents | `T3CODE_ACP_REGISTRY_PROBE_TIMEOUT_MS` |
285 +
286 +Longer deadlines also take longer to report a stalled check. These overrides
287 +cover readiness and discovery, including OpenCode server startup. Usage and
288 +config enrichment retain their own shorter limits. Turn execution, package
289 +installation, update checks, and shutdown limits keep their existing behavior.
290 +
291 ## Next steps
292
293 - [Working with threads](./thread-sidebar.md): start tasks and organize parallel work.
docs/user/providers-codex.md
+7
@@ -33,6 +33,13 @@ Running `codex login` does not change a managed ChatGPT connection. In
33 and complete the wizard. Then select that instance from the thread's model
34 picker. See [Use multiple accounts](#use-multiple-accounts).
35
36 +## Allow more time for provider checks
37 +
38 +If an authenticated Codex installation reports “Timed out while checking Codex
39 +app-server provider status,” set `T3CODE_CODEX_PROBE_TIMEOUT_MS=60000` in the
40 +T3 server's environment and restart it. See [Provider check timeouts](./install.md#provider-check-timeouts)
41 +for configuration and other providers.
42 +
43 ## Use multiple accounts
44
45 Add another ChatGPT account in **Settings → Providers**, then select the account
packages/provider-acp-registry/src/server/probe.ts
+9 -4
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 AcpRegistryListProvidersResult,
4 AcpRegistryOperationError,
@@ -42,8 +43,7 @@ const MAX_ID_LENGTH = 128;
43 const MAX_NAME_LENGTH = 160;
44 const MAX_DESCRIPTION_LENGTH = 1_024;
45 const MAX_COMMAND_LINE_LENGTH = 2_048;
45 -const PROBE_TIMEOUT_SECONDS = 60;
46 -const PROBE_TIMEOUT = `${PROBE_TIMEOUT_SECONDS} seconds`;
46 +const PROBE_TIMEOUT_MS = 60_000;
47 const COMMAND_ADVERTISEMENT_GRACE = "500 millis";
48 const PROBE_SESSION_DELETE_TIMEOUT = "5 seconds";
49
@@ -332,6 +332,11 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
332 | SecureRandom.SecureRandom
333 > {
334 const catalog = yield* AcpRegistrySupport.AcpRegistryCatalog;
335 + const probeTimeoutMs = resolveProviderProbeTimeoutMs(
336 + "acp_registry",
337 + PROBE_TIMEOUT_MS,
338 + input.environment,
339 + );
340 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
341 const random = yield* SecureRandom.SecureRandom;
342 const pty = yield* Effect.serviceOption(PtyAdapter.PtyAdapter);
@@ -444,12 +449,12 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
449 }).pipe(
450 Effect.scoped,
451 Effect.timeoutOrElse({
447 - duration: PROBE_TIMEOUT,
452 + duration: probeTimeoutMs,
453 orElse: () =>
454 Effect.fail(
455 new AcpRegistryOperationError({
456 reason: "probe_failed",
452 - message: `The ACP agent did not resolve and create a test session within ${PROBE_TIMEOUT_SECONDS} seconds. Package installation or agent startup may be slow; this check retries on the next provider refresh.`,
457 + message: `The ACP agent did not resolve and create a test session within ${probeTimeoutMs / 1_000} seconds. Package installation or agent startup may be slow; this check retries on the next provider refresh.`,
458 }),
459 ),
460 }),
packages/provider-core/src/server/snapshotProbe.test.ts
+32
@@ -12,6 +12,7 @@ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
12
13 import {
14 isCommandMissingCause,
15 + resolveProviderProbeTimeoutMs,
16 parseGenericCliVersion,
17 providerModelsFromSettings,
18 spawnAndCollect,
@@ -161,6 +162,37 @@ describe("ProviderCommandNotFoundError", () => {
162 });
163 });
164
165 +describe("resolveProviderProbeTimeoutMs", () => {
166 + it.each([
167 + "codex",
168 + "claude",
169 + "cursor",
170 + "antigravity",
171 + "grok",
172 + "kiro",
173 + "fx",
174 + "pi",
175 + "muse",
176 + "opencode",
177 + "acp_registry",
178 + ])("uses only %s's readiness override", (provider) => {
179 + const key = `T3CODE_${provider.toUpperCase()}_PROBE_TIMEOUT_MS`;
180 + expect(resolveProviderProbeTimeoutMs(provider, 25000, { [key]: "60000" })).toBe(60000);
181 + expect(resolveProviderProbeTimeoutMs(provider, 25000, { [key]: "1000" })).toBe(25000);
182 + expect(
183 + resolveProviderProbeTimeoutMs(provider, 25000, { T3CODE_OTHER_PROBE_TIMEOUT_MS: "60000" }),
184 + ).toBe(25000);
185 + });
186 + it.each([undefined, "", " ", "bad", "0", "-1", "1.5", "Infinity", "2147483648"])(
187 + "retains the phase default for invalid value %s",
188 + (value) => {
189 + expect(
190 + resolveProviderProbeTimeoutMs("claude", 25000, { T3CODE_CLAUDE_PROBE_TIMEOUT_MS: value }),
191 + ).toBe(25000);
192 + },
193 + );
194 +});
195 +
196 describe("spawnAndCollect", () => {
197 // regression: #35262 - without forceKillAfter a timed-out probe whose CLI ignores
198 // SIGTERM waits for it to exit, so the caller's timeout never returns.
packages/provider-core/src/server/snapshotProbe.ts
+13
@@ -45,6 +45,19 @@ export const isWindowsCommandNotFound = Effect.fn("isWindowsCommandNotFound")(fu
45 export const DEFAULT_TIMEOUT_MS = 4_000;
46 export const AUTH_PROBE_TIMEOUT_MS = 10_000;
47
48 +export const resolveProviderProbeTimeoutMs = (
49 + provider: string,
50 + defaultTimeoutMs: number,
51 + environment: NodeJS.ProcessEnv = process.env,
52 +): number => {
53 + const timeoutMs = Number(environment[`T3CODE_${provider.toUpperCase()}_PROBE_TIMEOUT_MS`]);
54 + // Overrides only extend: callers nest these deadlines and size optional work inside them
55 + // against the defaults. Node timers overflow above a signed 32-bit delay.
56 + return Number.isInteger(timeoutMs) && timeoutMs > defaultTimeoutMs && timeoutMs <= 2_147_483_647
57 + ? timeoutMs
58 + : defaultTimeoutMs;
59 +};
60 +
61 export const COMPACT_SLASH_COMMAND = {
62 name: "compact",
63 description: "Summarize the conversation and reduce context usage",
packages/provider-cursor/src/server/status.test.ts
+27
@@ -197,6 +197,33 @@ describe("checkCursorProviderStatus", () => {
197 }),
198 );
199
200 + it.effect("allows slow SDK discovery with a configured readiness timeout", () =>
201 + Effect.gen(function* () {
202 + const fiber = yield* checkCursorProviderStatus(baseCursorSettings, {
203 + CURSOR_API_KEY: "test-key",
204 + T3CODE_CURSOR_PROBE_TIMEOUT_MS: "30000",
205 + }).pipe(
206 + Effect.provide(
207 + CursorSdkCatalog.layerTest(() =>
208 + Effect.sleep("20 seconds").pipe(
209 + Effect.as({
210 + user: {
211 + apiKeyName: "test",
212 + userEmail: "cursor@example.com",
213 + createdAt: "2026-01-01",
214 + },
215 + models: [sdkParameterizedModel],
216 + }),
217 + ),
218 + ),
219 + ),
220 + Effect.forkChild,
221 + );
222 + yield* TestClock.adjust("20 seconds");
223 + expect((yield* Fiber.join(fiber)).status).toBe("ready");
224 + }),
225 + );
226 +
227 it.effect("surfaces SDK authentication failures", () =>
228 Effect.gen(function* () {
229 const provider = yield* checkCursorProviderStatus(baseCursorSettings, {
packages/provider-cursor/src/server/status.ts
+8 -2
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import type { SDKModel, SDKUser } from "@cursor/sdk";
3 import type {
4 ModelCapabilities,
@@ -286,8 +287,13 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
287 }
288
289 const sdkCatalog = yield* CursorSdkCatalog.CursorSdkCatalog;
290 + const timeoutMs = resolveProviderProbeTimeoutMs(
291 + "cursor",
292 + CURSOR_SDK_CATALOG_TIMEOUT_MS,
293 + environment,
294 + );
295 const readCatalog = Effect.suspend(() => sdkCatalog.read(sdkApiKey)).pipe(
290 - Effect.timeoutOption(CURSOR_SDK_CATALOG_TIMEOUT_MS),
296 + Effect.timeoutOption(timeoutMs),
297 );
298 // api.cursor.com latency is intermittent; one slow read should not flip the provider to error.
299 const catalogResult = yield* readCatalog.pipe(
@@ -338,7 +344,7 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
344 version: null,
345 status: "error",
346 auth: { status: "unknown" },
341 - message: `Cursor SDK catalog request timed out after ${CURSOR_SDK_CATALOG_TIMEOUT_MS}ms.`,
347 + message: `Cursor SDK catalog request timed out after ${timeoutMs}ms.`,
348 },
349 });
350 }
packages/provider-fx/src/server/status.ts
+5 -2
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import { type ServerProviderAuth, type ServerProviderModel } from "@t3tools/contracts";
3 import type { FxSettings } from "../settings.ts";
4 import { createModelCapabilities } from "@t3tools/shared/model";
@@ -166,7 +167,9 @@ export const checkFxProviderStatus = Effect.fn("checkFxProviderStatus")(function
167
168 const probeEnvironment = providerProbeEnvironment(environment);
169 const versionResult = yield* runFxCli(settings, ["--version"], probeEnvironment).pipe(
169 - Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS),
170 + Effect.timeoutOption(
171 + resolveProviderProbeTimeoutMs("fx", VERSION_PROBE_TIMEOUT_MS, environment),
172 + ),
173 Effect.result,
174 );
175 if (Result.isFailure(versionResult) || Option.isNone(versionResult.success)) {
@@ -193,7 +196,7 @@ export const checkFxProviderStatus = Effect.fn("checkFxProviderStatus")(function
196
197 const read = (args: ReadonlyArray<string>) =>
198 runFxCli(settings, args, probeEnvironment).pipe(
196 - Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS),
199 + Effect.timeoutOption(resolveProviderProbeTimeoutMs("fx", AUTH_PROBE_TIMEOUT_MS, environment)),
200 Effect.map(Option.filter((output) => output.code === 0)),
201 Effect.map(Option.map((output) => output.stdout)),
202 Effect.orElseSucceed(() => Option.none<string>()),
packages/provider-grok/src/server/skills.ts
+4 -1
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 // The CLI catalog honors ignored/disabled skills and nested plugin skills that flat scans miss.
3 import type { ServerProviderSkill } from "@t3tools/contracts";
4 import type { GrokSettings } from "../settings.ts";
@@ -112,7 +113,9 @@ export const discoverGrokSkills = Effect.fn("discoverGrokSkills")(function* (
113 cause,
114 }),
115 ),
115 - Effect.timeoutOption(GROK_SKILLS_PROBE_TIMEOUT_MS),
116 + Effect.timeoutOption(
117 + resolveProviderProbeTimeoutMs("grok", GROK_SKILLS_PROBE_TIMEOUT_MS, environment),
118 + ),
119 );
120
121 if (Option.isNone(inspectResult)) {
packages/provider-grok/src/server/status.ts
+11 -3
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 type CustomModelSetting,
4 type ModelCapabilities,
@@ -313,7 +314,7 @@ const probeGrokModels = Effect.fn("GrokProviderStatus.probeGrokModels")(function
314 environment: NodeJS.ProcessEnv,
315 ) {
316 const modelsResult = yield* runGrokCliCommand(grokSettings, ["models"], environment).pipe(
316 - Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS),
317 + Effect.timeoutOption(resolveProviderProbeTimeoutMs("grok", AUTH_PROBE_TIMEOUT_MS, environment)),
318 Effect.result,
319 );
320 // Only a clean exit is parsed. Failed invocations print help or error text that
@@ -429,7 +430,12 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
430 grokSettings,
431 ["--version"],
432 probeEnvironment,
432 - ).pipe(Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS), Effect.result);
433 + ).pipe(
434 + Effect.timeoutOption(
435 + resolveProviderProbeTimeoutMs("grok", VERSION_PROBE_TIMEOUT_MS, environment),
436 + ),
437 + Effect.result,
438 + );
439
440 if (Result.isFailure(versionResult)) {
441 const error = versionResult.failure;
@@ -517,7 +523,9 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
523 );
524
525 const acpExit = yield* discoverGrokMetadataViaAcpInitialize(grokSettings, probeEnvironment).pipe(
520 - Effect.timeoutOption(GROK_ACP_INITIALIZE_TIMEOUT_MS),
526 + Effect.timeoutOption(
527 + resolveProviderProbeTimeoutMs("grok", GROK_ACP_INITIALIZE_TIMEOUT_MS, environment),
528 + ),
529 Effect.exit,
530 );
531 const acpMetadata = Exit.isSuccess(acpExit) ? Option.getOrUndefined(acpExit.value) : undefined;
packages/provider-kiro/src/server/status.ts
+14 -4
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 type ModelCapabilities,
4 ProviderDriverKind,
@@ -376,7 +377,9 @@ export const checkKiroProviderStatus = Effect.fn("checkKiroProviderStatus")(func
377
378 const probeEnvironment = providerProbeEnvironment(environment);
379 const versionResult = yield* runKiroCli(settings, ["--version"], probeEnvironment).pipe(
379 - Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS),
380 + Effect.timeoutOption(
381 + resolveProviderProbeTimeoutMs("kiro", VERSION_PROBE_TIMEOUT_MS, environment),
382 + ),
383 Effect.result,
384 );
385 if (Result.isFailure(versionResult) || Option.isNone(versionResult.success)) {
@@ -407,7 +410,10 @@ export const checkKiroProviderStatus = Effect.fn("checkKiroProviderStatus")(func
410 settings,
411 ["whoami", "--format", "json"],
412 probeEnvironment,
410 - ).pipe(Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS), Effect.result);
413 + ).pipe(
414 + Effect.timeoutOption(resolveProviderProbeTimeoutMs("kiro", AUTH_PROBE_TIMEOUT_MS, environment)),
415 + Effect.result,
416 + );
417 const auth = kiroAuthFromWhoami(
418 Result.isSuccess(whoamiResult) ? Option.getOrUndefined(whoamiResult.success) : undefined,
419 environment,
@@ -433,12 +439,16 @@ export const checkKiroProviderStatus = Effect.fn("checkKiroProviderStatus")(func
439 ["chat", "--list-models", "--format", "json"],
440 probeEnvironment,
441 ).pipe(
436 - Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS),
442 + Effect.timeoutOption(
443 + resolveProviderProbeTimeoutMs("kiro", AUTH_PROBE_TIMEOUT_MS, environment),
444 + ),
445 Effect.map((output) => kiroModelsFromList(Option.getOrUndefined(output))),
446 Effect.orElseSucceed(() => undefined),
447 ),
448 probeKiroAgents(settings, probeEnvironment).pipe(
441 - Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS),
449 + Effect.timeoutOption(
450 + resolveProviderProbeTimeoutMs("kiro", AUTH_PROBE_TIMEOUT_MS, environment),
451 + ),
452 Effect.map(Option.getOrUndefined),
453 Effect.orElseSucceed(() => undefined),
454 ),
packages/provider-muse/src/server/modelCatalog.ts
+5 -1
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import type { SendUserTurnOptions } from "@muse-code/sdk";
3 import { ModelCapabilities, ServerProviderModel } from "@t3tools/contracts";
4 import { MuseSettings } from "../settings.ts";
@@ -11,6 +12,9 @@ import {
12 type MuseSdkHost,
13 } from "./sdk.ts";
14
15 +export const resolveMuseStartupTimeoutMs = (environment?: NodeJS.ProcessEnv) =>
16 + resolveProviderProbeTimeoutMs("muse", 8_000, environment);
17 +
18 type MuseReasoningEffort = NonNullable<SendUserTurnOptions<never>["reasoningEffort"]>;
19
20 const REASONING_EFFORT_LABELS = {
@@ -111,7 +115,7 @@ export const discoverMuseModels = Effect.fn("discoverMuseModels")(function* (
115 ...(environment ? { environment } : {}),
116 ...(cwd ? { cwd } : {}),
117 readOnly: true,
114 - startupTimeoutMs: 8_000,
118 + startupTimeoutMs: resolveMuseStartupTimeoutMs(environment),
119 },
120 createHost,
121 ),
packages/provider-muse/src/server/status.ts
+14 -3
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import { ServerProviderModel } from "@t3tools/contracts";
3 import { MuseSettings } from "../settings.ts";
4 import { resolveSpawnCommand } from "@t3tools/shared/shell";
@@ -9,7 +10,11 @@ import * as ChildProcess from "effect/process/ChildProcess";
10
11 import { createMuseSdkHost, makeMuseEnvironment } from "./sdk.ts";
12 import { parseMuseVersion } from "./maintenance.ts";
12 -import { discoverMuseModels, museModelCapabilities } from "./modelCatalog.ts";
13 +import {
14 + discoverMuseModels,
15 + museModelCapabilities,
16 + resolveMuseStartupTimeoutMs,
17 +} from "./modelCatalog.ts";
18 import {
19 buildServerProvider,
20 COMPACT_SLASH_COMMAND,
@@ -83,7 +88,12 @@ export const checkMuseProviderStatus = Effect.fn("checkMuseProviderStatus")(func
88 ...(cwd ? { cwd } : {}),
89 }),
90 );
86 - }).pipe(Effect.timeoutOption(DEFAULT_TIMEOUT_MS), Effect.result);
91 + }).pipe(
92 + Effect.timeoutOption(
93 + resolveProviderProbeTimeoutMs("muse", DEFAULT_TIMEOUT_MS, museEnvironment),
94 + ),
95 + Effect.result,
96 + );
97
98 if (Result.isFailure(versionResult)) {
99 const missing = isCommandMissingCause(versionResult.failure);
@@ -124,7 +134,8 @@ export const checkMuseProviderStatus = Effect.fn("checkMuseProviderStatus")(func
134
135 const catalog = yield* discoverMuseModels(settings, museEnvironment, cwd, createHost).pipe(
136 Effect.scoped,
127 - Effect.timeoutOption(12_000),
137 + // Startup shares the override, so the catalog keeps its 4 seconds on top of it.
138 + Effect.timeoutOption(resolveMuseStartupTimeoutMs(museEnvironment) + 4_000),
139 Effect.result,
140 );
141 if (Result.isFailure(catalog) || Option.isNone(catalog.success)) {
packages/provider-opencode/src/server/OpenCodeRuntime.ts
+17 -3
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import * as NodeURL from "node:url";
3
4 import type { ChatAttachment, ProviderApprovalDecision } from "@t3tools/contracts";
@@ -42,7 +43,7 @@ const encodeUnknownJsonStringExit = Schema.encodeUnknownExit(Schema.fromJsonStri
43 const OPENCODE_EMPTY_CONFIG_CONTENT = "{}";
44
45 export const MINIMUM_OPENCODE_VERSION = "1.14.19";
45 -const OPENCODE_HEALTH_TIMEOUT = "5 seconds";
46 +const OPENCODE_HEALTH_TIMEOUT_MS = 5_000;
47
48 const OpenCodeHealthSchema = Schema.Struct({
49 healthy: Schema.Literal(true),
@@ -163,10 +164,15 @@ export const runOpenCodeSdk = <A>(
164
165 export const verifyOpenCodeServerVersion = Effect.fn("verifyOpenCodeServerVersion")(function* (
166 client: OpencodeClient,
167 + environment?: NodeJS.ProcessEnv,
168 ) {
169 const healthOption = yield* runOpenCodeSdk("global.health", (signal) =>
170 client.global.health({ signal }),
169 - ).pipe(Effect.timeoutOption(OPENCODE_HEALTH_TIMEOUT));
171 + ).pipe(
172 + Effect.timeoutOption(
173 + resolveProviderProbeTimeoutMs("opencode", OPENCODE_HEALTH_TIMEOUT_MS, environment),
174 + ),
175 + );
176 if (Option.isNone(healthOption)) {
177 return yield* new OpenCodeRuntimeError({
178 operation: "global.health",
@@ -578,7 +584,13 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
584 }),
585 ),
586 ));
581 - const timeoutMs = input.timeoutMs ?? DEFAULT_OPENCODE_SERVER_TIMEOUT_MS;
587 + const timeoutMs =
588 + input.timeoutMs ??
589 + resolveProviderProbeTimeoutMs(
590 + "opencode",
591 + DEFAULT_OPENCODE_SERVER_TIMEOUT_MS,
592 + input.environment,
593 + );
594 const args = ["serve", `--hostname=${hostname}`, `--port=${port}`];
595 const launch = yield* agentScope.wrap({
596 command: input.binaryPath,
@@ -749,6 +761,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
761 directory: input.directory,
762 ...(serverPassword !== undefined ? { serverPassword } : {}),
763 }),
764 + input.environment,
765 )
766 );
767
@@ -801,6 +814,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
814 directory: input.directory,
815 ...(serverPassword !== undefined ? { serverPassword } : {}),
816 }),
817 + input.environment,
818 ).pipe(
819 Effect.map((version) => ({
820 url: serverUrl,
packages/provider-opencode/src/server/driver.ts
+16 -3
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 ProviderDriverKind,
4 settingsSecretLiteral,
@@ -398,6 +399,7 @@ export const OpenCodeDriver: ProviderDriver<
399 });
400 const loadOpenCode2Models = yield* makeOpenCode2ModelLoader(
401 openCode2Server.withConnection(({ client }) => loadOpenCode2Catalog(client, host.paths.cwd)),
402 + processEnv,
403 );
404 const listOpenCode2Workspace = (cwd: string) =>
405 openCode2Server.withConnection(({ client, events }) =>
@@ -441,6 +443,7 @@ export const OpenCodeDriver: ProviderDriver<
443 ),
444 // OpenCode answers provider.list for a location only once its skill scan has ended.
445 client.provider.list({ location }).pipe(Effect.timeout("10 seconds"), Effect.ignore),
446 + processEnv,
447 );
448 }).pipe(Effect.scoped),
449 );
@@ -514,6 +517,7 @@ export const OpenCodeDriver: ProviderDriver<
517 host.paths.cwd,
518 runtimeProbe.refresh,
519 loadOpenCode2Models,
520 + processEnv,
521 ).pipe(
522 Effect.annotateLogs({ providerInstanceId: instanceId }),
523 Effect.annotateSpans({ providerInstanceId: instanceId }),
@@ -542,7 +546,7 @@ export const OpenCodeDriver: ProviderDriver<
546 {
547 skills: openCodeRuntime.loadOpenCodeSkills(client),
548 commandInventory: OpenCodeRuntime.loadOpenCodeCommands(client).pipe(
545 - Effect.timeoutOption("10 seconds"),
549 + Effect.timeoutOption(resolveProviderProbeTimeoutMs("opencode", 10_000, processEnv)),
550 Effect.map((commands) => ({
551 commands: Option.getOrElse(commands, () => []),
552 slashCommandsPending: Option.isNone(commands),
@@ -706,6 +710,7 @@ export const OpenCodeDriver: ProviderDriver<
710 openCode2Server.withConnection(({ client }) =>
711 loadOpenCode2DirectoryCatalog(client, cwd),
712 ),
713 + processEnv,
714 ).pipe(
715 Effect.map(
716 Option.map((catalog) =>
@@ -714,7 +719,10 @@ export const OpenCodeDriver: ProviderDriver<
719 ),
720 ),
721 listOpenCode2Workspace(cwd).pipe(
717 - Effect.timeout("20 seconds"),
722 + // Leaves room for the reads around the scan wait, which uses the same override.
723 + Effect.timeout(
724 + 2 * resolveProviderProbeTimeoutMs("opencode", 10_000, processEnv),
725 + ),
726 Effect.mapError(
727 (cause) =>
728 new ProviderDriverError({
@@ -740,7 +748,12 @@ export const OpenCodeDriver: ProviderDriver<
748 ),
749 v1: Effect.all([
750 snapshot.getSnapshot,
743 - loadWorkspaceForCwd(cwd).pipe(Effect.timeout("20 seconds")),
751 + loadWorkspaceForCwd(cwd).pipe(
752 + // Leaves room for connection setup before the command fallback below.
753 + Effect.timeout(
754 + 2 * resolveProviderProbeTimeoutMs("opencode", 10_000, processEnv),
755 + ),
756 + ),
757 ]).pipe(
758 Effect.map(
759 ([machineSnapshot, { skills, models, commands, slashCommandsPending }]) => ({
packages/provider-opencode/src/server/status.ts
+20 -4
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 type ModelCapabilities,
4 type ServerProviderModel,
@@ -517,10 +518,11 @@ const settleOpenCode2Catalog = <E>(
518 );
519 });
520
520 -const OPENCODE_2_CATALOG_SETTLE_TIMEOUT = "5 seconds";
521 +const OPENCODE_2_CATALOG_SETTLE_TIMEOUT_MS = 5_000;
522
523 export const makeOpenCode2ModelLoader = <E>(
524 list: Effect.Effect<ReadonlyArray<OpenCode2Model>, E>,
525 + environment?: NodeJS.ProcessEnv,
526 ) =>
527 Effect.sync(() => {
528 let lastLoaded: ReadonlyArray<OpenCode2Model> = [];
@@ -537,7 +539,13 @@ export const makeOpenCode2ModelLoader = <E>(
539 return tracked.pipe(
540 Effect.flatMap((first) =>
541 settleOpenCode2Catalog(tracked, first).pipe(
540 - Effect.timeoutOption(OPENCODE_2_CATALOG_SETTLE_TIMEOUT),
542 + Effect.timeoutOption(
543 + resolveProviderProbeTimeoutMs(
544 + "opencode",
545 + OPENCODE_2_CATALOG_SETTLE_TIMEOUT_MS,
546 + environment,
547 + ),
548 + ),
549 ),
550 ),
551 Effect.catch((error) =>
@@ -556,9 +564,12 @@ export const makeOpenCode2ModelLoader = <E>(
564 /** None when the reads fail or never agree, so a partial catalog never passes for a settled one. */
565 export const readSettledOpenCode2Catalog = <E>(
566 list: Effect.Effect<ReadonlyArray<OpenCode2Model>, E>,
567 + environment?: NodeJS.ProcessEnv,
568 ) =>
569 settleOpenCode2Catalog(list).pipe(
561 - Effect.timeoutOption(OPENCODE_2_CATALOG_SETTLE_TIMEOUT),
570 + Effect.timeoutOption(
571 + resolveProviderProbeTimeoutMs("opencode", OPENCODE_2_CATALOG_SETTLE_TIMEOUT_MS, environment),
572 + ),
573 Effect.orElseSucceed(() => Option.none<ReadonlyArray<OpenCode2Model>>()),
574 );
575
@@ -587,12 +598,15 @@ export const loadOpenCode2Workspace = Effect.fn("OpencodeProviderStatus.loadOpen
598 scanned: Effect.Effect<void>,
599 loaded: Effect.Effect<boolean>,
600 settled: Effect.Effect<void> = Effect.void,
601 + environment?: NodeJS.ProcessEnv,
602 ) {
603 const wasLoaded = yield* loaded;
604 yield* settled;
605 const first = yield* read;
606 if (wasLoaded && first.commands.length > 0) return first;
595 - yield* scanned.pipe(Effect.timeoutOption("10 seconds"));
607 + yield* scanned.pipe(
608 + Effect.timeoutOption(resolveProviderProbeTimeoutMs("opencode", 10_000, environment)),
609 + );
610 return yield* read;
611 },
612 );
@@ -749,6 +763,7 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
763 ReadonlyArray<OpenCode2Model>,
764 OpenCodeRuntime.OpenCodeRuntimeError
765 >,
766 + environment?: NodeJS.ProcessEnv,
767 ): Effect.fn.Return<
768 ServerProviderDraft,
769 never,
@@ -865,6 +880,7 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
880 ...(settingsSecretLiteral(openCodeSettings.serverPassword)
881 ? { serverPassword: settingsSecretLiteral(openCodeSettings.serverPassword) }
882 : {}),
883 + ...(environment !== undefined ? { environment } : {}),
884 })
885 .pipe(Effect.flatMap(loadInventory), Effect.scoped)
886 : serverOwner.withServer(loadInventory);
packages/provider-opencode/src/server/v2/OpenCode2Server.ts
+5 -4
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 // One OpenCode 2 process serves all directories; share it across instance threads.
3 import type { OpenCodeClient } from "@opencode/client/effect";
4 import * as Context from "effect/Context";
@@ -12,7 +13,7 @@ import * as OpenCodeRuntime from "../OpenCodeRuntime.ts";
13 import * as OpenCodeServerOwner from "../OpenCodeServerOwner.ts";
14 import * as OpenCode2Client from "./OpenCode2Client.ts";
15
15 -const INFO_TIMEOUT = "5 seconds";
16 +const INFO_TIMEOUT_MS = 5_000;
17
18 export interface OpenCode2Connection extends OpenCode2Client.OpenCode2Api {
19 readonly url: string;
@@ -79,10 +80,10 @@ const describeInfoFailure = (cause: unknown) => {
80 };
81
82 /** Only server info proves readiness; keep credential-bearing failure details out of client text. */
82 -export const verifyServer = (client: OpenCodeClient) =>
83 +export const verifyServer = (client: OpenCodeClient, environment?: NodeJS.ProcessEnv) =>
84 client.server.info().pipe(
85 Effect.timeoutOrElse({
85 - duration: INFO_TIMEOUT,
86 + duration: resolveProviderProbeTimeoutMs("opencode", INFO_TIMEOUT_MS, environment),
87 orElse: () =>
88 Effect.fail(
89 new OpenCodeRuntime.OpenCodeRuntimeError({
@@ -127,7 +128,7 @@ export const make = Effect.fn("OpenCode2Server.make")(function* (input: {
128 external: boolean,
129 ) {
130 const api = yield* opencode.connect({ baseUrl: url, password });
130 - const version = yield* verifyServer(api.client);
131 + const version = yield* verifyServer(api.client, input.environment);
132 return { ...api, url, version, external } satisfies OpenCode2Connection;
133 });
134 let latest: OpenCode2Connection | undefined;
packages/provider-opencode/src/server/versionProbe.ts
+17 -6
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import { parseSemver } from "@t3tools/shared/semver";
3 import * as Cache from "effect/Cache";
4 import * as Duration from "effect/Duration";
@@ -17,8 +18,8 @@ export interface ProbedOpenCode {
18 }
19
20 // Meant to stop a hung `--version`; wrapped installs can take several seconds to start cold.
20 -const OPENCODE_VERSION_PROBE_TIMEOUT = "10 seconds";
21 -const OPENCODE_SERVER_PROBE_TIMEOUT = "5 seconds";
21 +const OPENCODE_VERSION_PROBE_TIMEOUT_MS = 10_000;
22 +const OPENCODE_SERVER_PROBE_TIMEOUT_MS = 5_000;
23 // 2.x's own CLI decodes `{version, pid}` from `/api/info`; requiring both keeps unrelated JSON out.
24 const decodeApiInfo = Schema.decodeUnknownOption(
25 Schema.fromJsonString(Schema.Struct({ version: Schema.String, pid: Schema.Int })),
@@ -60,6 +61,11 @@ export const probeOpenCodeBinary = Effect.fn("probeOpenCodeBinary")(function* (
61 environment: NodeJS.ProcessEnv | undefined,
62 ) {
63 const runtime = yield* OpenCodeRuntime.OpenCodeRuntime;
64 + const timeoutMs = resolveProviderProbeTimeoutMs(
65 + "opencode",
66 + OPENCODE_VERSION_PROBE_TIMEOUT_MS,
67 + environment,
68 + );
69 const { stdout } = yield* runtime
70 .runOpenCodeCommand({
71 binaryPath,
@@ -68,12 +74,12 @@ export const probeOpenCodeBinary = Effect.fn("probeOpenCodeBinary")(function* (
74 })
75 .pipe(
76 Effect.timeoutOrElse({
71 - duration: OPENCODE_VERSION_PROBE_TIMEOUT,
77 + duration: timeoutMs,
78 orElse: () =>
79 Effect.fail(
80 new OpenCodeRuntime.OpenCodeRuntimeError({
81 operation: "probeOpenCodeBinary",
76 - detail: `OpenCode CLI version probe timed out after ${OPENCODE_VERSION_PROBE_TIMEOUT}.`,
82 + detail: `OpenCode CLI version probe timed out after ${timeoutMs / 1_000} seconds.`,
83 }),
84 ),
85 }),
@@ -90,6 +96,7 @@ export const probeOpenCodeBinary = Effect.fn("probeOpenCodeBinary")(function* (
96 const probeOpenCodeServer = Effect.fn("probeOpenCodeServer")(function* (
97 serverUrl: string,
98 serverPassword: string,
99 + environment?: NodeJS.ProcessEnv,
100 ) {
101 const client = yield* HttpClient.HttpClient;
102 const baseUrl = URL.parse(serverUrl.trim());
@@ -132,7 +139,11 @@ const probeOpenCodeServer = Effect.fn("probeOpenCodeServer")(function* (
139 }),
140 ),
141 Effect.timeoutOrElse({
135 - duration: OPENCODE_SERVER_PROBE_TIMEOUT,
142 + duration: resolveProviderProbeTimeoutMs(
143 + "opencode",
144 + OPENCODE_SERVER_PROBE_TIMEOUT_MS,
145 + environment,
146 + ),
147 orElse: () =>
148 Effect.fail(
149 new OpenCodeRuntime.OpenCodeRuntimeError({
@@ -169,7 +180,7 @@ export const probeOpenCodeRuntime = (
180 HttpClient.HttpClient | OpenCodeRuntime.OpenCodeRuntime
181 > =>
182 settings.serverUrl.trim().length > 0
172 - ? probeOpenCodeServer(settings.serverUrl, settings.serverPassword)
183 + ? probeOpenCodeServer(settings.serverUrl, settings.serverPassword, environment)
184 : probeOpenCodeBinary(settings.binaryPath, environment);
185
186 // Only 2.x is kept: 1.x can be upgraded in place while T3 runs, and 2.x converts the shared
packages/provider-pi/src/server/status.ts
+28 -14
@@ -1,3 +1,4 @@
1 +import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2 import {
3 type CustomModelSetting,
4 type ServerProvider,
@@ -199,6 +200,7 @@ const discoverPiViaRpc = Effect.fn("PiProviderStatus.discoverPiViaRpc")(function
200 launchArgs: ReadonlyArray<string>,
201 cwd?: string,
202 ) {
203 + const timeoutMs = resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment);
204 // This optional probe must finish before the normal discovery deadline so
205 // it cannot discard an otherwise usable catalog and authentication state.
206 const textGenerationModelSlugsFiber = yield* discoverPiTextGenerationModelSlugs(
@@ -221,10 +223,10 @@ const discoverPiViaRpc = Effect.fn("PiProviderStatus.discoverPiViaRpc")(function
223 Effect.forkScoped,
224 );
225 const connection = yield* makePiDiscoveryConnection(piSettings, environment, launchArgs, cwd);
224 - const stateData = yield* connection.request({ type: "get_state" });
225 - const modelsData = yield* connection.request({ type: "get_available_models" });
226 + const stateData = yield* connection.request({ type: "get_state" }, timeoutMs);
227 + const modelsData = yield* connection.request({ type: "get_available_models" }, timeoutMs);
228 const commandsData = yield* connection
227 - .request({ type: "get_commands" })
229 + .request({ type: "get_commands" }, timeoutMs)
230 .pipe(Effect.orElseSucceed(() => undefined));
231 const discoveredModels = yield* Effect.fromResult(parseDiscoveredModels(modelsData, stateData));
232 const { slashCommands, skills } = parsePiDiscoveredCommands(commandsData);
@@ -269,18 +271,23 @@ export const discoverPiCommandsForCwd = Effect.fn("discoverPiCommandsForCwd")(
271 cwd,
272 );
273 // A failed read must not replace a previously usable workspace catalog with an empty one.
272 - const commandsData = yield* connection.request({ type: "get_commands" });
274 + const commandsData = yield* connection.request(
275 + { type: "get_commands" },
276 + resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment),
277 + );
278 const { slashCommands, skills } = parsePiDiscoveredCommands(commandsData);
279 return { slashCommands: withPiBuiltinSlashCommands(slashCommands), skills };
280 },
281 Effect.scoped,
277 - Effect.timeoutOrElse({
278 - duration: PI_RPC_DISCOVERY_TIMEOUT_MS,
279 - orElse: () =>
280 - Effect.fail(
281 - new PiRpcTimeoutError({ operation: "discovery", timeoutMs: PI_RPC_DISCOVERY_TIMEOUT_MS }),
282 - ),
283 - }),
282 + (effect, _settings, environment) => {
283 + const timeoutMs = resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment);
284 + return effect.pipe(
285 + Effect.timeoutOrElse({
286 + duration: timeoutMs,
287 + orElse: () => Effect.fail(new PiRpcTimeoutError({ operation: "discovery", timeoutMs })),
288 + }),
289 + );
290 + },
291 );
292
293 const runPiVersionCommand = Effect.fn("PiProviderStatus.runPiVersionCommand")(function* (
@@ -337,7 +344,7 @@ const describeUnavailablePiModel = Effect.fn("PiProviderStatus.describeUnavailab
344 }),
345 ),
346 ),
340 - Effect.timeout(DEFAULT_TIMEOUT_MS),
347 + Effect.timeout(resolveProviderProbeTimeoutMs("pi", DEFAULT_TIMEOUT_MS, environment)),
348 Effect.option,
349 );
350 const missingCredentials = Option.exists(
@@ -411,7 +418,9 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function
418
419 const probeEnvironment = providerProbeEnvironment(environment);
420 const versionResult = yield* runPiVersionCommand(piSettings, probeEnvironment).pipe(
414 - Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS),
421 + Effect.timeoutOption(
422 + resolveProviderProbeTimeoutMs("pi", VERSION_PROBE_TIMEOUT_MS, environment),
423 + ),
424 Effect.result,
425 );
426
@@ -523,7 +532,12 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function
532 probeEnvironment,
533 resolvedLaunchArgs.args,
534 cwd,
526 - ).pipe(Effect.timeoutOption(PI_RPC_DISCOVERY_TIMEOUT_MS), Effect.exit);
535 + ).pipe(
536 + Effect.timeoutOption(
537 + resolveProviderProbeTimeoutMs("pi", PI_RPC_DISCOVERY_TIMEOUT_MS, environment),
538 + ),
539 + Effect.exit,
540 + );
541 if (Exit.isFailure(discoveryExit)) {
542 yield* Effect.logWarning("Pi RPC discovery failed.", {
543 errorTag: causeErrorTag(discoveryExit.cause),