fix(server): return null for unresolved optional commands (#18871)
This commit is contained in:
1 parent
8110edfddd
commit
e2e95a39d3
9 files changed
+140
-52
No files matched your search
@@ -106,7 +106,6 @@ export const make = Effect.gen(function* () {
|
||||
Effect.provideService(FileSystem.FileSystem, fileSystem),
|
||||
Effect.provideService(Path.Path, path),
|
||||
Effect.provideService(HostProcess.Platform, platform),
|
||||
Effect.option,
|
||||
);
|
||||
|
||||
const run = (command: string, args: ReadonlyArray<string>) =>
|
||||
@@ -120,9 +119,9 @@ export const make = Effect.gen(function* () {
|
||||
if (runtimeDir === undefined || runtimeDir.length === 0) return undefined;
|
||||
const systemdRun = yield* resolve("systemd-run", hostEnvironment);
|
||||
const systemctl = yield* resolve("systemctl", hostEnvironment);
|
||||
if (systemdRun._tag === "None" || systemctl._tag === "None") return undefined;
|
||||
if (systemdRun === null || systemctl === null) return undefined;
|
||||
const probe = (options: ReadonlyArray<string>) =>
|
||||
run(systemdRun.value, [
|
||||
run(systemdRun, [
|
||||
"--user",
|
||||
"--scope",
|
||||
"--quiet",
|
||||
@@ -146,7 +145,7 @@ export const make = Effect.gen(function* () {
|
||||
return undefined;
|
||||
}
|
||||
const limits = agentSliceMemoryLimits(NodeOS.totalmem());
|
||||
const limited = yield* run(systemctl.value, [
|
||||
const limited = yield* run(systemctl, [
|
||||
"--user",
|
||||
"set-property",
|
||||
"--runtime",
|
||||
@@ -165,8 +164,8 @@ export const make = Effect.gen(function* () {
|
||||
oomPolicy: scopeOptions.length > 0,
|
||||
});
|
||||
return {
|
||||
systemdRun: systemdRun.value,
|
||||
systemctl: systemctl.value,
|
||||
systemdRun,
|
||||
systemctl,
|
||||
runtimeDir,
|
||||
scopeOptions,
|
||||
};
|
||||
@@ -294,9 +293,9 @@ export const make = Effect.gen(function* () {
|
||||
wrap: Effect.fn("AgentScope.wrap")(function* ({ command, args, name, threadId, env }) {
|
||||
const resolved = yield* resolve(command, env ?? hostEnvironment);
|
||||
// Leave unresolved commands alone so the spawn reports the missing binary.
|
||||
if (resolved._tag === "None") return { command, args };
|
||||
if (resolved === null) return { command, args };
|
||||
const scope = yield* systemd;
|
||||
if (scope === undefined) return agentScopeCommand({ command: resolved.value, args });
|
||||
if (scope === undefined) return agentScopeCommand({ command: resolved, args });
|
||||
const unit = `t3code-${name}-${NodeCrypto.randomUUID().slice(0, 8)}.scope`;
|
||||
if (threadId !== undefined) yield* track(scope.systemctl, threadId, unit);
|
||||
const systemdScope: AgentSystemdScope = {
|
||||
@@ -308,7 +307,7 @@ export const make = Effect.gen(function* () {
|
||||
// the unit even when it fails.
|
||||
options: threadId === undefined ? [...scope.scopeOptions, "--collect"] : scope.scopeOptions,
|
||||
};
|
||||
return agentScopeCommand({ command: resolved.value, args, scope: systemdScope });
|
||||
return agentScopeCommand({ command: resolved, args, scope: systemdScope });
|
||||
}),
|
||||
oomKilled,
|
||||
clear,
|
||||
|
||||
@@ -335,6 +335,7 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
|
||||
Effect.provideService(FileSystem.FileSystem, fs),
|
||||
Effect.provideService(Path.Path, path),
|
||||
);
|
||||
if (executablePath === null) return null;
|
||||
// Keep launcher symlinks intact: version-manager shims dispatch by their invoked name.
|
||||
const realExecutablePath = yield* fs.realPath(executablePath);
|
||||
// A PATH entry pointing into T3's download remains a managed installation.
|
||||
|
||||
@@ -592,7 +592,6 @@ it.layer(NodeServices.layer)("Antigravity profile preparation", (it) => {
|
||||
detail: expect.stringContaining("Install Node.js"),
|
||||
cause: {
|
||||
_tag: "NodeRuntimeUnavailableError",
|
||||
cause: { _tag: "CommandResolutionError" },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -238,4 +238,25 @@ describe("provider installation routing", () => {
|
||||
assert.deepEqual(harness.calls, ["remove", "refresh"]);
|
||||
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
it.effect("keeps only the configured path when another instance's binary is missing", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-provider-install-route-" });
|
||||
const binaryPath = path.join(directory, "missing");
|
||||
const harness = yield* makeHarness({
|
||||
settings: {
|
||||
providerInstances: {
|
||||
[ProviderInstanceId.make("antigravity-work")]: {
|
||||
driver,
|
||||
config: { binaryPath },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
yield* harness.router.remove({ instanceId });
|
||||
assert.deepEqual(harness.protectedPaths(), [binaryPath]);
|
||||
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
});
|
||||
@@ -141,12 +141,10 @@ export const makeProviderInstallation = Effect.fn("makeProviderInstallation")(fu
|
||||
return [];
|
||||
}
|
||||
const binaryPath = entry.config.binaryPath.trim();
|
||||
return yield* resolveCommandPath(binaryPath, {
|
||||
const resolved = yield* resolveCommandPath(binaryPath, {
|
||||
env: yield* mergeProviderInstanceEnvironment(entry.environment),
|
||||
}).pipe(
|
||||
Effect.map((resolved) => [binaryPath, resolved]),
|
||||
Effect.orElseSucceed(() => [binaryPath]),
|
||||
);
|
||||
});
|
||||
return resolved === null ? [binaryPath] : [binaryPath, resolved];
|
||||
}),
|
||||
);
|
||||
yield* installation
|
||||
|
||||
Reference in new issue
Block a user