Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fad51d16d8 | ||
|
|
5f9dc67976 |
No files matched your search
@@ -18,6 +18,7 @@ release-mock/
|
||||
apps/web/.playwright
|
||||
apps/web/playwright-report
|
||||
apps/web/src/components/__screenshots__
|
||||
apps/marketing/public/provider-compatibility.v1.json
|
||||
.vitest-*
|
||||
__screenshots__/
|
||||
.tanstack
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"build": "bun ../../scripts/mirror-provider-compatibility-map.ts && astro build",
|
||||
"preview": "astro preview",
|
||||
"typecheck": "astro check"
|
||||
},
|
||||
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
normalizeCommandPath,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import { enrichProviderSnapshotWithCompatibilityAdvisory } from "../providerCompatibility.ts";
|
||||
import { makeClaudeCapabilitiesCacheKey, makeClaudeContinuationGroupKey } from "./ClaudeHome.ts";
|
||||
const decodeClaudeSettings = Schema.decodeSync(ClaudeSettings);
|
||||
|
||||
@@ -171,6 +172,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
|
||||
checkProvider,
|
||||
enrichSnapshot: ({ snapshot, publishSnapshot }) =>
|
||||
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(
|
||||
Effect.flatMap(enrichProviderSnapshotWithCompatibilityAdvisory),
|
||||
Effect.provideService(HttpClient.HttpClient, httpClient),
|
||||
Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
|
||||
),
|
||||
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
makePackageManagedProviderMaintenanceResolver,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import { enrichProviderSnapshotWithCompatibilityAdvisory } from "../providerCompatibility.ts";
|
||||
import {
|
||||
codexContinuationIdentity,
|
||||
materializeCodexShadowHome,
|
||||
@@ -171,6 +172,7 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
|
||||
checkProvider,
|
||||
enrichSnapshot: ({ snapshot, publishSnapshot }) =>
|
||||
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(
|
||||
Effect.flatMap(enrichProviderSnapshotWithCompatibilityAdvisory),
|
||||
Effect.provideService(HttpClient.HttpClient, httpClient),
|
||||
Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
|
||||
),
|
||||
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
normalizeCommandPath,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import { enrichProviderSnapshotWithCompatibilityAdvisory } from "../providerCompatibility.ts";
|
||||
const decodeOpenCodeSettings = Schema.decodeSync(OpenCodeSettings);
|
||||
|
||||
const DRIVER_KIND = ProviderDriverKind.make("opencode");
|
||||
@@ -150,6 +151,7 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
|
||||
checkProvider,
|
||||
enrichSnapshot: ({ snapshot, publishSnapshot }) =>
|
||||
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(
|
||||
Effect.flatMap(enrichProviderSnapshotWithCompatibilityAdvisory),
|
||||
Effect.provideService(HttpClient.HttpClient, httpClient),
|
||||
Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
|
||||
),
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
enrichProviderSnapshotWithVersionAdvisory,
|
||||
type ProviderMaintenanceCapabilities,
|
||||
} from "../providerMaintenance.ts";
|
||||
import { enrichProviderSnapshotWithCompatibilityAdvisory } from "../providerCompatibility.ts";
|
||||
import { AcpSessionRuntime } from "../acp/AcpSessionRuntime.ts";
|
||||
|
||||
const PROVIDER = ProviderDriverKind.make("cursor");
|
||||
@@ -1242,6 +1243,7 @@ export const enrichCursorSnapshot = (input: {
|
||||
snapshot,
|
||||
input.maintenanceCapabilities,
|
||||
).pipe(
|
||||
Effect.flatMap(enrichProviderSnapshotWithCompatibilityAdvisory),
|
||||
Effect.provideService(HttpClient.HttpClient, input.httpClient),
|
||||
Effect.flatMap((enrichedSnapshot) =>
|
||||
publishSnapshot(stampIdentity(enrichedSnapshot)).pipe(Effect.as(enrichedSnapshot)),
|
||||
|
||||
@@ -0,0 +1,392 @@
|
||||
import { afterEach, describe, expect, it } from "@effect/vitest";
|
||||
import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { HttpClient, HttpClientResponse } from "effect/unstable/http";
|
||||
|
||||
import {
|
||||
clearProviderCompatibilityCacheForTests,
|
||||
createProviderCompatibilityAdvisory,
|
||||
DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
enrichProviderSnapshotWithCompatibilityAdvisory,
|
||||
GITHUB_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
type ProviderCompatibilityDocument,
|
||||
} from "./providerCompatibility.ts";
|
||||
|
||||
const codexDriver = ProviderDriverKind.make("codex");
|
||||
const claudeDriver = ProviderDriverKind.make("claudeAgent");
|
||||
const opencodeDriver = ProviderDriverKind.make("opencode");
|
||||
const cursorDriver = ProviderDriverKind.make("cursor");
|
||||
|
||||
const baseProvider: ServerProvider = {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
driver: codexDriver,
|
||||
displayName: "Codex",
|
||||
enabled: true,
|
||||
installed: true,
|
||||
version: "0.130.0",
|
||||
status: "ready",
|
||||
auth: { status: "authenticated" },
|
||||
checkedAt: "2026-04-10T00:00:00.000Z",
|
||||
models: [],
|
||||
slashCommands: [],
|
||||
skills: [],
|
||||
};
|
||||
|
||||
function jsonHttpClient(
|
||||
responseForUrl: (url: string) => { readonly payload: unknown; readonly status?: number },
|
||||
): HttpClient.HttpClient {
|
||||
return HttpClient.make((request) => {
|
||||
const response = responseForUrl(request.url);
|
||||
return Effect.succeed(
|
||||
HttpClientResponse.fromWeb(
|
||||
request,
|
||||
new Response(JSON.stringify(response.payload), {
|
||||
status: response.status ?? 200,
|
||||
headers: { "content-type": "application/json" },
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
clearProviderCompatibilityCacheForTests();
|
||||
});
|
||||
|
||||
describe("provider compatibility", () => {
|
||||
it("selects policies by T3 Code version range", () => {
|
||||
const document: ProviderCompatibilityDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: "<0.1.0",
|
||||
driver: codexDriver,
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
},
|
||||
{
|
||||
t3CodeRange: ">=0.1.0",
|
||||
driver: codexDriver,
|
||||
recommendedRange: ">=0.130.0",
|
||||
recommendedVersion: "0.130.0",
|
||||
ranges: [{ status: "supported", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver: codexDriver,
|
||||
currentVersion: "0.130.0",
|
||||
document,
|
||||
t3CodeVersion: "0.0.22",
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: "broken",
|
||||
recommendedVersion: "0.129.0",
|
||||
});
|
||||
});
|
||||
|
||||
it("classifies the initial hosted compatibility policies for T3 Code 0.0.24+", () => {
|
||||
const document: ProviderCompatibilityDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.24",
|
||||
driver: codexDriver,
|
||||
recommendedRange: ">=0.129.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [
|
||||
{ status: "supported", range: ">=0.129.0" },
|
||||
{ status: "broken", range: "<0.129.0" },
|
||||
],
|
||||
},
|
||||
{
|
||||
t3CodeRange: ">=0.0.24",
|
||||
driver: claudeDriver,
|
||||
recommendedRange: ">=0.2.111",
|
||||
recommendedVersion: "0.2.111",
|
||||
ranges: [{ status: "supported", range: ">=0.2.111" }],
|
||||
},
|
||||
{
|
||||
t3CodeRange: ">=0.0.24",
|
||||
driver: opencodeDriver,
|
||||
recommendedRange: ">=1.14.19",
|
||||
recommendedVersion: "1.14.19",
|
||||
ranges: [
|
||||
{ status: "supported", range: ">=1.14.19" },
|
||||
{ status: "broken", range: "<1.14.19" },
|
||||
],
|
||||
},
|
||||
{
|
||||
t3CodeRange: ">=0.0.24",
|
||||
driver: cursorDriver,
|
||||
recommendedRange: ">=2026.05.09",
|
||||
recommendedVersion: "2026.05.09",
|
||||
ranges: [
|
||||
{ status: "supported", range: ">=2026.05.09" },
|
||||
{ status: "unknown", range: "<2026.05.09" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const classify = (driver: ProviderDriverKind, currentVersion: string) =>
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver,
|
||||
currentVersion,
|
||||
document,
|
||||
t3CodeVersion: "0.0.24",
|
||||
})?.status;
|
||||
|
||||
expect(classify(codexDriver, "0.129.0")).toBe("supported");
|
||||
expect(classify(codexDriver, "0.128.0")).toBe("broken");
|
||||
expect(classify(claudeDriver, "0.2.111")).toBe("supported");
|
||||
expect(classify(opencodeDriver, "1.14.19")).toBe("supported");
|
||||
expect(classify(opencodeDriver, "1.14.18")).toBe("broken");
|
||||
expect(classify(cursorDriver, "2026.05.09")).toBe("supported");
|
||||
expect(classify(cursorDriver, "2026.05.09-0afadcc")).toBe("supported");
|
||||
expect(classify(cursorDriver, "2026.05.08")).toBe("unknown");
|
||||
});
|
||||
|
||||
it("matches T3 Code nightly versions against their base release policy", () => {
|
||||
const document: ProviderCompatibilityDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.24",
|
||||
driver: codexDriver,
|
||||
recommendedRange: ">=0.129.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "supported", range: ">=0.129.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver: codexDriver,
|
||||
currentVersion: "0.129.0",
|
||||
document,
|
||||
t3CodeVersion: "0.0.24-nightly.20260513.1",
|
||||
})?.status,
|
||||
).toBe("supported");
|
||||
});
|
||||
|
||||
it.effect("enriches snapshots from the remote compatibility map when available", () => {
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient(() => ({ payload: remoteDocument })),
|
||||
),
|
||||
);
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({
|
||||
status: "broken",
|
||||
recommendedVersion: "0.129.0",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("falls back from the hosted map to the GitHub raw mirror", () => {
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const requestedUrls: string[] = [];
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient((url) => {
|
||||
requestedUrls.push(url);
|
||||
return url === GITHUB_PROVIDER_COMPATIBILITY_MAP_URL
|
||||
? { payload: remoteDocument }
|
||||
: { payload: {}, status: 404 };
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
expect(requestedUrls).toEqual([
|
||||
DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
GITHUB_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
]);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "broken" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("falls back to default remote URLs when the env override parses empty", () => {
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const requestedUrls: string[] = [];
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const previousOverride = process.env.T3_PROVIDER_COMPATIBILITY_MAP_URL;
|
||||
process.env.T3_PROVIDER_COMPATIBILITY_MAP_URL = " , ";
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient((url) => {
|
||||
requestedUrls.push(url);
|
||||
return url === DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL
|
||||
? { payload: remoteDocument }
|
||||
: { payload: {}, status: 404 };
|
||||
}),
|
||||
),
|
||||
Effect.ensuring(
|
||||
Effect.sync(() => {
|
||||
if (previousOverride === undefined) {
|
||||
delete process.env.T3_PROVIDER_COMPATIBILITY_MAP_URL;
|
||||
} else {
|
||||
process.env.T3_PROVIDER_COMPATIBILITY_MAP_URL = previousOverride;
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
expect(requestedUrls).toEqual([DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL]);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "broken" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("lets the remote map relax a bundled compatibility error", () => {
|
||||
const bundledMessage =
|
||||
"This provider harness version 0.130.0 is known to be incompatible with this T3 Code release. Use 0.129.0.";
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: ">=0.130.0",
|
||||
recommendedVersion: "0.130.0",
|
||||
ranges: [{ status: "supported", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory({
|
||||
...baseProvider,
|
||||
status: "error",
|
||||
message: bundledMessage,
|
||||
compatibilityAdvisory: {
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.130.0",
|
||||
message: bundledMessage,
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
},
|
||||
}).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient(() => ({ payload: remoteDocument })),
|
||||
),
|
||||
);
|
||||
|
||||
expect(enriched.status).toBe("ready");
|
||||
expect(enriched.message).toBeUndefined();
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "supported" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("preserves genuine probe errors when the remote map relaxes a bundled advisory", () => {
|
||||
const bundledMessage =
|
||||
"This provider harness version 0.130.0 is known to be incompatible with this T3 Code release. Use 0.129.0.";
|
||||
const probeErrorMessage = "CLI health-check failed: process exited with code 1";
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: ">=0.130.0",
|
||||
recommendedVersion: "0.130.0",
|
||||
ranges: [{ status: "supported", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory({
|
||||
...baseProvider,
|
||||
status: "error",
|
||||
message: bundledMessage,
|
||||
compatibilityAdvisory: {
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.130.0",
|
||||
message: bundledMessage,
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
preAdvisoryStatus: "error",
|
||||
preAdvisoryMessage: probeErrorMessage,
|
||||
},
|
||||
}).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient(() => ({ payload: remoteDocument })),
|
||||
),
|
||||
);
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.message).toBe(probeErrorMessage);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "supported" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("falls back to the bundled map when the remote compatibility fetch fails", () =>
|
||||
Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory({
|
||||
...baseProvider,
|
||||
version: "0.128.0",
|
||||
}).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient(() => ({ payload: {}, status: 404 })),
|
||||
),
|
||||
);
|
||||
|
||||
expect(enriched.status).toBe("ready");
|
||||
expect(enriched.compatibilityAdvisory).toBeUndefined();
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,409 @@
|
||||
import {
|
||||
ProviderDriverKind,
|
||||
TrimmedNonEmptyString,
|
||||
type ServerProvider,
|
||||
type ServerProviderCompatibilityAdvisory,
|
||||
type ServerProviderCompatibilityRange,
|
||||
} from "@t3tools/contracts";
|
||||
import { satisfiesSemverRange } from "@t3tools/shared/semver";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
||||
|
||||
import bundledCompatibilityDocumentJson from "../../../../provider-compatibility.v1.json" with { type: "json" };
|
||||
import packageJson from "../../package.json" with { type: "json" };
|
||||
|
||||
export interface ProviderCompatibilityPolicy {
|
||||
readonly t3CodeRange: string;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly recommendedRange: string | null;
|
||||
readonly recommendedVersion?: string | null;
|
||||
readonly ranges: ReadonlyArray<ServerProviderCompatibilityRange>;
|
||||
}
|
||||
|
||||
export interface ProviderCompatibilityDocument {
|
||||
readonly version: 1;
|
||||
readonly policies: ReadonlyArray<ProviderCompatibilityPolicy>;
|
||||
}
|
||||
|
||||
interface RemoteCompatibilityCacheEntry {
|
||||
readonly expiresAt: number;
|
||||
readonly document: ProviderCompatibilityDocument | null;
|
||||
}
|
||||
|
||||
type ProviderCompatibilitySnapshot = Pick<ServerProvider, "enabled" | "status" | "message"> & {
|
||||
readonly compatibilityAdvisory?: ServerProviderCompatibilityAdvisory | undefined;
|
||||
};
|
||||
|
||||
const T3_CODE_VERSION = packageJson.version;
|
||||
const REMOTE_COMPATIBILITY_CACHE_TTL_MS = 15 * 60 * 1_000;
|
||||
const REMOTE_COMPATIBILITY_TIMEOUT_MS = 2_500;
|
||||
|
||||
export const DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL =
|
||||
"https://t3.codes/provider-compatibility.v1.json";
|
||||
export const GITHUB_PROVIDER_COMPATIBILITY_MAP_URL =
|
||||
"https://raw.githubusercontent.com/pingdotgg/t3code/main/provider-compatibility.v1.json";
|
||||
export const DEFAULT_PROVIDER_COMPATIBILITY_MAP_URLS = [
|
||||
DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
GITHUB_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
] as const;
|
||||
|
||||
const remoteCompatibilityCache = new Map<string, RemoteCompatibilityCacheEntry>();
|
||||
|
||||
const RemoteCompatibilityRange = Schema.Struct({
|
||||
status: Schema.Literals(["unknown", "supported", "graceful", "unsupported", "broken"]),
|
||||
range: TrimmedNonEmptyString,
|
||||
label: Schema.optional(TrimmedNonEmptyString),
|
||||
});
|
||||
|
||||
const RemoteCompatibilityPolicy = Schema.Struct({
|
||||
t3CodeRange: TrimmedNonEmptyString,
|
||||
driver: TrimmedNonEmptyString,
|
||||
recommendedRange: Schema.NullOr(TrimmedNonEmptyString),
|
||||
recommendedVersion: Schema.optionalKey(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
ranges: Schema.Array(RemoteCompatibilityRange),
|
||||
});
|
||||
|
||||
const RemoteCompatibilityDocument = Schema.Struct({
|
||||
version: Schema.Literal(1),
|
||||
policies: Schema.Array(RemoteCompatibilityPolicy),
|
||||
});
|
||||
|
||||
function normalizeCompatibilityDocument(
|
||||
document: typeof RemoteCompatibilityDocument.Type,
|
||||
): ProviderCompatibilityDocument {
|
||||
return {
|
||||
version: document.version,
|
||||
policies: document.policies.map((policy) => ({
|
||||
t3CodeRange: policy.t3CodeRange,
|
||||
driver: ProviderDriverKind.make(policy.driver),
|
||||
recommendedRange: policy.recommendedRange,
|
||||
...(policy.recommendedVersion !== undefined
|
||||
? { recommendedVersion: policy.recommendedVersion }
|
||||
: {}),
|
||||
ranges: policy.ranges.map((range) => ({
|
||||
status: range.status,
|
||||
range: range.range,
|
||||
...(range.label !== undefined ? { label: range.label } : {}),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
const decodeRawCompatibilityDocument = Schema.decodeUnknownEffect(RemoteCompatibilityDocument);
|
||||
const decodeCompatibilityDocument = (input: unknown) =>
|
||||
decodeRawCompatibilityDocument(input).pipe(Effect.map(normalizeCompatibilityDocument));
|
||||
|
||||
/**
|
||||
* Repo-root compatibility JSON bundled into the app. Used when the remote map
|
||||
* cannot be fetched or has no matching policy for the current provider/build.
|
||||
*/
|
||||
const bundledProviderCompatibilityDocument: ProviderCompatibilityDocument =
|
||||
normalizeCompatibilityDocument(
|
||||
bundledCompatibilityDocumentJson as typeof RemoteCompatibilityDocument.Type,
|
||||
);
|
||||
|
||||
export function clearProviderCompatibilityCacheForTests(): void {
|
||||
remoteCompatibilityCache.clear();
|
||||
}
|
||||
|
||||
function remoteCompatibilityMapUrls(): ReadonlyArray<string> {
|
||||
const configured = process.env.T3_PROVIDER_COMPATIBILITY_MAP_URL?.trim();
|
||||
if (!configured) {
|
||||
return DEFAULT_PROVIDER_COMPATIBILITY_MAP_URLS;
|
||||
}
|
||||
const urls = configured
|
||||
.split(",")
|
||||
.map((url) => url.trim())
|
||||
.filter((url) => url.length > 0);
|
||||
return urls.length > 0 ? urls : DEFAULT_PROVIDER_COMPATIBILITY_MAP_URLS;
|
||||
}
|
||||
|
||||
function policyMatches(input: {
|
||||
readonly policy: ProviderCompatibilityPolicy;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly t3CodeVersion: string;
|
||||
}): boolean {
|
||||
return (
|
||||
input.policy.driver === input.driver &&
|
||||
satisfiesSemverRange(input.t3CodeVersion, input.policy.t3CodeRange)
|
||||
);
|
||||
}
|
||||
|
||||
function compatibilityPolicyForDriver(input: {
|
||||
readonly document: ProviderCompatibilityDocument;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly t3CodeVersion?: string;
|
||||
}): ProviderCompatibilityPolicy | null {
|
||||
const t3CodeVersion = input.t3CodeVersion ?? T3_CODE_VERSION;
|
||||
return (
|
||||
input.document.policies.find((policy) =>
|
||||
policyMatches({ policy, driver: input.driver, t3CodeVersion }),
|
||||
) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
function severityForStatus(
|
||||
status: ServerProviderCompatibilityAdvisory["status"],
|
||||
): ServerProviderCompatibilityAdvisory["severity"] {
|
||||
switch (status) {
|
||||
case "broken":
|
||||
return "error";
|
||||
case "unsupported":
|
||||
case "graceful":
|
||||
return "warning";
|
||||
case "supported":
|
||||
case "unknown":
|
||||
return "info";
|
||||
}
|
||||
}
|
||||
|
||||
function messageForStatus(input: {
|
||||
readonly status: ServerProviderCompatibilityAdvisory["status"];
|
||||
readonly currentVersion: string | null;
|
||||
readonly recommendedRange: string | null;
|
||||
readonly recommendedVersion: string | null;
|
||||
}) {
|
||||
const current = input.currentVersion ? ` ${input.currentVersion}` : "";
|
||||
const recommendedTarget = input.recommendedVersion ?? input.recommendedRange;
|
||||
const recommended = recommendedTarget ? ` Use ${recommendedTarget}.` : "";
|
||||
switch (input.status) {
|
||||
case "broken":
|
||||
return `This provider harness version${current} is known to be incompatible with this T3 Code release.${recommended}`;
|
||||
case "unsupported":
|
||||
return `This provider harness version${current} is outside the compatibility range for this T3 Code release.${recommended}`;
|
||||
case "graceful":
|
||||
return `This provider harness version${current} should still work, but updating is recommended.${recommended}`;
|
||||
case "unknown":
|
||||
return `T3 Code could not determine whether this provider harness version is compatible.${recommended}`;
|
||||
case "supported":
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function createProviderCompatibilityAdvisoryFromDocument(input: {
|
||||
readonly document: ProviderCompatibilityDocument;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly currentVersion: string | null;
|
||||
readonly t3CodeVersion?: string;
|
||||
}): ServerProviderCompatibilityAdvisory | undefined {
|
||||
const policy = compatibilityPolicyForDriver({
|
||||
document: input.document,
|
||||
driver: input.driver,
|
||||
...(input.t3CodeVersion ? { t3CodeVersion: input.t3CodeVersion } : {}),
|
||||
});
|
||||
if (!policy) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const currentVersion = input.currentVersion;
|
||||
const matchedRange =
|
||||
currentVersion === null
|
||||
? undefined
|
||||
: policy.ranges.find((range) => satisfiesSemverRange(currentVersion, range.range));
|
||||
const status = matchedRange?.status ?? (currentVersion === null ? "unknown" : "unsupported");
|
||||
const recommendedVersion = policy.recommendedVersion ?? null;
|
||||
|
||||
return {
|
||||
status,
|
||||
severity: severityForStatus(status),
|
||||
currentVersion: input.currentVersion,
|
||||
message: messageForStatus({
|
||||
status,
|
||||
currentVersion: input.currentVersion,
|
||||
recommendedRange: policy.recommendedRange,
|
||||
recommendedVersion,
|
||||
}),
|
||||
recommendedRange: policy.recommendedRange,
|
||||
recommendedVersion,
|
||||
ranges: [...policy.ranges],
|
||||
};
|
||||
}
|
||||
|
||||
export function createProviderCompatibilityAdvisory(input: {
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly currentVersion: string | null;
|
||||
readonly document?: ProviderCompatibilityDocument;
|
||||
readonly t3CodeVersion?: string;
|
||||
}): ServerProviderCompatibilityAdvisory | undefined {
|
||||
return createProviderCompatibilityAdvisoryFromDocument({
|
||||
document: input.document ?? bundledProviderCompatibilityDocument,
|
||||
driver: input.driver,
|
||||
currentVersion: input.currentVersion,
|
||||
...(input.t3CodeVersion ? { t3CodeVersion: input.t3CodeVersion } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
function fetchRemoteCompatibilityDocument(
|
||||
url: string,
|
||||
): Effect.Effect<ProviderCompatibilityDocument | null, never, HttpClient.HttpClient> {
|
||||
return Effect.gen(function* () {
|
||||
const client = yield* HttpClient.HttpClient;
|
||||
const response = yield* client
|
||||
.execute(
|
||||
HttpClientRequest.get(url).pipe(
|
||||
HttpClientRequest.setHeader("accept", "application/json"),
|
||||
HttpClientRequest.setHeader("user-agent", `t3code/${T3_CODE_VERSION}`),
|
||||
),
|
||||
)
|
||||
.pipe(Effect.timeoutOption(REMOTE_COMPATIBILITY_TIMEOUT_MS));
|
||||
|
||||
if (Option.isNone(response)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const httpResponse = response.value;
|
||||
if (httpResponse.status < 200 || httpResponse.status >= 300) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const payload = yield* httpResponse.json.pipe(
|
||||
Effect.flatMap(decodeCompatibilityDocument),
|
||||
Effect.catch(() => Effect.succeed(null)),
|
||||
);
|
||||
return payload;
|
||||
}).pipe(
|
||||
Effect.tapError((cause) =>
|
||||
Effect.logWarning("provider compatibility map fetch failed", {
|
||||
cause,
|
||||
url,
|
||||
}),
|
||||
),
|
||||
Effect.catch(() => Effect.succeed(null)),
|
||||
);
|
||||
}
|
||||
|
||||
export const resolveRemoteProviderCompatibilityDocument = Effect.fn(
|
||||
"resolveRemoteProviderCompatibilityDocument",
|
||||
)(function* () {
|
||||
const urls = remoteCompatibilityMapUrls();
|
||||
const now = DateTime.toEpochMillis(yield* DateTime.now);
|
||||
|
||||
for (const url of urls) {
|
||||
const cached = remoteCompatibilityCache.get(url);
|
||||
if (cached && cached.expiresAt > now) {
|
||||
if (cached.document) {
|
||||
return cached.document;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const document = yield* fetchRemoteCompatibilityDocument(url);
|
||||
remoteCompatibilityCache.set(url, {
|
||||
expiresAt: now + REMOTE_COMPATIBILITY_CACHE_TTL_MS,
|
||||
document,
|
||||
});
|
||||
if (document) {
|
||||
return document;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
function applyCompatibilityAdvisory<Snapshot extends ProviderCompatibilitySnapshot>(
|
||||
snapshot: Snapshot,
|
||||
compatibilityAdvisory: ServerProviderCompatibilityAdvisory | undefined,
|
||||
): Snapshot {
|
||||
const baseSnapshot = removeExistingCompatibilityAdvisory(snapshot);
|
||||
if (!compatibilityAdvisory) {
|
||||
return baseSnapshot;
|
||||
}
|
||||
|
||||
const compatibilityMessage =
|
||||
compatibilityAdvisory.severity !== "info"
|
||||
? (compatibilityAdvisory.message ?? undefined)
|
||||
: undefined;
|
||||
const status =
|
||||
snapshot.enabled && compatibilityAdvisory.severity === "error"
|
||||
? "error"
|
||||
: snapshot.enabled &&
|
||||
compatibilityAdvisory.severity === "warning" &&
|
||||
baseSnapshot.status === "ready"
|
||||
? "warning"
|
||||
: baseSnapshot.status;
|
||||
|
||||
const advisoryWithPreState: ServerProviderCompatibilityAdvisory = {
|
||||
...compatibilityAdvisory,
|
||||
preAdvisoryStatus: baseSnapshot.status,
|
||||
...(baseSnapshot.message ? { preAdvisoryMessage: baseSnapshot.message } : {}),
|
||||
};
|
||||
|
||||
return {
|
||||
...baseSnapshot,
|
||||
status,
|
||||
...(compatibilityMessage || baseSnapshot.message
|
||||
? { message: compatibilityMessage ?? baseSnapshot.message }
|
||||
: {}),
|
||||
compatibilityAdvisory: advisoryWithPreState,
|
||||
} as Snapshot;
|
||||
}
|
||||
|
||||
function removeExistingCompatibilityAdvisory<Snapshot extends ProviderCompatibilitySnapshot>(
|
||||
snapshot: Snapshot,
|
||||
): Snapshot {
|
||||
if (!snapshot.compatibilityAdvisory) {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
const { compatibilityAdvisory: existingCompatibilityAdvisory, ...baseSnapshot } = snapshot;
|
||||
const compatibilityMessage =
|
||||
existingCompatibilityAdvisory.severity !== "info"
|
||||
? (existingCompatibilityAdvisory.message ?? undefined)
|
||||
: undefined;
|
||||
if (compatibilityMessage && baseSnapshot.message === compatibilityMessage) {
|
||||
const { message: _message, ...snapshotWithoutCompatibilityMessage } = baseSnapshot;
|
||||
const restoredStatus =
|
||||
existingCompatibilityAdvisory.preAdvisoryStatus ?? (snapshot.enabled ? "ready" : "disabled");
|
||||
return {
|
||||
...snapshotWithoutCompatibilityMessage,
|
||||
status: restoredStatus,
|
||||
...(existingCompatibilityAdvisory.preAdvisoryMessage
|
||||
? { message: existingCompatibilityAdvisory.preAdvisoryMessage }
|
||||
: {}),
|
||||
} as Snapshot;
|
||||
}
|
||||
if (existingCompatibilityAdvisory.preAdvisoryStatus !== undefined) {
|
||||
return { ...baseSnapshot, status: existingCompatibilityAdvisory.preAdvisoryStatus } as Snapshot;
|
||||
}
|
||||
return baseSnapshot as Snapshot;
|
||||
}
|
||||
|
||||
export function applyBundledProviderCompatibilityAdvisory<
|
||||
Snapshot extends ProviderCompatibilitySnapshot,
|
||||
>(input: {
|
||||
readonly snapshot: Snapshot;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly currentVersion: string | null;
|
||||
}): Snapshot {
|
||||
return applyCompatibilityAdvisory(
|
||||
input.snapshot,
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver: input.driver,
|
||||
currentVersion: input.currentVersion,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export const enrichProviderSnapshotWithCompatibilityAdvisory = Effect.fn(
|
||||
"enrichProviderSnapshotWithCompatibilityAdvisory",
|
||||
)(function* (snapshot: ServerProvider) {
|
||||
const remoteDocument = yield* resolveRemoteProviderCompatibilityDocument();
|
||||
const remoteAdvisory = remoteDocument
|
||||
? createProviderCompatibilityAdvisory({
|
||||
driver: snapshot.driver,
|
||||
currentVersion: snapshot.version,
|
||||
document: remoteDocument,
|
||||
})
|
||||
: undefined;
|
||||
const advisory =
|
||||
remoteAdvisory ??
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver: snapshot.driver,
|
||||
currentVersion: snapshot.version,
|
||||
});
|
||||
|
||||
return applyCompatibilityAdvisory(snapshot, advisory);
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { ProviderDriverKind, type ModelCapabilities } from "@t3tools/contracts";
|
||||
import { createModelCapabilities } from "@t3tools/shared/model";
|
||||
|
||||
import { providerModelsFromSettings } from "./providerSnapshot.ts";
|
||||
import { buildServerProvider, providerModelsFromSettings } from "./providerSnapshot.ts";
|
||||
|
||||
const OPENCODE_CUSTOM_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({
|
||||
optionDescriptors: [
|
||||
@@ -42,3 +42,25 @@ describe("providerModelsFromSettings", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildServerProvider", () => {
|
||||
it("leaves compatibility unset when no bundled policy matches this T3 Code version", () => {
|
||||
const provider = buildServerProvider({
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
presentation: { displayName: "Codex" },
|
||||
enabled: true,
|
||||
checkedAt: "2026-04-10T00:00:00.000Z",
|
||||
models: [],
|
||||
probe: {
|
||||
installed: true,
|
||||
version: "0.128.0",
|
||||
status: "ready",
|
||||
auth: { status: "authenticated" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(provider.status).toBe("ready");
|
||||
expect(provider.compatibilityAdvisory).toBeUndefined();
|
||||
expect(provider.message).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -14,6 +14,7 @@ import * as Stream from "effect/Stream";
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
import { normalizeModelSlug } from "@t3tools/shared/model";
|
||||
import { isWindowsCommandNotFound } from "../processRunner.ts";
|
||||
import { applyBundledProviderCompatibilityAdvisory } from "./providerCompatibility.ts";
|
||||
import { createProviderVersionAdvisory } from "./providerMaintenance.ts";
|
||||
import { collectUint8StreamText } from "../stream/collectUint8StreamText.ts";
|
||||
|
||||
@@ -208,7 +209,7 @@ export function buildServerProvider(input: {
|
||||
checkedAt: input.checkedAt,
|
||||
})
|
||||
: undefined;
|
||||
return {
|
||||
const snapshot: ServerProviderDraft = {
|
||||
displayName: input.presentation.displayName,
|
||||
...(input.presentation.badgeLabel ? { badgeLabel: input.presentation.badgeLabel } : {}),
|
||||
...(typeof input.presentation.showInteractionModeToggle === "boolean"
|
||||
@@ -226,6 +227,13 @@ export function buildServerProvider(input: {
|
||||
skills: [...(input.skills ?? [])],
|
||||
...(versionAdvisory ? { versionAdvisory } : {}),
|
||||
};
|
||||
return input.driver
|
||||
? applyBundledProviderCompatibilityAdvisory({
|
||||
snapshot,
|
||||
driver: input.driver,
|
||||
currentVersion: input.probe.version,
|
||||
})
|
||||
: snapshot;
|
||||
}
|
||||
|
||||
export const collectStreamAsString = <E>(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
AlertTriangleIcon,
|
||||
ArrowUpCircleIcon,
|
||||
ChevronDownIcon,
|
||||
CopyIcon,
|
||||
@@ -40,6 +41,7 @@ import { RedactedSensitiveText } from "./RedactedSensitiveText";
|
||||
import {
|
||||
getProviderVersionAdvisoryPresentation,
|
||||
PROVIDER_STATUS_STYLES,
|
||||
getProviderCompatibilityAdvisoryPresentation,
|
||||
getProviderSummary,
|
||||
getProviderVersionLabel,
|
||||
type ProviderStatusKey,
|
||||
@@ -481,6 +483,9 @@ export function ProviderInstanceCard({
|
||||
: null;
|
||||
const summary = rawSummary;
|
||||
const versionLabel = getProviderVersionLabel(liveProvider?.version);
|
||||
const compatibilityAdvisory = getProviderCompatibilityAdvisoryPresentation(
|
||||
liveProvider?.compatibilityAdvisory,
|
||||
);
|
||||
const versionAdvisory = getProviderVersionAdvisoryPresentation(liveProvider?.versionAdvisory);
|
||||
const updateCommand = versionAdvisory?.updateCommand ?? null;
|
||||
const FallbackIconComponent = driverOption?.icon;
|
||||
@@ -677,6 +682,45 @@ export function ProviderInstanceCard({
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
{titleHeadNode}
|
||||
{versionCodeNode}
|
||||
{compatibilityAdvisory ? (
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"size-5 rounded-sm p-0",
|
||||
compatibilityAdvisory.emphasis === "strong"
|
||||
? "text-destructive hover:text-destructive"
|
||||
: "text-warning hover:text-warning",
|
||||
)}
|
||||
aria-label={`${compatibilityAdvisory.title} — view details`}
|
||||
>
|
||||
<AlertTriangleIcon className="size-3.5" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<PopoverPopup side="bottom" align="start" className="w-84">
|
||||
<div className="grid gap-1">
|
||||
<p className="text-[13px] font-semibold leading-tight text-foreground">
|
||||
{compatibilityAdvisory.title}
|
||||
</p>
|
||||
<p
|
||||
className={cn(
|
||||
"text-xs leading-snug",
|
||||
compatibilityAdvisory.emphasis === "strong"
|
||||
? "text-destructive"
|
||||
: "text-warning",
|
||||
)}
|
||||
>
|
||||
{compatibilityAdvisory.detail}
|
||||
</p>
|
||||
</div>
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
) : null}
|
||||
{versionAdvisory ? (
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getProviderCompatibilityAdvisoryPresentation } from "./providerStatus";
|
||||
|
||||
describe("getProviderCompatibilityAdvisoryPresentation", () => {
|
||||
it("hides supported compatibility advisories", () => {
|
||||
expect(
|
||||
getProviderCompatibilityAdvisoryPresentation({
|
||||
status: "supported",
|
||||
severity: "info",
|
||||
currentVersion: "0.129.0",
|
||||
message: null,
|
||||
recommendedRange: ">=0.129.0",
|
||||
ranges: [],
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("presents broken compatibility advisories strongly", () => {
|
||||
expect(
|
||||
getProviderCompatibilityAdvisoryPresentation({
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.128.0",
|
||||
message: "Known incompatible.",
|
||||
recommendedRange: ">=0.129.0",
|
||||
ranges: [],
|
||||
}),
|
||||
).toEqual({
|
||||
title: "Incompatible provider version",
|
||||
detail: "Known incompatible.",
|
||||
emphasis: "strong",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { ServerProvider, ServerProviderVersionAdvisory } from "@t3tools/contracts";
|
||||
import type {
|
||||
ServerProvider,
|
||||
ServerProviderCompatibilityAdvisory,
|
||||
ServerProviderVersionAdvisory,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
/**
|
||||
* Visual treatment for each server-reported provider status. Centralized so
|
||||
@@ -115,3 +119,29 @@ export function getProviderVersionAdvisoryPresentation(
|
||||
emphasis: "normal" as const,
|
||||
};
|
||||
}
|
||||
|
||||
export function getProviderCompatibilityAdvisoryPresentation(
|
||||
advisory: ServerProviderCompatibilityAdvisory | undefined,
|
||||
): {
|
||||
readonly title: string;
|
||||
readonly detail: string;
|
||||
readonly emphasis: "normal" | "strong";
|
||||
} | null {
|
||||
if (!advisory || advisory.status === "supported") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const recommendedTarget = advisory.recommendedVersion ?? advisory.recommendedRange;
|
||||
const recommended = recommendedTarget ? ` Recommended: ${recommendedTarget}.` : "";
|
||||
const fallback =
|
||||
advisory.status === "unknown"
|
||||
? `Compatibility unknown.${recommended}`
|
||||
: `This provider harness is outside the supported range.${recommended}`;
|
||||
|
||||
return {
|
||||
title:
|
||||
advisory.status === "broken" ? "Incompatible provider version" : "Provider version warning",
|
||||
detail: advisory.message ?? fallback,
|
||||
emphasis: advisory.severity === "error" ? "strong" : "normal",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
# Provider Compatibility Map
|
||||
|
||||
This guide is for maintainers updating `provider-compatibility.v1.json`.
|
||||
|
||||
T3 Code bundles this file at build time and also fetches a hosted copy at
|
||||
runtime. The hosted copy is the maintainer-overridable source of truth: old
|
||||
installs can receive newer compatibility policy without updating the app. The
|
||||
fetch is best effort, so the bundled copy must remain conservative and useful
|
||||
when the user is offline or hosted endpoints are unavailable.
|
||||
|
||||
## When To Update It
|
||||
|
||||
Update the map when a provider harness release changes compatibility with a T3
|
||||
Code release.
|
||||
|
||||
Examples:
|
||||
|
||||
- Codex ships an app-server breaking change.
|
||||
- OpenCode changes its SDK or CLI behavior.
|
||||
- Cursor changes ACP behavior.
|
||||
- A new T3 Code release restores support for a provider version that older T3
|
||||
Code releases cannot support.
|
||||
|
||||
## Policy Shape
|
||||
|
||||
Each policy applies to one provider driver and one T3 Code version range.
|
||||
|
||||
```json
|
||||
{
|
||||
"t3CodeRange": ">=0.0.24 <0.0.25",
|
||||
"driver": "codex",
|
||||
"recommendedRange": ">=0.129.0 <0.131.0",
|
||||
"recommendedVersion": "0.130.0",
|
||||
"ranges": [
|
||||
{
|
||||
"status": "supported",
|
||||
"range": ">=0.129.0 <0.131.0",
|
||||
"label": "Known working Codex app-server harness"
|
||||
},
|
||||
{
|
||||
"status": "broken",
|
||||
"range": "<0.129.0",
|
||||
"label": "Known incompatible Codex app-server harness"
|
||||
},
|
||||
{
|
||||
"status": "broken",
|
||||
"range": ">=0.131.0",
|
||||
"label": "Known incompatible Codex app-server harness"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Fields:
|
||||
|
||||
- `t3CodeRange`: T3 Code versions this policy applies to.
|
||||
- `driver`: provider driver id. Current ids include `codex`, `claudeAgent`,
|
||||
`opencode`, and `cursor`.
|
||||
- `recommendedRange`: the harness range users should be on.
|
||||
- `recommendedVersion`: a concrete version to suggest when possible.
|
||||
- `ranges`: ordered harness-version classifications.
|
||||
|
||||
Statuses:
|
||||
|
||||
- `supported`: known working.
|
||||
- `graceful`: still expected to work, but users should update.
|
||||
- `unsupported`: outside the maintained range.
|
||||
- `broken`: known incompatible; the app shows an error-level advisory.
|
||||
- `unknown`: not tested or not enough signal yet.
|
||||
|
||||
## Version Ranges
|
||||
|
||||
The range syntax is intentionally small:
|
||||
|
||||
- comparators: `=`, `<`, `<=`, `>`, `>=`, `^`
|
||||
- spaces mean AND, for example `>=0.129.0 <0.131.0`
|
||||
- `||` means OR
|
||||
- two-segment versions are treated as patch zero, for example `>=24.10`
|
||||
|
||||
Provider and T3 Code prerelease suffixes are ignored for compatibility
|
||||
comparison. For example:
|
||||
|
||||
- `2026.05.09-0afadcc` matches `>=2026.05.09`
|
||||
- `0.0.24-nightly.20260513.1` matches `>=0.0.24`
|
||||
|
||||
## Handling Provider Breakages
|
||||
|
||||
If Codex `0.131.0` breaks T3 Code `0.0.24`, narrow the existing Codex policy for
|
||||
that app release and mark the new Codex range as broken:
|
||||
|
||||
```json
|
||||
{
|
||||
"t3CodeRange": ">=0.0.24 <0.0.25",
|
||||
"driver": "codex",
|
||||
"recommendedRange": ">=0.129.0 <0.131.0",
|
||||
"recommendedVersion": "0.130.0",
|
||||
"ranges": [
|
||||
{ "status": "supported", "range": ">=0.129.0 <0.131.0" },
|
||||
{ "status": "broken", "range": "<0.129.0" },
|
||||
{ "status": "broken", "range": ">=0.131.0" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
If T3 Code `0.0.25` fixes that breakage, add a separate policy for newer app
|
||||
versions instead of leaving a single broad `>=0.0.24` policy:
|
||||
|
||||
```json
|
||||
{
|
||||
"t3CodeRange": ">=0.0.25",
|
||||
"driver": "codex",
|
||||
"recommendedRange": ">=0.131.0",
|
||||
"recommendedVersion": "0.131.0",
|
||||
"ranges": [{ "status": "supported", "range": ">=0.131.0" }]
|
||||
}
|
||||
```
|
||||
|
||||
Keep T3 Code ranges as narrow as needed. A broad app range such as `>=0.0.24`
|
||||
means future app releases inherit the same provider policy until the hosted map
|
||||
is updated again.
|
||||
|
||||
## Full Breakage Recovery Flow
|
||||
|
||||
Use this sequence when a provider release breaks existing T3 Code installs.
|
||||
|
||||
1. A provider ships a breaking harness release.
|
||||
2. Update the hosted map on `main` so existing T3 Code installs classify that
|
||||
provider version correctly. For example, mark Codex `>=0.131.0` as `broken`
|
||||
for `t3CodeRange: ">=0.0.24 <0.0.25"`.
|
||||
3. Existing installs fetch the hosted map best-effort and show the compatibility
|
||||
advisory without requiring an app update.
|
||||
4. Ship a T3 Code fix in a new app release.
|
||||
5. Update the bundled `provider-compatibility.v1.json` in that release so fresh
|
||||
installs and offline users have the fixed policy baked in.
|
||||
6. Update the hosted map again with a separate policy for the fixed T3 Code
|
||||
version. For example, add `t3CodeRange: ">=0.0.25"` that marks Codex
|
||||
`>=0.131.0` as `supported`.
|
||||
|
||||
The hosted map is the emergency override for already-released builds. The
|
||||
bundled map is the conservative fallback for future downloads, fresh installs,
|
||||
and offline sessions.
|
||||
|
||||
## Hosting
|
||||
|
||||
The default runtime URLs are tried in order:
|
||||
|
||||
```text
|
||||
https://t3.codes/provider-compatibility.v1.json
|
||||
https://raw.githubusercontent.com/pingdotgg/t3code/main/provider-compatibility.v1.json
|
||||
```
|
||||
|
||||
The marketing app build mirrors the repo-root `provider-compatibility.v1.json`
|
||||
into `apps/marketing/public/provider-compatibility.v1.json`, so marketing
|
||||
deployments publish the primary `https://t3.codes/...` copy as a static asset.
|
||||
The GitHub raw URL remains a fallback mirror.
|
||||
|
||||
## Updating The Hosted Map
|
||||
|
||||
The primary hosted map is:
|
||||
|
||||
```text
|
||||
https://t3.codes/provider-compatibility.v1.json
|
||||
```
|
||||
|
||||
To update compatibility policy for existing installs:
|
||||
|
||||
1. Edit `provider-compatibility.v1.json` on `main`.
|
||||
2. Keep the JSON schema version at `1`.
|
||||
3. Prefer non-overlapping `t3CodeRange` values when app releases differ.
|
||||
4. Include a concrete `recommendedVersion` when a one-click install target is
|
||||
known.
|
||||
5. Ensure the marketing app release/deploy runs so the primary static copy is
|
||||
updated.
|
||||
6. Validate with `bun fmt`, `bun lint`, and `bun typecheck`.
|
||||
|
||||
Old installs cache the remote map briefly, so hosted changes are not always
|
||||
visible immediately.
|
||||
@@ -24,6 +24,8 @@ This document covers the unified release workflow for stable and nightly desktop
|
||||
- Publishes the CLI package (`apps/server`, npm package `t3`) with OIDC trusted publishing from the same workflow file:
|
||||
- stable releases publish npm dist-tag `latest`
|
||||
- nightly releases publish npm dist-tag `nightly`
|
||||
- Uses `provider-compatibility.v1.json` as the hosted provider harness compatibility map. See
|
||||
`docs/providers/compatibility.md` before changing compatibility policy.
|
||||
- Deploys the hosted web app to Vercel only after a release is published:
|
||||
- stable releases are aliased to the `latest` hosted app channel
|
||||
- nightly releases are aliased to the `nightly` hosted app channel
|
||||
|
||||
@@ -71,4 +71,39 @@ describe("ServerProvider", () => {
|
||||
|
||||
expect(parsed.continuation?.groupKey).toBe("codex:home:/Users/julius/.codex");
|
||||
});
|
||||
|
||||
it("decodes provider compatibility advisories", () => {
|
||||
const parsed = decodeServerProvider({
|
||||
instanceId: "codex",
|
||||
driver: "codex",
|
||||
enabled: true,
|
||||
installed: true,
|
||||
version: "0.128.0",
|
||||
status: "error",
|
||||
auth: {
|
||||
status: "authenticated",
|
||||
},
|
||||
checkedAt: "2026-04-10T00:00:00.000Z",
|
||||
models: [],
|
||||
compatibilityAdvisory: {
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.128.0",
|
||||
message: "Known incompatible.",
|
||||
recommendedRange: ">=0.129.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [
|
||||
{
|
||||
status: "supported",
|
||||
range: ">=0.129.0",
|
||||
label: "Known working",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.compatibilityAdvisory?.status).toBe("broken");
|
||||
expect(parsed.compatibilityAdvisory?.recommendedVersion).toBe("0.129.0");
|
||||
expect(parsed.compatibilityAdvisory?.ranges).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -134,6 +134,40 @@ export const ServerProviderVersionAdvisory = Schema.Struct({
|
||||
});
|
||||
export type ServerProviderVersionAdvisory = typeof ServerProviderVersionAdvisory.Type;
|
||||
|
||||
export const ServerProviderCompatibilityStatus = Schema.Literals([
|
||||
"unknown",
|
||||
"supported",
|
||||
"graceful",
|
||||
"unsupported",
|
||||
"broken",
|
||||
]);
|
||||
export type ServerProviderCompatibilityStatus = typeof ServerProviderCompatibilityStatus.Type;
|
||||
|
||||
export const ServerProviderCompatibilitySeverity = Schema.Literals(["info", "warning", "error"]);
|
||||
export type ServerProviderCompatibilitySeverity = typeof ServerProviderCompatibilitySeverity.Type;
|
||||
|
||||
export const ServerProviderCompatibilityRange = Schema.Struct({
|
||||
status: ServerProviderCompatibilityStatus,
|
||||
range: TrimmedNonEmptyString,
|
||||
label: Schema.optional(TrimmedNonEmptyString),
|
||||
});
|
||||
export type ServerProviderCompatibilityRange = typeof ServerProviderCompatibilityRange.Type;
|
||||
|
||||
export const ServerProviderCompatibilityAdvisory = Schema.Struct({
|
||||
status: ServerProviderCompatibilityStatus,
|
||||
severity: ServerProviderCompatibilitySeverity,
|
||||
currentVersion: Schema.NullOr(TrimmedNonEmptyString),
|
||||
message: Schema.NullOr(TrimmedNonEmptyString),
|
||||
recommendedRange: Schema.NullOr(TrimmedNonEmptyString),
|
||||
recommendedVersion: Schema.optionalKey(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
ranges: Schema.Array(ServerProviderCompatibilityRange).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed([])),
|
||||
),
|
||||
preAdvisoryStatus: Schema.optionalKey(ServerProviderState),
|
||||
preAdvisoryMessage: Schema.optionalKey(TrimmedNonEmptyString),
|
||||
});
|
||||
export type ServerProviderCompatibilityAdvisory = typeof ServerProviderCompatibilityAdvisory.Type;
|
||||
|
||||
export const ServerProviderUpdateStatus = Schema.Literals([
|
||||
"idle",
|
||||
"queued",
|
||||
@@ -187,6 +221,7 @@ export const ServerProvider = Schema.Struct({
|
||||
),
|
||||
skills: Schema.Array(ServerProviderSkill).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
||||
versionAdvisory: Schema.optionalKey(ServerProviderVersionAdvisory),
|
||||
compatibilityAdvisory: Schema.optionalKey(ServerProviderCompatibilityAdvisory),
|
||||
updateState: Schema.optionalKey(ServerProviderUpdateState),
|
||||
});
|
||||
export type ServerProvider = typeof ServerProvider.Type;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"version": 1,
|
||||
"policies": [
|
||||
{
|
||||
"t3CodeRange": ">=0.0.24",
|
||||
"driver": "codex",
|
||||
"recommendedRange": ">=0.129.0",
|
||||
"recommendedVersion": "0.129.0",
|
||||
"ranges": [
|
||||
{
|
||||
"status": "supported",
|
||||
"range": ">=0.129.0",
|
||||
"label": "Known working Codex app-server harness"
|
||||
},
|
||||
{
|
||||
"status": "broken",
|
||||
"range": "<0.129.0",
|
||||
"label": "Known incompatible Codex app-server harness"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"t3CodeRange": ">=0.0.24",
|
||||
"driver": "claudeAgent",
|
||||
"recommendedRange": ">=0.2.111",
|
||||
"recommendedVersion": "0.2.111",
|
||||
"ranges": [
|
||||
{
|
||||
"status": "supported",
|
||||
"range": ">=0.2.111",
|
||||
"label": "Known working Claude harness"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"t3CodeRange": ">=0.0.24",
|
||||
"driver": "opencode",
|
||||
"recommendedRange": ">=1.14.19",
|
||||
"recommendedVersion": "1.14.19",
|
||||
"ranges": [
|
||||
{
|
||||
"status": "supported",
|
||||
"range": ">=1.14.19",
|
||||
"label": "Known working OpenCode harness"
|
||||
},
|
||||
{
|
||||
"status": "broken",
|
||||
"range": "<1.14.19",
|
||||
"label": "Known incompatible OpenCode harness"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"t3CodeRange": ">=0.0.24",
|
||||
"driver": "cursor",
|
||||
"recommendedRange": ">=2026.05.09",
|
||||
"recommendedVersion": "2026.05.09",
|
||||
"ranges": [
|
||||
{
|
||||
"status": "supported",
|
||||
"range": ">=2026.05.09",
|
||||
"label": "Known working Cursor harness"
|
||||
},
|
||||
{
|
||||
"status": "unknown",
|
||||
"range": "<2026.05.09",
|
||||
"label": "Untested Cursor harness"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import * as Console from "effect/Console";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
const decodeJson = Schema.decodeEffect(Schema.UnknownFromJsonString);
|
||||
|
||||
const program = Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const repoRoot = path.resolve(import.meta.dirname, "..");
|
||||
const sourcePath = path.join(repoRoot, "provider-compatibility.v1.json");
|
||||
const destinationPath = path.join(
|
||||
repoRoot,
|
||||
"apps",
|
||||
"marketing",
|
||||
"public",
|
||||
"provider-compatibility.v1.json",
|
||||
);
|
||||
|
||||
const source = yield* fs.readFileString(sourcePath);
|
||||
yield* decodeJson(source);
|
||||
|
||||
yield* fs.makeDirectory(path.dirname(destinationPath), { recursive: true });
|
||||
yield* fs.copyFile(sourcePath, destinationPath);
|
||||
|
||||
yield* Console.log(
|
||||
`Mirrored ${path.relative(repoRoot, sourcePath)} to ${path.relative(repoRoot, destinationPath)}.`,
|
||||
);
|
||||
});
|
||||
|
||||
if (import.meta.main) {
|
||||
program.pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
|
||||
}
|
||||
Reference in new issue
Block a user