Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
973bdec065 | ||
|
|
97201a866b | ||
|
|
693ee1ac0f | ||
|
|
89d3b8fb5f | ||
|
|
e035af7654 | ||
|
|
278ba2db93 | ||
|
|
5af56065a9 | ||
|
|
845d508fb7 | ||
|
|
cb1c5cf683 | ||
|
|
9f819581e6 | ||
|
|
d90df543ed |
No files matched your search
@@ -46,14 +46,6 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Ensure Electron runtime is installed
|
||||
run: |
|
||||
if ! node -e "require('./apps/desktop/node_modules/electron')" >/dev/null 2>&1; then
|
||||
rm -rf apps/desktop/node_modules/electron/dist apps/desktop/node_modules/electron/path.txt
|
||||
bun apps/desktop/node_modules/electron/install.js
|
||||
fi
|
||||
node -e "require('./apps/desktop/node_modules/electron')"
|
||||
|
||||
- name: Format
|
||||
run: bun run fmt:check
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
import * as NetService from "@t3tools/shared/Net";
|
||||
@@ -26,8 +26,7 @@ const DEFAULT_DESKTOP_BACKEND_PORT = 3773;
|
||||
const MAX_TCP_PORT = 65_535;
|
||||
const DESKTOP_BACKEND_PORT_PROBE_HOSTS = ["127.0.0.1", "0.0.0.0", "::"] as const;
|
||||
|
||||
const makeDesktopRunId = Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.randomUUIDv4),
|
||||
const makeDesktopRunId = Random.nextUUIDv4.pipe(
|
||||
Effect.map((value) => value.replaceAll("-", "").slice(0, 12)),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { parsePersistedServerObservabilitySettings } from "@t3tools/shared/serverSettings";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
import * as DesktopBackendManager from "./DesktopBackendManager.ts";
|
||||
@@ -15,10 +13,7 @@ import * as DesktopObservability from "../app/DesktopObservability.ts";
|
||||
import * as DesktopServerExposure from "./DesktopServerExposure.ts";
|
||||
|
||||
export interface DesktopBackendConfigurationShape {
|
||||
readonly resolve: Effect.Effect<
|
||||
DesktopBackendManager.DesktopBackendStartConfig,
|
||||
PlatformError.PlatformError
|
||||
>;
|
||||
readonly resolve: Effect.Effect<DesktopBackendManager.DesktopBackendStartConfig>;
|
||||
}
|
||||
|
||||
export class DesktopBackendConfiguration extends Context.Service<
|
||||
@@ -85,6 +80,23 @@ const readPersistedBackendObservabilitySettings: Effect.Effect<
|
||||
};
|
||||
});
|
||||
|
||||
const getOrCreateBootstrapToken = Effect.fn("desktop.backendConfiguration.bootstrapToken")(
|
||||
function* (tokenRef: Ref.Ref<Option.Option<string>>) {
|
||||
const existing = yield* Ref.get(tokenRef);
|
||||
if (Option.isSome(existing)) {
|
||||
return existing.value;
|
||||
}
|
||||
|
||||
let token = "";
|
||||
while (token.length < 48) {
|
||||
token += (yield* Random.nextUUIDv4).replace(/-/g, "");
|
||||
}
|
||||
token = token.slice(0, 48);
|
||||
yield* Ref.set(tokenRef, Option.some(token));
|
||||
return token;
|
||||
},
|
||||
);
|
||||
|
||||
const resolveBackendStartConfig = Effect.fn("desktop.backendConfiguration.resolveStartConfig")(
|
||||
function* (input: {
|
||||
readonly bootstrapToken: string;
|
||||
@@ -136,22 +148,11 @@ export const layer = Layer.effect(
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const tokenRef = yield* Ref.make(Option.none<string>());
|
||||
const getOrCreateBootstrapToken = Effect.gen(function* () {
|
||||
const existing = yield* Ref.get(tokenRef);
|
||||
if (Option.isSome(existing)) {
|
||||
return existing.value;
|
||||
}
|
||||
|
||||
const token = Encoding.encodeHex(yield* crypto.randomBytes(24));
|
||||
yield* Ref.set(tokenRef, Option.some(token));
|
||||
return token;
|
||||
});
|
||||
|
||||
return DesktopBackendConfiguration.of({
|
||||
resolve: Effect.gen(function* () {
|
||||
const bootstrapToken = yield* getOrCreateBootstrapToken;
|
||||
const bootstrapToken = yield* getOrCreateBootstrapToken(tokenRef);
|
||||
const observabilitySettings = yield* readPersistedBackendObservabilitySettings.pipe(
|
||||
Effect.provideService(FileSystem.FileSystem, fileSystem),
|
||||
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
|
||||
|
||||
@@ -329,19 +329,9 @@ const makeDesktopBackendManager = Effect.fn("makeDesktopBackendManager")(functio
|
||||
}
|
||||
|
||||
yield* Ref.set(desktopState.backendReady, false);
|
||||
const config = yield* configuration.resolve.pipe(
|
||||
Effect.tapError((error) =>
|
||||
logBackendManagerError("failed to generate desktop backend configuration", {
|
||||
cause: error.message,
|
||||
}),
|
||||
),
|
||||
Effect.option,
|
||||
);
|
||||
if (Option.isNone(config)) {
|
||||
return;
|
||||
}
|
||||
const config = yield* configuration.resolve;
|
||||
const entryExists = yield* fileSystem
|
||||
.exists(config.value.entryPath)
|
||||
.exists(config.entryPath)
|
||||
.pipe(Effect.orElseSucceed(() => false));
|
||||
|
||||
yield* cancelRestart;
|
||||
@@ -349,11 +339,11 @@ const makeDesktopBackendManager = Effect.fn("makeDesktopBackendManager")(functio
|
||||
...latest,
|
||||
desiredRunning: true,
|
||||
ready: false,
|
||||
config: Option.some(config.value),
|
||||
config: Option.some(config),
|
||||
}));
|
||||
|
||||
if (!entryExists) {
|
||||
yield* scheduleRestart(`missing server entry at ${config.value.entryPath}`);
|
||||
yield* scheduleRestart(`missing server entry at ${config.entryPath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -435,7 +425,7 @@ const makeDesktopBackendManager = Effect.fn("makeDesktopBackendManager")(functio
|
||||
});
|
||||
|
||||
const program = runBackendProcess({
|
||||
...config.value,
|
||||
...config,
|
||||
onStarted: Effect.fn("desktop.backendManager.onStarted")(function* (pid) {
|
||||
yield* updateActiveRun(runId, (run) => ({
|
||||
...run,
|
||||
@@ -443,7 +433,7 @@ const makeDesktopBackendManager = Effect.fn("makeDesktopBackendManager")(functio
|
||||
}));
|
||||
yield* backendOutputLog.writeSessionBoundary({
|
||||
phase: "START",
|
||||
details: `pid=${pid} port=${config.value.bootstrap.port} cwd=${config.value.cwd}`,
|
||||
details: `pid=${pid} port=${config.bootstrap.port} cwd=${config.cwd}`,
|
||||
});
|
||||
}),
|
||||
onReady: Effect.fn("desktop.backendManager.onReady")(function* () {
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import { fromLenientJson } from "@t3tools/shared/schemaJson";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
@@ -14,6 +13,7 @@ import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as SynchronizedRef from "effect/SynchronizedRef";
|
||||
|
||||
@@ -222,10 +222,10 @@ const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (inp
|
||||
readonly settingsPath: string;
|
||||
readonly settings: DesktopSettings;
|
||||
readonly defaultSettings: DesktopSettings;
|
||||
readonly suffix: string;
|
||||
}): Effect.fn.Return<void, PlatformError.PlatformError | Schema.SchemaError> {
|
||||
const directory = input.path.dirname(input.settingsPath);
|
||||
const tempPath = `${input.settingsPath}.${process.pid}.${input.suffix}.tmp`;
|
||||
const suffix = (yield* Random.nextUUIDv4).replace(/-/g, "");
|
||||
const tempPath = `${input.settingsPath}.${process.pid}.${suffix}.tmp`;
|
||||
const encoded = yield* encodeDesktopSettingsJson(
|
||||
toDesktopSettingsDocument(input.settings, input.defaultSettings),
|
||||
);
|
||||
@@ -240,7 +240,6 @@ export const layer = Layer.effect(
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const settingsRef = yield* SynchronizedRef.make(environment.defaultDesktopSettings);
|
||||
|
||||
const persist = (
|
||||
@@ -252,18 +251,13 @@ export const layer = Layer.effect(
|
||||
return Effect.succeed([settingsChange(settings, false), settings] as const);
|
||||
}
|
||||
|
||||
return crypto.randomUUIDv4.pipe(
|
||||
Effect.map((uuid) => uuid.replace(/-/g, "")),
|
||||
Effect.flatMap((suffix) =>
|
||||
writeSettings({
|
||||
fileSystem,
|
||||
path,
|
||||
settingsPath: environment.desktopSettingsPath,
|
||||
settings: nextSettings,
|
||||
defaultSettings: environment.defaultDesktopSettings,
|
||||
suffix,
|
||||
}),
|
||||
),
|
||||
return writeSettings({
|
||||
fileSystem,
|
||||
path,
|
||||
settingsPath: environment.desktopSettingsPath,
|
||||
settings: nextSettings,
|
||||
defaultSettings: environment.defaultDesktopSettings,
|
||||
}).pipe(
|
||||
Effect.mapError((cause) => new DesktopSettingsWriteError({ cause })),
|
||||
Effect.as([settingsChange(nextSettings, true), nextSettings] as const),
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ClientSettingsSchema, type ClientSettings } from "@t3tools/contracts";
|
||||
import { fromLenientJson } from "@t3tools/shared/schemaJson";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
@@ -9,6 +8,7 @@ import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
@@ -74,10 +74,10 @@ const writeClientSettings = Effect.fnUntraced(function* (input: {
|
||||
readonly path: Path.Path;
|
||||
readonly settingsPath: string;
|
||||
readonly settings: ClientSettings;
|
||||
readonly suffix: string;
|
||||
}): Effect.fn.Return<void, PlatformError.PlatformError | Schema.SchemaError> {
|
||||
const directory = input.path.dirname(input.settingsPath);
|
||||
const tempPath = `${input.settingsPath}.${process.pid}.${input.suffix}.tmp`;
|
||||
const suffix = (yield* Random.nextUUIDv4).replace(/-/g, "");
|
||||
const tempPath = `${input.settingsPath}.${process.pid}.${suffix}.tmp`;
|
||||
const encoded = yield* encodeClientSettingsJson(input.settings);
|
||||
yield* input.fileSystem.makeDirectory(directory, { recursive: true });
|
||||
yield* input.fileSystem.writeFileString(tempPath, `${encoded}\n`);
|
||||
@@ -90,24 +90,18 @@ export const layer = Layer.effect(
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
|
||||
return DesktopClientSettings.of({
|
||||
get: readClientSettings(fileSystem, environment.clientSettingsPath).pipe(
|
||||
Effect.withSpan("desktop.clientSettings.get"),
|
||||
),
|
||||
set: (settings) =>
|
||||
crypto.randomUUIDv4.pipe(
|
||||
Effect.map((uuid) => uuid.replace(/-/g, "")),
|
||||
Effect.flatMap((suffix) =>
|
||||
writeClientSettings({
|
||||
fileSystem,
|
||||
path,
|
||||
settingsPath: environment.clientSettingsPath,
|
||||
settings,
|
||||
suffix,
|
||||
}),
|
||||
),
|
||||
writeClientSettings({
|
||||
fileSystem,
|
||||
path,
|
||||
settingsPath: environment.clientSettingsPath,
|
||||
settings,
|
||||
}).pipe(
|
||||
Effect.mapError((cause) => new DesktopClientSettingsWriteError({ cause })),
|
||||
Effect.withSpan("desktop.clientSettings.set"),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { EnvironmentId, type PersistedSavedEnvironmentRecord } from "@t3tools/contracts";
|
||||
import { fromLenientJson } from "@t3tools/shared/schemaJson";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
@@ -10,6 +9,7 @@ import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PlatformError from "effect/PlatformError";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
@@ -200,10 +200,10 @@ const writeRegistryDocument = Effect.fn("desktop.savedEnvironments.writeRegistry
|
||||
readonly path: Path.Path;
|
||||
readonly registryPath: string;
|
||||
readonly document: SavedEnvironmentRegistryDocument;
|
||||
readonly suffix: string;
|
||||
}): Effect.fn.Return<void, PlatformError.PlatformError | Schema.SchemaError> {
|
||||
const directory = input.path.dirname(input.registryPath);
|
||||
const tempPath = `${input.registryPath}.${process.pid}.${input.suffix}.tmp`;
|
||||
const suffix = (yield* Random.nextUUIDv4).replace(/-/g, "");
|
||||
const tempPath = `${input.registryPath}.${process.pid}.${suffix}.tmp`;
|
||||
const encoded = yield* encodeSavedEnvironmentRegistryDocumentJson(input.document);
|
||||
yield* input.fileSystem.makeDirectory(directory, { recursive: true });
|
||||
yield* input.fileSystem.writeFileString(tempPath, `${encoded}\n`);
|
||||
@@ -247,22 +247,14 @@ export const layer = Layer.effect(
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const safeStorage = yield* ElectronSafeStorage.ElectronSafeStorage;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
|
||||
const writeDocument = (document: SavedEnvironmentRegistryDocument) =>
|
||||
crypto.randomUUIDv4.pipe(
|
||||
Effect.map((uuid) => uuid.replace(/-/g, "")),
|
||||
Effect.flatMap((suffix) =>
|
||||
writeRegistryDocument({
|
||||
fileSystem,
|
||||
path,
|
||||
registryPath: environment.savedEnvironmentRegistryPath,
|
||||
document,
|
||||
suffix,
|
||||
}),
|
||||
),
|
||||
Effect.mapError((cause) => new DesktopSavedEnvironmentsWriteError({ cause })),
|
||||
);
|
||||
writeRegistryDocument({
|
||||
fileSystem,
|
||||
path,
|
||||
registryPath: environment.savedEnvironmentRegistryPath,
|
||||
document,
|
||||
}).pipe(Effect.mapError((cause) => new DesktopSavedEnvironmentsWriteError({ cause })));
|
||||
|
||||
return DesktopSavedEnvironments.of({
|
||||
getRegistry: readRegistryDocument(fileSystem, environment.savedEnvironmentRegistryPath).pipe(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
@@ -87,7 +86,6 @@ function makeElectronWindowLayer(window: ReturnType<typeof makeTestWindow>["wind
|
||||
function makeLayer(window: ReturnType<typeof makeTestWindow>["window"]) {
|
||||
return DesktopSshPasswordPrompts.layer({ passwordPromptTimeoutMs: 1_000 }).pipe(
|
||||
Layer.provide(makeElectronWindowLayer(window)),
|
||||
Layer.provide(NodeServices.layer),
|
||||
Layer.provideMerge(TestClock.layer()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import type { DesktopSshPasswordPromptRequest } from "@t3tools/contracts";
|
||||
import { DesktopSshPasswordPromptResolutionInputSchema } from "@t3tools/contracts";
|
||||
import type { SshPasswordRequest } from "@t3tools/ssh/auth";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Data from "effect/Data";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
@@ -10,6 +9,7 @@ import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
import * as IpcChannels from "../ipc/channels.ts";
|
||||
@@ -163,7 +163,6 @@ const failPending = (
|
||||
|
||||
const make = Effect.fn("desktop.sshPasswordPrompts.make")(function* (options: LayerOptions = {}) {
|
||||
const electronWindow = yield* ElectronWindow.ElectronWindow;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const pendingRef = yield* Ref.make(new Map<string, PendingSshPasswordPrompt>());
|
||||
const passwordPromptTimeoutMs =
|
||||
options.passwordPromptTimeoutMs ?? DEFAULT_SSH_PASSWORD_PROMPT_TIMEOUT_MS;
|
||||
@@ -231,11 +230,7 @@ const make = Effect.fn("desktop.sshPasswordPrompts.make")(function* (options: La
|
||||
});
|
||||
}
|
||||
|
||||
const requestId = yield* crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
() => new DesktopSshPromptUnavailableError({ reason: "Secure randomness is unavailable." }),
|
||||
),
|
||||
);
|
||||
const requestId = yield* Random.nextUUIDv4;
|
||||
const now = yield* DateTime.now;
|
||||
const expiresAt = DateTime.formatIso(
|
||||
DateTime.add(now, { milliseconds: passwordPromptTimeoutMs }),
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "^0.9.7",
|
||||
"@vercel/config": "^0.3.0",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { type VercelConfig } from "@vercel/config/v1";
|
||||
|
||||
export const config: VercelConfig = {
|
||||
installCommand: "bun install --filter '@t3tools/scripts' --filter '@t3tools/marketing'",
|
||||
buildCommand: "bun ../../scripts/mirror-provider-compatibility-map.ts && astro build",
|
||||
};
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
ProviderDriverKind,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Queue from "effect/Queue";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Stream from "effect/Stream";
|
||||
|
||||
import {
|
||||
@@ -226,7 +226,6 @@ function missingSessionEffect(
|
||||
export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapterHarnessOptions) =>
|
||||
Effect.gen(function* () {
|
||||
const provider = options?.provider ?? ProviderDriverKind.make("codex");
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const runtimeEvents = yield* Queue.unbounded<ProviderRuntimeEvent>();
|
||||
let sessionCount = 0;
|
||||
const sessions = new Map<ThreadId, SessionState>();
|
||||
@@ -242,18 +241,6 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
|
||||
>();
|
||||
|
||||
const emit = (event: ProviderRuntimeEvent) => Queue.offer(runtimeEvents, event);
|
||||
const randomUUIDv4 = (threadId: ThreadId) =>
|
||||
crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new ProviderAdapterValidationError({
|
||||
provider,
|
||||
operation: "crypto/randomUUIDv4",
|
||||
issue: `Failed to generate test runtime identifier for thread '${threadId}'.`,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const startSession: ProviderAdapterShape<ProviderAdapterError>["startSession"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
@@ -322,7 +309,7 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
|
||||
for (const fixtureEvent of response.events) {
|
||||
const rawEvent: Record<string, unknown> = {
|
||||
...(fixtureEvent as Record<string, unknown>),
|
||||
eventId: yield* randomUUIDv4(input.threadId),
|
||||
eventId: yield* Random.nextUUIDv4,
|
||||
provider,
|
||||
sessionId: RuntimeSessionId.make(String(input.threadId)),
|
||||
};
|
||||
@@ -379,7 +366,7 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
|
||||
if (deferredTurnCompletedEvents.length === 0) {
|
||||
yield* emit({
|
||||
type: "turn.completed",
|
||||
eventId: EventId.make(yield* randomUUIDv4(input.threadId)),
|
||||
eventId: EventId.make(yield* Random.nextUUIDv4),
|
||||
provider,
|
||||
createdAt: nowIso(),
|
||||
threadId: state.snapshot.threadId,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Random from "effect/Random";
|
||||
|
||||
export const writeFileStringAtomically = (input: {
|
||||
readonly filePath: string;
|
||||
@@ -10,6 +11,7 @@ export const writeFileStringAtomically = (input: {
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempFileId = yield* Random.nextUUIDv4;
|
||||
const targetDirectory = path.dirname(input.filePath);
|
||||
|
||||
yield* fs.makeDirectory(targetDirectory, { recursive: true });
|
||||
@@ -17,7 +19,7 @@ export const writeFileStringAtomically = (input: {
|
||||
directory: targetDirectory,
|
||||
prefix: `${path.basename(input.filePath)}.`,
|
||||
});
|
||||
const tempPath = path.join(tempDirectory, "contents.tmp");
|
||||
const tempPath = path.join(tempDirectory, `${tempFileId}.tmp`);
|
||||
|
||||
yield* fs.writeFileString(tempPath, input.contents);
|
||||
yield* fs.rename(tempPath, input.filePath);
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
type ClientOrchestrationCommand,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Console from "effect/Console";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Data from "effect/Data";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Duration from "effect/Duration";
|
||||
@@ -59,16 +58,6 @@ class ProjectCommandError extends Data.TaggedError("ProjectCommandError")<{
|
||||
readonly message: string;
|
||||
}> {}
|
||||
|
||||
const projectCommandUuid = Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.randomUUIDv4),
|
||||
Effect.mapError(
|
||||
() =>
|
||||
new ProjectCommandError({
|
||||
message: "Failed to generate a project command identifier.",
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const ProjectCliRuntimeLive = Layer.mergeAll(
|
||||
WorkspacePathsLive,
|
||||
OrchestrationLayerLive.pipe(
|
||||
@@ -271,7 +260,7 @@ const runProjectMutation = Effect.fn("runProjectMutation")(function* (
|
||||
}) => Effect.Effect<
|
||||
string,
|
||||
Error,
|
||||
Crypto.Crypto | FileSystem.FileSystem | HttpClient.HttpClient | Path.Path | WorkspacePaths
|
||||
FileSystem.FileSystem | HttpClient.HttpClient | Path.Path | WorkspacePaths
|
||||
>,
|
||||
) {
|
||||
const logLevel = yield* GlobalFlag.LogLevel;
|
||||
@@ -354,10 +343,10 @@ const projectAddCommand = Command.make("add", {
|
||||
}
|
||||
|
||||
const title = yield* resolveProjectTitle(workspaceRoot, Option.getOrUndefined(flags.title));
|
||||
const projectId = ProjectId.make(yield* projectCommandUuid);
|
||||
const projectId = ProjectId.make(crypto.randomUUID());
|
||||
yield* dispatch({
|
||||
type: "project.create",
|
||||
commandId: CommandId.make(yield* projectCommandUuid),
|
||||
commandId: CommandId.make(crypto.randomUUID()),
|
||||
projectId,
|
||||
title,
|
||||
workspaceRoot,
|
||||
@@ -395,7 +384,7 @@ const projectRemoveCommand = Command.make("remove", {
|
||||
});
|
||||
yield* dispatch({
|
||||
type: "project.delete",
|
||||
commandId: CommandId.make(yield* projectCommandUuid),
|
||||
commandId: CommandId.make(crypto.randomUUID()),
|
||||
projectId: project.id,
|
||||
});
|
||||
return `Removed project ${project.id} (${project.title}).`;
|
||||
@@ -435,7 +424,7 @@ const projectRenameCommand = Command.make("rename", {
|
||||
|
||||
yield* dispatch({
|
||||
type: "project.meta.update",
|
||||
commandId: CommandId.make(yield* projectCommandUuid),
|
||||
commandId: CommandId.make(crypto.randomUUID()),
|
||||
projectId: project.id,
|
||||
title: nextTitle,
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { EnvironmentId, type ExecutionEnvironmentDescriptor } from "@t3tools/contracts";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Random from "effect/Random";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { layer as ProcessRunnerLive } from "../../processRunner.ts";
|
||||
@@ -39,7 +39,6 @@ export const makeServerEnvironment = Effect.fn("makeServerEnvironment")(function
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const serverConfig = yield* ServerConfig;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
|
||||
const readPersistedEnvironmentId = Effect.gen(function* () {
|
||||
const exists = yield* fileSystem
|
||||
@@ -65,7 +64,7 @@ export const makeServerEnvironment = Effect.fn("makeServerEnvironment")(function
|
||||
return persisted;
|
||||
}
|
||||
|
||||
const generated = yield* crypto.randomUUIDv4;
|
||||
const generated = yield* Random.nextUUIDv4;
|
||||
yield* persistEnvironmentId(generated);
|
||||
return generated;
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
|
||||
import * as Arr from "effect/Array";
|
||||
import * as Cache from "effect/Cache";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -531,39 +532,32 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
|
||||
const sourceControlProviders = yield* SourceControlProviderRegistry;
|
||||
const textGeneration = yield* TextGeneration;
|
||||
const projectSetupScriptRunner = yield* ProjectSetupScriptRunner;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
|
||||
const sourceControlProvider = (cwd: string) => sourceControlProviders.resolve({ cwd });
|
||||
const serverSettingsService = yield* ServerSettingsService;
|
||||
const randomUUIDv4 = crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError((cause) =>
|
||||
gitManagerError("randomUUIDv4", "Failed to generate Git operation identifier.", cause),
|
||||
),
|
||||
);
|
||||
|
||||
const createProgressEmitter = (
|
||||
input: { cwd: string; action: GitStackedAction },
|
||||
options?: GitRunStackedActionOptions,
|
||||
) =>
|
||||
(options?.actionId === undefined ? randomUUIDv4 : Effect.succeed(options.actionId)).pipe(
|
||||
Effect.map((actionId) => {
|
||||
const reporter = options?.progressReporter;
|
||||
const emit = (event: GitActionProgressPayload) =>
|
||||
reporter
|
||||
? reporter.publish({
|
||||
actionId,
|
||||
cwd: input.cwd,
|
||||
action: input.action,
|
||||
...event,
|
||||
} as GitActionProgressEvent)
|
||||
: Effect.void;
|
||||
) => {
|
||||
const actionId = options?.actionId ?? randomUUID();
|
||||
const reporter = options?.progressReporter;
|
||||
|
||||
return {
|
||||
actionId,
|
||||
emit,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const emit = (event: GitActionProgressPayload) =>
|
||||
reporter
|
||||
? reporter.publish({
|
||||
actionId,
|
||||
cwd: input.cwd,
|
||||
action: input.action,
|
||||
...event,
|
||||
} as GitActionProgressEvent)
|
||||
: Effect.void;
|
||||
|
||||
return {
|
||||
actionId,
|
||||
emit,
|
||||
};
|
||||
};
|
||||
|
||||
const configurePullRequestHeadUpstreamBase = Effect.fn("configurePullRequestHeadUpstream")(
|
||||
function* (
|
||||
@@ -1307,7 +1301,7 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
|
||||
modelSelection,
|
||||
});
|
||||
|
||||
const bodyFile = path.join(tempDir, `t3code-pr-body-${process.pid}-${yield* randomUUIDv4}.md`);
|
||||
const bodyFile = path.join(tempDir, `t3code-pr-body-${process.pid}-${randomUUID()}.md`);
|
||||
yield* fileSystem
|
||||
.writeFileString(bodyFile, generated.body)
|
||||
.pipe(
|
||||
@@ -1597,7 +1591,7 @@ export const makeGitManager = Effect.fn("makeGitManager")(function* () {
|
||||
|
||||
const runStackedAction: GitManagerShape["runStackedAction"] = Effect.fn("runStackedAction")(
|
||||
function* (input, options) {
|
||||
const progress = yield* createProgressEmitter(input, options);
|
||||
const progress = createProgressEmitter(input, options);
|
||||
const currentPhase = yield* Ref.make<Option.Option<GitActionProgressPhase>>(Option.none());
|
||||
|
||||
const runAction = Effect.fn("runStackedAction.runAction")(function* (): Effect.fn.Return<
|
||||
|
||||
@@ -211,7 +211,6 @@ describe("OrchestrationEngine", () => {
|
||||
Layer.provide(Layer.succeed(OrchestrationEventStore, eventStore)),
|
||||
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
|
||||
Layer.provide(SqlitePersistenceMemory),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
const runtime = ManagedRuntime.make(layer);
|
||||
|
||||
@@ -7,7 +7,6 @@ import type {
|
||||
import { OrchestrationCommand } from "@t3tools/contracts";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Clock from "effect/Clock";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Duration from "effect/Duration";
|
||||
@@ -82,7 +81,6 @@ const makeOrchestrationEngine = Effect.gen(function* () {
|
||||
const commandReceiptRepository = yield* OrchestrationCommandReceiptRepository;
|
||||
const projectionPipeline = yield* OrchestrationProjectionPipeline;
|
||||
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
|
||||
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
|
||||
let commandReadModel = createEmptyReadModel(yield* nowIso);
|
||||
@@ -153,18 +151,7 @@ const makeOrchestrationEngine = Effect.gen(function* () {
|
||||
const eventBase = yield* decideOrchestrationCommand({
|
||||
command: envelope.command,
|
||||
readModel: commandReadModel,
|
||||
}).pipe(
|
||||
Effect.provideService(Crypto.Crypto, crypto),
|
||||
Effect.mapError((cause) =>
|
||||
isOrchestrationCommandInvariantError(cause)
|
||||
? cause
|
||||
: new OrchestrationCommandInvariantError({
|
||||
commandType: envelope.command.type,
|
||||
detail: "Failed to generate an event identifier.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
const eventBases = Array.isArray(eventBase) ? eventBase : [eventBase];
|
||||
const committedCommand = yield* sql
|
||||
.withTransaction(
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
import { isTemporaryWorktreeBranch, WORKTREE_BRANCH_PREFIX } from "@t3tools/shared/git";
|
||||
import * as Cache from "effect/Cache";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Equal from "effect/Equal";
|
||||
@@ -82,6 +81,9 @@ function mapProviderSessionStatusToOrchestrationStatus(
|
||||
const turnStartKeyForEvent = (event: ProviderIntentEvent): string =>
|
||||
event.commandId !== null ? `command:${event.commandId}` : `event:${event.eventId}`;
|
||||
|
||||
const serverCommandId = (tag: string): CommandId =>
|
||||
CommandId.make(`server:${tag}:${crypto.randomUUID()}`);
|
||||
|
||||
const HANDLED_TURN_START_KEY_MAX = 10_000;
|
||||
const HANDLED_TURN_START_KEY_TTL = Duration.minutes(30);
|
||||
const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
|
||||
@@ -176,7 +178,6 @@ function buildGeneratedWorktreeBranchName(raw: string): string {
|
||||
}
|
||||
|
||||
const make = Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const orchestrationEngine = yield* OrchestrationEngineService;
|
||||
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
const providerService = yield* ProviderService;
|
||||
@@ -184,9 +185,6 @@ const make = Effect.gen(function* () {
|
||||
const vcsStatusBroadcaster = yield* VcsStatusBroadcaster;
|
||||
const textGeneration = yield* TextGeneration;
|
||||
const serverSettingsService = yield* ServerSettingsService;
|
||||
const serverCommandId = (tag: string) =>
|
||||
crypto.randomUUIDv4.pipe(Effect.map((uuid) => CommandId.make(`server:${tag}:${uuid}`)));
|
||||
const serverEventId = () => crypto.randomUUIDv4.pipe(Effect.map(EventId.make));
|
||||
const handledTurnStartKeys = yield* Cache.make<string, true>({
|
||||
capacity: HANDLED_TURN_START_KEY_MAX,
|
||||
timeToLive: HANDLED_TURN_START_KEY_TTL,
|
||||
@@ -216,31 +214,24 @@ const make = Effect.gen(function* () {
|
||||
readonly createdAt: string;
|
||||
readonly requestId?: string;
|
||||
}) =>
|
||||
Effect.all({
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId: serverCommandId("provider-failure-activity"),
|
||||
eventId: serverEventId(),
|
||||
}).pipe(
|
||||
Effect.flatMap(({ commandId, eventId }) =>
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId,
|
||||
threadId: input.threadId,
|
||||
activity: {
|
||||
id: eventId,
|
||||
tone: "error",
|
||||
kind: input.kind,
|
||||
summary: input.summary,
|
||||
payload: {
|
||||
detail: input.detail,
|
||||
...(input.requestId ? { requestId: input.requestId } : {}),
|
||||
},
|
||||
turnId: input.turnId,
|
||||
createdAt: input.createdAt,
|
||||
},
|
||||
createdAt: input.createdAt,
|
||||
}),
|
||||
),
|
||||
);
|
||||
threadId: input.threadId,
|
||||
activity: {
|
||||
id: EventId.make(crypto.randomUUID()),
|
||||
tone: "error",
|
||||
kind: input.kind,
|
||||
summary: input.summary,
|
||||
payload: {
|
||||
detail: input.detail,
|
||||
...(input.requestId ? { requestId: input.requestId } : {}),
|
||||
},
|
||||
turnId: input.turnId,
|
||||
createdAt: input.createdAt,
|
||||
},
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
|
||||
const formatFailureDetail = (cause: Cause.Cause<unknown>): string => {
|
||||
const failReason = cause.reasons.find(Cause.isFailReason);
|
||||
@@ -258,17 +249,13 @@ const make = Effect.gen(function* () {
|
||||
readonly session: OrchestrationSession;
|
||||
readonly createdAt: string;
|
||||
}) =>
|
||||
serverCommandId("provider-session-set").pipe(
|
||||
Effect.flatMap((commandId) =>
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId,
|
||||
threadId: input.threadId,
|
||||
session: input.session,
|
||||
createdAt: input.createdAt,
|
||||
}),
|
||||
),
|
||||
);
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId: serverCommandId("provider-session-set"),
|
||||
threadId: input.threadId,
|
||||
session: input.session,
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
|
||||
const setThreadSessionErrorOnTurnStartFailure = Effect.fnUntraced(function* (input: {
|
||||
readonly threadId: ThreadId;
|
||||
@@ -623,7 +610,7 @@ const make = Effect.gen(function* () {
|
||||
const renamed = yield* gitWorkflow.renameBranch({ cwd, oldBranch, newBranch: targetBranch });
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.meta.update",
|
||||
commandId: yield* serverCommandId("worktree-branch-rename"),
|
||||
commandId: serverCommandId("worktree-branch-rename"),
|
||||
threadId: input.threadId,
|
||||
branch: renamed.branch,
|
||||
worktreePath: cwd,
|
||||
@@ -670,7 +657,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.meta.update",
|
||||
commandId: yield* serverCommandId("thread-title-rename"),
|
||||
commandId: serverCommandId("thread-title-rename"),
|
||||
threadId: input.threadId,
|
||||
title: generated.title,
|
||||
});
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import * as Cache from "effect/Cache";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
@@ -40,6 +39,8 @@ import {
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
|
||||
const providerTurnKey = (threadId: ThreadId, turnId: TurnId) => `${threadId}:${turnId}`;
|
||||
const providerCommandId = (event: ProviderRuntimeEvent, tag: string): CommandId =>
|
||||
CommandId.make(`provider:${event.eventId}:${tag}:${crypto.randomUUID()}`);
|
||||
|
||||
interface AssistantSegmentState {
|
||||
baseKey: string;
|
||||
@@ -606,16 +607,11 @@ function runtimeEventToActivities(
|
||||
}
|
||||
|
||||
const make = Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const orchestrationEngine = yield* OrchestrationEngineService;
|
||||
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
const providerService = yield* ProviderService;
|
||||
const projectionTurnRepository = yield* ProjectionTurnRepository;
|
||||
const serverSettingsService = yield* ServerSettingsService;
|
||||
const providerCommandId = (event: ProviderRuntimeEvent, tag: string) =>
|
||||
crypto.randomUUIDv4.pipe(
|
||||
Effect.map((uuid) => CommandId.make(`provider:${event.eventId}:${tag}:${uuid}`)),
|
||||
);
|
||||
|
||||
const turnMessageIdsByTurnKey = yield* Cache.make<string, Set<MessageId>>({
|
||||
capacity: TURN_MESSAGE_IDS_BY_TURN_CACHE_CAPACITY,
|
||||
@@ -852,7 +848,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.message.assistant.delta",
|
||||
commandId: yield* providerCommandId(input.event, input.commandTag),
|
||||
commandId: providerCommandId(input.event, input.commandTag),
|
||||
threadId: input.threadId,
|
||||
messageId: input.messageId,
|
||||
delta: bufferedText,
|
||||
@@ -919,7 +915,7 @@ const make = Effect.gen(function* () {
|
||||
if (hasRenderableText) {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.message.assistant.delta",
|
||||
commandId: yield* providerCommandId(input.event, input.finalDeltaCommandTag),
|
||||
commandId: providerCommandId(input.event, input.finalDeltaCommandTag),
|
||||
threadId: input.threadId,
|
||||
messageId: input.messageId,
|
||||
delta: text,
|
||||
@@ -931,7 +927,7 @@ const make = Effect.gen(function* () {
|
||||
if (input.hasProjectedMessage || hasRenderableText) {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.message.assistant.complete",
|
||||
commandId: yield* providerCommandId(input.event, input.commandTag),
|
||||
commandId: providerCommandId(input.event, input.commandTag),
|
||||
threadId: input.threadId,
|
||||
messageId: input.messageId,
|
||||
...(input.turnId ? { turnId: input.turnId } : {}),
|
||||
@@ -1007,7 +1003,7 @@ const make = Effect.gen(function* () {
|
||||
const existingPlan = findProposedPlanById(input.threadProposedPlans, input.planId);
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.proposed-plan.upsert",
|
||||
commandId: yield* providerCommandId(input.event, "proposed-plan-upsert"),
|
||||
commandId: providerCommandId(input.event, "proposed-plan-upsert"),
|
||||
threadId: input.threadId,
|
||||
proposedPlan: {
|
||||
id: input.planId,
|
||||
@@ -1163,11 +1159,10 @@ const make = Effect.gen(function* () {
|
||||
return;
|
||||
}
|
||||
|
||||
const commandUuid = yield* crypto.randomUUIDv4;
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.proposed-plan.upsert",
|
||||
commandId: CommandId.make(
|
||||
`provider:source-proposed-plan-implemented:${implementationThreadId}:${commandUuid}`,
|
||||
`provider:source-proposed-plan-implemented:${implementationThreadId}:${crypto.randomUUID()}`,
|
||||
),
|
||||
threadId: sourceThread.id,
|
||||
proposedPlan: {
|
||||
@@ -1301,7 +1296,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId: yield* providerCommandId(event, "thread-session-set"),
|
||||
commandId: providerCommandId(event, "thread-session-set"),
|
||||
threadId: thread.id,
|
||||
session: {
|
||||
threadId: thread.id,
|
||||
@@ -1347,7 +1342,7 @@ const make = Effect.gen(function* () {
|
||||
if (spillChunk.length > 0) {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.message.assistant.delta",
|
||||
commandId: yield* providerCommandId(event, "assistant-delta-buffer-spill"),
|
||||
commandId: providerCommandId(event, "assistant-delta-buffer-spill"),
|
||||
threadId: thread.id,
|
||||
messageId: assistantMessageId,
|
||||
delta: spillChunk,
|
||||
@@ -1358,7 +1353,7 @@ const make = Effect.gen(function* () {
|
||||
} else {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.message.assistant.delta",
|
||||
commandId: yield* providerCommandId(event, "assistant-delta"),
|
||||
commandId: providerCommandId(event, "assistant-delta"),
|
||||
threadId: thread.id,
|
||||
messageId: assistantMessageId,
|
||||
delta: assistantDelta,
|
||||
@@ -1551,7 +1546,7 @@ const make = Effect.gen(function* () {
|
||||
if (shouldApplyRuntimeError) {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId: yield* providerCommandId(event, "runtime-error-session-set"),
|
||||
commandId: providerCommandId(event, "runtime-error-session-set"),
|
||||
threadId: thread.id,
|
||||
session: {
|
||||
threadId: thread.id,
|
||||
@@ -1573,7 +1568,7 @@ const make = Effect.gen(function* () {
|
||||
if (event.type === "thread.metadata.updated" && event.payload.name) {
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.meta.update",
|
||||
commandId: yield* providerCommandId(event, "thread-meta-update"),
|
||||
commandId: providerCommandId(event, "thread-meta-update"),
|
||||
threadId: thread.id,
|
||||
title: event.payload.name,
|
||||
});
|
||||
@@ -1601,7 +1596,7 @@ const make = Effect.gen(function* () {
|
||||
);
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.turn.diff.complete",
|
||||
commandId: yield* providerCommandId(event, "thread-turn-diff-complete"),
|
||||
commandId: providerCommandId(event, "thread-turn-diff-complete"),
|
||||
threadId: thread.id,
|
||||
turnId,
|
||||
completedAt: now,
|
||||
@@ -1618,17 +1613,13 @@ const make = Effect.gen(function* () {
|
||||
|
||||
const activities = runtimeEventToActivities(event);
|
||||
yield* Effect.forEach(activities, (activity) =>
|
||||
providerCommandId(event, "thread-activity-append").pipe(
|
||||
Effect.flatMap((commandId) =>
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId,
|
||||
threadId: thread.id,
|
||||
activity,
|
||||
createdAt: activity.createdAt,
|
||||
}),
|
||||
),
|
||||
),
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId: providerCommandId(event, "thread-activity-append"),
|
||||
threadId: thread.id,
|
||||
activity,
|
||||
createdAt: activity.createdAt,
|
||||
}),
|
||||
).pipe(Effect.asVoid);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import {
|
||||
ThreadId,
|
||||
type OrchestrationCommand,
|
||||
type OrchestrationEvent,
|
||||
type OrchestrationReadModel,
|
||||
ProviderInstanceId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { expect, it } from "@effect/vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { decideOrchestrationCommand } from "./decider.ts";
|
||||
import { createEmptyReadModel, projectEvent } from "./projector.ts";
|
||||
@@ -20,87 +20,93 @@ const asEventId = (value: string): EventId => EventId.make(value);
|
||||
const asProjectId = (value: string): ProjectId => ProjectId.make(value);
|
||||
const asThreadId = (value: string): ThreadId => ThreadId.make(value);
|
||||
|
||||
const seedReadModel = Effect.gen(function* () {
|
||||
async function seedReadModel(): Promise<OrchestrationReadModel> {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = yield* projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
aggregateId: asProjectId("project-delete"),
|
||||
type: "project.created",
|
||||
occurredAt: now,
|
||||
commandId: asCommandId("cmd-project-create"),
|
||||
causationEventId: null,
|
||||
correlationId: asCommandId("cmd-project-create"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: asProjectId("project-delete"),
|
||||
title: "Project Delete",
|
||||
workspaceRoot: "/tmp/project-delete",
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
|
||||
const withFirstThread = yield* projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create-1"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: asThreadId("thread-delete-1"),
|
||||
type: "thread.created",
|
||||
occurredAt: now,
|
||||
commandId: asCommandId("cmd-thread-create-1"),
|
||||
causationEventId: null,
|
||||
correlationId: asCommandId("cmd-thread-create-1"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: asThreadId("thread-delete-1"),
|
||||
projectId: asProjectId("project-delete"),
|
||||
title: "Thread Delete 1",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
aggregateId: asProjectId("project-delete"),
|
||||
type: "project.created",
|
||||
occurredAt: now,
|
||||
commandId: asCommandId("cmd-project-create"),
|
||||
causationEventId: null,
|
||||
correlationId: asCommandId("cmd-project-create"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: asProjectId("project-delete"),
|
||||
title: "Project Delete",
|
||||
workspaceRoot: "/tmp/project-delete",
|
||||
defaultModelSelection: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return yield* projectEvent(withFirstThread, {
|
||||
sequence: 3,
|
||||
eventId: asEventId("evt-thread-create-2"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: asThreadId("thread-delete-2"),
|
||||
type: "thread.created",
|
||||
occurredAt: now,
|
||||
commandId: asCommandId("cmd-thread-create-2"),
|
||||
causationEventId: null,
|
||||
correlationId: asCommandId("cmd-thread-create-2"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: asThreadId("thread-delete-2"),
|
||||
projectId: asProjectId("project-delete"),
|
||||
title: "Thread Delete 2",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
const withFirstThread = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create-1"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: asThreadId("thread-delete-1"),
|
||||
type: "thread.created",
|
||||
occurredAt: now,
|
||||
commandId: asCommandId("cmd-thread-create-1"),
|
||||
causationEventId: null,
|
||||
correlationId: asCommandId("cmd-thread-create-1"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: asThreadId("thread-delete-1"),
|
||||
projectId: asProjectId("project-delete"),
|
||||
title: "Thread Delete 1",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return Effect.runPromise(
|
||||
projectEvent(withFirstThread, {
|
||||
sequence: 3,
|
||||
eventId: asEventId("evt-thread-create-2"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: asThreadId("thread-delete-2"),
|
||||
type: "thread.created",
|
||||
occurredAt: now,
|
||||
commandId: asCommandId("cmd-thread-create-2"),
|
||||
causationEventId: null,
|
||||
correlationId: asCommandId("cmd-thread-create-2"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: asThreadId("thread-delete-2"),
|
||||
projectId: asProjectId("project-delete"),
|
||||
title: "Thread Delete 2",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
type PlannedEvent = Omit<OrchestrationEvent, "sequence">;
|
||||
|
||||
@@ -136,11 +142,12 @@ function normalizeDeleteEvent(event: PlannedEvent | ReadonlyArray<PlannedEvent>)
|
||||
});
|
||||
}
|
||||
|
||||
it.layer(NodeServices.layer)("decider deletion flows", (it) => {
|
||||
it.effect("rejects deleting a non-empty project without force", () =>
|
||||
Effect.gen(function* () {
|
||||
const readModel = yield* seedReadModel;
|
||||
const error = yield* Effect.flip(
|
||||
describe("decider deletion flows", () => {
|
||||
it("rejects deleting a non-empty project without force", async () => {
|
||||
const readModel = await seedReadModel();
|
||||
|
||||
await expect(
|
||||
Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "project.delete",
|
||||
@@ -149,69 +156,72 @@ it.layer(NodeServices.layer)("decider deletion flows", (it) => {
|
||||
},
|
||||
readModel,
|
||||
}),
|
||||
);
|
||||
expect(error.message).toContain("cannot be deleted without force=true");
|
||||
}),
|
||||
);
|
||||
),
|
||||
).rejects.toThrow("cannot be deleted without force=true");
|
||||
});
|
||||
|
||||
it.effect("reuses thread.delete semantics when force-deleting a non-empty project", () =>
|
||||
Effect.gen(function* () {
|
||||
const readModel = yield* seedReadModel;
|
||||
const projectDeleteCommand: Extract<OrchestrationCommand, { type: "project.delete" }> = {
|
||||
type: "project.delete",
|
||||
commandId: asCommandId("cmd-project-delete-force"),
|
||||
projectId: asProjectId("project-delete"),
|
||||
force: true,
|
||||
};
|
||||
it("reuses thread.delete semantics when force-deleting a non-empty project", async () => {
|
||||
const readModel = await seedReadModel();
|
||||
const projectDeleteCommand: Extract<OrchestrationCommand, { type: "project.delete" }> = {
|
||||
type: "project.delete",
|
||||
commandId: asCommandId("cmd-project-delete-force"),
|
||||
projectId: asProjectId("project-delete"),
|
||||
force: true,
|
||||
};
|
||||
|
||||
const forcedResult = yield* decideOrchestrationCommand({
|
||||
const forcedResult = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: projectDeleteCommand,
|
||||
readModel,
|
||||
});
|
||||
const forcedEvents = Array.isArray(forcedResult) ? forcedResult : [forcedResult];
|
||||
}),
|
||||
);
|
||||
const forcedEvents = Array.isArray(forcedResult) ? forcedResult : [forcedResult];
|
||||
|
||||
expect(forcedEvents.map((event) => event.type)).toEqual([
|
||||
"thread.deleted",
|
||||
"thread.deleted",
|
||||
"project.deleted",
|
||||
]);
|
||||
expect(forcedEvents.map((event) => event.type)).toEqual([
|
||||
"thread.deleted",
|
||||
"thread.deleted",
|
||||
"project.deleted",
|
||||
]);
|
||||
|
||||
let sequentialReadModel = readModel;
|
||||
let nextSequence = readModel.snapshotSequence;
|
||||
const sequentialEvents: PlannedEvent[] = [];
|
||||
for (const nextCommand of [
|
||||
{
|
||||
type: "thread.delete",
|
||||
commandId: projectDeleteCommand.commandId,
|
||||
threadId: asThreadId("thread-delete-1"),
|
||||
},
|
||||
{
|
||||
type: "thread.delete",
|
||||
commandId: projectDeleteCommand.commandId,
|
||||
threadId: asThreadId("thread-delete-2"),
|
||||
},
|
||||
{
|
||||
type: "project.delete",
|
||||
commandId: projectDeleteCommand.commandId,
|
||||
projectId: asProjectId("project-delete"),
|
||||
},
|
||||
] satisfies ReadonlyArray<OrchestrationCommand>) {
|
||||
const decided = yield* decideOrchestrationCommand({
|
||||
let sequentialReadModel = readModel;
|
||||
let nextSequence = readModel.snapshotSequence;
|
||||
const sequentialEvents: PlannedEvent[] = [];
|
||||
for (const nextCommand of [
|
||||
{
|
||||
type: "thread.delete",
|
||||
commandId: projectDeleteCommand.commandId,
|
||||
threadId: asThreadId("thread-delete-1"),
|
||||
},
|
||||
{
|
||||
type: "thread.delete",
|
||||
commandId: projectDeleteCommand.commandId,
|
||||
threadId: asThreadId("thread-delete-2"),
|
||||
},
|
||||
{
|
||||
type: "project.delete",
|
||||
commandId: projectDeleteCommand.commandId,
|
||||
projectId: asProjectId("project-delete"),
|
||||
},
|
||||
] satisfies ReadonlyArray<OrchestrationCommand>) {
|
||||
const decided = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: nextCommand,
|
||||
readModel: sequentialReadModel,
|
||||
});
|
||||
const nextEvents = Array.isArray(decided) ? decided : [decided];
|
||||
sequentialEvents.push(...nextEvents);
|
||||
for (const nextEvent of nextEvents) {
|
||||
nextSequence += 1;
|
||||
sequentialReadModel = yield* projectEvent(sequentialReadModel, {
|
||||
}),
|
||||
);
|
||||
const nextEvents = Array.isArray(decided) ? decided : [decided];
|
||||
sequentialEvents.push(...nextEvents);
|
||||
for (const nextEvent of nextEvents) {
|
||||
nextSequence += 1;
|
||||
sequentialReadModel = await Effect.runPromise(
|
||||
projectEvent(sequentialReadModel, {
|
||||
...nextEvent,
|
||||
sequence: nextSequence,
|
||||
});
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
expect(normalizeDeleteEvent(forcedResult)).toEqual(normalizeDeleteEvent(sequentialEvents));
|
||||
}),
|
||||
);
|
||||
expect(normalizeDeleteEvent(forcedResult)).toEqual(normalizeDeleteEvent(sequentialEvents));
|
||||
});
|
||||
});
|
||||
@@ -8,9 +8,8 @@ import {
|
||||
ProviderInstanceId,
|
||||
} from "@t3tools/contracts";
|
||||
import { createModelSelection } from "@t3tools/shared/model";
|
||||
import { expect, it } from "@effect/vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
|
||||
import { decideOrchestrationCommand } from "./decider.ts";
|
||||
import { createEmptyReadModel, projectEvent } from "./projector.ts";
|
||||
@@ -18,13 +17,14 @@ import { createEmptyReadModel, projectEvent } from "./projector.ts";
|
||||
const asEventId = (value: string): EventId => EventId.make(value);
|
||||
const asProjectId = (value: string): ProjectId => ProjectId.make(value);
|
||||
const asMessageId = (value: string): MessageId => MessageId.make(value);
|
||||
it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
it.effect("emits empty scripts on project.create", () =>
|
||||
Effect.gen(function* () {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const readModel = createEmptyReadModel(now);
|
||||
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
describe("decider project scripts", () => {
|
||||
it("emits empty scripts on project.create", async () => {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const readModel = createEmptyReadModel(now);
|
||||
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "project.create",
|
||||
commandId: CommandId.make("cmd-project-create-scripts"),
|
||||
@@ -34,19 +34,19 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.created");
|
||||
expect((event.payload as { scripts: unknown[] }).scripts).toEqual([]);
|
||||
}),
|
||||
);
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.created");
|
||||
expect((event.payload as { scripts: unknown[] }).scripts).toEqual([]);
|
||||
});
|
||||
|
||||
it.effect("propagates scripts in project.meta.update payload", () =>
|
||||
Effect.gen(function* () {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const readModel = yield* projectEvent(initial, {
|
||||
it("propagates scripts in project.meta.update payload", async () => {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const readModel = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create-scripts"),
|
||||
aggregateKind: "project",
|
||||
@@ -66,19 +66,21 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const scripts = [
|
||||
{
|
||||
id: "lint",
|
||||
name: "Lint",
|
||||
command: "bun run lint",
|
||||
icon: "lint",
|
||||
runOnWorktreeCreate: false,
|
||||
},
|
||||
] as const;
|
||||
const scripts = [
|
||||
{
|
||||
id: "lint",
|
||||
name: "Lint",
|
||||
command: "bun run lint",
|
||||
icon: "lint",
|
||||
runOnWorktreeCreate: false,
|
||||
},
|
||||
] as const;
|
||||
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "project.meta.update",
|
||||
commandId: CommandId.make("cmd-project-update-scripts"),
|
||||
@@ -86,19 +88,19 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
scripts: Array.from(scripts),
|
||||
},
|
||||
readModel,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.meta-updated");
|
||||
expect((event.payload as { scripts?: unknown[] }).scripts).toEqual(scripts);
|
||||
}),
|
||||
);
|
||||
const event = Array.isArray(result) ? result[0] : result;
|
||||
expect(event.type).toBe("project.meta-updated");
|
||||
expect((event.payload as { scripts?: unknown[] }).scripts).toEqual(scripts);
|
||||
});
|
||||
|
||||
it.effect("emits user message and turn-start-requested events for thread.turn.start", () =>
|
||||
Effect.gen(function* () {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = yield* projectEvent(initial, {
|
||||
it("emits user message and turn-start-requested events for thread.turn.start", async () => {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
@@ -118,8 +120,10 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
const readModel = yield* projectEvent(withProject, {
|
||||
}),
|
||||
);
|
||||
const readModel = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create"),
|
||||
aggregateKind: "thread",
|
||||
@@ -145,9 +149,11 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.make("cmd-turn-start"),
|
||||
@@ -167,35 +173,35 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
expect(Array.isArray(result)).toBe(true);
|
||||
const events = Array.isArray(result) ? result : [result];
|
||||
expect(events).toHaveLength(2);
|
||||
expect(events[0]?.type).toBe("thread.message-sent");
|
||||
const turnStartEvent = events[1];
|
||||
expect(turnStartEvent?.type).toBe("thread.turn-start-requested");
|
||||
expect(turnStartEvent?.causationEventId).toBe(events[0]?.eventId ?? null);
|
||||
if (turnStartEvent?.type !== "thread.turn-start-requested") {
|
||||
return;
|
||||
}
|
||||
expect(turnStartEvent.payload).toMatchObject({
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
messageId: asMessageId("message-user-1"),
|
||||
modelSelection: createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.3-codex", [
|
||||
{ id: "reasoningEffort", value: "high" },
|
||||
{ id: "fastMode", value: true },
|
||||
]),
|
||||
runtimeMode: "approval-required",
|
||||
});
|
||||
}),
|
||||
);
|
||||
expect(Array.isArray(result)).toBe(true);
|
||||
const events = Array.isArray(result) ? result : [result];
|
||||
expect(events).toHaveLength(2);
|
||||
expect(events[0]?.type).toBe("thread.message-sent");
|
||||
const turnStartEvent = events[1];
|
||||
expect(turnStartEvent?.type).toBe("thread.turn-start-requested");
|
||||
expect(turnStartEvent?.causationEventId).toBe(events[0]?.eventId ?? null);
|
||||
if (turnStartEvent?.type !== "thread.turn-start-requested") {
|
||||
return;
|
||||
}
|
||||
expect(turnStartEvent.payload).toMatchObject({
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
messageId: asMessageId("message-user-1"),
|
||||
modelSelection: createModelSelection(ProviderInstanceId.make("codex"), "gpt-5.3-codex", [
|
||||
{ id: "reasoningEffort", value: "high" },
|
||||
{ id: "fastMode", value: true },
|
||||
]),
|
||||
runtimeMode: "approval-required",
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("emits thread.runtime-mode-set from thread.runtime-mode.set", () =>
|
||||
Effect.gen(function* () {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = yield* projectEvent(initial, {
|
||||
it("emits thread.runtime-mode-set from thread.runtime-mode.set", async () => {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
@@ -215,8 +221,10 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
const readModel = yield* projectEvent(withProject, {
|
||||
}),
|
||||
);
|
||||
const readModel = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create"),
|
||||
aggregateKind: "thread",
|
||||
@@ -242,9 +250,11 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.runtime-mode.set",
|
||||
commandId: CommandId.make("cmd-runtime-mode-set"),
|
||||
@@ -253,27 +263,27 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const singleResult = Array.isArray(result) ? null : result;
|
||||
if (singleResult === null) {
|
||||
throw new Error("Expected a single runtime-mode-set event.");
|
||||
}
|
||||
expect(singleResult).toMatchObject({
|
||||
type: "thread.runtime-mode-set",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
runtimeMode: "approval-required",
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
const singleResult = Array.isArray(result) ? null : result;
|
||||
if (singleResult === null) {
|
||||
throw new Error("Expected a single runtime-mode-set event.");
|
||||
}
|
||||
expect(singleResult).toMatchObject({
|
||||
type: "thread.runtime-mode-set",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
runtimeMode: "approval-required",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("emits thread.interaction-mode-set from thread.interaction-mode.set", () =>
|
||||
Effect.gen(function* () {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = yield* projectEvent(initial, {
|
||||
it("emits thread.interaction-mode-set from thread.interaction-mode.set", async () => {
|
||||
const now = "2026-01-01T00:00:00.000Z";
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
@@ -293,8 +303,10 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
const readModel = yield* projectEvent(withProject, {
|
||||
}),
|
||||
);
|
||||
const readModel = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create"),
|
||||
aggregateKind: "thread",
|
||||
@@ -320,9 +332,11 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const result = yield* decideOrchestrationCommand({
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.interaction-mode.set",
|
||||
commandId: CommandId.make("cmd-interaction-mode-set"),
|
||||
@@ -331,19 +345,19 @@ it.layer(NodeServices.layer)("decider project scripts", (it) => {
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
const singleResult = Array.isArray(result) ? null : result;
|
||||
if (singleResult === null) {
|
||||
throw new Error("Expected a single interaction-mode-set event.");
|
||||
}
|
||||
expect(singleResult).toMatchObject({
|
||||
type: "thread.interaction-mode-set",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
interactionMode: "plan",
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
const singleResult = Array.isArray(result) ? null : result;
|
||||
if (singleResult === null) {
|
||||
throw new Error("Expected a single interaction-mode-set event.");
|
||||
}
|
||||
expect(singleResult).toMatchObject({
|
||||
type: "thread.interaction-mode-set",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
interactionMode: "plan",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,10 @@
|
||||
import {
|
||||
EventId,
|
||||
type OrchestrationCommand,
|
||||
type OrchestrationEvent,
|
||||
type OrchestrationReadModel,
|
||||
import type {
|
||||
OrchestrationCommand,
|
||||
OrchestrationEvent,
|
||||
OrchestrationReadModel,
|
||||
} from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import type * as PlatformError from "effect/PlatformError";
|
||||
|
||||
import { OrchestrationCommandInvariantError } from "./Errors.ts";
|
||||
import {
|
||||
@@ -30,27 +27,17 @@ function withEventBase(
|
||||
readonly occurredAt: string;
|
||||
readonly metadata?: OrchestrationEvent["metadata"];
|
||||
},
|
||||
): Effect.Effect<
|
||||
Omit<OrchestrationEvent, "sequence" | "type" | "payload">,
|
||||
PlatformError.PlatformError,
|
||||
Crypto.Crypto
|
||||
> {
|
||||
return Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) =>
|
||||
crypto.randomUUIDv4.pipe(
|
||||
Effect.map((eventId) => ({
|
||||
eventId: EventId.make(eventId),
|
||||
aggregateKind: input.aggregateKind,
|
||||
aggregateId: input.aggregateId,
|
||||
occurredAt: input.occurredAt,
|
||||
commandId: input.commandId,
|
||||
causationEventId: null,
|
||||
correlationId: input.commandId,
|
||||
metadata: input.metadata ?? {},
|
||||
})),
|
||||
),
|
||||
),
|
||||
);
|
||||
): Omit<OrchestrationEvent, "sequence" | "type" | "payload"> {
|
||||
return {
|
||||
eventId: crypto.randomUUID() as OrchestrationEvent["eventId"],
|
||||
aggregateKind: input.aggregateKind,
|
||||
aggregateId: input.aggregateId,
|
||||
occurredAt: input.occurredAt,
|
||||
commandId: input.commandId,
|
||||
causationEventId: null,
|
||||
correlationId: input.commandId,
|
||||
metadata: input.metadata ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
type PlannedOrchestrationEvent = Omit<OrchestrationEvent, "sequence">;
|
||||
@@ -65,11 +52,7 @@ const decideCommandSequence = Effect.fn("decideCommandSequence")(function* ({
|
||||
}: {
|
||||
readonly commands: ReadonlyArray<OrchestrationCommand>;
|
||||
readonly readModel: OrchestrationReadModel;
|
||||
}): Effect.fn.Return<
|
||||
ReadonlyArray<PlannedOrchestrationEvent>,
|
||||
OrchestrationCommandInvariantError | PlatformError.PlatformError,
|
||||
Crypto.Crypto
|
||||
> {
|
||||
}): Effect.fn.Return<ReadonlyArray<PlannedOrchestrationEvent>, OrchestrationCommandInvariantError> {
|
||||
let nextReadModel = readModel;
|
||||
let nextSequence = readModel.snapshotSequence;
|
||||
const plannedEvents: PlannedOrchestrationEvent[] = [];
|
||||
@@ -99,11 +82,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
}: {
|
||||
readonly command: OrchestrationCommand;
|
||||
readonly readModel: OrchestrationReadModel;
|
||||
}): Effect.fn.Return<
|
||||
DecideOrchestrationCommandResult,
|
||||
OrchestrationCommandInvariantError | PlatformError.PlatformError,
|
||||
Crypto.Crypto
|
||||
> {
|
||||
}): Effect.fn.Return<DecideOrchestrationCommandResult, OrchestrationCommandInvariantError> {
|
||||
switch (command.type) {
|
||||
case "project.create": {
|
||||
yield* requireProjectAbsent({
|
||||
@@ -113,12 +92,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "project",
|
||||
aggregateId: command.projectId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "project.created",
|
||||
payload: {
|
||||
projectId: command.projectId,
|
||||
@@ -140,12 +119,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "project",
|
||||
aggregateId: command.projectId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "project.meta-updated",
|
||||
payload: {
|
||||
projectId: command.projectId,
|
||||
@@ -197,12 +176,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "project",
|
||||
aggregateId: command.projectId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "project.deleted" as const,
|
||||
payload: {
|
||||
projectId: command.projectId,
|
||||
@@ -223,12 +202,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.created",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -253,12 +232,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.deleted",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -275,12 +254,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.archived",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -298,12 +277,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.unarchived",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -320,12 +299,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.meta-updated",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -348,12 +327,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.runtime-mode-set",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -371,12 +350,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
const occurredAt = yield* nowIso;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.interaction-mode-set",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -417,12 +396,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
});
|
||||
}
|
||||
const userMessageEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.message-sent",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -437,12 +416,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
},
|
||||
};
|
||||
const turnStartRequestedEvent: Omit<OrchestrationEvent, "sequence"> = {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
causationEventId: userMessageEvent.eventId,
|
||||
type: "thread.turn-start-requested",
|
||||
payload: {
|
||||
@@ -468,12 +447,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.turn-interrupt-requested",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -490,7 +469,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
@@ -498,7 +477,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
metadata: {
|
||||
requestId: command.requestId,
|
||||
},
|
||||
})),
|
||||
}),
|
||||
type: "thread.approval-response-requested",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -516,7 +495,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
@@ -524,7 +503,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
metadata: {
|
||||
requestId: command.requestId,
|
||||
},
|
||||
})),
|
||||
}),
|
||||
type: "thread.user-input-response-requested",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -542,12 +521,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.checkpoint-revert-requested",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -564,12 +543,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.session-stop-requested",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -585,13 +564,13 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
metadata: {},
|
||||
})),
|
||||
}),
|
||||
type: "thread.session-set",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -607,12 +586,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.message-sent",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -634,12 +613,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.message-sent",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -661,12 +640,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.proposed-plan-upserted",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -682,12 +661,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.turn-diff-completed",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -709,12 +688,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
})),
|
||||
}),
|
||||
type: "thread.reverted",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
@@ -738,13 +717,13 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
.requestId as OrchestrationEvent["metadata"]["requestId"])
|
||||
: undefined;
|
||||
return {
|
||||
...(yield* withEventBase({
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
...(requestId !== undefined ? { metadata: { requestId } } : {}),
|
||||
})),
|
||||
}),
|
||||
type: "thread.activity-appended",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
|
||||
@@ -252,12 +252,14 @@ export const layerConfig = (
|
||||
config: Config.Wrap<SqliteClientConfig>,
|
||||
): Layer.Layer<Client.SqlClient, Config.ConfigError> =>
|
||||
Layer.effectContext(
|
||||
Config.unwrap(config).pipe(
|
||||
Effect.flatMap(make),
|
||||
Effect.map((client) =>
|
||||
Context.make(SqliteClient, client).pipe(Context.add(Client.SqlClient, client)),
|
||||
Config.unwrap(config)
|
||||
.asEffect()
|
||||
.pipe(
|
||||
Effect.flatMap(make),
|
||||
Effect.map((client) =>
|
||||
Context.make(SqliteClient, client).pipe(Context.add(Client.SqlClient, client)),
|
||||
),
|
||||
),
|
||||
),
|
||||
).pipe(Layer.provide(Reactivity.layer));
|
||||
|
||||
export const layer = (config: SqliteClientConfig): Layer.Layer<Client.SqlClient> =>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import { assertSuccess } from "@effect/vitest/utils";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Sink from "effect/Sink";
|
||||
import * as Stream from "effect/Stream";
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
@@ -651,9 +651,7 @@ it.layer(NodeServices.layer)("launchEditorProcess", (it) => {
|
||||
Effect.gen(function* () {
|
||||
const spawnerLayer = Layer.mock(ChildProcessSpawner.ChildProcessSpawner, {});
|
||||
const result = yield* launchEditorProcess({
|
||||
command: `t3code-no-such-command-${yield* Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.randomUUIDv4),
|
||||
)}`,
|
||||
command: `t3code-no-such-command-${yield* Random.nextUUIDv4}`,
|
||||
args: [],
|
||||
}).pipe(Effect.provide(spawnerLayer), Effect.result);
|
||||
assert.equal(result._tag, "Failure");
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
import { ClaudeSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Cache from "effect/Cache";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -48,6 +47,7 @@ import {
|
||||
normalizeCommandPath,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
import { makeClaudeCapabilitiesCacheKey, makeClaudeContinuationGroupKey } from "./ClaudeHome.ts";
|
||||
const decodeClaudeSettings = Schema.decodeSync(ClaudeSettings);
|
||||
|
||||
@@ -78,10 +78,10 @@ const UPDATE = makePackageManagedProviderMaintenanceResolver({
|
||||
|
||||
export type ClaudeDriverEnv =
|
||||
| ChildProcessSpawner.ChildProcessSpawner
|
||||
| Crypto.Crypto
|
||||
| FileSystem.FileSystem
|
||||
| HttpClient.HttpClient
|
||||
| Path.Path
|
||||
| ProviderCompatibility.ProviderCompatibilityService
|
||||
| ProviderEventLoggers
|
||||
| ServerConfig;
|
||||
|
||||
@@ -114,6 +114,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const path = yield* Path.Path;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const providerCompatibility = yield* ProviderCompatibility.ProviderCompatibilityService;
|
||||
const eventLoggers = yield* ProviderEventLoggers;
|
||||
const processEnv = mergeProviderInstanceEnvironment(environment);
|
||||
const fallbackContinuationIdentity = defaultProviderContinuationIdentity({
|
||||
@@ -173,7 +174,17 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
|
||||
checkProvider,
|
||||
enrichSnapshot: ({ snapshot, publishSnapshot }) =>
|
||||
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(
|
||||
Effect.flatMap((snapshot) =>
|
||||
ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory(
|
||||
snapshot,
|
||||
maintenanceCapabilities,
|
||||
),
|
||||
),
|
||||
Effect.provideService(HttpClient.HttpClient, httpClient),
|
||||
Effect.provideService(
|
||||
ProviderCompatibility.ProviderCompatibilityService,
|
||||
providerCompatibility,
|
||||
),
|
||||
Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
|
||||
),
|
||||
refreshInterval: SNAPSHOT_REFRESH_INTERVAL,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
import { CodexSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -47,6 +46,7 @@ import {
|
||||
makePackageManagedProviderMaintenanceResolver,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
import {
|
||||
codexContinuationIdentity,
|
||||
materializeCodexShadowHome,
|
||||
@@ -70,10 +70,10 @@ const UPDATE = makePackageManagedProviderMaintenanceResolver({
|
||||
*/
|
||||
export type CodexDriverEnv =
|
||||
| ChildProcessSpawner.ChildProcessSpawner
|
||||
| Crypto.Crypto
|
||||
| FileSystem.FileSystem
|
||||
| HttpClient.HttpClient
|
||||
| Path.Path
|
||||
| ProviderCompatibility.ProviderCompatibilityService
|
||||
| ProviderEventLoggers
|
||||
| ServerConfig;
|
||||
|
||||
@@ -111,6 +111,7 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
|
||||
Effect.gen(function* () {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const providerCompatibility = yield* ProviderCompatibility.ProviderCompatibilityService;
|
||||
const eventLoggers = yield* ProviderEventLoggers;
|
||||
const processEnv = mergeProviderInstanceEnvironment(environment);
|
||||
const homeLayout = yield* resolveCodexHomeLayout(config);
|
||||
@@ -173,7 +174,17 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
|
||||
checkProvider,
|
||||
enrichSnapshot: ({ snapshot, publishSnapshot }) =>
|
||||
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(
|
||||
Effect.flatMap((snapshot) =>
|
||||
ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory(
|
||||
snapshot,
|
||||
maintenanceCapabilities,
|
||||
),
|
||||
),
|
||||
Effect.provideService(HttpClient.HttpClient, httpClient),
|
||||
Effect.provideService(
|
||||
ProviderCompatibility.ProviderCompatibilityService,
|
||||
providerCompatibility,
|
||||
),
|
||||
Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
|
||||
),
|
||||
refreshInterval: SNAPSHOT_REFRESH_INTERVAL,
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
import { CursorSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -46,6 +45,7 @@ import {
|
||||
makeStaticProviderMaintenanceResolver,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
const decodeCursorSettings = Schema.decodeSync(CursorSettings);
|
||||
|
||||
const DRIVER_KIND = ProviderDriverKind.make("cursor");
|
||||
@@ -62,10 +62,10 @@ const UPDATE = makeStaticProviderMaintenanceResolver(
|
||||
|
||||
export type CursorDriverEnv =
|
||||
| ChildProcessSpawner.ChildProcessSpawner
|
||||
| Crypto.Crypto
|
||||
| FileSystem.FileSystem
|
||||
| HttpClient.HttpClient
|
||||
| Path.Path
|
||||
| ProviderCompatibility.ProviderCompatibilityService
|
||||
| ProviderEventLoggers
|
||||
| ServerConfig;
|
||||
|
||||
@@ -99,6 +99,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const providerCompatibility = yield* ProviderCompatibility.ProviderCompatibilityService;
|
||||
const eventLoggers = yield* ProviderEventLoggers;
|
||||
const processEnv = mergeProviderInstanceEnvironment(environment);
|
||||
const continuationIdentity = defaultProviderContinuationIdentity({
|
||||
@@ -152,7 +153,13 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
publishSnapshot,
|
||||
stampIdentity,
|
||||
httpClient,
|
||||
}).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner)),
|
||||
}).pipe(
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
Effect.provideService(
|
||||
ProviderCompatibility.ProviderCompatibilityService,
|
||||
providerCompatibility,
|
||||
),
|
||||
),
|
||||
refreshInterval: SNAPSHOT_REFRESH_INTERVAL,
|
||||
}).pipe(
|
||||
Effect.mapError(
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
import { OpenCodeSettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
@@ -47,6 +46,7 @@ import {
|
||||
normalizeCommandPath,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "../providerMaintenance.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
const decodeOpenCodeSettings = Schema.decodeSync(OpenCodeSettings);
|
||||
|
||||
const DRIVER_KIND = ProviderDriverKind.make("opencode");
|
||||
@@ -74,11 +74,11 @@ const UPDATE = makePackageManagedProviderMaintenanceResolver({
|
||||
|
||||
export type OpenCodeDriverEnv =
|
||||
| ChildProcessSpawner.ChildProcessSpawner
|
||||
| Crypto.Crypto
|
||||
| FileSystem.FileSystem
|
||||
| HttpClient.HttpClient
|
||||
| OpenCodeRuntime
|
||||
| Path.Path
|
||||
| ProviderCompatibility.ProviderCompatibilityService
|
||||
| ProviderEventLoggers
|
||||
| ServerConfig;
|
||||
|
||||
@@ -111,6 +111,7 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
|
||||
const openCodeRuntime = yield* OpenCodeRuntime;
|
||||
const serverConfig = yield* ServerConfig;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const providerCompatibility = yield* ProviderCompatibility.ProviderCompatibilityService;
|
||||
const eventLoggers = yield* ProviderEventLoggers;
|
||||
const processEnv = mergeProviderInstanceEnvironment(environment);
|
||||
const continuationIdentity = defaultProviderContinuationIdentity({
|
||||
@@ -152,7 +153,17 @@ export const OpenCodeDriver: ProviderDriver<OpenCodeSettings, OpenCodeDriverEnv>
|
||||
checkProvider,
|
||||
enrichSnapshot: ({ snapshot, publishSnapshot }) =>
|
||||
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(
|
||||
Effect.flatMap((snapshot) =>
|
||||
ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory(
|
||||
snapshot,
|
||||
maintenanceCapabilities,
|
||||
),
|
||||
),
|
||||
Effect.provideService(HttpClient.HttpClient, httpClient),
|
||||
Effect.provideService(
|
||||
ProviderCompatibility.ProviderCompatibilityService,
|
||||
providerCompatibility,
|
||||
),
|
||||
Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot)),
|
||||
),
|
||||
refreshInterval: SNAPSHOT_REFRESH_INTERVAL,
|
||||
|
||||
@@ -52,7 +52,6 @@ import {
|
||||
resolvePromptInjectedEffort,
|
||||
} from "@t3tools/shared/model";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -61,6 +60,7 @@ import * as FileSystem from "effect/FileSystem";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Queue from "effect/Queue";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Ref from "effect/Ref";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Stream from "effect/Stream";
|
||||
@@ -998,7 +998,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const serverConfig = yield* ServerConfig;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const claudeEnvironment = yield* makeClaudeEnvironment(claudeSettings, options?.environment).pipe(
|
||||
Effect.provideService(Path.Path, path),
|
||||
);
|
||||
@@ -1025,18 +1024,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
const runtimeEventQueue = yield* Queue.unbounded<ProviderRuntimeEvent>();
|
||||
|
||||
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
|
||||
const randomUUIDv4 = crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new ProviderAdapterRequestError({
|
||||
provider: PROVIDER,
|
||||
method: "crypto/randomUUIDv4",
|
||||
detail: "Failed to generate Claude runtime identifier.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const nextEventId = Effect.map(randomUUIDv4, (id) => EventId.make(id));
|
||||
const nextEventId = Effect.map(Random.nextUUIDv4, (id) => EventId.make(id));
|
||||
const makeEventStamp = () => Effect.all({ eventId: nextEventId, createdAt: nowIso });
|
||||
|
||||
const offerRuntimeEvent = (event: ProviderRuntimeEvent): Effect.Effect<void> =>
|
||||
@@ -1060,7 +1048,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
id:
|
||||
"uuid" in message && typeof message.uuid === "string"
|
||||
? message.uuid
|
||||
: yield* randomUUIDv4,
|
||||
: yield* Random.nextUUIDv4,
|
||||
kind: "notification",
|
||||
provider: PROVIDER,
|
||||
createdAt: observedAt,
|
||||
@@ -1144,7 +1132,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
}
|
||||
|
||||
const block: AssistantTextBlockState = {
|
||||
itemId: yield* randomUUIDv4,
|
||||
itemId: yield* Random.nextUUIDv4,
|
||||
blockIndex,
|
||||
emittedTextDelta: false,
|
||||
fallbackText: options?.fallbackText ?? "",
|
||||
@@ -1977,7 +1965,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
// Auto-start a synthetic turn for assistant messages that arrive without
|
||||
// an active turn (e.g., background agent/subagent responses between user prompts).
|
||||
if (!context.turnState) {
|
||||
const turnId = TurnId.make(yield* randomUUIDv4);
|
||||
const turnId = TurnId.make(yield* Random.nextUUIDv4);
|
||||
const startedAt = yield* nowIso;
|
||||
context.turnState = {
|
||||
turnId,
|
||||
@@ -2390,17 +2378,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
toProcessError(cause, "Claude runtime stream failed.", context.session.threadId),
|
||||
).pipe(
|
||||
Stream.takeWhile(() => !context.stopped),
|
||||
Stream.runForEach((message) =>
|
||||
handleSdkMessage(context, message).pipe(
|
||||
Effect.mapError((cause) =>
|
||||
toProcessError(
|
||||
cause,
|
||||
"Failed to process Claude runtime event.",
|
||||
context.session.threadId,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Stream.runForEach((message) => handleSdkMessage(context, message)),
|
||||
);
|
||||
|
||||
const handleStreamExit = Effect.fn("handleStreamExit")(function* (
|
||||
@@ -2574,7 +2552,8 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
const resumeState = readClaudeResumeState(input.resumeCursor);
|
||||
const threadId = input.threadId;
|
||||
const existingResumeSessionId = resumeState?.resume;
|
||||
const newSessionId = existingResumeSessionId === undefined ? yield* randomUUIDv4 : undefined;
|
||||
const newSessionId =
|
||||
existingResumeSessionId === undefined ? yield* Random.nextUUIDv4 : undefined;
|
||||
const sessionId = existingResumeSessionId ?? newSessionId;
|
||||
|
||||
const runtimeContext = yield* Effect.context<never>();
|
||||
@@ -2609,7 +2588,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
readonly toolUseID?: string;
|
||||
},
|
||||
) {
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const requestId = ApprovalRequestId.make(yield* Random.nextUUIDv4);
|
||||
|
||||
// Parse questions from the SDK's AskUserQuestion input.
|
||||
// `id` MUST equal the full question text — Claude SDK >= 2.1.121 looks
|
||||
@@ -2779,7 +2758,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
} satisfies PermissionResult;
|
||||
}
|
||||
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const requestId = ApprovalRequestId.make(yield* Random.nextUUIDv4);
|
||||
const requestType = classifyRequestType(toolName);
|
||||
const detail = summarizeToolRequest(toolName, toolInput);
|
||||
const decisionDeferred = yield* Deferred.make<ProviderApprovalDecision>();
|
||||
@@ -3080,11 +3059,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
if (context.streamFiber === streamFiber) {
|
||||
context.streamFiber = undefined;
|
||||
}
|
||||
return handleStreamExit(context, exit).pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logError("Failed to close Claude runtime stream.", { cause }),
|
||||
),
|
||||
);
|
||||
return handleStreamExit(context, exit);
|
||||
}),
|
||||
),
|
||||
);
|
||||
@@ -3145,7 +3120,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
});
|
||||
}
|
||||
|
||||
const turnId = TurnId.make(yield* randomUUIDv4);
|
||||
const turnId = TurnId.make(yield* Random.nextUUIDv4);
|
||||
const turnState: ClaudeTurnState = {
|
||||
turnId,
|
||||
startedAt: yield* nowIso,
|
||||
@@ -3294,12 +3269,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
emitExitEvent: false,
|
||||
}),
|
||||
{ discard: true },
|
||||
).pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logError("Failed to emit Claude session shutdown event.", { cause }),
|
||||
),
|
||||
Effect.tap(() => Queue.shutdown(runtimeEventQueue)),
|
||||
),
|
||||
).pipe(Effect.tap(() => Queue.shutdown(runtimeEventQueue))),
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -50,36 +50,6 @@ const CLAUDE_PRESENTATION = {
|
||||
} as const;
|
||||
const MINIMUM_CLAUDE_OPUS_4_7_VERSION = "2.1.111";
|
||||
const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
{
|
||||
slug: "claude-opus-4-8",
|
||||
name: "Claude Opus 4.8",
|
||||
isCustom: false,
|
||||
capabilities: createModelCapabilities({
|
||||
optionDescriptors: [
|
||||
buildSelectOptionDescriptor({
|
||||
id: "effort",
|
||||
label: "Reasoning",
|
||||
options: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium" },
|
||||
{ value: "high", label: "High" },
|
||||
{ value: "xhigh", label: "Extra High", isDefault: true },
|
||||
{ value: "max", label: "Max" },
|
||||
{ value: "ultrathink", label: "Ultrathink" },
|
||||
],
|
||||
promptInjectedValues: ["ultrathink"],
|
||||
}),
|
||||
buildSelectOptionDescriptor({
|
||||
id: "contextWindow",
|
||||
label: "Context Window",
|
||||
options: [
|
||||
{ value: "200k", label: "200k", isDefault: true },
|
||||
{ value: "1m", label: "1M" },
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
slug: "claude-opus-4-7",
|
||||
name: "Claude Opus 4.7",
|
||||
@@ -209,24 +179,22 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
},
|
||||
];
|
||||
|
||||
function supportsClaudeOpus47or48(version: string | null | undefined): boolean {
|
||||
function supportsClaudeOpus47(version: string | null | undefined): boolean {
|
||||
return version ? compareSemverVersions(version, MINIMUM_CLAUDE_OPUS_4_7_VERSION) >= 0 : false;
|
||||
}
|
||||
|
||||
function getBuiltInClaudeModelsForVersion(
|
||||
version: string | null | undefined,
|
||||
): ReadonlyArray<ServerProviderModel> {
|
||||
if (supportsClaudeOpus47or48(version)) {
|
||||
if (supportsClaudeOpus47(version)) {
|
||||
return BUILT_IN_MODELS;
|
||||
}
|
||||
return BUILT_IN_MODELS.filter(
|
||||
(model) => model.slug !== "claude-opus-4-7" && model.slug !== "claude-opus-4-8",
|
||||
);
|
||||
return BUILT_IN_MODELS.filter((model) => model.slug !== "claude-opus-4-7");
|
||||
}
|
||||
|
||||
function formatClaudeOpusUpgradeMessage(model: string, version: string | null): string {
|
||||
function formatClaudeOpus47UpgradeMessage(version: string | null): string {
|
||||
const versionLabel = version ? `v${version}` : "the installed version";
|
||||
return `Claude Code ${versionLabel} is too old for Claude Opus ${model}. Upgrade to v${MINIMUM_CLAUDE_OPUS_4_7_VERSION} or newer to access it.`;
|
||||
return `Claude Code ${versionLabel} is too old for Claude Opus 4.7. Upgrade to v${MINIMUM_CLAUDE_OPUS_4_7_VERSION} or newer to access it.`;
|
||||
}
|
||||
|
||||
export function getClaudeModelCapabilities(model: string | null | undefined): ModelCapabilities {
|
||||
@@ -649,9 +617,9 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
|
||||
claudeSettings.customModels,
|
||||
DEFAULT_CLAUDE_MODEL_CAPABILITIES,
|
||||
);
|
||||
const opus47UpgradeMessage = supportsClaudeOpus47or48(parsedVersion)
|
||||
const opus47UpgradeMessage = supportsClaudeOpus47(parsedVersion)
|
||||
? undefined
|
||||
: formatClaudeOpusUpgradeMessage("4.8", parsedVersion);
|
||||
: formatClaudeOpus47UpgradeMessage(parsedVersion);
|
||||
|
||||
const capabilities = resolveCapabilities
|
||||
? yield* resolveCapabilities(claudeSettings).pipe(Effect.orElseSucceed(() => undefined))
|
||||
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
ProviderSendTurnInput,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
@@ -1350,7 +1349,6 @@ export const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
|
||||
const boundInstanceId = options?.instanceId ?? ProviderInstanceId.make("codex");
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const serverConfig = yield* Effect.service(ServerConfig);
|
||||
const nativeEventLogger =
|
||||
options?.nativeEventLogger ??
|
||||
@@ -1408,7 +1406,6 @@ export const makeCodexAdapter = Effect.fn("makeCodexAdapter")(function* (
|
||||
const runtime = yield* createRuntime(runtimeInput).pipe(
|
||||
Effect.provideService(Scope.Scope, sessionScope),
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, childProcessSpawner),
|
||||
Effect.provideService(Crypto.Crypto, crypto),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new ProviderAdapterProcessError({
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { normalizeModelSlug } from "@t3tools/shared/model";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -26,6 +25,7 @@ import * as Layer from "effect/Layer";
|
||||
import * as Queue from "effect/Queue";
|
||||
import * as Ref from "effect/Ref";
|
||||
import * as Scope from "effect/Scope";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Stream from "effect/Stream";
|
||||
import * as SchemaIssue from "effect/SchemaIssue";
|
||||
@@ -697,12 +697,11 @@ export const makeCodexSessionRuntime = (
|
||||
): Effect.Effect<
|
||||
CodexSessionRuntimeShape,
|
||||
CodexErrors.CodexAppServerError,
|
||||
ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | Scope.Scope
|
||||
ChildProcessSpawner.ChildProcessSpawner | Scope.Scope
|
||||
> =>
|
||||
Effect.gen(function* () {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const runtimeScope = yield* Scope.Scope;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const events = yield* Queue.unbounded<ProviderEvent>();
|
||||
const pendingApprovalsRef = yield* Ref.make(new Map<ApprovalRequestId, PendingApproval>());
|
||||
const approvalCorrelationsRef = yield* Ref.make(new Map<string, ApprovalCorrelation>());
|
||||
@@ -747,15 +746,6 @@ export const makeCodexSessionRuntime = (
|
||||
);
|
||||
const serverNotifications = yield* Queue.unbounded<CodexServerNotification>();
|
||||
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
|
||||
const randomUUIDv4 = crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new CodexErrors.CodexAppServerTransportError({
|
||||
detail: "Failed to generate Codex runtime identifier.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const sessionCreatedAt = yield* nowIso;
|
||||
const initialSession = {
|
||||
@@ -775,7 +765,7 @@ export const makeCodexSessionRuntime = (
|
||||
|
||||
const emitEvent = (event: Omit<ProviderEvent, "id" | "provider" | "createdAt">) =>
|
||||
Effect.gen(function* () {
|
||||
const id = yield* randomUUIDv4;
|
||||
const id = yield* Random.nextUUIDv4;
|
||||
return yield* offerEvent({
|
||||
id: EventId.make(id),
|
||||
provider: PROVIDER,
|
||||
@@ -943,7 +933,7 @@ export const makeCodexSessionRuntime = (
|
||||
|
||||
yield* client.handleServerRequest("item/commandExecution/requestApproval", (payload) =>
|
||||
Effect.gen(function* () {
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const requestId = ApprovalRequestId.make(yield* Random.nextUUIDv4);
|
||||
const turnId = TurnId.make(payload.turnId);
|
||||
const itemId = ProviderItemId.make(payload.itemId);
|
||||
const decision = yield* Deferred.make<ProviderApprovalDecision>();
|
||||
@@ -999,7 +989,7 @@ export const makeCodexSessionRuntime = (
|
||||
|
||||
yield* client.handleServerRequest("item/fileChange/requestApproval", (payload) =>
|
||||
Effect.gen(function* () {
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const requestId = ApprovalRequestId.make(yield* Random.nextUUIDv4);
|
||||
const turnId = TurnId.make(payload.turnId);
|
||||
const itemId = ProviderItemId.make(payload.itemId);
|
||||
const decision = yield* Deferred.make<ProviderApprovalDecision>();
|
||||
@@ -1055,7 +1045,7 @@ export const makeCodexSessionRuntime = (
|
||||
|
||||
yield* client.handleServerRequest("item/tool/requestUserInput", (payload) =>
|
||||
Effect.gen(function* () {
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const requestId = ApprovalRequestId.make(yield* Random.nextUUIDv4);
|
||||
const turnId = TurnId.make(payload.turnId);
|
||||
const itemId = ProviderItemId.make(payload.itemId);
|
||||
const answers = yield* Deferred.make<ProviderUserInputAnswers>();
|
||||
@@ -1239,11 +1229,7 @@ export const makeCodexSessionRuntime = (
|
||||
status: "closed",
|
||||
activeTurnId: undefined,
|
||||
});
|
||||
yield* emitSessionEvent("session/closed", "Session stopped").pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logError("Failed to emit Codex session closed event.", { cause }),
|
||||
),
|
||||
);
|
||||
yield* emitSessionEvent("session/closed", "Session stopped");
|
||||
yield* Scope.close(runtimeScope, Exit.void);
|
||||
yield* Queue.shutdown(serverNotifications);
|
||||
yield* Queue.shutdown(events);
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
@@ -31,13 +30,13 @@ import * as FileSystem from "effect/FileSystem";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as PubSub from "effect/PubSub";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Scope from "effect/Scope";
|
||||
import * as Semaphore from "effect/Semaphore";
|
||||
import * as Stream from "effect/Stream";
|
||||
import * as SynchronizedRef from "effect/SynchronizedRef";
|
||||
import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
import * as EffectAcpErrors from "effect-acp/errors";
|
||||
import type * as EffectAcpSchema from "effect-acp/schema";
|
||||
|
||||
import { resolveAttachmentPath } from "../../attachmentStore.ts";
|
||||
@@ -63,7 +62,7 @@ import {
|
||||
type AcpSessionModeState,
|
||||
parsePermissionRequest,
|
||||
} from "../acp/AcpRuntimeModel.ts";
|
||||
import { makeAcpNativeLoggerFactory } from "../acp/AcpNativeLogging.ts";
|
||||
import { makeAcpNativeLoggers } from "../acp/AcpNativeLogging.ts";
|
||||
import { applyCursorAcpModelSelection, makeCursorAcpRuntime } from "../acp/CursorAcpSupport.ts";
|
||||
import {
|
||||
CursorAskQuestionRequest,
|
||||
@@ -315,7 +314,6 @@ export function makeCursorAdapter(
|
||||
const path = yield* Path.Path;
|
||||
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const serverConfig = yield* Effect.service(ServerConfig);
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const nativeEventLogger =
|
||||
options?.nativeEventLogger ??
|
||||
(options?.nativeEventLogPath !== undefined
|
||||
@@ -325,36 +323,14 @@ export function makeCursorAdapter(
|
||||
: undefined);
|
||||
const managedNativeEventLogger =
|
||||
options?.nativeEventLogger === undefined ? nativeEventLogger : undefined;
|
||||
const makeAcpNativeLoggers = yield* makeAcpNativeLoggerFactory();
|
||||
|
||||
const sessions = new Map<ThreadId, CursorSessionContext>();
|
||||
const threadLocksRef = yield* SynchronizedRef.make(new Map<string, Semaphore.Semaphore>());
|
||||
const runtimeEventPubSub = yield* PubSub.unbounded<ProviderRuntimeEvent>();
|
||||
|
||||
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
|
||||
const randomUUIDv4 = crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new ProviderAdapterRequestError({
|
||||
provider: PROVIDER,
|
||||
method: "crypto/randomUUIDv4",
|
||||
detail: "Failed to generate Cursor runtime identifier.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const nextEventId = Effect.map(randomUUIDv4, (id) => EventId.make(id));
|
||||
const nextEventId = Effect.map(Random.nextUUIDv4, (id) => EventId.make(id));
|
||||
const makeEventStamp = () => Effect.all({ eventId: nextEventId, createdAt: nowIso });
|
||||
const mapExtensionFailure = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
||||
effect.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new EffectAcpErrors.AcpTransportError({
|
||||
detail: "Failed to process Cursor ACP extension event.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const offerRuntimeEvent = (event: ProviderRuntimeEvent) =>
|
||||
PubSub.publish(runtimeEventPubSub, event).pipe(Effect.asVoid);
|
||||
@@ -393,7 +369,7 @@ export function makeCursorAdapter(
|
||||
{
|
||||
observedAt,
|
||||
event: {
|
||||
id: yield* randomUUIDv4,
|
||||
id: yield* Random.nextUUIDv4,
|
||||
kind: "notification",
|
||||
provider: PROVIDER,
|
||||
createdAt: observedAt,
|
||||
@@ -548,167 +524,159 @@ export function makeCursorAdapter(
|
||||
);
|
||||
const started = yield* Effect.gen(function* () {
|
||||
yield* acp.handleExtRequest("cursor/ask_question", CursorAskQuestionRequest, (params) =>
|
||||
mapExtensionFailure(
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"cursor/ask_question",
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
);
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const runtimeRequestId = RuntimeRequestId.make(requestId);
|
||||
const answers = yield* Deferred.make<ProviderUserInputAnswers>();
|
||||
pendingUserInputs.set(requestId, { answers });
|
||||
yield* offerRuntimeEvent({
|
||||
type: "user-input.requested",
|
||||
...(yield* makeEventStamp()),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
payload: { questions: extractAskQuestions(params) },
|
||||
raw: {
|
||||
source: "acp.cursor.extension",
|
||||
method: "cursor/ask_question",
|
||||
payload: params,
|
||||
},
|
||||
});
|
||||
const resolved = yield* Deferred.await(answers);
|
||||
pendingUserInputs.delete(requestId);
|
||||
yield* offerRuntimeEvent({
|
||||
type: "user-input.resolved",
|
||||
...(yield* makeEventStamp()),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
payload: { answers: resolved },
|
||||
});
|
||||
return { answers: resolved };
|
||||
}),
|
||||
),
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"cursor/ask_question",
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
);
|
||||
const requestId = ApprovalRequestId.make(crypto.randomUUID());
|
||||
const runtimeRequestId = RuntimeRequestId.make(requestId);
|
||||
const answers = yield* Deferred.make<ProviderUserInputAnswers>();
|
||||
pendingUserInputs.set(requestId, { answers });
|
||||
yield* offerRuntimeEvent({
|
||||
type: "user-input.requested",
|
||||
...(yield* makeEventStamp()),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
payload: { questions: extractAskQuestions(params) },
|
||||
raw: {
|
||||
source: "acp.cursor.extension",
|
||||
method: "cursor/ask_question",
|
||||
payload: params,
|
||||
},
|
||||
});
|
||||
const resolved = yield* Deferred.await(answers);
|
||||
pendingUserInputs.delete(requestId);
|
||||
yield* offerRuntimeEvent({
|
||||
type: "user-input.resolved",
|
||||
...(yield* makeEventStamp()),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
payload: { answers: resolved },
|
||||
});
|
||||
return { answers: resolved };
|
||||
}),
|
||||
);
|
||||
yield* acp.handleExtRequest("cursor/create_plan", CursorCreatePlanRequest, (params) =>
|
||||
mapExtensionFailure(
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"cursor/create_plan",
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
);
|
||||
yield* offerRuntimeEvent({
|
||||
type: "turn.proposed.completed",
|
||||
...(yield* makeEventStamp()),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
payload: { planMarkdown: extractPlanMarkdown(params) },
|
||||
raw: {
|
||||
source: "acp.cursor.extension",
|
||||
method: "cursor/create_plan",
|
||||
payload: params,
|
||||
},
|
||||
});
|
||||
return { accepted: true } as const;
|
||||
}),
|
||||
),
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"cursor/create_plan",
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
);
|
||||
yield* offerRuntimeEvent({
|
||||
type: "turn.proposed.completed",
|
||||
...(yield* makeEventStamp()),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
payload: { planMarkdown: extractPlanMarkdown(params) },
|
||||
raw: {
|
||||
source: "acp.cursor.extension",
|
||||
method: "cursor/create_plan",
|
||||
payload: params,
|
||||
},
|
||||
});
|
||||
return { accepted: true } as const;
|
||||
}),
|
||||
);
|
||||
yield* acp.handleExtNotification(
|
||||
"cursor/update_todos",
|
||||
CursorUpdateTodosRequest,
|
||||
(params) =>
|
||||
mapExtensionFailure(
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"cursor/update_todos",
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
);
|
||||
if (ctx) {
|
||||
yield* emitPlanUpdate(
|
||||
ctx,
|
||||
extractTodosAsPlan(params),
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
"cursor/update_todos",
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
yield* acp.handleRequestPermission((params) =>
|
||||
mapExtensionFailure(
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"session/request_permission",
|
||||
"cursor/update_todos",
|
||||
params,
|
||||
"acp.jsonrpc",
|
||||
"acp.cursor.extension",
|
||||
);
|
||||
if (input.runtimeMode === "full-access") {
|
||||
const autoApprovedOptionId = selectAutoApprovedPermissionOption(params);
|
||||
if (autoApprovedOptionId !== undefined) {
|
||||
return {
|
||||
outcome: {
|
||||
outcome: "selected" as const,
|
||||
optionId: autoApprovedOptionId,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (ctx) {
|
||||
yield* emitPlanUpdate(
|
||||
ctx,
|
||||
extractTodosAsPlan(params),
|
||||
params,
|
||||
"acp.cursor.extension",
|
||||
"cursor/update_todos",
|
||||
);
|
||||
}
|
||||
const permissionRequest = parsePermissionRequest(params);
|
||||
const requestId = ApprovalRequestId.make(yield* randomUUIDv4);
|
||||
const runtimeRequestId = RuntimeRequestId.make(requestId);
|
||||
const decision = yield* Deferred.make<ProviderApprovalDecision>();
|
||||
pendingApprovals.set(requestId, {
|
||||
decision,
|
||||
kind: permissionRequest.kind,
|
||||
});
|
||||
yield* offerRuntimeEvent(
|
||||
makeAcpRequestOpenedEvent({
|
||||
stamp: yield* makeEventStamp(),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
permissionRequest,
|
||||
detail:
|
||||
permissionRequest.detail ??
|
||||
encodeJsonStringForDiagnostics(params)?.slice(0, 2000) ??
|
||||
"[unserializable params]",
|
||||
args: params,
|
||||
source: "acp.jsonrpc",
|
||||
method: "session/request_permission",
|
||||
rawPayload: params,
|
||||
}),
|
||||
);
|
||||
const resolved = yield* Deferred.await(decision);
|
||||
pendingApprovals.delete(requestId);
|
||||
yield* offerRuntimeEvent(
|
||||
makeAcpRequestResolvedEvent({
|
||||
stamp: yield* makeEventStamp(),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
permissionRequest,
|
||||
decision: resolved,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
outcome:
|
||||
resolved === "cancel"
|
||||
? ({ outcome: "cancelled" } as const)
|
||||
: {
|
||||
outcome: "selected" as const,
|
||||
optionId: acpPermissionOutcome(resolved),
|
||||
},
|
||||
};
|
||||
}),
|
||||
),
|
||||
);
|
||||
yield* acp.handleRequestPermission((params) =>
|
||||
Effect.gen(function* () {
|
||||
yield* logNative(
|
||||
input.threadId,
|
||||
"session/request_permission",
|
||||
params,
|
||||
"acp.jsonrpc",
|
||||
);
|
||||
if (input.runtimeMode === "full-access") {
|
||||
const autoApprovedOptionId = selectAutoApprovedPermissionOption(params);
|
||||
if (autoApprovedOptionId !== undefined) {
|
||||
return {
|
||||
outcome: {
|
||||
outcome: "selected" as const,
|
||||
optionId: autoApprovedOptionId,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
const permissionRequest = parsePermissionRequest(params);
|
||||
const requestId = ApprovalRequestId.make(crypto.randomUUID());
|
||||
const runtimeRequestId = RuntimeRequestId.make(requestId);
|
||||
const decision = yield* Deferred.make<ProviderApprovalDecision>();
|
||||
pendingApprovals.set(requestId, {
|
||||
decision,
|
||||
kind: permissionRequest.kind,
|
||||
});
|
||||
yield* offerRuntimeEvent(
|
||||
makeAcpRequestOpenedEvent({
|
||||
stamp: yield* makeEventStamp(),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
permissionRequest,
|
||||
detail:
|
||||
permissionRequest.detail ??
|
||||
encodeJsonStringForDiagnostics(params)?.slice(0, 2000) ??
|
||||
"[unserializable params]",
|
||||
args: params,
|
||||
source: "acp.jsonrpc",
|
||||
method: "session/request_permission",
|
||||
rawPayload: params,
|
||||
}),
|
||||
);
|
||||
const resolved = yield* Deferred.await(decision);
|
||||
pendingApprovals.delete(requestId);
|
||||
yield* offerRuntimeEvent(
|
||||
makeAcpRequestResolvedEvent({
|
||||
stamp: yield* makeEventStamp(),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
turnId: ctx?.activeTurnId,
|
||||
requestId: runtimeRequestId,
|
||||
permissionRequest,
|
||||
decision: resolved,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
outcome:
|
||||
resolved === "cancel"
|
||||
? ({ outcome: "cancelled" } as const)
|
||||
: {
|
||||
outcome: "selected" as const,
|
||||
optionId: acpPermissionOutcome(resolved),
|
||||
},
|
||||
};
|
||||
}),
|
||||
);
|
||||
return yield* acp.start();
|
||||
}).pipe(
|
||||
@@ -842,12 +810,7 @@ export function makeCursorAdapter(
|
||||
}
|
||||
}),
|
||||
),
|
||||
).pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logError("Failed to process Cursor runtime notification.", { cause }),
|
||||
),
|
||||
Effect.forkChild,
|
||||
);
|
||||
).pipe(Effect.forkChild);
|
||||
|
||||
ctx.notificationFiber = nf;
|
||||
sessions.set(input.threadId, ctx);
|
||||
@@ -882,7 +845,7 @@ export function makeCursorAdapter(
|
||||
const sendTurn: CursorAdapterShape["sendTurn"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const ctx = yield* requireSession(input.threadId);
|
||||
const turnId = TurnId.make(yield* randomUUIDv4);
|
||||
const turnId = TurnId.make(crypto.randomUUID());
|
||||
const turnModelSelection =
|
||||
input.modelSelection?.instanceId === boundInstanceId ? input.modelSelection : undefined;
|
||||
const model = turnModelSelection?.model ?? ctx.session.model;
|
||||
@@ -1093,9 +1056,6 @@ export function makeCursorAdapter(
|
||||
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.forEach(sessions.values(), stopSessionInternal, { discard: true }).pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logError("Failed to emit Cursor session shutdown event.", { cause }),
|
||||
),
|
||||
Effect.tap(() => PubSub.shutdown(runtimeEventPubSub)),
|
||||
Effect.tap(() => managedNativeEventLogger?.close() ?? Effect.void),
|
||||
),
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
enrichProviderSnapshotWithVersionAdvisory,
|
||||
type ProviderMaintenanceCapabilities,
|
||||
} from "../providerMaintenance.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
import { AcpSessionRuntime } from "../acp/AcpSessionRuntime.ts";
|
||||
|
||||
const PROVIDER = ProviderDriverKind.make("cursor");
|
||||
@@ -1234,7 +1235,11 @@ export const enrichCursorSnapshot = (input: {
|
||||
readonly publishSnapshot: (snapshot: ServerProvider) => Effect.Effect<void>;
|
||||
readonly stampIdentity?: (snapshot: ServerProvider) => ServerProvider;
|
||||
readonly httpClient: HttpClient.HttpClient;
|
||||
}): Effect.Effect<void, never, ChildProcessSpawner.ChildProcessSpawner> => {
|
||||
}): Effect.Effect<
|
||||
void,
|
||||
never,
|
||||
ChildProcessSpawner.ChildProcessSpawner | ProviderCompatibility.ProviderCompatibilityService
|
||||
> => {
|
||||
const { settings, snapshot, publishSnapshot } = input;
|
||||
const stampIdentity = input.stampIdentity ?? ((value) => value);
|
||||
|
||||
@@ -1242,6 +1247,12 @@ export const enrichCursorSnapshot = (input: {
|
||||
snapshot,
|
||||
input.maintenanceCapabilities,
|
||||
).pipe(
|
||||
Effect.flatMap((enrichedSnapshot) =>
|
||||
ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory(
|
||||
enrichedSnapshot,
|
||||
input.maintenanceCapabilities,
|
||||
),
|
||||
),
|
||||
Effect.provideService(HttpClient.HttpClient, input.httpClient),
|
||||
Effect.flatMap((enrichedSnapshot) =>
|
||||
publishSnapshot(stampIdentity(enrichedSnapshot)).pipe(Effect.as(enrichedSnapshot)),
|
||||
|
||||
@@ -13,11 +13,11 @@ import {
|
||||
type UserInputQuestion,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Queue from "effect/Queue";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Ref from "effect/Ref";
|
||||
import * as Scope from "effect/Scope";
|
||||
import * as Stream from "effect/Stream";
|
||||
@@ -134,14 +134,40 @@ const toProcessError = (threadId: ThreadId, cause: unknown): ProviderAdapterProc
|
||||
cause,
|
||||
});
|
||||
|
||||
type EventBaseInput = {
|
||||
const buildEventBase = (input: {
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId?: TurnId | undefined;
|
||||
readonly itemId?: string | undefined;
|
||||
readonly requestId?: string | undefined;
|
||||
readonly createdAt?: string | undefined;
|
||||
readonly raw?: unknown;
|
||||
};
|
||||
}): Effect.Effect<
|
||||
Pick<
|
||||
ProviderRuntimeEvent,
|
||||
"eventId" | "provider" | "threadId" | "createdAt" | "turnId" | "itemId" | "requestId" | "raw"
|
||||
>
|
||||
> =>
|
||||
Effect.gen(function* () {
|
||||
const uuid = yield* Random.nextUUIDv4;
|
||||
const createdAt = input.createdAt ?? (yield* nowIso);
|
||||
return {
|
||||
eventId: EventId.make(uuid),
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
createdAt,
|
||||
...(input.turnId ? { turnId: input.turnId } : {}),
|
||||
...(input.itemId ? { itemId: RuntimeItemId.make(input.itemId) } : {}),
|
||||
...(input.requestId ? { requestId: RuntimeRequestId.make(input.requestId) } : {}),
|
||||
...(input.raw !== undefined
|
||||
? {
|
||||
raw: {
|
||||
source: "opencode.sdk.event",
|
||||
payload: input.raw,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
});
|
||||
|
||||
function toToolLifecycleItemType(toolName: string): ToolLifecycleItemType {
|
||||
const normalized = toolName.toLowerCase();
|
||||
@@ -431,7 +457,6 @@ export function makeOpenCodeAdapter(
|
||||
const boundInstanceId = options?.instanceId ?? ProviderInstanceId.make("opencode");
|
||||
const serverConfig = yield* ServerConfig;
|
||||
const openCodeRuntime = yield* OpenCodeRuntime;
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const nativeEventLogger =
|
||||
options?.nativeEventLogger ??
|
||||
(options?.nativeEventLogPath !== undefined
|
||||
@@ -445,40 +470,6 @@ export function makeOpenCodeAdapter(
|
||||
options?.nativeEventLogger === undefined ? nativeEventLogger : undefined;
|
||||
const runtimeEvents = yield* Queue.unbounded<ProviderRuntimeEvent>();
|
||||
const sessions = new Map<ThreadId, OpenCodeSessionContext>();
|
||||
const randomUUIDv4 = crypto.randomUUIDv4.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new ProviderAdapterRequestError({
|
||||
provider: PROVIDER,
|
||||
method: "crypto/randomUUIDv4",
|
||||
detail: "Failed to generate OpenCode runtime identifier.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
const buildEventBase = (input: EventBaseInput) =>
|
||||
Effect.all({
|
||||
eventId: randomUUIDv4.pipe(Effect.map(EventId.make)),
|
||||
createdAt: input.createdAt === undefined ? nowIso : Effect.succeed(input.createdAt),
|
||||
}).pipe(
|
||||
Effect.map(({ eventId, createdAt }) => ({
|
||||
eventId,
|
||||
provider: PROVIDER,
|
||||
threadId: input.threadId,
|
||||
createdAt,
|
||||
...(input.turnId ? { turnId: input.turnId } : {}),
|
||||
...(input.itemId ? { itemId: RuntimeItemId.make(input.itemId) } : {}),
|
||||
...(input.requestId ? { requestId: RuntimeRequestId.make(input.requestId) } : {}),
|
||||
...(input.raw !== undefined
|
||||
? {
|
||||
raw: {
|
||||
source: "opencode.sdk.event" as const,
|
||||
payload: input.raw,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
})),
|
||||
);
|
||||
|
||||
// Layer-level finalizer: when the adapter layer shuts down, stop every
|
||||
// session. Each session's `Scope.close` tears down its spawned OpenCode
|
||||
@@ -1151,7 +1142,7 @@ export function makeOpenCodeAdapter(
|
||||
|
||||
const sendTurn: OpenCodeAdapterShape["sendTurn"] = Effect.fn("sendTurn")(function* (input) {
|
||||
const context = ensureSessionContext(sessions, input.threadId);
|
||||
const turnId = TurnId.make(`opencode-turn-${yield* randomUUIDv4}`);
|
||||
const turnId = TurnId.make(`opencode-turn-${yield* Random.nextUUIDv4}`);
|
||||
const modelSelection =
|
||||
input.modelSelection ??
|
||||
(context.session.model
|
||||
|
||||
@@ -43,6 +43,7 @@ import { CodexDriver } from "../Drivers/CodexDriver.ts";
|
||||
import { CursorDriver } from "../Drivers/CursorDriver.ts";
|
||||
import { OpenCodeDriver } from "../Drivers/OpenCodeDriver.ts";
|
||||
import { OpenCodeRuntimeLive } from "../opencodeRuntime.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
import { NoOpProviderEventLoggers, ProviderEventLoggers } from "./ProviderEventLoggers.ts";
|
||||
import { makeProviderInstanceRegistry } from "./ProviderInstanceRegistryLive.ts";
|
||||
|
||||
@@ -52,6 +53,9 @@ const TestHttpClientLive = Layer.succeed(
|
||||
Effect.succeed(HttpClientResponse.fromWeb(request, Response.json({ version: "0.0.0" }))),
|
||||
),
|
||||
);
|
||||
const TestProviderCompatibilityLive = ProviderCompatibility.layer.pipe(
|
||||
Layer.provide(TestHttpClientLive),
|
||||
);
|
||||
|
||||
const makeCodexConfig = (overrides: Partial<CodexSettings>): CodexSettings => ({
|
||||
enabled: false,
|
||||
@@ -99,6 +103,7 @@ describe("ProviderInstanceRegistryLive — multi-instance codex slice", () => {
|
||||
}).pipe(
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
Layer.provideMerge(TestHttpClientLive),
|
||||
Layer.provideMerge(TestProviderCompatibilityLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers)),
|
||||
);
|
||||
|
||||
@@ -236,6 +241,7 @@ describe("ProviderInstanceRegistryLive — all drivers slice", () => {
|
||||
}).pipe(
|
||||
Layer.provideMerge(infraLayer),
|
||||
Layer.provideMerge(TestHttpClientLive),
|
||||
Layer.provideMerge(TestProviderCompatibilityLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers)),
|
||||
);
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import { readProviderStatusCache, resolveProviderStatusCachePath } from "../prov
|
||||
import type { ProviderInstance } from "../ProviderDriver.ts";
|
||||
import { ProviderInstanceRegistry } from "../Services/ProviderInstanceRegistry.ts";
|
||||
import { ProviderRegistry } from "../Services/ProviderRegistry.ts";
|
||||
import * as ProviderCompatibility from "../ProviderCompatibility.ts";
|
||||
import { makeManualOnlyProviderMaintenanceCapabilities } from "../providerMaintenance.ts";
|
||||
const decodeServerSettings = Schema.decodeSync(ServerSettings);
|
||||
const encodeServerSettings = Schema.encodeSync(ServerSettings);
|
||||
@@ -71,6 +72,9 @@ const TestHttpClientLive = Layer.succeed(
|
||||
Effect.succeed(HttpClientResponse.fromWeb(request, Response.json({ version: "0.0.0" }))),
|
||||
),
|
||||
);
|
||||
const TestProviderCompatibilityLive = ProviderCompatibility.layer.pipe(
|
||||
Layer.provide(TestHttpClientLive),
|
||||
);
|
||||
|
||||
function selectDescriptor(
|
||||
id: string,
|
||||
@@ -1027,6 +1031,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest(), T
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(TestHttpClientLive),
|
||||
Layer.provideMerge(TestProviderCompatibilityLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers)),
|
||||
Layer.provideMerge(OpenCodeRuntimeLive),
|
||||
// NO spawner mock — `ChildProcessSpawner` is supplied by the
|
||||
@@ -1102,6 +1107,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest(), T
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(TestHttpClientLive),
|
||||
Layer.provideMerge(TestProviderCompatibilityLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers)),
|
||||
Layer.provideMerge(OpenCodeRuntimeLive),
|
||||
// `it.live` does not inherit layers from the outer `it.layer`
|
||||
@@ -1205,6 +1211,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest(), T
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(TestHttpClientLive),
|
||||
Layer.provideMerge(TestProviderCompatibilityLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers)),
|
||||
Layer.provideMerge(OpenCodeRuntimeLive),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
@@ -1256,6 +1263,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest(), T
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(TestHttpClientLive),
|
||||
Layer.provideMerge(TestProviderCompatibilityLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderEventLoggers, NoOpProviderEventLoggers)),
|
||||
Layer.provideMerge(OpenCodeRuntimeLive),
|
||||
Layer.provideMerge(
|
||||
@@ -1410,7 +1418,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest(), T
|
||||
);
|
||||
assert.strictEqual(
|
||||
status.message,
|
||||
"Claude Code v2.1.110 is too old for Claude Opus 4.8. Upgrade to v2.1.111 or newer to access it.",
|
||||
"Claude Code v2.1.110 is too old for Claude Opus 4.7. Upgrade to v2.1.111 or newer to access it.",
|
||||
);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
|
||||
@@ -0,0 +1,529 @@
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import { HttpClient, HttpClientResponse } from "effect/unstable/http";
|
||||
|
||||
import * as ProviderCompatibility from "./ProviderCompatibility.ts";
|
||||
import { makeProviderMaintenanceCapabilities } from "./providerMaintenance.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: [],
|
||||
};
|
||||
|
||||
const codexNpmUpdateCapabilities = makeProviderMaintenanceCapabilities({
|
||||
provider: codexDriver,
|
||||
packageName: "@openai/codex",
|
||||
updateExecutable: "npm",
|
||||
updateArgs: ["install", "-g", "@openai/codex@latest"],
|
||||
updateLockKey: "npm-global",
|
||||
});
|
||||
|
||||
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" },
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const provideCompatibility = (
|
||||
responseForUrl: (url: string) => { readonly payload: unknown; readonly status?: number },
|
||||
) =>
|
||||
Effect.provide(
|
||||
ProviderCompatibility.layer.pipe(
|
||||
Layer.provide(Layer.succeed(HttpClient.HttpClient, jsonHttpClient(responseForUrl))),
|
||||
),
|
||||
);
|
||||
|
||||
describe("provider compatibility", () => {
|
||||
it("selects policies by T3 Code version range", () => {
|
||||
const document: ProviderCompatibility.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(
|
||||
ProviderCompatibility.createProviderCompatibilityAdvisory({
|
||||
driver: codexDriver,
|
||||
currentVersion: "0.130.0",
|
||||
document,
|
||||
t3CodeVersion: "0.0.22",
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: "broken",
|
||||
recommendedVersion: "0.129.0",
|
||||
});
|
||||
});
|
||||
|
||||
it("adds a targeted compatibility update command when a recommended version is available", () => {
|
||||
const document: ProviderCompatibility.ProviderCompatibilityDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: codexDriver,
|
||||
recommendedRange: ">=0.129.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: "<0.129.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(
|
||||
ProviderCompatibility.createProviderCompatibilityAdvisory({
|
||||
driver: codexDriver,
|
||||
currentVersion: "0.128.0",
|
||||
document,
|
||||
maintenanceCapabilities: codexNpmUpdateCapabilities,
|
||||
}),
|
||||
).toMatchObject({
|
||||
status: "broken",
|
||||
canUpdate: true,
|
||||
updateCommand: "npm install -g @openai/[email protected]",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not warn on disabled providers before their version has been probed", () => {
|
||||
const enriched = ProviderCompatibility.applyBundledProviderCompatibilityAdvisory({
|
||||
snapshot: {
|
||||
...baseProvider,
|
||||
driver: cursorDriver,
|
||||
enabled: false,
|
||||
version: null,
|
||||
status: "disabled",
|
||||
},
|
||||
driver: cursorDriver,
|
||||
currentVersion: null,
|
||||
});
|
||||
|
||||
expect(enriched.compatibilityAdvisory).toBeUndefined();
|
||||
expect(enriched.status).toBe("disabled");
|
||||
});
|
||||
|
||||
it("classifies the bundled compatibility policies for current T3 Code builds", () => {
|
||||
const document: ProviderCompatibility.ProviderCompatibilityDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
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.0",
|
||||
driver: claudeDriver,
|
||||
recommendedRange: ">=0.2.111",
|
||||
recommendedVersion: "0.2.111",
|
||||
ranges: [{ status: "supported", range: ">=0.2.111" }],
|
||||
},
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
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.0",
|
||||
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) =>
|
||||
ProviderCompatibility.createProviderCompatibilityAdvisory({
|
||||
driver,
|
||||
currentVersion,
|
||||
document,
|
||||
t3CodeVersion: "0.0.22",
|
||||
})?.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: ProviderCompatibility.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(
|
||||
ProviderCompatibility.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* ProviderCompatibility.enrichProviderSnapshotWithTargetedCompatibilityAdvisory(
|
||||
baseProvider,
|
||||
codexNpmUpdateCapabilities,
|
||||
).pipe(provideCompatibility(() => ({ payload: remoteDocument })));
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({
|
||||
status: "broken",
|
||||
recommendedVersion: "0.129.0",
|
||||
canUpdate: true,
|
||||
updateCommand: "npm install -g @openai/[email protected]",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("caches remote compatibility documents within the service layer", () => {
|
||||
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* () {
|
||||
yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider);
|
||||
yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider);
|
||||
|
||||
expect(requestedUrls).toEqual([ProviderCompatibility.DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL]);
|
||||
}).pipe(
|
||||
provideCompatibility((url) => {
|
||||
requestedUrls.push(url);
|
||||
return { payload: remoteDocument };
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("does not cache failed remote compatibility fetches", () => {
|
||||
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[] = [];
|
||||
let attempt = 0;
|
||||
|
||||
return Effect.gen(function* () {
|
||||
yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider);
|
||||
const enriched =
|
||||
yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(baseProvider);
|
||||
|
||||
expect(requestedUrls).toEqual([
|
||||
ProviderCompatibility.DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
ProviderCompatibility.GITHUB_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
ProviderCompatibility.DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
]);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "broken" });
|
||||
}).pipe(
|
||||
provideCompatibility((url) => {
|
||||
requestedUrls.push(url);
|
||||
attempt += 1;
|
||||
return attempt === 3 ? { payload: remoteDocument } : { payload: {}, status: 404 };
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
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* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(
|
||||
baseProvider,
|
||||
).pipe(
|
||||
provideCompatibility((url) => {
|
||||
requestedUrls.push(url);
|
||||
return url === ProviderCompatibility.GITHUB_PROVIDER_COMPATIBILITY_MAP_URL
|
||||
? { payload: remoteDocument }
|
||||
: { payload: {}, status: 404 };
|
||||
}),
|
||||
);
|
||||
|
||||
expect(requestedUrls).toEqual([
|
||||
ProviderCompatibility.DEFAULT_PROVIDER_COMPATIBILITY_MAP_URL,
|
||||
ProviderCompatibility.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* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(
|
||||
baseProvider,
|
||||
).pipe(
|
||||
provideCompatibility((url) => {
|
||||
requestedUrls.push(url);
|
||||
return url === ProviderCompatibility.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([ProviderCompatibility.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* ProviderCompatibility.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(provideCompatibility(() => ({ 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* ProviderCompatibility.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(provideCompatibility(() => ({ payload: remoteDocument })));
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.message).toBe(probeErrorMessage);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "supported" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("keeps probe error messages when warning advisories do not change status", () => {
|
||||
const probeErrorMessage = "Authentication failed";
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: ">=0.130.0",
|
||||
recommendedVersion: "0.130.0",
|
||||
ranges: [{ status: "graceful", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const enriched = yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(
|
||||
{
|
||||
...baseProvider,
|
||||
status: "error",
|
||||
message: probeErrorMessage,
|
||||
},
|
||||
).pipe(provideCompatibility(() => ({ payload: remoteDocument })));
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.message).toBe(probeErrorMessage);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "graceful" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("falls back to the bundled map when the remote compatibility fetch fails", () =>
|
||||
Effect.gen(function* () {
|
||||
const enriched = yield* ProviderCompatibility.enrichProviderSnapshotWithCompatibilityAdvisory(
|
||||
{
|
||||
...baseProvider,
|
||||
version: "0.128.0",
|
||||
},
|
||||
).pipe(provideCompatibility(() => ({ payload: {}, status: 404 })));
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "broken" });
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,425 @@
|
||||
import {
|
||||
ProviderDriverKind,
|
||||
TrimmedNonEmptyString,
|
||||
type ServerProvider,
|
||||
type ServerProviderCompatibilityAdvisory,
|
||||
} from "@t3tools/contracts";
|
||||
import { satisfiesSemverRange } from "@t3tools/shared/semver";
|
||||
import * as Cache from "effect/Cache";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Layer from "effect/Layer";
|
||||
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" };
|
||||
import {
|
||||
makeTargetedProviderUpdateAction,
|
||||
type ProviderMaintenanceCapabilities,
|
||||
} from "./providerMaintenance.ts";
|
||||
|
||||
const T3_CODE_VERSION = packageJson.version;
|
||||
const REMOTE_COMPATIBILITY_CACHE_TTL = Duration.minutes(15);
|
||||
const REMOTE_COMPATIBILITY_TIMEOUT = "2500 millis";
|
||||
const REMOTE_COMPATIBILITY_CACHE_CAPACITY = 8;
|
||||
|
||||
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 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),
|
||||
});
|
||||
|
||||
export type ProviderCompatibilityDocument = typeof RemoteCompatibilityDocument.Type;
|
||||
|
||||
type ProviderCompatibilitySnapshot = Pick<ServerProvider, "enabled" | "status" | "message"> & {
|
||||
readonly compatibilityAdvisory?: ServerProviderCompatibilityAdvisory | undefined;
|
||||
};
|
||||
|
||||
const decodeCompatibilityDocument = Schema.decodeUnknownEffect(RemoteCompatibilityDocument);
|
||||
|
||||
/**
|
||||
* 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 = Schema.decodeUnknownSync(RemoteCompatibilityDocument)(
|
||||
bundledCompatibilityDocumentJson,
|
||||
);
|
||||
|
||||
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: typeof RemoteCompatibilityPolicy.Type;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly t3CodeVersion: string;
|
||||
}): boolean {
|
||||
return (
|
||||
input.policy.driver === input.driver &&
|
||||
satisfiesSemverRange(input.t3CodeVersion, input.policy.t3CodeRange)
|
||||
);
|
||||
}
|
||||
|
||||
function compatibilityPolicyForDriver(input: {
|
||||
readonly document: typeof RemoteCompatibilityDocument.Type;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly t3CodeVersion?: string;
|
||||
}): typeof RemoteCompatibilityPolicy.Type | 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: typeof RemoteCompatibilityDocument.Type;
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly currentVersion: string | null;
|
||||
readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined;
|
||||
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;
|
||||
const targetedUpdateAction = input.maintenanceCapabilities
|
||||
? makeTargetedProviderUpdateAction(input.maintenanceCapabilities, recommendedVersion)
|
||||
: null;
|
||||
|
||||
return {
|
||||
status,
|
||||
severity: severityForStatus(status),
|
||||
currentVersion: input.currentVersion,
|
||||
message: messageForStatus({
|
||||
status,
|
||||
currentVersion: input.currentVersion,
|
||||
recommendedRange: policy.recommendedRange,
|
||||
recommendedVersion,
|
||||
}),
|
||||
recommendedRange: policy.recommendedRange,
|
||||
recommendedVersion,
|
||||
updateCommand: targetedUpdateAction?.command ?? null,
|
||||
canUpdate: targetedUpdateAction !== null,
|
||||
ranges: [...policy.ranges],
|
||||
};
|
||||
}
|
||||
|
||||
function shouldSkipCompatibilityAdvisory(input: {
|
||||
readonly snapshot: ProviderCompatibilitySnapshot;
|
||||
readonly currentVersion: string | null;
|
||||
}): boolean {
|
||||
return !input.snapshot.enabled && input.currentVersion === null;
|
||||
}
|
||||
|
||||
export function createProviderCompatibilityAdvisory(input: {
|
||||
readonly driver: ProviderDriverKind;
|
||||
readonly currentVersion: string | null;
|
||||
readonly document?: typeof RemoteCompatibilityDocument.Type;
|
||||
readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined;
|
||||
readonly t3CodeVersion?: string;
|
||||
}): ServerProviderCompatibilityAdvisory | undefined {
|
||||
return createProviderCompatibilityAdvisoryFromDocument({
|
||||
document: input.document ?? bundledProviderCompatibilityDocument,
|
||||
driver: input.driver,
|
||||
currentVersion: input.currentVersion,
|
||||
maintenanceCapabilities: input.maintenanceCapabilities,
|
||||
...(input.t3CodeVersion ? { t3CodeVersion: input.t3CodeVersion } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
const fetchRemoteCompatibilityDocument = Effect.fn("fetchRemoteCompatibilityDocument")(
|
||||
function* (url: string) {
|
||||
const client = yield* HttpClient.HttpClient;
|
||||
const response = yield* client
|
||||
.execute(
|
||||
HttpClientRequest.get(url).pipe(
|
||||
HttpClientRequest.acceptJson,
|
||||
HttpClientRequest.setHeader("user-agent", `t3code/${T3_CODE_VERSION}`),
|
||||
),
|
||||
)
|
||||
.pipe(Effect.timeoutOption(REMOTE_COMPATIBILITY_TIMEOUT));
|
||||
|
||||
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;
|
||||
},
|
||||
(effect, url) =>
|
||||
effect.pipe(
|
||||
Effect.tapError((cause) =>
|
||||
Effect.logWarning("provider compatibility map fetch failed", {
|
||||
cause,
|
||||
url,
|
||||
}),
|
||||
),
|
||||
Effect.catch(() => Effect.succeed(null)),
|
||||
),
|
||||
);
|
||||
|
||||
function applyCompatibilityAdvisory<Snapshot extends ProviderCompatibilitySnapshot>(
|
||||
snapshot: Snapshot,
|
||||
compatibilityAdvisory: ServerProviderCompatibilityAdvisory | undefined,
|
||||
): Snapshot {
|
||||
const baseSnapshot = removeExistingCompatibilityAdvisory(snapshot);
|
||||
if (!compatibilityAdvisory) {
|
||||
return baseSnapshot;
|
||||
}
|
||||
|
||||
const status =
|
||||
baseSnapshot.enabled && compatibilityAdvisory.severity === "error"
|
||||
? "error"
|
||||
: baseSnapshot.enabled &&
|
||||
compatibilityAdvisory.severity === "warning" &&
|
||||
baseSnapshot.status === "ready"
|
||||
? "warning"
|
||||
: baseSnapshot.status;
|
||||
const compatibilityMessage =
|
||||
status !== baseSnapshot.status && compatibilityAdvisory.severity !== "info"
|
||||
? (compatibilityAdvisory.message ?? undefined)
|
||||
: undefined;
|
||||
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;
|
||||
readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined;
|
||||
}): Snapshot {
|
||||
if (
|
||||
shouldSkipCompatibilityAdvisory({
|
||||
snapshot: input.snapshot,
|
||||
currentVersion: input.currentVersion,
|
||||
})
|
||||
) {
|
||||
return removeExistingCompatibilityAdvisory(input.snapshot);
|
||||
}
|
||||
|
||||
return applyCompatibilityAdvisory(
|
||||
input.snapshot,
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver: input.driver,
|
||||
currentVersion: input.currentVersion,
|
||||
maintenanceCapabilities: input.maintenanceCapabilities,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export const enrichProviderSnapshotWithCompatibilityAdvisory = Effect.fn(
|
||||
"enrichProviderSnapshotWithCompatibilityAdvisory",
|
||||
)(function* (snapshot: ServerProvider) {
|
||||
const compatibility = yield* ProviderCompatibilityService;
|
||||
return yield* compatibility.enrichSnapshot(snapshot);
|
||||
});
|
||||
|
||||
export const enrichProviderSnapshotWithTargetedCompatibilityAdvisory = Effect.fn(
|
||||
"enrichProviderSnapshotWithTargetedCompatibilityAdvisory",
|
||||
)(function* (snapshot: ServerProvider, maintenanceCapabilities: ProviderMaintenanceCapabilities) {
|
||||
const compatibility = yield* ProviderCompatibilityService;
|
||||
return yield* compatibility.enrichSnapshot(snapshot, maintenanceCapabilities);
|
||||
});
|
||||
|
||||
export interface ProviderCompatibilityServiceShape {
|
||||
readonly resolveRemoteDocument: Effect.Effect<typeof RemoteCompatibilityDocument.Type | null>;
|
||||
readonly enrichSnapshot: (
|
||||
snapshot: ServerProvider,
|
||||
maintenanceCapabilities?: ProviderMaintenanceCapabilities | undefined,
|
||||
) => Effect.Effect<ServerProvider>;
|
||||
}
|
||||
|
||||
export class ProviderCompatibilityService extends Context.Service<
|
||||
ProviderCompatibilityService,
|
||||
ProviderCompatibilityServiceShape
|
||||
>()("t3/provider/ProviderCompatibilityService") {}
|
||||
|
||||
export const makeProviderCompatibilityService = Effect.fn("makeProviderCompatibilityService")(
|
||||
function* () {
|
||||
const remoteDocumentCache = yield* Cache.makeWith(fetchRemoteCompatibilityDocument, {
|
||||
capacity: REMOTE_COMPATIBILITY_CACHE_CAPACITY,
|
||||
timeToLive: (exit) =>
|
||||
Exit.isSuccess(exit) && exit.value !== null
|
||||
? REMOTE_COMPATIBILITY_CACHE_TTL
|
||||
: Duration.zero,
|
||||
});
|
||||
|
||||
const resolveRemoteDocument = Effect.gen(function* () {
|
||||
for (const url of remoteCompatibilityMapUrls()) {
|
||||
const document = yield* Cache.get(remoteDocumentCache, url);
|
||||
if (document) {
|
||||
return document;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
return {
|
||||
resolveRemoteDocument,
|
||||
enrichSnapshot: (snapshot, maintenanceCapabilities) =>
|
||||
resolveRemoteDocument.pipe(
|
||||
Effect.map((remoteDocument) =>
|
||||
shouldSkipCompatibilityAdvisory({
|
||||
snapshot,
|
||||
currentVersion: snapshot.version,
|
||||
})
|
||||
? removeExistingCompatibilityAdvisory(snapshot)
|
||||
: applyCompatibilityAdvisory(
|
||||
snapshot,
|
||||
createProviderCompatibilityAdvisory({
|
||||
driver: snapshot.driver,
|
||||
currentVersion: snapshot.version,
|
||||
maintenanceCapabilities,
|
||||
...(remoteDocument ? { document: remoteDocument } : {}),
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
} satisfies ProviderCompatibilityServiceShape;
|
||||
},
|
||||
);
|
||||
|
||||
export const layer = Layer.effect(ProviderCompatibilityService, makeProviderCompatibilityService());
|
||||
@@ -1,13 +1,40 @@
|
||||
import type { ProviderDriverKind, ThreadId } from "@t3tools/contracts";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Random from "effect/Random";
|
||||
import type * as EffectAcpProtocol from "effect-acp/protocol";
|
||||
|
||||
import type { EventNdjsonLogger } from "../Layers/EventNdjsonLogger.ts";
|
||||
import type { AcpSessionRequestLogEvent, AcpSessionRuntimeOptions } from "./AcpSessionRuntime.ts";
|
||||
|
||||
function writeNativeAcpLog(input: {
|
||||
readonly nativeEventLogger: EventNdjsonLogger | undefined;
|
||||
readonly provider: ProviderDriverKind;
|
||||
readonly threadId: ThreadId;
|
||||
readonly kind: "request" | "protocol";
|
||||
readonly payload: unknown;
|
||||
}): Effect.Effect<void, never> {
|
||||
return Effect.gen(function* () {
|
||||
if (!input.nativeEventLogger) return;
|
||||
const observedAt = DateTime.formatIso(yield* DateTime.now);
|
||||
yield* input.nativeEventLogger.write(
|
||||
{
|
||||
observedAt,
|
||||
event: {
|
||||
id: yield* Random.nextUUIDv4,
|
||||
kind: input.kind,
|
||||
provider: input.provider,
|
||||
createdAt: observedAt,
|
||||
threadId: input.threadId,
|
||||
payload: input.payload,
|
||||
},
|
||||
},
|
||||
input.threadId,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function formatRequestLogPayload(event: AcpSessionRequestLogEvent) {
|
||||
return {
|
||||
method: event.method,
|
||||
@@ -18,63 +45,35 @@ function formatRequestLogPayload(event: AcpSessionRequestLogEvent) {
|
||||
};
|
||||
}
|
||||
|
||||
export const makeAcpNativeLoggerFactory = Effect.fn("makeAcpNativeLoggerFactory")(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
return (input: {
|
||||
readonly nativeEventLogger: EventNdjsonLogger | undefined;
|
||||
readonly provider: ProviderDriverKind;
|
||||
readonly threadId: ThreadId;
|
||||
}): Pick<AcpSessionRuntimeOptions, "requestLogger" | "protocolLogging"> => {
|
||||
const writeNativeAcpLog = (logInput: {
|
||||
readonly kind: "request" | "protocol";
|
||||
readonly payload: unknown;
|
||||
}) =>
|
||||
Effect.gen(function* () {
|
||||
if (!input.nativeEventLogger) return;
|
||||
const observedAt = DateTime.formatIso(yield* DateTime.now);
|
||||
yield* input.nativeEventLogger.write(
|
||||
{
|
||||
observedAt,
|
||||
event: {
|
||||
id: yield* crypto.randomUUIDv4,
|
||||
kind: logInput.kind,
|
||||
provider: input.provider,
|
||||
createdAt: observedAt,
|
||||
threadId: input.threadId,
|
||||
payload: logInput.payload,
|
||||
},
|
||||
},
|
||||
input.threadId,
|
||||
);
|
||||
}).pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logWarning("Failed to write native ACP event log.", {
|
||||
cause,
|
||||
provider: input.provider,
|
||||
threadId: input.threadId,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
return {
|
||||
requestLogger: (event: AcpSessionRequestLogEvent) =>
|
||||
writeNativeAcpLog({
|
||||
kind: "request",
|
||||
payload: formatRequestLogPayload(event),
|
||||
}),
|
||||
...(input.nativeEventLogger
|
||||
? {
|
||||
protocolLogging: {
|
||||
logIncoming: true,
|
||||
logOutgoing: true,
|
||||
logger: (event: EffectAcpProtocol.AcpProtocolLogEvent) =>
|
||||
writeNativeAcpLog({
|
||||
kind: "protocol",
|
||||
payload: event,
|
||||
}),
|
||||
} satisfies NonNullable<AcpSessionRuntimeOptions["protocolLogging"]>,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
export function makeAcpNativeLoggers(input: {
|
||||
readonly nativeEventLogger: EventNdjsonLogger | undefined;
|
||||
readonly provider: ProviderDriverKind;
|
||||
readonly threadId: ThreadId;
|
||||
}): Pick<AcpSessionRuntimeOptions, "requestLogger" | "protocolLogging"> {
|
||||
return {
|
||||
requestLogger: (event) =>
|
||||
writeNativeAcpLog({
|
||||
nativeEventLogger: input.nativeEventLogger,
|
||||
provider: input.provider,
|
||||
threadId: input.threadId,
|
||||
kind: "request",
|
||||
payload: formatRequestLogPayload(event),
|
||||
}),
|
||||
...(input.nativeEventLogger
|
||||
? {
|
||||
protocolLogging: {
|
||||
logIncoming: true,
|
||||
logOutgoing: true,
|
||||
logger: (event: EffectAcpProtocol.AcpProtocolLogEvent) =>
|
||||
writeNativeAcpLog({
|
||||
nativeEventLogger: input.nativeEventLogger,
|
||||
provider: input.provider,
|
||||
threadId: input.threadId,
|
||||
kind: "protocol",
|
||||
payload: event,
|
||||
}),
|
||||
} satisfies NonNullable<AcpSessionRuntimeOptions["protocolLogging"]>,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import { afterEach, expect, it } from "@effect/vitest";
|
||||
import { afterEach, describe, expect, it } from "@effect/vitest";
|
||||
import { chmodSync, mkdirSync, symlinkSync, writeFileSync } from "node:fs";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { ProviderDriverKind } from "@t3tools/contracts";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Random from "effect/Random";
|
||||
import {
|
||||
clearLatestProviderVersionCacheForTests,
|
||||
createProviderVersionAdvisory,
|
||||
makePackageManagedProviderMaintenanceResolver,
|
||||
makeProviderMaintenanceCapabilities,
|
||||
makeStaticProviderMaintenanceResolver,
|
||||
makeTargetedProviderUpdateAction,
|
||||
normalizeCommandPath,
|
||||
resolveProviderMaintenanceCapabilitiesEffect,
|
||||
} from "./providerMaintenance.ts";
|
||||
|
||||
const driver = (value: string) => ProviderDriverKind.make(value);
|
||||
const makeTempDir = (name: string) =>
|
||||
Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.randomUUIDv4),
|
||||
Effect.map((id) => path.join(os.tmpdir(), `${name}-${id}`)),
|
||||
);
|
||||
const makeTempDir = Effect.fn("makeTempDir")(function* (name: string) {
|
||||
const id = yield* Random.nextUUIDv4;
|
||||
return path.join(os.tmpdir(), `${name}-${id}`);
|
||||
});
|
||||
const isNativeTestCommandPath =
|
||||
(expectedPathSegment: string) =>
|
||||
(commandPath: string): boolean =>
|
||||
@@ -69,7 +69,7 @@ afterEach(() => {
|
||||
clearLatestProviderVersionCacheForTests();
|
||||
});
|
||||
|
||||
it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
describe("providerMaintenance", () => {
|
||||
it("marks providers with unknown current versions as unknown", () => {
|
||||
expect(
|
||||
createProviderVersionAdvisory({
|
||||
@@ -133,6 +133,24 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
});
|
||||
});
|
||||
|
||||
it("targets package install commands that omit an explicit latest suffix", () => {
|
||||
expect(
|
||||
makeTargetedProviderUpdateAction(
|
||||
makeProviderMaintenanceCapabilities({
|
||||
provider: driver("packageTool"),
|
||||
packageName: "@example/package-tool",
|
||||
updateExecutable: "vp",
|
||||
updateArgs: ["i", "-g", "@example/package-tool"],
|
||||
updateLockKey: "vite-plus-global",
|
||||
}),
|
||||
"1.2.3",
|
||||
),
|
||||
).toMatchObject({
|
||||
command: "vp i -g @example/[email protected]",
|
||||
args: ["i", "-g", "@example/[email protected]"],
|
||||
});
|
||||
});
|
||||
|
||||
it.effect(
|
||||
"switches package-managed providers to vite-plus updates when the resolved binary lives in vite-plus global bin",
|
||||
() =>
|
||||
@@ -405,7 +423,7 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
env: {
|
||||
PATH: "",
|
||||
},
|
||||
});
|
||||
}).pipe(Effect.provide(NodeServices.layer));
|
||||
|
||||
expect(capabilities).toEqual({
|
||||
provider: driver("packageTool"),
|
||||
@@ -453,7 +471,7 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
|
||||
env: {
|
||||
PATH: "",
|
||||
},
|
||||
});
|
||||
}).pipe(Effect.provide(NodeServices.layer));
|
||||
|
||||
expect(capabilities).toEqual({
|
||||
provider: driver("packageTool"),
|
||||
|
||||
@@ -108,6 +108,32 @@ export function makeManualOnlyProviderMaintenanceCapabilities(input: {
|
||||
});
|
||||
}
|
||||
|
||||
export function makeTargetedProviderUpdateAction(
|
||||
capabilities: ProviderMaintenanceCapabilities,
|
||||
targetVersion: string | null,
|
||||
): ProviderMaintenanceCommandAction | null {
|
||||
if (!capabilities.update || !capabilities.packageName || !targetVersion) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const versionedPackageArg = `${capabilities.packageName}@latest`;
|
||||
const targetPackageArg = `${capabilities.packageName}@${targetVersion}`;
|
||||
const packageArgIndex = capabilities.update.args.findIndex(
|
||||
(arg) => arg === versionedPackageArg || arg === capabilities.packageName,
|
||||
);
|
||||
if (packageArgIndex < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const args = [...capabilities.update.args];
|
||||
args[packageArgIndex] = targetPackageArg;
|
||||
return {
|
||||
...capabilities.update,
|
||||
args,
|
||||
command: [capabilities.update.executable, ...args].join(" "),
|
||||
};
|
||||
}
|
||||
|
||||
function makeNpmGlobalProviderMaintenanceCapabilities(
|
||||
definition: PackageManagedProviderMaintenanceDefinition,
|
||||
): ProviderMaintenanceCapabilities {
|
||||
|
||||
@@ -288,6 +288,36 @@ describe("providerMaintenanceRunner", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("runs a targeted package update when a target version is supplied", () => {
|
||||
const calls: Array<{ command: string; args: ReadonlyArray<string> }> = [];
|
||||
return Effect.gen(function* () {
|
||||
const { registry } = yield* makeRegistry(baseProvider);
|
||||
const updater = yield* makeTestRunner(registry);
|
||||
|
||||
yield* updater.updateProvider({
|
||||
provider: CODEX_DRIVER,
|
||||
targetVersion: "0.129.0",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(calls, [
|
||||
{
|
||||
command: "npm",
|
||||
args: ["install", "-g", "@openai/[email protected]"],
|
||||
},
|
||||
]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
latestVersionHttpClient("0.0.0"),
|
||||
mockSpawnerLayer((command, args) => {
|
||||
calls.push({ command, args });
|
||||
return { stdout: "updated" };
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect(
|
||||
"runs update commands through Effect ChildProcess when no test runner is injected",
|
||||
() => {
|
||||
|
||||
@@ -22,7 +22,10 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import { ProviderRegistry } from "./Services/ProviderRegistry.ts";
|
||||
import { makeProviderMaintenanceCommandCoordinator } from "./providerMaintenanceCommandCoordinator.ts";
|
||||
import { enrichProviderSnapshotWithVersionAdvisory } from "./providerMaintenance.ts";
|
||||
import {
|
||||
enrichProviderSnapshotWithVersionAdvisory,
|
||||
makeTargetedProviderUpdateAction,
|
||||
} from "./providerMaintenance.ts";
|
||||
import type { ProviderMaintenanceCapabilities } from "./providerMaintenance.ts";
|
||||
import { collectUint8StreamText } from "../stream/collectUint8StreamText.ts";
|
||||
const isServerProviderUpdateError = Schema.is(ServerProviderUpdateError);
|
||||
@@ -46,6 +49,7 @@ export interface ProviderMaintenanceRunnerShape {
|
||||
| {
|
||||
readonly provider: ProviderDriverKind;
|
||||
readonly instanceId?: ProviderInstanceId | undefined;
|
||||
readonly targetVersion?: string | undefined;
|
||||
},
|
||||
) => Effect.Effect<ServerProviderUpdatedPayload, ServerProviderUpdateError>;
|
||||
}
|
||||
@@ -283,12 +287,15 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () {
|
||||
typeof target === "string"
|
||||
? defaultInstanceIdForDriver(provider)
|
||||
: (target.instanceId ?? defaultInstanceIdForDriver(provider));
|
||||
const targetVersion = typeof target === "string" ? undefined : target.targetVersion;
|
||||
const targetKey = `instance:${instanceId}`;
|
||||
const capabilities = yield* providerRegistry.getProviderMaintenanceCapabilitiesForInstance(
|
||||
instanceId,
|
||||
provider,
|
||||
);
|
||||
const update = capabilities.update;
|
||||
const update = targetVersion
|
||||
? makeTargetedProviderUpdateAction(capabilities, targetVersion)
|
||||
: capabilities.update;
|
||||
if (!update) {
|
||||
return yield* new ServerProviderUpdateError({
|
||||
provider,
|
||||
|
||||
@@ -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("unmapped-test-driver"),
|
||||
presentation: { displayName: "Test" },
|
||||
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 * as ProviderCompatibility 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
|
||||
? ProviderCompatibility.applyBundledProviderCompatibilityAdvisory({
|
||||
snapshot,
|
||||
driver: input.driver,
|
||||
currentVersion: input.probe.version,
|
||||
})
|
||||
: snapshot;
|
||||
}
|
||||
|
||||
export const collectStreamAsString = <E>(
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ProviderEventLoggersLive } from "./provider/Layers/ProviderEventLoggers
|
||||
import { ProviderServiceLive } from "./provider/Layers/ProviderService.ts";
|
||||
import { ProviderSessionReaperLive } from "./provider/Layers/ProviderSessionReaper.ts";
|
||||
import { OpenCodeRuntimeLive } from "./provider/opencodeRuntime.ts";
|
||||
import * as ProviderCompatibility from "./provider/ProviderCompatibility.ts";
|
||||
import { CheckpointDiffQueryLive } from "./checkpointing/Layers/CheckpointDiffQuery.ts";
|
||||
import { CheckpointStoreLive } from "./checkpointing/Layers/CheckpointStore.ts";
|
||||
import * as AzureDevOpsCli from "./sourceControl/AzureDevOpsCli.ts";
|
||||
@@ -258,6 +259,7 @@ const RuntimeCoreDependenciesLive = ReactorLayerLive.pipe(
|
||||
// `providerInstances` hydration merges `settings.providers.<kind>`
|
||||
// with explicit `providerInstances` entries on boot.
|
||||
Layer.provideMerge(ProviderInstanceRegistryHydrationLive),
|
||||
Layer.provideMerge(ProviderCompatibility.layer),
|
||||
// Shared native/canonical NDJSON writers used by both the per-instance
|
||||
// drivers (native stream, written from inside each `<X>Adapter`) and
|
||||
// `ProviderService` (canonical stream, written after event normalization).
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Crypto from "node:crypto";
|
||||
import { homedir } from "node:os";
|
||||
import { ServerConfig } from "../config.ts";
|
||||
|
||||
@@ -23,17 +23,14 @@ class IdentifyUserError extends Schema.TaggedErrorClass<IdentifyUserError>()("Id
|
||||
}) {}
|
||||
|
||||
const hash = (value: string) =>
|
||||
Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.digest("SHA-256", new TextEncoder().encode(value))),
|
||||
Effect.map(Encoding.encodeHex),
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new IdentifyUserError({
|
||||
message: "Failed to hash identifier",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
);
|
||||
Effect.try({
|
||||
try: () => Crypto.createHash("sha256").update(value).digest("hex"),
|
||||
catch: (error) =>
|
||||
new IdentifyUserError({
|
||||
message: "Failed to hash identifier",
|
||||
cause: error,
|
||||
}),
|
||||
});
|
||||
|
||||
const getCodexAccountId = Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
@@ -67,10 +64,11 @@ const upsertAnonymousId = Effect.gen(function* () {
|
||||
|
||||
const anonymousId = yield* fileSystem.readFileString(anonymousIdPath).pipe(
|
||||
Effect.catch(() =>
|
||||
Crypto.Crypto.pipe(
|
||||
Effect.flatMap((crypto) => crypto.randomUUIDv4),
|
||||
Effect.tap((randomId) => fileSystem.writeFileString(anonymousIdPath, randomId)),
|
||||
),
|
||||
Effect.gen(function* () {
|
||||
const randomId = yield* Random.nextUUIDv4;
|
||||
yield* fileSystem.writeFileString(anonymousIdPath, randomId);
|
||||
return randomId;
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const TelemetryEnvConfig = Config.all({
|
||||
});
|
||||
|
||||
const makeAnalyticsService = Effect.gen(function* () {
|
||||
const telemetryConfig = yield* TelemetryEnvConfig;
|
||||
const telemetryConfig = yield* TelemetryEnvConfig.asEffect();
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const serverConfig = yield* ServerConfig;
|
||||
const identifier = yield* getTelemetryIdentifier;
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Scope from "effect/Scope";
|
||||
import * as Stream from "effect/Stream";
|
||||
@@ -78,9 +79,10 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
|
||||
content: string,
|
||||
): Effect.Effect<string, TextGenerationError, Scope.Scope> => {
|
||||
return Effect.gen(function* () {
|
||||
const tempFileId = yield* Random.nextUUIDv4;
|
||||
return yield* fileSystem
|
||||
.makeTempFileScoped({
|
||||
prefix: `t3code-${prefix}-${process.pid}-`,
|
||||
prefix: `t3code-${prefix}-${process.pid}-${tempFileId}.tmp`,
|
||||
})
|
||||
.pipe(Effect.tap((filePath) => fileSystem.writeFileString(filePath, content)));
|
||||
}).pipe(
|
||||
|
||||
@@ -42,7 +42,7 @@ import { useGitStatus } from "~/lib/gitStatusState";
|
||||
import { usePrimaryEnvironmentId } from "../environments/primary";
|
||||
import { readEnvironmentApi } from "../environmentApi";
|
||||
import { isElectron } from "../env";
|
||||
import { readLocalApi } from "../localApi";
|
||||
import { ensureLocalApi, readLocalApi } from "../localApi";
|
||||
import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch";
|
||||
import {
|
||||
collapseExpandedComposerCursor,
|
||||
@@ -104,8 +104,15 @@ import { BranchToolbar } from "./BranchToolbar";
|
||||
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
|
||||
import PlanSidebar from "./PlanSidebar";
|
||||
import ThreadTerminalDrawer from "./ThreadTerminalDrawer";
|
||||
import { ChevronDownIcon, TriangleAlertIcon, WifiOffIcon } from "lucide-react";
|
||||
import { cn, randomHex, randomUUID } from "~/lib/utils";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
CircleAlertIcon,
|
||||
DownloadIcon,
|
||||
LoaderIcon,
|
||||
TriangleAlertIcon,
|
||||
WifiOffIcon,
|
||||
} from "lucide-react";
|
||||
import { cn, randomUUID } from "~/lib/utils";
|
||||
import { stackedThreadToast, toastManager } from "./ui/toast";
|
||||
import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings";
|
||||
import { type NewProjectScriptInput } from "./ProjectScriptsControl";
|
||||
@@ -150,7 +157,6 @@ import { ChatHeader } from "./chat/ChatHeader";
|
||||
import { type ExpandedImagePreview } from "./chat/ExpandedImagePreview";
|
||||
import { NoActiveThreadState } from "./NoActiveThreadState";
|
||||
import { resolveEffectiveEnvMode, resolveEnvironmentOptionLabel } from "./BranchToolbar.logic";
|
||||
import { ProviderStatusBanner } from "./chat/ProviderStatusBanner";
|
||||
import { ThreadErrorBanner } from "./chat/ThreadErrorBanner";
|
||||
import { ComposerBannerStack, type ComposerBannerStackItem } from "./chat/ComposerBannerStack";
|
||||
import {
|
||||
@@ -186,6 +192,11 @@ import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
|
||||
import { retainThreadDetailSubscription } from "../environments/runtime/service";
|
||||
import { RightPanelSheet } from "./RightPanelSheet";
|
||||
import { Button } from "./ui/button";
|
||||
import { Popover, PopoverPopup, PopoverTrigger } from "./ui/popover";
|
||||
import {
|
||||
canRunProviderCompatibilityUpdate,
|
||||
getProviderCompatibilityUpdateCommand,
|
||||
} from "./settings/providerStatus";
|
||||
import {
|
||||
buildVersionMismatchDismissalKey,
|
||||
dismissVersionMismatch,
|
||||
@@ -200,6 +211,75 @@ const EMPTY_PROPOSED_PLANS: Thread["proposedPlans"] = [];
|
||||
const EMPTY_PROVIDERS: ServerProvider[] = [];
|
||||
const EMPTY_PROVIDER_SKILLS: ServerProvider["skills"] = [];
|
||||
const EMPTY_PENDING_USER_INPUT_ANSWERS: Record<string, PendingUserInputDraftAnswer> = {};
|
||||
|
||||
function stripProviderCompatibilityInstallHint(message: string, recommendedVersion: string | null) {
|
||||
if (!recommendedVersion) {
|
||||
return message;
|
||||
}
|
||||
const escapedVersion = recommendedVersion.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
return message.replace(new RegExp(`\\s*Use\\s+${escapedVersion}\\.?\\s*$`, "i"), "").trim();
|
||||
}
|
||||
|
||||
function ProviderCompatibilityBannerAction({
|
||||
providerLabel,
|
||||
recommendedVersion,
|
||||
updateCommand,
|
||||
canRunUpdate,
|
||||
updating,
|
||||
onRunUpdate,
|
||||
}: {
|
||||
readonly providerLabel: string;
|
||||
readonly recommendedVersion: string;
|
||||
readonly updateCommand: string | null;
|
||||
readonly canRunUpdate: boolean;
|
||||
readonly updating: boolean;
|
||||
readonly onRunUpdate: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<Button type="button" size="xs" variant="outline">
|
||||
Install {recommendedVersion}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<PopoverPopup side="top" align="end" className="w-84">
|
||||
<div className="grid gap-3">
|
||||
<div className="grid gap-0.5">
|
||||
<p className="text-[13px] font-semibold leading-tight text-foreground">
|
||||
Install compatible {providerLabel}
|
||||
</p>
|
||||
<p className="text-xs leading-snug text-muted-foreground">
|
||||
Install provider harness version {recommendedVersion}.
|
||||
</p>
|
||||
</div>
|
||||
{canRunUpdate ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="default"
|
||||
className="w-full"
|
||||
disabled={updating}
|
||||
onClick={onRunUpdate}
|
||||
>
|
||||
{updating ? <LoaderIcon className="animate-spin" /> : <DownloadIcon />}
|
||||
{updating ? "Installing" : "Install now"}
|
||||
</Button>
|
||||
) : null}
|
||||
{updateCommand ? (
|
||||
<div className="rounded-md border border-border/70 bg-muted/40 px-2 py-1.5">
|
||||
<code className="block overflow-x-auto whitespace-nowrap font-mono text-[11px] text-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||
{updateCommand}
|
||||
</code>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
type EnvironmentUnavailableState = {
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly label: string;
|
||||
@@ -1150,6 +1230,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState<string | null>(
|
||||
null,
|
||||
);
|
||||
const [compatibilityUpdatingProviderId, setCompatibilityUpdatingProviderId] =
|
||||
useState<ProviderInstanceId | null>(null);
|
||||
const versionMismatchDismissed =
|
||||
versionMismatchDismissKey === dismissedVersionMismatchKey ||
|
||||
isVersionMismatchDismissed(versionMismatchDismissKey);
|
||||
@@ -1178,8 +1260,112 @@ export default function ChatView(props: ChatViewProps) {
|
||||
savedEnvironmentRuntimeById,
|
||||
serverConfig?.environment.label,
|
||||
]);
|
||||
const providerStatuses = serverConfig?.providers ?? EMPTY_PROVIDERS;
|
||||
const unlockedSelectedProvider = resolveSelectableProvider(
|
||||
providerStatuses,
|
||||
selectedProviderByThreadId ?? threadProvider ?? ProviderDriverKind.make("codex"),
|
||||
);
|
||||
const selectedProvider: ProviderDriverKind = lockedProvider ?? unlockedSelectedProvider;
|
||||
// Prefer an instance-id match so a custom Codex instance (e.g.
|
||||
// `codex_personal`) surfaces its own status/message in the banner rather
|
||||
// than the default Codex's. Falls back to first-match-by-kind when no
|
||||
// saved instance id is available or the instance no longer exists.
|
||||
const activeProviderInstanceId =
|
||||
composerActiveProvider ??
|
||||
activeThread?.session?.providerInstanceId ??
|
||||
activeThread?.modelSelection.instanceId ??
|
||||
activeProject?.defaultModelSelection?.instanceId ??
|
||||
null;
|
||||
const activeProviderStatus = useMemo(() => {
|
||||
if (activeProviderInstanceId) {
|
||||
return (
|
||||
providerStatuses.find((status) => status.instanceId === activeProviderInstanceId) ?? null
|
||||
);
|
||||
}
|
||||
const defaultInstanceId = defaultInstanceIdForDriver(selectedProvider);
|
||||
return providerStatuses.find((status) => status.instanceId === defaultInstanceId) ?? null;
|
||||
}, [activeProviderInstanceId, providerStatuses, selectedProvider]);
|
||||
const runActiveProviderCompatibilityUpdate = useCallback(async () => {
|
||||
const provider = activeProviderStatus;
|
||||
const targetVersion = provider?.compatibilityAdvisory?.recommendedVersion ?? null;
|
||||
if (!provider || !targetVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
setCompatibilityUpdatingProviderId(provider.instanceId);
|
||||
try {
|
||||
await ensureLocalApi().server.updateProvider({
|
||||
provider: provider.driver,
|
||||
instanceId: provider.instanceId,
|
||||
targetVersion,
|
||||
});
|
||||
} catch (error) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: `Could not update ${provider.displayName ?? provider.driver}`,
|
||||
description:
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "The provider update command could not be started.",
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
setCompatibilityUpdatingProviderId((current) =>
|
||||
current === provider.instanceId ? null : current,
|
||||
);
|
||||
}
|
||||
}, [activeProviderStatus]);
|
||||
const composerBannerItems = useMemo<ComposerBannerStackItem[]>(() => {
|
||||
const items: ComposerBannerStackItem[] = [];
|
||||
if (
|
||||
activeProviderStatus &&
|
||||
activeProviderStatus.status !== "ready" &&
|
||||
activeProviderStatus.status !== "disabled"
|
||||
) {
|
||||
const defaultMessage =
|
||||
activeProviderStatus.status === "error"
|
||||
? "Provider is unavailable."
|
||||
: "Provider needs attention.";
|
||||
const recommendedVersion =
|
||||
activeProviderStatus.compatibilityAdvisory?.recommendedVersion ?? null;
|
||||
const compatibilityUpdateCommand =
|
||||
getProviderCompatibilityUpdateCommand(activeProviderStatus);
|
||||
const canRunCompatibilityUpdate = canRunProviderCompatibilityUpdate(activeProviderStatus);
|
||||
const compatibilityUpdating =
|
||||
compatibilityUpdatingProviderId === activeProviderStatus.instanceId;
|
||||
const hasCompatibilityInstallAction =
|
||||
activeProviderStatus.compatibilityAdvisory?.status !== "supported" &&
|
||||
recommendedVersion !== null &&
|
||||
(canRunCompatibilityUpdate || compatibilityUpdateCommand !== null);
|
||||
const rawMessage = activeProviderStatus.message ?? defaultMessage;
|
||||
const message = hasCompatibilityInstallAction
|
||||
? stripProviderCompatibilityInstallHint(rawMessage, recommendedVersion)
|
||||
: rawMessage;
|
||||
const providerLabel = activeProviderStatus.displayName ?? activeProviderStatus.driver;
|
||||
items.push({
|
||||
id: `provider-status:${activeProviderStatus.instanceId}:${activeProviderStatus.status}`,
|
||||
variant: activeProviderStatus.status === "error" ? "error" : "warning",
|
||||
icon: <CircleAlertIcon />,
|
||||
title: `${providerLabel} provider status`,
|
||||
description: (
|
||||
<span className="line-clamp-3" title={message}>
|
||||
{message}
|
||||
</span>
|
||||
),
|
||||
actions:
|
||||
hasCompatibilityInstallAction && recommendedVersion ? (
|
||||
<ProviderCompatibilityBannerAction
|
||||
providerLabel={providerLabel}
|
||||
recommendedVersion={recommendedVersion}
|
||||
updateCommand={compatibilityUpdateCommand}
|
||||
canRunUpdate={canRunCompatibilityUpdate}
|
||||
updating={compatibilityUpdating}
|
||||
onRunUpdate={() => void runActiveProviderCompatibilityUpdate()}
|
||||
/>
|
||||
) : undefined,
|
||||
});
|
||||
}
|
||||
if (activeEnvironmentUnavailableState) {
|
||||
items.push({
|
||||
id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`,
|
||||
@@ -1248,20 +1434,17 @@ export default function ChatView(props: ChatViewProps) {
|
||||
return items;
|
||||
}, [
|
||||
activeEnvironmentUnavailableState,
|
||||
activeProviderStatus,
|
||||
compatibilityUpdatingProviderId,
|
||||
handleReconnectActiveEnvironment,
|
||||
navigate,
|
||||
reconnectingEnvironmentId,
|
||||
runActiveProviderCompatibilityUpdate,
|
||||
showVersionMismatchBanner,
|
||||
versionMismatch,
|
||||
versionMismatchDismissKey,
|
||||
versionMismatchServerLabel,
|
||||
]);
|
||||
const providerStatuses = serverConfig?.providers ?? EMPTY_PROVIDERS;
|
||||
const unlockedSelectedProvider = resolveSelectableProvider(
|
||||
providerStatuses,
|
||||
selectedProviderByThreadId ?? threadProvider ?? ProviderDriverKind.make("codex"),
|
||||
);
|
||||
const selectedProvider: ProviderDriverKind = lockedProvider ?? unlockedSelectedProvider;
|
||||
const phase = derivePhase(activeThread?.session ?? null);
|
||||
const threadActivities = activeThread?.activities ?? EMPTY_ACTIVITIES;
|
||||
const workLogEntries = useMemo(
|
||||
@@ -1633,24 +1816,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const gitStatusQuery = useGitStatus({ environmentId, cwd: gitCwd });
|
||||
const keybindings = useServerKeybindings();
|
||||
const availableEditors = useServerAvailableEditors();
|
||||
// Prefer an instance-id match so a custom Codex instance (e.g.
|
||||
// `codex_personal`) surfaces its own status/message in the banner rather
|
||||
// than the default Codex's. Falls back to first-match-by-kind when no
|
||||
// saved instance id is available or the instance no longer exists.
|
||||
const activeProviderInstanceId =
|
||||
activeThread?.session?.providerInstanceId ??
|
||||
activeThread?.modelSelection.instanceId ??
|
||||
activeProject?.defaultModelSelection?.instanceId ??
|
||||
null;
|
||||
const activeProviderStatus = useMemo(() => {
|
||||
if (activeProviderInstanceId) {
|
||||
return (
|
||||
providerStatuses.find((status) => status.instanceId === activeProviderInstanceId) ?? null
|
||||
);
|
||||
}
|
||||
const defaultInstanceId = defaultInstanceIdForDriver(selectedProvider);
|
||||
return providerStatuses.find((status) => status.instanceId === defaultInstanceId) ?? null;
|
||||
}, [activeProviderInstanceId, providerStatuses, selectedProvider]);
|
||||
const activeProjectCwd = activeProject?.cwd ?? null;
|
||||
const activeThreadWorktreePath = activeThread?.worktreePath ?? null;
|
||||
const activeWorkspaceRoot = activeThreadWorktreePath ?? activeProjectCwd ?? undefined;
|
||||
@@ -2846,7 +3011,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
prepareWorktree: {
|
||||
projectCwd: activeProject.cwd,
|
||||
baseBranch: baseBranchForWorktree,
|
||||
branch: buildTemporaryWorktreeBranchName(randomHex),
|
||||
branch: buildTemporaryWorktreeBranchName(),
|
||||
},
|
||||
runSetupScript: true,
|
||||
}
|
||||
@@ -3540,8 +3705,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
/>
|
||||
</header>
|
||||
|
||||
{/* Error banner */}
|
||||
<ProviderStatusBanner status={activeProviderStatus} />
|
||||
<ThreadErrorBanner
|
||||
error={activeThread.error}
|
||||
onDismiss={() => setThreadError(activeThread.id, null)}
|
||||
|
||||
@@ -301,6 +301,7 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions(
|
||||
isSendBusy: boolean;
|
||||
isConnecting: boolean;
|
||||
isEnvironmentUnavailable: boolean;
|
||||
isProviderUnavailable: boolean;
|
||||
hasSendableContent: boolean;
|
||||
preserveComposerFocusOnPointerDown?: boolean;
|
||||
onPreviousPendingQuestion: () => void;
|
||||
@@ -322,6 +323,7 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions(
|
||||
isSendBusy={props.isSendBusy}
|
||||
isConnecting={props.isConnecting}
|
||||
isEnvironmentUnavailable={props.isEnvironmentUnavailable}
|
||||
isProviderUnavailable={props.isProviderUnavailable}
|
||||
isPreparingWorktree={props.isPreparingWorktree}
|
||||
hasSendableContent={props.hasSendableContent}
|
||||
preserveComposerFocusOnPointerDown={props.preserveComposerFocusOnPointerDown ?? false}
|
||||
@@ -715,6 +717,11 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
() => selectedProviderEntry?.snapshot ?? null,
|
||||
[selectedProviderEntry],
|
||||
);
|
||||
const selectedProviderUnavailableMessage =
|
||||
selectedProviderStatus?.status === "error"
|
||||
? (selectedProviderStatus.message ?? "Selected provider is unavailable.")
|
||||
: null;
|
||||
const isSelectedProviderUnavailable = selectedProviderUnavailableMessage !== null;
|
||||
const selectedProviderModels = useMemo<ReadonlyArray<ServerProvider["models"][number]>>(
|
||||
() => selectedProviderEntry?.models ?? [],
|
||||
[selectedProviderEntry],
|
||||
@@ -727,16 +734,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
prompt,
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
}),
|
||||
[
|
||||
composerModelOptions,
|
||||
prompt,
|
||||
selectedInstanceId,
|
||||
selectedModel,
|
||||
selectedProvider,
|
||||
selectedProviderModels,
|
||||
],
|
||||
[composerModelOptions, prompt, selectedModel, selectedProvider, selectedProviderModels],
|
||||
);
|
||||
|
||||
const selectedPromptEffort = composerProviderState.promptEffort;
|
||||
@@ -1025,23 +1025,21 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
|
||||
const providerTraitsMenuContent = renderProviderTraitsMenuContent({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
const providerTraitsPicker = renderProviderTraitsPicker({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
@@ -1623,12 +1621,21 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
|
||||
const submitComposer = useCallback(
|
||||
(event?: { preventDefault: () => void }) => {
|
||||
if (isSelectedProviderUnavailable) {
|
||||
event?.preventDefault();
|
||||
return;
|
||||
}
|
||||
onSend(event);
|
||||
if (shouldBlurMobileComposerOnSubmit()) {
|
||||
blurMobileComposerAfterSend();
|
||||
}
|
||||
},
|
||||
[blurMobileComposerAfterSend, onSend, shouldBlurMobileComposerOnSubmit],
|
||||
[
|
||||
blurMobileComposerAfterSend,
|
||||
isSelectedProviderUnavailable,
|
||||
onSend,
|
||||
shouldBlurMobileComposerOnSubmit,
|
||||
],
|
||||
);
|
||||
const expandMobileComposer = useCallback(() => {
|
||||
if (composerBlurFrameRef.current !== null) {
|
||||
@@ -2083,6 +2090,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
isSendBusy={isSendBusy}
|
||||
isConnecting={isConnecting}
|
||||
isEnvironmentUnavailable={environmentUnavailable !== null}
|
||||
isProviderUnavailable={isSelectedProviderUnavailable}
|
||||
isPreparingWorktree={false}
|
||||
hasSendableContent={false}
|
||||
preserveComposerFocusOnPointerDown
|
||||
@@ -2268,12 +2276,15 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
? "connecting"
|
||||
: "disconnected"
|
||||
}`
|
||||
: phase === "disconnected"
|
||||
? "Ask for follow-up changes or attach images"
|
||||
: "Ask anything, @tag files/folders, $use skills, or / for commands"
|
||||
: selectedProviderUnavailableMessage
|
||||
? selectedProviderUnavailableMessage
|
||||
: phase === "disconnected"
|
||||
? "Ask for follow-up changes or attach images"
|
||||
: "Ask anything, @tag files/folders, $use skills, or / for commands"
|
||||
}
|
||||
disabled={
|
||||
isConnecting ||
|
||||
isSelectedProviderUnavailable ||
|
||||
isComposerApprovalState ||
|
||||
(environmentUnavailable !== null && activePendingProgress === null)
|
||||
}
|
||||
@@ -2292,6 +2303,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
isSendBusy={isSendBusy}
|
||||
isConnecting={isConnecting}
|
||||
isEnvironmentUnavailable={environmentUnavailable !== null}
|
||||
isProviderUnavailable={isSelectedProviderUnavailable}
|
||||
isPreparingWorktree={false}
|
||||
hasSendableContent={false}
|
||||
preserveComposerFocusOnPointerDown
|
||||
@@ -2400,6 +2412,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
isSendBusy={isSendBusy}
|
||||
isConnecting={isConnecting}
|
||||
isEnvironmentUnavailable={environmentUnavailable !== null}
|
||||
isProviderUnavailable={isSelectedProviderUnavailable}
|
||||
isPreparingWorktree={isPreparingWorktree}
|
||||
hasSendableContent={composerSendState.hasSendableContent}
|
||||
preserveComposerFocusOnPointerDown={isMobileViewport}
|
||||
|
||||
@@ -21,6 +21,7 @@ interface ComposerPrimaryActionsProps {
|
||||
isSendBusy: boolean;
|
||||
isConnecting: boolean;
|
||||
isEnvironmentUnavailable: boolean;
|
||||
isProviderUnavailable: boolean;
|
||||
isPreparingWorktree: boolean;
|
||||
hasSendableContent: boolean;
|
||||
preserveComposerFocusOnPointerDown?: boolean;
|
||||
@@ -60,6 +61,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
isSendBusy,
|
||||
isConnecting,
|
||||
isEnvironmentUnavailable,
|
||||
isProviderUnavailable,
|
||||
isPreparingWorktree,
|
||||
hasSendableContent,
|
||||
preserveComposerFocusOnPointerDown = false,
|
||||
@@ -107,6 +109,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
{...pointerFocusProps}
|
||||
disabled={
|
||||
isEnvironmentUnavailable ||
|
||||
isProviderUnavailable ||
|
||||
pendingAction.isResponding ||
|
||||
(pendingAction.isLastQuestion ? !pendingAction.isComplete : !pendingAction.canAdvance)
|
||||
}
|
||||
@@ -146,7 +149,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
size="sm"
|
||||
className={cn("rounded-full", compact ? "h-9 px-3 sm:h-8" : "h-9 px-4 sm:h-8")}
|
||||
{...pointerFocusProps}
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable}
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable}
|
||||
>
|
||||
{isConnecting || isSendBusy ? "Sending..." : "Refine"}
|
||||
</Button>
|
||||
@@ -160,7 +163,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
size="sm"
|
||||
className="h-9 rounded-l-full rounded-r-none px-4 sm:h-8"
|
||||
{...pointerFocusProps}
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable}
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable}
|
||||
>
|
||||
{isConnecting || isSendBusy ? "Sending..." : "Implement"}
|
||||
</Button>
|
||||
@@ -173,7 +176,9 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
className="h-9 rounded-l-none rounded-r-full border-l-white/12 px-2 sm:h-8"
|
||||
aria-label="Implementation actions"
|
||||
{...pointerFocusProps}
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable}
|
||||
disabled={
|
||||
isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
@@ -181,7 +186,9 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end" side="top">
|
||||
<MenuItem
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable}
|
||||
disabled={
|
||||
isSendBusy || isConnecting || isEnvironmentUnavailable || isProviderUnavailable
|
||||
}
|
||||
onClick={() => void onImplementPlanInNewThread()}
|
||||
>
|
||||
Implement in a new thread
|
||||
@@ -197,17 +204,25 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
type="submit"
|
||||
className="flex h-9 w-9 enabled:cursor-pointer items-center justify-center rounded-full bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary hover:scale-105 disabled:pointer-events-none disabled:opacity-30 disabled:hover:scale-100 sm:h-8 sm:w-8"
|
||||
{...pointerFocusProps}
|
||||
disabled={isSendBusy || isConnecting || isEnvironmentUnavailable || !hasSendableContent}
|
||||
disabled={
|
||||
isSendBusy ||
|
||||
isConnecting ||
|
||||
isEnvironmentUnavailable ||
|
||||
isProviderUnavailable ||
|
||||
!hasSendableContent
|
||||
}
|
||||
aria-label={
|
||||
isEnvironmentUnavailable
|
||||
? "Environment disconnected"
|
||||
: isConnecting
|
||||
? "Connecting"
|
||||
: isPreparingWorktree
|
||||
? "Preparing worktree"
|
||||
: isSendBusy
|
||||
? "Sending"
|
||||
: "Send message"
|
||||
isProviderUnavailable
|
||||
? "Provider unavailable"
|
||||
: isEnvironmentUnavailable
|
||||
? "Environment disconnected"
|
||||
: isConnecting
|
||||
? "Connecting"
|
||||
: isPreparingWorktree
|
||||
? "Preparing worktree"
|
||||
: isSendBusy
|
||||
? "Sending"
|
||||
: "Send message"
|
||||
}
|
||||
>
|
||||
{isConnecting || isSendBusy ? (
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { type ServerProvider } from "@t3tools/contracts";
|
||||
import { memo } from "react";
|
||||
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
||||
import { CircleAlertIcon } from "lucide-react";
|
||||
import { formatProviderDriverKindLabel } from "../../providerModels";
|
||||
|
||||
export const ProviderStatusBanner = memo(function ProviderStatusBanner({
|
||||
status,
|
||||
}: {
|
||||
status: ServerProvider | null;
|
||||
}) {
|
||||
if (!status || status.status === "ready" || status.status === "disabled") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const providerLabel = status.displayName?.trim() || formatProviderDriverKindLabel(status.driver);
|
||||
const defaultMessage =
|
||||
status.status === "error"
|
||||
? `${providerLabel} provider is unavailable.`
|
||||
: `${providerLabel} provider has limited availability.`;
|
||||
const title = `${providerLabel} provider status`;
|
||||
|
||||
return (
|
||||
<div className="pt-3 mx-auto max-w-3xl">
|
||||
<Alert variant={status.status === "error" ? "error" : "warning"}>
|
||||
<CircleAlertIcon />
|
||||
<AlertTitle>{title}</AlertTitle>
|
||||
<AlertDescription className="line-clamp-3" title={status.message ?? defaultMessage}>
|
||||
{status.message ?? defaultMessage}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
import { memo } from "react";
|
||||
import { Alert, AlertAction, AlertDescription } from "../ui/alert";
|
||||
import { CircleAlertIcon, XIcon } from "lucide-react";
|
||||
|
||||
import { Alert, AlertAction, AlertDescription } from "../ui/alert";
|
||||
|
||||
export const ThreadErrorBanner = memo(function ThreadErrorBanner({
|
||||
error,
|
||||
onDismiss,
|
||||
@@ -11,7 +12,7 @@ export const ThreadErrorBanner = memo(function ThreadErrorBanner({
|
||||
}) {
|
||||
if (!error) return null;
|
||||
return (
|
||||
<div className="pt-3 mx-auto max-w-3xl">
|
||||
<div className="mx-auto max-w-3xl pt-3">
|
||||
<Alert variant="error">
|
||||
<CircleAlertIcon />
|
||||
<AlertDescription className="line-clamp-3" title={error}>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionDescriptor,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
@@ -197,7 +196,6 @@ export function shouldRenderTraitsControls(input: {
|
||||
|
||||
export interface TraitsMenuContentProps {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
model: string | null | undefined;
|
||||
prompt: string;
|
||||
@@ -210,7 +208,6 @@ export interface TraitsMenuContentProps {
|
||||
|
||||
export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -231,12 +228,11 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
return;
|
||||
}
|
||||
setProviderModelOptions(threadTarget, provider, nextOptions, {
|
||||
...(instanceId ? { instanceId } : {}),
|
||||
model,
|
||||
persistSticky: true,
|
||||
});
|
||||
},
|
||||
[instanceId, model, persistence, provider, setProviderModelOptions],
|
||||
[model, persistence, provider, setProviderModelOptions],
|
||||
);
|
||||
const {
|
||||
descriptors,
|
||||
@@ -347,7 +343,6 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
|
||||
export const TraitsPicker = memo(function TraitsPicker({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -436,7 +431,6 @@ export const TraitsPicker = memo(function TraitsPicker({
|
||||
<MenuPopup align="start">
|
||||
<TraitsMenuContent
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
model={model}
|
||||
prompt={prompt}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
type ServerProviderModel,
|
||||
@@ -36,7 +35,6 @@ export type ComposerProviderState = {
|
||||
|
||||
type TraitsRenderInput = {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
@@ -78,17 +76,8 @@ function renderTraitsControl(
|
||||
Component: typeof TraitsMenuContent | typeof TraitsPicker,
|
||||
input: TraitsRenderInput,
|
||||
): ReactNode {
|
||||
const {
|
||||
provider,
|
||||
instanceId,
|
||||
threadRef,
|
||||
draftId,
|
||||
model,
|
||||
models,
|
||||
modelOptions,
|
||||
prompt,
|
||||
onPromptChange,
|
||||
} = input;
|
||||
const { provider, threadRef, draftId, model, models, modelOptions, prompt, onPromptChange } =
|
||||
input;
|
||||
const hasTarget = threadRef !== undefined || draftId !== undefined;
|
||||
if (
|
||||
!hasTarget ||
|
||||
@@ -99,7 +88,6 @@ function renderTraitsControl(
|
||||
return (
|
||||
<Component
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
AlertTriangleIcon,
|
||||
ArrowUpCircleIcon,
|
||||
ChevronDownIcon,
|
||||
CopyIcon,
|
||||
@@ -39,8 +40,10 @@ import { ProviderModelsSection } from "./ProviderModelsSection";
|
||||
import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon";
|
||||
import { RedactedSensitiveText } from "./RedactedSensitiveText";
|
||||
import {
|
||||
getProviderCompatibilityUpdateCommand,
|
||||
getProviderVersionAdvisoryPresentation,
|
||||
PROVIDER_STATUS_STYLES,
|
||||
getProviderCompatibilityAdvisoryPresentation,
|
||||
getProviderSummary,
|
||||
getProviderVersionLabel,
|
||||
type ProviderStatusKey,
|
||||
@@ -56,6 +59,8 @@ const PROVIDER_ACCENT_SWATCHES = [
|
||||
] as const;
|
||||
|
||||
const ENVIRONMENT_VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
||||
const ADVISORY_ICON_CLUSTER_CLASS = "-my-0.5 inline-flex h-5 shrink-0 items-center gap-2";
|
||||
const ADVISORY_ICON_SLOT_CLASS = "inline-flex size-5 shrink-0 items-center justify-center";
|
||||
|
||||
let environmentVariableDraftId = 0;
|
||||
const nextEnvironmentVariableDraftId = () => `provider-env-${environmentVariableDraftId++}`;
|
||||
@@ -421,6 +426,8 @@ interface ProviderInstanceCardProps {
|
||||
readonly onModelOrderChange: (next: ReadonlyArray<string>) => void;
|
||||
readonly onRunUpdate?: (() => void) | undefined;
|
||||
readonly isUpdating?: boolean | undefined;
|
||||
readonly onRunCompatibilityUpdate?: (() => void) | undefined;
|
||||
readonly isCompatibilityUpdating?: boolean | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,6 +472,8 @@ export function ProviderInstanceCard({
|
||||
onModelOrderChange,
|
||||
onRunUpdate,
|
||||
isUpdating = false,
|
||||
onRunCompatibilityUpdate,
|
||||
isCompatibilityUpdating = false,
|
||||
}: ProviderInstanceCardProps) {
|
||||
const enabled = instance.enabled ?? true;
|
||||
// The server-reported status wins when present; otherwise fall back to
|
||||
@@ -482,8 +491,13 @@ export function ProviderInstanceCard({
|
||||
: null;
|
||||
const summary = rawSummary;
|
||||
const versionLabel = getProviderVersionLabel(liveProvider?.version);
|
||||
const compatibilityAdvisory = getProviderCompatibilityAdvisoryPresentation(
|
||||
liveProvider?.compatibilityAdvisory,
|
||||
);
|
||||
const versionAdvisory = getProviderVersionAdvisoryPresentation(liveProvider?.versionAdvisory);
|
||||
const hasProviderAdvisoryIcons = compatibilityAdvisory !== null || versionAdvisory !== null;
|
||||
const updateCommand = versionAdvisory?.updateCommand ?? null;
|
||||
const compatibilityUpdateCommand = getProviderCompatibilityUpdateCommand(liveProvider);
|
||||
const FallbackIconComponent = driverOption?.icon;
|
||||
const displayName =
|
||||
instance.displayName?.trim() || driverOption?.label || String(instance.driver);
|
||||
@@ -677,101 +691,212 @@ export function ProviderInstanceCard({
|
||||
<div className="min-w-0 flex-1 space-y-1">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
{titleHeadNode}
|
||||
{versionCodeNode}
|
||||
{versionAdvisory ? (
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"size-5 rounded-sm p-0",
|
||||
versionAdvisory.emphasis === "strong"
|
||||
? "text-warning hover:text-warning"
|
||||
: "text-primary hover:text-primary",
|
||||
)}
|
||||
aria-label="Update available — view details"
|
||||
>
|
||||
<ArrowUpCircleIcon className="size-3.5 [animation:bounce_2.4s_ease-in-out_infinite] motion-reduce:animate-none" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<PopoverPopup
|
||||
side="bottom"
|
||||
align="start"
|
||||
className="w-[min(21rem,calc(100vw-1.5rem))] [--popup-width:min(21rem,calc(100vw-1.5rem))]"
|
||||
>
|
||||
<div className="grid min-w-0 gap-3">
|
||||
<div className="grid gap-0.5">
|
||||
<p className="text-[13px] font-semibold leading-tight text-foreground">
|
||||
Update available
|
||||
</p>
|
||||
<p
|
||||
className={cn(
|
||||
"text-xs leading-snug",
|
||||
versionAdvisory.emphasis === "strong"
|
||||
? "text-warning"
|
||||
: "text-muted-foreground",
|
||||
)}
|
||||
{versionCodeNode || hasProviderAdvisoryIcons ? (
|
||||
<span className={ADVISORY_ICON_CLUSTER_CLASS}>
|
||||
{versionCodeNode}
|
||||
{compatibilityAdvisory ? (
|
||||
<span className={ADVISORY_ICON_SLOT_CLASS}>
|
||||
<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-[min(21rem,calc(100vw-1.5rem))] [--popup-width:min(21rem,calc(100vw-1.5rem))]"
|
||||
>
|
||||
{versionAdvisory.detail}
|
||||
</p>
|
||||
</div>
|
||||
{onRunUpdate ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="default"
|
||||
className="w-full"
|
||||
disabled={isUpdating}
|
||||
onClick={onRunUpdate}
|
||||
<div className="grid min-w-0 gap-3">
|
||||
<div className="grid gap-0.5">
|
||||
<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>
|
||||
{onRunCompatibilityUpdate ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="default"
|
||||
className="w-full"
|
||||
disabled={isCompatibilityUpdating}
|
||||
onClick={onRunCompatibilityUpdate}
|
||||
>
|
||||
{isCompatibilityUpdating ? (
|
||||
<LoaderIcon className="animate-spin" />
|
||||
) : (
|
||||
<DownloadIcon />
|
||||
)}
|
||||
{isCompatibilityUpdating ? "Updating" : "Update now"}
|
||||
</Button>
|
||||
) : null}
|
||||
{onRunCompatibilityUpdate && compatibilityUpdateCommand ? (
|
||||
<div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
|
||||
<span aria-hidden className="h-px flex-1 bg-border" />
|
||||
or, update manually using
|
||||
<span aria-hidden className="h-px flex-1 bg-border" />
|
||||
</div>
|
||||
) : null}
|
||||
{compatibilityUpdateCommand ? (
|
||||
<div className="flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
|
||||
<ScrollArea scrollFade className="h-8 min-w-0 flex-1 rounded-none">
|
||||
<code className="flex h-full w-max items-center whitespace-nowrap pr-3 font-mono text-[11px] text-foreground">
|
||||
{compatibilityUpdateCommand}
|
||||
</code>
|
||||
</ScrollArea>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className="size-6 shrink-0 rounded-sm p-0 text-muted-foreground hover:text-foreground"
|
||||
onClick={() =>
|
||||
copyToClipboard(compatibilityUpdateCommand, {
|
||||
providerName: displayName,
|
||||
})
|
||||
}
|
||||
aria-label="Copy compatibility update command"
|
||||
>
|
||||
<CopyIcon className="size-3" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Copy command</TooltipPopup>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
</span>
|
||||
) : null}
|
||||
{versionAdvisory ? (
|
||||
<span className={ADVISORY_ICON_SLOT_CLASS}>
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"size-5 rounded-sm p-0",
|
||||
versionAdvisory.emphasis === "strong"
|
||||
? "text-warning hover:text-warning"
|
||||
: "text-primary hover:text-primary",
|
||||
)}
|
||||
aria-label="Update available — view details"
|
||||
>
|
||||
<ArrowUpCircleIcon className="size-3.5 [animation:bounce_2.4s_ease-in-out_infinite] motion-reduce:animate-none" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<PopoverPopup
|
||||
side="bottom"
|
||||
align="start"
|
||||
className="w-[min(21rem,calc(100vw-1.5rem))] [--popup-width:min(21rem,calc(100vw-1.5rem))]"
|
||||
>
|
||||
{isUpdating ? <LoaderIcon className="animate-spin" /> : <DownloadIcon />}
|
||||
{isUpdating ? "Updating" : "Update now"}
|
||||
</Button>
|
||||
) : null}
|
||||
{onRunUpdate && updateCommand ? (
|
||||
<div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
|
||||
<span aria-hidden className="h-px flex-1 bg-border" />
|
||||
or, update manually using
|
||||
<span aria-hidden className="h-px flex-1 bg-border" />
|
||||
</div>
|
||||
) : null}
|
||||
{updateCommand ? (
|
||||
<div className="flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
|
||||
<ScrollArea scrollFade className="h-8 min-w-0 flex-1 rounded-none">
|
||||
<code className="flex h-full w-max items-center whitespace-nowrap pr-3 font-mono text-[11px] text-foreground">
|
||||
{updateCommand}
|
||||
</code>
|
||||
</ScrollArea>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className="size-6 shrink-0 rounded-sm p-0 text-muted-foreground hover:text-foreground"
|
||||
onClick={() =>
|
||||
copyToClipboard(updateCommand, {
|
||||
providerName: displayName,
|
||||
})
|
||||
}
|
||||
aria-label="Copy update command"
|
||||
>
|
||||
<CopyIcon className="size-3" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Copy command</TooltipPopup>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
<div className="grid min-w-0 gap-3">
|
||||
<div className="grid gap-0.5">
|
||||
<p className="text-[13px] font-semibold leading-tight text-foreground">
|
||||
Update available
|
||||
</p>
|
||||
<p
|
||||
className={cn(
|
||||
"text-xs leading-snug",
|
||||
versionAdvisory.emphasis === "strong"
|
||||
? "text-warning"
|
||||
: "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{versionAdvisory.detail}
|
||||
</p>
|
||||
</div>
|
||||
{onRunUpdate ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="default"
|
||||
className="w-full"
|
||||
disabled={isUpdating}
|
||||
onClick={onRunUpdate}
|
||||
>
|
||||
{isUpdating ? (
|
||||
<LoaderIcon className="animate-spin" />
|
||||
) : (
|
||||
<DownloadIcon />
|
||||
)}
|
||||
{isUpdating ? "Updating" : "Update now"}
|
||||
</Button>
|
||||
) : null}
|
||||
{onRunUpdate && updateCommand ? (
|
||||
<div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
|
||||
<span aria-hidden className="h-px flex-1 bg-border" />
|
||||
or, update manually using
|
||||
<span aria-hidden className="h-px flex-1 bg-border" />
|
||||
</div>
|
||||
) : null}
|
||||
{updateCommand ? (
|
||||
<div className="flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
|
||||
<ScrollArea scrollFade className="h-8 min-w-0 flex-1 rounded-none">
|
||||
<code className="flex h-full w-max items-center whitespace-nowrap pr-3 font-mono text-[11px] text-foreground">
|
||||
{updateCommand}
|
||||
</code>
|
||||
</ScrollArea>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className="size-6 shrink-0 rounded-sm p-0 text-muted-foreground hover:text-foreground"
|
||||
onClick={() =>
|
||||
copyToClipboard(updateCommand, {
|
||||
providerName: displayName,
|
||||
})
|
||||
}
|
||||
aria-label="Copy update command"
|
||||
>
|
||||
<CopyIcon className="size-3" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Copy command</TooltipPopup>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
) : null}
|
||||
{titleTailNode}
|
||||
</div>
|
||||
|
||||
@@ -239,7 +239,7 @@ function createBaseServerConfig(): ServerConfig {
|
||||
|
||||
function createOutdatedProvider(
|
||||
driver: string,
|
||||
updateCommand = "npm install -g openai/codex@latest",
|
||||
updateCommand = "npm install -g @openai/codex@latest",
|
||||
): ServerProvider {
|
||||
return {
|
||||
instanceId: ProviderInstanceId.make(driver),
|
||||
@@ -1177,6 +1177,63 @@ describe("GeneralSettingsPanel observability", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("runs targeted compatibility updates from the provider card", async () => {
|
||||
const updateProvider = vi.fn<LocalApi["server"]["updateProvider"]>().mockResolvedValue({
|
||||
providers: [],
|
||||
});
|
||||
window.nativeApi = {
|
||||
persistence: {
|
||||
getClientSettings: vi.fn().mockResolvedValue(null),
|
||||
setClientSettings: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
server: {
|
||||
updateProvider,
|
||||
},
|
||||
} as unknown as LocalApi;
|
||||
const incompatibleProvider: ServerProvider = {
|
||||
...createOutdatedProvider("codex"),
|
||||
version: "0.128.0",
|
||||
status: "error",
|
||||
message:
|
||||
"This provider harness version 0.128.0 is known to be incompatible with this T3 Code release. Use 0.129.0.",
|
||||
compatibilityAdvisory: {
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.128.0",
|
||||
message:
|
||||
"This provider harness version 0.128.0 is known to be incompatible with this T3 Code release. Use 0.129.0.",
|
||||
recommendedRange: ">=0.129.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: "<0.129.0" }],
|
||||
},
|
||||
};
|
||||
|
||||
setServerConfigSnapshot({
|
||||
...createBaseServerConfig(),
|
||||
providers: [incompatibleProvider],
|
||||
});
|
||||
|
||||
mounted = await render(
|
||||
<AppAtomRegistryProvider>
|
||||
<ProviderSettingsPanel />
|
||||
</AppAtomRegistryProvider>,
|
||||
);
|
||||
|
||||
await page
|
||||
.getByRole("button", { name: "Incompatible provider version — view details" })
|
||||
.click();
|
||||
await expect
|
||||
.element(page.getByText("npm install -g @openai/[email protected]"))
|
||||
.toBeInTheDocument();
|
||||
await page.getByRole("button", { name: "Update now" }).click();
|
||||
|
||||
expect(updateProvider).toHaveBeenCalledWith({
|
||||
provider: ProviderDriverKind.make("codex"),
|
||||
instanceId: ProviderInstanceId.make("codex"),
|
||||
targetVersion: "0.129.0",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps long provider update commands inside the fixed-width popover", async () => {
|
||||
const longUpdateCommand =
|
||||
"npm install -g @anthropic-ai/claude-code@latest --registry=https://registry.npmjs.org --cache=/tmp/t3code-provider-update-cache";
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type ProviderInstanceConfig,
|
||||
type ProviderInstanceId,
|
||||
type ScopedThreadRef,
|
||||
type ServerProvider,
|
||||
} from "@t3tools/contracts";
|
||||
import { scopeThreadRef } from "@t3tools/client-runtime";
|
||||
import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings";
|
||||
@@ -63,6 +64,10 @@ import {
|
||||
type ProviderUpdateCandidate,
|
||||
} from "../ProviderUpdateLaunchNotification.logic";
|
||||
import { ProviderInstanceCard } from "./ProviderInstanceCard";
|
||||
import {
|
||||
canRunProviderCompatibilityUpdate,
|
||||
getProviderCompatibilityUpdateCommand,
|
||||
} from "./providerStatus";
|
||||
import { DRIVER_OPTIONS, getDriverOption } from "./providerDriverMeta";
|
||||
import {
|
||||
buildProviderInstanceUpdatePatch,
|
||||
@@ -1010,6 +1015,55 @@ export function ProviderSettingsPanel() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const runProviderCompatibilityUpdate = useCallback(async (provider: ServerProvider) => {
|
||||
const targetVersion = provider.compatibilityAdvisory?.recommendedVersion ?? null;
|
||||
if (!targetVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
let started = false;
|
||||
setUpdatingProviderDrivers((previous) => {
|
||||
if (previous.has(provider.driver)) {
|
||||
return previous;
|
||||
}
|
||||
started = true;
|
||||
const next = new Set(previous);
|
||||
next.add(provider.driver);
|
||||
return next;
|
||||
});
|
||||
if (!started) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await ensureLocalApi().server.updateProvider({
|
||||
provider: provider.driver,
|
||||
instanceId: provider.instanceId,
|
||||
targetVersion,
|
||||
});
|
||||
} catch (error) {
|
||||
toastManager.add(
|
||||
stackedThreadToast({
|
||||
type: "error",
|
||||
title: `Could not update ${PROVIDER_DISPLAY_NAMES[provider.driver] ?? provider.driver}`,
|
||||
description:
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "The provider update command could not be started.",
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
setUpdatingProviderDrivers((previous) => {
|
||||
if (!previous.has(provider.driver)) {
|
||||
return previous;
|
||||
}
|
||||
const next = new Set(previous);
|
||||
next.delete(provider.driver);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
interface InstanceRow {
|
||||
readonly instanceId: ProviderInstanceId;
|
||||
readonly instance: ProviderInstanceConfig;
|
||||
@@ -1245,6 +1299,22 @@ export function ProviderSettingsPanel() {
|
||||
updateCandidate !== undefined &&
|
||||
canOneClickUpdateProviderCandidate(updateCandidate, serverProviders) &&
|
||||
!updatingProviderDrivers.has(updateCandidate.driver);
|
||||
const compatibilityUpdateCommand = getProviderCompatibilityUpdateCommand(liveProvider);
|
||||
const showInlineCompatibilityUpdateButton =
|
||||
canRunProviderCompatibilityUpdate(liveProvider) &&
|
||||
compatibilityUpdateCommand !== null &&
|
||||
Boolean(liveProvider?.compatibilityAdvisory?.recommendedVersion);
|
||||
const isCompatibilityUpdateRunning =
|
||||
liveProvider !== undefined &&
|
||||
(updatingProviderDrivers.has(liveProvider.driver) ||
|
||||
serverProviders.some(
|
||||
(provider) =>
|
||||
provider.driver === liveProvider.driver && isProviderUpdateActive(provider),
|
||||
));
|
||||
const canRunInlineCompatibilityUpdate =
|
||||
showInlineCompatibilityUpdateButton &&
|
||||
liveProvider !== undefined &&
|
||||
!updatingProviderDrivers.has(liveProvider.driver);
|
||||
const modelPreferences = settings.providerModelPreferences?.[row.instanceId] ?? {
|
||||
hiddenModels: [],
|
||||
modelOrder: [],
|
||||
@@ -1318,6 +1388,19 @@ export function ProviderSettingsPanel() {
|
||||
: undefined
|
||||
}
|
||||
isUpdating={showInlineUpdateButton ? isDriverUpdateRunning : undefined}
|
||||
onRunCompatibilityUpdate={
|
||||
showInlineCompatibilityUpdateButton && liveProvider
|
||||
? () => {
|
||||
if (!canRunInlineCompatibilityUpdate) {
|
||||
return;
|
||||
}
|
||||
void runProviderCompatibilityUpdate(liveProvider);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
isCompatibilityUpdating={
|
||||
showInlineCompatibilityUpdateButton ? isCompatibilityUpdateRunning : undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
getProviderCompatibilityAdvisoryPresentation,
|
||||
getProviderCompatibilityUpdateCommand,
|
||||
} 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.",
|
||||
updateCommand: null,
|
||||
canUpdate: false,
|
||||
emphasis: "strong",
|
||||
});
|
||||
});
|
||||
|
||||
it("derives targeted compatibility update commands from package install commands", () => {
|
||||
expect(
|
||||
getProviderCompatibilityUpdateCommand({
|
||||
compatibilityAdvisory: {
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.128.0",
|
||||
message: "Known incompatible.",
|
||||
recommendedRange: ">=0.129.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [],
|
||||
},
|
||||
versionAdvisory: {
|
||||
status: "behind_latest",
|
||||
currentVersion: "0.128.0",
|
||||
latestVersion: "0.130.0",
|
||||
checkedAt: "2026-05-13T00:00:00.000Z",
|
||||
message: "Update available.",
|
||||
updateCommand: "vp i -g @openai/codex",
|
||||
canUpdate: true,
|
||||
},
|
||||
}),
|
||||
).toBe("vp i -g @openai/[email protected]");
|
||||
});
|
||||
});
|
||||
@@ -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,85 @@ export function getProviderVersionAdvisoryPresentation(
|
||||
emphasis: "normal" as const,
|
||||
};
|
||||
}
|
||||
|
||||
function makeTargetedUpdateCommand(input: {
|
||||
readonly updateCommand: string | null | undefined;
|
||||
readonly recommendedVersion: string | null | undefined;
|
||||
}): string | null {
|
||||
if (!input.updateCommand || !input.recommendedVersion) {
|
||||
return null;
|
||||
}
|
||||
if (!input.updateCommand.includes("@latest")) {
|
||||
const packageNameMatch = input.updateCommand.match(
|
||||
/(?:^|\s)(@[^\s]+\/[^\s@]+|[^\s@]+)(?=\s*$)/,
|
||||
);
|
||||
if (!packageNameMatch?.[1]) {
|
||||
return null;
|
||||
}
|
||||
return input.updateCommand.replace(
|
||||
packageNameMatch[1],
|
||||
`${packageNameMatch[1]}@${input.recommendedVersion}`,
|
||||
);
|
||||
}
|
||||
return input.updateCommand.replace("@latest", `@${input.recommendedVersion}`);
|
||||
}
|
||||
|
||||
export function getProviderCompatibilityUpdateCommand(
|
||||
provider: Pick<ServerProvider, "compatibilityAdvisory" | "versionAdvisory"> | null | undefined,
|
||||
): string | null {
|
||||
const compatibilityAdvisory = provider?.compatibilityAdvisory;
|
||||
if (!compatibilityAdvisory || compatibilityAdvisory.status === "supported") {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
compatibilityAdvisory.updateCommand ??
|
||||
makeTargetedUpdateCommand({
|
||||
updateCommand: provider.versionAdvisory?.updateCommand,
|
||||
recommendedVersion: compatibilityAdvisory.recommendedVersion,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function canRunProviderCompatibilityUpdate(
|
||||
provider: Pick<ServerProvider, "compatibilityAdvisory" | "versionAdvisory"> | null | undefined,
|
||||
): boolean {
|
||||
const compatibilityAdvisory = provider?.compatibilityAdvisory;
|
||||
if (!compatibilityAdvisory || compatibilityAdvisory.status === "supported") {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
compatibilityAdvisory.canUpdate === true ||
|
||||
(provider?.versionAdvisory?.canUpdate === true &&
|
||||
getProviderCompatibilityUpdateCommand(provider) !== null)
|
||||
);
|
||||
}
|
||||
|
||||
export function getProviderCompatibilityAdvisoryPresentation(
|
||||
advisory: ServerProviderCompatibilityAdvisory | undefined,
|
||||
): {
|
||||
readonly title: string;
|
||||
readonly detail: string;
|
||||
readonly updateCommand: string | null;
|
||||
readonly canUpdate: boolean;
|
||||
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,
|
||||
updateCommand: advisory.updateCommand ?? null,
|
||||
canUpdate: advisory.canUpdate === true,
|
||||
emphasis: advisory.severity === "error" ? "strong" : "normal",
|
||||
};
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import { createModelSelection } from "@t3tools/shared/model";
|
||||
// `stickyModelSelectionByProvider` maps are keyed by `ProviderInstanceId`
|
||||
// in production; these aliases keep the legacy-key migration tests concise.
|
||||
const CODEX_INSTANCE = ProviderInstanceId.make("codex");
|
||||
const CODEX_SECONDARY_INSTANCE = ProviderInstanceId.make("codex_secondary");
|
||||
const CLAUDE_AGENT_INSTANCE = ProviderInstanceId.make("claudeAgent");
|
||||
const CURSOR_INSTANCE = ProviderInstanceId.make("cursor");
|
||||
const CODEX_DRIVER = ProviderDriverKind.make("codex");
|
||||
@@ -1202,43 +1201,6 @@ describe("composerDraftStore modelSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("stores provider option changes on a selected custom instance", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProviderModelOptions(
|
||||
threadRef,
|
||||
CODEX_DRIVER,
|
||||
toSelections({ reasoningEffort: "low" }),
|
||||
{
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
model: "gpt-5-codex",
|
||||
persistSticky: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
expect(draftFor(threadId, TEST_ENVIRONMENT_ID)?.activeProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyActiveProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_INSTANCE]).toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("updates only the draft when sticky persistence is disabled", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
|
||||
@@ -371,7 +371,6 @@ interface ComposerDraftStoreState {
|
||||
provider: ProviderDriverKind,
|
||||
nextProviderOptions: ReadonlyArray<ProviderOptionSelection> | null | undefined,
|
||||
options?: {
|
||||
instanceId?: ProviderInstanceId | null | undefined;
|
||||
model?: string | null | undefined;
|
||||
persistSticky?: boolean;
|
||||
},
|
||||
@@ -2457,7 +2456,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (normalizedProvider === null) {
|
||||
return;
|
||||
}
|
||||
const instanceKey = options?.instanceId ?? defaultInstanceIdForDriver(normalizedProvider);
|
||||
const instanceKey = defaultInstanceIdForDriver(normalizedProvider);
|
||||
const fallbackModel =
|
||||
normalizeModelSlug(options?.model, normalizedProvider) ??
|
||||
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider] ??
|
||||
@@ -2502,9 +2501,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const { options: _, ...rest } = stickyBase;
|
||||
nextStickyMap[instanceKey] = rest as ModelSelection;
|
||||
}
|
||||
nextStickyActiveProvider = options.instanceId
|
||||
? instanceKey
|
||||
: (base.activeProvider ?? instanceKey);
|
||||
nextStickyActiveProvider = base.activeProvider ?? instanceKey;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -2517,7 +2514,6 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
...(options?.instanceId ? { activeProvider: instanceKey } : {}),
|
||||
modelSelectionByProvider: nextMap,
|
||||
};
|
||||
const nextDraftsByThreadKey = { ...state.draftsByThreadKey };
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { CommandId, MessageId, ProjectId, ThreadId } from "@t3tools/contracts";
|
||||
import { type CxOptions, cx } from "class-variance-authority";
|
||||
import * as Encoding from "effect/Encoding";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import * as Random from "effect/Random";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { DraftId } from "../composerDraftStore";
|
||||
|
||||
export function cn(...inputs: CxOptions) {
|
||||
@@ -20,16 +21,11 @@ export function isLinuxPlatform(platform: string): boolean {
|
||||
return /linux/i.test(platform);
|
||||
}
|
||||
|
||||
export function randomHex(byteLength: number): string {
|
||||
return Encoding.encodeHex(globalThis.crypto.getRandomValues(new Uint8Array(byteLength)));
|
||||
}
|
||||
|
||||
export function randomUUID(): string {
|
||||
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
||||
bytes[6] = (bytes[6]! & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8]! & 0x3f) | 0x80;
|
||||
const hex = Encoding.encodeHex(bytes);
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
||||
if (typeof crypto.randomUUID === "function") {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
return Effect.runSync(Random.nextUUIDv4);
|
||||
}
|
||||
|
||||
export const newCommandId = (): CommandId => CommandId.make(randomUUID());
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "^0.9.7",
|
||||
"@vercel/config": "^0.3.0",
|
||||
"typescript": "catalog:",
|
||||
},
|
||||
},
|
||||
@@ -272,7 +273,7 @@
|
||||
"node-pty",
|
||||
],
|
||||
"patchedDependencies": {
|
||||
"[email protected].73": "patches/[email protected].73.patch",
|
||||
"[email protected].59": "patches/[email protected].59.patch",
|
||||
},
|
||||
"overrides": {
|
||||
"@effect/atom-react": "catalog:",
|
||||
@@ -285,18 +286,18 @@
|
||||
"vite": "^8.0.0",
|
||||
},
|
||||
"catalog": {
|
||||
"@effect/atom-react": "4.0.0-beta.73",
|
||||
"@effect/atom-react": "4.0.0-beta.59",
|
||||
"@effect/language-service": "0.84.2",
|
||||
"@effect/openapi-generator": "4.0.0-beta.73",
|
||||
"@effect/platform-bun": "4.0.0-beta.73",
|
||||
"@effect/platform-node": "4.0.0-beta.73",
|
||||
"@effect/platform-node-shared": "4.0.0-beta.73",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.73",
|
||||
"@effect/vitest": "4.0.0-beta.73",
|
||||
"@effect/openapi-generator": "4.0.0-beta.59",
|
||||
"@effect/platform-bun": "4.0.0-beta.59",
|
||||
"@effect/platform-node": "4.0.0-beta.59",
|
||||
"@effect/platform-node-shared": "4.0.0-beta.59",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.59",
|
||||
"@effect/vitest": "4.0.0-beta.59",
|
||||
"@pierre/diffs": "1.1.20",
|
||||
"@types/bun": "^1.3.11",
|
||||
"@types/node": "^24.10.13",
|
||||
"effect": "4.0.0-beta.73",
|
||||
"effect": "4.0.0-beta.59",
|
||||
"tsdown": "^0.20.3",
|
||||
"typescript": "^5.7.3",
|
||||
"vitest": "^4.0.0",
|
||||
@@ -384,21 +385,21 @@
|
||||
|
||||
"@dnd-kit/utilities": ["@dnd-kit/[email protected]", "", { "dependencies": { "tslib": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0" } }, "sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg=="],
|
||||
|
||||
"@effect/atom-react": ["@effect/[email protected].73", "", { "peerDependencies": { "effect": "^4.0.0-beta.73", "react": "^19.2.4", "scheduler": "*" } }, "sha512-RjNqEMV3z3iEFRBtJ1RVuxBNFMYxhDo2iRwck3kBYjrBuXWrKIRyqnunWJdL2KX97Gqp0orxaujG7qnIA5aIEA=="],
|
||||
"@effect/atom-react": ["@effect/[email protected].59", "", { "peerDependencies": { "effect": "^4.0.0-beta.59", "react": "^19.2.4", "scheduler": "*" } }, "sha512-VkznQz5c+Z/BLxX+hQNPzPOyUnLQjnbppFSNP7tbPru7HKR4ihzCDC6Xjbx87156MOrZ+JOa6shTMbmvGT5W0w=="],
|
||||
|
||||
"@effect/language-service": ["@effect/[email protected]", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-l04qNxpiA8rY5yXWckRPJ7Mk5MNerXuNymSFf+IdflfI5i8jgL1bpBNLuP6ijg7wgjdHc/KmTnCj2kT0SCntuA=="],
|
||||
|
||||
"@effect/openapi-generator": ["@effect/[email protected].73", "", { "peerDependencies": { "@effect/platform-node": "^4.0.0-beta.73", "effect": "^4.0.0-beta.73" }, "bin": { "openapigen": "dist/bin.js" } }, "sha512-tN1mKreMo6kypkuPy8Jt3eGoI0DberzD2/5XxEh17lTdyLg7/SUZv3LssRxtzO5+uIYzLNIHfT2zESz7gjCnwA=="],
|
||||
"@effect/openapi-generator": ["@effect/[email protected].59", "", { "peerDependencies": { "@effect/platform-node": "^4.0.0-beta.59", "effect": "^4.0.0-beta.59" }, "bin": { "openapigen": "dist/bin.js" } }, "sha512-y1KF6mEb3pA5AdQsNGeWxV42Xi1uBt9Wzo5xMsp06j/WkOM2vWFmvSXw6xvwINAUi1HVjdOLo3xnTXtSv9YdRg=="],
|
||||
|
||||
"@effect/platform-bun": ["@effect/[email protected].73", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.73" }, "peerDependencies": { "effect": "^4.0.0-beta.73" } }, "sha512-AQcE89eEVp0xA3SafaswiHPfo6V2YPg7T6PQbQqYK4/S2Sia5cadCm/6y7pfRmuOd4jkWI6VMbNtEDkM0NOBpw=="],
|
||||
"@effect/platform-bun": ["@effect/[email protected].59", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.59" }, "peerDependencies": { "effect": "^4.0.0-beta.59" } }, "sha512-1jXCIx34X80ojiK9ACO9Q7RST9CXudRmlAbsP4kPqjUo6aqOuGSWXq9ueBO4LbaIZiioRxtTciom35U9ldfTkQ=="],
|
||||
|
||||
"@effect/platform-node": ["@effect/[email protected].73", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.73", "mime": "^4.1.0", "undici": "^8.2.0" }, "peerDependencies": { "effect": "^4.0.0-beta.73", "ioredis": "^5.7.0" } }, "sha512-YYkUnmcs6EiRk8K/xNCU3l3jl1YbrhCHCJp+y32DWlKhhZot24/hvw0zYw0aymAtuI9dzAdPryVZkksH4+7ovw=="],
|
||||
"@effect/platform-node": ["@effect/[email protected].59", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.59", "mime": "^4.1.0", "undici": "^8.0.2" }, "peerDependencies": { "effect": "^4.0.0-beta.59", "ioredis": "^5.7.0" } }, "sha512-jHRW0l953FjYNhQHexr48jFiBu5iGEZH5nmKD6Ha+lPtm1MrKG2V4njfWA3Fv0nUmd3VN87eBJ557wU0twN1Hg=="],
|
||||
|
||||
"@effect/platform-node-shared": ["@effect/[email protected].73", "", { "dependencies": { "@types/ws": "^8.18.1", "ws": "^8.20.0" }, "peerDependencies": { "effect": "^4.0.0-beta.73" } }, "sha512-/7L8eftDS40VWgLx2GVtBtb8x97Vx4OF5IlRJfh14L5xDFdb9MZXxOuHfHAi+71d90pkbFpOFVtQCSOBWKRAWg=="],
|
||||
"@effect/platform-node-shared": ["@effect/[email protected].59", "", { "dependencies": { "@types/ws": "^8.18.1", "ws": "^8.20.0" }, "peerDependencies": { "effect": "^4.0.0-beta.59" } }, "sha512-fGwFJuG0Te9U/ZeqeDZ2HcSKZBhX5wLjX2/Rxb5+yaOkvvFAN9MvIh05R0QQK5DCcERvnbhHSl1CjSIAN4aEwQ=="],
|
||||
|
||||
"@effect/sql-sqlite-bun": ["@effect/[email protected].73", "", { "peerDependencies": { "effect": "^4.0.0-beta.73" } }, "sha512-dkTDDeBLjaKo7h1IE049Oj2BDKQOT+Kc57KbBVaSk36dRdsEmVspRMP7OGbZj3etJU3lL1GJi1BIfnb4N3uMRw=="],
|
||||
"@effect/sql-sqlite-bun": ["@effect/[email protected].59", "", { "peerDependencies": { "effect": "^4.0.0-beta.59" } }, "sha512-qZWt2HeLgSY8ygEfwbldK9lJ5xg/WP4lgCp1VLlyE8BImSB5g1h+UbhitXr+pOIf+ry4Xmc4ycp7YwTBOFH5/A=="],
|
||||
|
||||
"@effect/vitest": ["@effect/[email protected].73", "", { "peerDependencies": { "effect": "^4.0.0-beta.73", "vitest": "^3.0.0 || ^4.0.0" } }, "sha512-HIZa0aekh0ak1YfzCv8GTN75Vbvxp8g+W+z9KczvtUT+LvitX3i9nhLWZLKRrUP1LaJFLPJS2UG9ZGXjxgbjBg=="],
|
||||
"@effect/vitest": ["@effect/[email protected].59", "", { "peerDependencies": { "effect": "^4.0.0-beta.59", "vitest": "^3.0.0 || ^4.0.0" } }, "sha512-jhpJbpDs1ED58SmFzcfmqLXxle84fiexaMEhV8SBl8WC2GM3FT5DW0WJYFjbZIH5/735brp3iGdjY5/uAxS7Bg=="],
|
||||
|
||||
"@electron/get": ["@electron/[email protected]", "", { "dependencies": { "debug": "^4.1.1", "env-paths": "^2.2.0", "fs-extra": "^8.1.0", "got": "^11.8.5", "progress": "^2.0.3", "semver": "^6.2.0", "sumchecker": "^3.0.1" }, "optionalDependencies": { "global-agent": "^3.0.0" } }, "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ=="],
|
||||
|
||||
@@ -608,17 +609,17 @@
|
||||
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/[email protected]", "", { "dependencies": { "@hono/node-server": "^1.19.9", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.2.1", "express-rate-limit": "^8.2.1", "hono": "^4.11.4", "jose": "^6.1.3", "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.25 || ^4.0", "zod-to-json-schema": "^3.25.1" }, "peerDependencies": { "@cfworker/json-schema": "^4.1.1" }, "optionalPeers": ["@cfworker/json-schema"] }, "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-arm64": ["@msgpackr-extract/[email protected].4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-LCkGo6JDfaBhgST7UpPWgNgLINpcpabaHfyz5OBx75nUYxBsaEPxjnyNjWpeb/xBup/682QnBfRBy2/LvPutZQ=="],
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-arm64": ["@msgpackr-extract/[email protected].3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-x64": ["@msgpackr-extract/[email protected].4", "", { "os": "darwin", "cpu": "x64" }, "sha512-zExlW9zUJKZH/tOtVMttwjKa4Xm/3KcNjnE3dPN92uCktwavMxpgCA3MoJK/DOnTWsQgo224OaST27/mPNAf+w=="],
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-x64": ["@msgpackr-extract/[email protected].3", "", { "os": "darwin", "cpu": "x64" }, "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm": ["@msgpackr-extract/[email protected].4", "", { "os": "linux", "cpu": "arm" }, "sha512-Tg3yX65f5GbtXLkrYEHE5oibZG9epyYWas7FogTTEJeDEF9JlXJzKgXaNhT3UXlTOeA+AfZpYZYZ0uPj7Cfquw=="],
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm": ["@msgpackr-extract/[email protected].3", "", { "os": "linux", "cpu": "arm" }, "sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm64": ["@msgpackr-extract/[email protected].4", "", { "os": "linux", "cpu": "arm64" }, "sha512-dgX0P/9wGPJeHFBG+ZmhgE6bmtMt7NP5CRBGyyktpopdk/mW4POnrpQsSLtKI1dwpc+pPLuXHDh6vvskyQE/sw=="],
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm64": ["@msgpackr-extract/[email protected].3", "", { "os": "linux", "cpu": "arm64" }, "sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-linux-x64": ["@msgpackr-extract/[email protected].4", "", { "os": "linux", "cpu": "x64" }, "sha512-8TNXMEjJc3QEy7R/x1INhgiU+XakDAFUzBhaz7+Rbrs8NH5UQeHQxxmzsSBJGyV6I1jW79undiQm8tOI+D+8FQ=="],
|
||||
"@msgpackr-extract/msgpackr-extract-linux-x64": ["@msgpackr-extract/[email protected].3", "", { "os": "linux", "cpu": "x64" }, "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-win32-x64": ["@msgpackr-extract/[email protected].4", "", { "os": "win32", "cpu": "x64" }, "sha512-CmCXPQrkbwExx3j946/PtHWHbYJiCRBRDl4BlkRQcJB/YOwQxJRTpoo7aTsortjgoJ1x7opzTSxn7C+ASSLVjQ=="],
|
||||
"@msgpackr-extract/msgpackr-extract-win32-x64": ["@msgpackr-extract/[email protected].3", "", { "os": "win32", "cpu": "x64" }, "sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ=="],
|
||||
|
||||
"@mswjs/interceptors": ["@mswjs/[email protected]", "", { "dependencies": { "@open-draft/deferred-promise": "^2.2.0", "@open-draft/logger": "^0.3.0", "@open-draft/until": "^2.0.0", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", "strict-event-emitter": "^0.5.1" } }, "sha512-cXu86tF4VQVfwz8W1SPbhoRyHJkti6mjH/XJIxp40jhO4j2k1m4KYrEykxqWPkFF3vrK4rgQppBh//AwyGSXPA=="],
|
||||
|
||||
@@ -972,7 +973,7 @@
|
||||
|
||||
"acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="],
|
||||
|
||||
"ajv": ["ajv@8.18.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A=="],
|
||||
"ajv": ["ajv@6.15.0", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw=="],
|
||||
|
||||
"ajv-draft-04": ["[email protected]", "", { "peerDependencies": { "ajv": "^8.5.0" }, "optionalPeers": ["ajv"] }, "sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw=="],
|
||||
|
||||
@@ -1160,7 +1161,7 @@
|
||||
|
||||
"ee-first": ["[email protected]", "", {}, "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="],
|
||||
|
||||
"effect": ["[email protected].73", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.8.0", "find-my-way-ts": "^0.1.6", "ini": "^7.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^2.0.1", "multipasta": "^0.2.7", "toml": "^4.1.1", "uuid": "^14.0.0", "yaml": "^2.9.0" } }, "sha512-rL7jjpT31JhxNiZ0X4sgu+WSJi7uwKTX2jz2OW7PrPLfz5DPjT9iXxxVrekxwpfGdgo92bvxbCc5kBlXgusQJw=="],
|
||||
"effect": ["[email protected].59", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.6.0", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.9", "multipasta": "^0.2.7", "toml": "^4.1.1", "uuid": "^13.0.0", "yaml": "^2.8.3" } }, "sha512-xyUDLeHSe8d6lWGOvR6Fgn2HL6gYeTZ/S4Jzk9uc4ZUxMPPsNZlNXrvk0C7/utQFzeX7uAWcVnG2BjbA0SRoAA=="],
|
||||
|
||||
"effect-acp": ["effect-acp@workspace:packages/effect-acp"],
|
||||
|
||||
@@ -1230,7 +1231,7 @@
|
||||
|
||||
"extract-zip": ["[email protected]", "", { "dependencies": { "debug": "^4.1.1", "get-stream": "^5.1.0", "yauzl": "^2.10.0" }, "optionalDependencies": { "@types/yauzl": "^2.9.1" }, "bin": { "extract-zip": "cli.js" } }, "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg=="],
|
||||
|
||||
"fast-check": ["fast-check@4.8.0", "", { "dependencies": { "pure-rand": "^8.0.0" } }, "sha512-GOJ158CUMnN6cSahsv4+ExARvIDuzzinFjkp0E9WtiBa5zcVeLozVkWaE4IzFcc+Y48Wp1EDlUZsXRyAztQcSg=="],
|
||||
"fast-check": ["fast-check@4.6.0", "", { "dependencies": { "pure-rand": "^8.0.0" } }, "sha512-h7H6Dm0Fy+H4ciQYFxFjXnXkzR2kr9Fb22c0UBpHnm59K2zpr2t13aPTHlltFiNT6zuxp6HMPAVVvgur4BLdpA=="],
|
||||
|
||||
"fast-deep-equal": ["[email protected]", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
||||
|
||||
@@ -1346,7 +1347,7 @@
|
||||
|
||||
"inherits": ["[email protected]", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
|
||||
|
||||
"ini": ["ini@7.0.0", "", {}, "sha512-ifK0CgjALofS5bkrcTy4RaQ9Vx2Knf/eLeIO+NaswQEpH1UblrtTSCIvN71qQDMq0PeQ/SSPojvEJp9vvvfr+w=="],
|
||||
"ini": ["ini@6.0.0", "", {}, "sha512-IBTdIkzZNOpqm7q3dRqJvMaldXjDHWkEDfrwGEQTs5eaQMWV+djAhR+wahyNNMAa+qpbDUhBMVt4ZKNwpPm7xQ=="],
|
||||
|
||||
"inline-style-parser": ["[email protected]", "", {}, "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA=="],
|
||||
|
||||
@@ -1408,7 +1409,7 @@
|
||||
|
||||
"json-schema-to-ts": ["[email protected]", "", { "dependencies": { "@babel/runtime": "^7.18.3", "ts-algebra": "^2.0.0" } }, "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g=="],
|
||||
|
||||
"json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
"json-schema-traverse": ["json-schema-traverse@0.4.1", "", {}, "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="],
|
||||
|
||||
"json-schema-typed": ["[email protected]", "", {}, "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA=="],
|
||||
|
||||
@@ -1590,9 +1591,9 @@
|
||||
|
||||
"ms": ["[email protected]", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
|
||||
"msgpackr": ["msgpackr@2.0.2", "", { "optionalDependencies": { "msgpackr-extract": "^3.0.4" } }, "sha512-c5hYOXFbP79Slh6Dzd2wzk+jnV7mX1UxfMYtilnY1NmalXPqG8DGb5cYCMBrW4AsH3zekBBZd4QrKz9NhtvYLQ=="],
|
||||
"msgpackr": ["msgpackr@1.11.9", "", { "optionalDependencies": { "msgpackr-extract": "^3.0.2" } }, "sha512-FkoAAyyA6HM8wL882EcEyFZ9s7hVADSwG9xrVx3dxxNQAtgADTrJoEWivID82Iv1zWDsv/OtbrrcZAzGzOMdNw=="],
|
||||
|
||||
"msgpackr-extract": ["[email protected].4", "", { "dependencies": { "node-gyp-build-optional-packages": "5.2.2" }, "optionalDependencies": { "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.4", "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.4", "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.4", "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.4", "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.4", "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.4" }, "bin": { "download-msgpackr-prebuilds": "bin/download-prebuilds.js" } }, "sha512-4kmO/MdyUIkLIvTPr8VHLil4AtoKIoniWPIEk5+CDy0xnWC84azhSFmuJ7PxZdsYtiP5kEeQsORAVIeMgxT+Hw=="],
|
||||
"msgpackr-extract": ["[email protected].3", "", { "dependencies": { "node-gyp-build-optional-packages": "5.2.2" }, "optionalDependencies": { "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3", "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3", "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3", "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3", "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3", "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3" }, "bin": { "download-msgpackr-prebuilds": "bin/download-prebuilds.js" } }, "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA=="],
|
||||
|
||||
"msw": ["[email protected]", "", { "dependencies": { "@inquirer/confirm": "^5.0.0", "@mswjs/interceptors": "^0.41.2", "@open-draft/deferred-promise": "^2.2.0", "@types/statuses": "^2.0.6", "cookie": "^1.0.2", "graphql": "^16.12.0", "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", "path-to-regexp": "^6.3.0", "picocolors": "^1.1.1", "rettime": "^0.10.1", "statuses": "^2.0.2", "strict-event-emitter": "^0.5.1", "tough-cookie": "^6.0.0", "type-fest": "^5.2.0", "until-async": "^3.0.2", "yargs": "^17.7.2" }, "peerDependencies": { "typescript": ">= 4.8.x" }, "optionalPeers": ["typescript"], "bin": { "msw": "cli/index.js" } }, "sha512-dVg20zi2I2EvnwH/+WupzsOC2mCa7qsIhyMAWtfRikn6RKtwL9+7SaF1IQ5LyZry4tlUtf6KyTVhnlQiZXozTQ=="],
|
||||
|
||||
@@ -2022,7 +2023,7 @@
|
||||
|
||||
"use-sync-external-store": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="],
|
||||
|
||||
"uuid": ["uuid@14.0.0", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg=="],
|
||||
"uuid": ["uuid@13.0.0", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w=="],
|
||||
|
||||
"vary": ["[email protected]", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],
|
||||
|
||||
@@ -2096,7 +2097,7 @@
|
||||
|
||||
"yallist": ["[email protected]", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
|
||||
|
||||
"yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="],
|
||||
"yaml": ["yaml@2.8.3", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg=="],
|
||||
|
||||
"yaml-language-server": ["[email protected]", "", { "dependencies": { "@vscode/l10n": "^0.0.18", "ajv": "^8.17.1", "ajv-draft-04": "^1.0.0", "prettier": "^3.5.0", "request-light": "^0.5.7", "vscode-json-languageservice": "4.1.8", "vscode-languageserver": "^9.0.0", "vscode-languageserver-textdocument": "^1.0.1", "vscode-languageserver-types": "^3.16.0", "vscode-uri": "^3.0.2", "yaml": "2.7.1" }, "bin": { "yaml-language-server": "bin/yaml-language-server" } }, "sha512-qhjK/bzSRZ6HtTvgeFvjNPJGWdZ0+x5NREV/9XZWFjIGezew2b4r5JPy66IfOhd5OA7KeFwk1JfmEbnTvev0cA=="],
|
||||
|
||||
@@ -2112,7 +2113,7 @@
|
||||
|
||||
"yoctocolors-cjs": ["[email protected]", "", {}, "sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw=="],
|
||||
|
||||
"zod": ["zod@4.3.6", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
||||
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"zod-to-json-schema": ["[email protected]", "", { "peerDependencies": { "zod": "^3.25.28 || ^4" } }, "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA=="],
|
||||
|
||||
@@ -2120,6 +2121,8 @@
|
||||
|
||||
"zwitch": ["[email protected]", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
|
||||
|
||||
"@anthropic-ai/claude-agent-sdk/zod": ["[email protected]", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
||||
|
||||
"@astrojs/language-server/@astrojs/compiler": ["@astrojs/[email protected]", "", {}, "sha512-f3FN83d2G/v32ipNClRKgYv30onQlMZX1vCeZMjPsMMPl1mDpmbl0+N5BYo4S/ofzqJyS5hvwacEo0CCVDn/Qg=="],
|
||||
|
||||
"@astrojs/yaml2ts/yaml": ["[email protected]", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A=="],
|
||||
@@ -2154,6 +2157,10 @@
|
||||
|
||||
"@inquirer/core/wrap-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA=="],
|
||||
|
||||
"@modelcontextprotocol/sdk/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A=="],
|
||||
|
||||
"@modelcontextprotocol/sdk/zod": ["[email protected]", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
||||
|
||||
"@pierre/diffs/shiki": ["[email protected]", "", { "dependencies": { "@shikijs/core": "3.23.0", "@shikijs/engine-javascript": "3.23.0", "@shikijs/engine-oniguruma": "3.23.0", "@shikijs/langs": "3.23.0", "@shikijs/themes": "3.23.0", "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-55Dj73uq9ZXL5zyeRPzHQsK7Nbyt6Y10k5s7OjuFZGMhpp4r/rsLBH0o/0fstIzX1Lep9VxefWljK/SKCzygIA=="],
|
||||
|
||||
"@rolldown/plugin-babel/rolldown": ["[email protected]", "", { "dependencies": { "@oxc-project/types": "=0.115.0", "@rolldown/pluginutils": "1.0.0-rc.9" }, "optionalDependencies": { "@rolldown/binding-android-arm64": "1.0.0-rc.9", "@rolldown/binding-darwin-arm64": "1.0.0-rc.9", "@rolldown/binding-darwin-x64": "1.0.0-rc.9", "@rolldown/binding-freebsd-x64": "1.0.0-rc.9", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.9", "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.9", "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.9", "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.9", "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.9", "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.9", "@rolldown/binding-linux-x64-musl": "1.0.0-rc.9", "@rolldown/binding-openharmony-arm64": "1.0.0-rc.9", "@rolldown/binding-wasm32-wasi": "1.0.0-rc.9", "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.9", "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.9" }, "bin": { "rolldown": "bin/cli.mjs" } }, "sha512-9EbgWge7ZH+yqb4d2EnELAntgPTWbfL8ajiTW+SyhJEC4qhBbkCKbqFV4Ge4zmu5ziQuVbWxb/XwLZ+RIO7E8Q=="],
|
||||
@@ -2184,26 +2191,24 @@
|
||||
|
||||
"@tanstack/react-store/@tanstack/store": ["@tanstack/[email protected]", "", {}, "sha512-PtOisLjUZPz5VyPRSCGjNOlwTvabdTBQ2K80DpVL1chGVr35WRxfeavAPdNq6pm/t7F8GhoR2qtmkkqtCEtHYw=="],
|
||||
|
||||
"@tanstack/router-generator/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@tanstack/router-plugin/chokidar": ["[email protected]", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
|
||||
|
||||
"@tanstack/router-plugin/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@tanstack/router-utils/@babel/generator": ["@babel/[email protected]", "", { "dependencies": { "@babel/parser": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw=="],
|
||||
|
||||
"@vercel/config/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@vercel/routing-utils/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw=="],
|
||||
|
||||
"@vercel/routing-utils/path-to-regexp": ["[email protected]", "", {}, "sha512-h9DqehX3zZZDCEm+xbfU0ZmwCGFCAAraPJWMXJ4+v32NjZJilVg3k1TcKsRgIb8IQ/izZSaydDc1OhJCZvs2Dw=="],
|
||||
|
||||
"@vitest/browser/ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
|
||||
|
||||
"ajv-draft-04/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A=="],
|
||||
|
||||
"ajv-formats/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A=="],
|
||||
|
||||
"anymatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"ast-kit/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^8.0.0-rc.2" }, "bin": "./bin/babel-parser.js" }, "sha512-29AhEtcq4x8Dp3T72qvUMZHx0OMXCj4Jy/TEReQa+KWLln524Cj1fWb3QFi0l/xSpptQBR6y9RNEXuxpFvwiUQ=="],
|
||||
|
||||
"astro/zod": ["[email protected]", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
||||
|
||||
"clone-response/mimic-response": ["[email protected]", "", {}, "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="],
|
||||
|
||||
"csso/css-tree": ["[email protected]", "", { "dependencies": { "mdn-data": "2.0.28", "source-map-js": "^1.0.1" } }, "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA=="],
|
||||
@@ -2242,6 +2247,8 @@
|
||||
|
||||
"vscode-json-languageservice/jsonc-parser": ["[email protected]", "", {}, "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ=="],
|
||||
|
||||
"yaml-language-server/ajv": ["[email protected]", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A=="],
|
||||
|
||||
"yaml-language-server/request-light": ["[email protected]", "", {}, "sha512-3Zjgh+8b5fhRJBQZoy+zbVKpAQGLyka0MPgW3zruTF4dFFJ8Fqcfu9YsAvi/rvdcaTeWG3MkbZv4WKxAn/84Lg=="],
|
||||
|
||||
"yaml-language-server/yaml": ["[email protected]", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ=="],
|
||||
@@ -2254,6 +2261,8 @@
|
||||
|
||||
"@electron/get/fs-extra/universalify": ["[email protected]", "", {}, "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="],
|
||||
|
||||
"@modelcontextprotocol/sdk/ajv/json-schema-traverse": ["[email protected]", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"@pierre/diffs/shiki/@shikijs/core": ["@shikijs/[email protected]", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-NSWQz0riNb67xthdm5br6lAkvpDJRTgB36fxlo37ZzM2yq0PQFFzbd8psqC2XMPgCzo1fW6cVi18+ArJ44wqgA=="],
|
||||
|
||||
"@pierre/diffs/shiki/@shikijs/engine-javascript": ["@shikijs/[email protected]", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^4.3.4" } }, "sha512-aHt9eiGFobmWR5uqJUViySI1bHMqrAgamWE1TYSUoftkAeCCAiGawPMwM+VCadylQtF4V3VNOZ5LmfItH5f3yA=="],
|
||||
@@ -2322,7 +2331,9 @@
|
||||
|
||||
"@tanstack/router-plugin/chokidar/readdirp": ["[email protected]", "", { "dependencies": { "picomatch": "^2.2.1" } }, "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA=="],
|
||||
|
||||
"@vercel/routing-utils/ajv/json-schema-traverse": ["json-schema-traverse@0.4.1", "", {}, "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="],
|
||||
"ajv-draft-04/ajv/json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"ajv-formats/ajv/json-schema-traverse": ["[email protected]", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"ast-kit/@babel/parser/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.2", "@babel/helper-validator-identifier": "^8.0.0-rc.2" } }, "sha512-91gAaWRznDwSX4E2tZ1YjBuIfnQVOFDCQ2r0Toby0gu4XEbyF623kXLMA8d4ZbCu+fINcrudkmEcwSUHgDDkNw=="],
|
||||
|
||||
@@ -2392,6 +2403,8 @@
|
||||
|
||||
"vite/rolldown/@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-w6oiRWgEBl04QkFZgmW+jnU1EC9b57Oihi2ot3HNWIQRqgHp5PnYDia5iZ5FF7rpa4EQdiqMDXjlqKGXBhsoXw=="],
|
||||
|
||||
"yaml-language-server/ajv/json-schema-traverse": ["[email protected]", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
||||
|
||||
"@tanstack/router-plugin/chokidar/readdirp/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"ast-kit/@babel/parser/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-noLx87RwlBEMrTzncWd/FvTxoJ9+ycHNg0n8yyYydIoDsLZuxknKgWRJUqcrVkNrJ74uGyhWQzQaS3q8xfGAhQ=="],
|
||||
|
||||
@@ -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
|
||||
|
||||
+9
-9
@@ -9,14 +9,14 @@
|
||||
"scripts"
|
||||
],
|
||||
"catalog": {
|
||||
"effect": "4.0.0-beta.73",
|
||||
"@effect/atom-react": "4.0.0-beta.73",
|
||||
"@effect/openapi-generator": "4.0.0-beta.73",
|
||||
"@effect/platform-bun": "4.0.0-beta.73",
|
||||
"@effect/platform-node": "4.0.0-beta.73",
|
||||
"@effect/platform-node-shared": "4.0.0-beta.73",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.73",
|
||||
"@effect/vitest": "4.0.0-beta.73",
|
||||
"effect": "4.0.0-beta.59",
|
||||
"@effect/atom-react": "4.0.0-beta.59",
|
||||
"@effect/openapi-generator": "4.0.0-beta.59",
|
||||
"@effect/platform-bun": "4.0.0-beta.59",
|
||||
"@effect/platform-node": "4.0.0-beta.59",
|
||||
"@effect/platform-node-shared": "4.0.0-beta.59",
|
||||
"@effect/sql-sqlite-bun": "4.0.0-beta.59",
|
||||
"@effect/vitest": "4.0.0-beta.59",
|
||||
"@effect/language-service": "0.84.2",
|
||||
"@pierre/diffs": "1.1.20",
|
||||
"@types/bun": "^1.3.11",
|
||||
@@ -91,7 +91,7 @@
|
||||
]
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"[email protected].73": "patches/[email protected].73.patch"
|
||||
"[email protected].59": "patches/[email protected].59.patch"
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"node-pty",
|
||||
|
||||
@@ -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,42 @@ 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)),
|
||||
updateCommand: Schema.optionalKey(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
canUpdate: Schema.optionalKey(Schema.Boolean),
|
||||
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 +223,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;
|
||||
@@ -542,6 +579,7 @@ export type ServerProviderUpdatedPayload = typeof ServerProviderUpdatedPayload.T
|
||||
export const ServerProviderUpdateInput = Schema.Struct({
|
||||
provider: ProviderDriverKind,
|
||||
instanceId: Schema.optionalKey(ProviderInstanceId),
|
||||
targetVersion: Schema.optionalKey(TrimmedNonEmptyString),
|
||||
});
|
||||
export type ServerProviderUpdateInput = typeof ServerProviderUpdateInput.Type;
|
||||
|
||||
|
||||
@@ -55,14 +55,7 @@ describe("parseGitHubRepositoryNameWithOwnerFromRemoteUrl", () => {
|
||||
|
||||
describe("isTemporaryWorktreeBranch", () => {
|
||||
it("matches the generated temporary worktree refName format", () => {
|
||||
expect(
|
||||
isTemporaryWorktreeBranch(
|
||||
buildTemporaryWorktreeBranchName((byteLength) => {
|
||||
expect(byteLength).toBe(4);
|
||||
return "DEADBEEF";
|
||||
}),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(isTemporaryWorktreeBranch(buildTemporaryWorktreeBranchName())).toBe(true);
|
||||
});
|
||||
|
||||
it("matches generated temporary worktree refs", () => {
|
||||
|
||||
@@ -6,6 +6,8 @@ import type {
|
||||
VcsStatusResult,
|
||||
VcsStatusStreamEvent,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Random from "effect/Random";
|
||||
import { detectSourceControlProviderFromRemoteUrl } from "./sourceControl.ts";
|
||||
|
||||
export const WORKTREE_BRANCH_PREFIX = "t3code";
|
||||
@@ -84,10 +86,8 @@ export function deriveLocalBranchNameFromRemoteRef(branchName: string): string {
|
||||
return branchName.slice(firstSeparatorIndex + 1);
|
||||
}
|
||||
|
||||
export function buildTemporaryWorktreeBranchName(
|
||||
randomHex: (byteLength: number) => string,
|
||||
): string {
|
||||
const token = randomHex(4).toLowerCase();
|
||||
export function buildTemporaryWorktreeBranchName(): string {
|
||||
const token = Effect.runSync(Random.nextUUIDv4).replace(/-/g, "").slice(0, 8).toLowerCase();
|
||||
return `${WORKTREE_BRANCH_PREFIX}/${token}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/dist/unstable/rpc/RpcClient.d.ts b/dist/unstable/rpc/RpcClient.d.ts
|
||||
index b0f61df..ead663e 100644
|
||||
index 7c5970042df67a25b4145df017960b3e6febed9c..7af3374632d53ad59f24e80835aa6741853b1f2b 100644
|
||||
--- a/dist/unstable/rpc/RpcClient.d.ts
|
||||
+++ b/dist/unstable/rpc/RpcClient.d.ts
|
||||
@@ -2,6 +2,7 @@ import * as Cause from "../../Cause.ts";
|
||||
@@ -10,7 +10,7 @@ index b0f61df..ead663e 100644
|
||||
import * as Layer from "../../Layer.ts";
|
||||
import * as Queue from "../../Queue.ts";
|
||||
import * as Schedule from "../../Schedule.ts";
|
||||
@@ -260,9 +261,40 @@ export declare const layerProtocolWorker: (options: {
|
||||
@@ -192,9 +193,40 @@ export declare const layerProtocolWorker: (options: {
|
||||
readonly targetUtilization?: number | undefined;
|
||||
readonly timeToLive: Duration.Input;
|
||||
}) => Layer.Layer<Protocol, WorkerError, Worker.WorkerPlatform | Worker.Spawner>;
|
||||
@@ -50,19 +50,12 @@ index b0f61df..ead663e 100644
|
||||
+ readonly onPingTimeout?: Effect.Effect<void> | undefined;
|
||||
}>;
|
||||
/**
|
||||
* Represents optional client protocol hooks that run when a transport connects
|
||||
@@ -279,4 +311,4 @@ declare const ConnectionHooks_base: Context.ServiceClass<ConnectionHooks, "effec
|
||||
export declare class ConnectionHooks extends ConnectionHooks_base {
|
||||
}
|
||||
export {};
|
||||
-//# sourceMappingURL=RpcClient.d.ts.map
|
||||
\ No newline at end of file
|
||||
+//# sourceMappingURL=RpcClient.d.ts.map
|
||||
* @since 4.0.0
|
||||
diff --git a/dist/unstable/rpc/RpcClient.js b/dist/unstable/rpc/RpcClient.js
|
||||
index 811a8a8..f9cf2eb 100644
|
||||
index 951dfc2d667a9136cfa714dcd3195e6575917fde..599c0345873bedd72bc93afe80eab0c676319421 100644
|
||||
--- a/dist/unstable/rpc/RpcClient.js
|
||||
+++ b/dist/unstable/rpc/RpcClient.js
|
||||
@@ -46,6 +46,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -42,6 +42,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
const services = yield* Effect.context();
|
||||
const scope = Context.get(services, Scope.Scope);
|
||||
const entries = new Map();
|
||||
@@ -70,7 +63,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
let isShutdown = false;
|
||||
yield* Scope.addFinalizer(scope, Effect.withFiber(parent => {
|
||||
isShutdown = true;
|
||||
@@ -83,6 +84,11 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -79,6 +80,11 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
return Effect.interrupt;
|
||||
}
|
||||
const id = generateRequestId();
|
||||
@@ -82,7 +75,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
const send = middleware(message => options.onFromClient({
|
||||
message,
|
||||
context,
|
||||
@@ -100,7 +106,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -96,7 +102,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
headers: Headers.merge(parentFiber.getRef(CurrentHeaders), headers)
|
||||
});
|
||||
if (discard) {
|
||||
@@ -91,7 +84,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
}
|
||||
let fiber;
|
||||
return Effect.onInterrupt(Effect.callback(resume => {
|
||||
@@ -118,7 +124,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -114,7 +120,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
}
|
||||
};
|
||||
entries.set(id, entry);
|
||||
@@ -100,7 +93,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
captureStackTrace: false
|
||||
}) : identity, Effect.runForkWith(parentFiber.context));
|
||||
fiber.addObserver(exit => {
|
||||
@@ -127,8 +133,9 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -123,8 +129,9 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
}
|
||||
});
|
||||
}), interruptors => {
|
||||
@@ -111,7 +104,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
});
|
||||
});
|
||||
const onStreamRequest = Effect.fnUntraced(function* (rpc, middleware, payload, headers, streamBufferSize, context) {
|
||||
@@ -140,11 +147,17 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -136,11 +143,17 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
});
|
||||
const fiber = Fiber.getCurrent();
|
||||
const id = generateRequestId();
|
||||
@@ -131,7 +124,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
});
|
||||
const queue = yield* Queue.bounded(streamBufferSize);
|
||||
entries.set(id, {
|
||||
@@ -152,9 +165,10 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -148,9 +161,10 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
rpc,
|
||||
queue,
|
||||
scope,
|
||||
@@ -144,7 +137,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
message,
|
||||
context,
|
||||
discard: false
|
||||
@@ -169,7 +183,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -165,7 +179,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
sampled: span.sampled
|
||||
} : {}),
|
||||
headers: Headers.merge(fiber.getRef(CurrentHeaders), headers)
|
||||
@@ -153,7 +146,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
captureStackTrace: false
|
||||
}) : identity, Effect.catchCause(error => Queue.failCause(queue, error)), Effect.interruptible, Effect.forkIn(scope, {
|
||||
startImmediately: true
|
||||
@@ -199,7 +213,10 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -195,7 +209,10 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -165,7 +158,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
const parentFiber = Fiber.getCurrent();
|
||||
const fiber = options.onFromClient({
|
||||
message: {
|
||||
@@ -213,7 +230,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -209,7 +226,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
fiber.addObserver(() => {
|
||||
resume(Effect.void);
|
||||
});
|
||||
@@ -174,7 +167,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
const write = message => {
|
||||
switch (message._tag) {
|
||||
case "Chunk":
|
||||
@@ -221,7 +238,13 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -217,7 +234,13 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
const requestId = message.requestId;
|
||||
const entry = entries.get(requestId);
|
||||
if (!entry || entry._tag !== "Queue") return Effect.void;
|
||||
@@ -189,7 +182,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
message: {
|
||||
_tag: "Ack",
|
||||
requestId: message.requestId
|
||||
@@ -236,11 +259,18 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
@@ -232,11 +255,18 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
|
||||
const entry = entries.get(requestId);
|
||||
if (!entry) return Effect.void;
|
||||
entries.delete(requestId);
|
||||
@@ -211,7 +204,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
}
|
||||
case "Defect":
|
||||
{
|
||||
@@ -568,7 +598,7 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
@@ -530,7 +560,7 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
const requestClientMap = new Map();
|
||||
const write = yield* socket.writer;
|
||||
let parser = serialization.makeUnsafe();
|
||||
@@ -220,7 +213,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
let currentError;
|
||||
const onOpen = Effect.suspend(() => {
|
||||
currentError = undefined;
|
||||
@@ -588,8 +618,7 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
@@ -550,8 +580,7 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
body: () => {
|
||||
const response = responses[i++];
|
||||
if (response._tag === "Pong") {
|
||||
@@ -230,7 +223,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
}
|
||||
if ("requestId" in response) {
|
||||
const clientId = requestClientMap.get(response.requestId);
|
||||
@@ -617,12 +646,12 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
@@ -579,12 +608,12 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
}
|
||||
}, {
|
||||
onOpen
|
||||
@@ -245,7 +238,7 @@ index 811a8a8..f9cf2eb 100644
|
||||
}).pipe(Effect.flatMap(() => Effect.fail(new Socket.SocketError({
|
||||
reason: new Socket.SocketCloseError({
|
||||
code: 1000
|
||||
@@ -664,20 +693,20 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
@@ -626,20 +655,20 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
|
||||
};
|
||||
}));
|
||||
const defaultRetryPolicy = /*#__PURE__*/Schedule.exponential(500, 1.5).pipe(/*#__PURE__*/Schedule.either(/*#__PURE__*/Schedule.spaced(5000)));
|
||||
@@ -270,8 +263,8 @@ index 811a8a8..f9cf2eb 100644
|
||||
}).pipe(Effect.delay("5 seconds"), Effect.ignore, Effect.forever, Effect.interruptible, Effect.forkScoped);
|
||||
return {
|
||||
timeout: latch.await,
|
||||
@@ -820,6 +849,11 @@ export const makeProtocolWorker = options => Protocol.make(Effect.fnUntraced(fun
|
||||
* @since 4.0.0
|
||||
@@ -773,6 +802,11 @@ export const makeProtocolWorker = options => Protocol.make(Effect.fnUntraced(fun
|
||||
* @category protocol
|
||||
*/
|
||||
export const layerProtocolWorker = /*#__PURE__*/flow(makeProtocolWorker, /*#__PURE__*/Layer.effect(Protocol));
|
||||
+/**
|
||||
@@ -280,12 +273,5 @@ index 811a8a8..f9cf2eb 100644
|
||||
+ */
|
||||
+export class RequestHooks extends /*#__PURE__*/Context.Service()("effect/rpc/RpcClient/RequestHooks") {}
|
||||
/**
|
||||
* Represents optional client protocol hooks that run when a transport connects
|
||||
* and disconnects.
|
||||
@@ -835,4 +869,4 @@ export const layerProtocolWorker = /*#__PURE__*/flow(makeProtocolWorker, /*#__PU
|
||||
export class ConnectionHooks extends /*#__PURE__*/Context.Service()("effect/rpc/RpcClient/ConnectionHooks") {}
|
||||
// internal
|
||||
const decodeDefect = /*#__PURE__*/Schema.decodeSync(Schema.Defect);
|
||||
-//# sourceMappingURL=RpcClient.js.map
|
||||
\ No newline at end of file
|
||||
+//# sourceMappingURL=RpcClient.js.map
|
||||
* @since 4.0.0
|
||||
* @category ConnectionHooks
|
||||
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"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 <1.14.41",
|
||||
"recommendedVersion": "1.14.40",
|
||||
"ranges": [
|
||||
{
|
||||
"status": "broken",
|
||||
"range": ">1.14.40",
|
||||
"label": "Known incompatible OpenCode harness"
|
||||
},
|
||||
{
|
||||
"status": "supported",
|
||||
"range": ">=1.14.19 <=1.14.40",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -278,7 +278,7 @@ export const resolveBuildOptions = Effect.fn("resolveBuildOptions")(function* (
|
||||
) {
|
||||
const path = yield* Path.Path;
|
||||
const repoRoot = yield* RepoRoot;
|
||||
const env = yield* BuildEnvConfig;
|
||||
const env = yield* BuildEnvConfig.asEffect();
|
||||
|
||||
const platform = mergeOptions(
|
||||
input.platform,
|
||||
|
||||
@@ -385,7 +385,7 @@ interface DevRunnerCliInput {
|
||||
|
||||
export function runDevRunnerWithInput(input: DevRunnerCliInput) {
|
||||
return Effect.gen(function* () {
|
||||
const { portOffset, devInstance } = yield* OffsetConfig.pipe(
|
||||
const { portOffset, devInstance } = yield* OffsetConfig.asEffect().pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new DevRunnerError({
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
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",
|
||||
);
|
||||
|
||||
yield* Effect.flatMap(fs.readFileString(sourcePath), decodeJson);
|
||||
|
||||
yield* fs.makeDirectory(path.dirname(destinationPath), { recursive: true });
|
||||
yield* fs.copyFile(sourcePath, destinationPath);
|
||||
|
||||
yield* Effect.logInfo(
|
||||
`Mirrored ${path.relative(repoRoot, sourcePath)} to ${path.relative(repoRoot, destinationPath)}.`,
|
||||
);
|
||||
});
|
||||
|
||||
if (import.meta.main) {
|
||||
program.pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ const resolveMockUpdateServerConfig = Effect.gen(function* () {
|
||||
root: Config.string("T3CODE_DESKTOP_MOCK_UPDATE_SERVER_ROOT").pipe(
|
||||
Config.withDefault("../release-mock"),
|
||||
),
|
||||
});
|
||||
}).asEffect();
|
||||
|
||||
const resolvedRoot = path.resolve(import.meta.dirname, config.root);
|
||||
|
||||
|
||||
Reference in new issue
Block a user