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
18 changes: 17 additions & 1 deletion apps/server/src/provider/Drivers/CodexDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment
import {
enrichProviderSnapshotWithVersionAdvisory,
makePackageManagedProviderMaintenanceResolver,
normalizeCommandPath,
resolveProviderMaintenanceCapabilitiesEffect,
} from "../providerMaintenance.ts";
import {
Expand All @@ -61,11 +62,26 @@ const decodeCodexSettings = Schema.decodeSync(CodexSettings);

const DRIVER_KIND = ProviderDriverKind.make("codex");
const SNAPSHOT_REFRESH_INTERVAL = Duration.minutes(5);

function isCodexStandaloneCommandPath(commandPath: string): boolean {
const normalized = normalizeCommandPath(commandPath);
return (
normalized.includes("/.codex/packages/standalone/") &&
(normalized.endsWith("/bin/codex") || normalized.endsWith("/bin/codex.exe"))
);
}

const UPDATE = makePackageManagedProviderMaintenanceResolver({
provider: DRIVER_KIND,
npmPackageName: "@openai/codex",
homebrewFormula: "codex",
nativeUpdate: null,
nativeUpdate: {
executable: "codex",
args: ["update"],
lockKey: "codex-native",
isCommandPath: isCodexStandaloneCommandPath,
Comment thread
cursor[bot] marked this conversation as resolved.
useResolvedExecutable: true,
},
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("ProviderInstanceRegistryLive — multi-instance codex slice", () => {
displayName: "Codex (work)",
enabled: false,
config: makeCodexConfig({
binaryPath: "/opt/codex-work/bin/codex",
binaryPath: "/home/julius/.codex/packages/standalone/current/bin/codex",
homePath: "/home/julius/.codex",
customModels: ["work-preview"],
}),
Expand Down Expand Up @@ -181,6 +181,15 @@ describe("ProviderInstanceRegistryLive — multi-instance codex slice", () => {
expect(workSnapshot.driver).toBe(codexDriverKind);
expect(workSnapshot.enabled).toBe(false);
expect(workSnapshot.continuation?.groupKey).toBe("codex:home:/home/julius/.codex");
expect(work!.snapshot.maintenanceCapabilities).toMatchObject({
packageName: "@openai/codex",
update: {
command: "codex update",
executable: "/home/julius/.codex/packages/standalone/current/bin/codex",
args: ["update"],
lockKey: "codex-native",
},
});

// Nothing goes to the unavailable bucket — both drivers are registered.
const unavailable = yield* registry.listUnavailable;
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/provider/providerMaintenance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const nativePackageToolUpdate = makePackageManagedProviderMaintenanceResolver({
args: ["update"],
lockKey: "native-package-tool-native",
isCommandPath: isNativeTestCommandPath("/.local/bin/native-package-tool"),
useResolvedExecutable: true,
},
});
const scopedPackageToolUpdate = makePackageManagedProviderMaintenanceResolver({
Expand Down Expand Up @@ -358,7 +359,7 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
update: {
command: "native-package-tool update",

executable: "native-package-tool",
executable: nativePackageToolPath,

args: ["update"],

Expand Down
13 changes: 10 additions & 3 deletions apps/server/src/provider/providerMaintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export interface PackageManagedProviderMaintenanceDefinition {
readonly args: ReadonlyArray<string>;
readonly lockKey: string;
readonly isCommandPath: (commandPath: string) => boolean;
/** Execute the provider path resolved during capability detection. */
readonly useResolvedExecutable?: boolean;
} | null;
}

Expand All @@ -97,6 +99,7 @@ function nonEmptyString(value: unknown): string | null {
export function makeProviderMaintenanceCapabilities(input: {
readonly provider: ProviderDriverKind;
readonly packageName: string | null;
readonly updateCommand?: string;
readonly updateExecutable: string | null;
readonly updateArgs: ReadonlyArray<string>;
readonly updateLockKey: string | null;
Expand All @@ -105,7 +108,7 @@ export function makeProviderMaintenanceCapabilities(input: {
input.updateExecutable === null || input.updateLockKey === null
? null
: {
command: [input.updateExecutable, ...input.updateArgs].join(" "),
command: input.updateCommand ?? [input.updateExecutable, ...input.updateArgs].join(" "),
executable: input.updateExecutable,
args: input.updateArgs,
lockKey: input.updateLockKey,
Expand Down Expand Up @@ -199,6 +202,7 @@ function makeHomebrewProviderMaintenanceCapabilities(

function makeNativeProviderMaintenanceCapabilities(
definition: PackageManagedProviderMaintenanceDefinition,
resolvedCommandPath: string,
): ProviderMaintenanceCapabilities | null {
if (!definition.nativeUpdate) {
return null;
Expand All @@ -207,7 +211,10 @@ function makeNativeProviderMaintenanceCapabilities(
return makeProviderMaintenanceCapabilities({
provider: definition.provider,
packageName: definition.npmPackageName,
updateExecutable: definition.nativeUpdate.executable,
updateCommand: [definition.nativeUpdate.executable, ...definition.nativeUpdate.args].join(" "),
updateExecutable: definition.nativeUpdate.useResolvedExecutable
? resolvedCommandPath
: definition.nativeUpdate.executable,
updateArgs: definition.nativeUpdate.args,
updateLockKey: definition.nativeUpdate.lockKey,
});
Expand Down Expand Up @@ -287,7 +294,7 @@ export function resolvePackageManagedProviderMaintenance(
commandPaths.some((commandPath) => nativeUpdate.isCommandPath(commandPath))
) {
return (
makeNativeProviderMaintenanceCapabilities(definition) ??
makeNativeProviderMaintenanceCapabilities(definition, resolvedCommandPath) ??
makeNpmGlobalProviderMaintenanceCapabilities(definition)
);
}
Expand Down
Loading