@tarkahq/sdk 0.0.0-stage → 0.3.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/NOTICE +69 -0
- package/README.md +700 -2
- package/api-source.json +38 -0
- package/dist/cjs/client.d.ts +114 -0
- package/dist/cjs/client.js +174 -0
- package/dist/cjs/errors.d.ts +27 -0
- package/dist/cjs/errors.js +78 -0
- package/dist/cjs/generated/google/api/annotations.d.ts +1 -0
- package/dist/cjs/generated/google/api/annotations.js +10 -0
- package/dist/cjs/generated/google/api/http.d.ts +395 -0
- package/dist/cjs/generated/google/api/http.js +421 -0
- package/dist/cjs/generated/google/protobuf/descriptor.d.ts +873 -0
- package/dist/cjs/generated/google/protobuf/descriptor.js +3992 -0
- package/dist/cjs/generated/google/protobuf/empty.d.ts +35 -0
- package/dist/cjs/generated/google/protobuf/empty.js +58 -0
- package/dist/cjs/generated/google/protobuf/struct.d.ts +127 -0
- package/dist/cjs/generated/google/protobuf/struct.js +529 -0
- package/dist/cjs/generated/google/protobuf/timestamp.d.ts +128 -0
- package/dist/cjs/generated/google/protobuf/timestamp.js +95 -0
- package/dist/cjs/generated/protoc-gen-openapiv2/options/annotations.d.ts +1 -0
- package/dist/cjs/generated/protoc-gen-openapiv2/options/annotations.js +10 -0
- package/dist/cjs/generated/protoc-gen-openapiv2/options/openapiv2.d.ts +983 -0
- package/dist/cjs/generated/protoc-gen-openapiv2/options/openapiv2.js +4874 -0
- package/dist/cjs/generated/tarka/access/v1/access.d.ts +322 -0
- package/dist/cjs/generated/tarka/access/v1/access.js +2979 -0
- package/dist/cjs/generated/tarka/channels/v1/channels.d.ts +370 -0
- package/dist/cjs/generated/tarka/channels/v1/channels.js +3603 -0
- package/dist/cjs/generated/tarka/gateway/v1/gateway.d.ts +804 -0
- package/dist/cjs/generated/tarka/gateway/v1/gateway.js +8081 -0
- package/dist/cjs/generated/tarka/iam/v1/iam.d.ts +1291 -0
- package/dist/cjs/generated/tarka/iam/v1/iam.js +13207 -0
- package/dist/cjs/generated/tarka/inference/v1/inference.d.ts +699 -0
- package/dist/cjs/generated/tarka/inference/v1/inference.js +7058 -0
- package/dist/cjs/generated/tarka/provisioning/v1/agent_secrets.d.ts +70 -0
- package/dist/cjs/generated/tarka/provisioning/v1/agent_secrets.js +603 -0
- package/dist/cjs/generated/tarka/provisioning/v1/billing_quote.d.ts +171 -0
- package/dist/cjs/generated/tarka/provisioning/v1/billing_quote.js +1588 -0
- package/dist/cjs/generated/tarka/provisioning/v1/job.d.ts +168 -0
- package/dist/cjs/generated/tarka/provisioning/v1/job.js +1505 -0
- package/dist/cjs/generated/tarka/provisioning/v1/provisioning.d.ts +2644 -0
- package/dist/cjs/generated/tarka/provisioning/v1/provisioning.js +19501 -0
- package/dist/cjs/generated/tarka/provisioning/v1/registry_credentials.d.ts +89 -0
- package/dist/cjs/generated/tarka/provisioning/v1/registry_credentials.js +856 -0
- package/dist/cjs/generated/tarka/provisioning/v1/sandbox.d.ts +431 -0
- package/dist/cjs/generated/tarka/provisioning/v1/sandbox.js +3203 -0
- package/dist/cjs/generated/tarka/provisioning/v1/source_builds.d.ts +291 -0
- package/dist/cjs/generated/tarka/provisioning/v1/source_builds.js +3920 -0
- package/dist/cjs/grpc.d.ts +12 -0
- package/dist/cjs/grpc.js +55 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/inference.d.ts +293 -0
- package/dist/cjs/resources/inference.js +451 -0
- package/dist/cjs/resources/provisioning.d.ts +389 -0
- package/dist/cjs/resources/provisioning.js +552 -0
- package/dist/cjs/resources/sandboxes.d.ts +360 -0
- package/dist/cjs/resources/sandboxes.js +732 -0
- package/dist/cjs/rpc-types.d.ts +36 -0
- package/dist/cjs/rpc-types.js +29 -0
- package/dist/cjs/runtime.d.ts +99 -0
- package/dist/cjs/runtime.js +473 -0
- package/dist/cjs/transport.d.ts +60 -0
- package/dist/cjs/transport.js +114 -0
- package/dist/cjs/types.d.ts +309 -0
- package/dist/cjs/types.js +2 -0
- package/dist/esm/client.d.ts +114 -0
- package/dist/esm/client.js +169 -0
- package/dist/esm/errors.d.ts +27 -0
- package/dist/esm/errors.js +71 -0
- package/dist/esm/generated/google/api/annotations.d.ts +1 -0
- package/dist/esm/generated/google/api/annotations.js +7 -0
- package/dist/esm/generated/google/api/http.d.ts +395 -0
- package/dist/esm/generated/google/api/http.js +418 -0
- package/dist/esm/generated/google/protobuf/descriptor.d.ts +873 -0
- package/dist/esm/generated/google/protobuf/descriptor.js +3977 -0
- package/dist/esm/generated/google/protobuf/empty.d.ts +35 -0
- package/dist/esm/generated/google/protobuf/empty.js +55 -0
- package/dist/esm/generated/google/protobuf/struct.d.ts +127 -0
- package/dist/esm/generated/google/protobuf/struct.js +524 -0
- package/dist/esm/generated/google/protobuf/timestamp.d.ts +128 -0
- package/dist/esm/generated/google/protobuf/timestamp.js +92 -0
- package/dist/esm/generated/protoc-gen-openapiv2/options/annotations.d.ts +1 -0
- package/dist/esm/generated/protoc-gen-openapiv2/options/annotations.js +7 -0
- package/dist/esm/generated/protoc-gen-openapiv2/options/openapiv2.d.ts +983 -0
- package/dist/esm/generated/protoc-gen-openapiv2/options/openapiv2.js +4859 -0
- package/dist/esm/generated/tarka/access/v1/access.d.ts +322 -0
- package/dist/esm/generated/tarka/access/v1/access.js +2976 -0
- package/dist/esm/generated/tarka/channels/v1/channels.d.ts +370 -0
- package/dist/esm/generated/tarka/channels/v1/channels.js +3600 -0
- package/dist/esm/generated/tarka/gateway/v1/gateway.d.ts +804 -0
- package/dist/esm/generated/tarka/gateway/v1/gateway.js +8077 -0
- package/dist/esm/generated/tarka/iam/v1/iam.d.ts +1291 -0
- package/dist/esm/generated/tarka/iam/v1/iam.js +13203 -0
- package/dist/esm/generated/tarka/inference/v1/inference.d.ts +699 -0
- package/dist/esm/generated/tarka/inference/v1/inference.js +7055 -0
- package/dist/esm/generated/tarka/provisioning/v1/agent_secrets.d.ts +70 -0
- package/dist/esm/generated/tarka/provisioning/v1/agent_secrets.js +600 -0
- package/dist/esm/generated/tarka/provisioning/v1/billing_quote.d.ts +171 -0
- package/dist/esm/generated/tarka/provisioning/v1/billing_quote.js +1585 -0
- package/dist/esm/generated/tarka/provisioning/v1/job.d.ts +168 -0
- package/dist/esm/generated/tarka/provisioning/v1/job.js +1500 -0
- package/dist/esm/generated/tarka/provisioning/v1/provisioning.d.ts +2644 -0
- package/dist/esm/generated/tarka/provisioning/v1/provisioning.js +19496 -0
- package/dist/esm/generated/tarka/provisioning/v1/registry_credentials.d.ts +89 -0
- package/dist/esm/generated/tarka/provisioning/v1/registry_credentials.js +853 -0
- package/dist/esm/generated/tarka/provisioning/v1/sandbox.d.ts +431 -0
- package/dist/esm/generated/tarka/provisioning/v1/sandbox.js +3192 -0
- package/dist/esm/generated/tarka/provisioning/v1/source_builds.d.ts +291 -0
- package/dist/esm/generated/tarka/provisioning/v1/source_builds.js +3917 -0
- package/dist/esm/grpc.d.ts +12 -0
- package/dist/esm/grpc.js +11 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/resources/inference.d.ts +293 -0
- package/dist/esm/resources/inference.js +437 -0
- package/dist/esm/resources/provisioning.d.ts +389 -0
- package/dist/esm/resources/provisioning.js +531 -0
- package/dist/esm/resources/sandboxes.d.ts +360 -0
- package/dist/esm/resources/sandboxes.js +718 -0
- package/dist/esm/rpc-types.d.ts +36 -0
- package/dist/esm/rpc-types.js +26 -0
- package/dist/esm/runtime.d.ts +99 -0
- package/dist/esm/runtime.js +466 -0
- package/dist/esm/transport.d.ts +60 -0
- package/dist/esm/transport.js +110 -0
- package/dist/esm/types.d.ts +309 -0
- package/dist/esm/types.js +1 -0
- package/package.json +155 -4
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import type { SandboxRpc } from "../rpc-types.js";
|
|
2
|
+
import type * as wire from "../generated/tarka/provisioning/v1/sandbox.js";
|
|
3
|
+
import { TarkaError } from "../errors.js";
|
|
4
|
+
import type { RequestOptions, WaitOptions, SandboxInput, TemplateInput, ExecutionInput, SandboxData, TemplateData, ExecutionData, SandboxStatus, TemplateStatus, ExecutionStatus } from "../types.js";
|
|
5
|
+
/** Identifiers and idempotency context for an interrupted operation. Request code, stdin, and manifests are kept out of this object. */
|
|
6
|
+
export interface RecoveryDetails {
|
|
7
|
+
/** The interrupted phase. A resumed `execution.run` still waits for completion; `execution.submit` only submits. */
|
|
8
|
+
operation: "sandbox.create" | "sandbox.wait" | "template.create" | "template.wait" | "execution.submit" | "execution.wait" | "execution.run";
|
|
9
|
+
/** Organization in which the operation was started. */
|
|
10
|
+
orgId: string;
|
|
11
|
+
/** Sandbox identifier when it is known. */
|
|
12
|
+
sandboxId?: string;
|
|
13
|
+
/** Template identifier when creation was acknowledged. */
|
|
14
|
+
templateId?: string;
|
|
15
|
+
/** Acknowledged execution identifier. When present, recovery only reads this execution and never submits code again. */
|
|
16
|
+
executionId?: string;
|
|
17
|
+
/** Original mutation key. Replaying an unacknowledged request requires unchanged input within the API's 24-hour deduplication window. */
|
|
18
|
+
idempotencyKey?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A transient failure with explicit recovery for the original operation.
|
|
22
|
+
*
|
|
23
|
+
* No mutation is automatically retried. `resume()` returns the same entity type as the interrupted operation.
|
|
24
|
+
* @typeParam T - The result type of the original operation.
|
|
25
|
+
*/
|
|
26
|
+
export declare class OperationError<T> extends TarkaError {
|
|
27
|
+
#private;
|
|
28
|
+
/** Frozen recovery context containing available IDs and the original idempotency key, without the request payload. */
|
|
29
|
+
readonly recovery: Readonly<RecoveryDetails>;
|
|
30
|
+
constructor(cause: unknown, recovery: RecoveryDetails, resume: (options?: WaitOptions) => Promise<T>);
|
|
31
|
+
/**
|
|
32
|
+
* Resume the original operation with a fresh timeout and cancellation scope.
|
|
33
|
+
*
|
|
34
|
+
* Known execution IDs are polled without resubmitting code. Unacknowledged mutations replay the preserved input and idempotency key; resume within the API's 24-hour deduplication window.
|
|
35
|
+
* Previous deadlines and aborted signals are discarded. Metadata and polling interval are retained unless overridden. A further transient failure carries another resumable error.
|
|
36
|
+
* @param options - New request/wait settings. Waits default to 60 seconds; submission-only operations use the client timeout unless overridden.
|
|
37
|
+
* @returns The original operation's entity type. Resuming `run()` waits for completion; resuming `execute()` only completes submission.
|
|
38
|
+
* @example
|
|
39
|
+
* if (error instanceof ExecutionOperationError) {
|
|
40
|
+
* const execution = await error.resume({ timeoutMs: 60_000 });
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
resume(options?: WaitOptions): Promise<T>;
|
|
44
|
+
}
|
|
45
|
+
/** Interrupted sandbox creation or readiness wait. `resume()` returns a Sandbox handle. */
|
|
46
|
+
export declare class SandboxOperationError extends OperationError<Sandbox> {
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
49
|
+
/** Interrupted template creation or readiness wait. `resume()` returns a SandboxTemplate handle. */
|
|
50
|
+
export declare class TemplateOperationError extends OperationError<SandboxTemplate> {
|
|
51
|
+
name: string;
|
|
52
|
+
}
|
|
53
|
+
/** Interrupted code submission, run, or execution wait. `resume()` returns an Execution handle and preserves the original operation. */
|
|
54
|
+
export declare class ExecutionOperationError extends OperationError<Execution> {
|
|
55
|
+
name: string;
|
|
56
|
+
}
|
|
57
|
+
/** A resource cannot reach the requested state. Includes its snapshot in `info`; unknown statuses use `data_loss`, other terminal states use `failed_precondition`. */
|
|
58
|
+
export declare class ResourceStateError extends TarkaError {
|
|
59
|
+
/** Kind of resource whose state prevents this operation. */
|
|
60
|
+
readonly resource: "sandbox" | "template" | "execution";
|
|
61
|
+
/** Latest snapshot, including the status and available failure details. */
|
|
62
|
+
readonly info: SandboxData | TemplateData | ExecutionData;
|
|
63
|
+
constructor(
|
|
64
|
+
/** Kind of resource whose state prevents this operation. */
|
|
65
|
+
resource: "sandbox" | "template" | "execution",
|
|
66
|
+
/** Latest snapshot, including the status and available failure details. */
|
|
67
|
+
info: SandboxData | TemplateData | ExecutionData);
|
|
68
|
+
}
|
|
69
|
+
/** A code execution with retained output. Returned by submission, retrieval, and waiting; call `refresh()` or `wait()` to update its snapshot. */
|
|
70
|
+
export declare class Execution {
|
|
71
|
+
#private;
|
|
72
|
+
/** Organization identifier retained by this handle or collection. */
|
|
73
|
+
readonly orgId: string;
|
|
74
|
+
/** Sandbox identifier retained by this execution or collection. */
|
|
75
|
+
readonly sandboxId: string;
|
|
76
|
+
/** Original mutation key on created/submitted handles; absent on handles fetched by ID or listed. */
|
|
77
|
+
readonly idempotencyKey?: string | undefined;
|
|
78
|
+
/** Stable execution identifier; use `sandbox.executions.get(id)` to reattach later. */
|
|
79
|
+
readonly id: string;
|
|
80
|
+
constructor(rpc: SandboxRpc,
|
|
81
|
+
/** Organization identifier retained by this handle or collection. */
|
|
82
|
+
orgId: string,
|
|
83
|
+
/** Sandbox identifier retained by this execution or collection. */
|
|
84
|
+
sandboxId: string, info: wire.Execution,
|
|
85
|
+
/** Original mutation key on created/submitted handles; absent on handles fetched by ID or listed. */
|
|
86
|
+
idempotencyKey?: string | undefined);
|
|
87
|
+
/** Latest fetched execution snapshot. Reading it makes no network request. */
|
|
88
|
+
get info(): Readonly<ExecutionData>;
|
|
89
|
+
/** Latest known execution status. A terminal `failed`, `timed_out`, or `cancelled` result is returned for inspection. */
|
|
90
|
+
get status(): ExecutionStatus;
|
|
91
|
+
/** Retained standard output from the latest snapshot; may be empty after server-side output retention expires. */
|
|
92
|
+
get stdout(): string;
|
|
93
|
+
/** Retained standard error from the latest snapshot; inspect alongside status and exitCode. */
|
|
94
|
+
get stderr(): string;
|
|
95
|
+
/** Process exit code from the latest snapshot. Inspect it after the execution has reached a terminal status. */
|
|
96
|
+
get exitCode(): number;
|
|
97
|
+
/** Whether the server truncated retained execution output. */
|
|
98
|
+
get outputTruncated(): boolean;
|
|
99
|
+
/** Return the latest snapshot for serialization, without making a network request or including client internals. */
|
|
100
|
+
toJSON(): ExecutionData;
|
|
101
|
+
/**
|
|
102
|
+
* Fetch the latest execution snapshot and update this handle.
|
|
103
|
+
*
|
|
104
|
+
* @returns This same handle.
|
|
105
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
106
|
+
*/
|
|
107
|
+
refresh(options?: RequestOptions): Promise<this>;
|
|
108
|
+
/**
|
|
109
|
+
* Poll this execution until it reaches a terminal status.
|
|
110
|
+
*
|
|
111
|
+
* Code failures and server execution timeouts return this handle for inspection; they are not transport errors. An already terminal handle is returned without another request.
|
|
112
|
+
* @param options - One total wait budget in `timeoutMs` (default 60,000), `pollIntervalMs` (default 1,000), cancellation, and metadata.
|
|
113
|
+
* @returns This same handle with updated output and status.
|
|
114
|
+
* @throws ExecutionOperationError on a transient failure; `resume()` polls the same execution.
|
|
115
|
+
* @throws ResourceStateError for an unknown execution status.
|
|
116
|
+
* @example
|
|
117
|
+
* const execution = await sandbox.executions.get(executionId);
|
|
118
|
+
* await execution.wait({ timeoutMs: 60_000 });
|
|
119
|
+
*/
|
|
120
|
+
wait(options?: WaitOptions): Promise<this>;
|
|
121
|
+
}
|
|
122
|
+
/** Execution submission and retrieval bound to one sandbox. Access through `sandbox.executions`. */
|
|
123
|
+
export declare class Executions {
|
|
124
|
+
#private;
|
|
125
|
+
/** Organization identifier retained by this handle or collection. */
|
|
126
|
+
readonly orgId: string;
|
|
127
|
+
/** Sandbox identifier retained by this execution or collection. */
|
|
128
|
+
readonly sandboxId: string;
|
|
129
|
+
constructor(rpc: SandboxRpc,
|
|
130
|
+
/** Organization identifier retained by this handle or collection. */
|
|
131
|
+
orgId: string,
|
|
132
|
+
/** Sandbox identifier retained by this execution or collection. */
|
|
133
|
+
sandboxId: string);
|
|
134
|
+
/**
|
|
135
|
+
* Retrieve an execution handle without waiting for completion.
|
|
136
|
+
*
|
|
137
|
+
* @param id - Execution identifier within this sandbox.
|
|
138
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
139
|
+
*/
|
|
140
|
+
get(id: string, options?: RequestOptions): Promise<Execution>;
|
|
141
|
+
/**
|
|
142
|
+
* Submit code without readiness or completion polling.
|
|
143
|
+
*
|
|
144
|
+
* @param input - Source `code`, optional stdin, server `timeoutSeconds`, and optional idempotency key. A key is generated when omitted.
|
|
145
|
+
* @returns An Execution handle; call `wait()` to await completion.
|
|
146
|
+
* @throws ExecutionOperationError on a transient failure; recovery repeats the preserved request and key within the 24-hour deduplication window.
|
|
147
|
+
* @example
|
|
148
|
+
* const execution = await sandbox.executions.create({ code: "print(1)" });
|
|
149
|
+
* await execution.wait();
|
|
150
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
151
|
+
*/
|
|
152
|
+
create(input: ExecutionInput & {
|
|
153
|
+
code: string;
|
|
154
|
+
}, options?: RequestOptions): Promise<Execution>;
|
|
155
|
+
}
|
|
156
|
+
/** An organization-bound sandbox handle. Lists, gets, and creates return this same type; local properties reflect the latest fetched snapshot. */
|
|
157
|
+
export declare class Sandbox {
|
|
158
|
+
#private;
|
|
159
|
+
/** Organization identifier retained by this handle or collection. */
|
|
160
|
+
readonly orgId: string;
|
|
161
|
+
/** Original mutation key on created/submitted handles; absent on handles fetched by ID or listed. */
|
|
162
|
+
readonly idempotencyKey?: string | undefined;
|
|
163
|
+
/** Stable sandbox identifier; save it to reattach with `org.sandboxes.get(id)`. */
|
|
164
|
+
readonly id: string;
|
|
165
|
+
/** Submit code and retrieve executions within this sandbox. */
|
|
166
|
+
readonly executions: Executions;
|
|
167
|
+
constructor(rpc: SandboxRpc,
|
|
168
|
+
/** Organization identifier retained by this handle or collection. */
|
|
169
|
+
orgId: string, info: wire.CodeSandbox,
|
|
170
|
+
/** Original mutation key on created/submitted handles; absent on handles fetched by ID or listed. */
|
|
171
|
+
idempotencyKey?: string | undefined);
|
|
172
|
+
/** Latest fetched sandbox snapshot, including lifetime, runtime, and failure details. Reading it makes no request. */
|
|
173
|
+
get info(): Readonly<SandboxData>;
|
|
174
|
+
/** Latest known lifecycle status, such as `starting`, `ready`, or `failed`. */
|
|
175
|
+
get status(): SandboxStatus;
|
|
176
|
+
/** Return the latest snapshot for serialization, without client internals or a network request. */
|
|
177
|
+
toJSON(): SandboxData;
|
|
178
|
+
/**
|
|
179
|
+
* Fetch the latest sandbox snapshot and update this handle.
|
|
180
|
+
*
|
|
181
|
+
* @returns This same handle.
|
|
182
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
183
|
+
*/
|
|
184
|
+
refresh(options?: RequestOptions): Promise<this>;
|
|
185
|
+
/**
|
|
186
|
+
* Poll while the sandbox is starting or busy, until it becomes ready.
|
|
187
|
+
*
|
|
188
|
+
* @param options - One total wait budget in `timeoutMs` (default 60,000), `pollIntervalMs` (default 1,000), cancellation, and metadata.
|
|
189
|
+
* @returns This same handle. An already ready snapshot returns immediately.
|
|
190
|
+
* @throws SandboxOperationError on a transient failure; `resume()` continues waiting on this sandbox.
|
|
191
|
+
* @throws ResourceStateError when the sandbox cannot become ready.
|
|
192
|
+
* Cancellation stops waiting; it does not delete the sandbox.
|
|
193
|
+
*/
|
|
194
|
+
waitUntilReady(options?: WaitOptions): Promise<this>;
|
|
195
|
+
/**
|
|
196
|
+
* Submit code and return an Execution handle without waiting for readiness or completion.
|
|
197
|
+
*
|
|
198
|
+
* @param code - Source interpreted by the sandbox template's runtime.
|
|
199
|
+
* @param input - Optional stdin, server execution limit in `timeoutSeconds`, and idempotency key; a key is generated when omitted.
|
|
200
|
+
* @throws ExecutionOperationError on a transient failure; `resume()` recovers submission with the original input and key.
|
|
201
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
202
|
+
*/
|
|
203
|
+
execute(code: string, input?: ExecutionInput, options?: RequestOptions): Promise<Execution>;
|
|
204
|
+
/**
|
|
205
|
+
* Wait for readiness, submit code, then wait for completion within one total budget.
|
|
206
|
+
*
|
|
207
|
+
* @param code - Source interpreted by the sandbox template's runtime.
|
|
208
|
+
* @param input - Optional stdin, server execution limit in `timeoutSeconds`, and idempotency key. Pass `undefined` when supplying only wait settings.
|
|
209
|
+
* @param options - Total client wait in `timeoutMs` (default 60,000), polling interval (default 1,000), cancellation, and metadata. This overrides the client timeout.
|
|
210
|
+
* @returns The completed Execution handle, including code failures and server timeouts; inspect `status`, `exitCode`, and `stderr`.
|
|
211
|
+
* @throws ExecutionOperationError on a transient failure. `resume()` polls a known execution or replays an unacknowledged submission with the same key.
|
|
212
|
+
* @throws ResourceStateError if readiness is impossible or the execution status is unknown.
|
|
213
|
+
* Client timeout/cancellation does not necessarily stop remotely running code. Keep the sandbox available while recovering.
|
|
214
|
+
* @example
|
|
215
|
+
* const result = await sandbox.run("print(1)", { timeoutSeconds: 30 }, { timeoutMs: 60_000 });
|
|
216
|
+
* console.log(result.status, result.stdout);
|
|
217
|
+
*/
|
|
218
|
+
run(code: string, input?: ExecutionInput, options?: WaitOptions): Promise<Execution>;
|
|
219
|
+
/**
|
|
220
|
+
* Stop and delete this sandbox, updating the local snapshot from the server response.
|
|
221
|
+
*
|
|
222
|
+
* @returns Resolves without a value after acknowledgement. Finish recovery before deleting the sandbox.
|
|
223
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
224
|
+
*/
|
|
225
|
+
delete(options?: RequestOptions): Promise<void>;
|
|
226
|
+
}
|
|
227
|
+
/** A reusable sandbox template handle with build-state polling. Obtain from `org.sandboxes.templates`. */
|
|
228
|
+
export declare class SandboxTemplate {
|
|
229
|
+
#private;
|
|
230
|
+
/** Organization identifier retained by this handle or collection. */
|
|
231
|
+
readonly orgId: string;
|
|
232
|
+
/** Original mutation key on created/submitted handles; absent on handles fetched by ID or listed. */
|
|
233
|
+
readonly idempotencyKey?: string | undefined;
|
|
234
|
+
/** Stable template identifier, accepted by sandbox creation. */
|
|
235
|
+
readonly id: string;
|
|
236
|
+
constructor(rpc: SandboxRpc,
|
|
237
|
+
/** Organization identifier retained by this handle or collection. */
|
|
238
|
+
orgId: string, info: wire.SandboxTemplate,
|
|
239
|
+
/** Original mutation key on created/submitted handles; absent on handles fetched by ID or listed. */
|
|
240
|
+
idempotencyKey?: string | undefined);
|
|
241
|
+
/** Latest fetched template snapshot, including runtime, manifest digest, and build error code. */
|
|
242
|
+
get info(): Readonly<TemplateData>;
|
|
243
|
+
/** Latest known template lifecycle status, such as `building`, `ready`, or `failed`. */
|
|
244
|
+
get status(): TemplateStatus;
|
|
245
|
+
/** Template alias from the latest snapshot; also accepted by sandbox creation. */
|
|
246
|
+
get alias(): string;
|
|
247
|
+
/** Return the latest snapshot for serialization without client internals or a network request. */
|
|
248
|
+
toJSON(): TemplateData;
|
|
249
|
+
/**
|
|
250
|
+
* Fetch the latest template snapshot and update this handle.
|
|
251
|
+
*
|
|
252
|
+
* @returns This same handle.
|
|
253
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
254
|
+
*/
|
|
255
|
+
refresh(options?: RequestOptions): Promise<this>;
|
|
256
|
+
/**
|
|
257
|
+
* Poll a pending or building template until it is ready for sandbox creation.
|
|
258
|
+
*
|
|
259
|
+
* @param options - One total wait budget in `timeoutMs` (default 60,000), `pollIntervalMs` (default 1,000), cancellation, and metadata. Builds may need a larger budget.
|
|
260
|
+
* @returns This same handle. An already ready snapshot returns immediately.
|
|
261
|
+
* @throws TemplateOperationError on a transient failure; `resume()` continues polling this template.
|
|
262
|
+
* @throws ResourceStateError when the template cannot become ready.
|
|
263
|
+
* Cancelling a wait stops polling; it does not delete the template or cancel its build.
|
|
264
|
+
*/
|
|
265
|
+
waitUntilReady(options?: WaitOptions): Promise<this>;
|
|
266
|
+
/**
|
|
267
|
+
* Request deletion of this template and update its local snapshot.
|
|
268
|
+
*
|
|
269
|
+
* @returns Resolves without a value after acknowledgement; inspect the snapshot for lifecycle state.
|
|
270
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
271
|
+
*/
|
|
272
|
+
delete(options?: RequestOptions): Promise<void>;
|
|
273
|
+
}
|
|
274
|
+
/** Organization-visible reusable templates, including platform built-ins. Access through `org.sandboxes.templates`. */
|
|
275
|
+
export declare class SandboxTemplates {
|
|
276
|
+
#private;
|
|
277
|
+
/** Organization identifier retained by this handle or collection. */
|
|
278
|
+
readonly orgId: string;
|
|
279
|
+
constructor(rpc: SandboxRpc,
|
|
280
|
+
/** Organization identifier retained by this handle or collection. */
|
|
281
|
+
orgId: string);
|
|
282
|
+
/**
|
|
283
|
+
* List visible templates as SandboxTemplate handles, including platform built-ins.
|
|
284
|
+
*
|
|
285
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
286
|
+
*/
|
|
287
|
+
list(options?: RequestOptions): Promise<SandboxTemplate[]>;
|
|
288
|
+
/**
|
|
289
|
+
* Retrieve a template handle without waiting for build completion.
|
|
290
|
+
*
|
|
291
|
+
* @param id - Organization-visible template identifier.
|
|
292
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
293
|
+
*/
|
|
294
|
+
get(id: string, options?: RequestOptions): Promise<SandboxTemplate>;
|
|
295
|
+
/**
|
|
296
|
+
* Create a dependency-pinned template and return its handle without build polling.
|
|
297
|
+
*
|
|
298
|
+
* @param input - Alias, built-in base template alias, and exactly one manifest string: `requirementsTxt`, `packageJson`, or `pyprojectToml`. An omitted idempotency key is generated.
|
|
299
|
+
* @returns A SandboxTemplate handle; call `waitUntilReady()` before using a building template.
|
|
300
|
+
* @throws TemplateOperationError on a transient failure; `resume()` preserves the manifest and idempotency key.
|
|
301
|
+
* @example
|
|
302
|
+
* const template = await org.sandboxes.templates.create({
|
|
303
|
+
* alias: "custom-python", baseTemplateAlias, requirementsTxt: "numpy==2.0.0",
|
|
304
|
+
* });
|
|
305
|
+
* await template.waitUntilReady({ timeoutMs: 300_000 });
|
|
306
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
307
|
+
*/
|
|
308
|
+
create(input: TemplateInput, options?: RequestOptions): Promise<SandboxTemplate>;
|
|
309
|
+
/**
|
|
310
|
+
* Request deletion of an organization-owned template.
|
|
311
|
+
*
|
|
312
|
+
* @param id - Template identifier.
|
|
313
|
+
* @returns Resolves without a value after acknowledgement.
|
|
314
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
315
|
+
*/
|
|
316
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
317
|
+
}
|
|
318
|
+
/** Sandbox lifecycle and templates bound to one organization. Access through `client.org(orgId).sandboxes`. */
|
|
319
|
+
export declare class OrganizationSandboxes {
|
|
320
|
+
#private;
|
|
321
|
+
/** Organization identifier retained by this handle or collection. */
|
|
322
|
+
readonly orgId: string;
|
|
323
|
+
/** Visible reusable templates and custom template creation. */
|
|
324
|
+
readonly templates: SandboxTemplates;
|
|
325
|
+
constructor(rpc: SandboxRpc,
|
|
326
|
+
/** Organization identifier retained by this handle or collection. */
|
|
327
|
+
orgId: string);
|
|
328
|
+
/**
|
|
329
|
+
* List non-deleted sandboxes, newest first, as Sandbox handles.
|
|
330
|
+
*
|
|
331
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
332
|
+
*/
|
|
333
|
+
list(options?: RequestOptions): Promise<Sandbox[]>;
|
|
334
|
+
/**
|
|
335
|
+
* Retrieve a Sandbox handle without waiting for readiness.
|
|
336
|
+
*
|
|
337
|
+
* @param id - Sandbox identifier within this organization.
|
|
338
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
339
|
+
*/
|
|
340
|
+
get(id: string, options?: RequestOptions): Promise<Sandbox>;
|
|
341
|
+
/**
|
|
342
|
+
* Start a sandbox from a ready template and return its handle.
|
|
343
|
+
*
|
|
344
|
+
* @param input - Visible template ID or alias, optional server lifetime in `timeoutSeconds`, and optional idempotency key. A key is generated when omitted.
|
|
345
|
+
* @returns A Sandbox handle without readiness polling; `run()` waits for readiness automatically.
|
|
346
|
+
* @throws SandboxOperationError on a transient failure; `resume()` repeats the original request and key within the 24-hour deduplication window.
|
|
347
|
+
* @example
|
|
348
|
+
* const sandbox = await client.org(orgId).sandboxes.create({ template, timeoutSeconds: 600 });
|
|
349
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
350
|
+
*/
|
|
351
|
+
create(input: SandboxInput, options?: RequestOptions): Promise<Sandbox>;
|
|
352
|
+
/**
|
|
353
|
+
* Stop and delete an organization sandbox.
|
|
354
|
+
*
|
|
355
|
+
* @param id - Sandbox identifier.
|
|
356
|
+
* @returns Resolves without a value after acknowledgement.
|
|
357
|
+
* @param options - Per-call timeout in milliseconds, cancellation signal, and metadata.
|
|
358
|
+
*/
|
|
359
|
+
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
360
|
+
}
|