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

main
ts 29 lines 864 Bytes
Raw
1 import { ENTRY_ENVIRONMENT_KEY, type EntryEnvironment } from "./constants.shared.ts";
2 import type { ModuleRunnerDO } from "./module-runner.worker.ts";
3
4 export interface Env extends Cloudflare.Env {
5 __DISTILLED_MODULE_RUNNER__: {
6 get(id: "singleton"): ModuleRunnerDO;
7 };
8 __DISTILLED_UNSAFE_EVAL__: {
9 eval: (code: string, id: string) => Function;
10 };
11 __DISTILLED_INVOKE_MODULE__: Fetcher;
12 __DISTILLED_MODULE_FALLBACK__: Fetcher;
13 [key: string]: unknown;
14 }
15
16 export function stripInternalEnv(env: Env) {
17 const {
18 __DISTILLED_MODULE_RUNNER__,
19 __DISTILLED_UNSAFE_EVAL__,
20 __DISTILLED_INVOKE_MODULE__,
21 __DISTILLED_MODULE_FALLBACK__,
22 ...userEnv
23 } = env;
24 return userEnv;
25 }
26
27 export function getEntryEnvironment(): EntryEnvironment {
28 return (globalThis as Record<symbol, EntryEnvironment>)[Symbol.for(ENTRY_ENVIRONMENT_KEY)]!;
29 }