@aexhq/sdk 0.13.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.
Files changed (112) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +160 -0
  3. package/dist/_contracts/connection-ticket.d.ts +21 -0
  4. package/dist/_contracts/connection-ticket.js +49 -0
  5. package/dist/_contracts/event-envelope.d.ts +276 -0
  6. package/dist/_contracts/event-envelope.js +324 -0
  7. package/dist/_contracts/event-stream-client.d.ts +47 -0
  8. package/dist/_contracts/event-stream-client.js +141 -0
  9. package/dist/_contracts/http.d.ts +35 -0
  10. package/dist/_contracts/http.js +114 -0
  11. package/dist/_contracts/index.d.ts +28 -0
  12. package/dist/_contracts/index.js +29 -0
  13. package/dist/_contracts/managed-key.d.ts +74 -0
  14. package/dist/_contracts/managed-key.js +110 -0
  15. package/dist/_contracts/operations.d.ts +237 -0
  16. package/dist/_contracts/operations.js +632 -0
  17. package/dist/_contracts/provider-support.d.ts +220 -0
  18. package/dist/_contracts/provider-support.js +90 -0
  19. package/dist/_contracts/proxy-protocol.d.ts +257 -0
  20. package/dist/_contracts/proxy-protocol.js +234 -0
  21. package/dist/_contracts/proxy-validation.d.ts +19 -0
  22. package/dist/_contracts/proxy-validation.js +51 -0
  23. package/dist/_contracts/run-artifacts.d.ts +47 -0
  24. package/dist/_contracts/run-artifacts.js +101 -0
  25. package/dist/_contracts/run-config.d.ts +304 -0
  26. package/dist/_contracts/run-config.js +659 -0
  27. package/dist/_contracts/run-cost.d.ts +125 -0
  28. package/dist/_contracts/run-cost.js +616 -0
  29. package/dist/_contracts/run-custody.d.ts +226 -0
  30. package/dist/_contracts/run-custody.js +465 -0
  31. package/dist/_contracts/run-record.d.ts +127 -0
  32. package/dist/_contracts/run-record.js +177 -0
  33. package/dist/_contracts/run-retention.d.ts +213 -0
  34. package/dist/_contracts/run-retention.js +484 -0
  35. package/dist/_contracts/run-unit.d.ts +194 -0
  36. package/dist/_contracts/run-unit.js +215 -0
  37. package/dist/_contracts/runner-event.d.ts +114 -0
  38. package/dist/_contracts/runner-event.js +187 -0
  39. package/dist/_contracts/runtime-manifest.d.ts +106 -0
  40. package/dist/_contracts/runtime-manifest.js +98 -0
  41. package/dist/_contracts/runtime-security-profile.d.ts +27 -0
  42. package/dist/_contracts/runtime-security-profile.js +82 -0
  43. package/dist/_contracts/runtime-sizes.d.ts +144 -0
  44. package/dist/_contracts/runtime-sizes.js +136 -0
  45. package/dist/_contracts/runtime-types.d.ts +212 -0
  46. package/dist/_contracts/runtime-types.js +2 -0
  47. package/dist/_contracts/sdk-errors.d.ts +34 -0
  48. package/dist/_contracts/sdk-errors.js +52 -0
  49. package/dist/_contracts/sdk-secrets.d.ts +31 -0
  50. package/dist/_contracts/sdk-secrets.js +220 -0
  51. package/dist/_contracts/side-effect-audit.d.ts +129 -0
  52. package/dist/_contracts/side-effect-audit.js +494 -0
  53. package/dist/_contracts/sse.d.ts +74 -0
  54. package/dist/_contracts/sse.js +0 -0
  55. package/dist/_contracts/stable.d.ts +26 -0
  56. package/dist/_contracts/stable.js +44 -0
  57. package/dist/_contracts/status.d.ts +19 -0
  58. package/dist/_contracts/status.js +61 -0
  59. package/dist/_contracts/submission.d.ts +383 -0
  60. package/dist/_contracts/submission.js +1380 -0
  61. package/dist/agents-md.d.ts +46 -0
  62. package/dist/agents-md.js +83 -0
  63. package/dist/agents-md.js.map +1 -0
  64. package/dist/asset-upload.d.ts +66 -0
  65. package/dist/asset-upload.js +168 -0
  66. package/dist/asset-upload.js.map +1 -0
  67. package/dist/bundle.d.ts +33 -0
  68. package/dist/bundle.js +89 -0
  69. package/dist/bundle.js.map +1 -0
  70. package/dist/cli.mjs +4140 -0
  71. package/dist/cli.mjs.sha256 +1 -0
  72. package/dist/client.d.ts +460 -0
  73. package/dist/client.js +857 -0
  74. package/dist/client.js.map +1 -0
  75. package/dist/fetch-archive.d.ts +16 -0
  76. package/dist/fetch-archive.js +170 -0
  77. package/dist/fetch-archive.js.map +1 -0
  78. package/dist/file.d.ts +57 -0
  79. package/dist/file.js +153 -0
  80. package/dist/file.js.map +1 -0
  81. package/dist/index.d.ts +30 -0
  82. package/dist/index.js +34 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/mcp-server.d.ts +84 -0
  85. package/dist/mcp-server.js +114 -0
  86. package/dist/mcp-server.js.map +1 -0
  87. package/dist/node-fs.d.ts +12 -0
  88. package/dist/node-fs.js +44 -0
  89. package/dist/node-fs.js.map +1 -0
  90. package/dist/proxy-endpoint.d.ts +131 -0
  91. package/dist/proxy-endpoint.js +147 -0
  92. package/dist/proxy-endpoint.js.map +1 -0
  93. package/dist/skill.d.ts +117 -0
  94. package/dist/skill.js +169 -0
  95. package/dist/skill.js.map +1 -0
  96. package/dist/version.d.ts +9 -0
  97. package/dist/version.js +10 -0
  98. package/dist/version.js.map +1 -0
  99. package/docs/cleanup.md +38 -0
  100. package/docs/credentials.md +153 -0
  101. package/docs/events.md +76 -0
  102. package/docs/mcp.md +47 -0
  103. package/docs/outputs.md +157 -0
  104. package/docs/product-boundaries.md +57 -0
  105. package/docs/provider-runtime-capabilities.md +103 -0
  106. package/docs/quickstart.md +110 -0
  107. package/docs/release.md +99 -0
  108. package/docs/run-config.md +53 -0
  109. package/docs/run-record.md +39 -0
  110. package/docs/skills.md +139 -0
  111. package/docs/testing.md +29 -0
  112. package/package.json +47 -0
@@ -0,0 +1 @@
1
+ bbc00f3784013aefc17bd7b5253652f3290d1fcdef98a2302d32befb4f6bf2ec cli.mjs
@@ -0,0 +1,460 @@
1
+ import { HttpClient, type AexEvent, type AgentsMdRecord, type CredentialMode, type DebugSink, type FetchLike, type FileRecord, type Output, type PlatformSubmission, type PlatformInlineSecrets, type PlatformProxyEndpoint, type PlatformProxyEndpointAuth, type Run, type RunEvent, type RunProvider, type RunUnit, type RuntimeSize, type RuntimeKind, type SignedOutputLink, type Skill as SkillRecord, type WhoAmI } from "./_contracts/index.js";
2
+ import { AgentsMd } from "./agents-md.js";
3
+ import { File } from "./file.js";
4
+ import { McpServer } from "./mcp-server.js";
5
+ import { ProxyEndpoint } from "./proxy-endpoint.js";
6
+ import { Skill } from "./skill.js";
7
+ export interface AexClientOptions {
8
+ /** Workspace-scoped SDK API token. */
9
+ readonly apiToken: string;
10
+ /**
11
+ * API plane root, e.g. `https://aex.example.com`. Optional —
12
+ * defaults to the canonical hosted URL (`https://api.aex.dev`).
13
+ * Override for local, staging, or other hosted aex API planes.
14
+ */
15
+ readonly baseUrl?: string;
16
+ /** Optional `fetch` override for testing. */
17
+ readonly fetch?: FetchLike;
18
+ /**
19
+ * Local debug output. `true` prints a redacted one-line trace per HTTP
20
+ * request to stderr (method, path, status, elapsed); pass a function to
21
+ * route the traces elsewhere. Purely local — nothing is uploaded.
22
+ */
23
+ readonly debug?: boolean | DebugSink;
24
+ }
25
+ /**
26
+ * Per-run submission options. Everything the user wants to send is
27
+ * spelled out at the call site:
28
+ *
29
+ * - `model` / `system` / `prompt` — the agent's brief.
30
+ * - `skills` — array of local `Skill` instances
31
+ * (`Skill.fromFiles` / `Skill.fromPath`). Local skills are materialized
32
+ * to the hosted asset store before the run lands.
33
+ * - `mcpServers` — array of `McpServer` instances (headers split into
34
+ * `secrets.mcpServers` server-side; the public submission only
35
+ * carries `{ name, url }`).
36
+ * - `proxyEndpoints` — array of `ProxyEndpoint` instances. The auth
37
+ * secret is bundled into the constructor and split into
38
+ * `secrets.proxyEndpointAuth` server-side; the public submission
39
+ * only carries the declaration (`{ name, baseUrl, authShape, … }`).
40
+ * - `secrets.<provider>.apiKey` — REQUIRED for the selected provider.
41
+ * The platform never holds a long-lived provider key on your behalf.
42
+ *
43
+ * `idempotencyKey` is auto-generated when omitted; pass one explicitly
44
+ * if you want client-driven retry safety across process restarts.
45
+ */
46
+ export interface SubmitRunOptions {
47
+ /**
48
+ * Credential source for upstream provider access. Omitted defaults to
49
+ * `"byok"`, which requires `secrets.<provider>.apiKey` as today.
50
+ * `"managed"` is reserved for paid managed-key mode and currently fails
51
+ * closed until the hosted private implementation is wired.
52
+ */
53
+ readonly credentialMode?: CredentialMode;
54
+ /**
55
+ * Provider selector. Optional — defaults to
56
+ * {@link DEFAULT_RUN_PROVIDER} (`"anthropic"`). The call site must
57
+ * supply the matching `secrets.<provider>.apiKey` and MUST NOT
58
+ * supply any other provider's secret block.
59
+ */
60
+ readonly provider?: RunProvider;
61
+ /**
62
+ * Optional runtime selector. Omit it or pass `"managed"`; both run on
63
+ * the managed runtime through the hosted BYOK provider-proxy. `"native"`
64
+ * is no longer accepted.
65
+ */
66
+ readonly runtime?: RuntimeKind;
67
+ readonly model: string;
68
+ readonly system?: string;
69
+ readonly prompt: string | readonly string[];
70
+ readonly skills?: readonly Skill[];
71
+ readonly agentsMd?: readonly AgentsMd[];
72
+ readonly files?: readonly File[];
73
+ readonly mcpServers?: readonly McpServer[];
74
+ readonly environment?: PlatformSubmission["environment"];
75
+ readonly metadata?: PlatformSubmission["metadata"];
76
+ /**
77
+ * Managed runtime size. One of the closed {@link RuntimeSize} preset tokens.
78
+ * Prefer the {@link RuntimeSizes} symbol const, e.g.
79
+ * `RuntimeSizes.SHARED_2X_2GB`.
80
+ */
81
+ readonly runtimeSize?: RuntimeSize;
82
+ /**
83
+ * Run deadline as a duration string (`"1h"`, `"90m"`, `"30s"`). Bounded to
84
+ * [1m, 6h]; omit for the 1h default. Applies to both runtimes.
85
+ */
86
+ readonly timeout?: string;
87
+ readonly proxyEndpoints?: readonly ProxyEndpoint[];
88
+ /**
89
+ * Output capture policy for the run's output files.
90
+ *
91
+ * - `allowedDirs` omitted: every regular file the session creates or
92
+ * modifies is captured.
93
+ * - `allowedDirs` present: the listed roots narrow capture to those paths.
94
+ * - `deniedDirs` subtracts noise from the allowed roots.
95
+ *
96
+ * Captured bytes land in private storage and can be retrieved via
97
+ * `client.outputs(runId)` / `client.download(runId)`. See
98
+ * `packages/sdk/docs/outputs.md` for the full contract.
99
+ */
100
+ readonly outputs?: {
101
+ readonly allowedDirs?: readonly string[];
102
+ readonly deniedDirs?: readonly string[];
103
+ };
104
+ /**
105
+ * Override the managed runtime builtin extensions enabled inside the runner.
106
+ *
107
+ * - Omitted (default): the runner enables `["developer"]` which gives
108
+ * the agent `shell`, `write`, `edit`, and `tree` tools (bash, grep
109
+ * via shell, file read via shell or editor, file edit).
110
+ * - Empty array: the agent runs with zero builtin extensions —
111
+ * useful for pure-MCP setups where every tool comes from a
112
+ * submitted `mcpServers` entry.
113
+ * - Custom list: e.g. `["developer", "computercontroller"]` to add
114
+ * web search alongside the default shell/edit toolkit.
115
+ *
116
+ * Validation: each entry matches `/^[a-z][a-z0-9_-]{0,63}$/`, max 16
117
+ * entries, deduplicated server-side.
118
+ */
119
+ readonly builtins?: readonly string[];
120
+ readonly secrets: PlatformInlineSecrets;
121
+ readonly idempotencyKey?: string;
122
+ readonly signal?: AbortSignal;
123
+ }
124
+ export interface StreamEventsOptions {
125
+ /** Poll interval in ms for the `RunEvent` snapshot loop. Default 1000. */
126
+ readonly intervalMs?: number;
127
+ readonly signal?: AbortSignal;
128
+ }
129
+ export interface StreamEnvelopesOptions {
130
+ /** Starting cursor — events with `sequence >= from` are delivered. Default 0. */
131
+ readonly from?: number;
132
+ readonly signal?: AbortSignal;
133
+ }
134
+ export interface WaitForRunOptions {
135
+ readonly intervalMs?: number;
136
+ readonly timeoutMs?: number;
137
+ readonly signal?: AbortSignal;
138
+ }
139
+ export type OutputFilePathMatch = "exact" | "suffix";
140
+ export interface OutputFilePathSelector {
141
+ readonly path: string;
142
+ readonly match?: OutputFilePathMatch;
143
+ }
144
+ export interface OutputFileIdSelector {
145
+ readonly id: string;
146
+ }
147
+ export type OutputFileSelector = Output | OutputFileIdSelector | OutputFilePathSelector;
148
+ export interface OutputDownloadOptions {
149
+ readonly to?: string;
150
+ }
151
+ /**
152
+ * One captured debug artifact returned by {@link AexClient.getRunDebugLogs}.
153
+ *
154
+ * - `filename` is the path under `runs/{runId}/logs/` — leading
155
+ * `runtime/` for runtime logs and `host/` for host logs.
156
+ * - `text` is populated when the content type looks textual
157
+ * (`text/*`, `application/json`); decoded as UTF-8.
158
+ * - `bytesBase64` is always present so a caller that wants raw bytes
159
+ * (e.g. piping into a file) can use it uniformly across textual
160
+ * and binary artifacts.
161
+ */
162
+ export interface RunDebugLog {
163
+ readonly filename: string;
164
+ readonly sizeBytes: number;
165
+ readonly contentType: string;
166
+ readonly createdAt: string;
167
+ readonly text?: string;
168
+ readonly bytesBase64: string;
169
+ }
170
+ export interface RunDebugLogError {
171
+ readonly filename: string;
172
+ readonly message: string;
173
+ }
174
+ export interface RunDebugLogs {
175
+ readonly runId: string;
176
+ readonly logs: ReadonlyArray<RunDebugLog>;
177
+ readonly errors: ReadonlyArray<RunDebugLogError>;
178
+ }
179
+ /**
180
+ * Workspace skill admin operations exposed under `client.skills`.
181
+ *
182
+ * New run submissions usually use `Skill.fromFiles(...)` or
183
+ * `Skill.fromPath(...)` directly inside `submitRun`; the SDK materializes
184
+ * those bytes to the hosted asset store before the run lands. This namespace is the read/delete
185
+ * surface for workspace skill records and the internal transport used by the
186
+ * legacy CLI upload command.
187
+ */
188
+ export declare class SkillsClient {
189
+ #private;
190
+ constructor(http: HttpClient);
191
+ list(): Promise<readonly SkillRecord[]>;
192
+ get(skillId: string): Promise<SkillRecord>;
193
+ delete(skillId: string): Promise<void>;
194
+ /**
195
+ * Lookup a live workspace skill by `(name, contentHash)`.
196
+ *
197
+ * Returns the matching `Skill` record or `null` when no live row
198
+ * carries that hash. The `contentHash` is the wire format
199
+ * `sha256:<hex>` returned by `hashSkillBundle` (and stored verbatim
200
+ * on every skill row). The hash space is unique enough that one
201
+ * row at most can match, so this is a single keyed lookup.
202
+ *
203
+ * Consumers can call this directly when they already have a hash in hand
204
+ * and want to know whether the skill is already persisted.
205
+ */
206
+ findByHash(args: {
207
+ readonly name: string;
208
+ readonly contentHash: string;
209
+ }): Promise<SkillRecord | null>;
210
+ /**
211
+ * Lookup a live workspace skill by `name`. Returns the matching
212
+ * `Skill` record or `null` when no live row carries that name.
213
+ * Implemented as a list-and-filter against the existing `/api/skills`
214
+ * endpoint — typical workspace skill counts are small enough that
215
+ * the cost is negligible.
216
+ */
217
+ findByName(name: string): Promise<SkillRecord | null>;
218
+ /**
219
+ * Internal: post a pre-bundled skill zip to the BFF. Only
220
+ * `Skill.upload` calls this. NOT part of the public API.
221
+ */
222
+ _uploadSkillBundle(args: {
223
+ readonly name: string;
224
+ readonly body: Uint8Array;
225
+ }): Promise<SkillRecord>;
226
+ }
227
+ /**
228
+ * Workspace AgentsMd admin operations exposed under `client.agentsMd`.
229
+ *
230
+ * New run submissions usually use `AgentsMd.fromContent(...)` or
231
+ * `AgentsMd.fromPath(...)` directly inside `submitRun`; the SDK
232
+ * materializes those bytes to the hosted asset store before the run lands. This namespace is
233
+ * the read/delete surface for persisted AgentsMd records plus an internal
234
+ * upload transport retained for legacy callers.
235
+ */
236
+ export declare class AgentsMdClient {
237
+ #private;
238
+ constructor(http: HttpClient);
239
+ list(): Promise<readonly AgentsMdRecord[]>;
240
+ get(agentsMdId: string): Promise<AgentsMdRecord>;
241
+ delete(agentsMdId: string): Promise<void>;
242
+ /**
243
+ * Internal: post an AgentsMd markdown string to the BFF.
244
+ * NOT part of the public API.
245
+ */
246
+ _uploadAgentsMd(args: {
247
+ readonly name: string;
248
+ readonly content: string;
249
+ }): Promise<AgentsMdRecord>;
250
+ }
251
+ /**
252
+ * Workspace File admin operations exposed under `client.files`.
253
+ *
254
+ * New run submissions usually use `File.fromPath(...)` or
255
+ * `File.fromBytes(...)` directly inside `submitRun`; the SDK materializes
256
+ * those bytes to the hosted asset store before the run lands. This namespace is the read/delete
257
+ * surface for persisted file records plus an internal upload transport
258
+ * retained for legacy callers.
259
+ */
260
+ export declare class FilesClient {
261
+ #private;
262
+ constructor(http: HttpClient);
263
+ list(): Promise<readonly FileRecord[]>;
264
+ get(fileId: string): Promise<FileRecord>;
265
+ delete(fileId: string): Promise<void>;
266
+ /**
267
+ * Internal: post a pre-bundled file zip to the BFF.
268
+ * NOT part of the public API.
269
+ */
270
+ _uploadFile(args: {
271
+ readonly name: string;
272
+ readonly bytes: Uint8Array;
273
+ }): Promise<FileRecord>;
274
+ }
275
+ /**
276
+ * Unified user-facing client for the aex platform. The same class
277
+ * powers the published `@aexhq/sdk` SDK and (under the hood) every host-side
278
+ * subcommand of the in-container `aex` CLI. All operations talk to
279
+ * the dashboard BFF and operate on durable run records.
280
+ *
281
+ * The SDK never asks the caller for a workspace id — workspace identity
282
+ * is derived server-side from the API token on every request. Use
283
+ * `client.whoami()` if you want to introspect which workspace the
284
+ * token resolves to.
285
+ */
286
+ export declare class AexClient {
287
+ #private;
288
+ readonly skills: SkillsClient;
289
+ readonly agentsMd: AgentsMdClient;
290
+ readonly files: FilesClient;
291
+ constructor(options: AexClientOptions);
292
+ /**
293
+ * Internal: forwards to `SkillsClient._uploadSkillBundle`. NOT part of
294
+ * the public API.
295
+ *
296
+ * NOTE (tech-debt): this is part of the legacy workspace-skill upload
297
+ * surface (`SkillsClient` + `operations.createSkillBundle` + the TUS
298
+ * chunked path in asset-upload.ts). The live submit path materializes
299
+ * inline skills via `uploadAsset` instead; `Skill` no longer
300
+ * exposes `.upload()`/`.fromId()`. This surface is retained pending a
301
+ * deliberate deprecation pass (it still threads into the CLI host
302
+ * commands), tracked in the remediation plan as item 4a.
303
+ */
304
+ _uploadSkillBundle(args: {
305
+ readonly name: string;
306
+ readonly body: Uint8Array;
307
+ }): Promise<SkillRecord>;
308
+ /**
309
+ * Internal: an `AgentsMd.upload(this)` shortcut that bypasses
310
+ * `client.agentsMd` indirection. Forwarded to
311
+ * `AgentsMdClient._uploadAgentsMd`. NOT part of the public API.
312
+ */
313
+ _uploadAgentsMd(args: {
314
+ readonly name: string;
315
+ readonly content: string;
316
+ }): Promise<AgentsMdRecord>;
317
+ /**
318
+ * Internal: a `File.upload(this)` shortcut that bypasses
319
+ * `client.files` indirection. Forwarded to
320
+ * `FilesClient._uploadFile`. NOT part of the public API.
321
+ */
322
+ _uploadFile(args: {
323
+ readonly name: string;
324
+ readonly bytes: Uint8Array;
325
+ }): Promise<FileRecord>;
326
+ /**
327
+ * Submit a run and wait for it to reach a terminal state. Returns the
328
+ * final `Run` record. For long-running flows, prefer `submitRun` +
329
+ * `stream(runId)` + `wait(runId)`.
330
+ */
331
+ run(options: SubmitRunOptions): Promise<Run>;
332
+ /**
333
+ * Submit a run and return its run id immediately. Use that id with
334
+ * `wait`, `stream`, `outputs`, `download`, `cancel`, or `delete`.
335
+ *
336
+ * The SDK splits `mcpServers[i].headers` into `secrets.mcpServers`
337
+ * and `proxyEndpoints[i]` auth values into `secrets.proxyEndpointAuth`
338
+ * before sending so credentials never enter the hashed submission or
339
+ * the run snapshot.
340
+ *
341
+ * Unstaged inline skills (`Skill.fromFiles` / `Skill.fromPath`
342
+ * without a prior `.upload`) are accepted: the SDK switches to a
343
+ * multipart body that carries the canonical zip bytes alongside the
344
+ * JSON submission. The dashboard BFF ingests each one through the
345
+ * standard workspace-skill upload pipeline (dedup by content hash;
346
+ * upload via the existing two-phase pending → ready flow) and
347
+ * rewrites the run's `skills[]` to reference the resulting `skl_*`
348
+ * ids. The bytes persist on aex; the user can browse and
349
+ * download the resulting workspace skill from the dashboard.
350
+ */
351
+ submitRun(options: SubmitRunOptions): Promise<string>;
352
+ getRun(runId: string): Promise<Run>;
353
+ /** Short alias for `getRun`. */
354
+ get(runId: string): Promise<Run>;
355
+ /**
356
+ * Fetch the self-contained `RunUnit`: parsed submission inputs,
357
+ * attempts, indexed events (inline + cursor for the tail), raw
358
+ * provider-event Storage manifest, outputs, capture failures,
359
+ * proxy-call audit, pinned workspace skills, provider skills,
360
+ * inline skills. Backed by the same endpoint as `getRun` but
361
+ * typed against the full wire shape — use this when you need
362
+ * fields beyond `{id, status, timestamps, usage}`.
363
+ */
364
+ getRunUnit(runId: string): Promise<RunUnit>;
365
+ /** Short alias for `getRunUnit`. */
366
+ getUnit(runId: string): Promise<RunUnit>;
367
+ listEvents(runId: string): Promise<readonly RunEvent[]>;
368
+ /** Short alias for `listEvents`. */
369
+ events(runId: string): Promise<readonly RunEvent[]>;
370
+ /**
371
+ * Yield run events (the `RunEvent` snapshot shape) as they arrive, by
372
+ * polling the coordinator-backed `/events` endpoint until the run reaches
373
+ * a terminal state, the signal aborts, or the caller breaks the iterator.
374
+ *
375
+ * For the live, low-latency envelope stream prefer {@link streamEnvelopes}
376
+ * (coordinator WebSocket). This polling form stays for consumers that want
377
+ * the loose `RunEvent` shape without a WS.
378
+ */
379
+ streamEvents(runId: string, options?: StreamEventsOptions): AsyncIterable<RunEvent>;
380
+ /** Short alias for `streamEvents`. */
381
+ stream(runId: string, options?: StreamEventsOptions): AsyncIterable<RunEvent>;
382
+ /**
383
+ * Stream the unified {@link AexEvent} envelope live over the coordinator
384
+ * WebSocket. The Worker's ticket broker authorizes the connection (workspace
385
+ * token → short-lived coordinator ticket); the shared client replays from
386
+ * the cursor, tails live, and resumes exactly-once across reconnects. The
387
+ * ticket is re-minted on each (re)connect so a long run never outlives it.
388
+ */
389
+ streamEnvelopes(runId: string, options?: StreamEnvelopesOptions): AsyncIterable<AexEvent>;
390
+ /**
391
+ * Poll the run record until it reaches a terminal status (succeeded,
392
+ * failed, terminated). Throws if `timeoutMs` elapses first.
393
+ */
394
+ waitForRun(runId: string, options?: WaitForRunOptions): Promise<Run>;
395
+ /** Short alias for `waitForRun`. */
396
+ wait(runId: string, options?: WaitForRunOptions): Promise<Run>;
397
+ listOutputs(runId: string): Promise<readonly Output[]>;
398
+ /** Short alias for `listOutputs`. */
399
+ outputs(runId: string): Promise<readonly Output[]>;
400
+ createOutputLink(runId: string, outputId: string): Promise<SignedOutputLink>;
401
+ /**
402
+ * Download captured deliverables. Omit `selector` to receive the full
403
+ * outputs namespace as a zip; pass an id, Output object, or path selector
404
+ * to receive one file's raw bytes.
405
+ */
406
+ downloadOutput(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
407
+ downloadOutput(runId: string, selector: undefined, options?: OutputDownloadOptions): Promise<Uint8Array>;
408
+ downloadOutput(runId: string, selector: OutputFileSelector, options?: OutputDownloadOptions): Promise<Uint8Array>;
409
+ /**
410
+ * Bundle the per-run debug artifacts aex captures automatically:
411
+ *
412
+ * - `runtime/{stdout,stderr,args}.log` — runtime process diagnostics.
413
+ * - `host/...` — managed host logs when the platform includes them.
414
+ * These all live in the run's `logs` namespace (`runs/<id>/logs/`).
415
+ * Each is downloaded through the gated `/logs/:id/download` endpoint,
416
+ * decoded as UTF-8 text when the content type looks textual, and
417
+ * surfaced as raw bytes (base64) otherwise. The call is best-effort: a
418
+ * download failure for one file does not block the others; the failing
419
+ * entry lands in `errors` with the underlying message.
420
+ *
421
+ * Use this when a run failed or behaved oddly and you want all the
422
+ * post-mortem material in one round-trip — no need to wire
423
+ * `listOutputs` + `createOutputLink` by hand.
424
+ */
425
+ getRunDebugLogs(runId: string): Promise<RunDebugLogs>;
426
+ /** Short alias for `getRunDebugLogs`. */
427
+ debugLogs(runId: string): Promise<RunDebugLogs>;
428
+ cancelRun(runId: string): Promise<void>;
429
+ /** Short alias for `cancelRun`. */
430
+ cancel(runId: string): Promise<void>;
431
+ deleteRun(runId: string): Promise<void>;
432
+ /** Short alias for `deleteRun`. */
433
+ delete(runId: string): Promise<void>;
434
+ /**
435
+ * Delete a workspace asset blob from the shared content-addressed store
436
+ * (`assets/<workspaceId>/<hash>`). Accepts `sha256:<hex>` or a bare
437
+ * 64-hex digest. Runs that already snapshotted the asset are unaffected.
438
+ */
439
+ deleteWorkspaceAsset(hash: string): Promise<void>;
440
+ whoami(): Promise<WhoAmI>;
441
+ /**
442
+ * Download EVERYTHING about a run as one zip, assembled client-side
443
+ * from the public read endpoints (`getRun` + `listEvents` +
444
+ * `listOutputs` + per-output `/download`). Organised into the four
445
+ * namespace folders: `metadata/`, `events/`, `outputs/` (deliverables),
446
+ * `logs/` (`runtime/`, `host/`, `provider-proxy/`, `control-plane/`
447
+ * diagnostics), plus a `manifest.json`. Pass `to` to also write the
448
+ * bytes to a file path while still returning the bytes.
449
+ */
450
+ download(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
451
+ /** Download only the run's deliverables (the `outputs` namespace) as a zip. */
452
+ downloadOutputs(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
453
+ /** Download only the platform diagnostics (the `logs` namespace) as a zip. */
454
+ downloadLogs(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
455
+ /** Download only the indexed event archive (the `events` namespace) as a zip. */
456
+ downloadEvents(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
457
+ /** Download only the run record (the `metadata` namespace) as a zip. */
458
+ downloadMetadata(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
459
+ }
460
+ export type { PlatformProxyEndpoint, PlatformProxyEndpointAuth };