@helmr/sdk 0.1.0-preview.g52eb0eef.b35190749915

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.
Files changed (47) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +65 -0
  3. package/dist/actor.d.ts +3 -0
  4. package/dist/client-actor.d.ts +32 -0
  5. package/dist/client-deployment.d.ts +30 -0
  6. package/dist/client-sandbox.d.ts +26 -0
  7. package/dist/client-schedule.d.ts +44 -0
  8. package/dist/client-secret.d.ts +51 -0
  9. package/dist/client-session.d.ts +38 -0
  10. package/dist/client-workspace.d.ts +36 -0
  11. package/dist/client.d.ts +153 -0
  12. package/dist/config.d.ts +11 -0
  13. package/dist/contract.d.ts +341 -0
  14. package/dist/definitions.d.ts +42 -0
  15. package/dist/fuzzy.d.ts +1 -0
  16. package/dist/fuzzy.js +29 -0
  17. package/dist/image.d.ts +63 -0
  18. package/dist/index.d.ts +29 -0
  19. package/dist/index.js +3029 -0
  20. package/dist/internal/abort.d.ts +1 -0
  21. package/dist/internal/definition-query.d.ts +10 -0
  22. package/dist/internal/id.d.ts +1 -0
  23. package/dist/internal/jsoncanon.d.ts +5 -0
  24. package/dist/internal/origin.d.ts +1 -0
  25. package/dist/internal/program.d.ts +10 -0
  26. package/dist/internal/run-failure.d.ts +2 -0
  27. package/dist/internal/run-handle.d.ts +3 -0
  28. package/dist/internal/runtime.d.ts +43 -0
  29. package/dist/internal/session.d.ts +5 -0
  30. package/dist/internal/strings.d.ts +1 -0
  31. package/dist/internal/timestamp.d.ts +1 -0
  32. package/dist/internal/utf8.d.ts +3 -0
  33. package/dist/internal.d.ts +13 -0
  34. package/dist/internal.js +994 -0
  35. package/dist/logger.d.ts +9 -0
  36. package/dist/metadata.d.ts +6 -0
  37. package/dist/request.d.ts +3 -0
  38. package/dist/schedules.d.ts +33 -0
  39. package/dist/schema/payload.d.ts +39 -0
  40. package/dist/schema/task.d.ts +3 -0
  41. package/dist/secret.d.ts +1 -0
  42. package/dist/session.d.ts +5 -0
  43. package/dist/task.d.ts +2 -0
  44. package/dist/timers.d.ts +6 -0
  45. package/dist/tokens.d.ts +77 -0
  46. package/dist/workspace.d.ts +142 -0
  47. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Helmr
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ https://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # SDK
2
+
3
+ User-facing SDK packages live here. `typescript/` contains `@helmr/sdk` for
4
+ declaration authoring, managed runtime operations, and the external
5
+ `HelmrClient`.
6
+
7
+ Runtime adapter internals, VM details, and host-specific code stay outside the
8
+ SDK surface.
9
+
10
+ ## External client
11
+
12
+ Declaration-backed resources use a runtime declared ID and a type-only
13
+ definition generic:
14
+
15
+ ```ts
16
+ import { HelmrClient } from "@helmr/sdk"
17
+ import type { issueTask } from "./definitions"
18
+
19
+ const client = new HelmrClient({
20
+ url: process.env.HELMR_API_URL!,
21
+ apiKey: process.env.HELMR_API_KEY!,
22
+ })
23
+
24
+ const workspace = await client.sandboxes.createWorkspace(
25
+ "issue-workspace",
26
+ {
27
+ key: "issue:123",
28
+ idempotencyKey: "issue:123:workspace",
29
+ },
30
+ )
31
+
32
+ const run = await client.tasks.start<typeof issueTask>(
33
+ "issue-task",
34
+ {
35
+ payload: { issue: 123 },
36
+ workspace,
37
+ idempotencyKey: "issue:123:run",
38
+ },
39
+ )
40
+
41
+ const result = await client.runs.wait(run)
42
+ const logs = await client.runs.logs(run.id)
43
+ const events = await client.runs.events(run.id)
44
+ ```
45
+
46
+ Task start requires an existing Workspace. The Task Run payload is plaintext
47
+ audit data. Place Secret values when creating the Workspace; never put them in
48
+ payload.
49
+
50
+ ## Tokens
51
+
52
+ Tokens are independent durable external-completion resources. Task code can
53
+ create and wait on one; a trusted backend can also create or complete one
54
+ through `client.tokens`. Multiple Runs in the same Environment may wait on the
55
+ same Token.
56
+
57
+ ```ts
58
+ const token = await tokens.create({ timeout: "1h" })
59
+ const decision = await token.wait({ schema: approvalSchema })
60
+
61
+ await client.tokens.complete(tokenId, {
62
+ result: { approved: true },
63
+ idempotencyKey: "approval:123",
64
+ })
65
+ ```
@@ -0,0 +1,3 @@
1
+ export { actor } from "./definitions.js";
2
+ export { sessions } from "./session.js";
3
+ export type { SessionClosedError, ActorConfig, Actor, ActorSession, ActorSessionInput, ActorSessionOutput, ActorSessionOutputAppendOptions, ActorSessionOutputSequenceOptions, ActorSessionReceiveOptions, SessionInputMetadata, SessionInputRecord, SessionInputSendRequest, ActorSessionInputResult, SessionInputSource, SessionFailure, SessionStatus, SessionCloseRequest, SessionCloseReceipt, SessionOutputRecord, SessionOutputQuery, ActorSessionReceive, SessionRef, ActorStartOptions, ActorStartResult, Session, WaitTimeoutError, } from "./contract.js";
@@ -0,0 +1,32 @@
1
+ import type { ActorStartResult, ActorStartOptions, CursorPage } from "./contract.js";
2
+ import type { RequestOptions } from "./request.js";
3
+ export type ActorStartRequest = Omit<ActorStartOptions, "signal">;
4
+ export interface ActorRetrieveQuery {
5
+ readonly deploymentId?: string;
6
+ }
7
+ export interface ActorListQuery extends ActorRetrieveQuery {
8
+ readonly cursor?: string;
9
+ readonly limit?: number;
10
+ }
11
+ export interface ActorListItem {
12
+ readonly id: string;
13
+ }
14
+ export interface ActorInfo extends ActorListItem {
15
+ readonly deploymentId: string;
16
+ }
17
+ export interface ActorPage extends CursorPage<ActorListItem> {
18
+ readonly deploymentId: string;
19
+ }
20
+ export interface ClientActorsApi {
21
+ retrieve(id: string, query?: ActorRetrieveQuery, options?: RequestOptions): Promise<ActorInfo>;
22
+ list(query?: ActorListQuery, options?: RequestOptions): Promise<ActorPage>;
23
+ start(id: string, request: ActorStartRequest, options?: RequestOptions): Promise<ActorStartResult>;
24
+ }
25
+ interface ActorTransport {
26
+ request(method: "GET" | "POST", path: string, options?: Readonly<{
27
+ body?: unknown;
28
+ signal?: AbortSignal;
29
+ }>): Promise<unknown>;
30
+ }
31
+ export declare function createClientActors(transport: ActorTransport): ClientActorsApi;
32
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { CursorPage } from "./contract.js";
2
+ import type { RequestOptions } from "./request.js";
3
+ export interface Deployment {
4
+ readonly id: string;
5
+ readonly version: string;
6
+ readonly bundleDigest: string;
7
+ readonly createdAt: string;
8
+ }
9
+ export interface DeploymentListItem {
10
+ readonly id: string;
11
+ readonly version: string;
12
+ readonly bundleDigest: string;
13
+ readonly createdAt: string;
14
+ }
15
+ export interface DeploymentListQuery {
16
+ readonly cursor?: string;
17
+ readonly limit?: number;
18
+ }
19
+ export interface ClientDeploymentsApi {
20
+ list(query?: DeploymentListQuery, options?: RequestOptions): Promise<CursorPage<DeploymentListItem>>;
21
+ current(options?: RequestOptions): Promise<Deployment | null>;
22
+ retrieve(deploymentId: string, options?: RequestOptions): Promise<Deployment>;
23
+ }
24
+ interface DeploymentTransport {
25
+ request(method: "GET", path: string, options?: Readonly<{
26
+ signal?: AbortSignal;
27
+ }>): Promise<unknown>;
28
+ }
29
+ export declare function createClientDeployments(transport: DeploymentTransport): ClientDeploymentsApi;
30
+ export {};
@@ -0,0 +1,26 @@
1
+ import { type WorkspaceTransport } from "./client-workspace.js";
2
+ import type { CursorPage } from "./contract.js";
3
+ import type { RequestOptions } from "./request.js";
4
+ import { type WorkspaceCreateRequest, type WorkspaceRef } from "./workspace.js";
5
+ export interface SandboxRetrieveQuery {
6
+ readonly deploymentId?: string;
7
+ }
8
+ export interface SandboxListQuery extends SandboxRetrieveQuery {
9
+ readonly cursor?: string;
10
+ readonly limit?: number;
11
+ }
12
+ export interface SandboxListItem {
13
+ readonly id: string;
14
+ }
15
+ export interface SandboxInfo extends SandboxListItem {
16
+ readonly deploymentId: string;
17
+ }
18
+ export interface SandboxPage extends CursorPage<SandboxListItem> {
19
+ readonly deploymentId: string;
20
+ }
21
+ export interface ClientSandboxesApi {
22
+ retrieve(id: string, query?: SandboxRetrieveQuery, options?: RequestOptions): Promise<SandboxInfo>;
23
+ list(query?: SandboxListQuery, options?: RequestOptions): Promise<SandboxPage>;
24
+ createWorkspace(id: string, request?: WorkspaceCreateRequest, options?: RequestOptions): Promise<WorkspaceRef>;
25
+ }
26
+ export declare function createClientSandboxes(transport: WorkspaceTransport): ClientSandboxesApi;
@@ -0,0 +1,44 @@
1
+ import type { CursorPage, JsonValue } from "./contract.js";
2
+ import type { RequestOptions } from "./request.js";
3
+ export interface ScheduleFailure {
4
+ readonly code: string;
5
+ readonly message: string;
6
+ readonly details: Readonly<Record<string, JsonValue>>;
7
+ }
8
+ export type ScheduleStatus = "active" | "errored" | "archived";
9
+ export interface Schedule {
10
+ readonly id: string;
11
+ readonly taskId: string;
12
+ readonly generation: number;
13
+ readonly effectiveFrom: string;
14
+ readonly cron: Readonly<{
15
+ pattern: string;
16
+ timezone: string;
17
+ }>;
18
+ readonly status: ScheduleStatus;
19
+ readonly lastFailure?: ScheduleFailure;
20
+ readonly nextFireAt?: string;
21
+ readonly lastFireAt?: string;
22
+ readonly createdAt: string;
23
+ readonly updatedAt: string;
24
+ }
25
+ export type ScheduleListQuery = Readonly<{
26
+ taskId?: never;
27
+ cursor?: string;
28
+ limit?: number;
29
+ }> | Readonly<{
30
+ taskId: string;
31
+ cursor?: never;
32
+ limit?: never;
33
+ }>;
34
+ export interface ClientSchedulesApi {
35
+ retrieve(scheduleId: string, options?: RequestOptions): Promise<Schedule>;
36
+ list(query?: ScheduleListQuery, options?: RequestOptions): Promise<CursorPage<Schedule>>;
37
+ }
38
+ interface ScheduleTransport {
39
+ request(method: "GET", path: string, options?: Readonly<{
40
+ signal?: AbortSignal;
41
+ }>): Promise<unknown>;
42
+ }
43
+ export declare function createClientSchedules(transport: ScheduleTransport): ClientSchedulesApi;
44
+ export {};
@@ -0,0 +1,51 @@
1
+ import type { CursorPage } from "./contract.js";
2
+ import type { RequestOptions } from "./request.js";
3
+ export type SecretStatus = "active" | "revoked";
4
+ export interface SecretCreateRequest {
5
+ readonly name: string;
6
+ readonly value: string;
7
+ readonly idempotencyKey?: string;
8
+ }
9
+ export interface SecretRotateRequest {
10
+ readonly value: string;
11
+ readonly idempotencyKey: string;
12
+ }
13
+ export interface SecretRevokeRequest {
14
+ readonly idempotencyKey: string;
15
+ }
16
+ export interface Secret {
17
+ readonly id: string;
18
+ readonly name: string;
19
+ readonly status: SecretStatus;
20
+ readonly createdAt: string;
21
+ readonly rotatedAt?: string;
22
+ readonly revokedAt?: string;
23
+ }
24
+ export interface SecretRef {
25
+ readonly id: string;
26
+ rotate(request: SecretRotateRequest, options?: RequestOptions): Promise<Secret>;
27
+ revoke(request: SecretRevokeRequest, options?: RequestOptions): Promise<Secret>;
28
+ }
29
+ export interface ClientSecretsApi {
30
+ create(request: SecretCreateRequest, options?: RequestOptions): Promise<Secret>;
31
+ retrieve(id: string, options?: RequestOptions): Promise<Secret>;
32
+ ref(id: string): SecretRef;
33
+ list(query?: SecretListQuery, options?: RequestOptions): Promise<CursorPage<Secret>>;
34
+ }
35
+ export type SecretListQuery = Readonly<{
36
+ name?: never;
37
+ cursor?: string;
38
+ limit?: number;
39
+ }> | Readonly<{
40
+ name: string;
41
+ cursor?: never;
42
+ limit?: never;
43
+ }>;
44
+ interface SecretTransport {
45
+ request(method: "GET" | "POST", path: string, options?: Readonly<{
46
+ body?: unknown;
47
+ signal?: AbortSignal;
48
+ }>): Promise<unknown>;
49
+ }
50
+ export declare function createClientSecrets(transport: SecretTransport): ClientSecretsApi;
51
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { CursorPage, SessionInputPage, SessionInputQuery, SessionRef, SessionStatus, Session } from "./contract.js";
2
+ import type { RequestOptions } from "./request.js";
3
+ export type SessionListQuery = Readonly<{
4
+ actorId?: never;
5
+ key?: never;
6
+ status?: SessionStatus | readonly SessionStatus[];
7
+ cursor?: string;
8
+ limit?: number;
9
+ }> | Readonly<{
10
+ actorId: string;
11
+ key: string;
12
+ status?: never;
13
+ cursor?: never;
14
+ limit?: never;
15
+ }>;
16
+ /**
17
+ * A Session ref addressed through the REST client. It extends the shared
18
+ * SessionRef with the durable input log, which only the REST surface reads.
19
+ */
20
+ export interface ClientSessionRef extends SessionRef {
21
+ readonly input: SessionRef["input"] & Readonly<{
22
+ list(query?: SessionInputQuery, options?: RequestOptions): Promise<SessionInputPage>;
23
+ }>;
24
+ }
25
+ export interface ClientSessionsApi {
26
+ retrieve(id: string, options?: RequestOptions): Promise<Session>;
27
+ list(query?: SessionListQuery, options?: RequestOptions): Promise<CursorPage<Session>>;
28
+ ref(id: string): ClientSessionRef;
29
+ }
30
+ interface SessionTransport {
31
+ request(method: "GET" | "POST", path: string, options?: Readonly<{
32
+ body?: unknown;
33
+ signal?: AbortSignal;
34
+ }>): Promise<unknown>;
35
+ }
36
+ export declare function createClientSessions(transport: SessionTransport): ClientSessionsApi;
37
+ export declare function createSessionRef(id: string, transport: SessionTransport): ClientSessionRef;
38
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { CursorPage } from "./contract.js";
2
+ import type { RequestOptions } from "./request.js";
3
+ import { type WorkspaceOwner, type WorkspaceRef, type Workspace, type WorkspaceStatus } from "./workspace.js";
4
+ export interface WorkspaceListItem {
5
+ readonly id: string;
6
+ readonly key?: string;
7
+ readonly sandboxId: string;
8
+ readonly deploymentId: string;
9
+ readonly status: WorkspaceStatus;
10
+ readonly owner?: WorkspaceOwner;
11
+ readonly lastActivityAt: string;
12
+ readonly createdAt: string;
13
+ readonly updatedAt: string;
14
+ }
15
+ export type WorkspaceListQuery = Readonly<{
16
+ key?: never;
17
+ cursor?: string;
18
+ limit?: number;
19
+ }> | Readonly<{
20
+ key: string;
21
+ cursor?: never;
22
+ limit?: never;
23
+ }>;
24
+ export interface ClientWorkspacesApi {
25
+ retrieve(id: string, options?: RequestOptions): Promise<Workspace>;
26
+ list(query?: WorkspaceListQuery, options?: RequestOptions): Promise<CursorPage<WorkspaceListItem>>;
27
+ ref(id: string): WorkspaceRef;
28
+ }
29
+ export interface WorkspaceTransport {
30
+ request(method: "GET" | "POST" | "DELETE", path: string, options?: Readonly<{
31
+ body?: unknown;
32
+ signal?: AbortSignal;
33
+ }>): Promise<unknown>;
34
+ }
35
+ export declare function createClientWorkspaces(transport: WorkspaceTransport): ClientWorkspacesApi;
36
+ export declare function createClientWorkspaceRef(id: string, transport: WorkspaceTransport): WorkspaceRef;
@@ -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 {};