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

main
ts 194 lines 6.54 KB
Raw
1 import { startFileDrag } from "./methods/fileDrag.ts";
2 import * as Effect from "effect/Effect";
3
4 import { receiveProviderAuthCallback, cancelProviderAuthCallback } from "./methods/providerAuth.ts";
5 import {
6 appleSpeechAvailable,
7 appleSpeechPrepare,
8 appleSpeechTranscribe,
9 } from "./methods/appleSpeech.ts";
10 import * as DesktopIpc from "./DesktopIpc.ts";
11 import { installNotificationBadge } from "./methods/notificationBadge.ts";
12 import { getClientSettings, setClientSettings } from "./methods/clientSettings.ts";
13 import { getConnectionCatalog, setConnectionCatalog } from "./methods/connectionCatalog.ts";
14 import {
15 getHostEnvironmentId,
16 getLocalEnvironmentEnabled,
17 setLocalEnvironmentEnabled,
18 } from "./methods/localEnvironment.ts";
19 import {
20 getAdvertisedEndpoints,
21 getServerExposureState,
22 setServerExposureMode,
23 setTailscaleServeEnabled,
24 } from "./methods/serverExposure.ts";
25 import {
26 bootstrapSshBearerSession,
27 disconnectSshEnvironment,
28 discoverSshHosts,
29 ensureSshEnvironment,
30 fetchSshEnvironmentDescriptor,
31 fetchSshSessionState,
32 resolveSshHost,
33 resolveSshPasswordPrompt,
34 } from "./methods/sshEnvironment.ts";
35 import {
36 checkForUpdate,
37 downloadUpdate,
38 getUpdateState,
39 installUpdate,
40 setUpdateChannel,
41 } from "./methods/updates.ts";
42 import {
43 getAppBranding,
44 getLocalEnvironmentBootstraps,
45 getLocalEnvironmentBearerToken,
46 installRelayTelemetryEnabled,
47 getSystemLocale,
48 getPreferredSystemLanguages,
49 getPrimaryPasteEnabled,
50 getWindowFullscreenState,
51 openExternal,
52 readMedia,
53 restartAudioService,
54 openSystemSettings,
55 checkSystemPermission,
56 pasteAsText,
57 probeRemoteEditors,
58 revealWindow,
59 pickFolder,
60 toLocalBackendPath,
61 pickProjectFavicon,
62 pickThemeFiles,
63 setTheme,
64 syncHtmlFullscreen,
65 showContextMenu,
66 } from "./methods/window.ts";
67 import {
68 acknowledgeSnapShot,
69 checkSnapShotShortcut,
70 dismissSnapShotAnimation,
71 getSnapShotState,
72 setupSnapShot,
73 previewSnapShotConfig,
74 applySnapShotConfig,
75 listPendingSnapShots,
76 readSnapShot,
77 requestSnapShotPermissions,
78 setSnapShotAnimationDestination,
79 setSnapShotShortcutSuppressed,
80 } from "./methods/snapShot.ts";
81 import * as PreviewIpc from "./methods/preview.ts";
82 import * as AppActivationIpc from "./methods/appActivation.ts";
83 import * as WebLinksIpc from "./methods/webLinks.ts";
84 import {
85 completeLegacyLocalStorage,
86 takeLegacyLocalStorage,
87 } from "./methods/legacyLocalStorage.ts";
88 import { getWslState, setWslBackendEnabled, setWslDistro, setWslOnly } from "./methods/wsl.ts";
89 import {
90 getCliCommandState,
91 installCliCommand,
92 uninstallCliCommand,
93 addCliCommandToPath,
94 } from "./methods/cliCommand.ts";
95
96 export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers")(function* () {
97 const ipc = yield* DesktopIpc.DesktopIpc;
98 yield* installNotificationBadge();
99 yield* PreviewIpc.installPreviewEventForwarding();
100
101 yield* ipc.handle(AppActivationIpc.setReady);
102 yield* ipc.handle(AppActivationIpc.complete);
103 yield* ipc.handle(WebLinksIpc.setReady);
104
105 yield* ipc.handleSync(takeLegacyLocalStorage);
106 yield* ipc.handle(completeLegacyLocalStorage);
107 yield* ipc.handleSync(getAppBranding);
108 yield* installRelayTelemetryEnabled();
109 yield* ipc.handleSync(getSystemLocale);
110 yield* ipc.handleSync(getPreferredSystemLanguages);
111 yield* ipc.handleSync(getPrimaryPasteEnabled);
112 yield* ipc.handleSync(getWindowFullscreenState);
113 yield* ipc.handleSync(getLocalEnvironmentBootstraps);
114 yield* ipc.handleSync(getLocalEnvironmentEnabled);
115 yield* ipc.handle(setLocalEnvironmentEnabled);
116 yield* ipc.handle(getHostEnvironmentId);
117 yield* ipc.handle(getLocalEnvironmentBearerToken);
118
119 yield* ipc.handle(startFileDrag);
120 yield* ipc.handle(restartAudioService);
121 yield* ipc.handle(getClientSettings);
122 yield* ipc.handle(setClientSettings);
123 yield* ipc.handle(getConnectionCatalog);
124 yield* ipc.handle(getSnapShotState);
125 yield* ipc.handle(setupSnapShot);
126 yield* ipc.handle(previewSnapShotConfig);
127 yield* ipc.handle(applySnapShotConfig);
128 yield* ipc.handle(requestSnapShotPermissions);
129 yield* ipc.handle(checkSnapShotShortcut);
130 yield* ipc.handle(setSnapShotShortcutSuppressed);
131 yield* ipc.handle(listPendingSnapShots);
132 yield* ipc.handle(readSnapShot);
133 yield* ipc.handle(setSnapShotAnimationDestination);
134 yield* ipc.handle(dismissSnapShotAnimation);
135 yield* ipc.handle(acknowledgeSnapShot);
136 yield* ipc.handle(setConnectionCatalog);
137
138 yield* ipc.handle(discoverSshHosts);
139 yield* ipc.handle(resolveSshHost);
140 yield* ipc.handle(ensureSshEnvironment);
141 yield* ipc.handle(disconnectSshEnvironment);
142 yield* ipc.handle(fetchSshEnvironmentDescriptor);
143 yield* ipc.handle(bootstrapSshBearerSession);
144 yield* ipc.handle(fetchSshSessionState);
145 yield* ipc.handle(resolveSshPasswordPrompt);
146
147 yield* ipc.handle(getServerExposureState);
148 yield* ipc.handle(setServerExposureMode);
149 yield* ipc.handle(setTailscaleServeEnabled);
150 yield* ipc.handle(getAdvertisedEndpoints);
151
152 yield* ipc.handle(getWslState);
153 yield* ipc.handle(setWslBackendEnabled);
154 yield* ipc.handle(setWslDistro);
155 yield* ipc.handle(setWslOnly);
156
157 yield* ipc.handle(pickFolder);
158 yield* ipc.handle(toLocalBackendPath);
159 yield* ipc.handle(pickProjectFavicon);
160 yield* ipc.handle(pickThemeFiles);
161 yield* ipc.handle(setTheme);
162 yield* ipc.handle(showContextMenu);
163 yield* ipc.handle(openExternal);
164 yield* ipc.handle(readMedia);
165 yield* ipc.handle(receiveProviderAuthCallback);
166 yield* ipc.handle(cancelProviderAuthCallback);
167 yield* ipc.handle(openSystemSettings);
168 yield* ipc.handle(checkSystemPermission);
169 yield* ipc.handle(appleSpeechAvailable);
170 yield* ipc.handle(appleSpeechPrepare);
171 yield* ipc.handle(appleSpeechTranscribe);
172 yield* ipc.handle(pasteAsText);
173 yield* ipc.handle(revealWindow);
174 yield* ipc.handle(syncHtmlFullscreen);
175 yield* ipc.handle(probeRemoteEditors);
176 yield* ipc.handle(getUpdateState);
177 yield* ipc.handle(setUpdateChannel);
178 yield* ipc.handle(downloadUpdate);
179 yield* ipc.handle(installUpdate);
180 yield* ipc.handle(checkForUpdate);
181 yield* ipc.handle(getCliCommandState);
182 yield* ipc.handle(installCliCommand);
183 yield* ipc.handle(uninstallCliCommand);
184 yield* ipc.handle(addCliCommandToPath);
185 for (const previewMethod of PreviewIpc.methods) {
186 // Explicit types preserve the error/service union of these heterogeneous preview methods.
187 yield* ipc.handle<
188 Effect.Error<ReturnType<(typeof PreviewIpc.methods)[number]["handler"]>>,
189 Effect.Services<ReturnType<(typeof PreviewIpc.methods)[number]["handler"]>>
190 >(previewMethod);
191 }
192 yield* ipc.handle(PreviewIpc.listBrowserImportSources);
193 yield* ipc.handle(PreviewIpc.importBrowserCookies);
194 });