Skip to content

Commit 5d33f3e

Browse files
fix(providers): expand ~/ binary paths for OpenCode, Grok and Pi
A Binary path such as ~/.local/bin/opencode reached spawn unexpanded for the OpenCode, Grok and Pi drivers, so the status probe failed with ENOENT and Settings showed "Not found". These drivers now expand the path against the home directory like Codex, Claude and Muse, and hand the expanded config to their orchestration adapters so sessions launch the same binary. The Grok reproduction test now checks every argv element, since agent launches can be wrapped in /bin/sh and the maintenance lookup may spawn npm. Fixes #29302 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent cc95ff7 commit 5d33f3e

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

‎packages/provider-grok/src/server/driver.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ it.layer(layerTest)("GrokDriver", (it) => {
173173
}
174174

175175
it.effect("probes a ~/ binary path from the home directory", () => {
176-
const spawned: Array<string> = [];
176+
const argv: Array<string> = [];
177177
return Effect.gen(function* () {
178178
const path = yield* Path.Path;
179179
const instance = yield* GrokDriver.create({
@@ -184,13 +184,14 @@ it.layer(layerTest)("GrokDriver", (it) => {
184184
config: { ...GrokDriver.defaultConfig(), binaryPath: "~/bin/grok" },
185185
}).pipe(Effect.provideService(HostProcess.HomeDirectory, "/test-home"));
186186
yield* instance.snapshot.refresh;
187-
expect(spawned).not.toHaveLength(0);
188-
expect(new Set(spawned)).toEqual(new Set([path.join("/test-home", "bin", "grok")]));
187+
// Agent launches may be wrapped in /bin/sh, so look at every argv element.
188+
expect(argv).toContain(path.join("/test-home", "bin", "grok"));
189+
expect(argv).not.toContain("~/bin/grok");
189190
}).pipe(
190191
Effect.provideService(
191192
ChildProcessSpawner.ChildProcessSpawner,
192-
stdoutSpawner((command) => {
193-
spawned.push(command);
193+
stdoutSpawner((command, args) => {
194+
argv.push(command, ...args);
194195
return "grok 1.0.0\n";
195196
}),
196197
),

‎packages/provider-grok/src/server/driver.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import {
2929
} from "@t3tools/provider-core/server/driver";
3030
import { withInstanceIdentity } from "@t3tools/provider-core/server/instanceIdentity";
3131
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
32+
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
33+
import * as HostProcess from "@t3tools/shared/HostProcess";
3234
import { discoverGrokSkills } from "./skills.ts";
3335
import {
3436
homebrewOwnershipFromCommandPath,
@@ -137,7 +139,11 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv, Path.Path>
137139
accentColor,
138140
continuationGroupKey: continuationIdentity.continuationKey,
139141
});
140-
const effectiveConfig = { ...config, enabled } satisfies GrokSettings;
142+
const effectiveConfig = {
143+
...config,
144+
enabled,
145+
binaryPath: expandHomePath(config.binaryPath, yield* HostProcess.HomeDirectory),
146+
} satisfies GrokSettings;
141147
const resolveMaintenance = yield* makeCachedProviderMaintenanceResolution(
142148
resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {
143149
binaryPath: effectiveConfig.binaryPath,
@@ -154,7 +160,7 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv, Path.Path>
154160
accentColor,
155161
environment,
156162
enabled,
157-
config,
163+
config: effectiveConfig,
158164
}).pipe(
159165
Effect.mapError(
160166
(cause) =>

‎packages/provider-opencode/src/server/driver.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import {
5050
} from "@t3tools/provider-core/server/driver";
5151
import { withInstanceIdentity } from "@t3tools/provider-core/server/instanceIdentity";
5252
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
53+
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
54+
import * as HostProcess from "@t3tools/shared/HostProcess";
5355
import {
5456
enrichProviderSnapshotWithVersionAdvisory,
5557
makeCachedProviderMaintenanceResolution,
@@ -207,7 +209,11 @@ export const OpenCodeDriver: ProviderDriver<
207209
accentColor,
208210
continuationGroupKey: continuationIdentity.continuationKey,
209211
});
210-
const effectiveConfig = { ...config, enabled } satisfies OpenCodeSettings;
212+
const effectiveConfig = {
213+
...config,
214+
enabled,
215+
binaryPath: expandHomePath(config.binaryPath, yield* HostProcess.HomeDirectory),
216+
} satisfies OpenCodeSettings;
211217
const runtimeProbe = yield* makeOpenCodeRuntimeProbe(
212218
probeOpenCodeRuntime(effectiveConfig, processEnv).pipe(
213219
Effect.provideService(HttpClient.HttpClient, httpClient),
@@ -252,7 +258,7 @@ export const OpenCodeDriver: ProviderDriver<
252258
accentColor,
253259
environment,
254260
enabled,
255-
config,
261+
config: effectiveConfig,
256262
}).pipe(
257263
Effect.mapError(
258264
(cause) =>

‎packages/provider-pi/src/server/driver.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
} from "@t3tools/provider-core/server/driver";
2929
import type { ServerProviderDraft } from "@t3tools/provider-core/server/snapshotProbe";
3030
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
31+
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
32+
import * as HostProcess from "@t3tools/shared/HostProcess";
3133
import {
3234
makeCachedProviderMaintenanceResolution,
3335
makePackageManagedProviderMaintenanceResolver,
@@ -108,7 +110,11 @@ export const PiDriver: ProviderDriver<PiSettings, PiDriverEnv, Path.Path> = {
108110
accentColor,
109111
continuationGroupKey: continuationIdentity.continuationKey,
110112
});
111-
const effectiveConfig = { ...config, enabled } satisfies PiSettings;
113+
const effectiveConfig = {
114+
...config,
115+
enabled,
116+
binaryPath: expandHomePath(config.binaryPath, yield* HostProcess.HomeDirectory),
117+
} satisfies PiSettings;
112118
const resolveMaintenance = yield* makeCachedProviderMaintenanceResolution(
113119
resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {
114120
binaryPath: effectiveConfig.binaryPath,
@@ -126,7 +132,7 @@ export const PiDriver: ProviderDriver<PiSettings, PiDriverEnv, Path.Path> = {
126132
accentColor,
127133
environment,
128134
enabled,
129-
config,
135+
config: effectiveConfig,
130136
}).pipe(
131137
Effect.mapError(
132138
(cause) =>

0 commit comments

Comments
 (0)