The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { |
| 2 | createAtomCommandScheduler, |
| 3 | createRuntimeCommand, |
| 4 | } from "@t3tools/client-runtime/state/runtime"; |
| 5 | |
| 6 | import { connectionAtomRuntime } from "../connection/runtime"; |
| 7 | import { |
| 8 | checkCloudReachability, |
| 9 | linkEnvironmentToCloud, |
| 10 | readCloudLinkState, |
| 11 | type CloudLinkMode, |
| 12 | type CloudLinkTarget, |
| 13 | unlinkEnvironmentFromCloud, |
| 14 | updateCloudPreferences, |
| 15 | } from "./linkEnvironment"; |
| 16 | |
| 17 | const cloudLinkScheduler = createAtomCommandScheduler(); |
| 18 | const cloudLinkConcurrency = { |
| 19 | mode: "serial" as const, |
| 20 | key: (input: { readonly target: CloudLinkTarget }) => input.target.environmentId, |
| 21 | }; |
| 22 | |
| 23 | export const linkEnvironment = createRuntimeCommand(connectionAtomRuntime, { |
| 24 | label: "web:cloud:link-environment", |
| 25 | scheduler: cloudLinkScheduler, |
| 26 | concurrency: cloudLinkConcurrency, |
| 27 | execute: (input: { |
| 28 | readonly target: CloudLinkTarget; |
| 29 | readonly clerkToken: string; |
| 30 | readonly mode?: CloudLinkMode; |
| 31 | }) => linkEnvironmentToCloud(input), |
| 32 | }); |
| 33 | |
| 34 | export const unlinkEnvironment = createRuntimeCommand(connectionAtomRuntime, { |
| 35 | label: "web:cloud:unlink-environment", |
| 36 | scheduler: cloudLinkScheduler, |
| 37 | concurrency: cloudLinkConcurrency, |
| 38 | execute: (input: { readonly target: CloudLinkTarget; readonly clerkToken: string | null }) => |
| 39 | unlinkEnvironmentFromCloud(input), |
| 40 | }); |
| 41 | |
| 42 | export const updateEnvironmentPreferences = createRuntimeCommand(connectionAtomRuntime, { |
| 43 | label: "web:cloud:update-environment-preferences", |
| 44 | scheduler: cloudLinkScheduler, |
| 45 | concurrency: cloudLinkConcurrency, |
| 46 | execute: (input: { |
| 47 | readonly target: CloudLinkTarget; |
| 48 | readonly publishAgentActivity: boolean; |
| 49 | readonly holdWebhooksWhileOffline?: boolean; |
| 50 | }) => updateCloudPreferences(input), |
| 51 | }); |
| 52 | |
| 53 | export const checkReachability = createRuntimeCommand(connectionAtomRuntime, { |
| 54 | label: "web:cloud:check-reachability", |
| 55 | execute: (input: { readonly target: CloudLinkTarget }) => checkCloudReachability(input), |
| 56 | }); |
| 57 | |
| 58 | export const readLinkState = createRuntimeCommand(connectionAtomRuntime, { |
| 59 | label: "web:cloud:read-link-state", |
| 60 | execute: (input: { readonly target: CloudLinkTarget }) => readCloudLinkState(input), |
| 61 | }); |