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

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 CHANGED
@@ -22,7 +22,7 @@ Schemes such as `env:` and `file:` are local runner sources and are rejected for
22
22
  External TypeScript processes create runs with `task.trigger()` or the id-based `client.tasks.trigger()`. Triggering returns a lightweight `RunHandle`; retrieve or wait on that handle to get a `RunSnapshot`.
23
23
 
24
24
  ```ts
25
- import { HelmrClient, workspace } from "@helmr/sdk"
25
+ import { HelmrClient } from "@helmr/sdk"
26
26
  import { impl } from "./tasks/impl"
27
27
 
28
28
  const client = new HelmrClient({
@@ -33,9 +33,6 @@ const client = new HelmrClient({
33
33
  const handle = await client.tasks.trigger<typeof impl>(
34
34
  "impl",
35
35
  { issue: 123 },
36
- {
37
- workspace: workspace.github("OWNER/REPO", { ref: "main", subpath: "tasks" }),
38
- },
39
36
  )
40
37
 
41
38
  const current = await client.runs.retrieve(handle)
package/dist/compile.js CHANGED
@@ -27,7 +27,6 @@ import {
27
27
  SourceFileRefSchema,
28
28
  TaskSpecSchema,
29
29
  TaskScheduleSpecSchema,
30
- TaskScheduleWorkspaceSpecSchema,
31
30
  UserSchema,
32
31
  WorkdirSchema,
33
32
  WorkspaceRuntimeBindingSchema
@@ -124,7 +123,8 @@ function compile(opts) {
124
123
  ...resources ? {
125
124
  resources: create(ResourcesSchema, {
126
125
  ...resources.cpu === undefined ? {} : { cpu: resources.cpu },
127
- ...resources.memory === undefined ? {} : { memory: resources.memory }
126
+ ...resources.memory === undefined ? {} : { memory: resources.memory },
127
+ ...resources.disk === undefined ? {} : { disk: resources.disk }
128
128
  })
129
129
  } : {}
130
130
  });
@@ -160,11 +160,6 @@ function compileTaskSchedules(schedule) {
160
160
  id: "",
161
161
  cron: schedule.cron,
162
162
  timezone: schedule.timezone ?? "UTC",
163
- workspace: create(TaskScheduleWorkspaceSpecSchema, {
164
- repository: schedule.workspace.repository,
165
- ref: schedule.workspace.ref,
166
- subpath: schedule.workspace.subpath ?? ""
167
- }),
168
163
  secretBindings: { ...schedule.secretBindings }
169
164
  })
170
165
  ];
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ConcurrentWaitError, validateSecretName, type CacheBuilder, type CacheMount, type CacheMountBinding, type EmitContent, type EmitEvent, type ImageBuilder, type ImageRunOptions, type NoPayload, type Placement, type SandboxBuilder, type SecretDecls, type SecretMountBinding, type SourceCapabilities, type SourceDirRef, type SourceDirectoryOptions, type SourceFileRef, type TaskContext, type TaskSource, type TaskWorkspace, type GitHubRefKind, type GitHubPullRequestMetadata, type GitHubTaskSource, type TaskOutput, type TaskPayload, type TaskTriggerPayload, type WaitCapabilities, type WaitForInput, type WaitJson, type WaitOptions, type WaitResolution, type WaitManualOptions, type WaitUntilInput, type WorkspaceCapabilities, type WorkspaceSpec } from "./internal.js";
1
+ import { ConcurrentWaitError, validateSecretName, type CacheBuilder, type CacheMount, type CacheMountBinding, type EmitContent, type EmitEvent, type ImageBuilder, type ImageRunOptions, type NoPayload, type Placement, type SandboxBuilder, type SecretDecls, type SecretMountBinding, type SourceCapabilities, type SourceDirRef, type SourceDirectoryOptions, type SourceFileRef, type TaskContext, type TaskWorkspace, type TaskOutput, type TaskPayload, type TaskTriggerPayload, type WaitCapabilities, type WaitForInput, type WaitJson, type WaitOptions, type WaitResolution, type WaitManualOptions, type WaitUntilInput } from "./internal.js";
2
2
  import { PayloadSchemaValidationError } from "./schema/payload.js";
3
3
  import { idempotencyKeys } from "./idempotency.js";
4
4
  export type { IdempotencyKey, IdempotencyKeyCreateOptions, IdempotencyKeyInput, IdempotencyKeyScope } from "./idempotency.js";
@@ -18,7 +18,6 @@ export type { HelmrConfig, HelmrConfigInput, Placement, SecretDecls, Task, TaskC
18
18
  export declare const image: (id: string) => ImageBuilder;
19
19
  export declare const cache: (id: string) => CacheBuilder;
20
20
  export declare const source: SourceCapabilities;
21
- export declare const workspace: WorkspaceCapabilities;
22
21
  export { HelmrClient };
23
22
  export { validateSecretName };
24
23
  export declare const runs: {
@@ -49,4 +48,4 @@ export declare const schedules: Readonly<{
49
48
  delete: (id: string, opts?: import("./index.js").RetrieveScheduleOptions | undefined) => Promise<void>;
50
49
  }>;
51
50
  export type { ScheduleCron, ScheduledTaskConfig, ScheduledTaskPayload, };
52
- export type { CacheBuilder, CacheMount, CacheMountBinding, EmitContent, EmitEvent, ImageBuilder, ImageRunOptions, SandboxBuilder, SecretMountBinding, SourceCapabilities, SourceDirRef, SourceDirectoryOptions, SourceFileRef, WorkspaceCapabilities, WorkspaceSpec, TaskContext, TaskSource, TaskWorkspace, GitHubRefKind, GitHubPullRequestMetadata, GitHubTaskSource, };
51
+ export type { CacheBuilder, CacheMount, CacheMountBinding, EmitContent, EmitEvent, ImageBuilder, ImageRunOptions, SandboxBuilder, SecretMountBinding, SourceCapabilities, SourceDirRef, SourceDirectoryOptions, SourceFileRef, TaskContext, TaskWorkspace, };
package/dist/index.js CHANGED
@@ -304,9 +304,6 @@ function validateTaskSchedule(taskId, value) {
304
304
  if (value.timezone !== undefined && value.timezone.trim() === "") {
305
305
  throw new Error(`task ${JSON.stringify(taskId)} schedule timezone must not be empty`);
306
306
  }
307
- if (value.workspace.kind !== "github") {
308
- throw new Error(`task ${JSON.stringify(taskId)} schedule workspace must be workspace.github(...)`);
309
- }
310
307
  if (value.secretBindings !== undefined) {
311
308
  if (value.secretBindings === null || typeof value.secretBindings !== "object" || Array.isArray(value.secretBindings)) {
312
309
  throw new Error(`task ${JSON.stringify(taskId)} schedule secretBindings must be an object`);
@@ -501,7 +498,8 @@ class SandboxBuilderImpl {
501
498
  resources(opts) {
502
499
  const resourceSpec = {
503
500
  ...opts.cpu === undefined ? {} : { cpu: opts.cpu },
504
- ...opts.memory === undefined ? {} : { memory: opts.memory }
501
+ ...opts.memory === undefined ? {} : { memory: opts.memory },
502
+ ...opts.disk === undefined ? {} : { disk: opts.disk }
505
503
  };
506
504
  return new SandboxBuilderImpl(this.id, this.imageBuilder, this.workspaceBinding, resourceSpec);
507
505
  }
@@ -674,15 +672,6 @@ function runStatus(status) {
674
672
  }
675
673
  }
676
674
 
677
- // sdk/typescript/src/runtime/source.ts
678
- function runWorkspaceFromSpec(spec) {
679
- return {
680
- repository: spec.repository,
681
- ref: spec.ref,
682
- ...spec.subpath === undefined ? {} : { subpath: spec.subpath }
683
- };
684
- }
685
-
686
675
  // sdk/typescript/src/runtime/client.ts
687
676
  var MAX_SSE_BUFFER_CHARS = 1024 * 1024;
688
677
  var triggerTaskClientMethod = Symbol.for("helmr.sdk.client.triggerTask");
@@ -744,7 +733,6 @@ class HelmrClient {
744
733
  return await this.#triggerRun(task.id, payload, opts, readOptionalMaxDurationSeconds(task.maxDuration));
745
734
  }
746
735
  async#triggerRun(taskId, payload, opts, maxDurationSeconds) {
747
- const runWorkspace = runWorkspaceFromSpec(opts.workspace);
748
736
  const runOptions = {
749
737
  ...opts.deploymentId === undefined ? {} : { deployment_id: opts.deploymentId },
750
738
  ...opts.version === undefined ? {} : { version: opts.version },
@@ -761,7 +749,6 @@ class HelmrClient {
761
749
  task_id: taskId,
762
750
  secrets: opts.secrets ?? {},
763
751
  ...payload === undefined ? {} : { payload },
764
- workspace: runWorkspace,
765
752
  ...Object.keys(runOptions).length === 0 ? {} : { options: runOptions }
766
753
  }),
767
754
  headers: { "content-type": "application/json" }
@@ -1032,7 +1019,6 @@ function scheduleCreateBody(opts) {
1032
1019
  cron: opts.cron,
1033
1020
  ...opts.timezone === undefined ? {} : { timezone: opts.timezone },
1034
1021
  ...opts.active === undefined ? {} : { active: opts.active },
1035
- workspace: runWorkspaceFromSpec(opts.workspace),
1036
1022
  ...opts.secretBindings === undefined ? {} : { secret_bindings: opts.secretBindings },
1037
1023
  ...opts.options === undefined ? {} : { options: runOptionsBody(opts.options) }
1038
1024
  };
@@ -1072,7 +1058,6 @@ function scheduleFromResponse(response) {
1072
1058
  active: response.active,
1073
1059
  status: response.status,
1074
1060
  ...response.last_error === undefined || response.last_error === "" ? {} : { lastError: response.last_error },
1075
- ..."workspace" in response ? { workspace: response.workspace } : {},
1076
1061
  ...response.next_scheduled_at === undefined ? {} : { nextScheduledAt: response.next_scheduled_at },
1077
1062
  ...response.last_scheduled_at === undefined ? {} : { lastScheduledAt: response.last_scheduled_at },
1078
1063
  createdAt: response.created_at,
@@ -1483,15 +1468,10 @@ function queue(config) {
1483
1468
 
1484
1469
  // sdk/typescript/src/schedules.ts
1485
1470
  function task2(config) {
1486
- const { cron, workspace, secretBindings, ...taskConfig } = config;
1487
- const taskId = config.id;
1488
- if (cron !== undefined && workspace === undefined) {
1489
- throw new Error(`task ${JSON.stringify(taskId)} schedule workspace is required`);
1490
- }
1471
+ const { cron, secretBindings, ...taskConfig } = config;
1491
1472
  const schedule = cron === undefined ? undefined : {
1492
1473
  cron: typeof cron === "string" ? cron : cron.pattern,
1493
1474
  ...typeof cron === "string" || cron.timezone === undefined ? {} : { timezone: cron.timezone },
1494
- workspace,
1495
1475
  ...secretBindings === undefined ? {} : { secretBindings }
1496
1476
  };
1497
1477
  const marked = markScheduledTask({ ...taskConfig, payload: scheduledTaskPayloadSchema }, schedule);
@@ -1568,27 +1548,6 @@ var source = {
1568
1548
  return new SourceDirRefImpl(path, opts?.ignore ? [...opts.ignore] : []);
1569
1549
  }
1570
1550
  };
1571
- var workspace = {
1572
- github(repo, opts) {
1573
- const [org, name, extra] = repo.split("/");
1574
- if (!org || !name || extra !== undefined) {
1575
- throw new Error('workspace.github() repo must be "org/repo"');
1576
- }
1577
- const ref = opts.ref.trim();
1578
- if (!ref) {
1579
- throw new Error("workspace.github() ref is required");
1580
- }
1581
- if (ref.includes("\x00")) {
1582
- throw new Error("workspace.github() ref must not contain NUL");
1583
- }
1584
- return {
1585
- kind: "github",
1586
- repository: repo,
1587
- ref,
1588
- ...opts.subpath === undefined ? {} : { subpath: opts.subpath }
1589
- };
1590
- }
1591
- };
1592
1551
  var runs = new Proxy({}, {
1593
1552
  get(_target, property, receiver) {
1594
1553
  return Reflect.get(getDefaultClient().runs, property, receiver);
@@ -1610,7 +1569,6 @@ var schedules = Object.freeze({
1610
1569
  delete: (...args) => getDefaultClient().schedules.delete(...args)
1611
1570
  });
1612
1571
  export {
1613
- workspace,
1614
1572
  waitpoints,
1615
1573
  validateSecretName,
1616
1574
  tasks,
@@ -17,33 +17,6 @@ export interface SecretMountBinding {
17
17
  export interface SourceDirectoryOptions {
18
18
  readonly ignore?: readonly string[];
19
19
  }
20
- export interface WorkspaceSpec {
21
- readonly kind: "github";
22
- readonly repository: string;
23
- readonly ref: string;
24
- readonly subpath?: string;
25
- }
26
- export type GitHubRefKind = "branch" | "tag" | "sha" | "pull_request" | "unknown";
27
- export interface GitHubPullRequestMetadata {
28
- readonly number: number;
29
- readonly baseRef: string;
30
- readonly baseSha: string;
31
- readonly headRef: string;
32
- readonly headSha: string;
33
- }
34
- export interface GitHubTaskSource {
35
- readonly kind: "github";
36
- readonly repository: string;
37
- readonly requestedRef: string;
38
- readonly resolvedSha: string;
39
- readonly refKind?: GitHubRefKind;
40
- readonly refName?: string;
41
- readonly fullRef?: string;
42
- readonly subpath?: string;
43
- readonly defaultBranch?: string;
44
- readonly pullRequest?: GitHubPullRequestMetadata;
45
- }
46
- export type TaskSource = GitHubTaskSource;
47
20
  export interface TaskWorkspace {
48
21
  readonly path: string;
49
22
  readonly projectPath: string;
@@ -59,12 +32,6 @@ export interface SourceCapabilities {
59
32
  file(path: string): SourceFileRef;
60
33
  directory(path: string, opts?: SourceDirectoryOptions): SourceDirRef;
61
34
  }
62
- export interface WorkspaceCapabilities {
63
- github(repo: string, opts: {
64
- readonly ref: string;
65
- readonly subpath?: string;
66
- }): WorkspaceSpec;
67
- }
68
35
  export type WaitJson = null | boolean | number | string | readonly WaitJson[] | {
69
36
  readonly [key: string]: WaitJson;
70
37
  };
@@ -130,7 +97,6 @@ export interface TaskContext {
130
97
  readonly task: {
131
98
  readonly id: string;
132
99
  };
133
- readonly source: TaskSource;
134
100
  readonly workspace: TaskWorkspace;
135
101
  }
136
102
  export type EmitContent = {
@@ -177,10 +143,8 @@ export interface InternalTaskScheduleConfig {
177
143
  readonly cron: string;
178
144
  readonly timezone?: string;
179
145
  readonly secretBindings?: Record<string, string>;
180
- readonly workspace: WorkspaceSpec;
181
146
  }
182
147
  export type TaskRunOptions<TSecrets extends SecretDecls> = {
183
- readonly workspace: WorkspaceSpec;
184
148
  readonly deploymentId?: string;
185
149
  readonly version?: string;
186
150
  readonly queue?: string;
@@ -272,6 +236,7 @@ export interface SandboxBuilder {
272
236
  resources(opts: {
273
237
  readonly cpu?: number;
274
238
  readonly memory?: string;
239
+ readonly disk?: string;
275
240
  }): SandboxBuilder;
276
241
  }
277
242
  export type ImageBuildStep = {
@@ -308,6 +273,7 @@ export interface SandboxWorkspace {
308
273
  export interface SandboxResources {
309
274
  readonly cpu?: number;
310
275
  readonly memory?: string;
276
+ readonly disk?: string;
311
277
  }
312
278
  export type MarkedTask<TPayload, TOutput, TSecrets extends SecretDecls, TPayloadSchema extends PayloadSchema<any, any> | undefined> = TPayloadSchema extends PayloadSchema<any, any> ? Task<PayloadSchemaOutput<TPayloadSchema>, Awaited<TOutput>, TSecrets, PayloadSchemaInput<TPayloadSchema>> : Task<NoPayload, Awaited<TOutput>, TSecrets, NoPayload>;
313
279
  export declare function markTask<TPayload, TOutput, TSecrets extends SecretDecls, TPayloadSchema extends PayloadSchema<any, any> | undefined>(config: TaskConfig<TPayload, TOutput, TSecrets, TPayloadSchema>): MarkedTask<TPayload, TOutput, TSecrets, TPayloadSchema>;
@@ -353,6 +319,7 @@ export declare class SandboxBuilderImpl implements SandboxBuilder {
353
319
  resources(opts: {
354
320
  readonly cpu?: number;
355
321
  readonly memory?: string;
322
+ readonly disk?: string;
356
323
  }): SandboxBuilder;
357
324
  }
358
325
  export declare class SourceFileRefImpl implements SourceFileRef {
package/dist/internal.js CHANGED
@@ -304,9 +304,6 @@ function validateTaskSchedule(taskId, value) {
304
304
  if (value.timezone !== undefined && value.timezone.trim() === "") {
305
305
  throw new Error(`task ${JSON.stringify(taskId)} schedule timezone must not be empty`);
306
306
  }
307
- if (value.workspace.kind !== "github") {
308
- throw new Error(`task ${JSON.stringify(taskId)} schedule workspace must be workspace.github(...)`);
309
- }
310
307
  if (value.secretBindings !== undefined) {
311
308
  if (value.secretBindings === null || typeof value.secretBindings !== "object" || Array.isArray(value.secretBindings)) {
312
309
  throw new Error(`task ${JSON.stringify(taskId)} schedule secretBindings must be an object`);
@@ -517,7 +514,8 @@ class SandboxBuilderImpl {
517
514
  resources(opts) {
518
515
  const resourceSpec = {
519
516
  ...opts.cpu === undefined ? {} : { cpu: opts.cpu },
520
- ...opts.memory === undefined ? {} : { memory: opts.memory }
517
+ ...opts.memory === undefined ? {} : { memory: opts.memory },
518
+ ...opts.disk === undefined ? {} : { disk: opts.disk }
521
519
  };
522
520
  return new SandboxBuilderImpl(this.id, this.imageBuilder, this.workspaceBinding, resourceSpec);
523
521
  }
@@ -1,4 +1,4 @@
1
- import { type AnyTask, type NoPayload, type SecretDecls, type TaskOutput, type TaskRunOptions, type TaskSecrets, type TaskTriggerPayload, type WorkspaceSpec } from "../internal.js";
1
+ import { type AnyTask, type NoPayload, type SecretDecls, type TaskOutput, type TaskRunOptions, type TaskSecrets, type TaskTriggerPayload } from "../internal.js";
2
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;
@@ -47,7 +47,6 @@ export interface ScheduleCreateOptions {
47
47
  readonly cron: string;
48
48
  readonly timezone?: string;
49
49
  readonly active?: boolean;
50
- readonly workspace: WorkspaceSpec;
51
50
  readonly secretBindings?: Record<string, string>;
52
51
  readonly options?: ScheduleRunOptions;
53
52
  }
@@ -63,12 +62,6 @@ export interface ScheduleRunOptions {
63
62
  readonly ttl?: string;
64
63
  readonly maxDurationSeconds?: number;
65
64
  }
66
- export interface ScheduleWorkspace {
67
- readonly repository?: string;
68
- readonly ref?: string;
69
- readonly sha?: string;
70
- readonly subpath?: string;
71
- }
72
65
  export interface ListSchedulesOptions {
73
66
  readonly projectId?: string;
74
67
  readonly environmentId?: string;
@@ -92,7 +85,6 @@ export interface Schedule {
92
85
  readonly active: boolean;
93
86
  readonly status: "active" | "inactive" | "errored";
94
87
  readonly lastError?: string;
95
- readonly workspace?: ScheduleWorkspace;
96
88
  readonly nextScheduledAt?: string;
97
89
  readonly lastScheduledAt?: string;
98
90
  readonly createdAt: string;
@@ -1,4 +1,4 @@
1
- import { type MarkedTask, type MaybePromise, type SecretDecls, type TaskContext, type TaskConfigBase, type WorkspaceSpec } from "./internal.js";
1
+ import { type MarkedTask, type MaybePromise, type SecretDecls, type TaskContext, type TaskConfigBase } from "./internal.js";
2
2
  import type { PayloadSchema } from "./schema/payload.js";
3
3
  export interface ScheduledTaskPayload {
4
4
  readonly timestamp: Date;
@@ -14,11 +14,9 @@ export type ScheduleCron = string | {
14
14
  };
15
15
  type DeclarativeScheduleFields = {
16
16
  readonly cron: ScheduleCron;
17
- readonly workspace: WorkspaceSpec;
18
17
  readonly secretBindings?: Record<string, string>;
19
18
  } | {
20
19
  readonly cron?: undefined;
21
- readonly workspace?: undefined;
22
20
  readonly secretBindings?: undefined;
23
21
  };
24
22
  export type ScheduledTaskConfig<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>> = Omit<TaskConfigBase<TSecrets>, "payload"> & DeclarativeScheduleFields & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helmr/sdk",
3
- "version": "0.1.1-rc.5",
3
+ "version": "0.1.1-rc.6",
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.5"
46
+ "@helmr/proto": "0.1.1-rc.6"
47
47
  }
48
48
  }
@@ -1,7 +0,0 @@
1
- import type { WorkspaceSpec } from "../internal.js";
2
- export type RunWorkspace = {
3
- readonly repository: string;
4
- readonly ref: string;
5
- readonly subpath?: string;
6
- };
7
- export declare function runWorkspaceFromSpec(spec: WorkspaceSpec): RunWorkspace;