MCPcopy Create free account
hub / github.com/cloudflare/computer / getExec

Method getExec

packages/computer/src/runtime/runtime.ts:96–141  ·  view source on GitHub ↗
(
    id: string,
    options: WorkspaceRuntimeGetOptions<E> = {},
  )

Source from the content-addressed store, hash-verified

94 options: WorkspaceRuntimeGetOptions<undefined>,
95 ): Promise<WorkspaceRuntimeExecHandle<undefined>>;
96 async getExec<E extends ExecEncoding>(
97 id: string,
98 options: WorkspaceRuntimeGetOptions<E> = {},
99 ): Promise<WorkspaceRuntimeExecHandle<E>> {
100 assertExecutionId(id);
101 const backend = this.#backend(options.backend);
102 if (this.#options.commandBackendIds.has(backend)) {
103 const shell = this.#options.shell();
104 const handle = await (
105 shell.get as unknown as (
106 id: string,
107 options: Record<string, unknown>,
108 ) => Promise<ExecHandle<E>>
109 )(id, {
110 backend,
111 encoding: options.encoding,
112 resume: options.resume,
113 });
114 const resultHandle =
115 options.resume === undefined || options.resume === "full"
116 ? undefined
117 : () =>
118 (
119 shell.get as unknown as (
120 id: string,
121 options: Record<string, unknown>,
122 ) => Promise<ExecHandle<E>>
123 )(id, {
124 backend,
125 encoding: options.encoding,
126 resume: "full",
127 });
128 return wrapCommandHandle(handle, backend, resultHandle);
129 }
130
131 const runtime = await this.#options.moduleHandle(backend);
132 const envelope = await runtime.getExec({ id, after: resumeToAfter(options.resume) });
133 return wrapModuleHandle(
134 runtime,
135 backend,
136 envelope.id,
137 envelope.events,
138 options.encoding,
139 options.resume === undefined || options.resume === "full",
140 );
141 }
142
143 async killExec(id: string, options: WorkspaceRuntimeKillOptions = {}): Promise<void> {
144 assertExecutionId(id);

Callers

nothing calls this directly

Calls 8

#backendMethod · 0.95
wrapCommandHandleFunction · 0.85
wrapModuleHandleFunction · 0.85
hasMethod · 0.80
shellMethod · 0.80
assertExecutionIdFunction · 0.70
resumeToAfterFunction · 0.70
getExecMethod · 0.65

Tested by

no test coverage detected