@helmr/sdk 0.1.1-rc.4 → 0.1.1-rc.5

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.
@@ -1,51 +1,103 @@
1
- import { type SecretDecls, type Task, type WorkspaceSpec } from "../internal.js";
2
- import { type LogSnapshot, type ListRunEventsOptions, type ListRunsOptions, type PendingApprovalWaitpoint, type PendingMessageWaitpoint, type PendingWaitpoint, type PendingWaitpointResponse, type RetrieveRunOptions, type RunHandle, type RunEvent, type RunSnapshot, type RunSummary, type RunWaitOptions, type SubscribeRunEventsOptions, type WaitpointApprovalOptions, type WaitpointRef, type WaitpointReplyOptions } from "./run.js";
1
+ import { type AnyTask, type NoPayload, type SecretDecls, type TaskOutput, type TaskRunOptions, type TaskSecrets, type TaskTriggerPayload, type WorkspaceSpec } from "../internal.js";
2
+ import { type LogSnapshot, type ListRunEventsOptions, type ListRunsOptions, type PendingManualWaitpoint, type PendingWaitpointResponse, type RetrieveRunOptions, type RunHandle, type RunEvent, type RunSnapshot, type RunSummary, type RunWaitOptions, type SubscribeRunEventsOptions, type WaitpointRespondOptions, type WaitpointRef } from "./run.js";
3
3
  export interface HelmrClientOptions {
4
4
  readonly url?: string;
5
5
  readonly apiKey?: string;
6
6
  }
7
- export type TaskTriggerOptions<TPayload, TSecrets extends SecretDecls> = {
8
- /**
9
- * Payload is audit data: Helmr persists it in plaintext in the `run.created`
10
- * event, DB, and events stream. Do not put secret values (tokens, API keys,
11
- * credentials, or PII) in payload; use `secrets:` instead. Use payload for
12
- * business context such as PR numbers, repo names, ticket ids, and other
13
- * identifiers.
14
- */
15
- readonly payload: TPayload;
16
- readonly workspace: WorkspaceSpec;
17
- } & ([keyof TSecrets] extends [never] ? {
18
- readonly secrets?: Record<never, never>;
19
- } : {
20
- readonly secrets: {
21
- readonly [K in keyof TSecrets]: string;
22
- };
23
- });
7
+ export type TaskTriggerOptions<TSecrets extends SecretDecls> = TaskRunOptions<TSecrets>;
8
+ export type TasksTriggerArgs<TTask extends AnyTask> = [
9
+ TaskTriggerPayload<TTask>
10
+ ] extends [NoPayload] ? [id: string, opts: TaskTriggerOptions<TaskSecrets<TTask>>] : [id: string, payload: TaskTriggerPayload<TTask>, opts: TaskTriggerOptions<TaskSecrets<TTask>>];
11
+ export type DirectTaskTriggerArgs<TTask extends AnyTask> = [
12
+ TaskTriggerPayload<TTask>
13
+ ] extends [NoPayload] ? [opts: TaskTriggerOptions<TaskSecrets<TTask>>] : [payload: TaskTriggerPayload<TTask>, opts: TaskTriggerOptions<TaskSecrets<TTask>>];
14
+ export declare const triggerTaskClientMethod: unique symbol;
24
15
  export interface WaitpointsApi {
25
- readonly approve: {
26
- (target: PendingApprovalWaitpoint, opts?: WaitpointApprovalOptions): Promise<void>;
27
- (runId: string, waitpointId: string, opts?: WaitpointApprovalOptions): Promise<void>;
28
- };
29
- readonly deny: {
30
- (target: PendingApprovalWaitpoint, opts?: WaitpointApprovalOptions): Promise<void>;
31
- (runId: string, waitpointId: string, opts?: WaitpointApprovalOptions): Promise<void>;
32
- };
33
- readonly reply: {
34
- (target: PendingMessageWaitpoint, opts: WaitpointReplyOptions): Promise<void>;
35
- (runId: string, waitpointId: string, opts: WaitpointReplyOptions): Promise<void>;
16
+ readonly create: (opts: WaitpointCreateOptions) => Promise<Waitpoint>;
17
+ readonly respond: {
18
+ (target: PendingManualWaitpoint | WaitpointRef, opts?: WaitpointRespondOptions): Promise<void>;
19
+ (waitpointId: string, opts?: WaitpointRespondOptions): Promise<void>;
36
20
  };
37
21
  readonly tokens: {
38
22
  readonly create: {
39
- (target: PendingWaitpoint | WaitpointRef, opts?: WaitpointTokenCreateOptions): Promise<WaitpointResponseToken>;
40
- (runId: string, waitpointId: string, opts?: WaitpointTokenCreateOptions): Promise<WaitpointResponseToken>;
23
+ (target: PendingManualWaitpoint | WaitpointRef, opts?: WaitpointTokenCreateOptions): Promise<WaitpointResponseToken>;
24
+ (waitpointId: string, opts?: WaitpointTokenCreateOptions): Promise<WaitpointResponseToken>;
41
25
  };
42
- readonly complete: {
43
- (token: WaitpointResponseToken, opts: WaitpointTokenCompleteOptions): Promise<void>;
44
- (id: string, token: string, opts: WaitpointTokenCompleteOptions): Promise<void>;
26
+ readonly respond: {
27
+ (token: WaitpointResponseToken, opts: WaitpointTokenRespondOptions): Promise<void>;
28
+ (id: string, token: string, opts: WaitpointTokenRespondOptions): Promise<void>;
45
29
  };
46
30
  };
47
31
  }
48
- export type WaitpointTokenAction = "approve" | "deny" | "message" | "reply";
32
+ export interface SchedulesApi {
33
+ readonly create: (opts: ScheduleCreateOptions) => Promise<Schedule>;
34
+ readonly update: (id: string, opts: ScheduleUpdateOptions & RetrieveScheduleOptions) => Promise<Schedule>;
35
+ readonly list: (opts?: ListSchedulesOptions) => Promise<Schedule[]>;
36
+ readonly retrieve: (id: string, opts?: RetrieveScheduleOptions) => Promise<Schedule>;
37
+ readonly activate: (id: string, opts?: RetrieveScheduleOptions) => Promise<Schedule>;
38
+ readonly deactivate: (id: string, opts?: RetrieveScheduleOptions) => Promise<Schedule>;
39
+ readonly delete: (id: string, opts?: RetrieveScheduleOptions) => Promise<void>;
40
+ }
41
+ export interface ScheduleCreateOptions {
42
+ readonly deduplicationKey?: string;
43
+ readonly externalId?: string;
44
+ readonly projectId?: string;
45
+ readonly environmentId?: string;
46
+ readonly task: string;
47
+ readonly cron: string;
48
+ readonly timezone?: string;
49
+ readonly active?: boolean;
50
+ readonly workspace: WorkspaceSpec;
51
+ readonly secretBindings?: Record<string, string>;
52
+ readonly options?: ScheduleRunOptions;
53
+ }
54
+ export type ScheduleUpdateOptions = Omit<ScheduleCreateOptions, "deduplicationKey"> & {
55
+ readonly externalId?: string;
56
+ };
57
+ export interface ScheduleRunOptions {
58
+ readonly deploymentId?: string;
59
+ readonly version?: string;
60
+ readonly queue?: string;
61
+ readonly concurrencyKey?: string;
62
+ readonly priority?: number;
63
+ readonly ttl?: string;
64
+ readonly maxDurationSeconds?: number;
65
+ }
66
+ export interface ScheduleWorkspace {
67
+ readonly repository?: string;
68
+ readonly ref?: string;
69
+ readonly sha?: string;
70
+ readonly subpath?: string;
71
+ }
72
+ export interface ListSchedulesOptions {
73
+ readonly projectId?: string;
74
+ readonly environmentId?: string;
75
+ readonly signal?: AbortSignal;
76
+ }
77
+ export interface RetrieveScheduleOptions {
78
+ readonly projectId?: string;
79
+ readonly environmentId?: string;
80
+ readonly signal?: AbortSignal;
81
+ }
82
+ export interface Schedule {
83
+ readonly id: string;
84
+ readonly type: "imperative" | "declarative";
85
+ readonly projectId: string;
86
+ readonly environmentId: string;
87
+ readonly task: string;
88
+ readonly deduplicationKey?: string;
89
+ readonly externalId?: string;
90
+ readonly cron: string;
91
+ readonly timezone: string;
92
+ readonly active: boolean;
93
+ readonly status: "active" | "inactive" | "errored";
94
+ readonly lastError?: string;
95
+ readonly workspace?: ScheduleWorkspace;
96
+ readonly nextScheduledAt?: string;
97
+ readonly lastScheduledAt?: string;
98
+ readonly createdAt: string;
99
+ readonly updatedAt: string;
100
+ }
49
101
  type WaitpointTokenExpirationOptions = {
50
102
  readonly expiresInSeconds?: number;
51
103
  readonly expiresAt?: never;
@@ -54,39 +106,44 @@ type WaitpointTokenExpirationOptions = {
54
106
  readonly expiresAt?: string;
55
107
  };
56
108
  export type WaitpointTokenCreateOptions = WaitpointTokenExpirationOptions & {
57
- readonly actions?: readonly WaitpointTokenAction[];
58
109
  readonly metadata?: Record<string, unknown>;
59
110
  };
60
111
  export interface WaitpointResponseToken {
61
112
  readonly id: string;
62
- readonly runId: string;
63
113
  readonly waitpointId: string;
64
114
  readonly url: string;
65
115
  readonly token: string;
66
116
  readonly expiresAt: string | null;
67
117
  }
68
- export type WaitpointTokenCompleteOptions = {
69
- readonly action: "approve";
70
- readonly reason?: string;
71
- readonly externalSubject?: string;
72
- readonly metadata?: Record<string, unknown>;
73
- } | {
74
- readonly action: "deny";
75
- readonly reason?: string;
76
- readonly externalSubject?: string;
77
- readonly metadata?: Record<string, unknown>;
78
- } | {
79
- readonly action: "message" | "reply";
80
- readonly text: string;
81
- readonly externalSubject?: string;
82
- readonly metadata?: Record<string, unknown>;
83
- };
118
+ export type WaitpointTokenRespondOptions = WaitpointRespondOptions;
119
+ export interface WaitpointCreateOptions {
120
+ readonly projectId?: string;
121
+ readonly environmentId?: string;
122
+ readonly request?: unknown;
123
+ readonly displayText?: string;
124
+ readonly expiresAt: string;
125
+ readonly idempotencyKey?: string;
126
+ readonly idempotencyKeyExpiresAt?: string;
127
+ readonly idempotencyKeyTTLSeconds?: number;
128
+ }
129
+ export interface Waitpoint {
130
+ readonly id: string;
131
+ readonly projectId: string;
132
+ readonly environmentId: string;
133
+ readonly kind: "manual" | "delay";
134
+ readonly status: "pending" | "completed" | "expired" | "cancelled";
135
+ readonly request: unknown;
136
+ readonly displayText: string;
137
+ readonly expiresAt: string | null;
138
+ readonly createdAt: string;
139
+ }
84
140
  export declare class HelmrClient {
85
141
  #private;
86
142
  constructor(options?: HelmrClientOptions);
87
143
  readonly tasks: {
88
- trigger: <TPayload, TOutput, TSecrets extends SecretDecls>(task: Task<TPayload, TOutput, TSecrets>, opts: TaskTriggerOptions<TPayload, TSecrets>) => Promise<RunHandle<TOutput>>;
144
+ trigger: <TTask extends AnyTask>(...args: TasksTriggerArgs<TTask>) => Promise<RunHandle<TaskOutput<TTask>>>;
89
145
  };
146
+ [triggerTaskClientMethod]<TTask extends AnyTask>(task: TTask, ...args: DirectTaskTriggerArgs<TTask>): Promise<RunHandle<TaskOutput<TTask>>>;
90
147
  readonly runs: {
91
148
  retrieve: <TOutput = unknown>(idOrHandle: string | RunHandle<TOutput>, opts?: RetrieveRunOptions) => Promise<RunSnapshot<TOutput>>;
92
149
  wait: <TOutput = unknown>(idOrHandle: string | RunHandle<TOutput>, opts?: RunWaitOptions) => Promise<RunSnapshot<TOutput>>;
@@ -102,6 +159,7 @@ export declare class HelmrClient {
102
159
  };
103
160
  };
104
161
  readonly waitpoints: WaitpointsApi;
162
+ readonly schedules: SchedulesApi;
105
163
  }
106
164
  export interface RunResponse {
107
165
  readonly id: string;
@@ -112,7 +170,7 @@ export interface RunResponse {
112
170
  readonly exit_code?: number | null;
113
171
  readonly created_at?: string;
114
172
  readonly updated_at?: string;
115
- readonly pending_wait?: PendingWaitpointResponse | null;
173
+ readonly pending_waitpoint?: PendingWaitpointResponse | null;
116
174
  readonly output?: unknown;
117
175
  }
118
176
  export interface ListRunsResponse {
@@ -1,4 +1,4 @@
1
- export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled";
1
+ export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | "expired";
2
2
  declare const runOutputBrand: unique symbol;
3
3
  export interface RunHandle<TOutput = unknown> {
4
4
  readonly id: string;
@@ -28,30 +28,29 @@ export interface RunSnapshot<TOutput = unknown> extends RunStateBooleans {
28
28
  readonly output?: TOutput;
29
29
  }
30
30
  export type RunSummary<TOutput = unknown> = RunSnapshot<TOutput>;
31
- export type PendingWaitpoint = PendingApprovalWaitpoint | PendingMessageWaitpoint;
31
+ export type PendingWaitpoint = PendingManualWaitpoint | PendingDelayWaitpoint;
32
32
  interface PendingWaitpointBase {
33
33
  readonly runId: string;
34
34
  readonly waitpointId: string;
35
35
  readonly timeout: number | null;
36
36
  readonly requestedAt: string;
37
+ readonly request: unknown;
38
+ readonly displayText: string;
37
39
  }
38
- export interface PendingApprovalWaitpoint extends PendingWaitpointBase {
39
- readonly kind: "approval";
40
- readonly message: string;
40
+ export interface PendingManualWaitpoint extends PendingWaitpointBase {
41
+ readonly kind: "manual";
41
42
  }
42
- export interface PendingMessageWaitpoint extends PendingWaitpointBase {
43
- readonly kind: "message";
44
- readonly prompt: string | null;
43
+ export interface PendingDelayWaitpoint extends PendingWaitpointBase {
44
+ readonly kind: "delay";
45
45
  }
46
46
  export interface WaitpointRef {
47
- readonly runId: string;
48
47
  readonly waitpointId: string;
48
+ readonly kind?: never;
49
49
  }
50
- export interface WaitpointApprovalOptions {
51
- readonly reason?: string;
52
- }
53
- export interface WaitpointReplyOptions {
54
- readonly text: string;
50
+ export interface WaitpointRespondOptions {
51
+ readonly value?: unknown;
52
+ readonly externalSubject?: string;
53
+ readonly metadata?: Record<string, unknown>;
55
54
  }
56
55
  export interface RunWaitOptions {
57
56
  readonly timeoutMs?: number;
@@ -85,31 +84,21 @@ export type RunEvent = {
85
84
  readonly observed_seq: number;
86
85
  readonly at: string;
87
86
  } | {
88
- readonly type: "approval_request";
89
- readonly run_id: string;
90
- readonly waitpoint_id: string;
91
- readonly message: string;
92
- readonly timeout?: number;
93
- readonly at: string;
94
- } | {
95
- readonly type: "approval_decided";
87
+ readonly type: "waitpoint_request";
96
88
  readonly run_id: string;
97
89
  readonly waitpoint_id: string;
98
- readonly decision: "approved" | "denied";
99
- readonly reason?: string;
100
- readonly at: string;
101
- } | {
102
- readonly type: "message_request";
103
- readonly run_id: string;
104
- readonly waitpoint_id: string;
105
- readonly prompt?: string;
90
+ readonly kind: string;
91
+ readonly displayText: string;
92
+ readonly request: unknown;
106
93
  readonly timeout?: number;
107
94
  readonly at: string;
108
95
  } | {
109
- readonly type: "message_received";
96
+ readonly type: "waitpoint_resolved";
110
97
  readonly run_id: string;
111
98
  readonly waitpoint_id: string;
112
- readonly text: string;
99
+ readonly kind: string;
100
+ readonly resolutionKind: string;
101
+ readonly value: unknown;
113
102
  readonly at: string;
114
103
  } | {
115
104
  readonly type: "emit";
@@ -118,7 +107,7 @@ export type RunEvent = {
118
107
  readonly content: unknown;
119
108
  readonly at: string;
120
109
  } | {
121
- readonly type: "task_complete";
110
+ readonly type: "task_result";
122
111
  readonly run_id: string;
123
112
  readonly exit_code: number;
124
113
  readonly at: string;
@@ -129,15 +118,15 @@ export type RunEvent = {
129
118
  readonly detail?: unknown;
130
119
  readonly at: string;
131
120
  } | {
132
- readonly type: "run_timeout";
121
+ readonly type: "run_cancelled";
133
122
  readonly run_id: string;
134
- readonly elapsed_secs: number;
135
- readonly limit_secs: number;
123
+ readonly reason?: string;
136
124
  readonly at: string;
137
125
  } | {
138
- readonly type: "run_cancelled";
126
+ readonly type: "run_expired";
139
127
  readonly run_id: string;
140
- readonly reason?: string;
128
+ readonly ttl?: string;
129
+ readonly message?: string;
141
130
  readonly at: string;
142
131
  };
143
132
  export interface RunEventRecord {
@@ -164,19 +153,14 @@ export interface LogSnapshot {
164
153
  readonly cursor: string;
165
154
  readonly truncated: boolean;
166
155
  }
167
- export type PendingWaitpointResponse = {
168
- readonly kind: "approval";
156
+ export interface PendingWaitpointResponse {
157
+ readonly kind: "manual" | "delay";
169
158
  readonly waitpoint_id: string;
170
- readonly message?: string | null;
171
159
  readonly timeout?: number | null;
160
+ readonly request?: unknown;
161
+ readonly display_text?: string | null;
172
162
  readonly requested_at: string;
173
- } | {
174
- readonly kind: "message";
175
- readonly waitpoint_id: string;
176
- readonly prompt?: string | null;
177
- readonly timeout?: number | null;
178
- readonly requested_at: string;
179
- };
163
+ }
180
164
  export declare function runHandle<TOutput = unknown>(id: string, taskId: string): RunHandle<TOutput>;
181
165
  export declare function runSnapshot<TOutput = unknown>(snapshot: {
182
166
  readonly id: string;
@@ -0,0 +1,30 @@
1
+ import { type MarkedTask, type MaybePromise, type SecretDecls, type TaskContext, type TaskConfigBase, type WorkspaceSpec } from "./internal.js";
2
+ import type { PayloadSchema } from "./schema/payload.js";
3
+ export interface ScheduledTaskPayload {
4
+ readonly timestamp: Date;
5
+ readonly lastTimestamp?: Date;
6
+ readonly timezone: string;
7
+ readonly scheduleId: string;
8
+ readonly externalId?: string;
9
+ readonly upcoming: readonly Date[];
10
+ }
11
+ export type ScheduleCron = string | {
12
+ readonly pattern: string;
13
+ readonly timezone?: string;
14
+ };
15
+ type DeclarativeScheduleFields = {
16
+ readonly cron: ScheduleCron;
17
+ readonly workspace: WorkspaceSpec;
18
+ readonly secretBindings?: Record<string, string>;
19
+ } | {
20
+ readonly cron?: undefined;
21
+ readonly workspace?: undefined;
22
+ readonly secretBindings?: undefined;
23
+ };
24
+ export type ScheduledTaskConfig<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>> = Omit<TaskConfigBase<TSecrets>, "payload"> & DeclarativeScheduleFields & {
25
+ readonly payload?: never;
26
+ readonly run: (payload: ScheduledTaskPayload, ctx: TaskContext) => MaybePromise<TOutput>;
27
+ };
28
+ export declare function task<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>>(config: ScheduledTaskConfig<TOutput, TSecrets>): MarkedTask<ScheduledTaskPayload, Awaited<TOutput>, TSecrets, typeof scheduledTaskPayloadSchema>;
29
+ declare const scheduledTaskPayloadSchema: PayloadSchema<unknown, ScheduledTaskPayload>;
30
+ export {};
@@ -0,0 +1,40 @@
1
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
2
+ readonly "~standard": {
3
+ readonly version: 1;
4
+ readonly vendor: string;
5
+ validate(value: unknown): StandardSchemaV1.Result<Output> | PromiseLike<StandardSchemaV1.Result<Output>>;
6
+ readonly types?: StandardSchemaV1.Types<Input, Output> | undefined;
7
+ };
8
+ }
9
+ export declare namespace StandardSchemaV1 {
10
+ interface Types<Input = unknown, Output = Input> {
11
+ readonly input: Input;
12
+ readonly output: Output;
13
+ }
14
+ type Result<Output> = SuccessResult<Output> | FailureResult;
15
+ interface SuccessResult<Output> {
16
+ readonly value: Output;
17
+ readonly issues?: undefined;
18
+ }
19
+ interface FailureResult {
20
+ readonly issues: readonly Issue[];
21
+ }
22
+ interface Issue {
23
+ readonly message: string;
24
+ readonly path?: readonly (PropertyKey | PathSegment)[];
25
+ }
26
+ interface PathSegment {
27
+ readonly key: PropertyKey;
28
+ }
29
+ }
30
+ export type PayloadSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
31
+ export type PayloadSchemaInput<TSchema> = TSchema extends StandardSchemaV1<infer Input, any> ? Input : unknown;
32
+ export type PayloadSchemaOutput<TSchema> = TSchema extends StandardSchemaV1<any, infer Output> ? Output : unknown;
33
+ export declare class PayloadSchemaValidationError extends Error {
34
+ readonly issues: readonly StandardSchemaV1.Issue[];
35
+ constructor(label: string, issues: readonly StandardSchemaV1.Issue[]);
36
+ static [Symbol.hasInstance](value: unknown): boolean;
37
+ }
38
+ export declare function assertPayloadSchema(value: unknown, label?: string): asserts value is PayloadSchema;
39
+ export declare function assertStandardSchema(value: unknown, label?: string): asserts value is StandardSchemaV1;
40
+ export declare function parsePayloadWithSchema<TSchema extends StandardSchemaV1<any, any>>(schema: TSchema, payload: unknown, label: string): Promise<PayloadSchemaOutput<TSchema>>;
@@ -3,6 +3,8 @@ export declare const TASK_ID_MAX_LENGTH = 128;
3
3
  export declare const DEFAULT_MAX_DURATION_SECONDS = 900;
4
4
  export declare const MIN_MAX_DURATION_SECONDS = 5;
5
5
  export declare const MAX_DURATION_SECONDS = 86400;
6
+ export declare const QUEUE_NAME_PATTERN: "^[A-Za-z0-9][A-Za-z0-9._/-]{0,255}$";
7
+ export declare const QUEUE_NAME_MAX_LENGTH = 256;
6
8
  export declare class TaskIdError extends Error {
7
9
  readonly name = "TaskIdError";
8
10
  readonly value: string;
@@ -18,3 +20,16 @@ export declare class TaskMaxDurationError extends Error {
18
20
  }
19
21
  export declare function readOptionalMaxDurationSeconds(value: unknown, label?: string): number;
20
22
  export declare function validateOptionalMaxDurationSeconds(value: unknown, label?: string): void;
23
+ export declare class TaskQueueNameError extends Error {
24
+ readonly name = "TaskQueueNameError";
25
+ readonly value: string;
26
+ constructor(value: string);
27
+ }
28
+ export declare class TaskQueueConcurrencyLimitError extends Error {
29
+ readonly name = "TaskQueueConcurrencyLimitError";
30
+ readonly value: unknown;
31
+ constructor(value: unknown);
32
+ }
33
+ export declare function validateQueueName(value: string): void;
34
+ export declare function isValidQueueName(value: string): boolean;
35
+ export declare function validateOptionalQueueConcurrencyLimit(value: unknown): void;
package/dist/task.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- import { type SecretDecls, type Task, type TaskConfig, type TaskOutput, type TaskPayload } from "./internal.js";
2
- export declare function task<TPayload, TOutput, TSecrets extends SecretDecls = Record<never, never>>(config: TaskConfig<TPayload, TOutput, TSecrets>): Task<TPayload, Awaited<TOutput>, TSecrets>;
3
- export type { Task, TaskConfig, TaskOutput, TaskPayload };
1
+ import { type NoPayload, type SecretDecls, type Task, type TaskConfig, type TaskQueueConfig, type TaskConfigWithPayload, type TaskConfigWithoutPayload, type TaskRunOptions, type TaskOutput, type TaskPayload, type TaskTriggerPayload } from "./internal.js";
2
+ import type { PayloadSchema, PayloadSchemaInput, PayloadSchemaOutput } from "./schema/payload.js";
3
+ export declare function task<TPayloadSchema extends PayloadSchema<any, any>, TOutput, TSecrets extends SecretDecls = Record<never, never>>(config: TaskConfigWithPayload<TPayloadSchema, TOutput, TSecrets>): Task<PayloadSchemaOutput<TPayloadSchema>, Awaited<TOutput>, TSecrets, PayloadSchemaInput<TPayloadSchema>>;
4
+ export declare function task<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>>(config: TaskConfigWithoutPayload<TOutput, TSecrets>): Task<NoPayload, Awaited<TOutput>, TSecrets, NoPayload>;
5
+ export declare function queue(config: TaskQueueConfig): TaskQueueConfig;
6
+ export type { NoPayload, Task, TaskConfig, TaskOutput, TaskPayload, TaskQueueConfig, TaskRunOptions, TaskTriggerPayload };
package/dist/trigger.d.ts CHANGED
@@ -1,25 +1,15 @@
1
- import type { SecretDecls, Task, WorkspaceSpec } from "./internal.js";
1
+ import type { AnyTask, NoPayload, SecretDecls, TaskOutput, TaskRunOptions, TaskSecrets, TaskTriggerPayload } from "./internal.js";
2
2
  import { HelmrClient } from "./runtime/client.js";
3
3
  import type { RunHandle } from "./runtime/run.js";
4
4
  export declare function getDefaultClient(): HelmrClient;
5
- export type TriggerSecrets<TSecrets extends SecretDecls> = {
6
- readonly [K in keyof TSecrets]: string;
7
- };
8
- export type TriggerOptions<TPayload, TSecrets extends SecretDecls> = {
9
- /**
10
- * Payload is audit data: Helmr persists it in plaintext in the `run.created`
11
- * event, DB, and events stream. Do not put secret values (tokens, API keys,
12
- * credentials, or PII) in payload; use `secrets:` instead. Use payload for
13
- * business context such as PR numbers, repo names, ticket ids, and other
14
- * identifiers.
15
- */
16
- readonly payload: TPayload;
17
- readonly workspace: WorkspaceSpec;
18
- } & ([keyof TSecrets] extends [never] ? {
19
- readonly secrets?: Record<never, never>;
20
- } : {
21
- readonly secrets: TriggerSecrets<TSecrets>;
22
- });
5
+ export type TriggerOptions<TSecrets extends SecretDecls> = TaskRunOptions<TSecrets>;
6
+ export type TriggerArgs<TTask extends AnyTask> = [
7
+ TaskTriggerPayload<TTask>
8
+ ] extends [NoPayload] ? [id: string, opts: TriggerOptions<TaskSecrets<TTask>>] : [id: string, payload: TaskTriggerPayload<TTask>, opts: TriggerOptions<TaskSecrets<TTask>>];
9
+ export type TaskTriggerArgs<TTask extends AnyTask> = [
10
+ TaskTriggerPayload<TTask>
11
+ ] extends [NoPayload] ? [opts: TriggerOptions<TaskSecrets<TTask>>] : [payload: TaskTriggerPayload<TTask>, opts: TriggerOptions<TaskSecrets<TTask>>];
23
12
  export declare const tasks: {
24
- trigger<TPayload, TOutput, TSecrets extends SecretDecls>(task: Task<TPayload, TOutput, TSecrets>, opts: TriggerOptions<TPayload, TSecrets>): Promise<RunHandle<TOutput>>;
13
+ trigger<TTask extends AnyTask>(...args: TriggerArgs<TTask>): Promise<RunHandle<TaskOutput<TTask>>>;
25
14
  };
15
+ export declare function triggerTask<TTask extends AnyTask>(task: TTask, ...args: TaskTriggerArgs<TTask>): Promise<RunHandle<TaskOutput<TTask>>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helmr/sdk",
3
- "version": "0.1.1-rc.4",
3
+ "version": "0.1.1-rc.5",
4
4
  "description": "TypeScript SDK for authoring and triggering Helmr tasks.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -43,6 +43,6 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@bufbuild/protobuf": "^2.11.0",
46
- "@helmr/proto": "0.1.1-rc.4"
46
+ "@helmr/proto": "0.1.1-rc.5"
47
47
  }
48
48
  }