effect-cf 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,279 @@
1
+ import { ComputerArtifactsClient } from "./ComputerArtifacts.mjs";
2
+ import { t as DurableObjectState } from "./DurableObjectState-biHrHwrh.mjs";
3
+ import { Context, Effect, Layer, Schema, Scope, Stream } from "effect";
4
+ import { CommitView, GitClient, GitCloneOptions, GitCommitOptions, GitDiffOptions, GitFetchOptions, GitLogOptions, GitUpdateRefOptions } from "@cloudflare/computer/git";
5
+ import { ExecSyncResult, RuntimeExecOptions, RuntimeGetOptions, RuntimeKillOptions, ShellValue, SkippedEntry, ThinkWorkspaceCompatibility, WorkspaceClient, WorkspaceRuntimeResult, WorkspaceRuntimeValue as WorkspaceRuntimeValue$1 } from "@cloudflare/computer";
6
+ import { ShareOptions } from "@cloudflare/computer/assets";
7
+ //#region src/ComputerWorkspace.d.ts
8
+ type CloudflareWorkspaceFilesystem = WorkspaceClient["fs"];
9
+ type CloudflareReadFileOptions = Parameters<CloudflareWorkspaceFilesystem["readFile"]>[1];
10
+ type CloudflareReaddirOptions = Parameters<CloudflareWorkspaceFilesystem["readdir"]>[1];
11
+ type CloudflareFindOptions = Parameters<CloudflareWorkspaceFilesystem["find"]>[2];
12
+ type CloudflareGrepOptions = Parameters<CloudflareWorkspaceFilesystem["grep"]>[2];
13
+ type CloudflareRmOptions = Parameters<CloudflareWorkspaceFilesystem["rm"]>[1];
14
+ type CloudflareMkdirOptions = Parameters<CloudflareWorkspaceFilesystem["mkdir"]>[1];
15
+ type CloudflareWriteFileContent = Parameters<CloudflareWorkspaceFilesystem["writeFile"]>[1];
16
+ type CloudflareWriteFileOptions = Parameters<CloudflareWorkspaceFilesystem["writeFile"]>[2];
17
+ type CloudflareWorkspaceDirentResult = Awaited<ReturnType<CloudflareWorkspaceFilesystem["readdir"]>>[number];
18
+ type CloudflareWorkspaceStatResult = Awaited<ReturnType<CloudflareWorkspaceFilesystem["stat"]>>;
19
+ type CloudflareWorkspaceFoundEntry = Awaited<ReturnType<CloudflareWorkspaceFilesystem["find"]>>[number];
20
+ type CloudflareWorkspaceGrepMatch = Awaited<ReturnType<CloudflareWorkspaceFilesystem["grep"]>>[number];
21
+ declare const WorkspaceFsError_base: Schema.Class<WorkspaceFsError, Schema.TaggedStruct<"WorkspaceFsError", {
22
+ readonly operation: Schema.String;
23
+ readonly path: Schema.String;
24
+ readonly message: Schema.String;
25
+ readonly code: Schema.optionalKey<Schema.String>;
26
+ readonly cause: Schema.optionalKey<Schema.Defect>;
27
+ }>, import("effect/Cause").YieldableError>;
28
+ /**
29
+ * Workspace errors use `Schema.TaggedError`, unlike most local binding errors,
30
+ * because workspace operations commonly sit behind Durable Object RPC methods.
31
+ * The schema form preserves the operation-family tags across that boundary.
32
+ */
33
+ declare class WorkspaceFsError extends WorkspaceFsError_base {}
34
+ declare const WorkspaceGitError_base: Schema.Class<WorkspaceGitError, Schema.TaggedStruct<"WorkspaceGitError", {
35
+ readonly operation: Schema.String;
36
+ readonly message: Schema.String;
37
+ readonly code: Schema.optionalKey<Schema.String>;
38
+ readonly cause: Schema.optionalKey<Schema.Defect>;
39
+ }>, import("effect/Cause").YieldableError>;
40
+ /** Schema-serializable error for a workspace Git operation. */
41
+ declare class WorkspaceGitError extends WorkspaceGitError_base {}
42
+ declare const WorkspaceExecError_base: Schema.Class<WorkspaceExecError, Schema.TaggedStruct<"WorkspaceExecError", {
43
+ readonly operation: Schema.String;
44
+ readonly message: Schema.String;
45
+ readonly code: Schema.optionalKey<Schema.String>;
46
+ readonly cause: Schema.optionalKey<Schema.Defect>;
47
+ }>, import("effect/Cause").YieldableError>;
48
+ /** Schema-serializable error for a workspace runtime operation. */
49
+ declare class WorkspaceExecError extends WorkspaceExecError_base {}
50
+ declare const WorkspaceAssetsError_base: Schema.Class<WorkspaceAssetsError, Schema.TaggedStruct<"WorkspaceAssetsError", {
51
+ readonly operation: Schema.String;
52
+ readonly path: Schema.String;
53
+ readonly message: Schema.String;
54
+ readonly code: Schema.optionalKey<Schema.String>;
55
+ readonly cause: Schema.optionalKey<Schema.Defect>;
56
+ }>, import("effect/Cause").YieldableError>;
57
+ /** Schema-serializable error for a workspace Assets operation. */
58
+ declare class WorkspaceAssetsError extends WorkspaceAssetsError_base {}
59
+ type WorkspaceReadFileOptions = Omit<CloudflareReadFileOptions, "encoding">;
60
+ type ReadTextFileOptions = WorkspaceReadFileOptions;
61
+ type ListDirectoryOptions = CloudflareReaddirOptions;
62
+ type WorkspaceDirectoryEntry = CloudflareWorkspaceDirentResult;
63
+ type WorkspaceEntryStat = CloudflareWorkspaceStatResult;
64
+ type WorkspaceFindOptions = CloudflareFindOptions;
65
+ type WorkspaceFoundEntry = CloudflareWorkspaceFoundEntry;
66
+ type WorkspaceGrepOptions = CloudflareGrepOptions;
67
+ type WorkspaceGrepMatch = CloudflareWorkspaceGrepMatch;
68
+ type RemovePathOptions = CloudflareRmOptions;
69
+ type WorkspaceMkdirOptions = CloudflareMkdirOptions;
70
+ type WorkspaceWriteFileContent = CloudflareWriteFileContent;
71
+ type WorkspaceWriteFileOptions = CloudflareWriteFileOptions;
72
+ /** Explicit read mode. Text remains the default for consumer-port compatibility. */
73
+ type WorkspaceReadEncoding = "utf8" | "stream";
74
+ interface WorkspaceReadFile {
75
+ (path: string, options?: WorkspaceReadFileOptions & {
76
+ readonly encoding?: "utf8";
77
+ }): Effect.Effect<string, WorkspaceFsError>;
78
+ (path: string, options: WorkspaceReadFileOptions & {
79
+ readonly encoding: "stream";
80
+ }): Effect.Effect<ReadableStream<Uint8Array>, WorkspaceFsError>;
81
+ }
82
+ /** Complete Effect wrapper of `WorkspaceClient.fs`. */
83
+ interface ComputerWorkspaceFilesystem {
84
+ readonly readFile: WorkspaceReadFile;
85
+ readonly stat: (path: string) => Effect.Effect<WorkspaceEntryStat, WorkspaceFsError>;
86
+ readonly lstat: (path: string) => Effect.Effect<WorkspaceEntryStat, WorkspaceFsError>;
87
+ readonly exists: (path: string) => Effect.Effect<boolean, WorkspaceFsError>;
88
+ readonly readlink: (path: string) => Effect.Effect<string, WorkspaceFsError>;
89
+ readonly readdir: (path: string, options?: ListDirectoryOptions) => Effect.Effect<ReadonlyArray<WorkspaceDirectoryEntry>, WorkspaceFsError>;
90
+ readonly find: (directory: string, pattern?: string, options?: WorkspaceFindOptions) => Effect.Effect<ReadonlyArray<WorkspaceFoundEntry>, WorkspaceFsError>;
91
+ readonly ls: (prefix: string) => Effect.Effect<ReadonlyArray<string>, WorkspaceFsError>;
92
+ readonly grep: (pattern: string, path: string, options?: WorkspaceGrepOptions) => Effect.Effect<ReadonlyArray<WorkspaceGrepMatch>, WorkspaceFsError>;
93
+ readonly writeFile: (path: string, content: WorkspaceWriteFileContent, options?: WorkspaceWriteFileOptions) => Effect.Effect<void, WorkspaceFsError>;
94
+ readonly mkdir: (path: string, options?: WorkspaceMkdirOptions) => Effect.Effect<void, WorkspaceFsError>;
95
+ readonly rm: (path: string, options?: RemovePathOptions) => Effect.Effect<void, WorkspaceFsError>;
96
+ readonly chmod: (path: string, mode: number) => Effect.Effect<void, WorkspaceFsError>;
97
+ readonly symlink: (target: string, path: string) => Effect.Effect<void, WorkspaceFsError>;
98
+ }
99
+ type WorkspaceGitCloneOptions = GitCloneOptions;
100
+ type WorkspaceGitFetchOptions = GitFetchOptions;
101
+ type WorkspaceGitFetchResult = Awaited<ReturnType<GitClient["fetch"]>>;
102
+ type WorkspaceGitCheckoutOptions = Parameters<GitClient["checkout"]>[0];
103
+ type WorkspaceGitUpdateRefOptions = GitUpdateRefOptions;
104
+ type WorkspaceGitDiffOptions = GitDiffOptions;
105
+ type WorkspaceGitCommitOptions = GitCommitOptions;
106
+ interface WorkspaceGitLogOptions extends Omit<GitLogOptions, "depth"> {
107
+ /** Preferred upstream name for the history bound. */
108
+ readonly depth?: number;
109
+ /** Consumer-port compatibility alias for `depth`. */
110
+ readonly maxCount?: number;
111
+ }
112
+ type WorkspaceGitPerson = CommitView["author"] & {
113
+ /** Consumer-port compatibility alias for `timestamp`. */
114
+ readonly timestampSeconds: number;
115
+ };
116
+ interface WorkspaceGitCommit {
117
+ readonly oid: string;
118
+ readonly message: string;
119
+ readonly tree: string;
120
+ readonly parent: ReadonlyArray<string>;
121
+ /** Consumer-port compatibility alias for `parent`. */
122
+ readonly parents: ReadonlyArray<string>;
123
+ readonly author: WorkspaceGitPerson;
124
+ readonly committer: WorkspaceGitPerson;
125
+ }
126
+ type EffectGitMethod<Method> = Method extends ((...args: infer Args) => Promise<infer Success>) ? (...args: Args) => Effect.Effect<Success, WorkspaceGitError> : never;
127
+ type EffectGitClient = { readonly [Name in keyof GitClient]: EffectGitMethod<GitClient[Name]>; };
128
+ /** Complete Effect wrapper of the `@cloudflare/computer/git` client. */
129
+ type ComputerWorkspaceGit = Omit<EffectGitClient, "log" | "revParse"> & {
130
+ readonly log: (options?: WorkspaceGitLogOptions) => Effect.Effect<ReadonlyArray<WorkspaceGitCommit>, WorkspaceGitError>;
131
+ readonly revParse: {
132
+ (ref: string): Effect.Effect<string, WorkspaceGitError>;
133
+ (options: Parameters<GitClient["revParse"]>[0]): Effect.Effect<string, WorkspaceGitError>;
134
+ };
135
+ };
136
+ type WorkspaceExecSignal = NonNullable<RuntimeKillOptions["signal"]>;
137
+ type WorkspaceRuntimeValue = WorkspaceRuntimeValue$1;
138
+ type WorkspaceExecEncoding = "utf8" | "binary";
139
+ type WorkspaceExecSyncResult = ExecSyncResult;
140
+ type WorkspaceExecSkippedEntry = SkippedEntry;
141
+ type CloudflareEncoding<Encoding extends WorkspaceExecEncoding> = Encoding extends "utf8" ? "utf8" : undefined;
142
+ type WorkspaceExecChunk<Encoding extends WorkspaceExecEncoding> = Encoding extends "utf8" ? string : Uint8Array;
143
+ type WorkspaceExecOptions<Encoding extends WorkspaceExecEncoding = "utf8"> = Omit<RuntimeExecOptions, "encoding" | "timeoutMs"> & {
144
+ readonly encoding?: Encoding;
145
+ /** Upstream runtime option name. */
146
+ readonly timeoutMs?: number;
147
+ /** Consumer-port compatibility alias for `timeoutMs`. */
148
+ readonly timeoutMillis?: number;
149
+ };
150
+ type WorkspaceGetExecOptions<Encoding extends WorkspaceExecEncoding = "utf8"> = Omit<RuntimeGetOptions, "encoding"> & {
151
+ readonly encoding?: Encoding;
152
+ };
153
+ type WorkspaceExecEvent<Encoding extends WorkspaceExecEncoding = "utf8"> = ({
154
+ readonly _tag: "Stdout";
155
+ readonly id: string;
156
+ readonly sequence: number;
157
+ readonly chunk: WorkspaceExecChunk<Encoding>;
158
+ } & (Encoding extends "utf8" ? {
159
+ readonly text: string;
160
+ } : {
161
+ readonly bytes: Uint8Array;
162
+ })) | ({
163
+ readonly _tag: "Stderr";
164
+ readonly id: string;
165
+ readonly sequence: number;
166
+ readonly chunk: WorkspaceExecChunk<Encoding>;
167
+ } & (Encoding extends "utf8" ? {
168
+ readonly text: string;
169
+ } : {
170
+ readonly bytes: Uint8Array;
171
+ })) | {
172
+ readonly _tag: "Exit";
173
+ readonly id: string;
174
+ readonly sequence: number;
175
+ readonly exitCode: number;
176
+ readonly value?: WorkspaceRuntimeValue;
177
+ };
178
+ interface WorkspaceExecResult<Encoding extends WorkspaceExecEncoding = "utf8"> {
179
+ readonly status: WorkspaceRuntimeResult<CloudflareEncoding<Encoding>>["status"];
180
+ readonly exitCode: number;
181
+ readonly stdout: WorkspaceExecChunk<Encoding>;
182
+ readonly stderr: WorkspaceExecChunk<Encoding>;
183
+ readonly value?: WorkspaceRuntimeValue;
184
+ readonly pushed: number;
185
+ readonly pulled: number;
186
+ readonly skipped: ReadonlyArray<WorkspaceExecSkippedEntry>;
187
+ readonly sync: WorkspaceExecSyncResult;
188
+ }
189
+ interface WorkspaceExecRun<Encoding extends WorkspaceExecEncoding = "utf8"> {
190
+ readonly id: string;
191
+ readonly backend: string;
192
+ /**
193
+ * Live output. Like the upstream handle, `events` and `result` are mutually
194
+ * exclusive consumers of a run.
195
+ */
196
+ readonly events: Stream.Stream<WorkspaceExecEvent<Encoding>, WorkspaceExecError>;
197
+ readonly result: Effect.Effect<WorkspaceExecResult<Encoding>, WorkspaceExecError>;
198
+ readonly kill: (signal?: WorkspaceExecSignal) => Effect.Effect<void, WorkspaceExecError>;
199
+ }
200
+ interface WorkspaceExec {
201
+ (strings: TemplateStringsArray, ...values: Array<ShellValue>): Effect.Effect<WorkspaceExecRun<"utf8">, WorkspaceExecError, Scope.Scope>;
202
+ (command: string, options?: WorkspaceExecOptions<"utf8">): Effect.Effect<WorkspaceExecRun<"utf8">, WorkspaceExecError, Scope.Scope>;
203
+ (command: string, options: WorkspaceExecOptions<"binary">): Effect.Effect<WorkspaceExecRun<"binary">, WorkspaceExecError, Scope.Scope>;
204
+ }
205
+ interface WorkspaceGetExec {
206
+ (id: string, options?: WorkspaceGetExecOptions<"utf8">): Effect.Effect<WorkspaceExecRun<"utf8">, WorkspaceExecError, Scope.Scope>;
207
+ (id: string, options: WorkspaceGetExecOptions<"binary">): Effect.Effect<WorkspaceExecRun<"binary">, WorkspaceExecError, Scope.Scope>;
208
+ }
209
+ interface WorkspaceExecCollect {
210
+ (strings: TemplateStringsArray, ...values: Array<ShellValue>): Effect.Effect<WorkspaceExecResult<"utf8">, WorkspaceExecError>;
211
+ (command: string, options?: WorkspaceExecOptions<"utf8">): Effect.Effect<WorkspaceExecResult<"utf8">, WorkspaceExecError>;
212
+ (command: string, options: WorkspaceExecOptions<"binary">): Effect.Effect<WorkspaceExecResult<"binary">, WorkspaceExecError>;
213
+ }
214
+ /** Complete Effect wrapper of `WorkspaceClient.runtime`. */
215
+ interface ComputerWorkspaceRuntime {
216
+ readonly exec: WorkspaceExec;
217
+ readonly execCollect: WorkspaceExecCollect;
218
+ readonly getExec: WorkspaceGetExec;
219
+ readonly killExec: (id: string, options?: RuntimeKillOptions) => Effect.Effect<void, WorkspaceExecError>;
220
+ readonly disposeExec: (id: string, options?: {
221
+ readonly backend?: string;
222
+ }) => Effect.Effect<void, WorkspaceExecError>;
223
+ }
224
+ /** Effect wrapper over a configured local `Workspace.assets` client. */
225
+ interface ComputerWorkspaceAssets {
226
+ readonly share: (path: string, options: ShareOptions) => Effect.Effect<string, WorkspaceAssetsError>;
227
+ }
228
+ type EffectThinkMethod<Method> = Method extends ((...args: infer Args) => Promise<infer Success>) ? (...args: Args) => Effect.Effect<Success, WorkspaceFsError> : never;
229
+ /** Effect wrapper of the optional Think compatibility surface. */
230
+ type ComputerWorkspaceThink = { readonly [Name in keyof ThinkWorkspaceCompatibility]: EffectThinkMethod<ThinkWorkspaceCompatibility[Name]>; };
231
+ /** Effect service over every client surface exposed by Cloudflare Computer. */
232
+ interface ComputerWorkspaceShape {
233
+ readonly fs: ComputerWorkspaceFilesystem;
234
+ readonly git: ComputerWorkspaceGit;
235
+ readonly runtime: ComputerWorkspaceRuntime;
236
+ readonly artifacts: ComputerArtifactsClient;
237
+ readonly assets: ComputerWorkspaceAssets | undefined;
238
+ readonly think: ComputerWorkspaceThink | undefined;
239
+ /** Flat filesystem aliases retained for mechanical consumer migration. */
240
+ readonly readFile: WorkspaceReadFile;
241
+ readonly stat: ComputerWorkspaceFilesystem["stat"];
242
+ readonly lstat: ComputerWorkspaceFilesystem["lstat"];
243
+ readonly exists: ComputerWorkspaceFilesystem["exists"];
244
+ readonly readlink: ComputerWorkspaceFilesystem["readlink"];
245
+ readonly readdir: ComputerWorkspaceFilesystem["readdir"];
246
+ readonly listDirectory: ComputerWorkspaceFilesystem["readdir"];
247
+ readonly find: ComputerWorkspaceFilesystem["find"];
248
+ readonly ls: ComputerWorkspaceFilesystem["ls"];
249
+ readonly grep: ComputerWorkspaceFilesystem["grep"];
250
+ readonly writeFile: ComputerWorkspaceFilesystem["writeFile"];
251
+ readonly mkdir: ComputerWorkspaceFilesystem["mkdir"];
252
+ readonly rm: ComputerWorkspaceFilesystem["rm"];
253
+ readonly removePath: ComputerWorkspaceFilesystem["rm"];
254
+ readonly chmod: ComputerWorkspaceFilesystem["chmod"];
255
+ readonly symlink: ComputerWorkspaceFilesystem["symlink"];
256
+ /** Flat runtime aliases retained for mechanical consumer migration. */
257
+ readonly exec: WorkspaceExec;
258
+ readonly execCollect: WorkspaceExecCollect;
259
+ readonly getExec: WorkspaceGetExec;
260
+ readonly killExec: ComputerWorkspaceRuntime["killExec"];
261
+ readonly disposeExec: ComputerWorkspaceRuntime["disposeExec"];
262
+ }
263
+ /**
264
+ * Wraps a client whose lifetime is owned by the caller. Prefer
265
+ * {@link ComputerWorkspace.layer} in Durable Objects so the parent client and
266
+ * every runtime handle are disposed by Effect `Scope`.
267
+ */
268
+ declare const fromWorkspaceClient: (client: WorkspaceClient) => ComputerWorkspaceShape;
269
+ declare const ComputerWorkspace_base: Context.ServiceClass<ComputerWorkspace, "effect-cf/ComputerWorkspace", ComputerWorkspaceShape>;
270
+ /** Effect service for the workspace owned by the enclosing Durable Object. */
271
+ declare class ComputerWorkspace extends ComputerWorkspace_base {
272
+ /**
273
+ * Acquires the single workspace registered by `withComputerWorkspace` and
274
+ * releases its RPC client when the layer scope closes.
275
+ */
276
+ static readonly layer: Layer.Layer<ComputerWorkspace, never, DurableObjectState>;
277
+ }
278
+ //#endregion
279
+ export { ComputerWorkspace, ComputerWorkspaceAssets, ComputerWorkspaceFilesystem, ComputerWorkspaceGit, ComputerWorkspaceRuntime, ComputerWorkspaceShape, ComputerWorkspaceThink, ListDirectoryOptions, ReadTextFileOptions, RemovePathOptions, WorkspaceAssetsError, WorkspaceDirectoryEntry, WorkspaceEntryStat, WorkspaceExec, WorkspaceExecChunk, WorkspaceExecCollect, WorkspaceExecEncoding, WorkspaceExecError, WorkspaceExecEvent, WorkspaceExecOptions, WorkspaceExecResult, WorkspaceExecRun, WorkspaceExecSignal, WorkspaceExecSkippedEntry, WorkspaceExecSyncResult, WorkspaceFindOptions, WorkspaceFoundEntry, WorkspaceFsError, WorkspaceGetExec, WorkspaceGetExecOptions, WorkspaceGitCheckoutOptions, WorkspaceGitCloneOptions, WorkspaceGitCommit, WorkspaceGitCommitOptions, WorkspaceGitDiffOptions, WorkspaceGitError, WorkspaceGitFetchOptions, WorkspaceGitFetchResult, WorkspaceGitLogOptions, WorkspaceGitPerson, WorkspaceGitUpdateRefOptions, WorkspaceGrepMatch, WorkspaceGrepOptions, WorkspaceMkdirOptions, WorkspaceReadEncoding, WorkspaceReadFile, WorkspaceReadFileOptions, WorkspaceRuntimeValue, WorkspaceWriteFileContent, WorkspaceWriteFileOptions, fromWorkspaceClient };