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

main
ts 47 lines 2.18 KB
Raw
1 import { assert, it } from "@effect/vitest";
2 import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
3 import * as Effect from "effect/Effect";
4 import * as SqlClient from "effect/sql/SqlClient";
5
6 import { runMigrations } from "../Migrations.ts";
7
8 const layer = it.layer(NodeSqliteClient.layer({ filename: ":memory:" }));
9
10 layer("095_TurnItemInlineWorkOutput", (it) => {
11 it.effect("flags existing dynamic tools whose output renders inline", () =>
12 Effect.gen(function* () {
13 const sql = yield* SqlClient.SqlClient;
14 yield* runMigrations({ toMigrationInclusive: 94 });
15 const rows: ReadonlyArray<readonly [string, string, object, number]> = [
16 ["delegate", "dynamic_tool", { toolName: "mcp__t3_code__delegate_task" }, 1],
17 ["html", "dynamic_tool", { toolName: "x", output: { htmlRender: {} } }, 1],
18 ["mcp-app", "dynamic_tool", { toolName: "x", output: { t3McpApp: {} } }, 1],
19 ["image", "dynamic_tool", { toolName: "view_image", viewedImagePath: "/a.png" }, 1],
20 ["send", "dynamic_tool", { toolName: "mcp__t3-code__send_to_user" }, 1],
21 ["sent", "dynamic_tool", { toolName: "execute", output: '{"sentMessage":"Hi"}' }, 1],
22 ["plain", "dynamic_tool", { toolName: "mcp__docs__search", output: "ok" }, 0],
23 ["command", "command_execution", { output: "htmlRender" }, 0],
24 ];
25 for (const [id, type, payload] of rows) {
26 yield* sql`
27 INSERT INTO orchestration_v2_projection_turn_items (
28 turn_item_id, thread_id, ordinal, type, status, updated_at, payload_json
29 ) VALUES (
30 ${id}, 'thread-1', 0, ${type}, 'completed', '2026-11-01T00:00:00.000Z',
31 ${JSON.stringify({ type, ...payload })}
32 )
33 `;
34 }
35
36 yield* runMigrations({ toMigrationInclusive: 95 });
37 const flagged = yield* sql<{ readonly turn_item_id: string; readonly inline: number }>`
38 SELECT turn_item_id, inline_work_output AS inline
39 FROM orchestration_v2_projection_turn_items
40 `;
41 assert.deepStrictEqual(
42 new Map(flagged.map((row) => [row.turn_item_id, row.inline])),
43 new Map(rows.map(([id, , , inline]) => [id, inline])),
44 );
45 }),
46 );
47 });