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

Class Workspace

packages/computer/src/workspace.ts:205–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203) as GitClient;
204
205export class Workspace {
206 readonly #db: Database;
207 readonly #fs: WorkspaceFilesystem;
208 /**
209 * Lazily-constructed dofs provider. Built on first `provider()`
210 * call; cached so repeated callers share the same instance.
211 */
212 #provider: SQLiteWorkspaceProvider | undefined;
213 readonly #backends: WorkspaceBackend[];
214 readonly #backendsById: Map<string, WorkspaceBackend>;
215 readonly #moduleBackendsById: Map<string, WorkspaceModuleBackend>;
216 readonly #registeredBackendIds: Set<string>;
217 readonly #callableBackendIds: Set<string>;
218 readonly #defaultBackendId: string | undefined;
219 readonly #defaultCommandBackendId: string | undefined;
220 readonly #observer: WorkspaceObserver;
221 readonly #now: () => number;
222 readonly #waitUntil: ((promise: Promise<unknown>) => void) | undefined;
223 readonly #retryScheduler: SyncRetryScheduler | undefined;
224 readonly #retryInitialDelayMs: number;
225 readonly #retryMaxDelayMs: number;
226 readonly #retryMaxAttempts: number;
227 readonly #sessionId: string;
228 readonly #gitFactory: WorkspaceGitFactory | undefined;
229 readonly #defaultGitIdentity: GitIdentity | undefined;
230 readonly #useThink: boolean;
231 readonly #assets: AssetsClient | undefined;
232 readonly #artifacts: ArtifactClient;
233 // Lazily-constructed git client, cached so the dynamic
234 // imports of isomorphic-git / diff land once per Workspace.
235 #git: GitClient | undefined;
236 readonly #mounts: Map<string, Mount>;
237 readonly #mountIndex: MountIndex;
238 // Per-backend handle cache. Filled lazily on first use of each
239 // backend; a closed transport drops just that backend's entry,
240 // leaving the others warm.
241 readonly #handles = new Map<string, BackendHandle>();
242 // In-flight connect promises keyed by backend id, so concurrent
243 // callers for the same backend share one connect pass.
244 readonly #connecting = new Map<string, Promise<BackendHandle>>();
245 // Per-backend WorkspaceShell facades. Constructed alongside each
246 // handle; reused for the life of the handle.
247 readonly #shells = new Map<string, WorkspaceShell>();
248 readonly #moduleHandles = new Map<string, WorkspaceModuleBackendHandle>();
249 readonly #connectingModuleHandles = new Map<string, Promise<WorkspaceModuleBackendHandle>>();
250 #connectionGeneration = 0;
251 #runtime: WorkspaceRuntime | undefined;
252 #readyPromise: Promise<void> | undefined;
253 // Per-backend FIFOs that serialize mutating entry points (push,
254 // pull, and the shell exec bracket which goes through them) for
255 // that backend. A push to backend A does not block exec on
256 // backend B. Reads bypass the queue entirely — they hit the
257 // local store directly through Workspace.fs. Each value is a
258 // single tail-promise; each caller chains its work onto the tail
259 // and updates it. See docs/02 "Concurrent mutators".
260 readonly #mutationTails = new Map<string, Promise<unknown>>();
261
262 declare readonly readFile?: ThinkWorkspaceCompatibility["readFile"];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected