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

Function makeClient

packages/computer/src/client.ts:330–359  ·  view source on GitHub ↗
(
  // biome-ignore lint/suspicious/noExplicitAny: underlying surface differs per path
  surface: any,
  rehydrate: (handle: unknown, metadata?: RuntimeHandleMetadata) => unknown,
  dispose: () => void,
  useThink: boolean,
)

Source from the content-addressed store, hash-verified

328}
329
330function makeClient(
331 // biome-ignore lint/suspicious/noExplicitAny: underlying surface differs per path
332 surface: any,
333 rehydrate: (handle: unknown, metadata?: RuntimeHandleMetadata) => unknown,
334 dispose: () => void,
335 useThink: boolean,
336): WorkspaceClient {
337 const runtime = makeRuntimeClient(
338 surface.runtime as UnderlyingRuntime,
339 rehydrate as RehydrateRuntimeHandle,
340 );
341 const client: WorkspaceClient = {
342 get fs() {
343 return surface.fs;
344 },
345 runtime,
346 get git() {
347 return surface.git;
348 },
349 get assets() {
350 return surface.assets;
351 },
352 get artifacts() {
353 return surface.artifacts;
354 },
355 [Symbol.dispose]: dispose,
356 };
357 if (useThink) Object.assign(client, createThinkCompatibility(client.fs));
358 return client;
359}
360
361// What `getWorkspace` accepts: a local host carrying the symbol stash
362// (the durable object `this`), or a remote stub exposing

Callers 1

getWorkspaceFunction · 0.70

Calls 2

makeRuntimeClientFunction · 0.85
createThinkCompatibilityFunction · 0.85

Tested by

no test coverage detected