beachside 0.0.0 → 0.9.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,268 @@
1
+ import { z } from "zod";
2
+ export declare const CaptureExpectation: z.ZodObject<{
3
+ profile: z.ZodObject<{
4
+ id: z.ZodString;
5
+ preserve: z.ZodEnum<{
6
+ filesystem: "filesystem";
7
+ "filesystem+memory": "filesystem+memory";
8
+ }>;
9
+ sourceStates: z.ZodArray<z.ZodEnum<{
10
+ unknown: "unknown";
11
+ creating: "creating";
12
+ running: "running";
13
+ stopped: "stopped";
14
+ suspended: "suspended";
15
+ restoring: "restoring";
16
+ destroying: "destroying";
17
+ destroyed: "destroyed";
18
+ }>>;
19
+ interruption: z.ZodEnum<{
20
+ none: "none";
21
+ stop: "stop";
22
+ pause: "pause";
23
+ terminate: "terminate";
24
+ }>;
25
+ sourceAfter: z.ZodEnum<{
26
+ stopped: "stopped";
27
+ destroyed: "destroyed";
28
+ unchanged: "unchanged";
29
+ }>;
30
+ connections: z.ZodEnum<{
31
+ unknown: "unknown";
32
+ preserved: "preserved";
33
+ dropped: "dropped";
34
+ }>;
35
+ consistency: z.ZodEnum<{
36
+ unknown: "unknown";
37
+ "crash-consistent": "crash-consistent";
38
+ "caller-quiesced": "caller-quiesced";
39
+ }>;
40
+ restoreExecution: z.ZodEnum<{
41
+ resume: "resume";
42
+ fresh: "fresh";
43
+ }>;
44
+ mountHandling: z.ZodEnum<{
45
+ none: "none";
46
+ unknown: "unknown";
47
+ excluded: "excluded";
48
+ }>;
49
+ minimumRetentionSeconds: z.ZodOptional<z.ZodNumber>;
50
+ }, z.core.$strict>;
51
+ sourceState: z.ZodEnum<{
52
+ unknown: "unknown";
53
+ creating: "creating";
54
+ running: "running";
55
+ stopped: "stopped";
56
+ suspended: "suspended";
57
+ restoring: "restoring";
58
+ destroying: "destroying";
59
+ destroyed: "destroyed";
60
+ }>;
61
+ }, z.core.$strict>;
62
+ export declare const ReferenceSchema: z.ZodObject<{
63
+ version: z.ZodLiteral<2>;
64
+ mode: z.ZodLiteral<"direct">;
65
+ provider: z.ZodString;
66
+ kind: z.ZodEnum<{
67
+ create: "create";
68
+ destroy: "destroy";
69
+ exec: "exec";
70
+ file_write: "file_write";
71
+ file_mkdir: "file_mkdir";
72
+ file_remove: "file_remove";
73
+ image_build: "image_build";
74
+ image_delete: "image_delete";
75
+ sandbox_suspend: "sandbox_suspend";
76
+ sandbox_resume: "sandbox_resume";
77
+ sandbox_renew: "sandbox_renew";
78
+ snapshot_capture: "snapshot_capture";
79
+ snapshot_restore: "snapshot_restore";
80
+ snapshot_delete: "snapshot_delete";
81
+ volume_create: "volume_create";
82
+ volume_delete: "volume_delete";
83
+ }>;
84
+ scope: z.ZodObject<{
85
+ authority: z.ZodObject<{
86
+ kind: z.ZodString;
87
+ id: z.ZodString;
88
+ }, z.core.$strict>;
89
+ partition: z.ZodRecord<z.ZodString, z.ZodString>;
90
+ }, z.core.$strict>;
91
+ operationId: z.ZodString;
92
+ submissionId: z.ZodString;
93
+ invocationKey: z.ZodString;
94
+ sandboxId: z.ZodOptional<z.ZodString>;
95
+ sandboxReference: z.ZodOptional<z.ZodObject<{
96
+ version: z.ZodLiteral<1>;
97
+ provider: z.ZodString;
98
+ scope: z.ZodObject<{
99
+ authority: z.ZodObject<{
100
+ kind: z.ZodString;
101
+ id: z.ZodString;
102
+ }, z.core.$strict>;
103
+ partition: z.ZodRecord<z.ZodString, z.ZodString>;
104
+ }, z.core.$strict>;
105
+ nativeId: z.ZodString;
106
+ generation: z.ZodOptional<z.ZodString>;
107
+ ownership: z.ZodEnum<{
108
+ unknown: "unknown";
109
+ borrowed: "borrowed";
110
+ "verified-created": "verified-created";
111
+ }>;
112
+ history: z.ZodOptional<z.ZodJSONSchema>;
113
+ receipt: z.ZodOptional<z.ZodString>;
114
+ kind: z.ZodLiteral<"sandbox">;
115
+ }, z.core.$strict>>;
116
+ lifecycle: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
117
+ action: z.ZodLiteral<"suspend">;
118
+ preserve: z.ZodEnum<{
119
+ filesystem: "filesystem";
120
+ "filesystem+memory": "filesystem+memory";
121
+ }>;
122
+ }, z.core.$strict>, z.ZodObject<{
123
+ action: z.ZodLiteral<"resume">;
124
+ forSeconds: z.ZodOptional<z.ZodNumber>;
125
+ }, z.core.$strict>], "action">>;
126
+ renewal: z.ZodOptional<z.ZodObject<{
127
+ forSeconds: z.ZodNumber;
128
+ }, z.core.$strict>>;
129
+ capture: z.ZodOptional<z.ZodObject<{
130
+ profile: z.ZodObject<{
131
+ id: z.ZodString;
132
+ preserve: z.ZodEnum<{
133
+ filesystem: "filesystem";
134
+ "filesystem+memory": "filesystem+memory";
135
+ }>;
136
+ sourceStates: z.ZodArray<z.ZodEnum<{
137
+ unknown: "unknown";
138
+ creating: "creating";
139
+ running: "running";
140
+ stopped: "stopped";
141
+ suspended: "suspended";
142
+ restoring: "restoring";
143
+ destroying: "destroying";
144
+ destroyed: "destroyed";
145
+ }>>;
146
+ interruption: z.ZodEnum<{
147
+ none: "none";
148
+ stop: "stop";
149
+ pause: "pause";
150
+ terminate: "terminate";
151
+ }>;
152
+ sourceAfter: z.ZodEnum<{
153
+ stopped: "stopped";
154
+ destroyed: "destroyed";
155
+ unchanged: "unchanged";
156
+ }>;
157
+ connections: z.ZodEnum<{
158
+ unknown: "unknown";
159
+ preserved: "preserved";
160
+ dropped: "dropped";
161
+ }>;
162
+ consistency: z.ZodEnum<{
163
+ unknown: "unknown";
164
+ "crash-consistent": "crash-consistent";
165
+ "caller-quiesced": "caller-quiesced";
166
+ }>;
167
+ restoreExecution: z.ZodEnum<{
168
+ resume: "resume";
169
+ fresh: "fresh";
170
+ }>;
171
+ mountHandling: z.ZodEnum<{
172
+ none: "none";
173
+ unknown: "unknown";
174
+ excluded: "excluded";
175
+ }>;
176
+ minimumRetentionSeconds: z.ZodOptional<z.ZodNumber>;
177
+ }, z.core.$strict>;
178
+ sourceState: z.ZodEnum<{
179
+ unknown: "unknown";
180
+ creating: "creating";
181
+ running: "running";
182
+ stopped: "stopped";
183
+ suspended: "suspended";
184
+ restoring: "restoring";
185
+ destroying: "destroying";
186
+ destroyed: "destroyed";
187
+ }>;
188
+ }, z.core.$strict>>;
189
+ resource: z.ZodOptional<z.ZodObject<{
190
+ version: z.ZodLiteral<1>;
191
+ kind: z.ZodEnum<{
192
+ sandbox: "sandbox";
193
+ image: "image";
194
+ snapshot: "snapshot";
195
+ volume: "volume";
196
+ "volume-version": "volume-version";
197
+ mount: "mount";
198
+ session: "session";
199
+ }>;
200
+ provider: z.ZodString;
201
+ scope: z.ZodObject<{
202
+ authority: z.ZodObject<{
203
+ kind: z.ZodString;
204
+ id: z.ZodString;
205
+ }, z.core.$strict>;
206
+ partition: z.ZodRecord<z.ZodString, z.ZodString>;
207
+ }, z.core.$strict>;
208
+ nativeId: z.ZodString;
209
+ generation: z.ZodOptional<z.ZodString>;
210
+ ownership: z.ZodEnum<{
211
+ unknown: "unknown";
212
+ borrowed: "borrowed";
213
+ "verified-created": "verified-created";
214
+ }>;
215
+ history: z.ZodOptional<z.ZodJSONSchema>;
216
+ receipt: z.ZodOptional<z.ZodString>;
217
+ }, z.core.$strict>>;
218
+ mounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
219
+ volume: z.ZodObject<{
220
+ version: z.ZodLiteral<1>;
221
+ kind: z.ZodEnum<{
222
+ sandbox: "sandbox";
223
+ image: "image";
224
+ snapshot: "snapshot";
225
+ volume: "volume";
226
+ "volume-version": "volume-version";
227
+ mount: "mount";
228
+ session: "session";
229
+ }>;
230
+ provider: z.ZodString;
231
+ scope: z.ZodObject<{
232
+ authority: z.ZodObject<{
233
+ kind: z.ZodString;
234
+ id: z.ZodString;
235
+ }, z.core.$strict>;
236
+ partition: z.ZodRecord<z.ZodString, z.ZodString>;
237
+ }, z.core.$strict>;
238
+ nativeId: z.ZodString;
239
+ generation: z.ZodOptional<z.ZodString>;
240
+ ownership: z.ZodEnum<{
241
+ unknown: "unknown";
242
+ borrowed: "borrowed";
243
+ "verified-created": "verified-created";
244
+ }>;
245
+ history: z.ZodOptional<z.ZodJSONSchema>;
246
+ receipt: z.ZodOptional<z.ZodString>;
247
+ }, z.core.$strict>;
248
+ path: z.ZodString;
249
+ access: z.ZodDefault<z.ZodEnum<{
250
+ "read-write": "read-write";
251
+ "read-only": "read-only";
252
+ }>>;
253
+ subpath: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strict>>>;
255
+ networkPolicy: z.ZodOptional<z.ZodString>;
256
+ fileMutation: z.ZodOptional<z.ZodObject<{
257
+ path: z.ZodString;
258
+ recursive: z.ZodBoolean;
259
+ }, z.core.$strict>>;
260
+ file: z.ZodOptional<z.ZodObject<{
261
+ path: z.ZodString;
262
+ bytes: z.ZodNumber;
263
+ }, z.core.$strict>>;
264
+ maxOutputBytes: z.ZodOptional<z.ZodNumber>;
265
+ tokenVersion: z.ZodOptional<z.ZodNumber>;
266
+ token: z.ZodOptional<z.ZodJSONSchema>;
267
+ }, z.core.$strict>;
268
+ export type AdapterRecoveryReference = z.infer<typeof ReferenceSchema>;
@@ -0,0 +1 @@
1
+ export { bindAdapter, type BoundAdapter } from "@beachside/adapter";
@@ -0,0 +1,10 @@
1
+ /** Local connection setup controls; this signal does not own a returned client. */
2
+ export type ConnectionWaitOptions = {
3
+ signal?: AbortSignal;
4
+ timeoutMs?: number;
5
+ };
6
+ export type CloseOptions = ConnectionWaitOptions;
7
+ export declare function connectionBudget(options: ConnectionWaitOptions, phase: "connect" | "close"): {
8
+ signal: AbortSignal;
9
+ dispose(): void;
10
+ };
@@ -0,0 +1,8 @@
1
+ import { type FileEntry, type ReadContext } from "@beachside/adapter";
2
+ import { type ReadOptions } from "./resource.js";
3
+ export declare function directoryResult(result: import("@beachside/adapter").DirectoryResult): import("@beachside/adapter").DirectoryResult;
4
+ export declare function directoryEntries(entries: FileEntry[]): FileEntry[];
5
+ /** One deadline bounds the complete read, including adapter dispatch. */
6
+ export declare function directoryRead<T>(read: (context: ReadContext) => Promise<T>, closed: AbortSignal, options: ReadOptions): Promise<T>;
7
+ /** Native enumeration capacity is the same output-bound failure as a local listing limit. */
8
+ export declare function directoryListingRead<T>(read: (context: ReadContext) => Promise<T>, closed: AbortSignal, options: ReadOptions): Promise<T>;
@@ -0,0 +1,4 @@
1
+ import { type ReadContext } from "@beachside/adapter";
2
+ import { type ReadOptions } from "./resource.js";
3
+ /** One local deadline covers both adapter dispatch and every streamed chunk. */
4
+ export declare function readFileBytes(read: (context: ReadContext) => Promise<Uint8Array | ReadableStream<Uint8Array>>, maxBytes: number, closed: AbortSignal, options: ReadOptions): Promise<Uint8Array>;
@@ -0,0 +1,35 @@
1
+ import { AdapterFilesystemError, type ReadContext, type FileTransferContext } from "@beachside/adapter";
2
+ import { BeachsideError } from "./resource.js";
3
+ export type TransferPolicy = {
4
+ setupTimeoutMs?: number;
5
+ inactivityTimeoutMs?: number;
6
+ overallTimeoutMs?: number;
7
+ };
8
+ export type FileReadOptions = {
9
+ signal?: AbortSignal;
10
+ maxBytes?: number;
11
+ };
12
+ export type FileStreamOptions = FileReadOptions & TransferPolicy;
13
+ export type FileWriteOptions = FileReadOptions & {
14
+ overwrite?: boolean;
15
+ };
16
+ export type FileStreamWriteOptions = FileStreamOptions & {
17
+ overwrite?: boolean;
18
+ };
19
+ export declare class FilesystemError extends BeachsideError {
20
+ readonly details: AdapterFilesystemError["details"];
21
+ constructor(code: string, message: string, details: AdapterFilesystemError["details"]);
22
+ }
23
+ export declare function filesystemError(error: unknown): Error;
24
+ export declare function byteLimit(value: number | undefined, defaultValue?: number): number | undefined;
25
+ /**
26
+ * The effective limit of one buffered adapter read or write: the caller's optional `maxBytes`
27
+ * guard, bounded by the adapter's own buffered limit. Larger files use the adapter's streams.
28
+ */
29
+ export declare function bufferedLimit(value: number | undefined, adapterLimit: number): number;
30
+ /** The error for a file larger than an adapter without file streams can move in one call. */
31
+ export declare function adapterFileLimit(adapterLimit: number, code: "CAPACITY" | "OUTPUT_CAPACITY"): BeachsideError;
32
+ export declare function streamFile(read: (ctx: ReadContext) => Promise<ReadableStream<Uint8Array>>, closed: AbortSignal, options: FileStreamOptions, defaults: TransferPolicy): AsyncIterable<Uint8Array>;
33
+ export declare function writeStream(write: (bytes: AsyncIterable<Uint8Array>, ctx: FileTransferContext) => Promise<{
34
+ bytesWritten: number;
35
+ }>, source: AsyncIterable<Uint8Array>, closed: AbortSignal, options: FileStreamOptions, defaults: TransferPolicy, retain?: FileTransferContext["retain"]): Promise<number>;
@@ -0,0 +1,21 @@
1
+ import type { DirectoryResult, FileEntry } from "@beachside/adapter";
2
+ import { type FileStreamOptions } from "./file-transfer.js";
3
+ import { type ReadOptions } from "./resource.js";
4
+ export type WalkFilesOptions = ReadOptions & {
5
+ maxDepth?: number;
6
+ maxEntries?: number;
7
+ /** Exact root-relative paths to omit, including their descendants. */
8
+ exclude?: readonly string[];
9
+ };
10
+ export type WalkFileEntry = FileEntry & {
11
+ path: string;
12
+ relativePath: string;
13
+ /** Immediate children have depth 1; the root is not emitted. */
14
+ depth: number;
15
+ };
16
+ export type ReadTextLinesOptions = FileStreamOptions & {
17
+ /** UTF-8 bytes per line, excluding LF and its preceding CR; defaults to 1 MiB. */
18
+ maxLineBytes?: number;
19
+ };
20
+ export declare function walkFiles(root: string, read: (path: string) => Promise<DirectoryResult>, check: () => void, options: WalkFilesOptions): AsyncIterable<WalkFileEntry>;
21
+ export declare function readTextLines(source: AsyncIterable<Uint8Array>, check: () => void, options: ReadTextLinesOptions): AsyncIterable<string>;
@@ -0,0 +1 @@
1
+ export declare function freezeReference<T extends object>(value: T): T;
@@ -0,0 +1,25 @@
1
+ import { connectDirect } from "./adapter-direct.js";
2
+ export type { StartProcessInput, ProcessOutput, ProcessOutputBytes, ProcessOutputFormat, ProcessChunk, ProcessExit, ProcessStatus, ProcessTermination, ProcessHandle, ProcessReference, ProcessSignal, TerminalDimensions, StartTerminalInput, TerminalHandle, ProcessFailure, ExecOptions, } from "./processes.js";
3
+ export { AdapterDirectClient, AdapterSandbox, AdapterOperation, PreparedAdapterAttempt, ADAPTER_CONTRACT_VERSION, } from "./adapter-direct.js";
4
+ export type { AdapterRecoveryReference, AdapterConnectOptions, DirectConnectOptions, ConnectOptions, CloseOptions, AdapterCapabilities, RecoveredOperation, AdvancedOperationResult, AdvancedOperationKind, AdvancedIdentity, AdvancedObservation, SandboxInfo, } from "./adapter-direct.js";
5
+ export declare const Beachside: {
6
+ connect: typeof connectDirect;
7
+ };
8
+ export { Image, outputText, BeachsideError, UnsupportedFeatureError, OutcomeUnknownError, WaitAbortedError, NonzeroExitError, NoExitCodeError, } from "./resource.js";
9
+ export type { ImageInput, PreparedImage, ImageBuildResult, CreateInput, NetworkPolicy, ExecInput, ExecStdinStream, ExecOutput, OutputPreview, DirectBeachsideClient, DirectSandboxHandle, SandboxHandle, SnapshotHandle, ImageHandle, VolumeHandle, ReadOptions, OperationHandle, RecoveryReference, BeachsideClient, } from "./resource.js";
10
+ export { ResourceReference, ResourceKind, validateResourceReference, assertResourceScope, assertResourceIdentity, SnapshotRequest, SnapshotRequirements, Preserve, } from "@beachside/adapter";
11
+ export type { Support, Capabilities, DirectCapabilities, OperationOutcome, SnapshotPlan, SnapshotProfile, SandboxState, SandboxReference, SuspendResult, ResumeResult, RenewRequest, RenewResult, Preview, Fact, Deadline, ResourceMinimums, SandboxResources, CreatePlan, } from "@beachside/adapter";
12
+ export { AdapterSnapshot, AdapterVolume, AdapterImage } from "./resources.js";
13
+ export type { SnapshotResult, WaitOptions, RestoreInput, SandboxList, SandboxListEntry, SandboxListInput, } from "./resources.js";
14
+ export { MountSpec, SnapshotInfo, ImageInfo, VolumeInfo, RestoreRequest, VolumeCreateInput, ArtifactDeletionResult, } from "@beachside/adapter";
15
+ export type { MountCapabilities, VolumeCapabilities, RestoreCapabilities, } from "@beachside/adapter";
16
+ export { diagnosticContext } from "./observability.js";
17
+ export type { ObservabilityOptions, DiagnosticContext } from "./observability.js";
18
+ export { FilesystemError } from "./file-transfer.js";
19
+ export type { FileReadOptions, FileWriteOptions, FileStreamOptions, FileStreamWriteOptions, TransferPolicy, } from "./file-transfer.js";
20
+ export type { FileEntry, DirectoryResult, FileStat } from "@beachside/adapter";
21
+ export type { WalkFilesOptions, WalkFileEntry, ReadTextLinesOptions, } from "./filesystem-extensions.js";
22
+ export { createProcessTail, readProcessLines } from "./process-output.js";
23
+ export type { ProcessTail, ProcessTailOptions, ProcessLine, ProcessLineOptions, } from "./process-output.js";
24
+ export { SandboxCleanupError } from "./scoped-sandbox.js";
25
+ export type { SandboxScopeOptions, SandboxScopeCallbackOutcome } from "./scoped-sandbox.js";