Open History to see the last commit
1import { ProviderInstanceId, ThreadId, type ServerProvider } from "@t3tools/contracts";
2import { expect, it } from "@effect/vitest";
3
4import { type AgentThread, agentToolProperties, handoffSettings } from "./ProviderDimensions.ts";
5
6const provider = (
7 instanceId: string,
8 driver: string,
9 models: ReadonlyArray<{ slug: string; isCustom: boolean }>,
10) =>
11 ({
12 instanceId: ProviderInstanceId.make(instanceId),
13 driver,
14 models,
15 }) as unknown as ServerProvider;
16
17const providers = [
18 provider("work-codex", "codex", [{ slug: "gpt-5.5", isCustom: false }]),
19 provider("claudeAgent", "claudeAgent", [
20 { slug: "claude-opus-5-5", isCustom: false },
21 { slug: "my-private-finetune", isCustom: true },
22 ]),
23 provider("opencode", "opencode", [{ slug: "ollama/acme-internal", isCustom: false }]),
24];
25
26const thread = (
27 instanceId: string,
28 model: string,
29 overrides: Partial<AgentThread> = {},
30): AgentThread => ({
31 modelSelection: { instanceId: ProviderInstanceId.make(instanceId), model },
32 runtimeMode: "full-access",
33 interactionMode: "default",
34 createdBy: "user",
35 creationSource: "web",
36 lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: ThreadId.make("t") },
37 ...overrides,
38});
39
40it("omits custom, user-configured, and unknown models and instance names", () => {
41 expect(
42 agentToolProperties({
43 tool: "t3_thread_send",
44 providers,
45 caller: thread("claudeAgent", "my-private-finetune"),
46 targets: [thread("opencode", "ollama/acme-internal"), thread("removed-instance", "gpt-5.5")],
47 outcome: { outcome: "ok" },
48 }).map(({ callerProvider, callerModel, targetProvider, targetModel }) => ({
49 callerProvider,
50 callerModel,
51 targetProvider,
52 targetModel,
53 })),
54 ).toEqual([
55 {
56 callerProvider: "claudeAgent",
57 callerModel: undefined,
58 targetProvider: "opencode",
59 targetModel: undefined,
60 },
61 {
62 callerProvider: "claudeAgent",
63 callerModel: undefined,
64 targetProvider: "unknown",
65 targetModel: undefined,
66 },
67 ]);
68});
69
70it("drops input strings outside the schema's literals, since rejected calls are recorded too", () => {
71 expect(handoffSettings("delegate_task", { mode: "/home/me/secret" }, undefined)).toEqual({
72 targetChosen: false,
73 mode: "async",
74 });
75 expect(
76 handoffSettings("t3_thread_launch", { workspaceStrategy: { type: "/home/me/secret" } }, {}),
77 ).toEqual({ targetChosen: false, workspace: "root" });
78});