The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
fix(server): OpenCode and Pi read their minimum version from the manifest (#39434)
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Julius Marminge committed
Nov 19, 2026 at 16:58 UTC
f75eb015a3194c8874170baf0d36b6a0ca84a521
25 files changed
+292
-99
apps/server/src/provider/ProviderHostLive.ts
+10
@@ -14,6 +14,7 @@ import * as PortScanner from "../preview/PortScanner.ts";
14
import * as ServerLifecycleEvents from "../serverLifecycleEvents.ts";
15
import * as ServerSettings from "../serverSettings.ts";
16
import * as DocumentText from "./DocumentText.ts";
17
+import * as ModelManifest from "./ModelManifest.ts";
18
import * as ProviderCredentialStore from "./ProviderCredentialStore.ts";
19
20
export const layer = Layer.effect(
@@ -31,7 +32,16 @@ export const layer = Layer.effect(
32
);
33
// Optional so hosts built without the preview layer still construct.
34
const portDiscovery = yield* Effect.serviceOption(PortScanner.PortDiscovery);
35
+ // Optional like the services above; without it the bundled policy still applies.
36
+ const manifest = yield* Effect.serviceOption(ModelManifest.ModelManifest);
37
+ const currentManifest = Option.match(manifest, {
38
+ onNone: () => Effect.succeed(ModelManifest.BUNDLED_MODEL_MANIFEST),
39
+ onSome: (service) => service.current,
40
+ });
41
return ProviderHost.ProviderHost.of({
42
+ compatibility: Effect.fn("ProviderHost.compatibility")(function* (driver, version) {
43
+ return ModelManifest.providerCompatibility(yield* currentManifest, driver, version);
44
+ }),
45
paths: {
46
cwd: config.cwd,
47
baseDir: config.baseDir,
apps/server/src/provider/model-manifest.json
+3
-2
@@ -1,6 +1,6 @@
1
{
2
"version": 1,
3
- "updatedAt": "2026-11-19T23:30:00Z",
3
+ "updatedAt": "2026-11-20T00:34:00Z",
4
"compatibility": [
5
{
6
"driver": "codex",
@@ -65,6 +65,7 @@
65
{
66
"driver": "opencode",
67
"t3CodeRange": ">=0.0.46",
68
+ "versionPattern": "^(\\d+\\.\\d+\\.\\d+)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
69
"recommendedRange": ">=2.0.18",
70
"ranges": [
71
{ "range": ">=2.0.18", "status": "supported" },
@@ -107,7 +108,7 @@
108
"recommendedRange": ">=1.0.0",
109
"ranges": [
110
{ "range": ">=0.84.3", "status": "supported" },
110
- { "range": "<0.84.3", "status": "unsupported" }
111
+ { "range": "<0.84.3", "status": "broken" }
112
]
113
},
114
{
apps/server/src/provider/providerCompatibility.test.ts
+16
@@ -73,6 +73,22 @@ describe("provider compatibility", () => {
73
assert.strictEqual(advisory?.status, expected, `OpenCode ${version} on 0.0.45`);
74
assert.strictEqual(advisory?.recommendedVersion, "1.14.19");
75
}
76
+ // The current policy rates a prerelease or build by its base version.
77
+ for (const [version, expected] of [
78
+ ["1.13.0-beta.1", "broken"],
79
+ ["1.13.0+abc123", "broken"],
80
+ ["2.1.0-rc.1", "supported"],
81
+ ] as const) {
82
+ assert.strictEqual(
83
+ resolveProviderCompatibility(
84
+ ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility,
85
+ opencode,
86
+ version,
87
+ )?.status,
88
+ expected,
89
+ `OpenCode ${version}`,
90
+ );
91
+ }
92
assert.isUndefined(
93
resolveProviderCompatibility(
94
ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility,
apps/server/src/provider/providerCompatibility.ts
+5
-8
@@ -7,6 +7,7 @@ import {
7
type ServerProvider,
8
type ServerProviderCompatibilityAdvisory,
9
} from "@t3tools/contracts";
10
+import { brokenVersionDetail } from "@t3tools/provider-core/server/compatibility";
11
import { satisfiesSemverRange } from "@t3tools/shared/semver";
12
import * as Schema from "effect/Schema";
13
import packageJson from "../../package.json" with { type: "json" };
@@ -115,14 +116,10 @@ export function brokenRuntimeError(input: {
116
readonly advisory: ServerProviderCompatibilityAdvisory | undefined;
117
readonly action?: string;
118
}): ProviderSetupError | undefined {
118
- if (input.advisory?.status !== "broken") return undefined;
119
- const target =
120
- input.advisory.recommendedVersion ?? input.advisory.recommendedRange ?? "a newer version";
121
- return new ProviderSetupError({
122
- instanceId: input.instanceId,
123
- operation: "runtime",
124
- detail: `${input.name} ${input.version} does not work with this T3 Code release. ${input.action ?? `Update ${input.name}`} to ${target}, then retry.`,
125
- });
119
+ const detail = brokenVersionDetail(input);
120
+ return detail === undefined
121
+ ? undefined
122
+ : new ProviderSetupError({ instanceId: input.instanceId, operation: "runtime", detail });
123
}
124
125
export function applyProviderCompatibility(
docs/internals/adding-a-provider.md
+1
-1
@@ -114,7 +114,7 @@ A provider lives in its own `packages/provider-<name>` package, with
114
the server's replay testkits drive; testkits that need the orchestrator stay in the server.
115
Settings live in `providerInstances`; new providers are off by default.
116
- **Package boundaries.** Server code imports only `@t3tools/provider-core/server/*`, contracts,
117
- and shared. It reaches the server through `ProviderHost` (paths, settings, background demand,
117
+ and shared. It reaches the server through `ProviderHost` (paths, settings, background demand, version policy,
118
attachments, stored credentials), never through `apps/server`. Tests use `@t3tools/provider-testing`.
119
- **Server registration:** the driver's entry in
120
[`builtInDrivers.ts`](../../apps/server/src/provider/builtInDrivers.ts). The driver carries its
packages/provider-core/package.json
+4
@@ -19,6 +19,10 @@
19
"types": "./src/server/attachmentPrompt.ts",
20
"import": "./src/server/attachmentPrompt.ts"
21
},
22
+ "./server/compatibility": {
23
+ "types": "./src/server/compatibility.ts",
24
+ "import": "./src/server/compatibility.ts"
25
+ },
26
"./server/auth": {
27
"types": "./src/server/auth.ts",
28
"import": "./src/server/auth.ts"
packages/provider-core/src/server/ProviderHost.ts
+3
@@ -10,6 +10,7 @@ import type * as Option from "effect/Option";
10
import type * as Scope from "effect/Scope";
11
import type * as Stream from "effect/Stream";
12
13
+import type { ProviderCompatibilityLookup } from "./compatibility.ts";
14
import type { ProviderCredentialError } from "./errors.ts";
15
16
export interface ProviderHostPaths {
@@ -58,5 +59,7 @@ export class ProviderHost extends Context.Service<
59
namespace: string,
60
bindingId: string,
61
) => Effect.Effect<ProviderCredentials>;
62
+ /** A driver declares its minimum version in the policy and asks here, not in a constant. */
63
+ readonly compatibility: ProviderCompatibilityLookup;
64
}
65
>()("@t3tools/provider-core/server/ProviderHost") {}
packages/provider-core/src/server/compatibility.ts
new
+23
@@ -0,0 +1,23 @@
1
+import type { ProviderDriverKind, ServerProviderCompatibilityAdvisory } from "@t3tools/contracts";
2
+import * as Effect from "effect/Effect";
3
+
4
+/** Rates a detected provider version against the host's compatibility policy. */
5
+export type ProviderCompatibilityLookup = (
6
+ driver: ProviderDriverKind,
7
+ version: string,
8
+) => Effect.Effect<ServerProviderCompatibilityAdvisory | undefined>;
9
+
10
+export const noCompatibilityPolicy: ProviderCompatibilityLookup = () => Effect.undefined;
11
+
12
+/** The one message for a version the policy rates `broken`; `action` names how it is updated. */
13
+export function brokenVersionDetail(input: {
14
+ readonly name: string;
15
+ readonly version: string;
16
+ readonly advisory: ServerProviderCompatibilityAdvisory | undefined;
17
+ readonly action?: string;
18
+}): string | undefined {
19
+ if (input.advisory?.status !== "broken") return undefined;
20
+ const target =
21
+ input.advisory.recommendedVersion ?? input.advisory.recommendedRange ?? "a newer version";
22
+ return `${input.name} ${input.version} does not work with this T3 Code release. ${input.action ?? `Update ${input.name}`} to ${target}, then retry.`;
23
+}
packages/provider-core/src/server/managedProvider.test.ts
+1
@@ -105,6 +105,7 @@ function layerProviderHost(input: {
105
return Layer.succeed(
106
ProviderHost.ProviderHost,
107
ProviderHost.ProviderHost.of({
108
+ compatibility: () => Effect.undefined,
109
paths: {
110
cwd: process.cwd(),
111
baseDir: "/t3",
packages/provider-opencode/src/server/OpenCodeRuntime.environment.test.ts
-25
@@ -1,6 +1,3 @@
1
-import type { OpencodeClient } from "@opencode-ai/sdk/v2";
2
-import { it as effectIt } from "@effect/vitest";
3
-import * as Effect from "effect/Effect";
1
import { describe, expect, it } from "vite-plus/test";
2
3
import * as OpenCodeRuntime from "./OpenCodeRuntime.ts";
@@ -28,25 +25,3 @@ describe("resolveOpenCodeServerPassword", () => {
25
).toBeUndefined();
26
});
27
});
31
-
32
-function makeHealthClient(
33
- result: (options?: { readonly signal?: AbortSignal }) => Promise<unknown>,
34
-): OpencodeClient {
35
- return {
36
- global: {
37
- health: result,
38
- },
39
- } as unknown as OpencodeClient;
40
-}
41
-
42
-describe("verifyOpenCodeServerVersion", () => {
43
- effectIt.effect("rejects a server below the supported version", () =>
44
- Effect.gen(function* () {
45
- const error = yield* OpenCodeRuntime.verifyOpenCodeServerVersion(
46
- makeHealthClient(() => Promise.resolve({ data: { healthy: true, version: "1.14.18" } })),
47
- ).pipe(Effect.flip);
48
- expect(error).toBeInstanceOf(OpenCodeRuntime.OpenCodeRuntimeError);
49
- expect(error.detail).toContain("v1.14.18 is too old");
50
- }),
51
- );
52
-});
packages/provider-opencode/src/server/OpenCodeRuntime.ts
+4
-11
@@ -37,12 +37,11 @@ import { collectStreamAsString } from "@t3tools/provider-core/server/snapshotPro
37
import * as NetService from "@t3tools/shared/Net";
38
import { AgentScope } from "@t3tools/shared/AgentScope";
39
import * as HostProcess from "@t3tools/shared/HostProcess";
40
-import { compareSemverVersions, parseSemver } from "@t3tools/shared/semver";
40
+import { parseSemver } from "@t3tools/shared/semver";
41
import { resolveSpawnCommand } from "@t3tools/shared/shell";
42
const encodeUnknownJsonStringExit = Schema.encodeUnknownExit(Schema.fromJsonString(Schema.Unknown));
43
const OPENCODE_EMPTY_CONFIG_CONTENT = "{}";
44
45
-export const MINIMUM_OPENCODE_VERSION = "1.14.19";
45
const OPENCODE_HEALTH_TIMEOUT_MS = 5_000;
46
47
const OpenCodeHealthSchema = Schema.Struct({
@@ -162,7 +161,7 @@ export const runOpenCodeSdk = <A>(
161
new OpenCodeRuntimeError({ operation, detail: openCodeRuntimeErrorDetail(cause), cause }),
162
}).pipe(Effect.withSpan(`opencode.${operation}`));
163
165
-export const verifyOpenCodeServerVersion = Effect.fn("verifyOpenCodeServerVersion")(function* (
164
+const verifyOpenCodeServerVersion = Effect.fn("verifyOpenCodeServerVersion")(function* (
165
client: OpencodeClient,
166
environment?: NodeJS.ProcessEnv,
167
) {
@@ -185,7 +184,7 @@ export const verifyOpenCodeServerVersion = Effect.fn("verifyOpenCodeServerVersio
184
(cause) =>
185
new OpenCodeRuntimeError({
186
operation: "global.health",
188
- detail: `OpenCode server returned an invalid health response. T3 Code requires OpenCode v${MINIMUM_OPENCODE_VERSION} or newer.`,
187
+ detail: "OpenCode server returned an invalid health response.",
188
cause,
189
}),
190
),
@@ -193,13 +192,7 @@ export const verifyOpenCodeServerVersion = Effect.fn("verifyOpenCodeServerVersio
192
if (parseSemver(health.version) === null) {
193
return yield* new OpenCodeRuntimeError({
194
operation: "global.health",
196
- detail: `OpenCode server returned an invalid version. T3 Code requires OpenCode v${MINIMUM_OPENCODE_VERSION} or newer.`,
197
- });
198
- }
199
- if (compareSemverVersions(health.version, MINIMUM_OPENCODE_VERSION) < 0) {
200
- return yield* new OpenCodeRuntimeError({
201
- operation: "global.health",
202
- detail: `OpenCode v${health.version} is too old. Upgrade to v${MINIMUM_OPENCODE_VERSION} or newer.`,
195
+ detail: "OpenCode server returned an invalid version.",
196
});
197
}
198
return health.version;
packages/provider-opencode/src/server/adapter.test.ts
+32
@@ -184,6 +184,7 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct
184
connectToOpenCodeServer: () =>
185
Effect.succeed({
186
url: "http://test.invalid",
187
+ version: "1.14.19",
188
external: turnSettings.exitCode === undefined,
189
exitCode: turnSettings.exitCode ?? null,
190
}),
@@ -192,6 +193,7 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct
193
Effect.provideService(ProviderHost.ProviderHost, {
194
paths: { cwd: "/workspace" },
195
resolveAttachmentPath: () => null,
196
+ compatibility: () => Effect.undefined,
197
...host,
198
} as unknown as ProviderHost.ProviderHost["Service"]),
199
);
@@ -3846,6 +3848,7 @@ describe("OpenCodeAdapterV2", () => {
3848
Effect.provideService(ProviderHost.ProviderHost, {
3849
paths: { cwd: "/workspace" },
3850
resolveAttachmentPath: () => null,
3851
+ compatibility: () => Effect.undefined,
3852
} as unknown as ProviderHost.ProviderHost["Service"]),
3853
);
3854
const threadId = ThreadId.make("thread-opencode-admission-race");
@@ -4490,6 +4493,7 @@ describe("OpenCodeAdapterV2", () => {
4493
Effect.provideService(ProviderHost.ProviderHost, {
4494
paths: { cwd: "/workspace" },
4495
resolveAttachmentPath: () => null,
4496
+ compatibility: () => Effect.undefined,
4497
} as unknown as ProviderHost.ProviderHost["Service"]),
4498
);
4499
const threadId = ThreadId.make("thread-opencode-initial-stop");
@@ -5364,3 +5368,31 @@ it.live.each([true, false])("opens an authenticated OpenCode session (external=%
5368
]),
5369
),
5370
);
5371
+
5372
+it.effect("refuses a session on a server version the policy rates broken", () =>
5373
+ Effect.gen(function* () {
5374
+ const error = yield* makeOpenCodeRuntimeHarness(
5375
+ "broken-version",
5376
+ "ses_broken",
5377
+ {},
5378
+ {
5379
+ compatibility: () =>
5380
+ Effect.succeed({
5381
+ status: "broken" as const,
5382
+ message: null,
5383
+ recommendedVersion: null,
5384
+ recommendedRange: ">=2.0.18",
5385
+ }),
5386
+ },
5387
+ ).pipe(Effect.flip);
5388
+ assert.include(JSON.stringify(error), "OpenCode 1.14.19 does not work");
5389
+ }).pipe(
5390
+ Effect.scoped,
5391
+ Effect.provide([
5392
+ NodeServices.layer,
5393
+ TestProviderHost.layer().pipe(Layer.provide(NodeServices.layer)),
5394
+ IdAllocator.layer,
5395
+ McpProviderSessions.layer,
5396
+ ]),
5397
+ ),
5398
+);
packages/provider-opencode/src/server/adapter.ts
+15
@@ -30,6 +30,7 @@ import {
30
type OrchestrationV2TurnItem,
31
type PlanId,
32
ProviderDriverKind,
33
+ ProviderSetupError,
34
type ProviderInstanceId,
35
type ProviderRequestKind,
36
type ProviderSessionId,
@@ -54,6 +55,7 @@ import * as Semaphore from "effect/Semaphore";
55
import * as Scope from "effect/Scope";
56
import * as Stream from "effect/Stream";
57
58
+import { brokenVersionDetail } from "@t3tools/provider-core/server/compatibility";
59
import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
60
import { mcpToolPresentation } from "@t3tools/provider-core/server/mcpToolPresentation";
61
import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
@@ -1037,6 +1039,7 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
1039
return ProviderAdapter.ProviderAdapterV2.of({
1040
instanceId: options.instanceId,
1041
driver: OPENCODE_PROVIDER,
1042
+ checksVersionAtHandshake: true,
1043
getCapabilities: Effect.fn("OpencodeAdapter.getCapabilities")(function () {
1044
return Effect.succeed(OpenCodeProviderCapabilitiesV2);
1045
}),
@@ -1056,6 +1059,18 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
1059
: {}),
1060
environment: options.environment,
1061
});
1062
+ const broken = brokenVersionDetail({
1063
+ name: "OpenCode",
1064
+ version: connection.version,
1065
+ advisory: yield* host.compatibility(OPENCODE_PROVIDER, connection.version),
1066
+ });
1067
+ if (broken !== undefined) {
1068
+ return yield* new ProviderSetupError({
1069
+ instanceId: options.instanceId,
1070
+ operation: "runtime",
1071
+ detail: broken,
1072
+ });
1073
+ }
1074
const client = runtime.createOpenCodeSdkClient({
1075
baseUrl: connection.url,
1076
directory: cwd,
packages/provider-opencode/src/server/driver.ts
+1
@@ -524,6 +524,7 @@ export const OpenCodeDriver: ProviderDriver<
524
runtimeProbe.refresh,
525
loadOpenCode2Models,
526
processEnv,
527
+ host.compatibility,
528
).pipe(
529
Effect.annotateLogs({ providerInstanceId: instanceId }),
530
Effect.annotateSpans({ providerInstanceId: instanceId }),
packages/provider-opencode/src/server/status.test.ts
+35
-7
@@ -20,6 +20,7 @@ import { buildProviderOptionSelectionsFromDescriptors } from "@t3tools/shared/mo
20
import { settingsSecretLiteral } from "@t3tools/contracts";
21
22
import { OpenCodeSettings } from "../settings.ts";
23
+import type { ProviderCompatibilityLookup } from "@t3tools/provider-core/server/compatibility";
24
import * as OpenCodeRuntime from "./OpenCodeRuntime.ts";
25
import * as OpenCodeServerOwner from "./OpenCodeServerOwner.ts";
26
import {
@@ -507,6 +508,7 @@ const checkProvider = Effect.fn("checkProvider")(function* (
508
ReadonlyArray<OpenCode2Model>,
509
OpenCodeRuntime.OpenCodeRuntimeError
510
> = Effect.succeed([]),
511
+ compatibility?: ProviderCompatibilityLookup,
512
) {
513
return yield* Effect.scoped(
514
Effect.gen(function* () {
@@ -520,9 +522,14 @@ const checkProvider = Effect.fn("checkProvider")(function* (
522
Effect.provideService(HttpClient.HttpClient, server),
523
Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, OpenCodeRuntimeTestDouble),
524
);
523
- return yield* checkOpenCodeProviderStatus(settings, cwd, probe, openCode2Models).pipe(
524
- Effect.provideService(OpenCodeServerOwner.OpenCodeServerOwner, serverOwner),
525
- );
525
+ return yield* checkOpenCodeProviderStatus(
526
+ settings,
527
+ cwd,
528
+ probe,
529
+ openCode2Models,
530
+ environment,
531
+ compatibility,
532
+ ).pipe(Effect.provideService(OpenCodeServerOwner.OpenCodeServerOwner, serverOwner));
533
}),
534
);
535
});
@@ -1093,18 +1100,39 @@ it.layer(layerTest)("checkOpenCodeProviderStatus with configured server URL", (i
1100
}),
1101
);
1102
1096
- it.effect("rejects an unsupported server before loading inventory", () =>
1103
+ it.effect("reports a version the policy rates broken before loading inventory", () =>
1104
Effect.gen(function* () {
1098
- runtimeMock.state.connectionError = new Error(
1099
- "OpenCode v1.14.18 is too old. Upgrade to v1.14.19 or newer.",
1105
+ const snapshot = yield* checkProvider(
1106
+ makeOpenCodeSettings(),
1107
+ undefined,
1108
+ undefined,
1109
+ undefined,
1110
+ undefined,
1111
+ () =>
1112
+ Effect.succeed({
1113
+ status: "broken",
1114
+ message: null,
1115
+ recommendedVersion: null,
1116
+ recommendedRange: ">=2.0.18",
1117
+ }),
1118
);
1119
+
1120
+ NodeAssert.equal(snapshot.status, "error");
1121
+ NodeAssert.match(snapshot.message ?? "", /OpenCode 1\.14\.19 does not work/);
1122
+ NodeAssert.equal(runtimeMock.state.sdkClientInputs.length, 0);
1123
+ }),
1124
+ );
1125
+
1126
+ it.effect("reports a failed server connection before loading inventory", () =>
1127
+ Effect.gen(function* () {
1128
+ runtimeMock.state.connectionError = new Error("OpenCode server refused the connection.");
1129
const snapshot = yield* checkProvider(
1130
makeOpenCodeSettings({ serverUrl: "http://127.0.0.1:9999" }),
1131
);
1132
1133
NodeAssert.equal(snapshot.status, "error");
1134
NodeAssert.equal(snapshot.models.length, 0);
1107
- NodeAssert.match(snapshot.message ?? "", /v1\.14\.18 is too old/);
1135
+ NodeAssert.match(snapshot.message ?? "", /refused the connection/);
1136
NodeAssert.equal(runtimeMock.state.sdkClientInputs.length, 0);
1137
}),
1138
);
packages/provider-opencode/src/server/status.ts
+33
-15
@@ -1,5 +1,6 @@
1
import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2
import {
3
+ ProviderDriverKind,
4
type ModelCapabilities,
5
type ServerProviderModel,
6
type ServerProviderSkill,
@@ -15,7 +16,11 @@ import * as Option from "effect/Option";
16
import * as Schedule from "effect/Schedule";
17
18
import { createModelCapabilities } from "@t3tools/shared/model";
18
-import { compareSemverVersions } from "@t3tools/shared/semver";
19
+import {
20
+ brokenVersionDetail,
21
+ noCompatibilityPolicy,
22
+ type ProviderCompatibilityLookup,
23
+} from "@t3tools/provider-core/server/compatibility";
24
import {
25
buildServerProvider,
26
COMPACT_SLASH_COMMAND,
@@ -779,6 +784,7 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
784
OpenCodeRuntime.OpenCodeRuntimeError
785
>,
786
environment?: NodeJS.ProcessEnv,
787
+ compatibility: ProviderCompatibilityLookup = noCompatibilityPolicy,
788
): Effect.fn.Return<
789
ServerProviderDraft,
790
never,
@@ -853,21 +859,30 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
859
if (probed.generation === "v2") {
860
return yield* checkOpenCode2(openCodeSettings, probed.version, checkedAt, loadOpenCode2Models);
861
}
856
- if (compareSemverVersions(probed.version, OpenCodeRuntime.MINIMUM_OPENCODE_VERSION) < 0) {
857
- return buildServerProvider({
858
- presentation: OPENCODE_PRESENTATION,
859
- enabled: openCodeSettings.enabled,
860
- checkedAt,
861
- models: providerModelsFromSettings([], customModels, DEFAULT_OPENCODE_MODEL_CAPABILITIES),
862
- probe: {
863
- installed: true,
864
- version: probed.version,
865
- status: "error",
866
- auth: { status: "unknown" },
867
- message: `OpenCode v${probed.version} is too old. Upgrade to v${OpenCodeRuntime.MINIMUM_OPENCODE_VERSION} or newer.`,
868
- },
862
+ const refuseBroken = Effect.fnUntraced(function* (detected: string) {
863
+ const broken = brokenVersionDetail({
864
+ name: "OpenCode",
865
+ version: detected,
866
+ advisory: yield* compatibility(ProviderDriverKind.make("opencode"), detected),
867
});
870
- }
868
+ return broken === undefined
869
+ ? undefined
870
+ : buildServerProvider({
871
+ presentation: OPENCODE_PRESENTATION,
872
+ enabled: openCodeSettings.enabled,
873
+ checkedAt,
874
+ models: providerModelsFromSettings([], customModels, DEFAULT_OPENCODE_MODEL_CAPABILITIES),
875
+ probe: {
876
+ installed: true,
877
+ version: detected,
878
+ status: "error",
879
+ auth: { status: "unknown" },
880
+ message: broken,
881
+ },
882
+ });
883
+ });
884
+ const refused = yield* refuseBroken(probed.version);
885
+ if (refused !== undefined) return refused;
886
887
const installedVersion = isExternalServer ? {} : { installedVersion: probed.version };
888
let version = probed.version;
@@ -910,6 +925,9 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
925
),
926
),
927
);
928
+ // The server that answered can differ from the CLI the probe ran.
929
+ const refusedServer = version === probed.version ? undefined : yield* refuseBroken(version);
930
+ if (refusedServer !== undefined) return { ...refusedServer, ...installedVersion };
931
if (inventoryExit._tag === "Failure") {
932
yield* logDiscoveryFailure({
933
phase: "inventory",
packages/provider-opencode/src/server/textGeneration.test.ts
+14
-6
@@ -15,6 +15,7 @@ import * as TestClock from "effect/testing/TestClock";
15
import * as NetService from "@t3tools/shared/Net";
16
import { beforeEach, expect } from "vite-plus/test";
17
18
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
19
import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
20
import * as OpenCodeRuntime from "./OpenCodeRuntime.ts";
21
import * as OpenCodeServerOwner from "./OpenCodeServerOwner.ts";
@@ -615,21 +616,28 @@ it.layer(layerOpenCodeTextGenerationExistingServerTest)(
616
),
617
);
618
618
- it.effect("does not create a session when the server version is unsupported", () =>
619
+ it.effect("does not create a session on a server version the policy rates broken", () =>
620
withOpenCodeTextGeneration(EXISTING_SERVER_OPENCODE_SETTINGS, (textGeneration) =>
621
Effect.gen(function* () {
621
- runtimeMock.state.connectionError = new Error(
622
- "OpenCode v1.14.18 is too old. Upgrade to v1.14.19 or newer.",
623
- );
624
-
622
const error = yield* textGeneration
623
.generateCommitMessage(DEFAULT_COMMIT_MESSAGE_INPUT)
624
.pipe(Effect.flip);
625
626
expect(error).toBeInstanceOf(TextGenerationError);
630
- expect(error.message).toContain("v1.14.18 is too old");
627
+ expect(error.message).toContain("OpenCode 1.14.19 does not work");
628
expect(runtimeMock.state.sessionCreateCalls).toBe(0);
629
}),
630
+ ).pipe(
631
+ Effect.updateService(ProviderHost.ProviderHost, (host) => ({
632
+ ...host,
633
+ compatibility: () =>
634
+ Effect.succeed({
635
+ status: "broken" as const,
636
+ message: null,
637
+ recommendedVersion: null,
638
+ recommendedRange: ">=2.0.18",
639
+ }),
640
+ })),
641
),
642
);
643
packages/provider-opencode/src/server/textGeneration.ts
+16
-1
@@ -1,7 +1,13 @@
1
import * as Effect from "effect/Effect";
2
import * as Schema from "effect/Schema";
3
4
-import { NonNegativeInt, settingsSecretLiteral, TextGenerationError } from "@t3tools/contracts";
4
+import {
5
+ NonNegativeInt,
6
+ ProviderDriverKind,
7
+ settingsSecretLiteral,
8
+ TextGenerationError,
9
+} from "@t3tools/contracts";
10
+import { brokenVersionDetail } from "@t3tools/provider-core/server/compatibility";
11
import type { OpenCodeSettings } from "../settings.ts";
12
import { getModelSelectionStringOptionValue } from "@t3tools/shared/model";
13
@@ -203,6 +209,15 @@ export const makeOpenCodeTextGeneration = Effect.fn("makeOpenCodeTextGeneration"
209
"url" | "serverPassword" | "version"
210
>,
211
) {
212
+ // Text generation does not open a session, so the shared session check never sees it.
213
+ const broken = brokenVersionDetail({
214
+ name: "OpenCode",
215
+ version: server.version,
216
+ advisory: yield* host.compatibility(ProviderDriverKind.make("opencode"), server.version),
217
+ });
218
+ if (broken !== undefined) {
219
+ return yield* new TextGenerationError({ operation: input.operation, detail: broken });
220
+ }
221
const client = openCodeRuntime.createOpenCodeSdkClient({
222
baseUrl: server.url,
223
directory: input.cwd,
packages/provider-opencode/src/server/versionProbe.ts
+2
-2
@@ -88,7 +88,7 @@ export const probeOpenCodeBinary = Effect.fn("probeOpenCodeBinary")(function* (
88
if (result) return result;
89
return yield* new OpenCodeRuntime.OpenCodeRuntimeError({
90
operation: "probeOpenCodeBinary",
91
- detail: `Unable to determine OpenCode version from \`opencode --version\` output. T3 Code requires OpenCode v${OpenCodeRuntime.MINIMUM_OPENCODE_VERSION} or newer.`,
91
+ detail: "Unable to determine OpenCode version from `opencode --version` output.",
92
});
93
});
94
@@ -163,7 +163,7 @@ const probeOpenCodeServer = Effect.fn("probeOpenCodeServer")(function* (
163
}
164
return yield* new OpenCodeRuntime.OpenCodeRuntimeError({
165
operation: "probeOpenCodeServer",
166
- detail: `The server did not identify itself as OpenCode. T3 Code requires OpenCode v${OpenCodeRuntime.MINIMUM_OPENCODE_VERSION} or newer.`,
166
+ detail: "The server did not identify itself as OpenCode.",
167
});
168
});
169
packages/provider-pi/src/server/driver.ts
+8
-2
@@ -140,13 +140,19 @@ export const PiDriver: ProviderDriver<PiSettings, PiDriverEnv, Path.Path> = {
140
}),
141
),
142
);
143
- const textGeneration = yield* makePiTextGeneration(effectiveConfig, processEnv);
143
+ const textGeneration = yield* makePiTextGeneration(
144
+ effectiveConfig,
145
+ processEnv,
146
+ host.compatibility,
147
+ );
148
149
const checkProvider = fileSystem
150
.makeDirectory(probeCwd, { recursive: true })
151
.pipe(
152
Effect.ignore,
149
- Effect.andThen(checkPiProviderStatus(effectiveConfig, processEnv, probeCwd)),
153
+ Effect.andThen(
154
+ checkPiProviderStatus(effectiveConfig, processEnv, probeCwd, host.compatibility),
155
+ ),
156
Effect.map(stampIdentity),
157
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
158
);
packages/provider-pi/src/server/status.test.ts
+13
-4
@@ -12,7 +12,7 @@ import * as Stream from "effect/Stream";
12
import * as ChildProcess from "effect/process/ChildProcess";
13
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
14
15
-import { checkPiProviderStatus, MINIMUM_PI_VERSION } from "./status.ts";
15
+import { checkPiProviderStatus } from "./status.ts";
16
17
const encoder = new TextEncoder();
18
const decodeRpcRequest = Schema.decodeSync(
@@ -174,15 +174,24 @@ const settings = {
174
customModels: [],
175
} as const;
176
177
+const BROKEN_ADVISORY = {
178
+ status: "broken",
179
+ message: null,
180
+ recommendedVersion: null,
181
+ recommendedRange: ">=1.0.0",
182
+} as const;
183
+
184
describe("PiProvider", () => {
178
- it.effect("requires session-scoped thinking changes", () =>
185
+ it.effect("reports a version the policy rates broken as an error", () =>
186
Effect.gen(function* () {
180
- const snapshot = yield* checkPiProviderStatus(settings).pipe(
187
+ const snapshot = yield* checkPiProviderStatus(settings, undefined, undefined, () =>
188
+ Effect.succeed(BROKEN_ADVISORY),
189
+ ).pipe(
190
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, piProbeSpawner("0.84.2")),
191
);
192
assert.equal(snapshot.status, "error");
193
assert.equal(snapshot.version, "0.84.2");
185
- assert.include(snapshot.message ?? "", `Pi ${MINIMUM_PI_VERSION} or newer`);
194
+ assert.include(snapshot.message ?? "", "Pi 0.84.2 does not work");
195
}).pipe(Effect.provide(NodeServices.layer)),
196
);
197
packages/provider-pi/src/server/status.ts
+17
-6
@@ -1,5 +1,6 @@
1
import { resolveProviderProbeTimeoutMs } from "@t3tools/provider-core/server/snapshotProbe";
2
import {
3
+ ProviderDriverKind,
4
type CustomModelSetting,
5
type ServerProvider,
6
type ServerProviderModel,
@@ -7,7 +8,11 @@ import {
8
import type { PiSettings } from "../settings.ts";
9
import { causeErrorTag } from "@t3tools/shared/observability";
10
import { resolveSpawnCommand } from "@t3tools/shared/shell";
10
-import { compareSemverVersions } from "@t3tools/shared/semver";
11
+import {
12
+ brokenVersionDetail,
13
+ noCompatibilityPolicy,
14
+ type ProviderCompatibilityLookup,
15
+} from "@t3tools/provider-core/server/compatibility";
16
import * as Cause from "effect/Cause";
17
import * as DateTime from "effect/DateTime";
18
import * as Effect from "effect/Effect";
@@ -61,8 +66,6 @@ const PI_PRESENTATION = {
66
const VERSION_PROBE_TIMEOUT_MS = 10_000;
67
const PI_RPC_DISCOVERY_TIMEOUT_MS = 30_000;
68
const PI_TEXT_GENERATION_DISCOVERY_TIMEOUT_MS = 5_000;
64
-// Earlier releases persist background set_thinking_level requests as the user's global default.
65
-export const MINIMUM_PI_VERSION = "0.84.3";
69
70
const decodePiAuthCheck = Schema.decodeUnknownOption(
71
Schema.fromJsonString(Schema.Struct({ reason: Schema.optional(Schema.String) })),
@@ -433,6 +436,7 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function
436
piSettings: PiSettings,
437
environment: NodeJS.ProcessEnv = process.env,
438
cwd?: string,
439
+ compatibility: ProviderCompatibilityLookup = noCompatibilityPolicy,
440
): Effect.fn.Return<ServerProviderDraft, never, ChildProcessSpawner.ChildProcessSpawner> {
441
const checkedAt = DateTime.formatIso(yield* DateTime.now);
442
const fallbackModels = piModelsFromSettings(piSettings.customModels);
@@ -526,12 +530,19 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function
530
version: null,
531
status: "error",
532
auth: { status: "unknown" },
529
- message: `T3 Code could not determine the Pi version. Pi ${MINIMUM_PI_VERSION} or newer is required.`,
533
+ message: "T3 Code could not determine the Pi version. Update Pi, then refresh its status.",
534
},
535
});
536
}
537
534
- if (compareSemverVersions(version, MINIMUM_PI_VERSION) < 0) {
538
+ // Stop before discovery: releases the policy rates broken persist background
539
+ // set_thinking_level requests as the user's global default.
540
+ const broken = brokenVersionDetail({
541
+ name: "Pi",
542
+ version,
543
+ advisory: yield* compatibility(ProviderDriverKind.make("pi"), version),
544
+ });
545
+ if (broken !== undefined) {
546
return buildServerProvider({
547
presentation: PI_PRESENTATION,
548
enabled: piSettings.enabled,
@@ -542,7 +553,7 @@ export const checkPiProviderStatus = Effect.fn("checkPiProviderStatus")(function
553
version,
554
status: "error",
555
auth: { status: "unknown" },
545
- message: `Pi ${version} is unsupported. Update to Pi ${MINIMUM_PI_VERSION} or newer.`,
556
+ message: broken,
557
},
558
});
559
}
packages/provider-pi/src/server/textGeneration.test.ts
+12
-1
@@ -253,6 +253,17 @@ it.effect.each([
253
const textGeneration = yield* makePiTextGeneration(
254
{ enabled: true, binaryPath: "pi", launchArgs: "", customModels: [] },
255
{},
256
+ (_driver, detected) =>
257
+ Effect.succeed(
258
+ detected === "0.84.2"
259
+ ? {
260
+ status: "broken" as const,
261
+ message: null,
262
+ recommendedVersion: null,
263
+ recommendedRange: ">=1.0.0",
264
+ }
265
+ : undefined,
266
+ ),
267
).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, pi.spawner));
268
269
const generation = textGeneration.generateCommitMessage({
@@ -268,7 +279,7 @@ it.effect.each([
279
});
280
if (version === "0.84.2") {
281
const error = yield* generation.pipe(Effect.flip);
271
- assert.include(error.detail, "Pi 0.84.3 or newer");
282
+ assert.include(error.detail, "Pi 0.84.2 does not work");
283
assert.deepEqual(pi.received, []);
284
return;
285
}
packages/provider-pi/src/server/textGeneration.ts
+18
-8
@@ -4,9 +4,13 @@ import * as Queue from "effect/Queue";
4
import * as Schema from "effect/Schema";
5
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
6
7
-import { TextGenerationError } from "@t3tools/contracts";
7
+import { ProviderDriverKind, TextGenerationError } from "@t3tools/contracts";
8
import { getModelSelectionStringOptionValue } from "@t3tools/shared/model";
9
-import { compareSemverVersions } from "@t3tools/shared/semver";
9
+import {
10
+ brokenVersionDetail,
11
+ noCompatibilityPolicy,
12
+ type ProviderCompatibilityLookup,
13
+} from "@t3tools/provider-core/server/compatibility";
14
import { parseGenericCliVersion } from "@t3tools/provider-core/server/snapshotProbe";
15
import type { PiSettings } from "../settings.ts";
16
@@ -14,7 +18,7 @@ import { makePiRpcConnection, piRecordField, piRecordString, resolvePiModelSlug
18
import { buildPiRpcLaunch, resolvePiLaunchArgs } from "./mcpInjection.ts";
19
import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations";
20
import { isPiThinkingLevel } from "./modelCapabilities.ts";
17
-import { MINIMUM_PI_VERSION, runPiVersionCommand } from "./status.ts";
21
+import { runPiVersionCommand } from "./status.ts";
22
23
const PI_TIMEOUT_MS = 180_000;
24
@@ -32,6 +36,7 @@ const piTurnErrorDetail = (errorMessage: string | undefined) => {
36
export const makePiTextGeneration = Effect.fn("makePiTextGeneration")(function* (
37
piSettings: PiSettings,
38
environment: NodeJS.ProcessEnv = process.env,
39
+ compatibility: ProviderCompatibilityLookup = noCompatibilityPolicy,
40
) {
41
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
42
@@ -48,11 +53,16 @@ export const makePiTextGeneration = Effect.fn("makePiTextGeneration")(function*
53
Option.isSome(output) && output.value.code === 0
54
? parseGenericCliVersion(`${output.value.stdout}\n${output.value.stderr}`)
55
: null;
51
- if (version === null || compareSemverVersions(version, MINIMUM_PI_VERSION) < 0) {
52
- return yield* new TextGenerationError({
53
- operation,
54
- detail: `Pi ${MINIMUM_PI_VERSION} or newer is required for text generation thinking options. Update Pi and try again.`,
55
- });
56
+ const broken =
57
+ version === null
58
+ ? "T3 Code could not determine the Pi version. Update Pi and try again."
59
+ : brokenVersionDetail({
60
+ name: "Pi",
61
+ version,
62
+ advisory: yield* compatibility(ProviderDriverKind.make("pi"), version),
63
+ });
64
+ if (broken !== undefined) {
65
+ return yield* new TextGenerationError({ operation, detail: broken });
66
}
67
}
68
packages/provider-testing/src/TestProviderHost.ts
+6
@@ -1,4 +1,8 @@
1
import { DEFAULT_SERVER_SETTINGS, type ServerSettings } from "@t3tools/contracts";
2
+import {
3
+ noCompatibilityPolicy,
4
+ type ProviderCompatibilityLookup,
5
+} from "@t3tools/provider-core/server/compatibility";
6
import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
7
import * as Context from "effect/Context";
8
import * as Effect from "effect/Effect";
@@ -13,6 +17,7 @@ export interface TestProviderHostOptions {
17
readonly cwd?: string;
18
readonly settings?: ServerSettings;
19
readonly runBackgroundWork?: boolean;
20
+ readonly compatibility?: ProviderCompatibilityLookup;
21
}
22
23
export class TestProviderHostSettings extends Context.Service<
@@ -43,6 +48,7 @@ export const layer = (
48
const settings = yield* Ref.make(options.settings ?? DEFAULT_SERVER_SETTINGS);
49
const credentials = new Map<string, Uint8Array>();
50
const host = ProviderHost.ProviderHost.of({
51
+ compatibility: options.compatibility ?? noCompatibilityPolicy,
52
paths: {
53
cwd: options.cwd ?? process.cwd(),
54
baseDir,