beachside 0.0.0-stage → 0.8.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.
- package/LICENSE +201 -0
- package/README.md +120 -2
- package/dist/adapter-direct.d.ts +299 -0
- package/dist/adapter-reference.d.ts +268 -0
- package/dist/bound.d.ts +1 -0
- package/dist/connection-wait.d.ts +10 -0
- package/dist/directory-read.d.ts +8 -0
- package/dist/file-read.d.ts +4 -0
- package/dist/file-transfer.d.ts +29 -0
- package/dist/filesystem-extensions.d.ts +21 -0
- package/dist/freeze-reference.d.ts +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +5122 -0
- package/dist/observability.d.ts +64 -0
- package/dist/process-output.d.ts +33 -0
- package/dist/processes.d.ts +212 -0
- package/dist/recovery-diagnostics.d.ts +10 -0
- package/dist/resource.d.ts +175 -0
- package/dist/resources.d.ts +361 -0
- package/dist/scoped-sandbox.d.ts +30 -0
- package/package.json +44 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SpanKind, type Context, type SpanContext, type TracerProvider } from "@opentelemetry/api";
|
|
2
|
+
export interface ObservabilityOptions {
|
|
3
|
+
/** Omission uses the application provider. Beachside never owns provider shutdown. */
|
|
4
|
+
tracing?: false | {
|
|
5
|
+
tracerProvider?: TracerProvider;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface DiagnosticContext {
|
|
9
|
+
errorCode?: string;
|
|
10
|
+
effect?: "none" | "possible" | "applied" | "partial" | "unknown";
|
|
11
|
+
operationId?: string;
|
|
12
|
+
submissionId?: string;
|
|
13
|
+
operationState?: "pending" | "completed" | "rejected" | "failed" | "unknown";
|
|
14
|
+
recoveryAvailable: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function noteRetainedResources<T extends object>(value: T, count: number): void;
|
|
17
|
+
export declare function noteOperation<T extends object>(value: T, state: NonNullable<DiagnosticContext["operationState"]>, effect: DiagnosticContext["effect"]): void;
|
|
18
|
+
export declare function safeIdentity(value: unknown): string | undefined;
|
|
19
|
+
/** Pure correlation data; the original handle/error retains recovery authority. */
|
|
20
|
+
export declare function diagnosticContext(value: unknown): Readonly<DiagnosticContext>;
|
|
21
|
+
/** W3C version 00 only; fixed size, no tracestate or baggage. */
|
|
22
|
+
export declare function parseTraceParent(value: unknown): SpanContext | undefined;
|
|
23
|
+
export declare function activeTraceParent(): string | undefined;
|
|
24
|
+
/** Internal direct SDK instrumentation; never configures OTel globals. */
|
|
25
|
+
export declare class Telemetry {
|
|
26
|
+
private readonly mode;
|
|
27
|
+
private readonly provider;
|
|
28
|
+
private readonly owner;
|
|
29
|
+
constructor(options?: ObservabilityOptions, mode?: "direct", provider?: string);
|
|
30
|
+
private readonly options;
|
|
31
|
+
get enabled(): boolean;
|
|
32
|
+
correlate(value: unknown): void;
|
|
33
|
+
submitted(): void;
|
|
34
|
+
poll(state: "pending" | "completed" | "rejected" | "unknown"): void;
|
|
35
|
+
iterate(name: string, source: AsyncIterable<Uint8Array>, signal?: AbortSignal): AsyncIterable<Uint8Array>;
|
|
36
|
+
run<T>(name: string, work: () => Promise<T>, options?: {
|
|
37
|
+
phase?: boolean;
|
|
38
|
+
effect?: "none" | "possible" | "applied";
|
|
39
|
+
origin?: unknown;
|
|
40
|
+
parent?: Context;
|
|
41
|
+
kind?: SpanKind;
|
|
42
|
+
identity?: unknown;
|
|
43
|
+
operationType?: string;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
}): Promise<T>;
|
|
46
|
+
}
|
|
47
|
+
/** Wrap an instance method; the original receiver, arguments and results are preserved. */
|
|
48
|
+
export declare function instrument<T extends object, K extends keyof T>(target: T, key: K, telemetry: Telemetry, name: string, options?: {
|
|
49
|
+
phase?: boolean;
|
|
50
|
+
effect?: "none" | "possible" | "applied";
|
|
51
|
+
identity?: unknown;
|
|
52
|
+
origin?: string;
|
|
53
|
+
}): void;
|
|
54
|
+
/** Only explicit library delegation bypasses public tracing; user calls always get a span. */
|
|
55
|
+
export declare function internalMethod<F extends (...args: never[]) => Promise<unknown>>(method: F): F;
|
|
56
|
+
export declare function waitFor<T>(telemetry: Telemetry, operation: {
|
|
57
|
+
wait(options?: {
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
pollMs?: number;
|
|
60
|
+
}): Promise<T>;
|
|
61
|
+
}, options?: {
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
pollMs?: number;
|
|
64
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ProcessOutput, ProcessOutputBytes } from "@beachside/adapter";
|
|
2
|
+
export type ProcessLine = {
|
|
3
|
+
stream: "stdout" | "stderr";
|
|
4
|
+
text: string;
|
|
5
|
+
/** No newline has been observed for this line. */
|
|
6
|
+
partial: boolean;
|
|
7
|
+
/** The line exceeded its byte limit and its remainder was discarded. */
|
|
8
|
+
truncated: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ProcessLineOptions = {
|
|
11
|
+
maxLineBytes?: number;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
};
|
|
14
|
+
export type ProcessTailOptions = {
|
|
15
|
+
maxBytes?: number;
|
|
16
|
+
maxChunks?: number;
|
|
17
|
+
maxLines?: number;
|
|
18
|
+
maxLineBytes?: number;
|
|
19
|
+
};
|
|
20
|
+
export interface ProcessTail {
|
|
21
|
+
push(chunk: ProcessOutput | ProcessOutputBytes): void;
|
|
22
|
+
/** A bounded, independent snapshot; quiet processes return immediately. */
|
|
23
|
+
snapshot(): {
|
|
24
|
+
lines: ProcessLine[];
|
|
25
|
+
truncated: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** UTF-8 length of one code point from `for...of`; a lone surrogate encodes as U+FFFD (3 bytes). */
|
|
29
|
+
export declare function utf8Length(point: string): number;
|
|
30
|
+
/** Incremental UTF-8 lines, independently decoded per stream; oversized lines are clipped, not buffered. */
|
|
31
|
+
export declare function readProcessLines(output: AsyncIterable<ProcessOutput | ProcessOutputBytes>, options?: ProcessLineOptions): AsyncGenerator<ProcessLine>;
|
|
32
|
+
/** Keep a rolling diagnostic byte window, never a cumulative process transcript. */
|
|
33
|
+
export declare function createProcessTail(options?: ProcessTailOptions): ProcessTail;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { ResourceScope, type Json, type ProcessSignal, type TerminalDimensions, type NativeProcess, type Sandbox, type ProcessOutput, type ProcessOutputBytes, type ProcessOutputFormat, type NativeProcessStatus } from "@beachside/adapter";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { BeachsideError, type ExecOutput, type ExecInput } from "./resource.js";
|
|
4
|
+
import type { AdapterDirectClient } from "./adapter-direct.js";
|
|
5
|
+
export type { ProcessOutput, ProcessOutputBytes, ProcessOutputFormat } from "@beachside/adapter";
|
|
6
|
+
export type ProcessChunk<F extends ProcessOutputFormat> = F extends "bytes" ? ProcessOutputBytes : ProcessOutput;
|
|
7
|
+
export type StartProcessInput<F extends ProcessOutputFormat = ProcessOutputFormat> = Pick<ExecInput, "command" | "cwd" | "env" | "maxOutputBytes" | "deadlineSeconds"> & {
|
|
8
|
+
stdin?: "closed" | "pipe";
|
|
9
|
+
output?: {
|
|
10
|
+
mode: "stream";
|
|
11
|
+
format?: F;
|
|
12
|
+
};
|
|
13
|
+
} & (F extends "bytes" ? {
|
|
14
|
+
output: {
|
|
15
|
+
mode: "stream";
|
|
16
|
+
format: "bytes";
|
|
17
|
+
};
|
|
18
|
+
} : object);
|
|
19
|
+
export type { ProcessSignal, TerminalDimensions } from "@beachside/adapter";
|
|
20
|
+
declare const Reference: z.ZodObject<{
|
|
21
|
+
version: z.ZodLiteral<1>;
|
|
22
|
+
provider: z.ZodString;
|
|
23
|
+
sandboxId: z.ZodString;
|
|
24
|
+
scope: z.ZodObject<{
|
|
25
|
+
authority: z.ZodObject<{
|
|
26
|
+
kind: z.ZodString;
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
partition: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
profile: z.ZodEnum<{
|
|
32
|
+
process: "process";
|
|
33
|
+
terminal: "terminal";
|
|
34
|
+
}>;
|
|
35
|
+
output: z.ZodEnum<{
|
|
36
|
+
bytes: "bytes";
|
|
37
|
+
text: "text";
|
|
38
|
+
}>;
|
|
39
|
+
stdin: z.ZodEnum<{
|
|
40
|
+
pipe: "pipe";
|
|
41
|
+
closed: "closed";
|
|
42
|
+
}>;
|
|
43
|
+
expiresAt: z.ZodISODateTime;
|
|
44
|
+
native: z.ZodCustom<Json, Json>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export type ProcessReference<F extends ProcessOutputFormat = ProcessOutputFormat> = Omit<z.infer<typeof Reference>, "output"> & {
|
|
47
|
+
output: F;
|
|
48
|
+
};
|
|
49
|
+
export type StartTerminalInput = Pick<ExecInput, "command" | "cwd" | "env"> & TerminalDimensions;
|
|
50
|
+
export interface TerminalHandle extends Omit<ProcessHandle<"bytes">, "output" | "closeStdin"> {
|
|
51
|
+
output(options?: {
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
}): AsyncIterable<Uint8Array>;
|
|
54
|
+
resize(dimensions: TerminalDimensions, options?: {
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export type ProcessTermination = {
|
|
59
|
+
status: "requested" | "not-found" | "exited";
|
|
60
|
+
};
|
|
61
|
+
export type ProcessExit = {
|
|
62
|
+
exitCode: number;
|
|
63
|
+
outputComplete: boolean;
|
|
64
|
+
};
|
|
65
|
+
export type ProcessStatus = Omit<NativeProcessStatus, "exit"> & {
|
|
66
|
+
exit?: ProcessExit;
|
|
67
|
+
};
|
|
68
|
+
/** Local context only; these fields cannot reopen a command. */
|
|
69
|
+
export type ProcessFailure = BeachsideError & {
|
|
70
|
+
provider: string;
|
|
71
|
+
sandboxId: string;
|
|
72
|
+
confirmedExit?: ProcessExit;
|
|
73
|
+
};
|
|
74
|
+
export interface ProcessHandle<F extends ProcessOutputFormat = "text"> {
|
|
75
|
+
readonly provider: string;
|
|
76
|
+
readonly outputGap: boolean;
|
|
77
|
+
reference(): ProcessReference<F>;
|
|
78
|
+
signal(signal: ProcessSignal, options?: {
|
|
79
|
+
signal?: AbortSignal;
|
|
80
|
+
}): Promise<ProcessTermination>;
|
|
81
|
+
disconnect(): Promise<void>;
|
|
82
|
+
/** Returning a sustained iterator releases output only; finite legacy iterators detach the handle. */
|
|
83
|
+
output(options?: {
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
}): AsyncIterable<ProcessChunk<F>>;
|
|
86
|
+
wait(options?: {
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
}): Promise<ProcessExit>;
|
|
89
|
+
write(input: string | Uint8Array, options?: {
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
closeStdin(options?: {
|
|
93
|
+
signal?: AbortSignal;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
status(options?: {
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}): Promise<ProcessStatus>;
|
|
98
|
+
terminate(options?: {
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
}): Promise<ProcessTermination>;
|
|
101
|
+
/** Dispose local IO and cancel pending local controls; never terminate the remote process. */
|
|
102
|
+
detach(): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
declare class LocalProcess<F extends ProcessOutputFormat> implements ProcessHandle<F> {
|
|
105
|
+
readonly provider: string;
|
|
106
|
+
private readonly sandboxId;
|
|
107
|
+
private readonly max;
|
|
108
|
+
private readonly clientSignal;
|
|
109
|
+
private readonly controlActive;
|
|
110
|
+
private readonly sustained;
|
|
111
|
+
private readonly piped;
|
|
112
|
+
private readonly format;
|
|
113
|
+
readonly outputGap: boolean;
|
|
114
|
+
private readonly referenceContext?;
|
|
115
|
+
private readonly supportedSignals;
|
|
116
|
+
native?: NativeProcess;
|
|
117
|
+
private queue;
|
|
118
|
+
private queuedBytes;
|
|
119
|
+
private total;
|
|
120
|
+
private used;
|
|
121
|
+
private stopped;
|
|
122
|
+
private finished;
|
|
123
|
+
private complete;
|
|
124
|
+
private exitCode?;
|
|
125
|
+
private failure?;
|
|
126
|
+
private detached;
|
|
127
|
+
private readonly local;
|
|
128
|
+
private waitFailure?;
|
|
129
|
+
private inputClosed;
|
|
130
|
+
private inputClosing;
|
|
131
|
+
private inputFailure?;
|
|
132
|
+
private pendingInputBytes;
|
|
133
|
+
private pendingInputCalls;
|
|
134
|
+
private inputTail;
|
|
135
|
+
private closePromise?;
|
|
136
|
+
private termination?;
|
|
137
|
+
private signalRequests;
|
|
138
|
+
private park?;
|
|
139
|
+
private resizeTail;
|
|
140
|
+
private pendingResizes;
|
|
141
|
+
private resizeFailure?;
|
|
142
|
+
private cleanupPreservesInput;
|
|
143
|
+
private savedReference?;
|
|
144
|
+
private listeners;
|
|
145
|
+
private removeOutputAbort?;
|
|
146
|
+
private readonly closed;
|
|
147
|
+
constructor(provider: string, sandboxId: string, max: number, clientSignal: AbortSignal, controlActive: () => boolean, sustained: boolean, piped: boolean, format: F, outputGap?: boolean, referenceContext?: {
|
|
148
|
+
scope: z.infer<typeof ResourceScope>;
|
|
149
|
+
profile: "process" | "terminal";
|
|
150
|
+
expiresAt: string;
|
|
151
|
+
} | undefined, supportedSignals?: readonly ProcessSignal[]);
|
|
152
|
+
get error(): BeachsideError | undefined;
|
|
153
|
+
private notify;
|
|
154
|
+
private evidence;
|
|
155
|
+
private rememberNativeExit;
|
|
156
|
+
fail(error: BeachsideError): void;
|
|
157
|
+
private releaseOutput;
|
|
158
|
+
onOutput: (value: ProcessOutput) => void;
|
|
159
|
+
onOutputBytes: (value: ProcessOutputBytes) => void;
|
|
160
|
+
attach(native: NativeProcess): void;
|
|
161
|
+
output(options?: {
|
|
162
|
+
signal?: AbortSignal;
|
|
163
|
+
}): AsyncIterable<ProcessChunk<F>>;
|
|
164
|
+
private changed;
|
|
165
|
+
wait(options?: {
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
}): Promise<ProcessExit>;
|
|
168
|
+
private checkInput;
|
|
169
|
+
write(input: string | Uint8Array, options?: {
|
|
170
|
+
signal?: AbortSignal;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
closeStdin(options?: {
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}): Promise<void>;
|
|
175
|
+
private enqueueInput;
|
|
176
|
+
status(options?: {
|
|
177
|
+
signal?: AbortSignal;
|
|
178
|
+
}): Promise<ProcessStatus>;
|
|
179
|
+
private terminationFailure;
|
|
180
|
+
terminate(options?: {
|
|
181
|
+
signal?: AbortSignal;
|
|
182
|
+
}): Promise<ProcessTermination>;
|
|
183
|
+
private requestTermination;
|
|
184
|
+
reference(): ProcessReference<F>;
|
|
185
|
+
signal(signal: ProcessSignal, options?: {
|
|
186
|
+
signal?: AbortSignal;
|
|
187
|
+
}): Promise<ProcessTermination>;
|
|
188
|
+
private checkControl;
|
|
189
|
+
private control;
|
|
190
|
+
resize(dimensions: TerminalDimensions, options?: {
|
|
191
|
+
signal?: AbortSignal;
|
|
192
|
+
}): Promise<void>;
|
|
193
|
+
disconnect(): Promise<void>;
|
|
194
|
+
abandonPreservingInput(): Promise<void>;
|
|
195
|
+
detach(): Promise<void>;
|
|
196
|
+
}
|
|
197
|
+
export declare function startProcess<F extends ProcessOutputFormat = "text">(client: AdapterDirectClient, sandbox: Sandbox, input: StartProcessInput<F>, options: {
|
|
198
|
+
signal?: AbortSignal;
|
|
199
|
+
}, controlActive: () => boolean, capture?: {
|
|
200
|
+
maxBytes: number;
|
|
201
|
+
}, terminal?: TerminalDimensions, reopening?: ProcessReference<F>): Promise<LocalProcess<F>>;
|
|
202
|
+
export declare function reopenProcess<F extends ProcessOutputFormat>(client: AdapterDirectClient, sandbox: Sandbox, reference: ProcessReference<F>, options: {
|
|
203
|
+
signal?: AbortSignal;
|
|
204
|
+
}, active: () => boolean): Promise<LocalProcess<F>>;
|
|
205
|
+
export declare function terminalHandle(process: LocalProcess<"bytes">): TerminalHandle;
|
|
206
|
+
export type ExecOptions = {
|
|
207
|
+
signal?: AbortSignal;
|
|
208
|
+
/** Awaited live text delivery; captured stdout/stderr remain bounded by maxOutputBytes. */
|
|
209
|
+
onOutput?: (chunk: ProcessOutput) => void | Promise<void>;
|
|
210
|
+
};
|
|
211
|
+
/** Exactly one process dispatch; callback failure cannot fall back to finite exec. */
|
|
212
|
+
export declare function callbackExec(client: AdapterDirectClient, sandbox: Sandbox, controlActive: () => boolean, input: ExecInput | readonly string[], options: ExecOptions): Promise<ExecOutput>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Json } from "@beachside/adapter";
|
|
2
|
+
/** SDK-owned access to private state; telemetry never invokes a public accessor. */
|
|
3
|
+
export declare function certifyOperationReference<T extends object>(operation: T, read: () => object): void;
|
|
4
|
+
export declare function certifiedOperationReference(value: unknown): object | undefined;
|
|
5
|
+
/** Called only after the SDK validates and seals its own reference copy. */
|
|
6
|
+
export declare function certifyRecoveryReference<T extends object>(reference: T): T;
|
|
7
|
+
/** Membership never traverses an application-provided reference or opaque token. */
|
|
8
|
+
export declare function certifiedRecoveryAvailable(reference: unknown): boolean;
|
|
9
|
+
/** The caller has validated JSON and enforced the reference's declared byte bound. */
|
|
10
|
+
export declare function freezeRecoveryToken(value: Json): void;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { OperationOutcome } from "@beachside/adapter";
|
|
2
|
+
import { SnapshotRequest, MountSpec } from "@beachside/adapter";
|
|
3
|
+
import type { AdapterDirectClient, AdapterSandbox, AdapterOperation, AdapterRecoveryReference } from "./adapter-direct.js";
|
|
4
|
+
import type { OperationKind, RetainedArtifact, Scope } from "@beachside/adapter";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import type { AdapterImage, AdapterSnapshot, AdapterVolume } from "./resources.js";
|
|
7
|
+
import { ExecCommand, type SafeError } from "@beachside/adapter/portable";
|
|
8
|
+
export type PreparedImage = {
|
|
9
|
+
kind: "prepared";
|
|
10
|
+
value: string;
|
|
11
|
+
provider: string;
|
|
12
|
+
scope: Scope;
|
|
13
|
+
};
|
|
14
|
+
export type ImageBuildResult = {
|
|
15
|
+
prepared: PreparedImage;
|
|
16
|
+
retainedResources: RetainedArtifact[];
|
|
17
|
+
/**
|
|
18
|
+
* The built image as a scoped reference for `images.get()` and `images.delete()`. Ownership is
|
|
19
|
+
* `verified-created` only when the adapter proved this build created it; otherwise `unknown`.
|
|
20
|
+
*/
|
|
21
|
+
reference: import("@beachside/adapter").ResourceReference<"image">;
|
|
22
|
+
};
|
|
23
|
+
export type { OciImage, ImageInput } from "@beachside/adapter";
|
|
24
|
+
import type { ImageInput, OciImage } from "@beachside/adapter";
|
|
25
|
+
export declare const Image: {
|
|
26
|
+
prepared(value: string | PreparedImage): ImageInput;
|
|
27
|
+
oci(value: string): OciImage;
|
|
28
|
+
};
|
|
29
|
+
/** Portable outbound network policy; adapters map it to native settings. */
|
|
30
|
+
export type NetworkPolicy = "blocked" | "internet" | (string & {});
|
|
31
|
+
export type CreateInput = {
|
|
32
|
+
environment?: ImageInput;
|
|
33
|
+
requirements?: {
|
|
34
|
+
snapshot: SnapshotRequest;
|
|
35
|
+
};
|
|
36
|
+
mounts?: MountSpec[];
|
|
37
|
+
/** Outbound network policy; omitted uses the adapter setup default. */
|
|
38
|
+
network?: NetworkPolicy;
|
|
39
|
+
/** @deprecated Use `network`. */
|
|
40
|
+
networkPolicy?: string;
|
|
41
|
+
region?: string;
|
|
42
|
+
labels?: Record<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Environment variables for every command, process and terminal in the sandbox,
|
|
45
|
+
* including after reopen. A per-call `env` entry overrides the same key. Values are
|
|
46
|
+
* never saved in recovery references or included in errors and telemetry.
|
|
47
|
+
*/
|
|
48
|
+
env?: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Lifetime for this sandbox only, replacing the adapter setup's `lifecycle.lifetimeSeconds`.
|
|
51
|
+
* An adapter that cannot apply it exactly (or by rounding up) rejects before any effect.
|
|
52
|
+
*/
|
|
53
|
+
lifecycle?: {
|
|
54
|
+
lifetimeSeconds?: number;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type ExecInput = {
|
|
58
|
+
command: ExecCommand;
|
|
59
|
+
cwd?: string;
|
|
60
|
+
env?: Record<string, string>;
|
|
61
|
+
/** Finite stdin bytes; strings encode as UTF-8 and supplied input ends with guest EOF. */
|
|
62
|
+
stdin?: string | Uint8Array;
|
|
63
|
+
/** Provider-specific execution/observation limit (default 300), not a total wait budget. Use the call signal to bound local waiting. */
|
|
64
|
+
deadlineSeconds?: number;
|
|
65
|
+
maxOutputBytes?: number;
|
|
66
|
+
};
|
|
67
|
+
export type ValidatedExecInput = Required<Pick<ExecInput, "command" | "deadlineSeconds" | "maxOutputBytes">> & Omit<ExecInput, "stdin"> & {
|
|
68
|
+
stdin?: Uint8Array;
|
|
69
|
+
};
|
|
70
|
+
export type OutputPreview = {
|
|
71
|
+
text: string;
|
|
72
|
+
shortened: boolean;
|
|
73
|
+
};
|
|
74
|
+
export type ExecOutput = {
|
|
75
|
+
exitCode: number | null;
|
|
76
|
+
stdout: Uint8Array;
|
|
77
|
+
stderr: Uint8Array;
|
|
78
|
+
truncated: boolean;
|
|
79
|
+
stdoutText(maxBytes?: number): string;
|
|
80
|
+
stdoutText(options: {
|
|
81
|
+
full: true;
|
|
82
|
+
}): string;
|
|
83
|
+
stderrText(maxBytes?: number): string;
|
|
84
|
+
stderrText(options: {
|
|
85
|
+
full: true;
|
|
86
|
+
}): string;
|
|
87
|
+
stdoutPreview(options?: {
|
|
88
|
+
maxBytes?: number;
|
|
89
|
+
}): OutputPreview;
|
|
90
|
+
stderrPreview(options?: {
|
|
91
|
+
maxBytes?: number;
|
|
92
|
+
}): OutputPreview;
|
|
93
|
+
};
|
|
94
|
+
export type RecoveryReference = AdapterRecoveryReference;
|
|
95
|
+
/** A submitted operation; a concrete kind retains advanced continuation and narrowing. */
|
|
96
|
+
export type OperationHandle<T, K extends OperationKind | undefined = undefined> = [K] extends [
|
|
97
|
+
OperationKind
|
|
98
|
+
] ? AdapterOperation<T, Extract<K, OperationKind>> : {
|
|
99
|
+
readonly durability: "process";
|
|
100
|
+
readonly reference: RecoveryReference;
|
|
101
|
+
observe(): Promise<T | null>;
|
|
102
|
+
wait(options?: {
|
|
103
|
+
signal?: AbortSignal;
|
|
104
|
+
pollMs?: number;
|
|
105
|
+
}): Promise<T>;
|
|
106
|
+
};
|
|
107
|
+
/** @deprecated Use BeachsideClient for the complete SDK connection surface. */
|
|
108
|
+
export type DirectBeachsideClient = Pick<AdapterDirectClient, "provider" | "capabilities" | "images" | "sandboxes" | "snapshots" | "volumes" | "operations" | "recover" | "close">;
|
|
109
|
+
/** @deprecated Use SandboxHandle. This structural compatibility view remains available. */
|
|
110
|
+
export type DirectSandboxHandle = Pick<AdapterSandbox, keyof AdapterSandbox>;
|
|
111
|
+
/** Public sandbox handle. */
|
|
112
|
+
export type SandboxHandle<Advanced extends boolean = false> = Advanced extends true ? AdapterSandbox : DirectSandboxHandle;
|
|
113
|
+
/** Public SDK connection. */
|
|
114
|
+
export type BeachsideClient<Advanced extends boolean = false> = Advanced extends true ? AdapterDirectClient : DirectBeachsideClient;
|
|
115
|
+
/** A retained snapshot, with independent restore and deletion operations. */
|
|
116
|
+
export type SnapshotHandle = AdapterSnapshot;
|
|
117
|
+
/** A prepared image on the provider, with inspection and explicit deletion. */
|
|
118
|
+
export type ImageHandle = AdapterImage;
|
|
119
|
+
/** Retained storage, with explicit mount descriptors and deletion. */
|
|
120
|
+
export type VolumeHandle = AdapterVolume;
|
|
121
|
+
export declare class BeachsideError extends Error {
|
|
122
|
+
readonly code: string;
|
|
123
|
+
readonly effect: SafeError["effect"];
|
|
124
|
+
readonly outcome?: OperationOutcome | undefined;
|
|
125
|
+
readonly reference?: RecoveryReference | undefined;
|
|
126
|
+
constructor(code: string, message: string, effect?: SafeError["effect"], outcome?: OperationOutcome | undefined, reference?: RecoveryReference | undefined);
|
|
127
|
+
}
|
|
128
|
+
export declare class UnsupportedFeatureError extends BeachsideError {
|
|
129
|
+
readonly feature: string;
|
|
130
|
+
readonly unmetRequirements: readonly string[];
|
|
131
|
+
constructor(feature: string, unmetRequirements: readonly string[]);
|
|
132
|
+
}
|
|
133
|
+
export declare class OutcomeUnknownError<R extends RecoveryReference = RecoveryReference> extends BeachsideError {
|
|
134
|
+
readonly reference: R;
|
|
135
|
+
constructor(reference: R, message?: string, outcome?: OperationOutcome);
|
|
136
|
+
}
|
|
137
|
+
export declare class WaitAbortedError<R extends RecoveryReference = RecoveryReference> extends BeachsideError {
|
|
138
|
+
readonly reference: R;
|
|
139
|
+
readonly cause: unknown;
|
|
140
|
+
constructor(reference: R, reason: AbortSignal["reason"], outcome?: OperationOutcome);
|
|
141
|
+
}
|
|
142
|
+
export declare class NonzeroExitError extends BeachsideError {
|
|
143
|
+
readonly result: ExecOutput;
|
|
144
|
+
constructor(result: ExecOutput);
|
|
145
|
+
}
|
|
146
|
+
export declare class NoExitCodeError extends BeachsideError {
|
|
147
|
+
readonly result: ExecOutput;
|
|
148
|
+
constructor(result: ExecOutput);
|
|
149
|
+
}
|
|
150
|
+
export declare function newInvocationKey(): string;
|
|
151
|
+
export declare function outputText(bytes: Uint8Array, maxBytes?: number): string;
|
|
152
|
+
export declare function outputText(bytes: Uint8Array, options: {
|
|
153
|
+
full: true;
|
|
154
|
+
}): string;
|
|
155
|
+
export declare function validateFilePath(path: string): string;
|
|
156
|
+
export declare function execOutput(exitCode: number | null, stdout: Uint8Array, stderr: Uint8Array, truncated: boolean): ExecOutput;
|
|
157
|
+
export declare function checkExec(result: ExecOutput): ExecOutput;
|
|
158
|
+
/** Resolves `network` (or deprecated `networkPolicy`) to the policy name an adapter declares. */
|
|
159
|
+
export declare function resolveNetworkPolicy(network: string | undefined, networkPolicy: string | undefined, fallback: string, aliases?: Readonly<Record<string, string>>): string;
|
|
160
|
+
export declare function validateCreate(input: CreateInput | undefined, defaultEnvironment?: ImageInput, defaultNetworkPolicy?: string, networkPolicyAliases?: Readonly<Record<string, string>>): Omit<CreateInput, "network"> & {
|
|
161
|
+
environment: ImageInput;
|
|
162
|
+
networkPolicy: string;
|
|
163
|
+
};
|
|
164
|
+
export declare function validateExec(input: ExecInput | readonly string[], options?: {
|
|
165
|
+
allowStdin?: boolean;
|
|
166
|
+
}): ValidatedExecInput;
|
|
167
|
+
export declare function waitDelay(ms: number, signal?: AbortSignal): Promise<void>;
|
|
168
|
+
export declare function throwIfAborted(signal?: AbortSignal): void;
|
|
169
|
+
export declare function raceAbort<T>(work: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
170
|
+
/** Validate caller input only; native response validation must remain separate. */
|
|
171
|
+
export declare function validateResourceInput<S extends z.ZodType>(schema: S, value: z.input<S>, message: string): z.output<S>;
|
|
172
|
+
/** Options for local read-only sandbox observation. */
|
|
173
|
+
export type ReadOptions = {
|
|
174
|
+
signal?: AbortSignal;
|
|
175
|
+
};
|