@tensorlakeai/tensorlake 0.0.0-bootstrap.0 → 0.5.145
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/README.md +166 -2
- package/bin/function-executor.js +8 -0
- package/bin/tensorlake-create-sandbox-image.js +9 -0
- package/bin/tensorlake-deploy.cjs +8 -0
- package/bin/tensorlake-import-sandbox-image.js +9 -0
- package/bin/tensorlake-typescript-function-runner.js +8 -0
- package/dist/applications/index.cjs +4821 -0
- package/dist/applications/index.cjs.map +1 -0
- package/dist/applications/index.d.cts +130 -0
- package/dist/applications/index.d.ts +130 -0
- package/dist/applications/index.js +4782 -0
- package/dist/applications/index.js.map +1 -0
- package/dist/function-agent/main.cjs +1838 -0
- package/dist/function-agent/main.cjs.map +1 -0
- package/dist/function-agent/main.d.cts +3 -0
- package/dist/function-agent/main.d.ts +3 -0
- package/dist/function-agent/main.js +1825 -0
- package/dist/function-agent/main.js.map +1 -0
- package/dist/function-executor/main.cjs +4944 -0
- package/dist/function-executor/main.cjs.map +1 -0
- package/dist/function-executor/main.d.cts +4 -0
- package/dist/function-executor/main.d.ts +4 -0
- package/dist/function-executor/main.js +4902 -0
- package/dist/function-executor/main.js.map +1 -0
- package/dist/index.cjs +10184 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2431 -0
- package/dist/index.d.ts +2431 -0
- package/dist/index.js +10108 -0
- package/dist/index.js.map +1 -0
- package/dist/native-worker.cjs +278 -0
- package/dist/native-worker.cjs.map +1 -0
- package/dist/native-worker.d.cts +2 -0
- package/dist/native-worker.d.ts +2 -0
- package/dist/native-worker.js +276 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/remote-CNJ9TmcQ.d.cts +283 -0
- package/dist/remote-dblFxKug.d.ts +283 -0
- package/dist/sandbox-image-ChzWDeZy.d.cts +357 -0
- package/dist/sandbox-image-ChzWDeZy.d.ts +357 -0
- package/dist/sandbox-image.cjs +1992 -0
- package/dist/sandbox-image.cjs.map +1 -0
- package/dist/sandbox-image.d.cts +1 -0
- package/dist/sandbox-image.d.ts +1 -0
- package/dist/sandbox-image.js +1987 -0
- package/dist/sandbox-image.js.map +1 -0
- package/lib/libc.cjs +61 -0
- package/lib/libc.d.cts +1 -0
- package/lib/runtime.cjs +155 -0
- package/package.json +104 -4
- package/runtime/function-executor/manifest.json +59 -0
- package/runtime/function-executor/package/bin/function-executor.js +8 -0
- package/runtime/function-executor/package/dist/function-executor/main.js +4902 -0
- package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -0
- package/runtime/function-executor/package/dist/native-worker.cjs +278 -0
- package/runtime/function-executor/package/dist/native-worker.cjs.map +1 -0
- package/runtime/function-executor/package/npm-shrinkwrap.json +475 -0
- package/runtime/function-executor/package/package.json +22 -0
- package/runtime/function-executor/package/proto/README.md +18 -0
- package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/function_executor.proto +613 -0
- package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/status.proto +42 -0
- package/runtime/typescript-function-runner/manifest.json +44 -0
- package/runtime/typescript-function-runner/package/bin/tensorlake-typescript-function-runner.js +8 -0
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1825 -0
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -0
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs +278 -0
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs.map +1 -0
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +586 -0
- package/runtime/typescript-function-runner/package/package.json +25 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { C as CloudClientOptions, A as ApplicationManifest, F as FileSystem, a as ApplicationSummary, R as RequestInput, b as RequestOutput, I as Image } from './sandbox-image-ChzWDeZy.cjs';
|
|
2
|
+
|
|
3
|
+
declare class APIClient {
|
|
4
|
+
private readonly cloudClient;
|
|
5
|
+
private readonly filesystemOptions;
|
|
6
|
+
constructor(options?: CloudClientOptions);
|
|
7
|
+
close(): void;
|
|
8
|
+
upsertApplication(manifest: ApplicationManifest, codeZip: Uint8Array | ArrayBuffer | Blob | string, upgradeRunningRequests?: boolean): Promise<void>;
|
|
9
|
+
deleteApplication(applicationName: string): Promise<void>;
|
|
10
|
+
deleteSandboxImage(imageName: string): Promise<void>;
|
|
11
|
+
createFileSystem(name: string, description?: string, options?: {
|
|
12
|
+
organizationId?: string;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
region?: string;
|
|
15
|
+
}): Promise<FileSystem>;
|
|
16
|
+
listFileSystems(_options?: {
|
|
17
|
+
organizationId?: string;
|
|
18
|
+
projectId?: string;
|
|
19
|
+
}): Promise<FileSystem[]>;
|
|
20
|
+
deleteFileSystem(fileSystemId: string, _options?: {
|
|
21
|
+
organizationId?: string;
|
|
22
|
+
projectId?: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
applications(): Promise<ApplicationSummary[]>;
|
|
25
|
+
application(applicationName: string): Promise<ApplicationManifest>;
|
|
26
|
+
runRequest(applicationName: string, inputs: RequestInput[]): Promise<string>;
|
|
27
|
+
waitOnRequestCompletion(applicationName: string, requestId: string): Promise<void>;
|
|
28
|
+
requestOutput(applicationName: string, requestId: string): Promise<RequestOutput>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare const FILE_BRAND: unique symbol;
|
|
32
|
+
declare class File {
|
|
33
|
+
readonly [FILE_BRAND] = true;
|
|
34
|
+
readonly content: Uint8Array;
|
|
35
|
+
readonly contentType: string;
|
|
36
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
37
|
+
constructor(content: Uint8Array | ArrayBuffer, contentType: string);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const HTTP_BODY_BRAND: unique symbol;
|
|
41
|
+
declare class HttpBody {
|
|
42
|
+
readonly [HTTP_BODY_BRAND] = true;
|
|
43
|
+
readonly content: Uint8Array;
|
|
44
|
+
readonly contentType?: string;
|
|
45
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
46
|
+
constructor(content: Uint8Array | ArrayBuffer, contentType?: string);
|
|
47
|
+
text(encoding?: string): string;
|
|
48
|
+
json<T = unknown>(): T;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type JSONSchema = Record<string, unknown>;
|
|
52
|
+
declare const TYPE: unique symbol;
|
|
53
|
+
interface Schema<T> {
|
|
54
|
+
readonly jsonSchema: JSONSchema;
|
|
55
|
+
readonly [TYPE]?: T;
|
|
56
|
+
readonly _file?: boolean;
|
|
57
|
+
readonly _httpBody?: boolean;
|
|
58
|
+
}
|
|
59
|
+
type Infer<S extends Schema<unknown>> = S extends Schema<infer T> ? T : never;
|
|
60
|
+
interface ParameterOptions<T> {
|
|
61
|
+
description?: string;
|
|
62
|
+
optional?: boolean;
|
|
63
|
+
default?: T;
|
|
64
|
+
}
|
|
65
|
+
interface Parameter<T> {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly schema: Schema<T>;
|
|
68
|
+
readonly description?: string;
|
|
69
|
+
readonly required: boolean;
|
|
70
|
+
readonly hasDefault: boolean;
|
|
71
|
+
readonly defaultValue?: T;
|
|
72
|
+
}
|
|
73
|
+
type ParameterValues<P extends readonly Parameter<unknown>[]> = {
|
|
74
|
+
[K in keyof P]: P[K] extends Parameter<infer T> ? T : never;
|
|
75
|
+
};
|
|
76
|
+
declare function parameter<T>(name: string, valueSchema: Schema<T>, options?: ParameterOptions<T>): Parameter<T>;
|
|
77
|
+
declare const schema: {
|
|
78
|
+
/** Any JSON-serializable value. Useful when strict runtime validation is not needed. */
|
|
79
|
+
json: <T = unknown>() => Schema<T>;
|
|
80
|
+
string: (options?: Omit<JSONSchema, "type">) => Schema<string>;
|
|
81
|
+
number: (options?: Omit<JSONSchema, "type">) => Schema<number>;
|
|
82
|
+
integer: (options?: Omit<JSONSchema, "type">) => Schema<number>;
|
|
83
|
+
boolean: () => Schema<boolean>;
|
|
84
|
+
null: () => Schema<null>;
|
|
85
|
+
literal: <T extends string | number | boolean | null>(value: T) => Schema<T>;
|
|
86
|
+
enum: <const T extends readonly (string | number)[]>(values: T) => Schema<T[number]>;
|
|
87
|
+
array: <S extends Schema<unknown>>(item: S, options?: Omit<JSONSchema, "type" | "items">) => Schema<Infer<S>[]>;
|
|
88
|
+
tuple: <const S extends readonly Schema<unknown>[]>(items: S) => Schema<{ [K in keyof S]: S[K] extends Schema<infer T> ? T : never; }>;
|
|
89
|
+
record: <S extends Schema<unknown>>(value: S) => Schema<Record<string, Infer<S>>>;
|
|
90
|
+
object: <const P extends Record<string, Schema<unknown>>>(properties: P) => Schema<{ [K in keyof P]: P[K] extends Schema<infer T> ? T : never; }>;
|
|
91
|
+
union: <const S extends readonly Schema<unknown>[]>(...choices: S) => Schema<Infer<S[number]>>;
|
|
92
|
+
nullable: <S extends Schema<unknown>>(value: S) => Schema<Infer<S> | null>;
|
|
93
|
+
file: () => Schema<File>;
|
|
94
|
+
httpBody: () => Schema<HttpBody>;
|
|
95
|
+
custom: <T>(jsonSchema: JSONSchema) => Schema<T>;
|
|
96
|
+
parameter: typeof parameter;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
interface Retries {
|
|
100
|
+
maxRetries: number;
|
|
101
|
+
}
|
|
102
|
+
declare function retries(options: Retries): Retries;
|
|
103
|
+
type Region = "us-east-1" | "eu-west-1";
|
|
104
|
+
type ApplicationCapability = "unauthenticated_requests";
|
|
105
|
+
interface FunctionOptions<P extends readonly Parameter<unknown>[], R> {
|
|
106
|
+
name?: string;
|
|
107
|
+
parameters: P;
|
|
108
|
+
returns: Schema<R>;
|
|
109
|
+
description?: string;
|
|
110
|
+
cpu?: number;
|
|
111
|
+
memory?: number;
|
|
112
|
+
ephemeralDisk?: number;
|
|
113
|
+
gpu?: string | string[] | null;
|
|
114
|
+
timeout?: number;
|
|
115
|
+
image?: Image;
|
|
116
|
+
secrets?: string[];
|
|
117
|
+
retries?: Retries;
|
|
118
|
+
region?: Region;
|
|
119
|
+
warmContainers?: number;
|
|
120
|
+
minContainers?: number;
|
|
121
|
+
maxContainers?: number;
|
|
122
|
+
}
|
|
123
|
+
interface ApplicationOptions<P extends readonly Parameter<unknown>[], R> extends FunctionOptions<P, R> {
|
|
124
|
+
tags?: Record<string, string>;
|
|
125
|
+
applicationRetries?: Retries;
|
|
126
|
+
allow?: readonly ApplicationCapability[];
|
|
127
|
+
}
|
|
128
|
+
/** Options available when parameter and return schemas use the JSON defaults. */
|
|
129
|
+
type SimpleFunctionOptions = Omit<FunctionOptions<readonly Parameter<unknown>[], unknown>, "name" | "parameters" | "returns">;
|
|
130
|
+
/** Application options available when parameter and return schemas use the JSON defaults. */
|
|
131
|
+
type SimpleApplicationOptions = Omit<ApplicationOptions<readonly Parameter<unknown>[], unknown>, "name" | "parameters" | "returns">;
|
|
132
|
+
interface NormalizedFunctionOptions {
|
|
133
|
+
description: string;
|
|
134
|
+
cpu: number;
|
|
135
|
+
memory: number;
|
|
136
|
+
ephemeralDisk: number;
|
|
137
|
+
gpu: string | string[] | null;
|
|
138
|
+
timeout: number;
|
|
139
|
+
image?: Image;
|
|
140
|
+
secrets: string[];
|
|
141
|
+
retries?: Retries;
|
|
142
|
+
region?: Region;
|
|
143
|
+
warmContainers?: number;
|
|
144
|
+
minContainers?: number;
|
|
145
|
+
maxContainers?: number;
|
|
146
|
+
}
|
|
147
|
+
interface ApplicationConfiguration {
|
|
148
|
+
tags: Record<string, string>;
|
|
149
|
+
retries: Retries;
|
|
150
|
+
allow: ApplicationCapability[];
|
|
151
|
+
version: string;
|
|
152
|
+
}
|
|
153
|
+
interface RegisteredDefinition {
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly handler: (...args: unknown[]) => Promise<unknown>;
|
|
156
|
+
readonly parameters: readonly Parameter<unknown>[];
|
|
157
|
+
readonly returns: Schema<unknown>;
|
|
158
|
+
readonly options: NormalizedFunctionOptions;
|
|
159
|
+
readonly application?: ApplicationConfiguration;
|
|
160
|
+
}
|
|
161
|
+
declare const TAIL_CALL_BRAND: unique symbol;
|
|
162
|
+
interface TailCall<T> {
|
|
163
|
+
readonly [TAIL_CALL_BRAND]: true;
|
|
164
|
+
readonly kind: "tensorlake-tail-call";
|
|
165
|
+
readonly definition: RegisteredDefinition;
|
|
166
|
+
readonly args: readonly unknown[];
|
|
167
|
+
readonly _result?: T;
|
|
168
|
+
}
|
|
169
|
+
interface WaitOptions {
|
|
170
|
+
timeout?: number;
|
|
171
|
+
returnWhen?: "all_completed" | "first_completed" | "first_failure";
|
|
172
|
+
}
|
|
173
|
+
interface WaitResult<T> {
|
|
174
|
+
done: FunctionFuture<T>[];
|
|
175
|
+
notDone: FunctionFuture<T>[];
|
|
176
|
+
}
|
|
177
|
+
declare class FunctionFuture<T> implements PromiseLike<T> {
|
|
178
|
+
readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
179
|
+
readonly definition: RegisteredDefinition;
|
|
180
|
+
readonly args: readonly unknown[];
|
|
181
|
+
private promise?;
|
|
182
|
+
private startDelaySeconds;
|
|
183
|
+
private completionOrder?;
|
|
184
|
+
private failed;
|
|
185
|
+
exception?: unknown;
|
|
186
|
+
done: boolean;
|
|
187
|
+
constructor(definition: RegisteredDefinition, args: readonly unknown[]);
|
|
188
|
+
run(): this;
|
|
189
|
+
runLater(delaySeconds: number): this;
|
|
190
|
+
get delaySeconds(): number;
|
|
191
|
+
result(): Promise<T>;
|
|
192
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
193
|
+
static wait<T>(futures: FunctionFuture<T>[], options?: WaitOptions): Promise<WaitResult<T>>;
|
|
194
|
+
private static waitForFutures;
|
|
195
|
+
}
|
|
196
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
197
|
+
type AwaitableIterable<T> = Iterable<Awaitable<T>> | PromiseLike<Iterable<Awaitable<T>>>;
|
|
198
|
+
interface RegisteredFunction<Args extends readonly unknown[], Result> {
|
|
199
|
+
(...args: Args): Promise<Result>;
|
|
200
|
+
readonly definition: RegisteredDefinition;
|
|
201
|
+
future(...args: Args): FunctionFuture<Result>;
|
|
202
|
+
map(items: AwaitableIterable<Args[0]>): Promise<Result[]>;
|
|
203
|
+
reduce(items: AwaitableIterable<Args[1]>, initial?: Args[0]): Promise<Result>;
|
|
204
|
+
tailCall(...args: Args): TailCall<Result>;
|
|
205
|
+
}
|
|
206
|
+
type SimpleResult<Output> = Output extends TailCall<infer Result> ? Result : Output;
|
|
207
|
+
declare function registerFunction<const P extends readonly Parameter<unknown>[], Result>(handler: (...args: ParameterValues<P>) => Promise<Result | TailCall<Result>>, options: FunctionOptions<P, Result>): RegisteredFunction<ParameterValues<P>, Result>;
|
|
208
|
+
declare function registerFunction<const Args extends readonly unknown[], Output>(name: string, handler: (...args: Args) => Promise<Output>, options?: SimpleFunctionOptions): RegisteredFunction<Args, SimpleResult<Output>>;
|
|
209
|
+
declare function registerApplication<const P extends readonly Parameter<unknown>[], Result>(handler: (...args: ParameterValues<P>) => Promise<Result | TailCall<Result>>, options: ApplicationOptions<P, Result>): RegisteredFunction<ParameterValues<P>, Result>;
|
|
210
|
+
declare function registerApplication<const Args extends readonly unknown[], Output>(name: string, handler: (...args: Args) => Promise<Output>, options?: SimpleApplicationOptions): RegisteredFunction<Args, SimpleResult<Output>>;
|
|
211
|
+
|
|
212
|
+
type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]>;
|
|
213
|
+
declare const HEADERS_BRAND: unique symbol;
|
|
214
|
+
/** Immutable, case-insensitive application request headers. */
|
|
215
|
+
declare class Headers implements Iterable<readonly [string, string]> {
|
|
216
|
+
#private;
|
|
217
|
+
readonly [HEADERS_BRAND] = true;
|
|
218
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
219
|
+
constructor(headers?: HeadersInit);
|
|
220
|
+
get(name: string): string | undefined;
|
|
221
|
+
getAll(name: string): readonly string[];
|
|
222
|
+
has(name: string): boolean;
|
|
223
|
+
entries(): IterableIterator<readonly [string, string]>;
|
|
224
|
+
[Symbol.iterator](): IterableIterator<readonly [string, string]>;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
interface ProgressOptions {
|
|
228
|
+
message?: string;
|
|
229
|
+
attributes?: Record<string, string>;
|
|
230
|
+
}
|
|
231
|
+
interface RequestState {
|
|
232
|
+
set(key: string, value: unknown): Promise<void>;
|
|
233
|
+
get<T>(key: string, defaultValue?: T): Promise<T | undefined>;
|
|
234
|
+
}
|
|
235
|
+
interface RequestMetrics {
|
|
236
|
+
timer(name: string, value: number): Promise<void>;
|
|
237
|
+
counter(name: string, value?: number): Promise<void>;
|
|
238
|
+
}
|
|
239
|
+
interface FunctionProgress {
|
|
240
|
+
update(current: number, total: number, options?: ProgressOptions): Promise<void>;
|
|
241
|
+
}
|
|
242
|
+
interface RequestContextValue {
|
|
243
|
+
readonly requestId: string;
|
|
244
|
+
readonly headers: Headers;
|
|
245
|
+
readonly signal: AbortSignal;
|
|
246
|
+
readonly state: RequestState;
|
|
247
|
+
readonly metrics: RequestMetrics;
|
|
248
|
+
readonly progress: FunctionProgress;
|
|
249
|
+
}
|
|
250
|
+
declare class RequestContext {
|
|
251
|
+
static get(): RequestContextValue;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class LocalRequest<T> {
|
|
255
|
+
readonly id: string;
|
|
256
|
+
private readonly value;
|
|
257
|
+
private readonly cancelRequest;
|
|
258
|
+
constructor(id: string, value: Promise<T>, cancelRequest: (reason?: unknown) => void);
|
|
259
|
+
output(): Promise<T>;
|
|
260
|
+
cancel(reason?: unknown): void;
|
|
261
|
+
}
|
|
262
|
+
declare function runLocal<Args extends readonly unknown[], Result>(application: RegisteredFunction<Args, Result>, ...args: Args): Promise<LocalRequest<Result>>;
|
|
263
|
+
|
|
264
|
+
declare const REMOTE_OPTIONS_BRAND: unique symbol;
|
|
265
|
+
/** Explicitly marks client options when one or more application arguments are omitted. */
|
|
266
|
+
interface RemoteOptions {
|
|
267
|
+
readonly [REMOTE_OPTIONS_BRAND]: true;
|
|
268
|
+
readonly clientOptions: CloudClientOptions;
|
|
269
|
+
}
|
|
270
|
+
type RemoteInvocation<Args extends readonly unknown[]> = [...Args] | [...Required<Args>, CloudClientOptions] | [...Partial<Args>, RemoteOptions];
|
|
271
|
+
declare function remoteOptions(options?: CloudClientOptions): RemoteOptions;
|
|
272
|
+
declare class RemoteRequest<T> {
|
|
273
|
+
readonly id: string;
|
|
274
|
+
private readonly applicationName;
|
|
275
|
+
private readonly client;
|
|
276
|
+
private readonly outputIsFile?;
|
|
277
|
+
constructor(id: string, applicationName: string, client: APIClient, outputIsFile?: boolean | undefined);
|
|
278
|
+
output(): Promise<T>;
|
|
279
|
+
}
|
|
280
|
+
declare function runRemote<Result = unknown>(application: string, ...args: unknown[]): Promise<RemoteRequest<Result>>;
|
|
281
|
+
declare function runRemote<Args extends readonly unknown[], Result>(application: RegisteredFunction<Args, Result>, ...argsAndOptions: RemoteInvocation<Args>): Promise<RemoteRequest<Result>>;
|
|
282
|
+
|
|
283
|
+
export { type ApplicationCapability as A, File as F, Headers as H, type Infer as I, type JSONSchema as J, LocalRequest as L, type Parameter as P, type RegisteredDefinition as R, type Schema as S, type TailCall as T, type WaitOptions as W, type ApplicationOptions as a, type FunctionOptions as b, FunctionFuture as c, type HeadersInit as d, HttpBody as e, type ParameterValues as f, type RegisteredFunction as g, type RemoteOptions as h, RemoteRequest as i, RequestContext as j, type RequestContextValue as k, type SimpleApplicationOptions as l, type SimpleFunctionOptions as m, type WaitResult as n, registerFunction as o, remoteOptions as p, retries as q, registerApplication as r, runLocal as s, runRemote as t, schema as u, APIClient as v };
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { C as CloudClientOptions, A as ApplicationManifest, F as FileSystem, a as ApplicationSummary, R as RequestInput, b as RequestOutput, I as Image } from './sandbox-image-ChzWDeZy.js';
|
|
2
|
+
|
|
3
|
+
declare class APIClient {
|
|
4
|
+
private readonly cloudClient;
|
|
5
|
+
private readonly filesystemOptions;
|
|
6
|
+
constructor(options?: CloudClientOptions);
|
|
7
|
+
close(): void;
|
|
8
|
+
upsertApplication(manifest: ApplicationManifest, codeZip: Uint8Array | ArrayBuffer | Blob | string, upgradeRunningRequests?: boolean): Promise<void>;
|
|
9
|
+
deleteApplication(applicationName: string): Promise<void>;
|
|
10
|
+
deleteSandboxImage(imageName: string): Promise<void>;
|
|
11
|
+
createFileSystem(name: string, description?: string, options?: {
|
|
12
|
+
organizationId?: string;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
region?: string;
|
|
15
|
+
}): Promise<FileSystem>;
|
|
16
|
+
listFileSystems(_options?: {
|
|
17
|
+
organizationId?: string;
|
|
18
|
+
projectId?: string;
|
|
19
|
+
}): Promise<FileSystem[]>;
|
|
20
|
+
deleteFileSystem(fileSystemId: string, _options?: {
|
|
21
|
+
organizationId?: string;
|
|
22
|
+
projectId?: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
applications(): Promise<ApplicationSummary[]>;
|
|
25
|
+
application(applicationName: string): Promise<ApplicationManifest>;
|
|
26
|
+
runRequest(applicationName: string, inputs: RequestInput[]): Promise<string>;
|
|
27
|
+
waitOnRequestCompletion(applicationName: string, requestId: string): Promise<void>;
|
|
28
|
+
requestOutput(applicationName: string, requestId: string): Promise<RequestOutput>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare const FILE_BRAND: unique symbol;
|
|
32
|
+
declare class File {
|
|
33
|
+
readonly [FILE_BRAND] = true;
|
|
34
|
+
readonly content: Uint8Array;
|
|
35
|
+
readonly contentType: string;
|
|
36
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
37
|
+
constructor(content: Uint8Array | ArrayBuffer, contentType: string);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const HTTP_BODY_BRAND: unique symbol;
|
|
41
|
+
declare class HttpBody {
|
|
42
|
+
readonly [HTTP_BODY_BRAND] = true;
|
|
43
|
+
readonly content: Uint8Array;
|
|
44
|
+
readonly contentType?: string;
|
|
45
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
46
|
+
constructor(content: Uint8Array | ArrayBuffer, contentType?: string);
|
|
47
|
+
text(encoding?: string): string;
|
|
48
|
+
json<T = unknown>(): T;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type JSONSchema = Record<string, unknown>;
|
|
52
|
+
declare const TYPE: unique symbol;
|
|
53
|
+
interface Schema<T> {
|
|
54
|
+
readonly jsonSchema: JSONSchema;
|
|
55
|
+
readonly [TYPE]?: T;
|
|
56
|
+
readonly _file?: boolean;
|
|
57
|
+
readonly _httpBody?: boolean;
|
|
58
|
+
}
|
|
59
|
+
type Infer<S extends Schema<unknown>> = S extends Schema<infer T> ? T : never;
|
|
60
|
+
interface ParameterOptions<T> {
|
|
61
|
+
description?: string;
|
|
62
|
+
optional?: boolean;
|
|
63
|
+
default?: T;
|
|
64
|
+
}
|
|
65
|
+
interface Parameter<T> {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly schema: Schema<T>;
|
|
68
|
+
readonly description?: string;
|
|
69
|
+
readonly required: boolean;
|
|
70
|
+
readonly hasDefault: boolean;
|
|
71
|
+
readonly defaultValue?: T;
|
|
72
|
+
}
|
|
73
|
+
type ParameterValues<P extends readonly Parameter<unknown>[]> = {
|
|
74
|
+
[K in keyof P]: P[K] extends Parameter<infer T> ? T : never;
|
|
75
|
+
};
|
|
76
|
+
declare function parameter<T>(name: string, valueSchema: Schema<T>, options?: ParameterOptions<T>): Parameter<T>;
|
|
77
|
+
declare const schema: {
|
|
78
|
+
/** Any JSON-serializable value. Useful when strict runtime validation is not needed. */
|
|
79
|
+
json: <T = unknown>() => Schema<T>;
|
|
80
|
+
string: (options?: Omit<JSONSchema, "type">) => Schema<string>;
|
|
81
|
+
number: (options?: Omit<JSONSchema, "type">) => Schema<number>;
|
|
82
|
+
integer: (options?: Omit<JSONSchema, "type">) => Schema<number>;
|
|
83
|
+
boolean: () => Schema<boolean>;
|
|
84
|
+
null: () => Schema<null>;
|
|
85
|
+
literal: <T extends string | number | boolean | null>(value: T) => Schema<T>;
|
|
86
|
+
enum: <const T extends readonly (string | number)[]>(values: T) => Schema<T[number]>;
|
|
87
|
+
array: <S extends Schema<unknown>>(item: S, options?: Omit<JSONSchema, "type" | "items">) => Schema<Infer<S>[]>;
|
|
88
|
+
tuple: <const S extends readonly Schema<unknown>[]>(items: S) => Schema<{ [K in keyof S]: S[K] extends Schema<infer T> ? T : never; }>;
|
|
89
|
+
record: <S extends Schema<unknown>>(value: S) => Schema<Record<string, Infer<S>>>;
|
|
90
|
+
object: <const P extends Record<string, Schema<unknown>>>(properties: P) => Schema<{ [K in keyof P]: P[K] extends Schema<infer T> ? T : never; }>;
|
|
91
|
+
union: <const S extends readonly Schema<unknown>[]>(...choices: S) => Schema<Infer<S[number]>>;
|
|
92
|
+
nullable: <S extends Schema<unknown>>(value: S) => Schema<Infer<S> | null>;
|
|
93
|
+
file: () => Schema<File>;
|
|
94
|
+
httpBody: () => Schema<HttpBody>;
|
|
95
|
+
custom: <T>(jsonSchema: JSONSchema) => Schema<T>;
|
|
96
|
+
parameter: typeof parameter;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
interface Retries {
|
|
100
|
+
maxRetries: number;
|
|
101
|
+
}
|
|
102
|
+
declare function retries(options: Retries): Retries;
|
|
103
|
+
type Region = "us-east-1" | "eu-west-1";
|
|
104
|
+
type ApplicationCapability = "unauthenticated_requests";
|
|
105
|
+
interface FunctionOptions<P extends readonly Parameter<unknown>[], R> {
|
|
106
|
+
name?: string;
|
|
107
|
+
parameters: P;
|
|
108
|
+
returns: Schema<R>;
|
|
109
|
+
description?: string;
|
|
110
|
+
cpu?: number;
|
|
111
|
+
memory?: number;
|
|
112
|
+
ephemeralDisk?: number;
|
|
113
|
+
gpu?: string | string[] | null;
|
|
114
|
+
timeout?: number;
|
|
115
|
+
image?: Image;
|
|
116
|
+
secrets?: string[];
|
|
117
|
+
retries?: Retries;
|
|
118
|
+
region?: Region;
|
|
119
|
+
warmContainers?: number;
|
|
120
|
+
minContainers?: number;
|
|
121
|
+
maxContainers?: number;
|
|
122
|
+
}
|
|
123
|
+
interface ApplicationOptions<P extends readonly Parameter<unknown>[], R> extends FunctionOptions<P, R> {
|
|
124
|
+
tags?: Record<string, string>;
|
|
125
|
+
applicationRetries?: Retries;
|
|
126
|
+
allow?: readonly ApplicationCapability[];
|
|
127
|
+
}
|
|
128
|
+
/** Options available when parameter and return schemas use the JSON defaults. */
|
|
129
|
+
type SimpleFunctionOptions = Omit<FunctionOptions<readonly Parameter<unknown>[], unknown>, "name" | "parameters" | "returns">;
|
|
130
|
+
/** Application options available when parameter and return schemas use the JSON defaults. */
|
|
131
|
+
type SimpleApplicationOptions = Omit<ApplicationOptions<readonly Parameter<unknown>[], unknown>, "name" | "parameters" | "returns">;
|
|
132
|
+
interface NormalizedFunctionOptions {
|
|
133
|
+
description: string;
|
|
134
|
+
cpu: number;
|
|
135
|
+
memory: number;
|
|
136
|
+
ephemeralDisk: number;
|
|
137
|
+
gpu: string | string[] | null;
|
|
138
|
+
timeout: number;
|
|
139
|
+
image?: Image;
|
|
140
|
+
secrets: string[];
|
|
141
|
+
retries?: Retries;
|
|
142
|
+
region?: Region;
|
|
143
|
+
warmContainers?: number;
|
|
144
|
+
minContainers?: number;
|
|
145
|
+
maxContainers?: number;
|
|
146
|
+
}
|
|
147
|
+
interface ApplicationConfiguration {
|
|
148
|
+
tags: Record<string, string>;
|
|
149
|
+
retries: Retries;
|
|
150
|
+
allow: ApplicationCapability[];
|
|
151
|
+
version: string;
|
|
152
|
+
}
|
|
153
|
+
interface RegisteredDefinition {
|
|
154
|
+
readonly name: string;
|
|
155
|
+
readonly handler: (...args: unknown[]) => Promise<unknown>;
|
|
156
|
+
readonly parameters: readonly Parameter<unknown>[];
|
|
157
|
+
readonly returns: Schema<unknown>;
|
|
158
|
+
readonly options: NormalizedFunctionOptions;
|
|
159
|
+
readonly application?: ApplicationConfiguration;
|
|
160
|
+
}
|
|
161
|
+
declare const TAIL_CALL_BRAND: unique symbol;
|
|
162
|
+
interface TailCall<T> {
|
|
163
|
+
readonly [TAIL_CALL_BRAND]: true;
|
|
164
|
+
readonly kind: "tensorlake-tail-call";
|
|
165
|
+
readonly definition: RegisteredDefinition;
|
|
166
|
+
readonly args: readonly unknown[];
|
|
167
|
+
readonly _result?: T;
|
|
168
|
+
}
|
|
169
|
+
interface WaitOptions {
|
|
170
|
+
timeout?: number;
|
|
171
|
+
returnWhen?: "all_completed" | "first_completed" | "first_failure";
|
|
172
|
+
}
|
|
173
|
+
interface WaitResult<T> {
|
|
174
|
+
done: FunctionFuture<T>[];
|
|
175
|
+
notDone: FunctionFuture<T>[];
|
|
176
|
+
}
|
|
177
|
+
declare class FunctionFuture<T> implements PromiseLike<T> {
|
|
178
|
+
readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
179
|
+
readonly definition: RegisteredDefinition;
|
|
180
|
+
readonly args: readonly unknown[];
|
|
181
|
+
private promise?;
|
|
182
|
+
private startDelaySeconds;
|
|
183
|
+
private completionOrder?;
|
|
184
|
+
private failed;
|
|
185
|
+
exception?: unknown;
|
|
186
|
+
done: boolean;
|
|
187
|
+
constructor(definition: RegisteredDefinition, args: readonly unknown[]);
|
|
188
|
+
run(): this;
|
|
189
|
+
runLater(delaySeconds: number): this;
|
|
190
|
+
get delaySeconds(): number;
|
|
191
|
+
result(): Promise<T>;
|
|
192
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
193
|
+
static wait<T>(futures: FunctionFuture<T>[], options?: WaitOptions): Promise<WaitResult<T>>;
|
|
194
|
+
private static waitForFutures;
|
|
195
|
+
}
|
|
196
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
197
|
+
type AwaitableIterable<T> = Iterable<Awaitable<T>> | PromiseLike<Iterable<Awaitable<T>>>;
|
|
198
|
+
interface RegisteredFunction<Args extends readonly unknown[], Result> {
|
|
199
|
+
(...args: Args): Promise<Result>;
|
|
200
|
+
readonly definition: RegisteredDefinition;
|
|
201
|
+
future(...args: Args): FunctionFuture<Result>;
|
|
202
|
+
map(items: AwaitableIterable<Args[0]>): Promise<Result[]>;
|
|
203
|
+
reduce(items: AwaitableIterable<Args[1]>, initial?: Args[0]): Promise<Result>;
|
|
204
|
+
tailCall(...args: Args): TailCall<Result>;
|
|
205
|
+
}
|
|
206
|
+
type SimpleResult<Output> = Output extends TailCall<infer Result> ? Result : Output;
|
|
207
|
+
declare function registerFunction<const P extends readonly Parameter<unknown>[], Result>(handler: (...args: ParameterValues<P>) => Promise<Result | TailCall<Result>>, options: FunctionOptions<P, Result>): RegisteredFunction<ParameterValues<P>, Result>;
|
|
208
|
+
declare function registerFunction<const Args extends readonly unknown[], Output>(name: string, handler: (...args: Args) => Promise<Output>, options?: SimpleFunctionOptions): RegisteredFunction<Args, SimpleResult<Output>>;
|
|
209
|
+
declare function registerApplication<const P extends readonly Parameter<unknown>[], Result>(handler: (...args: ParameterValues<P>) => Promise<Result | TailCall<Result>>, options: ApplicationOptions<P, Result>): RegisteredFunction<ParameterValues<P>, Result>;
|
|
210
|
+
declare function registerApplication<const Args extends readonly unknown[], Output>(name: string, handler: (...args: Args) => Promise<Output>, options?: SimpleApplicationOptions): RegisteredFunction<Args, SimpleResult<Output>>;
|
|
211
|
+
|
|
212
|
+
type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]>;
|
|
213
|
+
declare const HEADERS_BRAND: unique symbol;
|
|
214
|
+
/** Immutable, case-insensitive application request headers. */
|
|
215
|
+
declare class Headers implements Iterable<readonly [string, string]> {
|
|
216
|
+
#private;
|
|
217
|
+
readonly [HEADERS_BRAND] = true;
|
|
218
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
219
|
+
constructor(headers?: HeadersInit);
|
|
220
|
+
get(name: string): string | undefined;
|
|
221
|
+
getAll(name: string): readonly string[];
|
|
222
|
+
has(name: string): boolean;
|
|
223
|
+
entries(): IterableIterator<readonly [string, string]>;
|
|
224
|
+
[Symbol.iterator](): IterableIterator<readonly [string, string]>;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
interface ProgressOptions {
|
|
228
|
+
message?: string;
|
|
229
|
+
attributes?: Record<string, string>;
|
|
230
|
+
}
|
|
231
|
+
interface RequestState {
|
|
232
|
+
set(key: string, value: unknown): Promise<void>;
|
|
233
|
+
get<T>(key: string, defaultValue?: T): Promise<T | undefined>;
|
|
234
|
+
}
|
|
235
|
+
interface RequestMetrics {
|
|
236
|
+
timer(name: string, value: number): Promise<void>;
|
|
237
|
+
counter(name: string, value?: number): Promise<void>;
|
|
238
|
+
}
|
|
239
|
+
interface FunctionProgress {
|
|
240
|
+
update(current: number, total: number, options?: ProgressOptions): Promise<void>;
|
|
241
|
+
}
|
|
242
|
+
interface RequestContextValue {
|
|
243
|
+
readonly requestId: string;
|
|
244
|
+
readonly headers: Headers;
|
|
245
|
+
readonly signal: AbortSignal;
|
|
246
|
+
readonly state: RequestState;
|
|
247
|
+
readonly metrics: RequestMetrics;
|
|
248
|
+
readonly progress: FunctionProgress;
|
|
249
|
+
}
|
|
250
|
+
declare class RequestContext {
|
|
251
|
+
static get(): RequestContextValue;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class LocalRequest<T> {
|
|
255
|
+
readonly id: string;
|
|
256
|
+
private readonly value;
|
|
257
|
+
private readonly cancelRequest;
|
|
258
|
+
constructor(id: string, value: Promise<T>, cancelRequest: (reason?: unknown) => void);
|
|
259
|
+
output(): Promise<T>;
|
|
260
|
+
cancel(reason?: unknown): void;
|
|
261
|
+
}
|
|
262
|
+
declare function runLocal<Args extends readonly unknown[], Result>(application: RegisteredFunction<Args, Result>, ...args: Args): Promise<LocalRequest<Result>>;
|
|
263
|
+
|
|
264
|
+
declare const REMOTE_OPTIONS_BRAND: unique symbol;
|
|
265
|
+
/** Explicitly marks client options when one or more application arguments are omitted. */
|
|
266
|
+
interface RemoteOptions {
|
|
267
|
+
readonly [REMOTE_OPTIONS_BRAND]: true;
|
|
268
|
+
readonly clientOptions: CloudClientOptions;
|
|
269
|
+
}
|
|
270
|
+
type RemoteInvocation<Args extends readonly unknown[]> = [...Args] | [...Required<Args>, CloudClientOptions] | [...Partial<Args>, RemoteOptions];
|
|
271
|
+
declare function remoteOptions(options?: CloudClientOptions): RemoteOptions;
|
|
272
|
+
declare class RemoteRequest<T> {
|
|
273
|
+
readonly id: string;
|
|
274
|
+
private readonly applicationName;
|
|
275
|
+
private readonly client;
|
|
276
|
+
private readonly outputIsFile?;
|
|
277
|
+
constructor(id: string, applicationName: string, client: APIClient, outputIsFile?: boolean | undefined);
|
|
278
|
+
output(): Promise<T>;
|
|
279
|
+
}
|
|
280
|
+
declare function runRemote<Result = unknown>(application: string, ...args: unknown[]): Promise<RemoteRequest<Result>>;
|
|
281
|
+
declare function runRemote<Args extends readonly unknown[], Result>(application: RegisteredFunction<Args, Result>, ...argsAndOptions: RemoteInvocation<Args>): Promise<RemoteRequest<Result>>;
|
|
282
|
+
|
|
283
|
+
export { type ApplicationCapability as A, File as F, Headers as H, type Infer as I, type JSONSchema as J, LocalRequest as L, type Parameter as P, type RegisteredDefinition as R, type Schema as S, type TailCall as T, type WaitOptions as W, type ApplicationOptions as a, type FunctionOptions as b, FunctionFuture as c, type HeadersInit as d, HttpBody as e, type ParameterValues as f, type RegisteredFunction as g, type RemoteOptions as h, RemoteRequest as i, RequestContext as j, type RequestContextValue as k, type SimpleApplicationOptions as l, type SimpleFunctionOptions as m, type WaitResult as n, registerFunction as o, remoteOptions as p, retries as q, registerApplication as r, runLocal as s, runRemote as t, schema as u, APIClient as v };
|