@helmr/sdk 0.1.0-preview.g02e24af0.b35435419086
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 +190 -0
- package/README.md +65 -0
- package/dist/actor.d.ts +3 -0
- package/dist/builder.d.ts +18 -0
- package/dist/client-actor.d.ts +32 -0
- package/dist/client-deployment.d.ts +30 -0
- package/dist/client-sandbox.d.ts +26 -0
- package/dist/client-schedule.d.ts +44 -0
- package/dist/client-secret.d.ts +51 -0
- package/dist/client-session.d.ts +38 -0
- package/dist/client-workspace.d.ts +36 -0
- package/dist/client.d.ts +153 -0
- package/dist/config.d.ts +24 -0
- package/dist/contract.d.ts +341 -0
- package/dist/definitions.d.ts +42 -0
- package/dist/fuzzy.d.ts +1 -0
- package/dist/fuzzy.js +29 -0
- package/dist/image.d.ts +63 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +3124 -0
- package/dist/internal/abort.d.ts +1 -0
- package/dist/internal/definition-query.d.ts +10 -0
- package/dist/internal/id.d.ts +1 -0
- package/dist/internal/jsoncanon.d.ts +5 -0
- package/dist/internal/origin.d.ts +1 -0
- package/dist/internal/program.d.ts +10 -0
- package/dist/internal/run-failure.d.ts +2 -0
- package/dist/internal/run-handle.d.ts +3 -0
- package/dist/internal/runtime.d.ts +43 -0
- package/dist/internal/session.d.ts +5 -0
- package/dist/internal/strings.d.ts +1 -0
- package/dist/internal/timestamp.d.ts +1 -0
- package/dist/internal/utf8.d.ts +3 -0
- package/dist/internal.d.ts +14 -0
- package/dist/internal.js +1089 -0
- package/dist/logger.d.ts +9 -0
- package/dist/metadata.d.ts +6 -0
- package/dist/request.d.ts +3 -0
- package/dist/schedules.d.ts +33 -0
- package/dist/schema/payload.d.ts +39 -0
- package/dist/schema/task.d.ts +3 -0
- package/dist/secret.d.ts +1 -0
- package/dist/session.d.ts +5 -0
- package/dist/task.d.ts +2 -0
- package/dist/timers.d.ts +6 -0
- package/dist/tokens.d.ts +77 -0
- package/dist/workspace.d.ts +142 -0
- package/package.json +49 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { CursorPage, JsonValue, RunHandle, Run, RunStatus, Task, TaskInput, TaskOutput, RunOptions, TaskWait } from "./contract.js";
|
|
2
|
+
import type { TokenCreateRequest, TokenCreateResult, TokenListItem, TokenListQuery, Token } from "./tokens.js";
|
|
3
|
+
import type { WorkspaceRef } from "./workspace.js";
|
|
4
|
+
import { type ClientWorkspacesApi } from "./client-workspace.js";
|
|
5
|
+
import { type ClientSandboxesApi } from "./client-sandbox.js";
|
|
6
|
+
import { type ClientActorsApi } from "./client-actor.js";
|
|
7
|
+
import { type ClientSessionsApi } from "./client-session.js";
|
|
8
|
+
import { type ClientDeploymentsApi } from "./client-deployment.js";
|
|
9
|
+
import { type ClientSchedulesApi } from "./client-schedule.js";
|
|
10
|
+
import { type ClientSecretsApi } from "./client-secret.js";
|
|
11
|
+
import type { RequestOptions } from "./request.js";
|
|
12
|
+
import type { LogAttributes, RunLogLevel } from "./logger.js";
|
|
13
|
+
export interface HelmrClientOptions {
|
|
14
|
+
readonly url?: string;
|
|
15
|
+
readonly apiKey: string;
|
|
16
|
+
readonly fetch?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
export interface TokenCompleteRequest {
|
|
19
|
+
readonly result: JsonValue;
|
|
20
|
+
readonly idempotencyKey?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TokenCancelRequest {
|
|
23
|
+
readonly idempotencyKey?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ClientTokensApi {
|
|
26
|
+
create(request?: TokenCreateRequest, options?: RequestOptions): Promise<TokenCreateResult>;
|
|
27
|
+
retrieve(id: string, options?: RequestOptions): Promise<Token>;
|
|
28
|
+
list(query?: TokenListQuery, options?: RequestOptions): Promise<CursorPage<TokenListItem>>;
|
|
29
|
+
complete(id: string, request: TokenCompleteRequest, options?: RequestOptions): Promise<Token>;
|
|
30
|
+
cancel(id: string, request?: TokenCancelRequest, options?: RequestOptions): Promise<Token>;
|
|
31
|
+
}
|
|
32
|
+
type ClientTaskRunRequest = RunOptions & Readonly<{
|
|
33
|
+
idempotencyKey?: string;
|
|
34
|
+
workspace: WorkspaceRef;
|
|
35
|
+
}>;
|
|
36
|
+
export type TaskStartRequest<TTask extends Task> = [
|
|
37
|
+
TaskInput<TTask>
|
|
38
|
+
] extends [never] ? ClientTaskRunRequest & Readonly<{
|
|
39
|
+
payload?: never;
|
|
40
|
+
}> : ClientTaskRunRequest & Readonly<{
|
|
41
|
+
payload: TaskInput<TTask>;
|
|
42
|
+
}>;
|
|
43
|
+
export interface ClientTasksApi {
|
|
44
|
+
retrieve(id: string, query?: TaskRetrieveQuery, options?: RequestOptions): Promise<TaskInfo>;
|
|
45
|
+
list(query?: TaskListQuery, options?: RequestOptions): Promise<TaskPage>;
|
|
46
|
+
start<TTask extends Task>(taskId: TTask["id"], request: TaskStartRequest<TTask>, options?: RequestOptions): Promise<RunHandle<TaskOutput<TTask>>>;
|
|
47
|
+
}
|
|
48
|
+
export interface TaskRetrieveQuery {
|
|
49
|
+
readonly deploymentId?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface TaskListQuery extends TaskRetrieveQuery {
|
|
52
|
+
readonly cursor?: string;
|
|
53
|
+
readonly limit?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface TaskListItem {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
}
|
|
58
|
+
export interface TaskInfo extends TaskListItem {
|
|
59
|
+
readonly deploymentId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface TaskPage extends CursorPage<TaskListItem> {
|
|
62
|
+
readonly deploymentId: string;
|
|
63
|
+
}
|
|
64
|
+
export interface RunListQuery {
|
|
65
|
+
readonly status?: RunStatus | readonly RunStatus[];
|
|
66
|
+
readonly kind?: RunEntrypointKind | readonly RunEntrypointKind[];
|
|
67
|
+
readonly sessionId?: string;
|
|
68
|
+
readonly cursor?: string;
|
|
69
|
+
readonly limit?: number;
|
|
70
|
+
}
|
|
71
|
+
export type RunEntrypointKind = "task" | "actor";
|
|
72
|
+
export interface RunListItem {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly status: RunStatus;
|
|
75
|
+
readonly entrypoint: Readonly<{
|
|
76
|
+
kind: RunEntrypointKind;
|
|
77
|
+
id: string;
|
|
78
|
+
}>;
|
|
79
|
+
readonly workspaceId: string;
|
|
80
|
+
readonly sessionId?: string;
|
|
81
|
+
readonly currentAttemptNumber: number;
|
|
82
|
+
readonly createdAt: string;
|
|
83
|
+
readonly startedAt?: string;
|
|
84
|
+
readonly terminalAt?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface RunLogQuery {
|
|
87
|
+
readonly cursor?: string;
|
|
88
|
+
readonly limit?: number;
|
|
89
|
+
readonly level?: RunLogLevel | readonly RunLogLevel[];
|
|
90
|
+
}
|
|
91
|
+
export interface RunEventQuery {
|
|
92
|
+
readonly cursor?: string;
|
|
93
|
+
readonly limit?: number;
|
|
94
|
+
readonly severity?: RunLogLevel | readonly RunLogLevel[];
|
|
95
|
+
}
|
|
96
|
+
export interface StructuredRunLogRecord {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly kind: "structured";
|
|
99
|
+
readonly runId: string;
|
|
100
|
+
readonly attemptNumber: number;
|
|
101
|
+
readonly level: RunLogLevel;
|
|
102
|
+
readonly message: string;
|
|
103
|
+
readonly attributes: LogAttributes;
|
|
104
|
+
readonly at: string;
|
|
105
|
+
}
|
|
106
|
+
export interface StreamRunLogRecord {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly kind: "stdout" | "stderr";
|
|
109
|
+
readonly runId: string;
|
|
110
|
+
readonly attemptNumber: number;
|
|
111
|
+
readonly observedSequence: number;
|
|
112
|
+
readonly contentBase64: string;
|
|
113
|
+
readonly bytes: number;
|
|
114
|
+
readonly at: string;
|
|
115
|
+
}
|
|
116
|
+
export type RunLogRecord = StructuredRunLogRecord | StreamRunLogRecord;
|
|
117
|
+
export interface RunEventRecord {
|
|
118
|
+
readonly id: string;
|
|
119
|
+
readonly runId: string;
|
|
120
|
+
readonly attemptNumber?: number;
|
|
121
|
+
readonly category: string;
|
|
122
|
+
readonly severity: RunLogLevel;
|
|
123
|
+
readonly source: string;
|
|
124
|
+
readonly kind: string;
|
|
125
|
+
readonly message: string;
|
|
126
|
+
readonly attributes: JsonValue;
|
|
127
|
+
readonly occurredAt: string;
|
|
128
|
+
readonly at: string;
|
|
129
|
+
}
|
|
130
|
+
export interface ClientRunsApi {
|
|
131
|
+
retrieve<TOutput extends JsonValue>(run: RunHandle<TOutput>, options?: RequestOptions): Promise<Run<TOutput>>;
|
|
132
|
+
retrieve(runId: string, options?: RequestOptions): Promise<Run<JsonValue>>;
|
|
133
|
+
list(query?: RunListQuery, options?: RequestOptions): Promise<CursorPage<RunListItem>>;
|
|
134
|
+
cancel(runId: string, options?: RequestOptions): Promise<Run<JsonValue>>;
|
|
135
|
+
wait<TOutput extends JsonValue>(run: RunHandle<TOutput>, options?: RequestOptions): TaskWait<TOutput>;
|
|
136
|
+
wait(runId: string, options?: RequestOptions): TaskWait<JsonValue>;
|
|
137
|
+
logs(runId: string, query?: RunLogQuery, options?: RequestOptions): Promise<CursorPage<RunLogRecord>>;
|
|
138
|
+
events(runId: string, query?: RunEventQuery, options?: RequestOptions): Promise<CursorPage<RunEventRecord>>;
|
|
139
|
+
}
|
|
140
|
+
export declare class HelmrClient {
|
|
141
|
+
readonly tasks: ClientTasksApi;
|
|
142
|
+
readonly actors: ClientActorsApi;
|
|
143
|
+
readonly sessions: ClientSessionsApi;
|
|
144
|
+
readonly sandboxes: ClientSandboxesApi;
|
|
145
|
+
readonly deployments: ClientDeploymentsApi;
|
|
146
|
+
readonly schedules: ClientSchedulesApi;
|
|
147
|
+
readonly secrets: ClientSecretsApi;
|
|
148
|
+
readonly runs: ClientRunsApi;
|
|
149
|
+
readonly tokens: ClientTokensApi;
|
|
150
|
+
readonly workspaces: ClientWorkspacesApi;
|
|
151
|
+
constructor(options: HelmrClientOptions);
|
|
152
|
+
}
|
|
153
|
+
export {};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Builder } from "./builder.js";
|
|
2
|
+
export interface HelmrBuildInput {
|
|
3
|
+
readonly builder?: Builder;
|
|
4
|
+
readonly installCommand?: string;
|
|
5
|
+
readonly secrets?: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export interface HelmrConfigInput {
|
|
8
|
+
readonly dirs?: readonly string[];
|
|
9
|
+
readonly ignorePatterns?: readonly string[];
|
|
10
|
+
readonly build?: HelmrBuildInput;
|
|
11
|
+
}
|
|
12
|
+
export interface HelmrBuildConfig {
|
|
13
|
+
readonly builder: Builder;
|
|
14
|
+
readonly installCommand: string | undefined;
|
|
15
|
+
readonly secrets: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface HelmrConfig {
|
|
18
|
+
readonly dirs: readonly string[];
|
|
19
|
+
readonly ignorePatterns: readonly string[];
|
|
20
|
+
readonly build: HelmrBuildConfig;
|
|
21
|
+
}
|
|
22
|
+
export declare function defineConfig(input: HelmrConfigInput): HelmrConfig;
|
|
23
|
+
export declare function inspectConfig(value: unknown): HelmrConfig;
|
|
24
|
+
export declare function matchesIgnorePattern(pattern: string, path: string): boolean;
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import type { PayloadSchema } from "./schema/payload.js";
|
|
2
|
+
import type { RequestOptions } from "./request.js";
|
|
3
|
+
import type { WorkspaceRef } from "./workspace.js";
|
|
4
|
+
export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
5
|
+
readonly [key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
export type Serializable = JsonValue;
|
|
8
|
+
export type Metadata = Readonly<Record<string, JsonValue>>;
|
|
9
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
10
|
+
export type { PayloadSchema };
|
|
11
|
+
export interface CursorPage<T> {
|
|
12
|
+
readonly items: readonly T[];
|
|
13
|
+
readonly nextCursor?: string;
|
|
14
|
+
}
|
|
15
|
+
export type Duration = string;
|
|
16
|
+
export type RetryPolicy = Readonly<{
|
|
17
|
+
enabled?: true;
|
|
18
|
+
maxAttempts: number;
|
|
19
|
+
backoff?: Readonly<{
|
|
20
|
+
minDelay?: Duration;
|
|
21
|
+
maxDelay?: Duration;
|
|
22
|
+
factor?: number;
|
|
23
|
+
jitter?: "none" | "full";
|
|
24
|
+
}>;
|
|
25
|
+
}> | Readonly<{
|
|
26
|
+
enabled: false;
|
|
27
|
+
}>;
|
|
28
|
+
declare const queueTypeBrand: unique symbol;
|
|
29
|
+
export interface QueueConfig {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly concurrencyLimit?: number | null;
|
|
32
|
+
}
|
|
33
|
+
export interface Queue extends QueueConfig {
|
|
34
|
+
readonly [queueTypeBrand]: true;
|
|
35
|
+
}
|
|
36
|
+
export interface RunOptions {
|
|
37
|
+
readonly queue?: string;
|
|
38
|
+
readonly concurrencyKey?: string;
|
|
39
|
+
readonly priority?: number;
|
|
40
|
+
readonly ttl?: Duration;
|
|
41
|
+
readonly retry?: RetryPolicy;
|
|
42
|
+
readonly metadata?: Metadata;
|
|
43
|
+
readonly tags?: readonly string[];
|
|
44
|
+
}
|
|
45
|
+
export interface RunDefaults {
|
|
46
|
+
readonly queue?: Queue | string;
|
|
47
|
+
readonly maxDuration?: Duration;
|
|
48
|
+
readonly ttl?: Duration;
|
|
49
|
+
readonly retry?: RetryPolicy;
|
|
50
|
+
}
|
|
51
|
+
declare const workspaceAddressTypeBrand: unique symbol;
|
|
52
|
+
export interface WorkspaceAddress {
|
|
53
|
+
readonly [workspaceAddressTypeBrand]: true;
|
|
54
|
+
readonly id: string;
|
|
55
|
+
}
|
|
56
|
+
export type RunCause = Readonly<{
|
|
57
|
+
type: "api" | "manual";
|
|
58
|
+
}> | Readonly<{
|
|
59
|
+
type: "child";
|
|
60
|
+
parentRunId: string;
|
|
61
|
+
}> | Readonly<{
|
|
62
|
+
type: "schedule";
|
|
63
|
+
scheduleId: string;
|
|
64
|
+
scheduledAt: string;
|
|
65
|
+
lastScheduledAt?: string;
|
|
66
|
+
timezone: string;
|
|
67
|
+
}> | Readonly<{
|
|
68
|
+
type: "actor_start" | "continuation";
|
|
69
|
+
}>;
|
|
70
|
+
interface RunContext {
|
|
71
|
+
readonly signal: AbortSignal;
|
|
72
|
+
readonly run: Readonly<{
|
|
73
|
+
id: string;
|
|
74
|
+
attemptNumber: number;
|
|
75
|
+
cause: RunCause;
|
|
76
|
+
}>;
|
|
77
|
+
readonly deployment: Readonly<{
|
|
78
|
+
id: string;
|
|
79
|
+
version: string;
|
|
80
|
+
}>;
|
|
81
|
+
readonly workspace: WorkspaceRef;
|
|
82
|
+
}
|
|
83
|
+
export interface TaskContext extends RunContext {
|
|
84
|
+
readonly task: Readonly<{
|
|
85
|
+
id: string;
|
|
86
|
+
}>;
|
|
87
|
+
readonly actor?: never;
|
|
88
|
+
}
|
|
89
|
+
export interface ActorContext extends RunContext {
|
|
90
|
+
readonly task?: never;
|
|
91
|
+
readonly actor: Readonly<{
|
|
92
|
+
id: string;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
export interface HelmrError extends Error {
|
|
96
|
+
readonly code: string;
|
|
97
|
+
readonly requestId?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface APIError extends HelmrError {
|
|
100
|
+
readonly details?: Readonly<Record<string, JsonValue>>;
|
|
101
|
+
}
|
|
102
|
+
export type RunStatus = "queued" | "running" | "waiting" | "retry_delayed" | "cancel_requested" | "succeeded" | "failed" | "cancelled" | "expired" | "system_failed";
|
|
103
|
+
declare const runHandleOutputBrand: unique symbol;
|
|
104
|
+
export interface RunHandle<TOutput extends JsonValue = JsonValue> {
|
|
105
|
+
readonly id: string;
|
|
106
|
+
readonly [runHandleOutputBrand]: TOutput;
|
|
107
|
+
}
|
|
108
|
+
export interface RunFailure {
|
|
109
|
+
readonly code: string;
|
|
110
|
+
readonly message: string;
|
|
111
|
+
readonly details: Readonly<Record<string, JsonValue>>;
|
|
112
|
+
}
|
|
113
|
+
export interface Run<TOutput extends JsonValue = JsonValue> extends RunHandle<TOutput> {
|
|
114
|
+
readonly status: RunStatus;
|
|
115
|
+
readonly entrypoint: Readonly<{
|
|
116
|
+
kind: "task" | "actor";
|
|
117
|
+
id: string;
|
|
118
|
+
}>;
|
|
119
|
+
readonly deployment: Readonly<{
|
|
120
|
+
id: string;
|
|
121
|
+
version: string;
|
|
122
|
+
}>;
|
|
123
|
+
readonly workspaceId: string;
|
|
124
|
+
readonly sessionId?: string;
|
|
125
|
+
readonly parentRunId?: string;
|
|
126
|
+
readonly currentAttemptNumber: number;
|
|
127
|
+
readonly cause: RunCause;
|
|
128
|
+
readonly metadata: Metadata;
|
|
129
|
+
readonly tags: readonly string[];
|
|
130
|
+
readonly output?: TOutput;
|
|
131
|
+
readonly failure?: RunFailure;
|
|
132
|
+
readonly createdAt: string;
|
|
133
|
+
readonly startedAt?: string;
|
|
134
|
+
readonly terminalAt?: string;
|
|
135
|
+
}
|
|
136
|
+
export type TaskResult<T extends JsonValue> = Readonly<{
|
|
137
|
+
ok: true;
|
|
138
|
+
output: T;
|
|
139
|
+
run: RunHandle<T>;
|
|
140
|
+
}> | Readonly<{
|
|
141
|
+
ok: false;
|
|
142
|
+
failure: RunFailure;
|
|
143
|
+
run: RunHandle<T>;
|
|
144
|
+
}>;
|
|
145
|
+
export interface TaskWait<T extends JsonValue> extends PromiseLike<TaskResult<T>> {
|
|
146
|
+
unwrap(): Promise<T>;
|
|
147
|
+
}
|
|
148
|
+
export interface TaskStartOptions extends RunOptions {
|
|
149
|
+
readonly idempotencyKey?: string;
|
|
150
|
+
readonly workspace: WorkspaceRef;
|
|
151
|
+
readonly signal?: AbortSignal;
|
|
152
|
+
}
|
|
153
|
+
export interface TaskCallOptions extends RunOptions {
|
|
154
|
+
readonly idempotencyKey: string;
|
|
155
|
+
readonly workspace: WorkspaceRef;
|
|
156
|
+
readonly signal?: AbortSignal;
|
|
157
|
+
}
|
|
158
|
+
declare const taskBrand: unique symbol;
|
|
159
|
+
interface TaskTypeInfo<TIdentifier extends string, TInput extends JsonValue, TOutput extends JsonValue> {
|
|
160
|
+
readonly identifier: TIdentifier;
|
|
161
|
+
readonly input: TInput;
|
|
162
|
+
readonly output: TOutput;
|
|
163
|
+
}
|
|
164
|
+
export interface Task<TIdentifier extends string = string, TInput extends JsonValue = JsonValue, TOutput extends JsonValue = JsonValue> {
|
|
165
|
+
readonly [taskBrand]: TaskTypeInfo<TIdentifier, TInput, TOutput>;
|
|
166
|
+
readonly id: TIdentifier;
|
|
167
|
+
readonly hasPayload: boolean;
|
|
168
|
+
start(...args: [TInput] extends [never] ? [options: TaskStartOptions] : [payload: TInput, options: TaskStartOptions]): Promise<RunHandle<TOutput>>;
|
|
169
|
+
call(...args: [TInput] extends [never] ? [options: TaskCallOptions] : [payload: TInput, options: TaskCallOptions]): TaskWait<TOutput>;
|
|
170
|
+
}
|
|
171
|
+
export type TaskInput<TTask extends Task> = TTask[typeof taskBrand]["input"];
|
|
172
|
+
export type TaskOutput<TTask extends Task> = TTask[typeof taskBrand]["output"];
|
|
173
|
+
export type TaskConfigWithPayload<TIdentifier extends string, TInput extends JsonValue, TPayload, TOutput extends JsonValue> = RunDefaults & Readonly<{
|
|
174
|
+
id: TIdentifier;
|
|
175
|
+
payload: PayloadSchema<TInput, TPayload>;
|
|
176
|
+
run(payload: TPayload, ctx: TaskContext): MaybePromise<TOutput>;
|
|
177
|
+
}>;
|
|
178
|
+
export type TaskConfigWithoutPayload<TIdentifier extends string, TOutput extends JsonValue> = RunDefaults & Readonly<{
|
|
179
|
+
id: TIdentifier;
|
|
180
|
+
payload?: never;
|
|
181
|
+
run(ctx: TaskContext): MaybePromise<TOutput>;
|
|
182
|
+
}>;
|
|
183
|
+
export type TaskConfig<TIdentifier extends string = string, TInput extends JsonValue = never, TPayload = never, TOutput extends JsonValue = JsonValue> = TaskConfigWithPayload<TIdentifier, TInput, TPayload, TOutput> | TaskConfigWithoutPayload<TIdentifier, TOutput>;
|
|
184
|
+
export type SessionInputSource = Readonly<{
|
|
185
|
+
type: "external";
|
|
186
|
+
}> | Readonly<{
|
|
187
|
+
type: "run";
|
|
188
|
+
runId: string;
|
|
189
|
+
}>;
|
|
190
|
+
export interface WaitTimeoutError extends HelmrError {
|
|
191
|
+
readonly code: "wait_timeout";
|
|
192
|
+
}
|
|
193
|
+
export interface SessionClosedError extends HelmrError {
|
|
194
|
+
readonly code: "session_closed";
|
|
195
|
+
}
|
|
196
|
+
export interface SessionInputMetadata {
|
|
197
|
+
readonly id: string;
|
|
198
|
+
readonly sequence: number;
|
|
199
|
+
readonly createdAt: string;
|
|
200
|
+
readonly source: SessionInputSource;
|
|
201
|
+
}
|
|
202
|
+
export interface SessionInputRecord extends SessionInputMetadata {
|
|
203
|
+
readonly data: JsonValue;
|
|
204
|
+
}
|
|
205
|
+
export type ActorSessionInputResult = Readonly<{
|
|
206
|
+
ok: true;
|
|
207
|
+
value: JsonValue;
|
|
208
|
+
record: SessionInputMetadata;
|
|
209
|
+
}> | Readonly<{
|
|
210
|
+
ok: false;
|
|
211
|
+
error: WaitTimeoutError | SessionClosedError;
|
|
212
|
+
}>;
|
|
213
|
+
export interface ActorSessionReceive extends PromiseLike<ActorSessionInputResult> {
|
|
214
|
+
unwrap(): Promise<JsonValue>;
|
|
215
|
+
}
|
|
216
|
+
export interface SessionInputSendRequest {
|
|
217
|
+
readonly idempotencyKey?: string;
|
|
218
|
+
}
|
|
219
|
+
export interface ActorSessionReceiveOptions {
|
|
220
|
+
readonly timeout?: Duration;
|
|
221
|
+
readonly idleTimeout?: Duration;
|
|
222
|
+
readonly metadata?: Metadata;
|
|
223
|
+
readonly tags?: readonly string[];
|
|
224
|
+
}
|
|
225
|
+
export interface ActorSessionInput {
|
|
226
|
+
receive(options?: ActorSessionReceiveOptions): ActorSessionReceive;
|
|
227
|
+
}
|
|
228
|
+
export interface SessionOutputRecord {
|
|
229
|
+
readonly id: string;
|
|
230
|
+
readonly sequence: number;
|
|
231
|
+
readonly data: unknown;
|
|
232
|
+
readonly contentType: string;
|
|
233
|
+
readonly createdAt: string;
|
|
234
|
+
readonly provenance: Readonly<{
|
|
235
|
+
runId: string;
|
|
236
|
+
attemptNumber: number;
|
|
237
|
+
deploymentId: string;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
240
|
+
export interface ActorSessionOutputAppendOptions {
|
|
241
|
+
readonly contentType?: string;
|
|
242
|
+
readonly idempotencyKey?: string;
|
|
243
|
+
}
|
|
244
|
+
export interface ActorSessionOutputSequenceOptions {
|
|
245
|
+
readonly contentType?: string;
|
|
246
|
+
}
|
|
247
|
+
export interface SessionOutputQuery {
|
|
248
|
+
readonly after?: number;
|
|
249
|
+
readonly limit?: number;
|
|
250
|
+
}
|
|
251
|
+
export interface SessionInputQuery {
|
|
252
|
+
readonly after?: number;
|
|
253
|
+
readonly limit?: number;
|
|
254
|
+
}
|
|
255
|
+
export interface SessionOutputWriter {
|
|
256
|
+
write(value: Serializable): Promise<SessionOutputRecord>;
|
|
257
|
+
close(): Promise<void>;
|
|
258
|
+
}
|
|
259
|
+
export interface ActorSessionOutput {
|
|
260
|
+
append(value: Serializable, options?: ActorSessionOutputAppendOptions): Promise<SessionOutputRecord>;
|
|
261
|
+
pipe(source: AsyncIterable<Serializable> | Iterable<Serializable>, options?: ActorSessionOutputSequenceOptions): Promise<void>;
|
|
262
|
+
writer(options?: ActorSessionOutputSequenceOptions): SessionOutputWriter;
|
|
263
|
+
}
|
|
264
|
+
export interface SessionOutputPage {
|
|
265
|
+
readonly records: readonly SessionOutputRecord[];
|
|
266
|
+
readonly nextAfter: number;
|
|
267
|
+
readonly hasMore: boolean;
|
|
268
|
+
}
|
|
269
|
+
export interface SessionInputPage {
|
|
270
|
+
readonly records: readonly SessionInputRecord[];
|
|
271
|
+
readonly nextAfter: number;
|
|
272
|
+
readonly hasMore: boolean;
|
|
273
|
+
}
|
|
274
|
+
export interface ActorSession {
|
|
275
|
+
readonly id: string;
|
|
276
|
+
readonly key?: string;
|
|
277
|
+
readonly input: ActorSessionInput;
|
|
278
|
+
readonly output: ActorSessionOutput;
|
|
279
|
+
}
|
|
280
|
+
export interface ActorConfig extends RunDefaults {
|
|
281
|
+
readonly id: string;
|
|
282
|
+
readonly idleTimeout?: Duration;
|
|
283
|
+
readonly run: (session: ActorSession, ctx: ActorContext) => MaybePromise<void>;
|
|
284
|
+
}
|
|
285
|
+
export interface ActorStartOptions {
|
|
286
|
+
readonly key?: string;
|
|
287
|
+
readonly input?: JsonValue;
|
|
288
|
+
readonly idempotencyKey?: string;
|
|
289
|
+
readonly workspace: WorkspaceRef;
|
|
290
|
+
readonly run?: RunOptions;
|
|
291
|
+
readonly signal?: AbortSignal;
|
|
292
|
+
}
|
|
293
|
+
export type SessionStatus = "open" | "closed" | "cancelled" | "failed";
|
|
294
|
+
export type SessionFailureCode = string;
|
|
295
|
+
export interface SessionFailure {
|
|
296
|
+
readonly code: SessionFailureCode;
|
|
297
|
+
readonly message: string;
|
|
298
|
+
readonly details: Readonly<{
|
|
299
|
+
runId?: string;
|
|
300
|
+
}>;
|
|
301
|
+
}
|
|
302
|
+
export interface Session {
|
|
303
|
+
readonly id: string;
|
|
304
|
+
readonly actorId: string;
|
|
305
|
+
readonly deploymentId: string;
|
|
306
|
+
readonly workspaceId: string;
|
|
307
|
+
readonly key?: string;
|
|
308
|
+
readonly status: SessionStatus;
|
|
309
|
+
readonly createdAt: string;
|
|
310
|
+
readonly updatedAt: string;
|
|
311
|
+
readonly currentRunId?: string;
|
|
312
|
+
readonly failure?: SessionFailure;
|
|
313
|
+
}
|
|
314
|
+
export interface SessionCloseRequest {
|
|
315
|
+
readonly idempotencyKey?: string;
|
|
316
|
+
}
|
|
317
|
+
export interface SessionCloseReceipt {
|
|
318
|
+
readonly sessionId: string;
|
|
319
|
+
readonly acceptedAt: string;
|
|
320
|
+
}
|
|
321
|
+
export interface SessionRef {
|
|
322
|
+
readonly id: string;
|
|
323
|
+
readonly input: Readonly<{
|
|
324
|
+
send(input: JsonValue, request?: SessionInputSendRequest, options?: RequestOptions): Promise<SessionInputRecord>;
|
|
325
|
+
}>;
|
|
326
|
+
readonly output: Readonly<{
|
|
327
|
+
list(query?: SessionOutputQuery, options?: RequestOptions): Promise<SessionOutputPage>;
|
|
328
|
+
}>;
|
|
329
|
+
retrieve(options?: RequestOptions): Promise<Session>;
|
|
330
|
+
close(request?: SessionCloseRequest, options?: RequestOptions): Promise<SessionCloseReceipt>;
|
|
331
|
+
}
|
|
332
|
+
declare const actorTypeBrand: unique symbol;
|
|
333
|
+
export interface ActorStartResult {
|
|
334
|
+
readonly session: SessionRef;
|
|
335
|
+
readonly run: RunHandle<null>;
|
|
336
|
+
}
|
|
337
|
+
export interface Actor {
|
|
338
|
+
readonly [actorTypeBrand]: true;
|
|
339
|
+
readonly id: string;
|
|
340
|
+
start(options: ActorStartOptions): Promise<ActorStartResult>;
|
|
341
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ActorConfig, type Actor, type JsonValue, type Queue, type QueueConfig, type Task, type TaskConfigWithPayload, type TaskConfigWithoutPayload } from "./contract.js";
|
|
2
|
+
import { type PayloadSchema } from "./schema/payload.js";
|
|
3
|
+
export type InternalTaskDefinition = Readonly<{
|
|
4
|
+
kind: "task";
|
|
5
|
+
id: string;
|
|
6
|
+
hasPayload: boolean;
|
|
7
|
+
handler: (...args: readonly unknown[]) => unknown;
|
|
8
|
+
payloadSchema?: PayloadSchema;
|
|
9
|
+
queue?: Queue | string;
|
|
10
|
+
maxDuration?: import("./contract.js").Duration;
|
|
11
|
+
ttl?: import("./contract.js").Duration;
|
|
12
|
+
retry?: ActorConfig["retry"];
|
|
13
|
+
schedule?: Readonly<{
|
|
14
|
+
cron: string;
|
|
15
|
+
timezone: string;
|
|
16
|
+
workspace: Readonly<{
|
|
17
|
+
sandbox: import("./workspace.js").Sandbox;
|
|
18
|
+
secrets: readonly import("./workspace.js").EncodedWorkspaceSecret[];
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
}>;
|
|
22
|
+
export type InternalActorDefinition = Readonly<{
|
|
23
|
+
kind: "actor";
|
|
24
|
+
id: string;
|
|
25
|
+
handler: ActorConfig["run"];
|
|
26
|
+
queue?: Queue | string;
|
|
27
|
+
maxDuration?: import("./contract.js").Duration;
|
|
28
|
+
ttl?: import("./contract.js").Duration;
|
|
29
|
+
retry?: ActorConfig["retry"];
|
|
30
|
+
idleTimeout?: ActorConfig["idleTimeout"];
|
|
31
|
+
}>;
|
|
32
|
+
export type InternalDefinition = InternalTaskDefinition | InternalActorDefinition;
|
|
33
|
+
export declare function inspectDefinition(value: unknown): InternalDefinition | undefined;
|
|
34
|
+
export declare function isQueue(value: unknown): value is Queue;
|
|
35
|
+
export declare function queue(config: QueueConfig): Queue;
|
|
36
|
+
export declare function task<TIdentifier extends string, TInput extends JsonValue, TPayload, TOutput extends JsonValue>(config: TaskConfigWithPayload<TIdentifier, TInput, TPayload, TOutput>): Task<TIdentifier, TInput, TOutput>;
|
|
37
|
+
export declare function task<TIdentifier extends string, TOutput extends JsonValue>(config: TaskConfigWithoutPayload<TIdentifier, TOutput>): Task<TIdentifier, never, TOutput>;
|
|
38
|
+
export declare function actor(config: ActorConfig): Actor;
|
|
39
|
+
export declare function createScheduledTask<TIdentifier extends string, TInput extends JsonValue, TPayload, TOutput extends JsonValue>(config: Omit<TaskConfigWithPayload<TIdentifier, TInput, TPayload, TOutput>, "payload"> & {
|
|
40
|
+
readonly payload: PayloadSchema<TInput, TPayload>;
|
|
41
|
+
readonly schedule: NonNullable<InternalTaskDefinition["schedule"]>;
|
|
42
|
+
}): Task<TIdentifier, TInput, TOutput>;
|
package/dist/fuzzy.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function levenshteinDistance(left: string, right: string): number;
|
package/dist/fuzzy.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// sdk/typescript/src/fuzzy.ts
|
|
2
|
+
function levenshteinDistance(left, right) {
|
|
3
|
+
if (left === right) {
|
|
4
|
+
return 0;
|
|
5
|
+
}
|
|
6
|
+
if (left.length === 0) {
|
|
7
|
+
return right.length;
|
|
8
|
+
}
|
|
9
|
+
if (right.length === 0) {
|
|
10
|
+
return left.length;
|
|
11
|
+
}
|
|
12
|
+
const previous = new Array(right.length + 1);
|
|
13
|
+
const current = new Array(right.length + 1);
|
|
14
|
+
for (let column = 0;column <= right.length; column += 1) {
|
|
15
|
+
previous[column] = column;
|
|
16
|
+
}
|
|
17
|
+
for (let row = 1;row <= left.length; row += 1) {
|
|
18
|
+
current[0] = row;
|
|
19
|
+
for (let column = 1;column <= right.length; column += 1) {
|
|
20
|
+
const cost = left[row - 1] === right[column - 1] ? 0 : 1;
|
|
21
|
+
current[column] = Math.min(current[column - 1] + 1, previous[column] + 1, previous[column - 1] + cost);
|
|
22
|
+
}
|
|
23
|
+
previous.splice(0, previous.length, ...current);
|
|
24
|
+
}
|
|
25
|
+
return previous[right.length] ?? right.length;
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
levenshteinDistance
|
|
29
|
+
};
|
package/dist/image.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
declare const sourceFileTypeBrand: unique symbol;
|
|
2
|
+
declare const sourceDirectoryTypeBrand: unique symbol;
|
|
3
|
+
declare const imageBuilderTypeBrand: unique symbol;
|
|
4
|
+
export interface SourceFile {
|
|
5
|
+
readonly [sourceFileTypeBrand]: true;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SourceDirectory {
|
|
9
|
+
readonly [sourceDirectoryTypeBrand]: true;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ImageBuilder {
|
|
13
|
+
readonly [imageBuilderTypeBrand]: true;
|
|
14
|
+
readonly key: string;
|
|
15
|
+
from(ref: string): ImageBuilder;
|
|
16
|
+
run(argv: readonly string[]): ImageBuilder;
|
|
17
|
+
copy(source: SourceFile | SourceDirectory, destination: string): ImageBuilder;
|
|
18
|
+
copyFrom(destination: string, source: ImageBuilder, sourcePath: string): ImageBuilder;
|
|
19
|
+
workdir(path: string): ImageBuilder;
|
|
20
|
+
env(key: string, value: string): ImageBuilder;
|
|
21
|
+
user(name: string): ImageBuilder;
|
|
22
|
+
}
|
|
23
|
+
export type InternalImageStep = Readonly<{
|
|
24
|
+
kind: "from";
|
|
25
|
+
ref: string;
|
|
26
|
+
}> | Readonly<{
|
|
27
|
+
kind: "run";
|
|
28
|
+
argv: readonly string[];
|
|
29
|
+
}> | Readonly<{
|
|
30
|
+
kind: "copy_source_file";
|
|
31
|
+
destination: string;
|
|
32
|
+
source: SourceFile;
|
|
33
|
+
}> | Readonly<{
|
|
34
|
+
kind: "copy_source_directory";
|
|
35
|
+
destination: string;
|
|
36
|
+
source: SourceDirectory;
|
|
37
|
+
}> | Readonly<{
|
|
38
|
+
kind: "copy_from_image";
|
|
39
|
+
destination: string;
|
|
40
|
+
source: ImageBuilder;
|
|
41
|
+
sourcePath: string;
|
|
42
|
+
}> | Readonly<{
|
|
43
|
+
kind: "workdir";
|
|
44
|
+
path: string;
|
|
45
|
+
}> | Readonly<{
|
|
46
|
+
kind: "env";
|
|
47
|
+
key: string;
|
|
48
|
+
value: string;
|
|
49
|
+
}> | Readonly<{
|
|
50
|
+
kind: "user";
|
|
51
|
+
name: string;
|
|
52
|
+
}>;
|
|
53
|
+
export interface InternalImage {
|
|
54
|
+
readonly key: string;
|
|
55
|
+
readonly steps: readonly InternalImageStep[];
|
|
56
|
+
}
|
|
57
|
+
export declare function image(key: string): ImageBuilder;
|
|
58
|
+
export declare const source: Readonly<{
|
|
59
|
+
file(path: string): SourceFile;
|
|
60
|
+
directory(path: string): SourceDirectory;
|
|
61
|
+
}>;
|
|
62
|
+
export declare function inspectImage(value: unknown): InternalImage | undefined;
|
|
63
|
+
export {};
|