Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/aft-bridge/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class BridgeReplacedDuringVersionCheck extends Error {
export interface BridgeOptions {
/** Request timeout in milliseconds. Default: 30000 */
timeoutMs?: number;
/** Number of consecutive request timeouts before the bridge restarts. Default: 2 */
hangTimeoutThreshold?: number;
/**
* Extra environment variables to set on the spawned `aft` child process,
* applied on top of the inherited `process.env` at spawn time. Use this to
Expand Down Expand Up @@ -338,6 +340,7 @@ export class BinaryBridge {
this.binaryPath = binaryPath;
this.cwd = cwd;
this.timeoutMs = options?.timeoutMs ?? DEFAULT_BRIDGE_TIMEOUT_MS;
this.hangTimeoutThreshold = options?.hangTimeoutThreshold ?? BRIDGE_HANG_TIMEOUT_THRESHOLD;
this.maxRestarts = options?.maxRestarts ?? 3;
this.configOverrides = clampSemanticTimeout(configOverrides ?? {}, this.timeoutMs);
this.minVersion = options?.minVersion;
Expand Down Expand Up @@ -633,7 +636,7 @@ export class BinaryBridge {
const consecutiveTimeouts = this.consecutiveRequestTimeouts + 1;
this.consecutiveRequestTimeouts = consecutiveTimeouts;
const keepWarm =
childActiveSinceRequest || consecutiveTimeouts < BRIDGE_HANG_TIMEOUT_THRESHOLD;
childActiveSinceRequest || consecutiveTimeouts < this.hangTimeoutThreshold;
const restartSuffix = keepWarm ? " — bridge kept warm" : " — restarting bridge";
const timeoutMsg = `Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms${restartSuffix}`;
if (requestSessionId) {
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode-plugin/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ export const AftConfigSchema = z
max_callgraph_files: z.number().int().positive().optional(),
/** Auto-refresh OpenCode's cached @cortexkit/aft-opencode package when a newer channel version exists. */
auto_update: z.boolean().optional(),
/** Bridge startup timeout in milliseconds. Default: 30000. Raise for slow environments (WSL/DrvFs). */
configure_timeout_ms: z.number().int().positive().optional(),
/** Consecutive request timeouts before bridge restart. Default: 2. Raise for slow environments. */
hang_timeout_threshold: z.number().int().positive().optional(),
})
.strict();

Expand Down
2 changes: 2 additions & 0 deletions packages/opencode-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ async function initializePluginForDirectory(input: Parameters<Plugin>[0]) {
);
},
};
poolOptions.timeoutMs = aftConfig.configure_timeout_ms;
poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold;
const pool = new BridgePool(binaryPath, poolOptions, configOverrides);
pool.setConfigureOverride("harness", "opencode");
const ctx: PluginContext = {
Expand Down
Loading