@aexhq/sdk 0.38.1 → 0.40.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 (100) hide show
  1. package/README.md +23 -17
  2. package/dist/_contracts/api-key.d.ts +49 -0
  3. package/dist/_contracts/api-key.js +87 -0
  4. package/dist/_contracts/bundle-manifest.d.ts +86 -0
  5. package/dist/_contracts/bundle-manifest.js +157 -0
  6. package/dist/_contracts/error-codes.d.ts +26 -0
  7. package/dist/_contracts/error-codes.js +79 -0
  8. package/dist/_contracts/error-factory.d.ts +32 -0
  9. package/dist/_contracts/error-factory.js +142 -0
  10. package/dist/_contracts/event-envelope.d.ts +33 -10
  11. package/dist/_contracts/event-envelope.js +46 -10
  12. package/dist/_contracts/event-view.d.ts +123 -0
  13. package/dist/_contracts/event-view.js +120 -0
  14. package/dist/_contracts/http.js +12 -3
  15. package/dist/_contracts/index.d.ts +8 -4
  16. package/dist/_contracts/index.js +11 -7
  17. package/dist/_contracts/models.d.ts +15 -0
  18. package/dist/_contracts/models.js +33 -0
  19. package/dist/_contracts/operations.d.ts +70 -2
  20. package/dist/_contracts/operations.js +143 -7
  21. package/dist/_contracts/run-config.d.ts +35 -10
  22. package/dist/_contracts/run-config.js +17 -5
  23. package/dist/_contracts/run-record.d.ts +3 -2
  24. package/dist/_contracts/runtime-types.d.ts +148 -36
  25. package/dist/_contracts/runtime-types.js +33 -1
  26. package/dist/_contracts/sdk-errors.d.ts +61 -2
  27. package/dist/_contracts/sdk-errors.js +83 -3
  28. package/dist/_contracts/sdk-secrets.js +31 -6
  29. package/dist/_contracts/stable.d.ts +14 -0
  30. package/dist/_contracts/stable.js +14 -0
  31. package/dist/_contracts/status.d.ts +28 -1
  32. package/dist/_contracts/status.js +48 -3
  33. package/dist/_contracts/submission.d.ts +157 -14
  34. package/dist/_contracts/submission.js +319 -55
  35. package/dist/_contracts/suggest.d.ts +15 -0
  36. package/dist/_contracts/suggest.js +54 -0
  37. package/dist/asset-upload.d.ts +27 -1
  38. package/dist/asset-upload.js +219 -4
  39. package/dist/asset-upload.js.map +1 -1
  40. package/dist/bundle.d.ts +23 -14
  41. package/dist/bundle.js +39 -20
  42. package/dist/bundle.js.map +1 -1
  43. package/dist/canonical-zip.d.ts +68 -0
  44. package/dist/canonical-zip.js +307 -0
  45. package/dist/canonical-zip.js.map +1 -0
  46. package/dist/cli.mjs +1927 -326
  47. package/dist/cli.mjs.sha256 +1 -1
  48. package/dist/client.d.ts +273 -70
  49. package/dist/client.js +885 -335
  50. package/dist/client.js.map +1 -1
  51. package/dist/fetch-archive.js +14 -14
  52. package/dist/fetch-archive.js.map +1 -1
  53. package/dist/file.d.ts +33 -6
  54. package/dist/file.js +120 -54
  55. package/dist/file.js.map +1 -1
  56. package/dist/index.d.ts +23 -14
  57. package/dist/index.js +31 -14
  58. package/dist/index.js.map +1 -1
  59. package/dist/node-fs.d.ts +26 -9
  60. package/dist/node-fs.js +13 -38
  61. package/dist/node-fs.js.map +1 -1
  62. package/dist/node-walk.d.ts +69 -0
  63. package/dist/node-walk.js +146 -0
  64. package/dist/node-walk.js.map +1 -0
  65. package/dist/retry.d.ts +9 -13
  66. package/dist/retry.js +18 -17
  67. package/dist/retry.js.map +1 -1
  68. package/dist/skill.d.ts +151 -0
  69. package/dist/skill.js +298 -0
  70. package/dist/skill.js.map +1 -0
  71. package/dist/tool.d.ts +14 -2
  72. package/dist/tool.js +33 -7
  73. package/dist/tool.js.map +1 -1
  74. package/dist/version.d.ts +1 -1
  75. package/dist/version.js +1 -1
  76. package/docs/authentication.md +29 -5
  77. package/docs/billing.md +6 -0
  78. package/docs/concepts/agent-tools.md +11 -0
  79. package/docs/concepts/composition.md +3 -3
  80. package/docs/defaults.md +1 -0
  81. package/docs/errors.md +64 -4
  82. package/docs/events.md +84 -49
  83. package/docs/limits-and-quotas.md +24 -0
  84. package/docs/mcp.md +3 -2
  85. package/docs/networking.md +7 -1
  86. package/docs/outputs.md +36 -7
  87. package/docs/provider-runtime-capabilities.md +1 -1
  88. package/docs/quickstart.md +17 -7
  89. package/docs/run-config.md +3 -3
  90. package/docs/secrets.md +14 -0
  91. package/docs/skills.md +74 -44
  92. package/docs/vision-skills.md +3 -3
  93. package/examples/feature-tour.ts +4 -6
  94. package/examples/spike-settle-latency.ts +125 -0
  95. package/package.json +4 -3
  96. package/dist/_contracts/event-guards.d.ts +0 -67
  97. package/dist/_contracts/event-guards.js +0 -36
  98. package/dist/skill-tool.d.ts +0 -102
  99. package/dist/skill-tool.js +0 -190
  100. package/dist/skill-tool.js.map +0 -1
@@ -1 +1 @@
1
- 5e34d5001f6ad9cd7e95730c6b14e0a5ebce55d732b19288a95f04df76fba078 cli.mjs
1
+ 8897a441b79fa1dff980a75c03cb387f105f4583a6139eb47787de30ab77e1d6 cli.mjs
package/dist/client.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { HttpClient, SecretString, type AexEvent, type AgentsMdRecord, type BillingCheckoutRequest, type BillingHostedSession, type BillingLedgerPage, type BillingLedgerQuery, type BillingPortalRequest, type BillingSummary, type DebugSink, type FetchLike, type FileRecord, type Output, type OutputFileType, type OutputLink, type OutputLinkOptions, type OutputQuery, type OutputText, type OutputMode, type ReadOutputTextOptions, type OutputSearchQuery, type OutputSearchPage, type Session, type SessionCreateRequest, type SessionEvent, type SessionListPage, type SessionListQuery, type SessionMessage, type SessionStateChangeAccepted, type SessionTurn, type PlatformEnvironmentInput, type PlatformSubmission, type Run, type RunModel, type RunEvent, type RunTrace, type UsageSummary, type RunWebhookDelivery, type RunProvider, type SecretRecord, type RunUnit, type BuiltinToolName, type RuntimeSize, 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 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";
2
2
  import { AgentsMd } from "./agents-md.js";
3
3
  import { type UploadedAsset } from "./asset-upload.js";
4
- import { File } from "./file.js";
4
+ import { File, type ZipStreamDriver } from "./file.js";
5
5
  import { McpServer } from "./mcp-server.js";
6
6
  import { type RetryOptions } from "./retry.js";
7
7
  import { Secret } from "./secret.js";
8
- import { SkillTool } from "./skill-tool.js";
8
+ import { Skill } from "./skill.js";
9
9
  import { Tool } from "./tool.js";
10
10
  export interface AexOptions {
11
11
  /** Workspace-scoped SDK API key. */
@@ -36,48 +36,47 @@ export interface AexOptions {
36
36
  readonly retry?: RetryOptions | false;
37
37
  }
38
38
  /**
39
- * The settle-consistent result of {@link Aex.run}:
40
- * the one-shot session record plus its events, decoded trace, assistant text,
41
- * and captured outputs — everything a "do it and give me the result" caller
42
- * needs without hand-rolling a session/message/stream loop.
39
+ * The unified SETTLED result of {@link Aex.run}. Extends the contracts
40
+ * {@link SettledResult} (the ONE settled shape `run()` and `done()` share), so
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.
45
+ *
46
+ * `T` is the `responseFormat` decode type: when the run was submitted with a
47
+ * `json_schema` `responseFormat`, {@link outcome} carries the typed decoded
48
+ * value or a typed refusal.
43
49
  */
44
- export interface RunResult {
50
+ export interface RunResult<T = unknown> extends SettledResult {
45
51
  readonly runId: string;
46
52
  /** The session id used as the run-compatible handle. */
47
53
  readonly sessionId?: string;
48
54
  /** Run-compatible view of the underlying session record. */
49
55
  readonly run: Run;
50
- /** The underlying resumable session record. */
56
+ /** The underlying resumable session record (its lifecycle `status` is idle/suspended when resumable). */
51
57
  readonly session?: Session;
52
58
  /** The turn accepted for this one-shot run. */
53
59
  readonly turn?: SessionTurn;
54
- readonly status: string;
55
- /** `true` when the one-shot turn parked the session cleanly (`idle` or `suspended`). */
56
- readonly ok: boolean;
57
60
  /** The assistant's final text. */
58
61
  readonly text: string;
59
62
  /** Assistant messages projected from the settled event stream. */
60
63
  readonly messages: readonly Message[];
61
- /** The session turn event stream. */
62
- readonly events: readonly RunEvent[];
64
+ /** The session turn event stream — each event carries the `is*()` type-guard methods. */
65
+ readonly events: readonly AexEventView[];
63
66
  /** Decoded view of the events: tool calls + usage + assistant text. */
64
67
  readonly trace: RunTrace;
65
68
  /** The run's captured output files. */
66
69
  readonly outputs: readonly Output[];
67
- /** Aggregate token usage when the deployment exposes it on the record. */
68
- readonly usage?: UsageSummary;
69
70
  /**
70
- * Settle-time showback estimate (USD), from the settle-stamped session
71
- * record's `costUsd` (the full `costTelemetry` block is served on
72
- * `GET /api/runs/:id`, not on the session projection). The settle
73
- * write lands tens of seconds AFTER the turn parks, so by default this is
74
- * usually absent on a fresh run — pass `settleConsistent: true` to wait for
75
- * it, or read `sessions.get(runId).costUsd` later.
71
+ * The typed schema-decode outcome present only when the run was submitted
72
+ * with a `json_schema` `responseFormat`: `{ kind:'decoded', value }` or
73
+ * `{ kind:'refused', reason }`. There is no untyped path that yields a
74
+ * hallucinated object.
76
75
  */
77
- readonly costUsd?: number;
78
- /** The run's error message when `!ok`. */
79
- readonly error?: string;
76
+ readonly outcome?: RunOutcome<T>;
80
77
  }
78
+ /** How a one-shot / turn resolves: at the render-complete park, or (default) at the settle commit. */
79
+ export type SettleAwait = "park" | "settle";
81
80
  /** Options for {@link Aex.run}. */
82
81
  export interface RunCollectOptions {
83
82
  /** Overall wait budget (ms) for the one-shot session turn to park. */
@@ -88,13 +87,25 @@ export interface RunCollectOptions {
88
87
  /** Throw a {@link RunStateError} when the run does not succeed. Default false. */
89
88
  readonly throwOnFailure?: boolean;
90
89
  /**
91
- * Wait (bounded, ~60s) for the settle write after the turn parks, so the
92
- * result carries the settle-stamped `costUsd`/`usage`/`errorMessage`. The
93
- * settle lambda lands tens of seconds after the park event, so this trades
94
- * latency for a complete record. Default false: return at park; read
95
- * `sessions.get(runId)` later for the showback.
90
+ * When the result resolves. `'settle'` (DEFAULT) waits (bounded) for the
91
+ * settle commit after the turn parks, so `costUsd`/`usage`/terminal `status`
92
+ * are always present. `'park'` returns at the render-complete park event for
93
+ * latency-sensitive streaming cost/usage are then best-effort (the settle
94
+ * write lands tens of seconds later).
96
95
  */
97
- readonly settleConsistent?: boolean;
96
+ readonly await?: SettleAwait;
97
+ }
98
+ /** The result of {@link Aex.submit}: the run id + a resumable session handle. */
99
+ export interface SubmitResult {
100
+ readonly runId: string;
101
+ readonly session: SessionHandle;
102
+ }
103
+ /** Options for {@link Aex.batch}. */
104
+ export interface BatchOptions {
105
+ /** Max concurrent items, clamped to `[1, 10]` (below the workspace tier cap). */
106
+ readonly concurrency?: number;
107
+ /** Reserved — the cost/usage rollup is always computed on the result. */
108
+ readonly rollup?: boolean;
98
109
  }
99
110
  export type SessionInput = string | readonly string[];
100
111
  export interface SessionEnvironmentOptions extends Omit<PlatformEnvironmentInput, "envVars"> {
@@ -105,16 +116,23 @@ export interface SessionOverrides {
105
116
  readonly idleTtl?: string;
106
117
  readonly timeout?: string;
107
118
  readonly maxSpendUsd?: number;
119
+ /**
120
+ * Per-run iteration cap (agent loop turns). Defaults + ceiling are enforced
121
+ * server-side; omit to accept the platform default. A positive integer.
122
+ */
123
+ readonly maxTurns?: number;
108
124
  }
109
125
  /**
110
126
  * Options for opening a session (the low-level API) or a one-shot `run`.
111
127
  * Everything the agent needs is spelled out at the call site:
112
128
  *
113
129
  * - `model` / `system` — the agent's brief.
114
- * - `tools` — custom `Tool` bundles, skill-tools
115
- * (`Tools.fromSkillDir` / `Tools.fromSkillUrl`), and builtin tool-name
116
- * references; local composition instances are materialized to the hosted
117
- * asset store before the session lands.
130
+ * - `tools` — custom `Tool` bundles and builtin tool-name references; local
131
+ * custom-tool instances are materialized to the hosted asset store before
132
+ * the session lands.
133
+ * - `skills` workspace skill bundles from `Skill.fromDir` / `Skill.fromUrl`
134
+ * / `Skill.fromFiles` / …; the SDK upserts them by name before the session
135
+ * lands, and the wire submission references only those names.
118
136
  * - `agentsMd` / `files` — local composition instances
119
137
  * (`AgentsMd.fromContent` / `File.fromBytes`, …), materialized to the
120
138
  * hosted asset store before the session lands.
@@ -138,12 +156,17 @@ export interface SessionCreateOptions {
138
156
  readonly model: RunModel;
139
157
  readonly system?: string;
140
158
  /**
141
- * Tools available to the agent. Each entry is a custom {@link Tool} bundle, a
142
- * skill-tool ({@link SkillTool} from `Tools.fromSkillDir` / `Tools.fromSkillUrl`),
143
- * or a BUILTIN tool reference — a bare name string, preferably
144
- * `BuiltinTools.<name>` so a typo is a compile error.
159
+ * Tools available to the agent. Each entry is a custom {@link Tool} bundle or
160
+ * a BUILTIN tool reference a bare name string, preferably `BuiltinTools.<name>`
161
+ * so a typo is a compile error.
162
+ */
163
+ readonly tools?: readonly (Tool | BuiltinToolName)[];
164
+ /**
165
+ * Workspace skills available to the agent. Build them with the `Skill.from*`
166
+ * factories; the SDK upserts each bundle into the workspace skill registry by
167
+ * name, then sends only `{ kind:"skill", name }` in the submission.
145
168
  */
146
- readonly tools?: readonly (Tool | SkillTool | BuiltinToolName)[];
169
+ readonly skills?: readonly Skill[];
147
170
  readonly agentsMd?: readonly AgentsMd[];
148
171
  readonly files?: readonly File[];
149
172
  readonly mcpServers?: readonly McpServer[];
@@ -167,10 +190,32 @@ export interface SessionCreateOptions {
167
190
  */
168
191
  readonly includeBuiltinTools?: boolean;
169
192
  /**
170
- * Assistant-output granularity. `"buffered"` (default) delivers one event per
171
- * assistant message; `"stream"` delivers per-token text deltas.
193
+ * Assistant-output granularity. `"buffered"` (default) delivers ONE coalesced
194
+ * `TEXT_MESSAGE_CONTENT` per assistant message. `"stream"` delivers per-token
195
+ * `TEXT_MESSAGE_CONTENT` DELTAS (each `event.isTextMessage()` with
196
+ * `event.data.delta === true`) as they arrive — but this is CAPABILITY-GATED:
197
+ * `"stream"` is only honored for a streamable provider (submitting `"stream"`
198
+ * against a non-streamable one is rejected at submit, never silently
199
+ * downgraded). A coalesced final `TEXT_MESSAGE_CONTENT` ALWAYS follows the
200
+ * deltas, so a buffered consumer sees the same final text either way; deltas
201
+ * are provisional until that coalesced block.
172
202
  */
173
203
  readonly outputMode?: OutputMode;
204
+ /**
205
+ * Structured-output policy. `{ kind:'text' }` (default) is free-form;
206
+ * `{ kind:'json_schema', schema, strict?, name? }` requests provider-native
207
+ * constrained decode against `schema`. The typed outcome is read from
208
+ * `run<T>()`'s `result.outcome` (`{ kind:'decoded', value }` or
209
+ * `{ kind:'refused', reason }`) — never an untyped hallucinated object.
210
+ */
211
+ readonly responseFormat?: ResponseFormat;
212
+ /**
213
+ * Declarative HITL write-gate: the platform parks the session
214
+ * `awaiting_approval` BEFORE dispatching any tool in `tools`, independent of
215
+ * model prose. Resume with `session.approve()` or reject with
216
+ * `session.deny()`.
217
+ */
218
+ readonly approvalGate?: ApprovalGate;
174
219
  readonly metadata?: PlatformSubmission["metadata"];
175
220
  readonly idempotencyKey?: string;
176
221
  /** BYOK provider key(s), keyed by provider. */
@@ -198,6 +243,12 @@ export interface SessionSendOptions {
198
243
  readonly webSocketFactory?: WebSocketFactory;
199
244
  readonly idleTimeoutMs?: number;
200
245
  readonly pingIntervalMs?: number;
246
+ /**
247
+ * When the turn resolves. `'settle'` (DEFAULT) awaits the settle commit so
248
+ * `costUsd`/`usage`/terminal `status` are present on the result; `'park'`
249
+ * returns at the render-complete park event (cost/usage then best-effort).
250
+ */
251
+ readonly await?: SettleAwait;
201
252
  }
202
253
  export interface SessionRunOptions extends SessionCreateOptions {
203
254
  readonly message: SessionInput;
@@ -205,22 +256,29 @@ export interface SessionRunOptions extends SessionCreateOptions {
205
256
  readonly messageIdempotencyKey?: string;
206
257
  readonly stream?: Omit<SessionSendOptions, "idempotencyKey">;
207
258
  }
208
- export interface SessionTurnResult {
259
+ /**
260
+ * The unified SETTLED result of one turn (`session.send(...).done()`). Extends
261
+ * the contracts {@link SettledResult}, so `done()` returns the SAME shape as
262
+ * `run()`: the terminal `status` (a {@link SessionTerminalOutcome}), `ok`,
263
+ * `costUsd`, and `usage` are always present (the turn awaits settle by default).
264
+ */
265
+ export interface SessionTurnResult<T = unknown> extends SettledResult {
209
266
  readonly sessionId: string;
210
267
  readonly session: Session;
211
268
  readonly turn: SessionTurn;
212
- readonly status: string;
213
269
  readonly text: string;
214
- readonly events: readonly SessionEvent[];
270
+ readonly events: readonly AexEventView[];
215
271
  readonly outputs: readonly Output[];
216
272
  readonly messages: readonly Message[];
273
+ /** The typed schema-decode outcome when a `json_schema` `responseFormat` was set. */
274
+ readonly outcome?: RunOutcome<T>;
217
275
  }
218
276
  export interface SessionRunResult extends SessionTurnResult {
219
277
  }
220
- export declare class SessionTurnStream implements AsyncIterable<SessionEvent> {
278
+ export declare class SessionTurnStream implements AsyncIterable<AexEventView> {
221
279
  #private;
222
- constructor(run: () => AsyncGenerator<SessionEvent, SessionTurnResult, void>);
223
- [Symbol.asyncIterator](): AsyncIterator<SessionEvent>;
280
+ constructor(run: () => AsyncGenerator<AexEventView, SessionTurnResult, void>);
281
+ [Symbol.asyncIterator](): AsyncIterator<AexEventView>;
224
282
  done(): Promise<SessionTurnResult>;
225
283
  }
226
284
  type CallableSessionMessages = SessionMessages & (() => SessionMessages);
@@ -237,16 +295,18 @@ export interface SessionMessages {
237
295
  first(): Promise<Message | undefined>;
238
296
  }
239
297
  /**
240
- * Accessor over the session's event stream (`session.events()`): the buffered
241
- * `SessionEvent` snapshots, the polling `RunEvent` iterator, the live
242
- * coordinator envelope iterator, and the events-namespace archive.
298
+ * Accessor over the session's event stream (`session.events()`). EVERY surface
299
+ * yields the one canonical {@link AexEventView} (guard-bearing, non-optional
300
+ * populated `sequence`): the buffered snapshot `list()`, the polling `stream()`
301
+ * iterator, the live coordinator `streamEnvelopes()` iterator, and the
302
+ * events-namespace archive.
243
303
  */
244
304
  export interface SessionEvents {
245
- list(): Promise<readonly SessionEvent[]>;
246
- last(): Promise<SessionEvent | undefined>;
247
- first(): Promise<SessionEvent | undefined>;
248
- stream(options?: StreamEventsOptions): AsyncIterable<RunEvent>;
249
- streamEnvelopes(options?: StreamEnvelopesOptions): AsyncIterable<AexEvent>;
305
+ list(): Promise<readonly AexEventView[]>;
306
+ last(): Promise<AexEventView | undefined>;
307
+ first(): Promise<AexEventView | undefined>;
308
+ stream(options?: StreamEventsOptions): AsyncIterable<AexEventView>;
309
+ streamEnvelopes(options?: StreamEnvelopesOptions): AsyncIterable<AexEventView>;
250
310
  archiveLink(options?: OutputLinkOptions): Promise<OutputLink>;
251
311
  /** Download the events-namespace archive as a zip. */
252
312
  download(options?: OutputDownloadOptions): Promise<Uint8Array>;
@@ -262,11 +322,20 @@ export interface SessionOutputs {
262
322
  read(selector: OutputFileSelector, options?: ReadOutputTextOptions): Promise<OutputText>;
263
323
  find(query: OutputQuery): Promise<readonly Output[]>;
264
324
  findOne(query: OutputQuery): Promise<Output | null>;
325
+ /**
326
+ * Search THIS session's captured outputs by filename (`string | RegExp`) /
327
+ * extension / content type. Metadata-only (reference hits, no bytes). A
328
+ * content-shaped query throws a typed "content search unsupported" rather than
329
+ * silently returning 0 hits.
330
+ */
331
+ search(query?: PerSessionOutputSearchQuery): Promise<OutputSearchPage>;
265
332
  link(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<OutputLink>;
266
333
  fetch(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<Response>;
267
334
  /** No selector = outputs-namespace zip; with selector = one file's raw bytes. */
268
335
  download(selector?: OutputFileSelector, options?: OutputDownloadOptions): Promise<Uint8Array>;
269
336
  }
337
+ /** A per-session output search — {@link OutputSearchQuery} without the cross-run `runIds` corpus. */
338
+ export type PerSessionOutputSearchQuery = Omit<OutputSearchQuery, "runIds">;
270
339
  /**
271
340
  * Accessor over the session's webhook delivery ledger (`session.webhooks()`).
272
341
  */
@@ -292,6 +361,24 @@ export declare class SessionHandle {
292
361
  cancel(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
293
362
  resume(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
294
363
  delete(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<void>;
364
+ /**
365
+ * Request the HITL write-gate: park this session `awaiting_approval` before
366
+ * its next gated action. Imperative counterpart to the declarative
367
+ * `approvalGate` submission option. Resume with {@link approve} / reject with
368
+ * {@link deny}.
369
+ */
370
+ requestApproval(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
371
+ /** Approve an `awaiting_approval` session so the held turn resumes (→ running). */
372
+ approve(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
373
+ /** Deny an `awaiting_approval` session so the held turn is cancelled (→ cancelled). */
374
+ deny(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
375
+ /**
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) —
378
+ * NOT `openSession` — so every child the platform hands you is resolvable, with
379
+ * its lineage (`parentRunId`/`depth`) and terminal outcome exposed.
380
+ */
381
+ children(): Promise<readonly ChildRunHandle[]>;
295
382
  /**
296
383
  * Accessor for the session's assistant messages. `all()` returns them
297
384
  * oldest-first; `last()`/`first()` return a single entry or `undefined` when
@@ -301,7 +388,7 @@ export declare class SessionHandle {
301
388
  get messages(): CallableSessionMessages;
302
389
  /**
303
390
  * Accessor for the session's event stream: the buffered `SessionEvent`
304
- * snapshots (`list`/`last`/`first`), the polling `RunEvent` iterator
391
+ * snapshots (`list`/`last`/`first`), the polling `AexEventView` iterator
305
392
  * (`stream`), the live coordinator envelope iterator (`streamEnvelopes`), and
306
393
  * the events-namespace archive (`archiveLink`/`download`).
307
394
  */
@@ -365,19 +452,70 @@ export declare class SessionClient {
365
452
  * live handle share one accessor convention.
366
453
  */
367
454
  outputs(sessionId: string): SessionOutputs;
368
- /**
369
- * Find output files across sessions by filename / extension / content type.
370
- * Returns lean REFERENCE hits (never bytes; fetch content with `readOutput`).
371
- * Scope the search to a corpus with `query.runIds` (a session-id allow-list);
372
- * omit it to scan every session in the workspace. Composed client-side (per-
373
- * session `listSessionOutputs` + the contracts output filter), bounded by
374
- * `query.limit` (default 100).
375
- */
376
- searchOutputs(query?: OutputSearchQuery): Promise<OutputSearchPage>;
377
455
  run(options: SessionRunOptions): Promise<SessionRunResult>;
378
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>;
468
+ }
469
+ /** A run-facade events accessor (list + polling stream) keyed on a run id. */
470
+ export interface RunEvents {
471
+ list(): Promise<readonly AexEventView[]>;
472
+ stream(options?: StreamEventsOptions): AsyncIterable<AexEventView>;
473
+ }
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>;
482
+ }
483
+ /**
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
488
+ * terminal outcome (`status`) are first-class.
489
+ */
490
+ export declare class ChildRunHandle {
491
+ #private;
492
+ constructor(http: HttpClient, ref: ChildRunRef, fetch?: FetchLike);
493
+ get id(): string;
494
+ get parentRunId(): string;
495
+ get depth(): number | undefined;
496
+ /** The child's run status (a real run terminal outcome once settled). */
497
+ 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;
505
+ /** This child's own subagent children (recursive lineage). */
506
+ children(): Promise<readonly ChildRunHandle[]>;
507
+ /** Cancel the child run (run facade `POST /runs/:id/cancel`). */
508
+ cancel(): Promise<void>;
509
+ }
510
+ /**
511
+ * The terminal READ a turn's terminal event carries: either a
512
+ * {@link SessionTerminalOutcome} (succeeded/failed/timed_out/cancelled) or a
513
+ * resumable/held lifecycle park (idle/suspended/awaiting_approval). The SDK
514
+ * READS this from the carried event — it never re-derives a lossy `idle`.
515
+ */
516
+ export type SessionTerminalRead = SessionTerminalOutcome | "idle" | "suspended" | "awaiting_approval";
379
517
  export interface StreamEventsOptions {
380
- /** Poll interval in ms for the `RunEvent` snapshot loop. Default 1000. */
518
+ /** Poll interval in ms for the event snapshot loop. Default 1000. */
381
519
  readonly intervalMs?: number;
382
520
  readonly signal?: AbortSignal;
383
521
  }
@@ -446,6 +584,20 @@ export declare class FilesClient {
446
584
  get(fileId: string): Promise<FileRecord>;
447
585
  delete(fileId: string): Promise<void>;
448
586
  }
587
+ /**
588
+ * Workspace skill registry operations exposed under `client.skills`.
589
+ *
590
+ * Session creation normally passes `Skill.from*(...)` instances directly in the
591
+ * `skills` option (auto-upserted by name). This namespace is the metadata
592
+ * read/delete surface for the named workspace skill registry.
593
+ */
594
+ export declare class SkillsClient {
595
+ #private;
596
+ constructor(http: HttpClient);
597
+ list(): Promise<readonly SkillRecord[]>;
598
+ get(name: string): Promise<SkillRecord>;
599
+ delete(name: string): Promise<void>;
600
+ }
449
601
  /**
450
602
  * Workspace secret management exposed under `client.secrets`, mirroring
451
603
  * `client.agentsMd` / `client.files`.
@@ -504,8 +656,11 @@ export declare class Aex {
504
656
  #private;
505
657
  readonly agentsMd: AgentsMdClient;
506
658
  readonly files: FilesClient;
659
+ readonly skills: SkillsClient;
507
660
  readonly secrets: SecretsClient;
508
661
  readonly sessions: SessionClient;
662
+ /** Cross-run output search (`aex.outputs.search(...)`). */
663
+ readonly outputs: OutputsClient;
509
664
  constructor(apiKey: string, options?: Omit<AexOptions, "apiKey">);
510
665
  constructor(options: AexOptions);
511
666
  /**
@@ -523,8 +678,9 @@ export declare class Aex {
523
678
  /**
524
679
  * Internal: materialize raw bytes to the content-addressable asset store
525
680
  * (`/assets/presign` → PUT → `/assets/finalize`). Used by the session-create
526
- * prepare step to upload draft skill-tool / tool / agentsMd / file bundles so
527
- * the wire submission carries only plain `kind:"asset"` / `kind:"skill"` refs.
681
+ * prepare step to upload draft skill / tool / agentsMd / file bundles so
682
+ * the wire submission carries only plain `kind:"asset"` refs (skills resolve
683
+ * to name-only `kind:"skill"` refs after their bytes upload).
528
684
  * NOT part of the public API.
529
685
  */
530
686
  _uploadAsset(args: {
@@ -532,6 +688,30 @@ export declare class Aex {
532
688
  readonly hash: string;
533
689
  readonly contentType?: string;
534
690
  }): Promise<UploadedAsset>;
691
+ /**
692
+ * Internal: materialize a LARGE draft (a `File.fromPath` over the streaming
693
+ * threshold) to the content store via the two-pass streaming multipart flow —
694
+ * hash the deterministic canonical-zip stream, presign by hash (dedup still
695
+ * short-circuits), then upload it in parts. Bounded memory (one entry + one
696
+ * part). NOT part of the public API.
697
+ */
698
+ _uploadAssetStream(args: {
699
+ readonly drive: ZipStreamDriver;
700
+ readonly contentType?: string;
701
+ }): Promise<UploadedAsset>;
702
+ /**
703
+ * Internal: upsert already-uploaded skill metadata into the workspace registry.
704
+ * The bytes are staged through `_uploadAsset`; this call binds the content hash
705
+ * to a mutable workspace skill name before the run references that name.
706
+ */
707
+ _upsertSkill(args: {
708
+ readonly name: string;
709
+ readonly contentHash: string;
710
+ readonly description: string;
711
+ readonly sizeBytes: number;
712
+ }): Promise<{
713
+ readonly updated: boolean;
714
+ }>;
535
715
  /**
536
716
  * Convenience one-shot on top of the canonical session API:
537
717
  * open a session, send `message` as the first turn, stream until the session
@@ -539,7 +719,22 @@ export declare class Aex {
539
719
  * events, outputs, and session record. The returned `runId` is the session id,
540
720
  * so callers can resume later with `openSession(runId)`.
541
721
  */
542
- run(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult>;
722
+ run<T = unknown>(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult<T>>;
723
+ /**
724
+ * Fire-and-forget: create the session and POST its first turn WITHOUT awaiting
725
+ * settle (the honest counterpart to await-settle `run()`). Resolves with the
726
+ * `runId` + a resumable {@link SessionHandle} immediately; observe the run via
727
+ * a `webhook`, the event stream, or `openSession(runId)`.
728
+ */
729
+ submit(options: SessionRunOptions): Promise<SubmitResult>;
730
+ /**
731
+ * Run a batch of one-shot items with a bounded worker pool, returning every
732
+ * item's settled result PLUS a REAL cost/usage rollup. The rollup is honest
733
+ * because each `run()` awaits settle, so each item's `costUsd`/`usage` is
734
+ * populated — a failed item lands in `failed[]`, never a silent `$0` success.
735
+ * Concurrency is clamped below the workspace tier cap.
736
+ */
737
+ batch<T = unknown>(items: readonly SessionRunOptions[], options?: BatchOptions): Promise<BatchResult<T>>;
543
738
  openSession(options: SessionCreateOptions): Promise<SessionHandle>;
544
739
  openSession(sessionId: string): Promise<SessionHandle>;
545
740
  /**
@@ -583,4 +778,12 @@ export declare class Aex {
583
778
  */
584
779
  webhookSigningSecret(): Promise<WebhookSigningSecret>;
585
780
  }
781
+ /**
782
+ * Map `items` through `fn` with at most `limit` in flight, PRESERVING ORDER (the
783
+ * result at index `i` is `fn(items[i], i)` regardless of completion order). A
784
+ * rejection from any call propagates (the first to reject wins) once the
785
+ * in-flight batch settles. Exported for direct unit testing; not part of the
786
+ * public SDK surface (index.ts controls that).
787
+ */
788
+ export declare function mapWithConcurrency<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
586
789
  export type { OutputFileType, OutputLink, OutputLinkOptions, OutputQuery };