Skip to content

Commit 797bcb0

Browse files
authored
fix: Intel Mac installs and broken Codex versions fail with clear next steps (pingdotgg#27281)
1 parent a0d6cc8 commit 797bcb0

7 files changed

Lines changed: 110 additions & 10 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
type ProviderApprovalDecision,
2323
ProviderInstanceId,
2424
ProviderSessionId,
25+
ProviderSetupError,
2526
ProviderThreadId,
2627
ProviderTurnId,
2728
RunAttemptId,
@@ -66,6 +67,8 @@ import * as Orchestrator from "../Orchestrator.ts";
6667
import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts";
6768
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
6869
import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
70+
import * as ModelManifest from "../../provider/ModelManifest.ts";
71+
import { resolveProviderCompatibility } from "../../provider/providerCompatibility.ts";
6972
import * as CodexAdapterV2 from "./CodexAdapterV2.ts";
7073
import { withCodexReplayChildMetadata } from "./CodexAdapterV2.testkit.ts";
7174
import * as CodexAdapterV2Testkit from "./CodexAdapterV2.testkit.ts";
@@ -876,6 +879,7 @@ describe("CodexAdapterV2 session initialize", () => {
876879
const openReplaySession = (
877880
transcript: CodexReplay.CodexAppServerReplayTranscript,
878881
beforeEmitInbound?: CodexReplay.CodexAppServerReplayDriver["beforeEmitInbound"],
882+
compatibility?: CodexAdapterV2.CodexAdapterV2Options["compatibility"],
879883
) =>
880884
Effect.gen(function* () {
881885
const driver = yield* CodexReplay.makeReplayDriver(
@@ -887,6 +891,7 @@ describe("CodexAdapterV2 session initialize", () => {
887891
instanceId: CodexAdapterV2.CODEX_DEFAULT_INSTANCE_ID,
888892
settings: DEFAULT_CODEX_SETTINGS,
889893
environment: {},
894+
...(compatibility === undefined ? {} : { compatibility }),
890895
clientFactory: {
891896
open: (openInput) =>
892897
Layer.build(CodexReplay.layerReplayWithDriver(driver)).pipe(
@@ -1018,6 +1023,54 @@ describe("CodexAdapterV2 session initialize", () => {
10181023
),
10191024
);
10201025

1026+
it.effect("refuses to open a session on a Codex version marked broken", () =>
1027+
Effect.gen(function* () {
1028+
const [initialize] = replayPreamble("broken-version");
1029+
const failure = yield* openReplaySession(
1030+
makeCodexReplayTranscript({
1031+
scenario: "broken-version",
1032+
entries: [
1033+
initialize!,
1034+
{
1035+
type: "emit_inbound",
1036+
label: "initialize",
1037+
frame: {
1038+
id: 1,
1039+
result: {
1040+
userAgent: "T3 Code/0.144.3 (Mac OS 15.5.0; x86_64) unknown (T3 Code; 0.1.5)",
1041+
codexHome: "/tmp/codex-home",
1042+
platformFamily: "unix",
1043+
platformOs: "macos",
1044+
},
1045+
},
1046+
},
1047+
],
1048+
}),
1049+
undefined,
1050+
(version) =>
1051+
Effect.succeed(
1052+
resolveProviderCompatibility(
1053+
ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility,
1054+
CodexAdapterV2.CODEX_DRIVER_KIND,
1055+
version,
1056+
),
1057+
),
1058+
).pipe(Effect.flip);
1059+
1060+
assert.instanceOf(failure, ProviderAdapter.ProviderAdapterOpenSessionError);
1061+
assert.instanceOf(failure.cause, ProviderSetupError);
1062+
assert.equal(
1063+
failure.cause.message,
1064+
"Codex 0.144.3 does not work with this T3 Code release. Update Codex to >=0.159.0, then retry.",
1065+
);
1066+
}).pipe(
1067+
Effect.scoped,
1068+
Effect.provide(
1069+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
1070+
),
1071+
),
1072+
);
1073+
10211074
it.effect("completes the handshake after a caller is interrupted mid-initialize", () =>
10221075
Effect.gen(function* () {
10231076
const initializeAwaitingResponse = yield* Deferred.make<void>();

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ import {
3636
OrchestrationV2ProviderGoal,
3737
parseGoalCommand,
3838
ProviderDriverKind,
39-
type ProviderSetupError,
39+
ProviderSetupError,
40+
type ServerProviderCompatibilityAdvisory,
4041
} from "@t3tools/contracts";
4142
import { SKILL_MENTION_PATTERN } from "@t3tools/shared/composerInlineTokens";
4243
import { AgentScope } from "@t3tools/shared/AgentScope";
@@ -1549,7 +1550,7 @@ export type CodexAdapterV2DriverEnv =
15491550

15501551
export const createCodexAdapterV2 = Effect.fn("CodexAdapterV2.createCodexAdapterV2")(function* (
15511552
{ instanceId, environment, enabled, config }: ProviderAdapterDriverCreateInput<CodexSettings>,
1552-
hooks: Pick<CodexAdapterV2Options, "onUsageLimits" | "resolveRuntime"> = {},
1553+
hooks: Pick<CodexAdapterV2Options, "onUsageLimits" | "resolveRuntime" | "compatibility"> = {},
15531554
) {
15541555
const clientFactory = yield* CodexAppServerClientFactory;
15551556
const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
@@ -1600,6 +1601,9 @@ export interface CodexAdapterV2Options {
16001601
readonly clientFactory: CodexAppServerClientFactoryShape;
16011602
readonly onUsageLimits?: ManagedServerProvider["applyUsageLimits"];
16021603
readonly resolveRuntime?: Effect.Effect<CodexEffectiveRuntime, ProviderSetupError, Scope.Scope>;
1604+
readonly compatibility?: (
1605+
version: string,
1606+
) => Effect.Effect<ServerProviderCompatibilityAdvisory | undefined>;
16031607
readonly crypto: Crypto.Crypto;
16041608
readonly fileSystem: FileSystem.FileSystem;
16051609
readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
@@ -1706,24 +1710,41 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
17061710
return;
17071711
}
17081712

1709-
yield* client
1713+
const userAgent = yield* client
17101714
.request("initialize", {
17111715
clientInfo: buildCodexInitializeParams().clientInfo,
17121716
capabilities: CODEX_CLIENT_CAPABILITIES,
17131717
})
17141718
.pipe(
1719+
Effect.map((response) => response.userAgent),
17151720
Effect.catchTags({
17161721
// Interruption can leave Codex initialized before the local flag is set.
17171722
CodexAppServerRequestError: (error) =>
17181723
error.code === -32600 && error.errorMessage === "Already initialized"
1719-
? Effect.void
1724+
? Effect.succeed(null)
17201725
: Effect.fail(error),
17211726
}),
17221727
);
1728+
const version = userAgent && /\/(\S+)/u.exec(userAgent)?.[1];
1729+
const advisory =
1730+
version && adapterOptions.compatibility
1731+
? yield* adapterOptions.compatibility(version)
1732+
: undefined;
1733+
if (advisory?.status === "broken") {
1734+
const target =
1735+
advisory.recommendedVersion ?? advisory.recommendedRange ?? "a newer version";
1736+
return yield* new ProviderSetupError({
1737+
instanceId: adapterOptions.instanceId,
1738+
operation: "runtime",
1739+
detail: `Codex ${version} does not work with this T3 Code release. Update Codex to ${target}, then retry.`,
1740+
});
1741+
}
17231742
yield* client.notify("initialized", undefined);
17241743
yield* Ref.set(initialized, true);
17251744
}),
17261745
);
1746+
// A failed open is discarded, so the next turn spawns the updated binary.
1747+
if (adapterOptions.compatibility !== undefined) yield* ensureInitialized;
17271748
const now = yield* DateTime.now;
17281749
const session = providerSession({
17291750
providerSessionId: input.providerSessionId,

‎apps/server/src/provider/CodexInstallation.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// @effect-diagnostics nodeBuiltinImport:off - Effect has no incremental digest.
2-
import { ProviderDriverKind, type ProviderInstallState } from "@t3tools/contracts";
2+
import {
3+
ProviderDriverKind,
4+
type ProviderInstallState,
5+
type ServerProviderCompatibilityAdvisory,
6+
} from "@t3tools/contracts";
37
import { cliArchiveTarCommand } from "@t3tools/shared/cliRelease";
48
import * as HostProcess from "@t3tools/shared/HostProcess";
59
import { resolveCommandPath, resolveSpawnCommand } from "@t3tools/shared/shell";
@@ -125,6 +129,9 @@ interface CodexInstallationService {
125129
readonly managedDirectory: string;
126130
readonly resolve: () => Effect.Effect<CodexExecutable, CodexInstallationError>;
127131
readonly acquire: () => Effect.Effect<CodexExecutable, CodexInstallationError, Scope.Scope>;
132+
readonly compatibility: (
133+
version: string,
134+
) => Effect.Effect<ServerProviderCompatibilityAdvisory | undefined>;
128135
readonly start: Effect.Effect<ProviderInstallState, CodexInstallationError>;
129136
readonly cancel: (
130137
operationId: string,
@@ -796,6 +803,7 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
796803
managedDirectory,
797804
resolve,
798805
acquire,
806+
compatibility,
799807
start,
800808
cancel,
801809
state: SubscriptionRef.get(state),

‎apps/server/src/provider/Drivers/CodexDriver.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export const CodexDriver: ProviderDriver<
147147
const pathService = yield* Path.Path;
148148
const httpClient = yield* HttpClient.HttpClient;
149149
const latestVersions = yield* ProviderLatestVersions.ProviderLatestVersions;
150+
const installation = yield* CodexInstallation.CodexInstallation;
150151
const modelCatalog = yield* ModelCatalog.ModelCatalog;
151152
const currentCatalog = modelCatalog.current(DRIVER_KIND);
152153
const processEnv = yield* mergeProviderInstanceEnvironment(environment);
@@ -199,7 +200,10 @@ export const CodexDriver: ProviderDriver<
199200
enabled,
200201
config,
201202
},
202-
{ onUsageLimits: (update) => snapshot.applyUsageLimits(update) },
203+
{
204+
onUsageLimits: (update) => snapshot.applyUsageLimits(update),
205+
compatibility: installation.compatibility,
206+
},
203207
).pipe(
204208
Effect.mapError(
205209
(cause) =>

‎packages/provider-core/src/server/failure.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { assert, it } from "@effect/vitest";
22
import {
33
NodeId,
44
ProviderDriverKind,
5+
ProviderInstanceId,
6+
ProviderSetupError,
57
ProviderThreadId,
68
ProviderTurnId,
79
RunId,
@@ -83,8 +85,16 @@ it("does not expose arbitrary cause messages and preserves explicit messages", (
8385
}
8486
});
8587

86-
it("preserves actionable handoff errors wrapped by turn startup", () => {
87-
for (const error of [new ContextHandoffBudgetError(), new ContextHandoffBackgroundWorkError()]) {
88+
it("preserves actionable T3 errors wrapped by turn startup", () => {
89+
for (const error of [
90+
new ContextHandoffBudgetError(),
91+
new ContextHandoffBackgroundWorkError(),
92+
new ProviderSetupError({
93+
instanceId: ProviderInstanceId.make("codex"),
94+
operation: "runtime",
95+
detail: "Codex 0.144.3 does not work with this T3 Code release.",
96+
}),
97+
]) {
8898
const cause = new ProviderAdapter.ProviderAdapterTurnStartError({
8999
driver: ProviderDriverKind.make("codex"),
90100
threadId: ThreadId.make("thread:handoff-error"),

‎packages/provider-core/src/server/failure.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function curatedCauseMessages(cause: unknown): {
108108
case "ClaudeSettingsLaunchArgError":
109109
case "ClaudeMcpRegistrationTimeoutError":
110110
case "CursorModelUnavailableError":
111+
case "ProviderSetupError":
111112
return { known: stringField(cause, "message"), category: categoryMessage() };
112113
case "ContextHandoffDeliveryUncertainError":
113114
return {

‎scripts/install.sh‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ case "$(uname -m)" in
133133
x86_64 | amd64) arch="x64" ;;
134134
*) fail "unsupported architecture $(uname -m)" ;;
135135
esac
136+
if [ "${platform}-${arch}" = darwin-x64 ]; then
137+
fail "there is no t3 CLI for Intel Macs. Install the desktop app from https://t3.codes/download, or run a server from source: https://github.com/${repo}/blob/main/docs/user/install.md#intel-macs"
138+
fi
136139
command -v tar >/dev/null 2>&1 || fail "tar is required"
137140
if command -v sha256sum >/dev/null 2>&1; then
138141
checksum() { sha256sum "$1" | cut -d' ' -f1; }
@@ -206,11 +209,11 @@ else
206209
elif [ "$fetch_status" -ne 0 ]; then
207210
fail "could not download the release checksums"
208211
fi
212+
expected="$(grep " \*\{0,1\}${archive}\$" "${staging}/SHA256SUMS" | cut -d' ' -f1)"
213+
[ -n "$expected" ] || fail "t3 ${version} has no release archive for ${platform}-${arch}"
209214
download "${base_url}/v${version}/${archive}" "${staging}/${archive}"
210215

211216
step "Verifying the download..."
212-
expected="$(grep " \*\{0,1\}${archive}\$" "${staging}/SHA256SUMS" | cut -d' ' -f1)"
213-
[ -n "$expected" ] || fail "${archive} is not listed in SHA256SUMS"
214217
actual="$(checksum "${staging}/${archive}")"
215218
[ "$actual" = "$expected" ] || fail "checksum mismatch for ${archive}"
216219

0 commit comments

Comments
 (0)