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

Class WorkspaceRuntimeBridge

packages/computer/src/runtime/bridge.ts:8–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import type { WorkspaceTrustedModule } from "./types.js";
7
8export class WorkspaceRuntimeBridge extends RpcTarget {
9 readonly #capability: WorkspaceRuntimeCapability;
10 readonly #git: GitClient | undefined;
11 readonly #artifacts: ArtifactClient | undefined;
12 readonly #trustedModules: Record<string, WorkspaceTrustedModule>;
13 readonly #allowGitNetwork: boolean;
14 readonly #allowArtifactNetwork: boolean;
15 readonly #maxPayloadBytes: number;
16 readonly #maxCallDurationMs: number;
17 readonly #maxConcurrentCalls: number;
18 readonly #maxCalls: number;
19 readonly #maxTotalRequestBytes: number;
20 readonly #maxTotalResponseBytes: number;
21 readonly #maxResultBytes: number;
22 readonly #onAttachOutput?: (readable: ReadableStream<Uint8Array>) => Promise<void>;
23 readonly #inFlight = new Set<Promise<string>>();
24 readonly #abortControllers = new Set<AbortController>();
25 #cancelled = false;
26 #callTimedOut = false;
27 #calls = 0;
28 #requestBytes = 0;
29 #responseBytes = 0;
30
31 constructor(
32 capability: WorkspaceRuntimeCapability,
33 integrations: {
34 git?: GitClient;
35 artifacts?: ArtifactClient;
36 trustedModules?: Record<string, WorkspaceTrustedModule>;
37 allowGitNetwork?: boolean;
38 allowArtifactNetwork?: boolean;
39 maxPayloadBytes?: number;
40 maxCallDurationMs?: number;
41 maxConcurrentCalls?: number;
42 maxCalls?: number;
43 maxTotalRequestBytes?: number;
44 maxTotalResponseBytes?: number;
45 maxResultBytes?: number;
46 onAttachOutput?: (readable: ReadableStream<Uint8Array>) => Promise<void>;
47 } = {},
48 ) {
49 super();
50 this.#capability = capability;
51 this.#git = integrations.git;
52 this.#artifacts = integrations.artifacts;
53 this.#trustedModules = integrations.trustedModules ?? {};
54 this.#allowGitNetwork = integrations.allowGitNetwork ?? false;
55 this.#allowArtifactNetwork = integrations.allowArtifactNetwork ?? false;
56 this.#maxPayloadBytes = integrations.maxPayloadBytes ?? 1024 * 1024;
57 this.#maxCallDurationMs = integrations.maxCallDurationMs ?? 30_000;
58 this.#maxConcurrentCalls = integrations.maxConcurrentCalls ?? 16;
59 this.#maxCalls = integrations.maxCalls ?? 256;
60 this.#maxTotalRequestBytes = integrations.maxTotalRequestBytes ?? 8 * 1024 * 1024;
61 this.#maxTotalResponseBytes = integrations.maxTotalResponseBytes ?? 8 * 1024 * 1024;
62 this.#maxResultBytes = integrations.maxResultBytes ?? 1024 * 1024;
63 this.#onAttachOutput = integrations.onAttachOutput;
64 }
65

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected