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

Function withWorkspace

packages/computer/src/with-workspace.ts:59–80  ·  view source on GitHub ↗
(
  Base: TBase,
  options: (self: InstanceType<TBase>) => WorkspaceOptions,
)

Source from the content-addressed store, hash-verified

57 ) => InstanceType<TBase> & WorkspaceStubHost & WorkspaceLocalHost);
58
59export function withWorkspace<TBase extends DOCtor>(
60 Base: TBase,
61 options: (self: InstanceType<TBase>) => WorkspaceOptions,
62): WithWorkspaceCtor<TBase> {
63 class WithWorkspace extends Base {
64 // biome-ignore lint/suspicious/noExplicitAny: mixin constructor shape requires any[]
65 constructor(...args: any[]) {
66 super(...args);
67 const self = this as unknown as InstanceType<TBase>;
68 (this as unknown as WorkspaceLocalHost)[WORKSPACE] = new Workspace(options(self));
69 }
70
71 __getWorkspaceStub(): Promise<import("./stub.js").WorkspaceStub> {
72 const ws = (this as unknown as WorkspaceLocalHost)[WORKSPACE];
73 return (async () => {
74 await ws.ready();
75 return ws.stub();
76 })();
77 }
78 }
79 return WithWorkspace as WithWorkspaceCtor<TBase>;
80}

Callers 4

ContainerExampleClass · 0.90
ContainerExampleClass · 0.90
ArtifactCreatorClass · 0.90
ContainerExampleClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected