Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d9e4a1f30 |
No files matched your search
@@ -607,7 +607,6 @@ export const make = Effect.gen(function* () {
|
||||
const backendExposure = yield* serverExposure.backendConfig;
|
||||
const persistedSettings = yield* settings.get;
|
||||
const shared = yield* sharedInputs;
|
||||
yield* wslEnvironment.preWarm(persistedSettings.wslDistro);
|
||||
return yield* resolveWslStartConfig({
|
||||
...shared,
|
||||
port: backendExposure.port,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assert, describe, expect, it } from "@effect/vitest";
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import { vi } from "vite-plus/test";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -193,47 +193,6 @@ describe("CloudManagedEndpointRuntime", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("deduplicates Cloudflare connector configs with absent optional tunnel fields", () =>
|
||||
Effect.gen(function* () {
|
||||
const spawned: Array<number> = [];
|
||||
const killed: Array<number> = [];
|
||||
const spawner = ChildProcessSpawner.make(() =>
|
||||
Effect.gen(function* () {
|
||||
const pid = 250 + spawned.length;
|
||||
spawned.push(pid);
|
||||
const handle = makeHandle({
|
||||
pid,
|
||||
onKill: () => {
|
||||
killed.push(pid);
|
||||
},
|
||||
});
|
||||
yield* Effect.addFinalizer(() => handle.kill().pipe(Effect.ignore));
|
||||
return handle;
|
||||
}),
|
||||
);
|
||||
const runtime = yield* buildCloudManagedEndpointRuntime(spawner);
|
||||
|
||||
const first = yield* runtime.applyConfig({
|
||||
providerKind: "cloudflare_tunnel",
|
||||
connectorToken: "token",
|
||||
});
|
||||
const second = yield* runtime.applyConfig({
|
||||
providerKind: "cloudflare_tunnel",
|
||||
connectorToken: "token",
|
||||
});
|
||||
yield* runtime.applyConfig(null);
|
||||
|
||||
assert.deepStrictEqual(spawned, [250]);
|
||||
assert.deepStrictEqual(killed, [250]);
|
||||
assert.deepStrictEqual(first, {
|
||||
status: "running",
|
||||
providerKind: "cloudflare_tunnel",
|
||||
pid: 250,
|
||||
});
|
||||
assert.deepStrictEqual(second, first);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("restarts the connector when the active process has exited", () =>
|
||||
Effect.gen(function* () {
|
||||
const spawned: Array<number> = [];
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
RelayManagedEndpointProviderKind,
|
||||
type RelayManagedEndpointRuntimeConfig,
|
||||
} from "@t3tools/contracts/relay";
|
||||
import type { RelayManagedEndpointRuntimeConfig } from "@t3tools/contracts/relay";
|
||||
import * as RelayClient from "@t3tools/shared/relayClient";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -10,7 +7,6 @@ import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Ref from "effect/Ref";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Semaphore from "effect/Semaphore";
|
||||
import * as Scope from "effect/Scope";
|
||||
import * as Stream from "effect/Stream";
|
||||
@@ -24,22 +20,13 @@ function bytesToString(bytes: Uint8Array): string {
|
||||
return new TextDecoder().decode(bytes);
|
||||
}
|
||||
|
||||
const RuntimeConfigKeyPayload = Schema.Struct({
|
||||
providerKind: RelayManagedEndpointProviderKind,
|
||||
connectorToken: Schema.String,
|
||||
tunnelId: Schema.NullOr(Schema.String),
|
||||
tunnelName: Schema.NullOr(Schema.String),
|
||||
});
|
||||
const RuntimeConfigKeyPayloadJson = Schema.fromJsonString(RuntimeConfigKeyPayload);
|
||||
const encodeRuntimeConfigKey = Schema.encodeSync(RuntimeConfigKeyPayloadJson);
|
||||
|
||||
const readRuntimeConfig = Effect.gen(function* () {
|
||||
const secrets = yield* ServerSecretStore.ServerSecretStore;
|
||||
const bytes = yield* secrets.get(CLOUD_ENDPOINT_RUNTIME_CONFIG);
|
||||
if (Option.isNone(bytes)) {
|
||||
return Option.none();
|
||||
return null;
|
||||
}
|
||||
return decodeRuntimeConfig(bytesToString(bytes.value));
|
||||
return Option.getOrNull(decodeRuntimeConfig(bytesToString(bytes.value)));
|
||||
});
|
||||
|
||||
export type CloudManagedEndpointRuntimeStatus =
|
||||
@@ -89,7 +76,7 @@ export function classifyRelayClientOutput(line: string): "connected" | "warning"
|
||||
}
|
||||
|
||||
function runtimeConfigKey(config: RelayManagedEndpointRuntimeConfig): string {
|
||||
return encodeRuntimeConfigKey({
|
||||
return JSON.stringify({
|
||||
providerKind: config.providerKind,
|
||||
connectorToken: config.connectorToken,
|
||||
tunnelId: config.tunnelId ?? null,
|
||||
@@ -320,11 +307,11 @@ export const make = Effect.gen(function* () {
|
||||
const initialConfig = yield* readRuntimeConfig.pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.logWarning("Failed to read managed endpoint runtime config", { cause }).pipe(
|
||||
Effect.as(Option.none()),
|
||||
Effect.as(null),
|
||||
),
|
||||
),
|
||||
);
|
||||
yield* runtime.applyConfig(Option.getOrNull(initialConfig));
|
||||
yield* runtime.applyConfig(initialConfig);
|
||||
yield* Effect.addFinalizer(() => runtime.applyConfig(null));
|
||||
return runtime;
|
||||
});
|
||||
|
||||
@@ -193,36 +193,6 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
slug: "claude-sonnet-5",
|
||||
name: "Claude Sonnet 5",
|
||||
isCustom: false,
|
||||
capabilities: createModelCapabilities({
|
||||
optionDescriptors: [
|
||||
buildSelectOptionDescriptor({
|
||||
id: "effort",
|
||||
label: "Reasoning",
|
||||
options: [
|
||||
{ value: "low", label: "Low" },
|
||||
{ value: "medium", label: "Medium" },
|
||||
{ value: "high", label: "High", isDefault: true },
|
||||
{ value: "xhigh", label: "Extra High" },
|
||||
{ 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-sonnet-4-6",
|
||||
name: "Claude Sonnet 4.6",
|
||||
@@ -352,12 +322,7 @@ export function normalizeClaudeCliEffort(
|
||||
if (effort === "ultracode") {
|
||||
return "xhigh";
|
||||
}
|
||||
if (
|
||||
effort === "xhigh" &&
|
||||
model !== "claude-fable-5" &&
|
||||
model !== "claude-opus-4-8" &&
|
||||
model !== "claude-sonnet-5"
|
||||
) {
|
||||
if (effort === "xhigh" && model !== "claude-fable-5" && model !== "claude-opus-4-8") {
|
||||
return "max";
|
||||
}
|
||||
if (effort === "max" && model === "claude-sonnet-4-6") {
|
||||
|
||||
@@ -331,19 +331,6 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
|
||||
},
|
||||
[props],
|
||||
);
|
||||
const handleTabMouseDown = useCallback((event: ReactMouseEvent) => {
|
||||
if (event.button !== 1) return;
|
||||
event.preventDefault();
|
||||
}, []);
|
||||
const handleTabAuxClick = useCallback(
|
||||
(event: ReactMouseEvent, surface: RightPanelSurface) => {
|
||||
if (event.button !== 1) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
props.onCloseSurface(surface);
|
||||
},
|
||||
[props],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const activeTab = tabListRef.current?.querySelector<HTMLElement>("[data-active-tab='true']");
|
||||
@@ -380,8 +367,6 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
|
||||
<div
|
||||
key={surface.id}
|
||||
data-active-tab={active}
|
||||
onMouseDown={handleTabMouseDown}
|
||||
onAuxClick={(event) => handleTabAuxClick(event, surface)}
|
||||
onContextMenu={(event) => void handleTabContextMenu(event, surface)}
|
||||
className={cn(
|
||||
"group flex h-7 min-w-25 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-sm",
|
||||
|
||||
@@ -5,7 +5,18 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import { resolveSelectableModel } from "@t3tools/shared/model";
|
||||
import { LegendList, type LegendListRef } from "@legendapp/list/react";
|
||||
import { memo, useMemo, useState, useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import {
|
||||
type ChangeEvent,
|
||||
type KeyboardEvent as ReactKeyboardEvent,
|
||||
memo,
|
||||
useMemo,
|
||||
useState,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import { SearchIcon } from "lucide-react";
|
||||
import { ModelListRow } from "./ModelListRow";
|
||||
import { ModelPickerSidebar } from "./ModelPickerSidebar";
|
||||
@@ -43,6 +54,8 @@ type ModelPickerItem = {
|
||||
|
||||
const EMPTY_MODEL_JUMP_LABELS = new Map<string, string>();
|
||||
|
||||
const normalizeModelSearchQuery = (value: string): string => value.trim();
|
||||
|
||||
// Split a `${instanceId}:${slug}` combobox key back into its pieces. Slugs
|
||||
// can contain colons (e.g. some vendor model ids), so we only split on the
|
||||
// first colon — anything after that is the slug.
|
||||
@@ -57,6 +70,70 @@ function splitInstanceModelKey(key: string): { instanceId: ProviderInstanceId; s
|
||||
};
|
||||
}
|
||||
|
||||
const ModelPickerSearchInput = memo(function ModelPickerSearchInput(props: {
|
||||
inputRef: RefObject<HTMLInputElement | null>;
|
||||
onSearchQueryChange: (query: string) => void;
|
||||
onRequestClose?: () => void;
|
||||
onSubmitHighlightedModel: () => boolean;
|
||||
}) {
|
||||
const { inputRef, onRequestClose, onSearchQueryChange, onSubmitHighlightedModel } = props;
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
const lastNormalizedQueryRef = useRef("");
|
||||
|
||||
const handleChange = useCallback(
|
||||
(event: ChangeEvent<HTMLInputElement>) => {
|
||||
const nextValue = event.target.value;
|
||||
const nextNormalizedQuery = normalizeModelSearchQuery(nextValue);
|
||||
setInputValue(nextValue);
|
||||
if (lastNormalizedQueryRef.current === nextNormalizedQuery) {
|
||||
return;
|
||||
}
|
||||
lastNormalizedQueryRef.current = nextNormalizedQuery;
|
||||
onSearchQueryChange(nextNormalizedQuery);
|
||||
},
|
||||
[onSearchQueryChange],
|
||||
);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(event: ReactKeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onRequestClose?.();
|
||||
return;
|
||||
}
|
||||
if (event.key === "Enter" && onSubmitHighlightedModel()) {
|
||||
(event as typeof event & { preventBaseUIHandler?: () => void }).preventBaseUIHandler?.();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
},
|
||||
[onRequestClose, onSubmitHighlightedModel],
|
||||
);
|
||||
|
||||
return (
|
||||
<ComboboxInput
|
||||
ref={inputRef}
|
||||
className="[&_input]:h-6.5 [&_input]:font-sans [&_input]:leading-6.5"
|
||||
inputClassName="rounded-none bg-transparent text-sm"
|
||||
placeholder="Search models..."
|
||||
showTrigger={false}
|
||||
startAddon={
|
||||
<SearchIcon className="-translate-x-0.5 size-4 shrink-0 text-muted-foreground/55" />
|
||||
}
|
||||
value={inputValue}
|
||||
onChange={handleChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
onMouseDown={(event) => event.stopPropagation()}
|
||||
onTouchStart={(event) => event.stopPropagation()}
|
||||
size="sm"
|
||||
unstyled
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
/** The instance currently selected in the composer (combobox "value"). */
|
||||
activeInstanceId: ProviderInstanceId;
|
||||
@@ -518,6 +595,15 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
};
|
||||
}, [filteredModelKeys, updateModelListScrollFades]);
|
||||
|
||||
const submitHighlightedModel = useCallback(() => {
|
||||
if (!highlightedModelKeyRef.current) {
|
||||
return false;
|
||||
}
|
||||
const { instanceId, slug } = splitInstanceModelKey(highlightedModelKeyRef.current);
|
||||
handleModelSelect(slug, instanceId);
|
||||
return true;
|
||||
}, [handleModelSelect]);
|
||||
|
||||
return (
|
||||
<TooltipProvider delay={0}>
|
||||
<div
|
||||
@@ -577,42 +663,11 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
{/* Search bar */}
|
||||
<div className="px-4 pt-2.5">
|
||||
<div className="-translate-y-px border-b border-border/70 pb-2.5 transition-colors focus-within:border-ring">
|
||||
<ComboboxInput
|
||||
ref={searchInputRef}
|
||||
className="[&_input]:h-6.5 [&_input]:font-sans [&_input]:leading-6.5"
|
||||
inputClassName="rounded-none bg-transparent text-sm"
|
||||
placeholder="Search models..."
|
||||
showTrigger={false}
|
||||
startAddon={
|
||||
<SearchIcon className="-translate-x-0.5 size-4 shrink-0 text-muted-foreground/55" />
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
props.onRequestClose?.();
|
||||
return;
|
||||
}
|
||||
if (e.key === "Enter" && highlightedModelKeyRef.current) {
|
||||
(
|
||||
e as typeof e & { preventBaseUIHandler?: () => void }
|
||||
).preventBaseUIHandler?.();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const { instanceId, slug } = splitInstanceModelKey(
|
||||
highlightedModelKeyRef.current,
|
||||
);
|
||||
handleModelSelect(slug, instanceId);
|
||||
return;
|
||||
}
|
||||
e.stopPropagation();
|
||||
}}
|
||||
onMouseDown={(e) => e.stopPropagation()}
|
||||
onTouchStart={(e) => e.stopPropagation()}
|
||||
size="sm"
|
||||
unstyled
|
||||
<ModelPickerSearchInput
|
||||
inputRef={searchInputRef}
|
||||
onSearchQueryChange={setSearchQuery}
|
||||
onSubmitHighlightedModel={submitHighlightedModel}
|
||||
{...(props.onRequestClose ? { onRequestClose: props.onRequestClose } : {})}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,7 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
*/
|
||||
const CUSTOM_MODEL_PLACEHOLDER_BY_KIND: Partial<Record<ProviderDriverKind, string>> = {
|
||||
[ProviderDriverKind.make("codex")]: "gpt-6.7-codex-ultra-preview",
|
||||
[ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5",
|
||||
[ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5-0",
|
||||
[ProviderDriverKind.make("cursor")]: "claude-sonnet-4-6",
|
||||
[ProviderDriverKind.make("opencode")]: "openai/gpt-5",
|
||||
};
|
||||
|
||||
@@ -812,35 +812,12 @@ label:has(> select#reasoning-effort) select {
|
||||
#ec4899 90%,
|
||||
#ff6b6b 100%
|
||||
);
|
||||
position: relative;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.ultrathink-frame::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: inherit;
|
||||
padding: 2px;
|
||||
background-image: var(--ultrathink-spectrum);
|
||||
background-size: 220% 220%;
|
||||
pointer-events: none;
|
||||
filter: saturate(0.82) brightness(0.92);
|
||||
-webkit-mask:
|
||||
linear-gradient(#000 0 0) content-box,
|
||||
linear-gradient(#000 0 0);
|
||||
-webkit-mask-composite: xor;
|
||||
mask:
|
||||
linear-gradient(#000 0 0) content-box,
|
||||
linear-gradient(#000 0 0);
|
||||
mask-composite: exclude;
|
||||
animation: ultrathink-rainbow 10s linear infinite;
|
||||
}
|
||||
|
||||
.ultrathink-frame > * {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.ultrathink-chroma {
|
||||
animation: ultrathink-chroma-shift 10s linear infinite;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
RelayClientEnvironmentRecord,
|
||||
RelayEnvironmentStatusResponse,
|
||||
} from "@t3tools/contracts/relay";
|
||||
import { assert, describe, expect, it } from "@effect/vitest";
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import * as Layer from "effect/Layer";
|
||||
@@ -334,27 +334,6 @@ describe("createManagedRelayQueryManager", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("refreshes environment status atoms keyed by schema-encoded relay environments", async () => {
|
||||
const getEnvironmentStatus = vi.fn(() =>
|
||||
Effect.succeed({
|
||||
environmentId: environment.environmentId,
|
||||
endpoint: environment.endpoint,
|
||||
status: "online" as const,
|
||||
checkedAt: "2026-06-01T00:00:00.000Z",
|
||||
}),
|
||||
);
|
||||
const manager = createManager({ getEnvironmentStatus });
|
||||
setSession();
|
||||
const atom = manager.environmentStatusAtom({ accountId: "account-1", environment });
|
||||
|
||||
registry.get(atom);
|
||||
await vi.waitFor(() => assert.equal(getEnvironmentStatus.mock.calls.length, 1));
|
||||
|
||||
manager.refreshEnvironmentStatus(registry, { accountId: "account-1", environment });
|
||||
await vi.waitFor(() => assert.equal(getEnvironmentStatus.mock.calls.length, 2));
|
||||
assert.equal(readManagedRelaySnapshotState(registry.get(atom)).data?.status, "online");
|
||||
});
|
||||
|
||||
it("rejects status responses for a different environment", async () => {
|
||||
const mismatchedStatus = {
|
||||
environmentId: EnvironmentId.make("environment-2"),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type {
|
||||
RelayClientEnvironmentRecord as RelayClientEnvironmentRecordType,
|
||||
RelayClientEnvironmentRecord,
|
||||
RelayEnvironmentStatusResponse,
|
||||
} from "@t3tools/contracts/relay";
|
||||
import {
|
||||
RelayClientEnvironmentRecord,
|
||||
RelayEnvironmentConnectScope,
|
||||
RelayEnvironmentStatusScope,
|
||||
} from "@t3tools/contracts/relay";
|
||||
@@ -13,7 +12,6 @@ import * as Clock from "effect/Clock";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Schema from "effect/Schema";
|
||||
import * as Stream from "effect/Stream";
|
||||
import { AsyncResult, Atom, AtomRegistry } from "effect/unstable/reactivity";
|
||||
|
||||
@@ -23,14 +21,6 @@ import * as ManagedRelay from "./managedRelay.ts";
|
||||
const DEFAULT_STALE_TIME_MS = 15_000;
|
||||
const DEFAULT_IDLE_TTL_MS = 5 * 60_000;
|
||||
const CLERK_TOKEN_EXPIRY_SKEW_MS = 5_000;
|
||||
const ManagedRelayStatusKeyPayload = Schema.Struct({
|
||||
accountId: Schema.String,
|
||||
environment: RelayClientEnvironmentRecord,
|
||||
});
|
||||
type ManagedRelayStatusKeyPayload = typeof ManagedRelayStatusKeyPayload.Type;
|
||||
const ManagedRelayStatusKeyPayloadJson = Schema.fromJsonString(ManagedRelayStatusKeyPayload);
|
||||
const encodeManagedRelayStatusKey = Schema.encodeSync(ManagedRelayStatusKeyPayloadJson);
|
||||
const decodeManagedRelayStatusKey = Schema.decodeUnknownSync(ManagedRelayStatusKeyPayloadJson);
|
||||
|
||||
export interface ManagedRelaySession {
|
||||
readonly accountId: string;
|
||||
@@ -245,18 +235,24 @@ function requireClerkToken(
|
||||
|
||||
function statusKey(input: {
|
||||
readonly accountId: string;
|
||||
readonly environment: RelayClientEnvironmentRecordType;
|
||||
readonly environment: RelayClientEnvironmentRecord;
|
||||
}): string {
|
||||
return encodeManagedRelayStatusKey(input);
|
||||
return JSON.stringify(input);
|
||||
}
|
||||
|
||||
function parseStatusKey(key: string): ManagedRelayStatusKeyPayload {
|
||||
return decodeManagedRelayStatusKey(key);
|
||||
function parseStatusKey(key: string): {
|
||||
readonly accountId: string;
|
||||
readonly environment: RelayClientEnvironmentRecord;
|
||||
} {
|
||||
return JSON.parse(key) as {
|
||||
readonly accountId: string;
|
||||
readonly environment: RelayClientEnvironmentRecord;
|
||||
};
|
||||
}
|
||||
|
||||
function endpointMatches(
|
||||
left: RelayClientEnvironmentRecordType["endpoint"],
|
||||
right: RelayClientEnvironmentRecordType["endpoint"],
|
||||
left: RelayClientEnvironmentRecord["endpoint"],
|
||||
right: RelayClientEnvironmentRecord["endpoint"],
|
||||
): boolean {
|
||||
return (
|
||||
left.httpBaseUrl === right.httpBaseUrl &&
|
||||
@@ -266,7 +262,7 @@ function endpointMatches(
|
||||
}
|
||||
|
||||
function validateEnvironmentStatus(
|
||||
environment: RelayClientEnvironmentRecordType,
|
||||
environment: RelayClientEnvironmentRecord,
|
||||
status: RelayEnvironmentStatusResponse,
|
||||
): Effect.Effect<RelayEnvironmentStatusResponse, ManagedRelaySnapshotError> {
|
||||
if (status.environmentId !== environment.environmentId) {
|
||||
@@ -433,7 +429,7 @@ export function createManagedRelayQueryManager(
|
||||
devicesAtom,
|
||||
environmentStatusAtom: (input: {
|
||||
readonly accountId: string;
|
||||
readonly environment: RelayClientEnvironmentRecordType;
|
||||
readonly environment: RelayClientEnvironmentRecord;
|
||||
}) => environmentStatusAtom(statusKey(input)),
|
||||
refreshEnvironments(registry: AtomRegistry.AtomRegistry, accountId: string): void {
|
||||
registry.refresh(environmentsAtom(accountId));
|
||||
@@ -445,7 +441,7 @@ export function createManagedRelayQueryManager(
|
||||
registry: AtomRegistry.AtomRegistry,
|
||||
input: {
|
||||
readonly accountId: string;
|
||||
readonly environment: RelayClientEnvironmentRecordType;
|
||||
readonly environment: RelayClientEnvironmentRecord;
|
||||
},
|
||||
): void {
|
||||
registry.refresh(environmentStatusAtom(statusKey(input)));
|
||||
|
||||
@@ -138,7 +138,7 @@ export const DEFAULT_GIT_TEXT_GENERATION_MODEL = "gpt-5.4-mini";
|
||||
|
||||
export const DEFAULT_MODEL_BY_PROVIDER: Partial<Record<ProviderDriverKind, string>> = {
|
||||
[CODEX_DRIVER_KIND]: DEFAULT_MODEL,
|
||||
[CLAUDE_DRIVER_KIND]: "claude-sonnet-5",
|
||||
[CLAUDE_DRIVER_KIND]: "claude-sonnet-4-6",
|
||||
[CURSOR_DRIVER_KIND]: "auto",
|
||||
[GROK_DRIVER_KIND]: "grok-build",
|
||||
[OPENCODE_DRIVER_KIND]: "openai/gpt-5",
|
||||
@@ -174,10 +174,7 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER: Partial<
|
||||
"opus-4.6": "claude-opus-4-6",
|
||||
"claude-opus-4.6": "claude-opus-4-6",
|
||||
"claude-opus-4-6-20251117": "claude-opus-4-6",
|
||||
sonnet: "claude-sonnet-5",
|
||||
"sonnet-5": "claude-sonnet-5",
|
||||
"claude-sonnet-5.0": "claude-sonnet-5",
|
||||
"claude-sonnet-5-0": "claude-sonnet-5",
|
||||
sonnet: "claude-sonnet-4-6",
|
||||
"sonnet-4.6": "claude-sonnet-4-6",
|
||||
"claude-sonnet-4.6": "claude-sonnet-4-6",
|
||||
"claude-sonnet-4-6-20251117": "claude-sonnet-4-6",
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
|
||||
import {
|
||||
DEFAULT_MODEL,
|
||||
ProviderDriverKind,
|
||||
ProviderInstanceId,
|
||||
type ModelCapabilities,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
applyClaudePromptEffortPrefix,
|
||||
buildProviderOptionSelectionsFromDescriptors,
|
||||
createModelCapabilities,
|
||||
createModelSelection,
|
||||
@@ -10,6 +16,11 @@ import {
|
||||
getProviderOptionDescriptors,
|
||||
getProviderOptionBooleanSelectionValue,
|
||||
getProviderOptionStringSelectionValue,
|
||||
isClaudeUltrathinkPrompt,
|
||||
normalizeModelSlug,
|
||||
resolveModelSlugForProvider,
|
||||
resolveSelectableModel,
|
||||
trimOrNull,
|
||||
} from "./model.ts";
|
||||
|
||||
const codexCaps: ModelCapabilities = createModelCapabilities({
|
||||
@@ -59,6 +70,82 @@ const claudeCaps: ModelCapabilities = createModelCapabilities({
|
||||
],
|
||||
});
|
||||
|
||||
describe("normalizeModelSlug", () => {
|
||||
it("maps known aliases to canonical slugs", () => {
|
||||
const claude = ProviderDriverKind.make("claudeAgent");
|
||||
expect(normalizeModelSlug("gpt-5-codex")).toBe("gpt-5.4");
|
||||
expect(normalizeModelSlug("5.3")).toBe("gpt-5.3-codex");
|
||||
expect(normalizeModelSlug("sonnet", claude)).toBe("claude-sonnet-4-6");
|
||||
});
|
||||
|
||||
it("returns null for empty or missing values", () => {
|
||||
expect(normalizeModelSlug("")).toBeNull();
|
||||
expect(normalizeModelSlug(" ")).toBeNull();
|
||||
expect(normalizeModelSlug(null)).toBeNull();
|
||||
expect(normalizeModelSlug(undefined)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveModelSlugForProvider", () => {
|
||||
it("returns defaults when the model is missing", () => {
|
||||
expect(resolveModelSlugForProvider(ProviderDriverKind.make("codex"), undefined)).toBe(
|
||||
DEFAULT_MODEL,
|
||||
);
|
||||
expect(resolveModelSlugForProvider(ProviderDriverKind.make("ollama"), undefined)).toBe(
|
||||
DEFAULT_MODEL,
|
||||
);
|
||||
expect(resolveModelSlugForProvider(ProviderDriverKind.make("grok"), undefined)).toBe(
|
||||
"grok-build",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves normalized unknown models", () => {
|
||||
expect(
|
||||
resolveModelSlugForProvider(ProviderDriverKind.make("codex"), "custom/internal-model"),
|
||||
).toBe("custom/internal-model");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveSelectableModel", () => {
|
||||
it("resolves exact slugs, labels, and aliases", () => {
|
||||
const options = [
|
||||
{ slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
{ slug: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
|
||||
];
|
||||
expect(resolveSelectableModel(ProviderDriverKind.make("codex"), "gpt-5.3-codex", options)).toBe(
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
expect(resolveSelectableModel(ProviderDriverKind.make("codex"), "gpt-5.3 codex", options)).toBe(
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
expect(resolveSelectableModel(ProviderDriverKind.make("claudeAgent"), "sonnet", options)).toBe(
|
||||
"claude-sonnet-4-6",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("misc helpers", () => {
|
||||
it("detects ultrathink prompts", () => {
|
||||
expect(isClaudeUltrathinkPrompt("Please ultrathink about this")).toBe(true);
|
||||
expect(isClaudeUltrathinkPrompt("Ultrathink:\nInvestigate")).toBe(true);
|
||||
expect(isClaudeUltrathinkPrompt("Investigate")).toBe(false);
|
||||
});
|
||||
|
||||
it("prefixes ultrathink prompts once", () => {
|
||||
expect(applyClaudePromptEffortPrefix("Investigate", "ultrathink")).toBe(
|
||||
"Ultrathink:\nInvestigate",
|
||||
);
|
||||
expect(applyClaudePromptEffortPrefix("Ultrathink:\nInvestigate", "ultrathink")).toBe(
|
||||
"Ultrathink:\nInvestigate",
|
||||
);
|
||||
});
|
||||
|
||||
it("trims strings to null", () => {
|
||||
expect(trimOrNull(" hi ")).toBe("hi");
|
||||
expect(trimOrNull(" ")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("descriptor helpers", () => {
|
||||
it("applies selection values to capability descriptors", () => {
|
||||
expect(
|
||||
|
||||
Reference in new issue
Block a user