The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { |
| 2 | DefaultThemePreference, |
| 3 | EnvironmentThemeFile, |
| 4 | EnvironmentThemeId, |
| 5 | OrchestratorMcpFailure, |
| 6 | } from "@t3tools/contracts"; |
| 7 | import * as Schema from "effect/Schema"; |
| 8 | import { Tool, Toolkit } from "effect/ai"; |
| 9 | import * as EnvironmentTheme from "../../../environmentTheme.ts"; |
| 10 | import * as McpInvocationContext from "../../McpInvocationContext.ts"; |
| 11 | import * as ThreadCommandExecutor from "../../../orchestration-v2/ThreadCommandExecutor.ts"; |
| 12 | import * as ThreadManagementService from "../../../orchestration-v2/ThreadManagementService.ts"; |
| 13 | |
| 14 | const Appearance = Schema.Literals(["light", "dark", "system"]); |
| 15 | |
| 16 | const shared = { |
| 17 | failure: OrchestratorMcpFailure, |
| 18 | failureMode: "return" as const, |
| 19 | dependencies: [ |
| 20 | McpInvocationContext.McpInvocationContext, |
| 21 | ThreadManagementService.ThreadManagementService, |
| 22 | EnvironmentTheme.EnvironmentThemeService, |
| 23 | ThreadCommandExecutor.ThreadCommandExecutor, |
| 24 | ], |
| 25 | }; |
| 26 | |
| 27 | const ThemeReadTool = Tool.make("t3_theme_read", { |
| 28 | ...shared, |
| 29 | description: |
| 30 | "Read T3 Code's own themes and the guide to restyle it: color roles and CSS selectors. Call before `t3_theme_set`.", |
| 31 | parameters: Schema.Struct({ |
| 32 | themeId: Schema.optionalKey( |
| 33 | EnvironmentThemeId.annotate({ description: "Also return this published theme's file." }), |
| 34 | ), |
| 35 | }), |
| 36 | success: Schema.Struct({ |
| 37 | current: DefaultThemePreference, |
| 38 | builtIn: Schema.Array(Schema.String), |
| 39 | published: Schema.Array( |
| 40 | Schema.Struct({ |
| 41 | id: EnvironmentThemeId, |
| 42 | name: Schema.String, |
| 43 | hasCss: Schema.Boolean, |
| 44 | hasBackground: Schema.Boolean, |
| 45 | }), |
| 46 | ), |
| 47 | theme: Schema.optionalKey(EnvironmentThemeFile), |
| 48 | themesDir: Schema.String, |
| 49 | guide: Schema.String, |
| 50 | }), |
| 51 | }) |
| 52 | .annotate(Tool.Readonly, true) |
| 53 | .annotate(Tool.Destructive, false); |
| 54 | |
| 55 | const ThemeSetTool = Tool.make("t3_theme_set", { |
| 56 | ...shared, |
| 57 | description: |
| 58 | "Restyle T3 Code itself, only when the user asks. With `theme`, publish it as `themeId` (same id updates it) and switch this server's web app and this machine's desktop app to it, not remote desktop apps. Without `theme`, switch to a built-in or published `themeId`. `appearance` sets light, dark, or system mode. Live full-access or default caller thread only.", |
| 59 | parameters: Schema.Struct({ |
| 60 | themeId: Schema.optionalKey(EnvironmentThemeId), |
| 61 | theme: Schema.optionalKey(EnvironmentThemeFile), |
| 62 | appearance: Schema.optionalKey(Appearance), |
| 63 | }), |
| 64 | success: Schema.Struct({ |
| 65 | themeId: Schema.optionalKey(EnvironmentThemeId), |
| 66 | appearance: Schema.optionalKey(Appearance), |
| 67 | published: Schema.Boolean, |
| 68 | }), |
| 69 | }).annotate(Tool.Destructive, true); |
| 70 | |
| 71 | export const ThemeToolkit = Toolkit.make(ThemeReadTool, ThemeSetTool); |