@aexhq/sdk 0.31.0 → 0.33.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 (43) hide show
  1. package/README.md +29 -31
  2. package/dist/_contracts/event-stream-client.d.ts +2 -2
  3. package/dist/_contracts/event-stream-client.js +3 -3
  4. package/dist/_contracts/index.d.ts +0 -1
  5. package/dist/_contracts/index.js +0 -1
  6. package/dist/_contracts/models.d.ts +0 -76
  7. package/dist/_contracts/models.js +0 -20
  8. package/dist/_contracts/operations.d.ts +15 -18
  9. package/dist/_contracts/operations.js +81 -40
  10. package/dist/_contracts/post-hook.d.ts +4 -4
  11. package/dist/_contracts/post-hook.js +1 -1
  12. package/dist/_contracts/run-config.d.ts +0 -4
  13. package/dist/_contracts/run-config.js +0 -7
  14. package/dist/_contracts/run-unit.js +4 -4
  15. package/dist/_contracts/runtime-types.d.ts +86 -2
  16. package/dist/_contracts/status.d.ts +3 -1
  17. package/dist/_contracts/status.js +17 -0
  18. package/dist/_contracts/submission.d.ts +1 -10
  19. package/dist/_contracts/submission.js +0 -4
  20. package/dist/cli.mjs +118 -135
  21. package/dist/cli.mjs.sha256 +1 -1
  22. package/dist/client.d.ts +118 -72
  23. package/dist/client.js +427 -96
  24. package/dist/client.js.map +1 -1
  25. package/dist/index.d.ts +5 -4
  26. package/dist/index.js +3 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/version.d.ts +1 -1
  29. package/dist/version.js +1 -1
  30. package/docs/cleanup.md +2 -2
  31. package/docs/credentials.md +3 -3
  32. package/docs/defaults.md +0 -2
  33. package/docs/events.md +32 -13
  34. package/docs/limits.md +4 -3
  35. package/docs/outputs.md +2 -2
  36. package/docs/provider-runtime-capabilities.md +2 -2
  37. package/docs/public-surface.json +15 -10
  38. package/docs/quickstart.md +38 -12
  39. package/docs/run-config.md +3 -8
  40. package/docs/secrets.md +2 -2
  41. package/docs/skills.md +4 -4
  42. package/docs/vision-skills.md +2 -2
  43. package/package.json +1 -1
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HttpClient, SecretString, type AexEvent, type AgentsMdRecord, type DebugSink, type FetchLike, type FileRecord, type Output, type OutputFileType, type OutputLink, type OutputLinkOptions, type OutputQuery, type OutputText, type OutputMode, type ReadOutputTextOptions, type RunListPage, type RunListQuery, type OutputSearchQuery, type OutputSearchPage, type PlatformEnvironmentInput, type PlatformSubmission, type PlatformInlineSecrets, type PlatformProxyEndpoint, type PlatformProxyEndpointAuth, type PlatformPostHookInput, type Run, type RunModel, type RunEvent, type RunTrace, type UsageSummary, type RunLimits, type RunWebhookDelivery, type RunProvider, type SecretRecord, type SecretReveal, type RunUnit, type BuiltinToolName, type RuntimeSize, type Skill as SkillRecord, type WhoAmI } from "./_contracts/index.js";
1
+ import { HttpClient, SecretString, type AexEvent, type AgentsMdRecord, type DebugSink, type FetchLike, type FileRecord, type Output, type OutputFileType, type OutputLink, type OutputLinkOptions, type OutputQuery, type OutputText, type OutputMode, type ReadOutputTextOptions, type RunListPage, type RunListQuery, type OutputSearchQuery, type OutputSearchPage, type Session, type SessionCreateRequest, type SessionEvent, type SessionListPage, type SessionListQuery, type SessionStateChangeAccepted, type SessionTurn, type PlatformEnvironmentInput, type PlatformSubmission, type PlatformInlineSecrets, type PlatformProxyEndpoint, type PlatformProxyEndpointAuth, type Run, type RunModel, type RunEvent, type RunTrace, type UsageSummary, type RunLimits, type RunWebhookDelivery, type RunProvider, type SecretRecord, type SecretReveal, type RunUnit, type BuiltinToolName, type RuntimeSize, type Skill as SkillRecord, 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 } from "./file.js";
@@ -110,12 +110,6 @@ export interface SubmitOptions {
110
110
  * [1m, 6h]; omit for the 1h default. Applies to both runtimes.
111
111
  */
112
112
  readonly timeout?: string;
113
- /**
114
- * Command to run after the agent process exits successfully. A non-zero exit
115
- * or timeout is sent back to the model as a repair prompt until `maxTurns`
116
- * is exhausted. Empty commands are treated as omitted.
117
- */
118
- readonly postHook?: PlatformPostHookInput;
119
113
  readonly proxyEndpoints?: readonly ProxyEndpoint[];
120
114
  /**
121
115
  * Output capture policy for the run's output files.
@@ -186,24 +180,29 @@ export interface SubmitOptions {
186
180
  * shape + positivity are validated client-side.
187
181
  */
188
182
  readonly limits?: RunLimits;
189
- readonly signal?: AbortSignal;
190
183
  }
191
184
  /**
192
185
  * The settle-consistent result of {@link AgentExecutor.run} / `runAndCollect`:
193
- * the terminal run record plus its settle-bracketed events, decoded trace,
194
- * assistant text, and captured outputs — everything a "do it and give me the
195
- * result" caller needs without hand-rolling a poll loop.
186
+ * the one-shot session record plus its events, decoded trace, assistant text,
187
+ * and captured outputs — everything a "do it and give me the result" caller
188
+ * needs without hand-rolling a session/message/stream loop.
196
189
  */
197
190
  export interface RunResult {
198
191
  readonly runId: string;
199
- /** The full terminal run record (status, costTelemetry, timings). */
192
+ /** The session id used as the run-compatible handle. */
193
+ readonly sessionId?: string;
194
+ /** Run-compatible view of the underlying session record. */
200
195
  readonly run: Run;
196
+ /** The underlying resumable session record. */
197
+ readonly session?: Session;
198
+ /** The turn accepted for this one-shot run. */
199
+ readonly turn?: SessionTurn;
201
200
  readonly status: string;
202
- /** `true` when `status === "succeeded"`. */
201
+ /** `true` when the one-shot turn parked the session cleanly (`idle` or `suspended`). */
203
202
  readonly ok: boolean;
204
- /** The assistant's final text (decoded over the settled events). */
203
+ /** The assistant's final text. */
205
204
  readonly text: string;
206
- /** The settle-bracketed event stream (RUN_STARTED … terminal). */
205
+ /** The session turn event stream. */
207
206
  readonly events: readonly RunEvent[];
208
207
  /** Decoded view of the events: tool calls + usage + assistant text. */
209
208
  readonly trace: RunTrace;
@@ -218,12 +217,96 @@ export interface RunResult {
218
217
  }
219
218
  /** Options for {@link AgentExecutor.run} / `runAndCollect`. */
220
219
  export interface RunCollectOptions {
221
- /** Overall wait budget (ms) for the run to reach a terminal record. */
220
+ /** Overall wait budget (ms) for the one-shot session turn to park. */
222
221
  readonly timeoutMs?: number;
223
- readonly signal?: AbortSignal;
222
+ readonly webSocketFactory?: WebSocketFactory;
223
+ readonly idleTimeoutMs?: number;
224
+ readonly pingIntervalMs?: number;
224
225
  /** Throw a {@link RunStateError} when the run does not succeed. Default false. */
225
226
  readonly throwOnFailure?: boolean;
226
227
  }
228
+ export type SessionInput = string | readonly string[];
229
+ export type ChatInput = SessionInput;
230
+ export interface SessionEnvironmentOptions extends Omit<PlatformEnvironmentInput, "envVars"> {
231
+ readonly variables?: Readonly<Record<string, string>>;
232
+ readonly secrets?: Readonly<Record<string, Secret>>;
233
+ }
234
+ export interface SessionOverrides {
235
+ readonly idleTtl?: string;
236
+ readonly timeout?: string;
237
+ readonly maxSpendUsd?: number;
238
+ }
239
+ export interface SessionCreateOptions extends Omit<SubmitOptions, "prompt" | "webhook" | "environment" | "secretEnv" | "secrets" | "runtimeSize" | "parentRunId" | "limits" | "timeout"> {
240
+ readonly apiKeys?: Partial<Record<RunProvider, string>>;
241
+ readonly environment?: SessionEnvironmentOptions;
242
+ readonly runtime?: RuntimeSize;
243
+ readonly overrides?: SessionOverrides;
244
+ }
245
+ export type ChatCreateOptions = SessionCreateOptions;
246
+ export interface SessionSendOptions {
247
+ readonly idempotencyKey?: string;
248
+ readonly from?: number;
249
+ readonly webSocketFactory?: WebSocketFactory;
250
+ readonly idleTimeoutMs?: number;
251
+ readonly pingIntervalMs?: number;
252
+ }
253
+ export type ChatSendOptions = SessionSendOptions;
254
+ export interface SessionRunOptions extends SessionCreateOptions {
255
+ readonly message: SessionInput;
256
+ readonly deleteAfter?: boolean;
257
+ readonly messageIdempotencyKey?: string;
258
+ readonly stream?: Omit<SessionSendOptions, "idempotencyKey">;
259
+ }
260
+ export type ChatRunOptions = SessionRunOptions;
261
+ export interface SessionTurnResult {
262
+ readonly sessionId: string;
263
+ readonly session: Session;
264
+ readonly turn: SessionTurn;
265
+ readonly status: string;
266
+ readonly text: string;
267
+ readonly events: readonly SessionEvent[];
268
+ readonly outputs: readonly Output[];
269
+ }
270
+ export interface ChatTurnResult extends SessionTurnResult {
271
+ }
272
+ export interface SessionRunResult extends SessionTurnResult {
273
+ }
274
+ export interface ChatRunResult extends SessionRunResult {
275
+ }
276
+ export declare class SessionTurnStream implements AsyncIterable<SessionEvent> {
277
+ #private;
278
+ constructor(run: () => AsyncGenerator<SessionEvent, SessionTurnResult, void>);
279
+ [Symbol.asyncIterator](): AsyncIterator<SessionEvent>;
280
+ done(): Promise<SessionTurnResult>;
281
+ }
282
+ export declare const ChatTurnStream: typeof SessionTurnStream;
283
+ export type ChatTurnStream = SessionTurnStream;
284
+ export declare class SessionHandle {
285
+ #private;
286
+ constructor(http: HttpClient, session: Session);
287
+ get id(): string;
288
+ get record(): Session;
289
+ send(input: SessionInput, options?: SessionSendOptions): SessionTurnStream;
290
+ suspend(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
291
+ cancel(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
292
+ resume(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
293
+ delete(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<void>;
294
+ listEvents(): Promise<readonly SessionEvent[]>;
295
+ listOutputs(query?: OutputQuery): Promise<readonly Output[]>;
296
+ }
297
+ export declare const ChatSession: typeof SessionHandle;
298
+ export type ChatSession = SessionHandle;
299
+ export declare class SessionClient {
300
+ #private;
301
+ constructor(http: HttpClient, buildCreateRequest: (options: SessionCreateOptions) => Promise<SessionCreateRequest>);
302
+ create(options: SessionCreateOptions): Promise<SessionHandle>;
303
+ open(sessionId: string): Promise<SessionHandle>;
304
+ get(sessionId: string): Promise<Session>;
305
+ list(query?: SessionListQuery): Promise<SessionListPage>;
306
+ run(options: SessionRunOptions): Promise<SessionRunResult>;
307
+ }
308
+ export declare const ChatClient: typeof SessionClient;
309
+ export type ChatClient = SessionClient;
227
310
  export interface StreamEventsOptions {
228
311
  /** Poll interval in ms for the `RunEvent` snapshot loop. Default 1000. */
229
312
  readonly intervalMs?: number;
@@ -310,8 +393,7 @@ export declare class SkillsClient {
310
393
  * New run submissions usually use `AgentsMd.fromContent(...)` or
311
394
  * `AgentsMd.fromPath(...)` directly inside `submit`; the SDK
312
395
  * materializes those bytes to the hosted asset store before the run lands. This namespace is
313
- * the read/delete surface for persisted AgentsMd records plus an internal
314
- * upload transport retained for legacy callers.
396
+ * the read/delete surface for persisted AgentsMd records.
315
397
  */
316
398
  export declare class AgentsMdClient {
317
399
  #private;
@@ -319,14 +401,6 @@ export declare class AgentsMdClient {
319
401
  list(): Promise<readonly AgentsMdRecord[]>;
320
402
  get(agentsMdId: string): Promise<AgentsMdRecord>;
321
403
  delete(agentsMdId: string): Promise<void>;
322
- /**
323
- * Internal: post an AgentsMd markdown string to the BFF.
324
- * NOT part of the public API.
325
- */
326
- _uploadAgentsMd(args: {
327
- readonly name: string;
328
- readonly content: string;
329
- }): Promise<AgentsMdRecord>;
330
404
  }
331
405
  /**
332
406
  * Workspace File admin operations exposed under `client.files`.
@@ -334,8 +408,7 @@ export declare class AgentsMdClient {
334
408
  * New run submissions usually use `File.fromPath(...)` or
335
409
  * `File.fromBytes(...)` directly inside `submit`; the SDK materializes
336
410
  * those bytes to the hosted asset store before the run lands. This namespace is the read/delete
337
- * surface for persisted file records plus an internal upload transport
338
- * retained for legacy callers.
411
+ * surface for persisted file records.
339
412
  */
340
413
  export declare class FilesClient {
341
414
  #private;
@@ -343,14 +416,6 @@ export declare class FilesClient {
343
416
  list(): Promise<readonly FileRecord[]>;
344
417
  get(fileId: string): Promise<FileRecord>;
345
418
  delete(fileId: string): Promise<void>;
346
- /**
347
- * Internal: post a pre-bundled file zip to the BFF.
348
- * NOT part of the public API.
349
- */
350
- _uploadFile(args: {
351
- readonly name: string;
352
- readonly bytes: Uint8Array;
353
- }): Promise<FileRecord>;
354
419
  }
355
420
  /**
356
421
  * Workspace secret management exposed under `client.secrets`, mirroring
@@ -415,25 +480,9 @@ export declare class AgentExecutor {
415
480
  readonly agentsMd: AgentsMdClient;
416
481
  readonly files: FilesClient;
417
482
  readonly secrets: SecretsClient;
483
+ readonly sessions: SessionClient;
484
+ readonly chat: ChatClient;
418
485
  constructor(options: AgentExecutorOptions);
419
- /**
420
- * Internal: an `AgentsMd.upload(this)` shortcut that bypasses
421
- * `client.agentsMd` indirection. Forwarded to
422
- * `AgentsMdClient._uploadAgentsMd`. NOT part of the public API.
423
- */
424
- _uploadAgentsMd(args: {
425
- readonly name: string;
426
- readonly content: string;
427
- }): Promise<AgentsMdRecord>;
428
- /**
429
- * Internal: a `File.upload(this)` shortcut that bypasses
430
- * `client.files` indirection. Forwarded to
431
- * `FilesClient._uploadFile`. NOT part of the public API.
432
- */
433
- _uploadFile(args: {
434
- readonly name: string;
435
- readonly bytes: Uint8Array;
436
- }): Promise<FileRecord>;
437
486
  /**
438
487
  * Internal: satisfies the `SecretUploader` surface so a
439
488
  * `Secret.value(...).upload(client, { name })` promotes an ephemeral secret
@@ -458,26 +507,20 @@ export declare class AgentExecutor {
458
507
  readonly contentType?: string;
459
508
  }): Promise<UploadedAsset>;
460
509
  /**
461
- * Submit a run, wait until its RECORD is terminal, and collect the full
462
- * {@link RunResult} the settle-consistent "do it and give me the result"
463
- * primitive. Folds the poll loop every consumer hand-rolled into one call:
464
- * submit {@link waitForRun} (polls `getRun`, NOT the earlier RUN_FINISHED
465
- * event) poll `listEvents` until the snapshot is settle-bracketed
466
- * (RUN_STARTED + a terminal event present) → `listOutputs` → decode the trace
467
- * and assistant text. On resolve, `getRun`/`listOutputs` are guaranteed
468
- * consistent.
469
- *
470
- * Uses polling (portable across backends), NOT the coordinator WebSocket. By
471
- * default a failed run resolves with `ok: false` and a populated `error`; pass
472
- * `{ throwOnFailure: true }` to throw instead. For live events prefer `submit`
473
- * + `streamEnvelopes(runId, { settleConsistent: true })`.
510
+ * Convenience one-shot on top of the canonical session API:
511
+ * open a session, send `message` as the first turn, stream until the session
512
+ * parks (`idle` / `suspended` / `error`), then return the collected text,
513
+ * events, outputs, and session record. The returned `runId` is the session id,
514
+ * so callers can resume later with `openSession(runId)`.
474
515
  */
475
- run(options: SubmitOptions, opts?: RunCollectOptions): Promise<RunResult>;
516
+ run(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult>;
476
517
  /**
477
- * Explicit, discoverable alias for {@link run}: submit, wait, and collect the
478
- * full {@link RunResult} in one call.
518
+ * Explicit, discoverable alias for {@link run}: open a one-shot session turn
519
+ * and collect the full {@link RunResult} in one call.
479
520
  */
480
- runAndCollect(options: SubmitOptions, opts?: RunCollectOptions): Promise<RunResult>;
521
+ runAndCollect(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult>;
522
+ openSession(options: SessionCreateOptions): Promise<SessionHandle>;
523
+ openSession(sessionId: string): Promise<SessionHandle>;
481
524
  /**
482
525
  * Submit a run and return its run id immediately. Use that id with
483
526
  * `wait`, `stream`, `outputs`, `download`, `cancel`, or `delete`.
@@ -628,4 +671,7 @@ export declare class AgentExecutor {
628
671
  /** Download only the run record (the `metadata` namespace) as a zip. */
629
672
  downloadMetadata(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
630
673
  }
674
+ /** Canonical SDK client name. `AgentExecutor` remains as a compatibility alias. */
675
+ export declare class Aex extends AgentExecutor {
676
+ }
631
677
  export type { OutputFileType, OutputLink, OutputLinkOptions, OutputQuery, PlatformProxyEndpoint, PlatformProxyEndpointAuth };