@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 91 lines 2.86 KB
Raw
1 import { ProviderInstanceId, ThreadId, type ServerProvider } from "@t3tools/contracts";
2 import { expect, it } from "@effect/vitest";
3
4 import { type AgentThread, agentToolProperties, handoffSettings } from "./ProviderDimensions.ts";
5
6 const 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
17 const 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
26 const 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
40 it("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
70 it("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 });
79
80 it("records the binding the saved scheduled task resolved to, and none for failures", () => {
81 expect(handoffSettings("schedule_task", {}, { boundThreadId: null })).toEqual({
82 bindToCurrentThread: false,
83 });
84 expect(
85 handoffSettings(
86 "schedule_task",
87 { bindToCurrentThread: true },
88 { _tag: "OrchestratorMcpFailure", code: "invalid_request", message: "Different project." },
89 ),
90 ).toEqual({});
91 });