@aexhq/sdk 0.40.16 → 0.41.0

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 (130) hide show
  1. package/README.md +25 -25
  2. package/dist/_contracts/api-key.d.ts +6 -4
  3. package/dist/_contracts/api-key.js +20 -7
  4. package/dist/_contracts/connection-ticket.d.ts +5 -5
  5. package/dist/_contracts/connection-ticket.js +7 -7
  6. package/dist/_contracts/error-codes.d.ts +1 -1
  7. package/dist/_contracts/error-codes.js +4 -4
  8. package/dist/_contracts/error-factory.js +1 -1
  9. package/dist/_contracts/event-envelope.d.ts +41 -41
  10. package/dist/_contracts/event-envelope.js +49 -49
  11. package/dist/_contracts/event-stream-client.d.ts +9 -9
  12. package/dist/_contracts/event-stream-client.js +5 -5
  13. package/dist/_contracts/event-view.d.ts +6 -6
  14. package/dist/_contracts/event-view.js +12 -12
  15. package/dist/_contracts/http.js +1 -1
  16. package/dist/_contracts/index.d.ts +10 -10
  17. package/dist/_contracts/index.js +9 -9
  18. package/dist/_contracts/models.d.ts +17 -17
  19. package/dist/_contracts/models.js +14 -14
  20. package/dist/_contracts/operations.d.ts +79 -82
  21. package/dist/_contracts/operations.js +233 -243
  22. package/dist/_contracts/provider-support.d.ts +2 -2
  23. package/dist/_contracts/runner-event.d.ts +8 -8
  24. package/dist/_contracts/runner-event.js +9 -9
  25. package/dist/_contracts/runtime-manifest.d.ts +12 -12
  26. package/dist/_contracts/runtime-manifest.js +1 -1
  27. package/dist/_contracts/runtime-sizes.d.ts +12 -12
  28. package/dist/_contracts/runtime-sizes.js +18 -18
  29. package/dist/_contracts/runtime-types.d.ts +117 -117
  30. package/dist/_contracts/runtime-types.js +2 -2
  31. package/dist/_contracts/sdk-errors.d.ts +3 -3
  32. package/dist/_contracts/sdk-errors.js +4 -4
  33. package/dist/_contracts/sdk-secrets.js +10 -10
  34. package/dist/_contracts/session-artifacts.d.ts +151 -0
  35. package/dist/_contracts/session-artifacts.js +234 -0
  36. package/dist/_contracts/{run-config.d.ts → session-config.d.ts} +29 -29
  37. package/dist/_contracts/{run-config.js → session-config.js} +37 -37
  38. package/dist/_contracts/session-cost.d.ts +140 -0
  39. package/dist/_contracts/{run-cost.js → session-cost.js} +94 -94
  40. package/dist/_contracts/{run-custody.d.ts → session-custody.d.ts} +16 -16
  41. package/dist/_contracts/{run-custody.js → session-custody.js} +42 -42
  42. package/dist/_contracts/session-record.d.ts +112 -0
  43. package/dist/_contracts/{run-record.js → session-record.js} +23 -23
  44. package/dist/_contracts/session-retention.d.ts +209 -0
  45. package/dist/_contracts/{run-retention.js → session-retention.js} +116 -116
  46. package/dist/_contracts/{run-unit.d.ts → session-unit.d.ts} +38 -38
  47. package/dist/_contracts/{run-unit.js → session-unit.js} +33 -33
  48. package/dist/_contracts/side-effect-audit.d.ts +14 -14
  49. package/dist/_contracts/side-effect-audit.js +38 -38
  50. package/dist/_contracts/sse.d.ts +1 -1
  51. package/dist/_contracts/sse.js +0 -0
  52. package/dist/_contracts/stable.d.ts +1 -1
  53. package/dist/_contracts/stable.js +1 -1
  54. package/dist/_contracts/status.d.ts +18 -18
  55. package/dist/_contracts/status.js +19 -19
  56. package/dist/_contracts/submission.d.ts +101 -99
  57. package/dist/_contracts/submission.js +96 -96
  58. package/dist/_contracts/{run-trace.d.ts → turn-trace.d.ts} +1 -1
  59. package/dist/_contracts/webhook-verify.d.ts +1 -1
  60. package/dist/_contracts/webhook-verify.js +1 -1
  61. package/dist/agents-md.d.ts +4 -4
  62. package/dist/agents-md.js +5 -5
  63. package/dist/agents-md.js.map +1 -1
  64. package/dist/bundle.d.ts +1 -1
  65. package/dist/bundle.js +1 -1
  66. package/dist/bundle.js.map +1 -1
  67. package/dist/cli.mjs +578 -621
  68. package/dist/cli.mjs.sha256 +1 -1
  69. package/dist/client.d.ts +141 -155
  70. package/dist/client.js +236 -245
  71. package/dist/client.js.map +1 -1
  72. package/dist/fetch-archive.js +3 -3
  73. package/dist/file.d.ts +7 -7
  74. package/dist/file.js +8 -8
  75. package/dist/file.js.map +1 -1
  76. package/dist/index.d.ts +10 -10
  77. package/dist/index.js +8 -8
  78. package/dist/index.js.map +1 -1
  79. package/dist/mcp-server.d.ts +1 -1
  80. package/dist/retry.d.ts +1 -1
  81. package/dist/secret.d.ts +6 -6
  82. package/dist/secret.js +6 -6
  83. package/dist/secret.js.map +1 -1
  84. package/dist/skill.d.ts +2 -2
  85. package/dist/skill.js +3 -3
  86. package/dist/skill.js.map +1 -1
  87. package/dist/tool.js +2 -2
  88. package/dist/tool.js.map +1 -1
  89. package/dist/version.d.ts +1 -1
  90. package/dist/version.js +1 -1
  91. package/dist/version.js.map +1 -1
  92. package/docs/authentication.md +11 -11
  93. package/docs/billing.md +3 -3
  94. package/docs/cleanup.md +5 -5
  95. package/docs/concepts/agent-tools.md +5 -5
  96. package/docs/concepts/composition.md +3 -3
  97. package/docs/concepts/providers-and-runtimes.md +3 -3
  98. package/docs/concepts/{runs.md → sessions.md} +8 -8
  99. package/docs/concepts/subagents.md +16 -16
  100. package/docs/credentials.md +7 -7
  101. package/docs/defaults.md +14 -14
  102. package/docs/errors.md +10 -10
  103. package/docs/events.md +26 -26
  104. package/docs/files.md +267 -0
  105. package/docs/limits-and-quotas.md +35 -35
  106. package/docs/limits.md +6 -6
  107. package/docs/mcp.md +3 -3
  108. package/docs/networking.md +24 -24
  109. package/docs/provider-runtime-capabilities.md +1 -1
  110. package/docs/public-surface.json +6 -6
  111. package/docs/quickstart.md +13 -13
  112. package/docs/release.md +5 -5
  113. package/docs/retries.md +3 -3
  114. package/docs/secrets.md +16 -16
  115. package/docs/session-config.md +58 -0
  116. package/docs/{run-record.md → session-record.md} +16 -16
  117. package/docs/skills.md +9 -9
  118. package/docs/vision-skills.md +7 -7
  119. package/docs/webhooks.md +11 -11
  120. package/examples/feature-tour.ts +17 -17
  121. package/examples/spike-settle-latency.ts +11 -11
  122. package/package.json +1 -1
  123. package/dist/_contracts/run-artifacts.d.ts +0 -49
  124. package/dist/_contracts/run-artifacts.js +0 -102
  125. package/dist/_contracts/run-cost.d.ts +0 -140
  126. package/dist/_contracts/run-record.d.ts +0 -116
  127. package/dist/_contracts/run-retention.d.ts +0 -209
  128. package/docs/outputs.md +0 -267
  129. package/docs/run-config.md +0 -58
  130. /package/dist/_contracts/{run-trace.js → turn-trace.js} +0 -0
@@ -1 +1 @@
1
- 6a03ce618806a3cbd18663d4a1187106b1c6fecd4256e5f78d043b7480967505 cli.mjs
1
+ b55fdfa4ea2269e666c3232ae406e9f691422193792a6258af7373ce2756d31e cli.mjs
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HttpClient, SecretString, type AexEventView, type AgentsMdRecord, type ApprovalGate, type BatchResult, type BillingCheckoutRequest, type BillingHostedSession, type BillingLedgerPage, type BillingLedgerQuery, type BillingPortalRequest, type BillingSummary, type ChildRunRef, type DebugSink, type FetchLike, type FileRecord, type Output, type OutputFileType, type OutputLink, type OutputLinkOptions, type OutputQuery, type OutputText, type OutputMode, type ReadOutputTextOptions, type ResponseFormat, type OutputSearchQuery, type OutputSearchPage, type RunOutcome, type Session, type SessionCreateRequest, type SessionListPage, type SessionListQuery, type SessionMessage, type SessionStateChangeAccepted, type SessionTerminalOutcome, type SessionTurn, type SettledResult, type PlatformEnvironmentInput, type PlatformSubmission, type Run, type RunModel, type RunTrace, type RunWebhookDelivery, type RunProvider, type SecretRecord, type RunUnit, type BuiltinToolName, type RuntimeSize, type SkillRecord, type WebhookSigningSecret, type WebSocketFactory, type WhoAmI } from "./_contracts/index.js";
1
+ import { HttpClient, SecretString, type AexEventView, type AgentsMdRecord, type ApprovalGate, type BatchResult, type BillingCheckoutRequest, type BillingHostedSession, type BillingLedgerPage, type BillingLedgerQuery, type BillingPortalRequest, type BillingSummary, type ChildSessionRef, type DebugSink, type FetchLike, type FileRecord, type SessionFile, type SessionFileType, type SessionFileLink, type SessionFileLinkOptions, type SessionFileQuery, type SessionFileText, type OutputMode, type ReadSessionFileTextOptions, type ResponseFormat, type SessionFileSearchQuery, type SessionFileSearchPage, type TurnOutcome, type Session, type SessionCreateRequest, type SessionListPage, type SessionListQuery, type SessionMessage, type SessionStateChangeAccepted, type SessionTerminalOutcome, type SessionTurn, type SettledResult, type PlatformEnvironmentInput, type PlatformSubmission, type SessionRecord, type ModelName, type TurnTrace, type SessionWebhookDelivery, type ProviderName, type SecretRecord, type SessionUnit, type BuiltinToolName, type RuntimeSize, type SkillRecord, type WebhookSigningSecret, type WebSocketFactory, type WhoAmI } from "./_contracts/index.js";
2
2
  import { AgentsMd } from "./agents-md.js";
3
3
  import { type UploadedAsset } from "./asset-upload.js";
4
4
  import { File, type ZipStreamDriver } from "./file.js";
@@ -28,7 +28,7 @@ export interface AexOptions {
28
28
  * Built-in transport retry policy. Every BFF request is retried on transient
29
29
  * failures (HTTP 429/500/502/503/504/529 and network errors) with bounded
30
30
  * exponential backoff + jitter, honoring `Retry-After`. Billable submits carry
31
- * a stable idempotency key, so a retry never creates a duplicate billable run.
31
+ * a stable idempotency key, so a retry never creates a duplicate billable session turn.
32
32
  *
33
33
  * Omit for sensible defaults (4 attempts, ~2 min budget); pass an object to
34
34
  * tune `maxAttempts` / delays / `maxElapsedMs`; pass `false` to disable.
@@ -36,26 +36,24 @@ export interface AexOptions {
36
36
  readonly retry?: RetryOptions | false;
37
37
  }
38
38
  /**
39
- * The unified SETTLED result of {@link Aex.run}. Extends the contracts
40
- * {@link SettledResult} (the ONE settled shape `run()` and `done()` share), so
39
+ * The unified SETTLED result of {@link Aex.start}. Extends the contracts
40
+ * {@link SettledResult} (the ONE settled shape `start()` and `done()` share), so
41
41
  * the terminal `status` (a {@link SessionTerminalOutcome}), `ok`, `costUsd`
42
- * (`number`, `>= 0`), and `usage` are ALWAYS present — `run()` awaits the settle
43
- * commit by default. Adds the one-shot conveniences: the run-compatible record,
44
- * events, decoded trace, assistant text, and captured outputs.
42
+ * (`number`, `>= 0`), and `usage` are ALWAYS present — `start()` awaits the settle
43
+ * commit by default. Adds the one-shot conveniences: the session-record-compatible record,
44
+ * events, decoded trace, assistant text, and captured files.
45
45
  *
46
- * `T` is the `responseFormat` decode type: when the run was submitted with a
46
+ * `T` is the `responseFormat` decode type: when the session was submitted with a
47
47
  * `json_schema` `responseFormat`, {@link outcome} carries the typed decoded
48
48
  * value or a typed refusal.
49
49
  */
50
- export interface RunResult<T = unknown> extends SettledResult {
51
- readonly runId: string;
52
- /** The session id used as the run-compatible handle. */
53
- readonly sessionId?: string;
54
- /** Run-compatible view of the underlying session record. */
55
- readonly run: Run;
50
+ export interface SessionResult<T = unknown> extends SettledResult {
51
+ readonly sessionId: string;
52
+ /** Session-record view of the underlying session. */
53
+ readonly record: SessionRecord;
56
54
  /** The underlying resumable session record (its lifecycle `status` is idle/suspended when resumable). */
57
55
  readonly session?: Session;
58
- /** The turn accepted for this one-shot run. */
56
+ /** The turn accepted for this one-shot session. */
59
57
  readonly turn?: SessionTurn;
60
58
  /** The assistant's final text. */
61
59
  readonly text: string;
@@ -64,27 +62,27 @@ export interface RunResult<T = unknown> extends SettledResult {
64
62
  /** The session turn event stream — each event carries the `is*()` type-guard methods. */
65
63
  readonly events: readonly AexEventView[];
66
64
  /** Decoded view of the events: tool calls + usage + assistant text. */
67
- readonly trace: RunTrace;
68
- /** The run's captured output files. */
69
- readonly outputs: readonly Output[];
65
+ readonly trace: TurnTrace;
66
+ /** The session's captured files. */
67
+ readonly files: readonly SessionFile[];
70
68
  /**
71
- * The typed schema-decode outcome — present only when the run was submitted
69
+ * The typed schema-decode outcome — present only when the session was submitted
72
70
  * with a `json_schema` `responseFormat`: `{ kind:'decoded', value }` or
73
71
  * `{ kind:'refused', reason }`. There is no untyped path that yields a
74
72
  * hallucinated object.
75
73
  */
76
- readonly outcome?: RunOutcome<T>;
74
+ readonly outcome?: TurnOutcome<T>;
77
75
  }
78
76
  /** How a one-shot / turn resolves: at the render-complete park, or (default) at the settle commit. */
79
77
  export type SettleAwait = "park" | "settle";
80
- /** Options for {@link Aex.run}. */
81
- export interface RunCollectOptions {
78
+ /** Options for {@link Aex.start}. */
79
+ export interface StartSessionOptions {
82
80
  /** Overall wait budget (ms) for the one-shot session turn to park. */
83
81
  readonly timeoutMs?: number;
84
82
  readonly webSocketFactory?: WebSocketFactory;
85
83
  readonly idleTimeoutMs?: number;
86
84
  readonly pingIntervalMs?: number;
87
- /** Throw a {@link RunStateError} when the run does not succeed. Default false. */
85
+ /** Throw a {@link SessionStateError} when the session does not succeed. Default false. */
88
86
  readonly throwOnFailure?: boolean;
89
87
  /**
90
88
  * When the result resolves. `'settle'` (DEFAULT) waits (bounded) for the
@@ -95,9 +93,9 @@ export interface RunCollectOptions {
95
93
  */
96
94
  readonly await?: SettleAwait;
97
95
  }
98
- /** The result of {@link Aex.submit}: the run id + a resumable session handle. */
96
+ /** The result of {@link Aex.submit}: the session id + a resumable session handle. */
99
97
  export interface SubmitResult {
100
- readonly runId: string;
98
+ readonly sessionId: string;
101
99
  readonly session: SessionHandle;
102
100
  }
103
101
  /** Options for {@link Aex.batch}. */
@@ -117,7 +115,7 @@ export interface SessionOverrides {
117
115
  readonly timeout?: string;
118
116
  readonly maxSpendUsd?: number;
119
117
  /**
120
- * Per-run iteration cap (agent loop turns). Defaults + ceiling are enforced
118
+ * Per-session iteration cap (agent loop turns). Defaults + ceiling are enforced
121
119
  * server-side; omit to accept the platform default. A positive integer.
122
120
  */
123
121
  readonly maxTurns?: number;
@@ -148,12 +146,12 @@ export interface SessionCreateOptions {
148
146
  * {@link Providers} symbol const, e.g. `provider: Providers.DEEPSEEK`. When
149
147
  * omitted it is derived from `model`; if supplied it MUST serve the model.
150
148
  */
151
- readonly provider?: RunProvider;
149
+ readonly provider?: ProviderName;
152
150
  /**
153
151
  * Closed public model id. Prefer the {@link Models} symbol const, e.g.
154
152
  * `Models.CLAUDE_HAIKU_4_5`.
155
153
  */
156
- readonly model: RunModel;
154
+ readonly model: ModelName;
157
155
  readonly system?: string;
158
156
  /**
159
157
  * Tools available to the agent. Each entry is a custom {@link Tool} bundle or
@@ -171,11 +169,11 @@ export interface SessionCreateOptions {
171
169
  readonly files?: readonly File[];
172
170
  readonly mcpServers?: readonly McpServer[];
173
171
  /**
174
- * Output capture policy for the session's output files. `allowedDirs` omitted
175
- * captures every regular file the session creates or modifies; the listed
176
- * roots narrow capture; `deniedDirs` subtracts noise.
172
+ * File capture policy for the session's captured files. Omit `allowedDirs`
173
+ * to expose regular workspace files from the latest complete checkpoint;
174
+ * listed roots narrow capture, and `deniedDirs` subtracts noise.
177
175
  */
178
- readonly outputs?: {
176
+ readonly fileCapture?: {
179
177
  readonly allowedDirs?: readonly string[];
180
178
  readonly deniedDirs?: readonly string[];
181
179
  readonly captureTimeoutMs?: number;
@@ -205,7 +203,7 @@ export interface SessionCreateOptions {
205
203
  * Structured-output policy. `{ kind:'text' }` (default) is free-form;
206
204
  * `{ kind:'json_schema', schema, strict?, name? }` requests provider-native
207
205
  * constrained decode against `schema`. The typed outcome is read from
208
- * `run<T>()`'s `result.outcome` (`{ kind:'decoded', value }` or
206
+ * `start<T>()`'s `result.outcome` (`{ kind:'decoded', value }` or
209
207
  * `{ kind:'refused', reason }`) — never an untyped hallucinated object.
210
208
  */
211
209
  readonly responseFormat?: ResponseFormat;
@@ -219,7 +217,7 @@ export interface SessionCreateOptions {
219
217
  readonly metadata?: PlatformSubmission["metadata"];
220
218
  readonly idempotencyKey?: string;
221
219
  /** BYOK provider key(s), keyed by provider. */
222
- readonly apiKeys?: Partial<Record<RunProvider, string>>;
220
+ readonly apiKeys?: Partial<Record<ProviderName, string>>;
223
221
  readonly environment?: SessionEnvironmentOptions;
224
222
  /**
225
223
  * Managed runtime size. One of the closed {@link RuntimeSize} preset tokens.
@@ -250,7 +248,7 @@ export interface SessionSendOptions {
250
248
  */
251
249
  readonly await?: SettleAwait;
252
250
  }
253
- export interface SessionRunOptions extends SessionCreateOptions {
251
+ export interface SessionStartOptions extends SessionCreateOptions {
254
252
  readonly message: SessionInput;
255
253
  readonly deleteAfter?: boolean;
256
254
  readonly messageIdempotencyKey?: string;
@@ -259,7 +257,7 @@ export interface SessionRunOptions extends SessionCreateOptions {
259
257
  /**
260
258
  * The unified SETTLED result of one turn (`session.send(...).done()`). Extends
261
259
  * the contracts {@link SettledResult}, so `done()` returns the SAME shape as
262
- * `run()`: the terminal `status` (a {@link SessionTerminalOutcome}), `ok`,
260
+ * `start()`: the terminal `status` (a {@link SessionTerminalOutcome}), `ok`,
263
261
  * `costUsd`, and `usage` are always present (the turn awaits settle by default).
264
262
  */
265
263
  export interface SessionTurnResult<T = unknown> extends SettledResult {
@@ -268,16 +266,16 @@ export interface SessionTurnResult<T = unknown> extends SettledResult {
268
266
  readonly turn: SessionTurn;
269
267
  readonly text: string;
270
268
  readonly events: readonly AexEventView[];
271
- readonly outputs: readonly Output[];
269
+ readonly files: readonly SessionFile[];
272
270
  readonly messages: readonly Message[];
273
271
  /** The typed schema-decode outcome when a `json_schema` `responseFormat` was set. */
274
- readonly outcome?: RunOutcome<T>;
272
+ readonly outcome?: TurnOutcome<T>;
275
273
  }
276
- export interface SessionRunResult extends SessionTurnResult {
274
+ export interface SessionStartResult extends SessionTurnResult {
277
275
  }
278
276
  export declare class SessionTurnStream implements AsyncIterable<AexEventView> {
279
277
  #private;
280
- constructor(run: () => AsyncGenerator<AexEventView, SessionTurnResult, void>);
278
+ constructor(stream: () => AsyncGenerator<AexEventView, SessionTurnResult, void>);
281
279
  [Symbol.asyncIterator](): AsyncIterator<AexEventView>;
282
280
  done(): Promise<SessionTurnResult>;
283
281
  }
@@ -307,40 +305,40 @@ export interface SessionEvents {
307
305
  first(): Promise<AexEventView | undefined>;
308
306
  stream(options?: StreamEventsOptions): AsyncIterable<AexEventView>;
309
307
  streamEnvelopes(options?: StreamEnvelopesOptions): AsyncIterable<AexEventView>;
310
- archiveLink(options?: OutputLinkOptions): Promise<OutputLink>;
308
+ archiveLink(options?: SessionFileLinkOptions): Promise<SessionFileLink>;
311
309
  /** Download the events-namespace archive as a zip. */
312
- download(options?: OutputDownloadOptions): Promise<Uint8Array>;
310
+ download(options?: DownloadOptions): Promise<Uint8Array>;
313
311
  }
314
312
  /**
315
- * Accessor over the session's captured output files (`session.outputs()`):
313
+ * Accessor over the session's captured files (`session.files()`):
316
314
  * enumerate, read one as capped text, locate/resolve, and download.
317
315
  */
318
- export interface SessionOutputs {
319
- list(query?: OutputQuery): Promise<readonly Output[]>;
320
- last(): Promise<Output | undefined>;
321
- first(): Promise<Output | undefined>;
322
- read(selector: OutputFileSelector, options?: ReadOutputTextOptions): Promise<OutputText>;
323
- find(query: OutputQuery): Promise<readonly Output[]>;
324
- findOne(query: OutputQuery): Promise<Output | null>;
325
- /**
326
- * Search THIS session's captured outputs by filename (`string | RegExp`) /
316
+ export interface SessionFiles {
317
+ list(query?: SessionFileQuery): Promise<readonly SessionFile[]>;
318
+ last(): Promise<SessionFile | undefined>;
319
+ first(): Promise<SessionFile | undefined>;
320
+ read(selector: SessionFileSelector, options?: ReadSessionFileTextOptions): Promise<SessionFileText>;
321
+ find(query: SessionFileQuery): Promise<readonly SessionFile[]>;
322
+ findOne(query: SessionFileQuery): Promise<SessionFile | null>;
323
+ /**
324
+ * Search THIS session's captured files by filename (`string | RegExp`) /
327
325
  * extension / content type. Metadata-only (reference hits, no bytes). A
328
326
  * content-shaped query throws a typed "content search unsupported" rather than
329
327
  * silently returning 0 hits.
330
328
  */
331
- search(query?: PerSessionOutputSearchQuery): Promise<OutputSearchPage>;
332
- link(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<OutputLink>;
333
- fetch(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<Response>;
334
- /** No selector = outputs-namespace zip; with selector = one file's raw bytes. */
335
- download(selector?: OutputFileSelector, options?: OutputDownloadOptions): Promise<Uint8Array>;
329
+ search(query?: PerSessionFileSearchQuery): Promise<SessionFileSearchPage>;
330
+ link(selectorOrQuery: SessionFileLinkSelector, options?: SessionFileLinkOptions): Promise<SessionFileLink>;
331
+ fetch(selectorOrQuery: SessionFileLinkSelector, options?: SessionFileLinkOptions): Promise<Response>;
332
+ /** No selector = files-namespace zip; with selector = one file's raw bytes. */
333
+ download(selector?: SessionFileSelector, options?: DownloadOptions): Promise<Uint8Array>;
336
334
  }
337
- /** A per-session output search — {@link OutputSearchQuery} without the cross-run `runIds` corpus. */
338
- export type PerSessionOutputSearchQuery = Omit<OutputSearchQuery, "runIds">;
335
+ /** A per-session file search — {@link SessionFileSearchQuery} without the cross-session `sessionIds` corpus. */
336
+ export type PerSessionFileSearchQuery = Omit<SessionFileSearchQuery, "sessionIds">;
339
337
  /**
340
338
  * Accessor over the session's webhook delivery ledger (`session.webhooks()`).
341
339
  */
342
340
  export interface SessionWebhooks {
343
- list(): Promise<readonly RunWebhookDelivery[]>;
341
+ list(): Promise<readonly SessionWebhookDelivery[]>;
344
342
  redeliver(deliveryId: string): Promise<void>;
345
343
  }
346
344
  export declare class SessionHandle {
@@ -373,12 +371,12 @@ export declare class SessionHandle {
373
371
  /** Deny an `awaiting_approval` session so the held turn is cancelled (→ cancelled). */
374
372
  deny(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
375
373
  /**
376
- * Enumerate this run's subagent CHILD runs (`GET /runs/:id/children`). Each is
377
- * a {@link ChildRunHandle} backed by the RUN facade (getRun/events/outputs) —
374
+ * Enumerate this session's subagent CHILD sessions (`GET /sessions/:id/children`). Each is
375
+ * a {@link ChildSessionHandle} backed by the RUN facade (getSessionRecord/events/files) —
378
376
  * NOT `openSession` — so every child the platform hands you is resolvable, with
379
- * its lineage (`parentRunId`/`depth`) and terminal outcome exposed.
377
+ * its lineage (`parentSessionId`/`depth`) and terminal outcome exposed.
380
378
  */
381
- children(): Promise<readonly ChildRunHandle[]>;
379
+ children(): Promise<readonly ChildSessionHandle[]>;
382
380
  /**
383
381
  * Accessor for the session's assistant messages. `all()` returns them
384
382
  * oldest-first; `last()`/`first()` return a single entry or `undefined` when
@@ -394,12 +392,12 @@ export declare class SessionHandle {
394
392
  */
395
393
  events(): SessionEvents;
396
394
  /**
397
- * Accessor for the session's captured output files: `list`/`last`/`first`
395
+ * Accessor for the session's captured files: `list`/`last`/`first`
398
396
  * enumerate them; `read` streams one as capped text; `find`/`findOne`/`link`/
399
- * `fetch` locate and resolve them; `download` fetches the outputs-namespace
397
+ * `fetch` locate and resolve them; `download` fetches the files-namespace
400
398
  * zip (no selector) or one file's raw bytes (with selector).
401
399
  */
402
- outputs(): SessionOutputs;
400
+ files(): SessionFiles;
403
401
  /**
404
402
  * Accessor for the session's webhook delivery ledger: `list()` returns the
405
403
  * delivery attempts; `redeliver(id)` re-sends the frozen payload under the
@@ -410,31 +408,31 @@ export declare class SessionHandle {
410
408
  refresh(): Promise<Session>;
411
409
  /**
412
410
  * Poll the session record until it reaches a parked/terminal status (idle,
413
- * suspended, error, or any terminal run status). Throws if `timeoutMs`
411
+ * suspended, error, or any terminal session status). Throws if `timeoutMs`
414
412
  * elapses first. Updates the stored record.
415
413
  */
416
- wait(options?: WaitForRunOptions): Promise<Session>;
414
+ wait(options?: WaitForSessionOptions): Promise<Session>;
417
415
  /**
418
- * Fetch the self-contained `RunUnit` for this session: parsed submission,
419
- * attempts, indexed events, outputs, capture failures, proxy-call audit, and
416
+ * Fetch the self-contained `SessionUnit` for this session: parsed submission,
417
+ * attempts, indexed events, session files, capture failures, proxy-call audit, and
420
418
  * resolved skills. Use this when you need fields beyond the session record.
421
419
  *
422
420
  * On the managed plane this is a LEAN summary — the aggregate collections
423
- * (`attempts` / `events.entries` / `outputs` / `rawEventPages`) default to
424
- * empty. For authoritative per-run data use `outputs()` / `events()` /
421
+ * (`attempts` / `events.entries` / `sessionFiles` / `rawEventPages`) default to
422
+ * empty. For authoritative per-session data use `files()` / `events()` /
425
423
  * `messages()`. The returned shape is always type-valid (never `undefined`
426
424
  * where the type promises an array/page), so array/page access is safe.
427
425
  */
428
- unit(): Promise<RunUnit>;
426
+ unit(): Promise<SessionUnit>;
429
427
  /**
430
428
  * Download EVERYTHING public about this session as one zip, assembled
431
429
  * client-side from the public read endpoints. Organised into `metadata/`,
432
- * `events/`, and `outputs/` folders, plus a `manifest.json`. Pass `to` to
430
+ * `events/`, and `files/` folders, plus a `manifest.json`. Pass `to` to
433
431
  * also write the bytes to a file path while still returning them.
434
432
  */
435
- download(options?: OutputDownloadOptions): Promise<Uint8Array>;
433
+ download(options?: DownloadOptions): Promise<Uint8Array>;
436
434
  /** Download only the session record (the `metadata` namespace) as a zip. */
437
- downloadMetadata(options?: OutputDownloadOptions): Promise<Uint8Array>;
435
+ downloadMetadata(options?: DownloadOptions): Promise<Uint8Array>;
438
436
  }
439
437
  export declare class SessionClient {
440
438
  #private;
@@ -445,66 +443,54 @@ export declare class SessionClient {
445
443
  delete(sessionId: string, options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<void>;
446
444
  list(query?: SessionListQuery): Promise<SessionListPage>;
447
445
  /**
448
- * Accessor over one session's captured output files, addressed by id without
449
- * opening a handle. Returns the SAME rich {@link SessionOutputs} surface as
450
- * `session.outputs()` — `aex.sessions.outputs(id).list()` /
446
+ * Accessor over one session's captured files, addressed by id without
447
+ * opening a handle. Returns the SAME rich {@link SessionFiles} surface as
448
+ * `session.files()` — `aex.sessions.files(id).list()` /
451
449
  * `.read(selector)` / `.download()` / … — so the workspace client and the
452
450
  * live handle share one accessor convention.
453
451
  */
454
- outputs(sessionId: string): SessionOutputs;
455
- run(options: SessionRunOptions): Promise<SessionRunResult>;
456
- }
457
- /**
458
- * Cross-run output search (`aex.outputs`). Composed client-side (per-run
459
- * `listSessionOutputs` + the contracts output filter): scope a corpus with
460
- * `query.runIds`, or omit it to scan every run in the workspace. Metadata-only
461
- * (reference hits, no bytes); a content-shaped query throws a typed
462
- * "content search unsupported".
463
- */
464
- export declare class OutputsClient {
465
- #private;
466
- constructor(http: HttpClient);
467
- search(query?: OutputSearchQuery): Promise<OutputSearchPage>;
452
+ files(sessionId: string): SessionFiles;
453
+ start(options: SessionStartOptions): Promise<SessionStartResult>;
468
454
  }
469
- /** A run-facade events accessor (list + polling stream) keyed on a run id. */
470
- export interface RunEvents {
455
+ /** Child-session events accessor (list + polling stream) keyed on a session id. */
456
+ export interface ChildSessionEvents {
471
457
  list(): Promise<readonly AexEventView[]>;
472
458
  stream(options?: StreamEventsOptions): AsyncIterable<AexEventView>;
473
459
  }
474
- /** A run-facade outputs accessor (a subset of {@link SessionOutputs}) keyed on a run id. */
475
- export interface RunOutputs {
476
- list(query?: OutputQuery): Promise<readonly Output[]>;
477
- find(query: OutputQuery): Promise<readonly Output[]>;
478
- findOne(query: OutputQuery): Promise<Output | null>;
479
- read(selector: OutputFileSelector, options?: ReadOutputTextOptions): Promise<OutputText>;
480
- link(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<OutputLink>;
481
- download(selector?: OutputFileSelector, options?: OutputDownloadOptions): Promise<Uint8Array>;
460
+ /** A session facade files accessor (a subset of {@link SessionFiles}) keyed on a session id. */
461
+ export interface SessionFiles {
462
+ list(query?: SessionFileQuery): Promise<readonly SessionFile[]>;
463
+ find(query: SessionFileQuery): Promise<readonly SessionFile[]>;
464
+ findOne(query: SessionFileQuery): Promise<SessionFile | null>;
465
+ read(selector: SessionFileSelector, options?: ReadSessionFileTextOptions): Promise<SessionFileText>;
466
+ link(selectorOrQuery: SessionFileLinkSelector, options?: SessionFileLinkOptions): Promise<SessionFileLink>;
467
+ download(selector?: SessionFileSelector, options?: DownloadOptions): Promise<Uint8Array>;
482
468
  }
483
469
  /**
484
- * A first-class, lineage-discoverable SUBAGENT CHILD run — handed out by
485
- * `session.children()` / `run.children()`, backed by the RUN facade
486
- * (getRun/events/outputs), NOT `openSession`. Every child the platform hands you
487
- * is resolvable through this handle; its lineage (`parentRunId`/`depth`) and
470
+ * A first-class, lineage-discoverable SUBAGENT child session — handed out by
471
+ * `session.children()`, backed by the session-record facade
472
+ * (getSessionRecord/events/files), NOT `openSession`. Every child the platform hands you
473
+ * is resolvable through this handle; its lineage (`parentSessionId`/`depth`) and
488
474
  * terminal outcome (`status`) are first-class.
489
475
  */
490
- export declare class ChildRunHandle {
476
+ export declare class ChildSessionHandle {
491
477
  #private;
492
- constructor(http: HttpClient, ref: ChildRunRef, fetch?: FetchLike);
478
+ constructor(http: HttpClient, ref: ChildSessionRef, fetch?: FetchLike);
493
479
  get id(): string;
494
- get parentRunId(): string;
480
+ get parentSessionId(): string;
495
481
  get depth(): number | undefined;
496
- /** The child's run status (a real run terminal outcome once settled). */
482
+ /** The child's session status (a real session terminal outcome once settled). */
497
483
  get status(): string;
498
- get ref(): ChildRunRef;
499
- /** Re-read the child run record (status, lineage, costTelemetry). */
500
- get(): Promise<Run>;
501
- /** The child's events over the RUN facade (`/runs/:id/events`). */
502
- events(): RunEvents;
503
- /** The child's captured outputs over the RUN facade (`/runs/:id/outputs`). */
504
- outputs(): RunOutputs;
484
+ get ref(): ChildSessionRef;
485
+ /** Re-read the child session record (status, lineage, costTelemetry). */
486
+ get(): Promise<SessionRecord>;
487
+ /** The child's events over the session-record facade (`/sessions/:id/events`). */
488
+ events(): ChildSessionEvents;
489
+ /** The child's captured files over the session-record facade (`/sessions/:id/files`). */
490
+ files(): SessionFiles;
505
491
  /** This child's own subagent children (recursive lineage). */
506
- children(): Promise<readonly ChildRunHandle[]>;
507
- /** Cancel the child run (run facade `POST /runs/:id/cancel`). */
492
+ children(): Promise<readonly ChildSessionHandle[]>;
493
+ /** Cancel the child session (session record facade `POST /sessions/:id/cancel`). */
508
494
  cancel(): Promise<void>;
509
495
  }
510
496
  /**
@@ -547,40 +533,40 @@ export interface StreamEnvelopesOptions {
547
533
  readonly terminalDrainGraceMs?: number;
548
534
  /**
549
535
  * End the stream settle-consistently. By default the iterator ends on the
550
- * AG-UI terminal event (RUN_FINISHED / RUN_ERROR) or the managed-session
536
+ * AG-UI terminal event (TURN_FINISHED / TURN_ERROR) or the managed-session
551
537
  * terminal park (`aex.session.succeeded` / failed / timed_out / cancelled /
552
538
  * idle / suspended). These are render-complete UX signals, emitted before the
553
- * platform commit is necessarily read-consistent, so a `getRun` immediately
539
+ * platform commit is necessarily read-consistent, so a `getSessionRecord` immediately
554
540
  * after can still read `running`. With `settleConsistent: true` the iterator
555
541
  * keeps reading PAST the render terminal until the post-mirror
556
- * `aex.run.settled` barrier when the plane emits it, or a session park
557
- * fallback otherwise. When it ends a subsequent `getRun` is guaranteed
558
- * terminal and `listOutputs` is complete.
559
- * Note: outputs are durable at the RUN_FINISHED event already; this only adds
560
- * the run-RECORD consistency barrier.
542
+ * `aex.session.settled` barrier when the plane emits it, or a session park
543
+ * fallback otherwise. When it ends a subsequent `getSessionRecord` is guaranteed
544
+ * terminal and `listSessionFiles` is complete.
545
+ * Note: files are durable at the TURN_FINISHED event already; this only adds
546
+ * the session-record consistency barrier.
561
547
  */
562
548
  readonly settleConsistent?: boolean;
563
549
  }
564
- export interface WaitForRunOptions {
550
+ export interface WaitForSessionOptions {
565
551
  readonly intervalMs?: number;
566
552
  readonly timeoutMs?: number;
567
553
  readonly signal?: AbortSignal;
568
554
  }
569
- export type OutputFilePathMatch = "exact" | "suffix";
570
- export interface OutputFilePathSelector {
555
+ export type SessionFilePathMatch = "exact" | "suffix";
556
+ export interface SessionFilePathSelector {
571
557
  readonly path: string;
572
- readonly match?: OutputFilePathMatch;
558
+ readonly match?: SessionFilePathMatch;
573
559
  }
574
- export interface OutputFileIdSelector {
560
+ export interface SessionFileIdSelector {
575
561
  readonly id: string;
576
562
  }
577
- export type OutputFileSelector = Output | OutputFileIdSelector | OutputFilePathSelector;
578
- export type OutputLinkSelector = string | OutputFileSelector | OutputQuery;
579
- export interface OutputDownloadOptions {
563
+ export type SessionFileSelector = SessionFile | SessionFileIdSelector | SessionFilePathSelector;
564
+ export type SessionFileLinkSelector = string | SessionFileSelector | SessionFileQuery;
565
+ export interface DownloadOptions {
580
566
  readonly to?: string;
581
567
  /**
582
- * Per-attempt timeout for fetching and reading the selected output body.
583
- * Defaults to 30_000ms; idempotent output downloads retry once on timeout.
568
+ * Per-attempt timeout for fetching and reading the selected file body.
569
+ * Defaults to 30_000ms; idempotent file downloads retry once on timeout.
584
570
  */
585
571
  readonly timeoutMs?: number;
586
572
  }
@@ -613,6 +599,8 @@ export declare class FilesClient {
613
599
  list(): Promise<readonly FileRecord[]>;
614
600
  get(fileId: string): Promise<FileRecord>;
615
601
  delete(fileId: string): Promise<void>;
602
+ /** Cross-session captured-file metadata search. */
603
+ search(query?: SessionFileSearchQuery): Promise<SessionFileSearchPage>;
616
604
  }
617
605
  /**
618
606
  * Workspace skill registry operations exposed under `client.skills`.
@@ -632,7 +620,7 @@ export declare class SkillsClient {
632
620
  * Workspace secret management exposed under `client.secrets`, mirroring
633
621
  * `client.agentsMd` / `client.files`.
634
622
  *
635
- * Lifecycle parity with assets: a `Secret.value(...)` is per-run and
623
+ * Lifecycle parity with assets: a `Secret.value(...)` is per-session and
636
624
  * gone at terminal; `set` (or promoting an ephemeral via `secret.upload`)
637
625
  * persists a named, searchable workspace secret you can `get` (metadata),
638
626
  * `rotate`, `list`, and `delete`. The identity is the `name`; the value rotates
@@ -675,7 +663,7 @@ export declare class SecretsClient {
675
663
  * Unified user-facing client for the aex platform. The same class
676
664
  * powers the published `@aexhq/sdk` SDK and (under the hood) every host-side
677
665
  * subcommand of the in-container `aex` CLI. All operations talk to
678
- * the dashboard BFF and operate on durable run records.
666
+ * the dashboard BFF and operate on durable session records.
679
667
  *
680
668
  * The SDK never asks the caller for a workspace id — workspace identity
681
669
  * is derived server-side from the API key on every request. Use
@@ -689,8 +677,6 @@ export declare class Aex {
689
677
  readonly skills: SkillsClient;
690
678
  readonly secrets: SecretsClient;
691
679
  readonly sessions: SessionClient;
692
- /** Cross-run output search (`aex.outputs.search(...)`). */
693
- readonly outputs: OutputsClient;
694
680
  constructor(apiKey: string, options?: Omit<AexOptions, "apiKey">);
695
681
  constructor(options: AexOptions);
696
682
  /**
@@ -732,7 +718,7 @@ export declare class Aex {
732
718
  /**
733
719
  * Internal: upsert already-uploaded skill metadata into the workspace registry.
734
720
  * The bytes are staged through `_uploadAsset`; this call binds the content hash
735
- * to a mutable workspace skill name before the run references that name.
721
+ * to a mutable workspace skill name before the session references that name.
736
722
  */
737
723
  _upsertSkill(args: {
738
724
  readonly name: string;
@@ -746,31 +732,31 @@ export declare class Aex {
746
732
  * Convenience one-shot on top of the canonical session API:
747
733
  * open a session, send `message` as the first turn, stream until the session
748
734
  * parks (`idle` / `suspended` / `error`), then return the collected text,
749
- * events, outputs, and session record. The returned `runId` is the session id,
750
- * so callers can resume later with `openSession(runId)`.
735
+ * events, files, and session record. The returned `sessionId` is the session id,
736
+ * so callers can resume later with `openSession(sessionId)`.
751
737
  */
752
- run<T = unknown>(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult<T>>;
738
+ start<T = unknown>(options: SessionStartOptions, opts?: StartSessionOptions): Promise<SessionResult<T>>;
753
739
  /**
754
740
  * Fire-and-forget: create the session and POST its first turn WITHOUT awaiting
755
- * settle (the honest counterpart to await-settle `run()`). Resolves with the
756
- * `runId` + a resumable {@link SessionHandle} immediately; observe the run via
757
- * a `webhook`, the event stream, or `openSession(runId)`.
741
+ * settle (the honest counterpart to await-settle `start()`). Resolves with the
742
+ * `sessionId` + a resumable {@link SessionHandle} immediately; observe the session via
743
+ * a `webhook`, the event stream, or `openSession(sessionId)`.
758
744
  */
759
- submit(options: SessionRunOptions): Promise<SubmitResult>;
745
+ submit(options: SessionStartOptions): Promise<SubmitResult>;
760
746
  /**
761
- * Run a batch of one-shot items with a bounded worker pool, returning every
747
+ * SessionRecord a batch of one-shot items with a bounded worker pool, returning every
762
748
  * item's settled result PLUS a REAL cost/usage rollup. The rollup is honest
763
- * because each `run()` awaits settle, so each item's `costUsd`/`usage` is
749
+ * because each `start()` awaits settle, so each item's `costUsd`/`usage` is
764
750
  * populated — a failed item lands in `failed[]`, never a silent `$0` success.
765
751
  * Concurrency is clamped below the workspace tier cap.
766
752
  */
767
- batch<T = unknown>(items: readonly SessionRunOptions[], options?: BatchOptions): Promise<BatchResult<T>>;
753
+ batch<T = unknown>(items: readonly SessionStartOptions[], options?: BatchOptions): Promise<BatchResult<T>>;
768
754
  openSession(options: SessionCreateOptions): Promise<SessionHandle>;
769
755
  openSession(sessionId: string): Promise<SessionHandle>;
770
756
  /**
771
757
  * Delete a workspace asset blob from the shared content-addressed store
772
758
  * (`assets/<workspaceId>/<hash>`). Accepts `sha256:<hex>` or a bare
773
- * 64-hex digest. Runs that already snapshotted the asset are unaffected.
759
+ * 64-hex digest. Sessions that already snapshotted the asset are unaffected.
774
760
  */
775
761
  deleteWorkspaceAsset(hash: string): Promise<void>;
776
762
  whoami(): Promise<WhoAmI>;
@@ -816,4 +802,4 @@ export declare class Aex {
816
802
  * public SDK surface (index.ts controls that).
817
803
  */
818
804
  export declare function mapWithConcurrency<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
819
- export type { OutputFileType, OutputLink, OutputLinkOptions, OutputQuery };
805
+ export type { SessionFileType, SessionFileLink, SessionFileLinkOptions, SessionFileQuery };