Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c55e3fe449 | ||
|
|
208b61d69b | ||
|
|
eb39be4bdc |
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,
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
ServerTraceDiagnosticsSpanOccurrence,
|
||||
ServerTraceDiagnosticsSpanSummary,
|
||||
} from "@t3tools/contracts";
|
||||
import { decodeJsonResult } from "@t3tools/shared/schemaJson";
|
||||
import * as Context from "effect/Context";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
@@ -17,22 +18,30 @@ import * as PlatformError from "effect/PlatformError";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
interface TraceRecordLike {
|
||||
readonly name?: unknown;
|
||||
readonly traceId?: unknown;
|
||||
readonly spanId?: unknown;
|
||||
readonly startTimeUnixNano?: unknown;
|
||||
readonly endTimeUnixNano?: unknown;
|
||||
readonly durationMs?: unknown;
|
||||
readonly exit?: unknown;
|
||||
readonly events?: unknown;
|
||||
}
|
||||
const TraceEvent = Schema.Struct({
|
||||
name: Schema.optional(Schema.String),
|
||||
timeUnixNano: Schema.optional(Schema.String),
|
||||
attributes: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
||||
});
|
||||
|
||||
interface TraceEventLike {
|
||||
readonly name?: unknown;
|
||||
readonly timeUnixNano?: unknown;
|
||||
readonly attributes?: unknown;
|
||||
}
|
||||
const TraceExit = Schema.Struct({
|
||||
_tag: Schema.String,
|
||||
cause: Schema.optional(Schema.String),
|
||||
});
|
||||
|
||||
const TraceRecord = Schema.Struct({
|
||||
name: Schema.String,
|
||||
traceId: Schema.String,
|
||||
spanId: Schema.String,
|
||||
startTimeUnixNano: Schema.optional(Schema.String),
|
||||
endTimeUnixNano: Schema.String,
|
||||
durationMs: Schema.Number,
|
||||
exit: Schema.optional(TraceExit),
|
||||
events: Schema.optional(Schema.Array(TraceEvent)),
|
||||
});
|
||||
type TraceRecord = typeof TraceRecord.Type;
|
||||
|
||||
const decodeTraceRecord = decodeJsonResult(TraceRecord);
|
||||
|
||||
export interface TraceDiagnosticsOptions {
|
||||
readonly traceFilePath: string;
|
||||
@@ -90,47 +99,25 @@ function toRotatedTracePaths(traceFilePath: string, maxFiles: number): ReadonlyA
|
||||
return [...backups, traceFilePath];
|
||||
}
|
||||
|
||||
function isRecordObject(value: unknown): value is TraceRecordLike {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
function toStringValue(value: unknown): string | null {
|
||||
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
||||
}
|
||||
|
||||
function toNumberValue(value: unknown): number | null {
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
||||
function unixNanoToDateTime(value: unknown): DateTime.Utc | null {
|
||||
const text = toStringValue(value);
|
||||
if (!text) return null;
|
||||
function unixNanoToDateTime(value: string): Option.Option<DateTime.Utc> {
|
||||
try {
|
||||
const millis = Number(BigInt(text) / 1_000_000n);
|
||||
return Option.getOrNull(DateTime.make(millis));
|
||||
const millis = Number(BigInt(value) / 1_000_000n);
|
||||
return DateTime.make(millis);
|
||||
} catch {
|
||||
return null;
|
||||
return Option.none();
|
||||
}
|
||||
}
|
||||
|
||||
function readExitTag(exit: unknown): string | null {
|
||||
if (!isRecordObject(exit) || !("_tag" in exit)) return null;
|
||||
return toStringValue(exit._tag);
|
||||
function readExitTag(exit: TraceRecord["exit"]): string | null {
|
||||
return exit?._tag ?? null;
|
||||
}
|
||||
|
||||
function readExitCause(exit: unknown): string {
|
||||
if (!isRecordObject(exit) || !("cause" in exit)) return "Failure";
|
||||
return toStringValue(exit.cause)?.trim() ?? "Failure";
|
||||
}
|
||||
|
||||
function isTraceEvent(value: unknown): value is TraceEventLike {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
function readEventAttributes(event: TraceEventLike): Readonly<Record<string, unknown>> {
|
||||
return typeof event.attributes === "object" && event.attributes !== null
|
||||
? (event.attributes as Readonly<Record<string, unknown>>)
|
||||
: {};
|
||||
function readExitCause(exit: TraceRecord["exit"]): string {
|
||||
return exit?.cause?.trim() || "Failure";
|
||||
}
|
||||
|
||||
function makeEmptyDiagnostics(input: {
|
||||
@@ -211,8 +198,8 @@ export function aggregateTraceDiagnostics(
|
||||
let failureCount = 0;
|
||||
let interruptionCount = 0;
|
||||
let slowSpanCount = 0;
|
||||
let firstSpanAt: DateTime.Utc | null = null;
|
||||
let lastSpanAt: DateTime.Utc | null = null;
|
||||
let firstSpanAt = Option.none<DateTime.Utc>();
|
||||
let lastSpanAt = Option.none<DateTime.Utc>();
|
||||
|
||||
const spansByName = new Map<
|
||||
string,
|
||||
@@ -229,38 +216,44 @@ export function aggregateTraceDiagnostics(
|
||||
for (const line of lines) {
|
||||
if (line.trim().length === 0) continue;
|
||||
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(line);
|
||||
} catch {
|
||||
const parsedResult = decodeTraceRecord(line);
|
||||
if (Result.isFailure(parsedResult)) {
|
||||
parseErrorCount += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isRecordObject(parsed)) {
|
||||
parseErrorCount += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const name = toStringValue(parsed.name);
|
||||
const traceId = toStringValue(parsed.traceId);
|
||||
const spanId = toStringValue(parsed.spanId);
|
||||
const durationMs = toNumberValue(parsed.durationMs);
|
||||
const parsed = parsedResult.success;
|
||||
const name = parsed.name;
|
||||
const traceId = parsed.traceId;
|
||||
const spanId = parsed.spanId;
|
||||
const durationMs = parsed.durationMs;
|
||||
const endedAt = unixNanoToDateTime(parsed.endTimeUnixNano);
|
||||
const startedAt = unixNanoToDateTime(parsed.startTimeUnixNano);
|
||||
const startedAt =
|
||||
parsed.startTimeUnixNano === undefined
|
||||
? Option.none<DateTime.Utc>()
|
||||
: unixNanoToDateTime(parsed.startTimeUnixNano);
|
||||
|
||||
if (!name || !traceId || !spanId || durationMs === null || !endedAt) {
|
||||
if (
|
||||
name.trim().length === 0 ||
|
||||
traceId.trim().length === 0 ||
|
||||
spanId.trim().length === 0 ||
|
||||
!Number.isFinite(durationMs) ||
|
||||
Option.isNone(endedAt)
|
||||
) {
|
||||
parseErrorCount += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
recordCount += 1;
|
||||
firstSpanAt =
|
||||
startedAt && (firstSpanAt === null || DateTime.isLessThan(startedAt, firstSpanAt))
|
||||
? startedAt
|
||||
: firstSpanAt;
|
||||
lastSpanAt =
|
||||
lastSpanAt === null || DateTime.isGreaterThan(endedAt, lastSpanAt) ? endedAt : lastSpanAt;
|
||||
if (
|
||||
Option.isSome(startedAt) &&
|
||||
(Option.isNone(firstSpanAt) || DateTime.isLessThan(startedAt.value, firstSpanAt.value))
|
||||
) {
|
||||
firstSpanAt = startedAt;
|
||||
}
|
||||
if (Option.isNone(lastSpanAt) || DateTime.isGreaterThan(endedAt.value, lastSpanAt.value)) {
|
||||
lastSpanAt = endedAt;
|
||||
}
|
||||
|
||||
const exitTag = readExitTag(parsed.exit);
|
||||
const isFailure = exitTag === "Failure";
|
||||
@@ -280,7 +273,7 @@ export function aggregateTraceDiagnostics(
|
||||
if (isFailure) spanSummary.failureCount += 1;
|
||||
spansByName.set(name, spanSummary);
|
||||
|
||||
const spanItem = { name, durationMs, endedAt, traceId, spanId };
|
||||
const spanItem = { name, durationMs, endedAt: endedAt.value, traceId, spanId };
|
||||
if (durationMs >= slowSpanThresholdMs) {
|
||||
slowSpanCount += 1;
|
||||
}
|
||||
@@ -292,22 +285,21 @@ export function aggregateTraceDiagnostics(
|
||||
|
||||
const failureKey = `${name}\0${cause}`;
|
||||
const existing = failuresByKey.get(failureKey);
|
||||
const isLatestFailure = !existing || DateTime.isGreaterThan(endedAt, existing.lastSeenAt);
|
||||
const isLatestFailure =
|
||||
!existing || DateTime.isGreaterThan(endedAt.value, existing.lastSeenAt);
|
||||
failuresByKey.set(failureKey, {
|
||||
name,
|
||||
cause,
|
||||
count: (existing?.count ?? 0) + 1,
|
||||
lastSeenAt: isLatestFailure ? endedAt : existing!.lastSeenAt,
|
||||
lastSeenAt: isLatestFailure ? endedAt.value : existing!.lastSeenAt,
|
||||
traceId: isLatestFailure ? traceId : existing!.traceId,
|
||||
spanId: isLatestFailure ? spanId : existing!.spanId,
|
||||
});
|
||||
}
|
||||
|
||||
if (Array.isArray(parsed.events)) {
|
||||
for (const rawEvent of parsed.events) {
|
||||
if (!isTraceEvent(rawEvent)) continue;
|
||||
const attributes = readEventAttributes(rawEvent);
|
||||
const level = toStringValue(attributes["effect.logLevel"]);
|
||||
if (parsed.events !== undefined) {
|
||||
for (const event of parsed.events) {
|
||||
const level = toStringValue(event.attributes?.["effect.logLevel"]);
|
||||
if (!level) continue;
|
||||
|
||||
logLevelCounts[level] = (logLevelCounts[level] ?? 0) + 1;
|
||||
@@ -321,8 +313,11 @@ export function aggregateTraceDiagnostics(
|
||||
continue;
|
||||
}
|
||||
|
||||
const seenAt = unixNanoToDateTime(rawEvent.timeUnixNano) ?? endedAt;
|
||||
const message = toStringValue(rawEvent.name)?.trim() ?? "Log event";
|
||||
const seenAt =
|
||||
event.timeUnixNano === undefined
|
||||
? endedAt.value
|
||||
: Option.getOrElse(unixNanoToDateTime(event.timeUnixNano), () => endedAt.value);
|
||||
const message = event.name?.trim() || "Log event";
|
||||
latestWarningAndErrorLogs.push({
|
||||
spanName: name,
|
||||
level,
|
||||
@@ -354,8 +349,8 @@ export function aggregateTraceDiagnostics(
|
||||
readAt,
|
||||
recordCount,
|
||||
parseErrorCount,
|
||||
firstSpanAt: Option.fromNullishOr(firstSpanAt),
|
||||
lastSpanAt: Option.fromNullishOr(lastSpanAt),
|
||||
firstSpanAt,
|
||||
lastSpanAt,
|
||||
failureCount,
|
||||
interruptionCount,
|
||||
slowSpanThresholdMs,
|
||||
|
||||
@@ -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,18 +5,7 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import { resolveSelectableModel } from "@t3tools/shared/model";
|
||||
import { LegendList, type LegendListRef } from "@legendapp/list/react";
|
||||
import {
|
||||
type ChangeEvent,
|
||||
type KeyboardEvent,
|
||||
type RefObject,
|
||||
memo,
|
||||
useMemo,
|
||||
useState,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
} from "react";
|
||||
import { memo, useMemo, useState, useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { SearchIcon } from "lucide-react";
|
||||
import { ModelListRow } from "./ModelListRow";
|
||||
import { ModelPickerSidebar } from "./ModelPickerSidebar";
|
||||
@@ -68,66 +57,6 @@ function splitInstanceModelKey(key: string): { instanceId: ProviderInstanceId; s
|
||||
};
|
||||
}
|
||||
|
||||
const ModelPickerSearchInput = memo(function ModelPickerSearchInput(props: {
|
||||
inputRef: RefObject<HTMLInputElement | null>;
|
||||
onSearchQueryChange: (query: string) => void;
|
||||
onEscape: () => void;
|
||||
onEnterHighlightedModel: () => boolean;
|
||||
}) {
|
||||
const { inputRef, onSearchQueryChange, onEscape, onEnterHighlightedModel } = props;
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
|
||||
const handleChange = useCallback(
|
||||
(event: ChangeEvent<HTMLInputElement>) => {
|
||||
const nextValue = event.target.value;
|
||||
setInputValue(nextValue);
|
||||
onSearchQueryChange(nextValue.trim());
|
||||
},
|
||||
[onSearchQueryChange],
|
||||
);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(event: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onEscape();
|
||||
return;
|
||||
}
|
||||
if (event.key === "Enter") {
|
||||
if (onEnterHighlightedModel()) {
|
||||
(event as typeof event & { preventBaseUIHandler?: () => void }).preventBaseUIHandler?.();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
event.stopPropagation();
|
||||
},
|
||||
[onEnterHighlightedModel, onEscape],
|
||||
);
|
||||
|
||||
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;
|
||||
@@ -292,7 +221,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
}, [modelOptionsByInstance, entryByInstanceId, readyInstanceSet]);
|
||||
|
||||
const isLocked = props.lockedProvider !== null;
|
||||
const isSearching = searchQuery.length > 0;
|
||||
const isSearching = searchQuery.trim().length > 0;
|
||||
const lockedDisabledInstanceIds = useMemo(() => {
|
||||
if (!isLocked) {
|
||||
return undefined;
|
||||
@@ -332,7 +261,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
let result = flatModels;
|
||||
|
||||
// Apply tokenized fuzzy search across the combined provider/model search fields.
|
||||
if (searchQuery) {
|
||||
if (searchQuery.trim()) {
|
||||
const rankedMatches = result
|
||||
.map((model) => ({
|
||||
model,
|
||||
@@ -456,23 +385,6 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
|
||||
},
|
||||
[entryByInstanceId, getModelDisabledReason, modelOptionsByInstance, onInstanceModelChange],
|
||||
);
|
||||
const handleSearchQueryChange = useCallback((nextSearchQuery: string) => {
|
||||
setSearchQuery((currentSearchQuery) =>
|
||||
currentSearchQuery === nextSearchQuery ? currentSearchQuery : nextSearchQuery,
|
||||
);
|
||||
}, []);
|
||||
const handleSearchEscape = useCallback(() => {
|
||||
props.onRequestClose?.();
|
||||
}, [props.onRequestClose]);
|
||||
const handleSearchEnterHighlightedModel = useCallback(() => {
|
||||
const highlightedModelKey = highlightedModelKeyRef.current;
|
||||
if (!highlightedModelKey) {
|
||||
return false;
|
||||
}
|
||||
const { instanceId, slug } = splitInstanceModelKey(highlightedModelKey);
|
||||
handleModelSelect(slug, instanceId);
|
||||
return true;
|
||||
}, [handleModelSelect]);
|
||||
|
||||
const toggleFavorite = useCallback(
|
||||
(instanceId: ProviderInstanceId, model: string) => {
|
||||
@@ -665,11 +577,42 @@ 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">
|
||||
<ModelPickerSearchInput
|
||||
inputRef={searchInputRef}
|
||||
onSearchQueryChange={handleSearchQueryChange}
|
||||
onEscape={handleSearchEscape}
|
||||
onEnterHighlightedModel={handleSearchEnterHighlightedModel}
|
||||
<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
|
||||
/>
|
||||
</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;
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -5,7 +5,23 @@ import * as Ref from "effect/Ref";
|
||||
import * as Schedule from "effect/Schedule";
|
||||
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
||||
|
||||
export const DEFAULT_HTTP_READY_PROBE_TIMEOUT_MS = 1_000;
|
||||
const DEFAULT_HTTP_READY_TIMEOUT = Duration.seconds(30);
|
||||
const DEFAULT_HTTP_READY_INTERVAL = Duration.millis(100);
|
||||
export const DEFAULT_HTTP_READY_PROBE_TIMEOUT = Duration.seconds(1);
|
||||
export const DEFAULT_HTTP_READY_PROBE_TIMEOUT_MS = Duration.toMillis(
|
||||
DEFAULT_HTTP_READY_PROBE_TIMEOUT,
|
||||
);
|
||||
|
||||
function normalizeDuration(input: {
|
||||
readonly duration: Duration.Input | undefined;
|
||||
readonly durationMs: number | undefined;
|
||||
readonly fallback: Duration.Duration;
|
||||
}): Duration.Duration {
|
||||
return Option.getOrElse(
|
||||
Duration.fromInput(input.duration ?? input.durationMs ?? input.fallback),
|
||||
() => input.fallback,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes an arbitrary readiness probe failure into a plain, structured value
|
||||
@@ -39,9 +55,10 @@ export function describeReadinessCause(cause: unknown): unknown {
|
||||
/**
|
||||
* Generic HTTP readiness probe shared by the SSH tunnel and the desktop backend
|
||||
* manager. Polls `baseUrl + path` until it returns a 2xx response or the overall
|
||||
* `timeoutMs` elapses. Each individual probe is bounded by `probeTimeoutMs` so a
|
||||
* `timeout` elapses. Each individual probe is bounded by `probeTimeout` so a
|
||||
* single hung request cannot stall the retry loop, and the retry cadence is
|
||||
* `intervalMs` bounded to roughly `timeoutMs / intervalMs` attempts.
|
||||
* `interval` bounded to roughly `timeout / interval` attempts. Legacy `*Ms`
|
||||
* options are still accepted at the boundary and are treated as milliseconds.
|
||||
*
|
||||
* The error type is left to the caller via `makeError`, so each consumer keeps
|
||||
* its own tagged error. `makeError` is called at every failure site; callers can
|
||||
@@ -53,6 +70,9 @@ export const waitForHttpReady = Effect.fn("shared.httpReadiness.waitForHttpReady
|
||||
>(input: {
|
||||
readonly baseUrl: string;
|
||||
readonly path?: string;
|
||||
readonly timeout?: Duration.Input;
|
||||
readonly interval?: Duration.Input;
|
||||
readonly probeTimeout?: Duration.Input;
|
||||
readonly timeoutMs?: number;
|
||||
readonly intervalMs?: number;
|
||||
readonly probeTimeoutMs?: number;
|
||||
@@ -63,10 +83,25 @@ export const waitForHttpReady = Effect.fn("shared.httpReadiness.waitForHttpReady
|
||||
readonly cause: unknown;
|
||||
}) => E;
|
||||
}): Effect.fn.Return<void, E, HttpClient.HttpClient> {
|
||||
const timeoutMs = input.timeoutMs ?? 30_000;
|
||||
const intervalMs = input.intervalMs ?? 100;
|
||||
const probeTimeoutMs = input.probeTimeoutMs ?? DEFAULT_HTTP_READY_PROBE_TIMEOUT_MS;
|
||||
const retryPolicy = Schedule.spaced(Duration.millis(intervalMs)).pipe(
|
||||
const timeout = normalizeDuration({
|
||||
duration: input.timeout,
|
||||
durationMs: input.timeoutMs,
|
||||
fallback: DEFAULT_HTTP_READY_TIMEOUT,
|
||||
});
|
||||
const interval = normalizeDuration({
|
||||
duration: input.interval,
|
||||
durationMs: input.intervalMs,
|
||||
fallback: DEFAULT_HTTP_READY_INTERVAL,
|
||||
});
|
||||
const probeTimeout = normalizeDuration({
|
||||
duration: input.probeTimeout,
|
||||
durationMs: input.probeTimeoutMs,
|
||||
fallback: DEFAULT_HTTP_READY_PROBE_TIMEOUT,
|
||||
});
|
||||
const timeoutMs = Duration.toMillis(timeout);
|
||||
const intervalMs = Duration.toMillis(interval);
|
||||
const probeTimeoutMs = Duration.toMillis(probeTimeout);
|
||||
const retryPolicy = Schedule.spaced(interval).pipe(
|
||||
Schedule.take(Math.max(0, Math.ceil(timeoutMs / intervalMs))),
|
||||
);
|
||||
const requestUrl = new URL(input.path ?? "/", input.baseUrl).toString();
|
||||
@@ -103,7 +138,7 @@ export const waitForHttpReady = Effect.fn("shared.httpReadiness.waitForHttpReady
|
||||
Effect.gen(function* () {
|
||||
attempt += 1;
|
||||
const responseOption = yield* effect.pipe(
|
||||
Effect.timeoutOption(Duration.millis(probeTimeoutMs)),
|
||||
Effect.timeoutOption(probeTimeout),
|
||||
Effect.mapError((cause) => fail(cause)),
|
||||
);
|
||||
return yield* Option.match(responseOption, {
|
||||
@@ -133,7 +168,7 @@ export const waitForHttpReady = Effect.fn("shared.httpReadiness.waitForHttpReady
|
||||
|
||||
const result = yield* readinessClient.execute(HttpClientRequest.get(requestUrl)).pipe(
|
||||
Effect.mapError((cause) => (isMadeError(cause) ? cause : fail(cause))),
|
||||
Effect.timeoutOption(Duration.millis(timeoutMs)),
|
||||
Effect.timeoutOption(timeout),
|
||||
);
|
||||
|
||||
return yield* Option.match(result, {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -244,9 +244,9 @@ describe("ssh tunnel scripts", () => {
|
||||
Effect.result(
|
||||
waitForHttpReady({
|
||||
baseUrl: "http://127.0.0.1:41773/",
|
||||
timeoutMs: 1_000,
|
||||
intervalMs: 100,
|
||||
probeTimeoutMs: 250,
|
||||
timeout: Duration.seconds(1),
|
||||
interval: Duration.millis(100),
|
||||
probeTimeout: Duration.millis(250),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -11,6 +11,7 @@ import { extractJsonObject, fromLenientJson } from "@t3tools/shared/schemaJson";
|
||||
import { satisfiesSemverRange } from "@t3tools/shared/semver";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
@@ -843,6 +844,9 @@ const readRemoteServerLogTail = Effect.fn("ssh/tunnel.readRemoteServerLogTail")(
|
||||
|
||||
export const waitForHttpReady = (input: {
|
||||
readonly baseUrl: string;
|
||||
readonly timeout?: Duration.Input;
|
||||
readonly interval?: Duration.Input;
|
||||
readonly probeTimeout?: Duration.Input;
|
||||
readonly timeoutMs?: number;
|
||||
readonly intervalMs?: number;
|
||||
readonly probeTimeoutMs?: number;
|
||||
@@ -851,6 +855,9 @@ export const waitForHttpReady = (input: {
|
||||
waitForHttpReadyShared({
|
||||
baseUrl: input.baseUrl,
|
||||
...(input.path === undefined ? {} : { path: input.path }),
|
||||
...(input.timeout === undefined ? {} : { timeout: input.timeout }),
|
||||
...(input.interval === undefined ? {} : { interval: input.interval }),
|
||||
...(input.probeTimeout === undefined ? {} : { probeTimeout: input.probeTimeout }),
|
||||
...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
|
||||
...(input.intervalMs === undefined ? {} : { intervalMs: input.intervalMs }),
|
||||
probeTimeoutMs: input.probeTimeoutMs ?? SSH_READY_PROBE_TIMEOUT_MS,
|
||||
|
||||
Reference in new issue
Block a user