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
| 1 | import { |
| 2 | BackgroundActivityProfile, |
| 3 | BackgroundActivityProfileSelection, |
| 4 | ExecutionEnvironmentDescriptor, |
| 5 | OrchestratorMcpEnvironmentTarget, |
| 6 | OrchestratorMcpFailure, |
| 7 | ServerSettings, |
| 8 | ServerSettingsPatch, |
| 9 | } from "@t3tools/contracts"; |
| 10 | import * as Schema from "effect/Schema"; |
| 11 | import { Tool, Toolkit } from "effect/ai"; |
| 12 | import * as ServerEnvironment from "../../../environment/ServerEnvironment.ts"; |
| 13 | import * as ThreadCommandExecutor from "../../../orchestration-v2/ThreadCommandExecutor.ts"; |
| 14 | import * as ThreadManagementService from "../../../orchestration-v2/ThreadManagementService.ts"; |
| 15 | import * as Settings from "../../../serverSettings.ts"; |
| 16 | import * as McpInvocationContext from "../../McpInvocationContext.ts"; |
| 17 | |
| 18 | const PreferenceFields = { |
| 19 | defaultThreadEnvMode: ServerSettings.fields.defaultThreadEnvMode, |
| 20 | newWorktreesStartFromOrigin: ServerSettings.fields.newWorktreesStartFromOrigin, |
| 21 | enableProviderUpdateChecks: ServerSettings.fields.enableProviderUpdateChecks, |
| 22 | backgroundActivity: Schema.Struct({ profile: BackgroundActivityProfileSelection }), |
| 23 | sourceControlWritingStyle: Schema.Struct({ |
| 24 | mode: Schema.String, |
| 25 | followChangeRequestTemplates: Schema.Boolean, |
| 26 | customInstructions: Schema.String, |
| 27 | truncated: Schema.Boolean, |
| 28 | }), |
| 29 | }; |
| 30 | const shared = { |
| 31 | failure: OrchestratorMcpFailure, |
| 32 | failureMode: "return" as const, |
| 33 | dependencies: [ |
| 34 | McpInvocationContext.McpInvocationContext, |
| 35 | ThreadManagementService.ThreadManagementService, |
| 36 | ServerEnvironment.ServerEnvironment, |
| 37 | Settings.ServerSettingsService, |
| 38 | ThreadCommandExecutor.ThreadCommandExecutor, |
| 39 | ], |
| 40 | }; |
| 41 | const EnvironmentReadTool = Tool.make("t3_environment_read", { |
| 42 | ...shared, |
| 43 | description: |
| 44 | "Read this server's identity and preferences. Providers and models: `orchestrator_capabilities`.", |
| 45 | parameters: Schema.Struct({ environmentId: OrchestratorMcpEnvironmentTarget }), |
| 46 | success: Schema.Struct({ |
| 47 | environmentId: ExecutionEnvironmentDescriptor.fields.environmentId, |
| 48 | label: Schema.String, |
| 49 | serverVersion: Schema.String, |
| 50 | platform: ExecutionEnvironmentDescriptor.fields.platform, |
| 51 | preferences: Schema.Struct(PreferenceFields), |
| 52 | }), |
| 53 | }) |
| 54 | .annotate(Tool.Readonly, true) |
| 55 | .annotate(Tool.Destructive, false); |
| 56 | const EnvironmentPreferencesTool = Tool.make("t3_environment_preferences_update", { |
| 57 | ...shared, |
| 58 | description: |
| 59 | "Update environment-wide preferences. Live full-access or default caller thread only. Omitted fields are unchanged; `customInstructions: ''` clears it.", |
| 60 | parameters: Schema.Struct({ |
| 61 | environmentId: OrchestratorMcpEnvironmentTarget, |
| 62 | defaultThreadEnvMode: ServerSettingsPatch.fields.defaultThreadEnvMode, |
| 63 | newWorktreesStartFromOrigin: ServerSettingsPatch.fields.newWorktreesStartFromOrigin, |
| 64 | enableProviderUpdateChecks: ServerSettingsPatch.fields.enableProviderUpdateChecks, |
| 65 | backgroundActivity: Schema.optionalKey(Schema.Struct({ profile: BackgroundActivityProfile })), |
| 66 | sourceControlWritingStyle: ServerSettingsPatch.fields.sourceControlWritingStyle, |
| 67 | }), |
| 68 | success: Schema.Struct(PreferenceFields), |
| 69 | }).annotate(Tool.Destructive, true); |
| 70 | export const EnvironmentToolkit = Toolkit.make(EnvironmentReadTool, EnvironmentPreferencesTool); |