Add ACP replay harness and session lifecycle support

- Add replay agent and fixture-driven ACP transcript testing
- Support session lifecycle, auth methods, and session resume/fork flows
- Expand orchestration V2 adapter coverage and debug tooling
This commit is contained in:
Julius Marminge committed 2026-06-18 20:55:08 -07:00
1 parent 9d38de8628
commit 1161529645
65 files changed
+9914 -74

No files matched your search

@@ -13,7 +13,7 @@ import { useSettings, useUpdateSettings } from "../../hooks/useSettings";
import { cn } from "../../lib/utils";
import { normalizeProviderAccentColor } from "../../providerInstances";
import { Button } from "../ui/button";
import { ACPRegistryIcon, Gemini, GithubCopilotIcon, PiAgentIcon, type Icon } from "../Icons";
import { Gemini, GithubCopilotIcon, PiAgentIcon, type Icon } from "../Icons";
import {
Dialog,
DialogDescription,
@@ -81,11 +81,6 @@ const COMING_SOON_DRIVER_OPTIONS: readonly ComingSoonDriverOption[] = [
label: "Gemini",
icon: Gemini,
},
{
value: ProviderDriverKind.make("acpRegistry"),
label: "ACP Registry",
icon: ACPRegistryIcon,
},
{
value: ProviderDriverKind.make("piAgent"),
label: "Pi Agent",
@@ -36,6 +36,18 @@ describe("ProviderSettingsForm helpers", () => {
});
});
it("exposes ACP Registry as an instance-only configurable driver", () => {
const acpRegistry = DRIVER_OPTION_BY_VALUE[ProviderDriverKind.make("acpRegistry")];
expect(acpRegistry).toBeDefined();
expect(acpRegistry?.hasDefaultInstance).toBe(false);
expect(deriveProviderSettingsFields(acpRegistry!).map((field) => field.key)).toEqual([
"agentId",
"commandPath",
"authMethodId",
]);
});
it("preserves unknown config keys while omitting empty configurable fields", () => {
const opencode = DRIVER_OPTION_BY_VALUE[ProviderDriverKind.make("opencode")];
expect(opencode).toBeDefined();
@@ -1233,6 +1233,35 @@ describe("GeneralSettingsPanel observability", () => {
await expect.element(page.getByPlaceholder("Optional")).toBeInTheDocument();
});
it("renders configured ACP Registry instances without a blank default card", async () => {
const instanceId = ProviderInstanceId.make("acpRegistry_devin");
setServerConfigSnapshot({
...createBaseServerConfig(),
settings: {
...DEFAULT_SERVER_SETTINGS,
providerInstances: {
[instanceId]: {
driver: ProviderDriverKind.make("acpRegistry"),
displayName: "Devin ACP",
config: { agentId: "devin" },
},
},
},
});
mounted = await render(
<AppAtomRegistryProvider>
<ProviderSettingsPanel />
</AppAtomRegistryProvider>,
);
await expect
.element(page.getByLabelText("Toggle ACP Registry details"))
.not.toBeInTheDocument();
await page.getByLabelText("Toggle Devin ACP details").click();
await expect.element(page.getByText("Registry agent ID")).toBeInTheDocument();
});
it("runs one-click provider updates from the provider card", async () => {
const updateProvider = vi.fn<LocalApi["server"]["updateProvider"]>().mockResolvedValue({
providers: [createOutdatedProvider("codex")],
@@ -121,6 +121,7 @@ function withoutProviderInstanceFavorites(
const PROVIDER_SETTINGS = DRIVER_OPTIONS.map((definition) => ({
provider: definition.value,
hasDefaultInstance: definition.hasDefaultInstance !== false,
}));
function ProviderLastChecked({ lastCheckedAt }: { lastCheckedAt: string | null }) {
@@ -1032,9 +1033,9 @@ export function ProviderSettingsPanel() {
}
const defaultSlotIdsBySource = new Set<string>(
visibleProviderSettings.map((providerSettings) =>
String(defaultInstanceIdForDriver(providerSettings.provider)),
),
visibleProviderSettings
.filter((providerSettings) => providerSettings.hasDefaultInstance)
.map((providerSettings) => String(defaultInstanceIdForDriver(providerSettings.provider))),
);
const rows: InstanceRow[] = [];
@@ -1043,6 +1044,12 @@ export function ProviderSettingsPanel() {
);
for (const providerSettings of visibleProviderSettings) {
if (!providerSettings.hasDefaultInstance) {
for (const [id, instance] of instancesByDriver.get(providerSettings.provider) ?? []) {
rows.push({ instanceId: id, instance, driver: instance.driver, isDefault: false });
}
continue;
}
type LegacyProviderSettings = (typeof settings.providers)[keyof typeof settings.providers];
const legacyProviders = settings.providers as Record<string, LegacyProviderSettings>;
const defaultLegacyProviders = DEFAULT_UNIFIED_SETTINGS.providers as Record<
@@ -1,4 +1,5 @@
import {
AcpRegistrySettings,
ClaudeSettings,
CodexSettings,
CursorSettings,
@@ -7,7 +8,15 @@ import {
ProviderDriverKind,
} from "@t3tools/contracts";
import type * as Schema from "effect/Schema";
import { ClaudeAI, CursorIcon, GrokIcon, type Icon, OpenAI, OpenCodeIcon } from "../Icons";
import {
ACPRegistryIcon,
ClaudeAI,
CursorIcon,
GrokIcon,
type Icon,
OpenAI,
OpenCodeIcon,
} from "../Icons";
type ProviderSettingsSchema = {
readonly fields: Readonly<Record<string, Schema.Top>>;
@@ -24,6 +33,8 @@ export interface ProviderClientDefinition {
readonly label: string;
readonly icon: Icon;
readonly settingsSchema: ProviderSettingsSchema;
/** Whether this driver has a built-in default instance backed by legacy settings. */
readonly hasDefaultInstance?: boolean;
/**
* Optional short label rendered as a `variant="warning"` badge next to
* the instance title. Used to flag drivers that still ship under an
@@ -61,6 +72,14 @@ export const PROVIDER_CLIENT_DEFINITIONS: readonly ProviderClientDefinition[] =
badgeLabel: "Early Access",
settingsSchema: GrokSettings,
},
{
value: ProviderDriverKind.make("acpRegistry"),
label: "ACP Registry",
icon: ACPRegistryIcon,
badgeLabel: "V2 Preview",
settingsSchema: AcpRegistrySettings,
hasDefaultInstance: false,
},
{
value: ProviderDriverKind.make("opencode"),
label: "OpenCode",
@@ -0,0 +1,82 @@
import {
ProviderDriverKind,
ProviderInstanceId,
type ProviderInstanceConfigMap,
type ServerProvider,
} from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";
import { deriveOrchestrationV2DebugProviderSnapshots } from "./orchestrationV2DebugProviders";
const acpRegistry = ProviderDriverKind.make("acpRegistry");
const instanceId = ProviderInstanceId.make("acpRegistry_example");
const unavailable: ServerProvider = {
instanceId,
driver: acpRegistry,
displayName: "Example ACP",
enabled: false,
installed: false,
version: null,
status: "error",
auth: { status: "unknown" },
checkedAt: "2026-01-01T00:00:00.000Z",
availability: "unavailable",
unavailableReason: "Driver is not registered in the V1 runtime.",
models: [],
slashCommands: [],
skills: [],
};
describe("deriveOrchestrationV2DebugProviderSnapshots", () => {
it("replaces the V1 unavailable shadow for a configured registry agent", () => {
const providerInstances = {
[instanceId]: {
driver: acpRegistry,
enabled: true,
displayName: "Example ACP",
config: {
agentId: "example-agent",
customModels: ["model-one"],
},
},
} satisfies ProviderInstanceConfigMap;
expect(
deriveOrchestrationV2DebugProviderSnapshots({
providers: [unavailable],
providerInstances,
}),
).toEqual([
expect.objectContaining({
instanceId,
driver: acpRegistry,
displayName: "Example ACP",
enabled: true,
installed: true,
status: "ready",
availability: "available",
models: [
expect.objectContaining({ slug: "default", isCustom: false }),
expect.objectContaining({ slug: "model-one", isCustom: true }),
],
}),
]);
});
it("does not make an incomplete registry instance selectable", () => {
const providerInstances = {
[instanceId]: {
driver: acpRegistry,
config: { agentId: "" },
},
} satisfies ProviderInstanceConfigMap;
expect(
deriveOrchestrationV2DebugProviderSnapshots({
providers: [unavailable],
providerInstances,
}),
).toEqual([unavailable]);
});
});
@@ -0,0 +1,88 @@
import {
ProviderDriverKind,
type ProviderInstanceConfigMap,
type ProviderInstanceId,
type ServerProvider,
type ServerProviderModel,
} from "@t3tools/contracts";
const ACP_REGISTRY_DRIVER = ProviderDriverKind.make("acpRegistry");
const DEBUG_CHECKED_AT = "1970-01-01T00:00:00.000Z";
function configRecord(config: unknown): Readonly<Record<string, unknown>> {
return config !== null && typeof config === "object" && !Array.isArray(config)
? (config as Readonly<Record<string, unknown>>)
: {};
}
function configuredModels(
config: Readonly<Record<string, unknown>>,
): ReadonlyArray<ServerProviderModel> {
const customModels = Array.isArray(config.customModels)
? config.customModels.filter(
(model): model is string => typeof model === "string" && model.trim().length > 0,
)
: [];
const slugs = [...new Set(["default", ...customModels.map((model) => model.trim())])];
return slugs.map((slug) => ({
slug,
name: slug === "default" ? "Agent default" : slug,
shortName: slug === "default" ? "Default" : slug,
isCustom: slug !== "default",
capabilities: null,
}));
}
/**
* Add V2-only ACP Registry instances to the orchestration debugger's provider catalog.
* The regular application provider catalog remains V1-owned and is intentionally untouched.
*/
export function deriveOrchestrationV2DebugProviderSnapshots(input: {
readonly providers: ReadonlyArray<ServerProvider>;
readonly providerInstances: ProviderInstanceConfigMap;
}): ReadonlyArray<ServerProvider> {
const snapshots = [...input.providers];
const indexByInstanceId = new Map<ProviderInstanceId, number>(
snapshots.map((provider, index) => [provider.instanceId, index]),
);
for (const [instanceId, instance] of Object.entries(input.providerInstances)) {
if (instance.driver !== ACP_REGISTRY_DRIVER) continue;
const config = configRecord(instance.config);
const agentId = typeof config.agentId === "string" ? config.agentId.trim() : "";
if (agentId.length === 0) continue;
const id = instanceId as ProviderInstanceId;
const existingIndex = indexByInstanceId.get(id);
const existing = existingIndex === undefined ? undefined : snapshots[existingIndex];
const enabled =
instance.enabled ?? (typeof config.enabled === "boolean" ? config.enabled : true);
const snapshot: ServerProvider = {
instanceId: id,
driver: ACP_REGISTRY_DRIVER,
displayName: instance.displayName?.trim() || `ACP: ${agentId}`,
...(instance.accentColor ? { accentColor: instance.accentColor } : {}),
badgeLabel: "V2 Preview",
showInteractionModeToggle: true,
requiresNewThreadForModelChange: false,
enabled,
installed: true,
version: null,
status: enabled ? "ready" : "disabled",
auth: { status: "unknown" },
checkedAt: existing?.checkedAt ?? DEBUG_CHECKED_AT,
message: `ACP Registry agent '${agentId}' is resolved when the V2 session starts.`,
availability: "available",
models: configuredModels(config),
slashCommands: [],
skills: [],
};
if (existingIndex === undefined) {
indexByInstanceId.set(id, snapshots.length);
snapshots.push(snapshot);
} else {
snapshots[existingIndex] = snapshot;
}
}
return snapshots;
}
@@ -36,6 +36,7 @@ import {
} from "../lib/orchestrationV2Timeline";
import { newCommandId, newMessageId, newProjectId, newThreadId } from "../lib/utils";
import { type AppModelOption, getAppModelOptionsForInstance } from "../modelSelection";
import { deriveOrchestrationV2DebugProviderSnapshots } from "../orchestrationV2DebugProviders";
import {
type ProviderInstanceEntry,
deriveProviderInstanceEntries,
@@ -1621,7 +1622,14 @@ function OrchestrationV2DebugRoute() {
const serverProviders = useServerProviders();
const settings = useSettings();
const keybindings = useServerKeybindings();
const providerSnapshots = serverProviders.length > 0 ? serverProviders : DEBUG_PROVIDER_SNAPSHOTS;
const providerSnapshots = useMemo(
() =>
deriveOrchestrationV2DebugProviderSnapshots({
providers: serverProviders.length > 0 ? serverProviders : DEBUG_PROVIDER_SNAPSHOTS,
providerInstances: settings.providerInstances,
}),
[serverProviders, settings.providerInstances],
);
const providerInstanceEntries = useMemo<ReadonlyArray<ProviderInstanceEntry>>(
() => sortProviderInstanceEntries(deriveProviderInstanceEntries(providerSnapshots)),
[providerSnapshots],