@aexhq/sdk 0.39.0 → 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.
- package/README.md +22 -16
- package/dist/_contracts/api-key.d.ts +49 -0
- package/dist/_contracts/api-key.js +87 -0
- package/dist/_contracts/bundle-manifest.d.ts +86 -0
- package/dist/_contracts/bundle-manifest.js +157 -0
- package/dist/_contracts/error-codes.d.ts +26 -0
- package/dist/_contracts/error-codes.js +79 -0
- package/dist/_contracts/error-factory.d.ts +32 -0
- package/dist/_contracts/error-factory.js +142 -0
- package/dist/_contracts/event-envelope.d.ts +33 -10
- package/dist/_contracts/event-envelope.js +46 -10
- package/dist/_contracts/event-view.d.ts +123 -0
- package/dist/_contracts/event-view.js +120 -0
- package/dist/_contracts/http.js +12 -3
- package/dist/_contracts/index.d.ts +8 -4
- package/dist/_contracts/index.js +11 -7
- package/dist/_contracts/models.d.ts +15 -0
- package/dist/_contracts/models.js +33 -0
- package/dist/_contracts/operations.d.ts +50 -2
- package/dist/_contracts/operations.js +100 -7
- package/dist/_contracts/run-record.d.ts +3 -2
- package/dist/_contracts/runtime-types.d.ts +126 -36
- package/dist/_contracts/runtime-types.js +33 -1
- package/dist/_contracts/sdk-errors.d.ts +61 -2
- package/dist/_contracts/sdk-errors.js +83 -3
- package/dist/_contracts/sdk-secrets.js +31 -6
- package/dist/_contracts/stable.d.ts +14 -0
- package/dist/_contracts/stable.js +14 -0
- package/dist/_contracts/status.d.ts +28 -1
- package/dist/_contracts/status.js +48 -3
- package/dist/_contracts/submission.d.ts +79 -2
- package/dist/_contracts/submission.js +148 -5
- package/dist/_contracts/suggest.d.ts +15 -0
- package/dist/_contracts/suggest.js +54 -0
- package/dist/asset-upload.d.ts +26 -0
- package/dist/asset-upload.js +218 -3
- package/dist/asset-upload.js.map +1 -1
- package/dist/bundle.d.ts +14 -3
- package/dist/bundle.js +34 -14
- package/dist/bundle.js.map +1 -1
- package/dist/canonical-zip.d.ts +68 -0
- package/dist/canonical-zip.js +307 -0
- package/dist/canonical-zip.js.map +1 -0
- package/dist/cli.mjs +1900 -340
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +217 -58
- package/dist/client.js +746 -261
- package/dist/client.js.map +1 -1
- package/dist/file.d.ts +33 -6
- package/dist/file.js +120 -54
- package/dist/file.js.map +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/dist/node-fs.d.ts +26 -9
- package/dist/node-fs.js +13 -38
- package/dist/node-fs.js.map +1 -1
- package/dist/node-walk.d.ts +69 -0
- package/dist/node-walk.js +146 -0
- package/dist/node-walk.js.map +1 -0
- package/dist/retry.d.ts +9 -13
- package/dist/retry.js +18 -17
- package/dist/retry.js.map +1 -1
- package/dist/skill.d.ts +16 -4
- package/dist/skill.js +18 -9
- package/dist/skill.js.map +1 -1
- package/dist/tool.d.ts +14 -2
- package/dist/tool.js +33 -7
- package/dist/tool.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/authentication.md +29 -5
- package/docs/billing.md +6 -0
- package/docs/concepts/agent-tools.md +11 -0
- package/docs/defaults.md +1 -0
- package/docs/errors.md +64 -4
- package/docs/events.md +84 -49
- package/docs/limits-and-quotas.md +24 -0
- package/docs/networking.md +7 -1
- package/docs/outputs.md +36 -7
- package/docs/quickstart.md +17 -7
- package/docs/run-config.md +3 -3
- package/docs/secrets.md +14 -0
- package/examples/feature-tour.ts +4 -6
- package/examples/spike-settle-latency.ts +125 -0
- package/package.json +4 -3
- package/dist/_contracts/event-guards.d.ts +0 -67
- package/dist/_contracts/event-guards.js +0 -36
package/dist/cli.mjs.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8897a441b79fa1dff980a75c03cb387f105f4583a6139eb47787de30ab77e1d6 cli.mjs
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HttpClient, SecretString, type
|
|
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";
|
|
@@ -36,48 +36,47 @@ export interface AexOptions {
|
|
|
36
36
|
readonly retry?: RetryOptions | false;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* The
|
|
40
|
-
* the
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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
|
|
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
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* `
|
|
73
|
-
*
|
|
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
|
|
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
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* latency
|
|
95
|
-
*
|
|
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
|
|
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,6 +116,11 @@ 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`.
|
|
@@ -174,10 +190,32 @@ export interface SessionCreateOptions {
|
|
|
174
190
|
*/
|
|
175
191
|
readonly includeBuiltinTools?: boolean;
|
|
176
192
|
/**
|
|
177
|
-
* Assistant-output granularity. `"buffered"` (default) delivers
|
|
178
|
-
* assistant message
|
|
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.
|
|
179
202
|
*/
|
|
180
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;
|
|
181
219
|
readonly metadata?: PlatformSubmission["metadata"];
|
|
182
220
|
readonly idempotencyKey?: string;
|
|
183
221
|
/** BYOK provider key(s), keyed by provider. */
|
|
@@ -205,6 +243,12 @@ export interface SessionSendOptions {
|
|
|
205
243
|
readonly webSocketFactory?: WebSocketFactory;
|
|
206
244
|
readonly idleTimeoutMs?: number;
|
|
207
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;
|
|
208
252
|
}
|
|
209
253
|
export interface SessionRunOptions extends SessionCreateOptions {
|
|
210
254
|
readonly message: SessionInput;
|
|
@@ -212,22 +256,29 @@ export interface SessionRunOptions extends SessionCreateOptions {
|
|
|
212
256
|
readonly messageIdempotencyKey?: string;
|
|
213
257
|
readonly stream?: Omit<SessionSendOptions, "idempotencyKey">;
|
|
214
258
|
}
|
|
215
|
-
|
|
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 {
|
|
216
266
|
readonly sessionId: string;
|
|
217
267
|
readonly session: Session;
|
|
218
268
|
readonly turn: SessionTurn;
|
|
219
|
-
readonly status: string;
|
|
220
269
|
readonly text: string;
|
|
221
|
-
readonly events: readonly
|
|
270
|
+
readonly events: readonly AexEventView[];
|
|
222
271
|
readonly outputs: readonly Output[];
|
|
223
272
|
readonly messages: readonly Message[];
|
|
273
|
+
/** The typed schema-decode outcome when a `json_schema` `responseFormat` was set. */
|
|
274
|
+
readonly outcome?: RunOutcome<T>;
|
|
224
275
|
}
|
|
225
276
|
export interface SessionRunResult extends SessionTurnResult {
|
|
226
277
|
}
|
|
227
|
-
export declare class SessionTurnStream implements AsyncIterable<
|
|
278
|
+
export declare class SessionTurnStream implements AsyncIterable<AexEventView> {
|
|
228
279
|
#private;
|
|
229
|
-
constructor(run: () => AsyncGenerator<
|
|
230
|
-
[Symbol.asyncIterator](): AsyncIterator<
|
|
280
|
+
constructor(run: () => AsyncGenerator<AexEventView, SessionTurnResult, void>);
|
|
281
|
+
[Symbol.asyncIterator](): AsyncIterator<AexEventView>;
|
|
231
282
|
done(): Promise<SessionTurnResult>;
|
|
232
283
|
}
|
|
233
284
|
type CallableSessionMessages = SessionMessages & (() => SessionMessages);
|
|
@@ -244,16 +295,18 @@ export interface SessionMessages {
|
|
|
244
295
|
first(): Promise<Message | undefined>;
|
|
245
296
|
}
|
|
246
297
|
/**
|
|
247
|
-
* Accessor over the session's event stream (`session.events()`)
|
|
248
|
-
*
|
|
249
|
-
*
|
|
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.
|
|
250
303
|
*/
|
|
251
304
|
export interface SessionEvents {
|
|
252
|
-
list(): Promise<readonly
|
|
253
|
-
last(): Promise<
|
|
254
|
-
first(): Promise<
|
|
255
|
-
stream(options?: StreamEventsOptions): AsyncIterable<
|
|
256
|
-
streamEnvelopes(options?: StreamEnvelopesOptions): AsyncIterable<
|
|
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>;
|
|
257
310
|
archiveLink(options?: OutputLinkOptions): Promise<OutputLink>;
|
|
258
311
|
/** Download the events-namespace archive as a zip. */
|
|
259
312
|
download(options?: OutputDownloadOptions): Promise<Uint8Array>;
|
|
@@ -269,11 +322,20 @@ export interface SessionOutputs {
|
|
|
269
322
|
read(selector: OutputFileSelector, options?: ReadOutputTextOptions): Promise<OutputText>;
|
|
270
323
|
find(query: OutputQuery): Promise<readonly Output[]>;
|
|
271
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>;
|
|
272
332
|
link(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<OutputLink>;
|
|
273
333
|
fetch(selectorOrQuery: OutputLinkSelector, options?: OutputLinkOptions): Promise<Response>;
|
|
274
334
|
/** No selector = outputs-namespace zip; with selector = one file's raw bytes. */
|
|
275
335
|
download(selector?: OutputFileSelector, options?: OutputDownloadOptions): Promise<Uint8Array>;
|
|
276
336
|
}
|
|
337
|
+
/** A per-session output search — {@link OutputSearchQuery} without the cross-run `runIds` corpus. */
|
|
338
|
+
export type PerSessionOutputSearchQuery = Omit<OutputSearchQuery, "runIds">;
|
|
277
339
|
/**
|
|
278
340
|
* Accessor over the session's webhook delivery ledger (`session.webhooks()`).
|
|
279
341
|
*/
|
|
@@ -299,6 +361,24 @@ export declare class SessionHandle {
|
|
|
299
361
|
cancel(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
|
|
300
362
|
resume(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
|
|
301
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[]>;
|
|
302
382
|
/**
|
|
303
383
|
* Accessor for the session's assistant messages. `all()` returns them
|
|
304
384
|
* oldest-first; `last()`/`first()` return a single entry or `undefined` when
|
|
@@ -308,7 +388,7 @@ export declare class SessionHandle {
|
|
|
308
388
|
get messages(): CallableSessionMessages;
|
|
309
389
|
/**
|
|
310
390
|
* Accessor for the session's event stream: the buffered `SessionEvent`
|
|
311
|
-
* snapshots (`list`/`last`/`first`), the polling `
|
|
391
|
+
* snapshots (`list`/`last`/`first`), the polling `AexEventView` iterator
|
|
312
392
|
* (`stream`), the live coordinator envelope iterator (`streamEnvelopes`), and
|
|
313
393
|
* the events-namespace archive (`archiveLink`/`download`).
|
|
314
394
|
*/
|
|
@@ -372,19 +452,70 @@ export declare class SessionClient {
|
|
|
372
452
|
* live handle share one accessor convention.
|
|
373
453
|
*/
|
|
374
454
|
outputs(sessionId: string): SessionOutputs;
|
|
375
|
-
/**
|
|
376
|
-
* Find output files across sessions by filename / extension / content type.
|
|
377
|
-
* Returns lean REFERENCE hits (never bytes; fetch content with `readOutput`).
|
|
378
|
-
* Scope the search to a corpus with `query.runIds` (a session-id allow-list);
|
|
379
|
-
* omit it to scan every session in the workspace. Composed client-side (per-
|
|
380
|
-
* session `listSessionOutputs` + the contracts output filter), bounded by
|
|
381
|
-
* `query.limit` (default 100).
|
|
382
|
-
*/
|
|
383
|
-
searchOutputs(query?: OutputSearchQuery): Promise<OutputSearchPage>;
|
|
384
455
|
run(options: SessionRunOptions): Promise<SessionRunResult>;
|
|
385
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";
|
|
386
517
|
export interface StreamEventsOptions {
|
|
387
|
-
/** Poll interval in ms for the
|
|
518
|
+
/** Poll interval in ms for the event snapshot loop. Default 1000. */
|
|
388
519
|
readonly intervalMs?: number;
|
|
389
520
|
readonly signal?: AbortSignal;
|
|
390
521
|
}
|
|
@@ -528,6 +659,8 @@ export declare class Aex {
|
|
|
528
659
|
readonly skills: SkillsClient;
|
|
529
660
|
readonly secrets: SecretsClient;
|
|
530
661
|
readonly sessions: SessionClient;
|
|
662
|
+
/** Cross-run output search (`aex.outputs.search(...)`). */
|
|
663
|
+
readonly outputs: OutputsClient;
|
|
531
664
|
constructor(apiKey: string, options?: Omit<AexOptions, "apiKey">);
|
|
532
665
|
constructor(options: AexOptions);
|
|
533
666
|
/**
|
|
@@ -555,6 +688,17 @@ export declare class Aex {
|
|
|
555
688
|
readonly hash: string;
|
|
556
689
|
readonly contentType?: string;
|
|
557
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>;
|
|
558
702
|
/**
|
|
559
703
|
* Internal: upsert already-uploaded skill metadata into the workspace registry.
|
|
560
704
|
* The bytes are staged through `_uploadAsset`; this call binds the content hash
|
|
@@ -575,7 +719,22 @@ export declare class Aex {
|
|
|
575
719
|
* events, outputs, and session record. The returned `runId` is the session id,
|
|
576
720
|
* so callers can resume later with `openSession(runId)`.
|
|
577
721
|
*/
|
|
578
|
-
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>>;
|
|
579
738
|
openSession(options: SessionCreateOptions): Promise<SessionHandle>;
|
|
580
739
|
openSession(sessionId: string): Promise<SessionHandle>;
|
|
581
740
|
/**
|