Skip to content
Merged
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
20 changes: 20 additions & 0 deletions apps/server/src/provider/providerMaintenance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,26 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
});
});

it("recognizes absolute Windows npm shims as one-click updatable installs", () => {
const commandPath = "C:\\Users\\example\\AppData\\Roaming\\npm\\package-tool.cmd";
expect(
packageToolUpdate.resolve({
binaryPath: commandPath,
resolvedCommandPath: commandPath,
realCommandPath: commandPath,
}),
).toEqual({
provider: driver("packageTool"),
packageName: "@example/package-tool",
update: {
command: "npm install -g @example/package-tool@latest",
executable: "npm",
args: ["install", "-g", "@example/package-tool@latest"],
lockKey: "npm-global",
},
});
});

it.effect(
"switches native-package-tool to native updates when the binary resolves through the native installer",
() =>
Expand Down
5 changes: 4 additions & 1 deletion apps/server/src/provider/providerMaintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ function isNpmGlobalCommandPath(commandPath: string): boolean {
return (
normalized.includes("/node_modules/.bin/") ||
normalized.includes("/lib/node_modules/") ||
normalized.includes("/npm/node_modules/")
normalized.includes("/npm/node_modules/") ||
normalized.includes("/appdata/roaming/npm/") ||
normalized.includes("/.npm-global/") ||
normalized.includes("/npm-global/")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@
}),
);

it.effect("resolves the native executable behind an official Windows npm launcher", () =>
it.effect("resolves current and legacy native executables behind a Windows npm launcher", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
Expand All @@ -509,22 +509,32 @@
"@openai",
"codex-win32-x64",
);
const nativePath = path.join(
platformPackageRoot,
"vendor",
"x86_64-pc-windows-msvc",
"codex",
"codex.exe",
);
const platformVendorRoot = path.join(platformPackageRoot, "vendor", "x86_64-pc-windows-msvc");
const currentNativePath = path.join(platformVendorRoot, "bin", "codex.exe");
const legacyNativePath = path.join(platformVendorRoot, "codex", "codex.exe");
yield* writeFile(commandPath, "@echo off\r\n");
yield* writeFile(path.join(packageRoot, "bin", "codex.js"), "// launcher\n");
yield* writeFile(
path.join(platformPackageRoot, "package.json"),
'{"name":"@openai/codex-win32-x64","version":"0.0.0"}\n',
);
yield* fileSystem.makeDirectory(path.dirname(nativePath), { recursive: true });
yield* fileSystem.writeFile(nativePath, Uint8Array.from([0x4d, 0x5a, 0x00, 0x00]));
yield* fileSystem.makeDirectory(path.dirname(currentNativePath), { recursive: true });
yield* fileSystem.makeDirectory(path.dirname(legacyNativePath), { recursive: true });
yield* fileSystem.writeFile(currentNativePath, Uint8Array.from([0x4d, 0x5a, 0x00, 0x00]));
yield* fileSystem.writeFile(legacyNativePath, Uint8Array.from([0x4d, 0x5a, 0x00, 0x00]));

NodeAssert.equal(
yield* resolveCommandCenterCodexRuntimeExecutable({
commandPath,
platform: "win32",
architecture: "x64",
fileSystem,
path,
}),
yield* fileSystem.realPath(currentNativePath),
);

yield* fileSystem.remove(currentNativePath);
NodeAssert.equal(
yield* resolveCommandCenterCodexRuntimeExecutable({
commandPath,
Expand All @@ -533,7 +543,7 @@
fileSystem,
path,
}),
yield* fileSystem.realPath(nativePath),
yield* fileSystem.realPath(legacyNativePath),
);
}),
);
Expand Down Expand Up @@ -664,7 +674,7 @@
fileSystem,
path,
}).pipe(Effect.flip);
NodeAssert.match(error.issue, fixture.expected);

Check failure on line 677 in apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts

View workflow job for this annotation

GitHub Actions / Command Center Native Isolation (macOS)

apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts > CommandCenter provider runtime isolation > denies executable or included config for provider-writable sessions

AssertionError: The input did not match the regular expression /filter\.\*\.process/u. Input: 'The managed Command Center worktree Git directory contains a symlink escape.' - Expected: /filter\.\*\.process/u + Received: "The managed Command Center worktree Git directory contains a symlink escape." ❯ Array.<anonymous> apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts:677:20 ❯ next node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:1350:25 ❯ Object.~effect/Effect/evaluate node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/core.ts:514:30 ❯ FiberImpl.runLoop node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:655:39 ❯ runLoop node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:607:22 ❯ evaluate node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:1106:14 ❯ resume node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/Effect.ts:25168:12
}
}),
);
Expand Down Expand Up @@ -702,7 +712,7 @@
fileSystem,
path,
}).pipe(Effect.flip);
NodeAssert.match(error.issue, /single-link regular file/u);

Check failure on line 715 in apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts

View workflow job for this annotation

GitHub Actions / Command Center Native Isolation (macOS)

apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts > CommandCenter provider runtime isolation > denies hardlink aliases for every linked-worktree control pointer

AssertionError: The input did not match the regular expression /single-link regular file/u. Input: 'The managed Command Center worktree Git directory contains a symlink escape.' - Expected: /single-link regular file/u + Received: "The managed Command Center worktree Git directory contains a symlink escape." ❯ Array.<anonymous> apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts:715:20 ❯ next node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:1350:25 ❯ Object.~effect/Effect/evaluate node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/core.ts:514:30 ❯ FiberImpl.runLoop node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:655:39 ❯ runLoop node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:607:22 ❯ evaluate node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:1106:14 ❯ resume node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/Effect.ts:25168:12
}
}),
);
Expand Down
34 changes: 18 additions & 16 deletions apps/server/src/provider/security/CommandCenterProviderIsolation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
issue: string,
cause?: unknown,
): CommandCenterManagedWorktreeIsolationError {
return new CommandCenterManagedWorktreeIsolationError({

Check failure on line 377 in apps/server/src/provider/security/CommandCenterProviderIsolation.ts

View workflow job for this annotation

GitHub Actions / Command Center Native Isolation (macOS)

apps/server/src/provider/security/CommandCenterProviderIsolation.test.ts > CommandCenter provider runtime isolation > grants read-only access to the exact pointer and common metadata for a valid worktree

CommandCenterManagedWorktreeIsolationError: The managed Command Center worktree Git directory contains a symlink escape. ❯ managedWorktreeError apps/server/src/provider/security/CommandCenterProviderIsolation.ts:377:10 ❯ apps/server/src/provider/security/CommandCenterProviderIsolation.ts:1050:19 ❯ next node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:1350:25 ❯ Object.~effect/Effect/evaluate node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/core.ts:514:30 ❯ FiberImpl.runLoop node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:655:39 ❯ runLoop node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:607:22 ❯ evaluate node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/internal/effect.ts:1106:14 ❯ resume node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/src/Effect.ts:25168:12 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _tag: 'CommandCenterManagedWorktreeIsolationError', issue: 'The managed Command Center worktree Git directory contains a symlink escape.' }
issue,
...(cause === undefined ? {} : { cause }),
});
Expand Down Expand Up @@ -440,23 +440,25 @@
cause,
),
});
const nativeExecutablePath = path.join(
path.dirname(packageJsonPath),
"vendor",
target.triple,
"codex",
"codex.exe",
const platformVendorRoot = path.join(path.dirname(packageJsonPath), "vendor", target.triple);
const nativeExecutableCandidates = [
path.join(platformVendorRoot, "bin", "codex.exe"),
path.join(platformVendorRoot, "codex", "codex.exe"),
];
for (const candidate of nativeExecutableCandidates) {
if (yield* fileSystem.exists(candidate)) {
return yield* fileSystem
.realPath(candidate)
.pipe(
Effect.mapError((cause) =>
codexHomeError("Command Center could not canonicalize the native codex.exe.", cause),
),
);
}
}
return yield* codexHomeError(
"Command Center found the Windows Codex package but not its native codex.exe. Reinstall @openai/codex with optional dependencies enabled.",
);
return yield* fileSystem
.realPath(nativeExecutablePath)
.pipe(
Effect.mapError((cause) =>
codexHomeError(
"Command Center could not locate the native codex.exe and its Windows sandbox resources. Reinstall or update @openai/codex.",
cause,
),
),
);
});

function isNotSymlink(error: PlatformError.PlatformError): boolean {
Expand Down
Loading