Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

toolPresentation.test.ts

107 lines3.1 KB

1import { describe, expect, it } from "@effect/vitest";
2​
3import { extractToolActivityPresentation } from "./toolPresentation.ts";
4​
5describe("extractToolActivityPresentation", () => {
6 it("retains valid image paths independently of redacted output", () => {
7 expect(
8 extractToolActivityPresentation({ viewedImagePath: " /workspace/reference.webp " }),
9 ).toEqual({ viewedImagePath: "/workspace/reference.webp" });
10 for (const viewedImagePath of [
11 "/workspace/README.md",
12 "/workspace/a.png\nother",
13 "x".repeat(4097) + ".png",
14 ])
15 expect(extractToolActivityPresentation({ viewedImagePath })).toEqual({});
16 });
17​
18 it("reads provider-neutral presentation fields", () => {
19 expect(
20 extractToolActivityPresentation({
21 toolSurface: "browser",
22 toolIcon: {
23 _tag: "website",
24 pageUrl: "https://example.com/docs",
25 faviconUrl: "https://example.com/favicon.png",
26 faviconUrlDark: "https://example.com/favicon-dark.png",
27 },
28 toolSource: {
29 key: "integration:example",
30 name: "Example",
31 kind: "integration",
32 icon: {
33 _tag: "themed-logo",
34 logoUrl: "https://example.com/logo-light.png",
35 logoUrlDark: "https://example.com/logo-dark.png",
36 },
37 },
38 }),
39 ).toEqual({
40 toolSurface: "browser",
41 toolIcon: {
42 _tag: "website",
43 pageUrl: "https://example.com/docs",
44 faviconUrl: "https://example.com/favicon.png",
45 faviconUrlDark: "https://example.com/favicon-dark.png",
46 },
47 toolSource: {
48 key: "integration:example",
49 name: "Example",
50 kind: "integration",
51 icon: {
52 _tag: "themed-logo",
53 logoUrl: "https://example.com/logo-light.png",
54 logoUrlDark: "https://example.com/logo-dark.png",
55 },
56 },
57 });
58 });
59​
60 it("reads provider-neutral native app icons", () => {
61 expect(
62 extractToolActivityPresentation({
63 toolSurface: "computer",
64 toolIcon: {
65 _tag: "native-app",
66 app: { _tag: "app-id", appId: "com.example.Editor" },
67 },
68 toolSource: {
69 key: "native-app:com.example.editor",
70 name: "Editor",
71 kind: "computer",
72 },
73 }),
74 ).toEqual({
75 toolSurface: "computer",
76 toolIcon: {
77 _tag: "native-app",
78 app: { _tag: "app-id", appId: "com.example.Editor" },
79 },
80 toolSource: {
81 key: "native-app:com.example.editor",
82 name: "Editor",
83 kind: "computer",
84 },
85 });
86 });
87​
88 it("does not infer presentation from provider-specific payload data", () => {
89 expect(
90 extractToolActivityPresentation({
91 data: {
92 item: {
93 arguments: { code: 'await sky.click({ app: "Finder" })' },
94 result: {
95 _meta: {
96 "codex/toolSurface": {
97 kind: "computerUse",
98 app: { kind: "displayName", displayName: "Finder" },
99 },
100 },
101 },
102 },
103 },
104 }),
105 ).toEqual({});
106 });
107});