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

Method exec

packages/computer/src/workspace.ts:1020–1040  ·  view source on GitHub ↗
(command: string, options: { backend?: string } & Record<string, unknown> = {})

Source from the content-addressed store, hash-verified

1018 }
1019
1020 async exec(command: string, options: { backend?: string } & Record<string, unknown> = {}) {
1021 const id = this.#resolveId(options.backend) || this.#defaultId;
1022 // Capture the BackendHandle here, at dispatch time. A late
1023 // failure from this command's stream must invalidate THIS
1024 // handle, not whatever the cache holds when the rejection
1025 // eventually fires; a concurrent reconnect may have already
1026 // swapped in a newer handle that we must not clobber.
1027 const { shell, handle: dispatchHandle } = await this.#shellFor(id);
1028 const { backend: _backend, ...rest } = options;
1029 let execHandle: unknown;
1030 try {
1031 execHandle = await (shell.exec as unknown as (c: string, o: typeof rest) => Promise<unknown>)(
1032 command,
1033 rest,
1034 );
1035 } catch (error) {
1036 this.#onError(id, dispatchHandle, error);
1037 throw error;
1038 }
1039 return this.#wrapHandle(id, dispatchHandle, execHandle);
1040 }
1041
1042 async get(id: string, options: { backend?: string } & Record<string, unknown> = {}) {
1043 const backendId = this.#resolveId(options.backend) || this.#defaultId;

Callers

nothing calls this directly

Calls 2

#wrapHandleMethod · 0.95
#shellForMethod · 0.80

Tested by

no test coverage detected