@aexhq/sdk 0.40.16 → 0.41.1

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
@@ -7,17 +7,17 @@
7
7
  * the shape the coordinator (Phase 2) appends, broadcasts, and archives.
8
8
  *
9
9
  * - **CloudEvents-shaped** self-describing envelope: a stable `id`, the
10
- * coarse `source`, the AG-UI-aligned `type`, the `subject` (run), a
10
+ * coarse `source`, the AG-UI-aligned `type`, the `subject` (session), a
11
11
  * `time`, the `sequence` cursor, and the typed `data`.
12
12
  * - **AG-UI vocabulary** for `type` where it maps; aex-specific events
13
13
  * ride AG-UI's reserved `CUSTOM` carrier under an `aex.*` name, so an
14
- * off-the-shelf AG-UI client reads an aex run with no glue.
14
+ * off-the-shelf AG-UI client reads an aex start with no glue.
15
15
  * - Two aex extensions: a coarse `source` (filter first by origin) and
16
16
  * an optional human `message` (log / CLI / dashboard rendering).
17
17
  *
18
18
  * Unified observability spine:
19
19
  * the envelope additionally carries four ordering attributes so BOTH the typed
20
- * event stream and the high-volume hosted-platform log stream ride one per-run
20
+ * event stream and the high-volume hosted-platform log stream ride one per-session
21
21
  * coordinator:
22
22
  * - `channel` — "event" (the typed AG-UI stream) or "log" (a verbose log
23
23
  * line). The single axis a consumer splits the unified stream
@@ -59,7 +59,7 @@ export const AEX_EVENT_MAP_VERSION = 1;
59
59
  */
60
60
  export const AEX_EVENT_SOURCES = ["agent", "api", "runtime", "mcp", "aex", "workflow", "host"];
61
61
  /**
62
- * The channel a record rides on the unified per-run stream:
62
+ * The channel a record rides on the unified per-session stream:
63
63
  * - `event` — the typed, low-volume, fully-replayed AG-UI event stream.
64
64
  * - `log` — a high-volume verbose log line (level + message + fields). The
65
65
  * coordinator prunes flushed log rows after evidence archival
@@ -80,16 +80,16 @@ export const AEX_LOG_LEVELS = ["info", "warn", "error"];
80
80
  * `CUSTOM`, AG-UI's reserved carrier for aex-native events.
81
81
  */
82
82
  export const AEX_EVENT_TYPES = [
83
- "RUN_STARTED",
84
- "RUN_FINISHED",
85
- "RUN_ERROR",
83
+ "TURN_STARTED",
84
+ "TURN_FINISHED",
85
+ "TURN_ERROR",
86
86
  "TEXT_MESSAGE_CONTENT",
87
87
  "TOOL_CALL_START",
88
88
  "TOOL_CALL_RESULT",
89
89
  "CUSTOM",
90
90
  // The carrier type for a `channel: "log"` record. Kept out of the AG-UI
91
- // typed-event vocabulary on purpose: a `LOG` is never a run-lifecycle signal,
92
- // so terminal detection (RUN_FINISHED/RUN_ERROR) is unaffected and an
91
+ // typed-event vocabulary on purpose: a `LOG` is never a session-lifecycle signal,
92
+ // so terminal detection (TURN_FINISHED/TURN_ERROR) is unaffected and an
93
93
  // off-the-shelf AG-UI client filters logs out by `channel`.
94
94
  "LOG"
95
95
  ];
@@ -103,10 +103,10 @@ export function runnerEventToAexEvent(evt, ctx) {
103
103
  const projection = project(evt);
104
104
  return {
105
105
  specversion: AEX_EVENT_SPECVERSION,
106
- id: `${ctx.runId}:${evt.seq}`,
106
+ id: `${ctx.sessionId}:${evt.seq}`,
107
107
  source: projection.source,
108
108
  type: projection.type,
109
- subject: ctx.runId,
109
+ subject: ctx.sessionId,
110
110
  time: new Date(ctx.baseMs + evt.tMs).toISOString(),
111
111
  sequence: evt.seq,
112
112
  ...(projection.message !== undefined ? { message: projection.message } : {}),
@@ -117,7 +117,7 @@ function project(evt) {
117
117
  const data = evt.data;
118
118
  switch (evt.kind) {
119
119
  case "runtime_started":
120
- return { type: "RUN_STARTED", source: "runtime", message: "run started", data: { ...data } };
120
+ return { type: "TURN_STARTED", source: "runtime", message: "turn started", data: { ...data } };
121
121
  case "assistant_text": {
122
122
  const text = str(data.text);
123
123
  return {
@@ -154,11 +154,11 @@ function project(evt) {
154
154
  const reason = str(data.reason);
155
155
  return {
156
156
  // The event's own reason types it (error vs finished); the
157
- // authoritative run *status* is still owned by the orchestrator and
157
+ // authoritative session *status* is still owned by the orchestrator and
158
158
  // is never re-derived from this event.
159
- type: reason === "error" ? "RUN_ERROR" : "RUN_FINISHED",
159
+ type: reason === "error" ? "TURN_ERROR" : "TURN_FINISHED",
160
160
  source: "runtime",
161
- message: reason ? `run ${reason}` : "run finished",
161
+ message: reason ? `turn ${reason}` : "session finished",
162
162
  data: { ...data }
163
163
  };
164
164
  }
@@ -199,30 +199,30 @@ function custom(name, source, value, message) {
199
199
  }
200
200
  // --- Honest guards over the emitted vocabulary --------------------------------
201
201
  // These match the vocabulary a consumer of the unified stream actually receives.
202
- export function isRunStarted(e) {
203
- return e.type === "RUN_STARTED";
202
+ export function isTurnStarted(e) {
203
+ return e.type === "TURN_STARTED";
204
204
  }
205
- export function isRunFinished(e) {
206
- return e.type === "RUN_FINISHED";
205
+ export function isTurnFinished(e) {
206
+ return e.type === "TURN_FINISHED";
207
207
  }
208
- export function isRunError(e) {
209
- return e.type === "RUN_ERROR";
208
+ export function isTurnError(e) {
209
+ return e.type === "TURN_ERROR";
210
210
  }
211
211
  /** A terminal event of either flavour (finished or error). */
212
- export function isRunTerminal(e) {
213
- return e.type === "RUN_FINISHED" || e.type === "RUN_ERROR";
212
+ export function isTurnTerminal(e) {
213
+ return e.type === "TURN_FINISHED" || e.type === "TURN_ERROR";
214
214
  }
215
215
  /**
216
- * The CUSTOM `data.name`s the MANAGED runtime emits as a run/turn's SETTLED
217
- * terminal. A managed one-shot run PARKS (`session_parked.v1` → one of these)
218
- * rather than writing a `session_finished` → RUN_FINISHED, so these — not just
219
- * the AG-UI RUN_FINISHED/RUN_ERROR — are what actually end a managed run's event
216
+ * The CUSTOM `data.name`s the MANAGED runtime emits as a session/turn's SETTLED
217
+ * terminal. A managed one-shot session PARKS (`session_parked.v1` → one of these)
218
+ * rather than writing a `session_finished` → TURN_FINISHED, so these — not just
219
+ * the AG-UI TURN_FINISHED/TURN_ERROR — are what actually end a managed session's event
220
220
  * stream. Clean-cut (WS1): the bare `aex.session.error` park is retired in favour
221
221
  * of the terminal OUTCOME vocabulary — a failed turn is `failed`, a wall-clock
222
222
  * kill `timed_out`, a cancel `cancelled`, a clean finish `succeeded`; `idle`/
223
223
  * `suspended` remain the resumable parks. Held `awaiting_approval` is NOT here:
224
224
  * it ends the TURN stream (see `isSessionTurnTerminalEvent` in the SDK) but the
225
- * RUN is not settled. Kept byte-in-sync with `@aexhq/shared` `AEX_SESSION_PARKED_NAMES`
225
+ * session is not settled. Kept byte-in-sync with `@aexhq/shared` `AEX_SESSION_PARKED_NAMES`
226
226
  * and the platform journal projection (`journal-project.ts` session_parked.v1).
227
227
  */
228
228
  export const AEX_SESSION_PARKED_NAMES = [
@@ -237,8 +237,8 @@ export const AEX_SESSION_PARKED_NAMES = [
237
237
  * True for a managed-runtime session-park terminal (a resumable idle/suspended
238
238
  * park OR a terminal succeeded/failed/timed_out/cancelled outcome). The turn's
239
239
  * work is done and the record has reached its terminal status; a stream consumer
240
- * should stop here exactly as it would on RUN_FINISHED/RUN_ERROR. (Held
241
- * `awaiting_approval` is deliberately excluded — the run is paused, not settled.)
240
+ * should stop here exactly as it would on TURN_FINISHED/TURN_ERROR. (Held
241
+ * `awaiting_approval` is deliberately excluded — the session is paused, not settled.)
242
242
  */
243
243
  export function isSessionParked(e) {
244
244
  const name = customName(e);
@@ -262,27 +262,27 @@ export function customName(e) {
262
262
  }
263
263
  /**
264
264
  * The `data.name` of the settle-consistency barrier event. The coordinator
265
- * broadcasts ONE such CUSTOM event as a run's LAST stream event, after the
266
- * Postgres mirror lands — so observing it ⇒ a subsequent `getRun` is terminal
267
- * and `listOutputs` is complete. It is intentionally a CUSTOM event (not a
268
- * typed RUN_* event): off-the-shelf AG-UI clients ignore it, while
269
- * `streamEnvelopes(runId, { settleConsistent: true })` ends the iterator on it.
270
- * Unlike RUN_FINISHED (the AG-UI render-complete UX signal, emitted by the
265
+ * broadcasts ONE such CUSTOM event as a session's LAST stream event, after the
266
+ * Postgres mirror lands — so observing it ⇒ a subsequent `getSessionRecord` is terminal
267
+ * and `listSessionFiles` is complete. It is intentionally a CUSTOM event (not a
268
+ * typed SESSION_* event): off-the-shelf AG-UI clients ignore it, while
269
+ * `streamEnvelopes(sessionId, { settleConsistent: true })` ends the iterator on it.
270
+ * Unlike TURN_FINISHED (the AG-UI render-complete UX signal, emitted by the
271
271
  * runner BEFORE the platform learns the outcome), this is settle-gated. The
272
272
  * platform mirrors this constant in `@aexhq/shared`.
273
273
  */
274
- export const AEX_RUN_SETTLED_NAME = "aex.run.settled";
274
+ export const AEX_SESSION_SETTLED_NAME = "aex.session.settled";
275
275
  /**
276
276
  * True for the settle-consistency barrier event (post-mirror, read-consistent).
277
277
  * Also true for a managed-runtime session-park terminal: the current plane emits
278
- * an `aex.run.settled` barrier after settle, but a stream may still observe the
278
+ * an `aex.session.settled` barrier after settle, but a stream may still observe the
279
279
  * park as the terminal event when no later barrier is delivered.
280
280
  */
281
- export function isRunSettled(e) {
282
- return customName(e) === AEX_RUN_SETTLED_NAME || isSessionParked(e);
281
+ export function isSessionSettled(e) {
282
+ return customName(e) === AEX_SESSION_SETTLED_NAME || isSessionParked(e);
283
283
  }
284
284
  /**
285
- * The CUSTOM `data.name` of the HITL write-gate park: the run has reached the
285
+ * The CUSTOM `data.name` of the HITL write-gate park: the session has reached the
286
286
  * `awaiting_approval` state before a gated action and is holding for an
287
287
  * `approve()`/`deny()`. Structural (independent of model prose).
288
288
  */
@@ -337,23 +337,23 @@ export function exceedsRowBudget(e, max = MAX_SQLITE_ROW_BYTES) {
337
337
  }
338
338
  /**
339
339
  * Project an aex envelope to a strict AG-UI event so an off-the-shelf
340
- * AG-UI client can consume an aex run with no glue. This is the
340
+ * AG-UI client can consume an aex start with no glue. This is the
341
341
  * client-side projection the SDK exposes.
342
342
  */
343
343
  export function toAGUI(e) {
344
344
  const timestamp = Date.parse(e.time);
345
345
  const d = e.data;
346
346
  switch (e.type) {
347
- case "RUN_STARTED":
348
- return { type: "RUN_STARTED", timestamp, threadId: e.subject, runId: e.subject };
349
- case "RUN_FINISHED":
350
- return { type: "RUN_FINISHED", timestamp, threadId: e.subject, runId: e.subject };
351
- case "RUN_ERROR": {
347
+ case "TURN_STARTED":
348
+ return { type: "TURN_STARTED", timestamp, threadId: e.subject, sessionId: e.subject };
349
+ case "TURN_FINISHED":
350
+ return { type: "TURN_FINISHED", timestamp, threadId: e.subject, sessionId: e.subject };
351
+ case "TURN_ERROR": {
352
352
  const code = str(d.failureClass);
353
353
  return {
354
- type: "RUN_ERROR",
354
+ type: "TURN_ERROR",
355
355
  timestamp,
356
- message: str(d.failureMessage) || e.message || "run error",
356
+ message: str(d.failureMessage) || e.message || "turn error",
357
357
  ...(code ? { code } : {})
358
358
  };
359
359
  }
@@ -12,13 +12,13 @@
12
12
  * A silently half-open socket (no close/error, no frames) is the dangerous
13
13
  * case: the read loop would block forever and MISS a terminal that was already
14
14
  * persisted server-side. So the client sends a post-open replay trigger plus a
15
- * tiny keep-alive ping the coordinator answers with a matching pong, and runs an idle
15
+ * tiny keep-alive ping the coordinator answers with a matching pong, and uses an idle
16
16
  * watchdog: if no frame arrives within {@link CoordinatorStreamOptions.idleTimeoutMs},
17
17
  * the socket is treated as dead and reconnected — resume-from-cursor then
18
18
  * replays the terminal.
19
19
  *
20
20
  * Filtering and projection are the client's concern (the wire carries the
21
- * whole run): compose {@link filterStream} with the envelope guards, and
21
+ * whole session): compose {@link filterStream} with the envelope guards, and
22
22
  * {@link mapStream} with {@link toAGUI}, on top of this stream.
23
23
  *
24
24
  * The WebSocket is injectable so the SDK/CLI use the global `WebSocket`
@@ -36,7 +36,7 @@ export interface WebSocketLike {
36
36
  }
37
37
  export type WebSocketFactory = (url: string) => WebSocketLike;
38
38
  export interface CoordinatorStreamOptions {
39
- /** Base subscribe URL, e.g. `wss://coordinator/runs/<id>/subscribe`. */
39
+ /** Base subscribe URL, e.g. `wss://coordinator/sessions/<id>/subscribe`. */
40
40
  readonly wsUrl: string;
41
41
  /** Starting cursor: events with `sequence >= from` are delivered. Default 0 (from start). */
42
42
  readonly from?: number;
@@ -51,10 +51,10 @@ export interface CoordinatorStreamOptions {
51
51
  readonly reconnectDelayMs?: number;
52
52
  /**
53
53
  * Predicate that decides which event ENDS the stream. Default: the AG-UI
54
- * terminal events (RUN_FINISHED / RUN_ERROR) — the render-complete UX signal.
55
- * Pass {@link isRunSettled} for a settle-consistent stream that keeps reading
56
- * PAST RUN_FINISHED until the post-mirror barrier, so the iterator only ends
57
- * once a subsequent `getRun` is guaranteed terminal.
54
+ * terminal events (TURN_FINISHED / TURN_ERROR) — the render-complete UX signal.
55
+ * Pass {@link isSessionSettled} for a settle-consistent stream that keeps reading
56
+ * PAST TURN_FINISHED until the post-mirror barrier, so the iterator only ends
57
+ * once a subsequent `getSessionRecord` is guaranteed terminal.
58
58
  */
59
59
  readonly isTerminal?: (event: AexEvent) => boolean;
60
60
  /**
@@ -66,9 +66,9 @@ export interface CoordinatorStreamOptions {
66
66
  /**
67
67
  * Client keep-alive ping cadence. The client sends {@link COORDINATOR_PING},
68
68
  * which the coordinator answers with a matching pong, so
69
- * a legitimately quiet run keeps the socket measurably alive and does not trip
69
+ * a legitimately quiet session keeps the socket measurably alive and does not trip
70
70
  * the watchdog. Default 15s. Set 0 to disable (then only real events reset the
71
- * watchdog → quiet runs may reconnect).
71
+ * watchdog → quiet sessions may reconnect).
72
72
  */
73
73
  readonly pingIntervalMs?: number;
74
74
  /**
@@ -12,13 +12,13 @@
12
12
  * A silently half-open socket (no close/error, no frames) is the dangerous
13
13
  * case: the read loop would block forever and MISS a terminal that was already
14
14
  * persisted server-side. So the client sends a post-open replay trigger plus a
15
- * tiny keep-alive ping the coordinator answers with a matching pong, and runs an idle
15
+ * tiny keep-alive ping the coordinator answers with a matching pong, and uses an idle
16
16
  * watchdog: if no frame arrives within {@link CoordinatorStreamOptions.idleTimeoutMs},
17
17
  * the socket is treated as dead and reconnected — resume-from-cursor then
18
18
  * replays the terminal.
19
19
  *
20
20
  * Filtering and projection are the client's concern (the wire carries the
21
- * whole run): compose {@link filterStream} with the envelope guards, and
21
+ * whole session): compose {@link filterStream} with the envelope guards, and
22
22
  * {@link mapStream} with {@link toAGUI}, on top of this stream.
23
23
  *
24
24
  * The WebSocket is injectable so the SDK/CLI use the global `WebSocket`
@@ -27,10 +27,10 @@
27
27
  import { isSessionParked } from "./event-envelope.js";
28
28
  // The default terminal predicate ends the stream on the AG-UI terminals AND on
29
29
  // the managed runtime's CUSTOM session-park terminal (aex.session.idle/.error/
30
- // .suspended). A managed one-shot run parks instead of emitting RUN_FINISHED, so
31
- // WITHOUT the session-park arm a `streamEnvelopes()` over a finished managed run
30
+ // .suspended). A managed one-shot session parks instead of emitting TURN_FINISHED, so
31
+ // WITHOUT the session-park arm a `streamEnvelopes()` over a finished managed session
32
32
  // never sees a terminal and hangs on the idle watchdog forever.
33
- const isTerminalType = (e) => e.type === "RUN_FINISHED" || e.type === "RUN_ERROR" || isSessionParked(e);
33
+ const isTerminalType = (e) => e.type === "TURN_FINISHED" || e.type === "TURN_ERROR" || isSessionParked(e);
34
34
  /**
35
35
  * Keep-alive ping the client sends; the coordinator answers it with the matching
36
36
  * pong in its WebSocket message handler. Must stay byte-identical to
@@ -68,14 +68,14 @@ export interface ToolCallResultEventView extends AexEventView {
68
68
  * unchanged. Construct one with {@link asAexEventView}.
69
69
  */
70
70
  export declare class AexEventView {
71
- /** True for the run-start lifecycle event. */
72
- isRunStarted(): boolean;
71
+ /** True for the turn-start lifecycle event. */
72
+ isTurnStarted(): boolean;
73
73
  /** True for the terminal success event. */
74
- isRunFinished(): boolean;
74
+ isTurnFinished(): boolean;
75
75
  /** True for the terminal error event. */
76
- isRunError(): boolean;
76
+ isTurnError(): boolean;
77
77
  /** True for a terminal event of either flavour (finished or error). */
78
- isRunTerminal(): boolean;
78
+ isTurnTerminal(): boolean;
79
79
  /** True for an assistant text event; narrows `data.text` to `string`. */
80
80
  isTextMessage(): this is TextMessageEventView;
81
81
  /** True for a tool-call start event; narrows `data` to `{ id, name }`. */
@@ -106,7 +106,7 @@ export declare class AexEventView {
106
106
  * session-park terminal (idle/error/suspended) — the one check that reliably
107
107
  * means "this stream is done and the record is authoritative".
108
108
  */
109
- isRunSettled(): boolean;
109
+ isSessionSettled(): boolean;
110
110
  /** True when the record originates from the given coarse source. */
111
111
  isFromSource(source: AexEventSource): boolean;
112
112
  }
@@ -20,7 +20,7 @@
20
20
  * the prototype (they never serialize), and an `AexEventView` is still a
21
21
  * structural {@link AexEvent}.
22
22
  */
23
- import { channelOf, isRunSettled, isAwaitingApproval, isResultDecoded, isResultRefused } from "./event-envelope.js";
23
+ import { channelOf, isSessionSettled, isAwaitingApproval, isResultDecoded, isResultRefused } from "./event-envelope.js";
24
24
  /**
25
25
  * A coordinator {@link AexEvent} with the standardized-event-type guards carried
26
26
  * as METHODS (`event.isTextMessage()`, `event.isToolCallStart()`, …). Extends
@@ -28,21 +28,21 @@ import { channelOf, isRunSettled, isAwaitingApproval, isResultDecoded, isResultR
28
28
  * unchanged. Construct one with {@link asAexEventView}.
29
29
  */
30
30
  export class AexEventView {
31
- /** True for the run-start lifecycle event. */
32
- isRunStarted() {
33
- return this.type === "RUN_STARTED";
31
+ /** True for the turn-start lifecycle event. */
32
+ isTurnStarted() {
33
+ return this.type === "TURN_STARTED";
34
34
  }
35
35
  /** True for the terminal success event. */
36
- isRunFinished() {
37
- return this.type === "RUN_FINISHED";
36
+ isTurnFinished() {
37
+ return this.type === "TURN_FINISHED";
38
38
  }
39
39
  /** True for the terminal error event. */
40
- isRunError() {
41
- return this.type === "RUN_ERROR";
40
+ isTurnError() {
41
+ return this.type === "TURN_ERROR";
42
42
  }
43
43
  /** True for a terminal event of either flavour (finished or error). */
44
- isRunTerminal() {
45
- return this.type === "RUN_FINISHED" || this.type === "RUN_ERROR";
44
+ isTurnTerminal() {
45
+ return this.type === "TURN_FINISHED" || this.type === "TURN_ERROR";
46
46
  }
47
47
  /** True for an assistant text event; narrows `data.text` to `string`. */
48
48
  isTextMessage() {
@@ -95,8 +95,8 @@ export class AexEventView {
95
95
  * session-park terminal (idle/error/suspended) — the one check that reliably
96
96
  * means "this stream is done and the record is authoritative".
97
97
  */
98
- isRunSettled() {
99
- return isRunSettled(this);
98
+ isSessionSettled() {
99
+ return isSessionSettled(this);
100
100
  }
101
101
  /** True when the record originates from the given coarse source. */
102
102
  isFromSource(source) {
@@ -200,7 +200,7 @@ function transientReadErrorCode(err) {
200
200
  function toNetworkError(method, url, err, attempts, elapsedMs) {
201
201
  if (err instanceof AexError)
202
202
  return err;
203
- // `DOMException` is not an `Error` subclass on every runtime, so match aborts by name.
203
+ // `DOMException` is not an `Error` subclass on every sessiontime, so match aborts by name.
204
204
  if (err?.name === "AbortError")
205
205
  return err;
206
206
  return new AexNetworkError({
@@ -1,32 +1,32 @@
1
1
  export * from "./provider-support.js";
2
2
  export * from "./models.js";
3
3
  export * from "./status.js";
4
- export { AEX_RESERVED_ENV_PREFIX, BUILTIN_TOOL_NAMES, BuiltinTools, DEFAULT_BUILTIN_TOOLS, DEFAULT_OUTPUT_MODE, DEFAULT_RUN_PROVIDER, ENV_VARS_MAX_ENTRIES, ENV_VARS_MAX_TOTAL_BYTES, ENV_VARS_MAX_VALUE_BYTES, OUTPUT_MODES, PLATFORM_PACKAGE_ECOSYSTEMS, Providers, RESPONSE_FORMAT_KINDS, RUN_PROVIDERS, SECRETS_KEY, SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SKILLS_MAX, SKILLS_TOOL_DEFINITION, SKILLS_TOOL_NAME, STREAMABLE_SHAPES, assertStreamableOutputMode, crossValidateSecretEnvAndValues, isStreamableProvider, packageInstallString, parseApprovalGate, parseInlineSecrets, parseResponseFormat, parseRunLimits, parseRunProvider, parseRunSubmissionRequest, parseRunWebhook, parseSkills, parseSubmission, resolveBuiltinToolNames } from "./submission.js";
5
- export type { ApprovalGate, BuiltinToolName, JsonPrimitive, JsonValue, OutputMode, ParseRunSubmissionOptions, PlatformEnvironment, PlatformEnvironmentInput, PlatformInlineSecrets, PlatformInjectionConfig, PlatformMcpServerSecret, PlatformNetworking, PlatformOutputCaptureConfig, PlatformPackage, PlatformPackageEcosystem, PlatformPackageInput, PlatformRunSubmissionInput, PlatformRunSubmissionRequest, PlatformSecretEnvEntry, PlatformSubmission, ResponseFormat, ResponseFormatKind, RunLimits, RunMachine, RunProvider, RunWebhookSpec, StreamableShape } from "./submission.js";
4
+ export { AEX_RESERVED_ENV_PREFIX, BUILTIN_TOOL_NAMES, BuiltinTools, DEFAULT_BUILTIN_TOOLS, DEFAULT_OUTPUT_MODE, DEFAULT_PROVIDER, ENV_VARS_MAX_ENTRIES, ENV_VARS_MAX_TOTAL_BYTES, ENV_VARS_MAX_VALUE_BYTES, OUTPUT_MODES, PLATFORM_PACKAGE_ECOSYSTEMS, Providers, RESPONSE_FORMAT_KINDS, PROVIDERS, SECRETS_KEY, SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SKILLS_MAX, SKILLS_TOOL_DEFINITION, SKILLS_TOOL_NAME, STREAMABLE_SHAPES, assertStreamableOutputMode, crossValidateSecretEnvAndValues, isStreamableProvider, packageInstallString, parseApprovalGate, parseInlineSecrets, parseResponseFormat, parseSessionLimits, parseProviderName, parseSessionSubmissionRequest, parseSessionWebhook, parseSkills, parseSubmission, resolveBuiltinToolNames } from "./submission.js";
5
+ export type { ApprovalGate, BuiltinToolName, JsonPrimitive, JsonValue, OutputMode, ParseSessionSubmissionOptions, PlatformEnvironment, PlatformEnvironmentInput, PlatformInlineSecrets, PlatformInjectionConfig, PlatformMcpServerSecret, PlatformNetworking, PlatformFileCaptureConfig, PlatformPackage, PlatformPackageEcosystem, PlatformPackageInput, PlatformSessionSubmissionInput, PlatformSessionSubmissionRequest, PlatformSecretEnvEntry, PlatformSubmission, ResponseFormat, ResponseFormatKind, SessionLimits, SessionMachine, ProviderName, SessionWebhookSpec, StreamableShape } from "./submission.js";
6
6
  export * from "./runtime-sizes.js";
7
7
  export * from "./runner-event.js";
8
8
  export * from "./event-envelope.js";
9
9
  export * from "./event-view.js";
10
10
  export * from "./connection-ticket.js";
11
11
  export * from "./event-stream-client.js";
12
- export * from "./run-unit.js";
13
- export type { AssistantTextEntry, RunTrace, ToolCallResult, ToolCallTrace } from "./run-trace.js";
12
+ export * from "./session-unit.js";
13
+ export type { AssistantTextEntry, TurnTrace, ToolCallResult, ToolCallTrace } from "./turn-trace.js";
14
14
  export * from "./runtime-manifest.js";
15
15
  export * from "./runtime-security-profile.js";
16
- export * from "./run-record.js";
17
- export * from "./run-cost.js";
18
- export * from "./run-custody.js";
19
- export * from "./run-retention.js";
16
+ export * from "./session-record.js";
17
+ export * from "./session-cost.js";
18
+ export * from "./session-custody.js";
19
+ export * from "./session-retention.js";
20
20
  export * from "./side-effect-audit.js";
21
21
  export * from "./stable.js";
22
22
  export * from "./sdk-secrets.js";
23
23
  export * from "./sdk-errors.js";
24
- export * from "./run-config.js";
24
+ export * from "./session-config.js";
25
25
  export * from "./bundle-manifest.js";
26
26
  export * from "./runtime-types.js";
27
27
  export * from "./webhook-verify.js";
28
28
  export * from "./http.js";
29
- export * from "./run-artifacts.js";
29
+ export * from "./session-artifacts.js";
30
30
  export * as operations from "./operations.js";
31
31
  export * from "./sse.js";
32
32
  export * from "./error-codes.js";
@@ -1,35 +1,35 @@
1
1
  export * from "./provider-support.js";
2
2
  export * from "./models.js";
3
3
  export * from "./status.js";
4
- export { AEX_RESERVED_ENV_PREFIX, BUILTIN_TOOL_NAMES, BuiltinTools, DEFAULT_BUILTIN_TOOLS, DEFAULT_OUTPUT_MODE, DEFAULT_RUN_PROVIDER, ENV_VARS_MAX_ENTRIES, ENV_VARS_MAX_TOTAL_BYTES, ENV_VARS_MAX_VALUE_BYTES, OUTPUT_MODES, PLATFORM_PACKAGE_ECOSYSTEMS, Providers, RESPONSE_FORMAT_KINDS, RUN_PROVIDERS, SECRETS_KEY, SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SKILLS_MAX, SKILLS_TOOL_DEFINITION, SKILLS_TOOL_NAME, STREAMABLE_SHAPES, assertStreamableOutputMode, crossValidateSecretEnvAndValues, isStreamableProvider, packageInstallString, parseApprovalGate, parseInlineSecrets, parseResponseFormat, parseRunLimits, parseRunProvider, parseRunSubmissionRequest, parseRunWebhook, parseSkills, parseSubmission, resolveBuiltinToolNames } from "./submission.js";
4
+ export { AEX_RESERVED_ENV_PREFIX, BUILTIN_TOOL_NAMES, BuiltinTools, DEFAULT_BUILTIN_TOOLS, DEFAULT_OUTPUT_MODE, DEFAULT_PROVIDER, ENV_VARS_MAX_ENTRIES, ENV_VARS_MAX_TOTAL_BYTES, ENV_VARS_MAX_VALUE_BYTES, OUTPUT_MODES, PLATFORM_PACKAGE_ECOSYSTEMS, Providers, RESPONSE_FORMAT_KINDS, PROVIDERS, SECRETS_KEY, SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SKILLS_MAX, SKILLS_TOOL_DEFINITION, SKILLS_TOOL_NAME, STREAMABLE_SHAPES, assertStreamableOutputMode, crossValidateSecretEnvAndValues, isStreamableProvider, packageInstallString, parseApprovalGate, parseInlineSecrets, parseResponseFormat, parseSessionLimits, parseProviderName, parseSessionSubmissionRequest, parseSessionWebhook, parseSkills, parseSubmission, resolveBuiltinToolNames } from "./submission.js";
5
5
  export * from "./runtime-sizes.js";
6
6
  export * from "./runner-event.js";
7
7
  export * from "./event-envelope.js";
8
8
  export * from "./event-view.js";
9
9
  export * from "./connection-ticket.js";
10
10
  export * from "./event-stream-client.js";
11
- export * from "./run-unit.js";
11
+ export * from "./session-unit.js";
12
12
  export * from "./runtime-manifest.js";
13
13
  export * from "./runtime-security-profile.js";
14
- export * from "./run-record.js";
15
- export * from "./run-cost.js";
16
- export * from "./run-custody.js";
17
- export * from "./run-retention.js";
14
+ export * from "./session-record.js";
15
+ export * from "./session-cost.js";
16
+ export * from "./session-custody.js";
17
+ export * from "./session-retention.js";
18
18
  export * from "./side-effect-audit.js";
19
19
  export * from "./stable.js";
20
20
  export * from "./sdk-secrets.js";
21
21
  export * from "./sdk-errors.js";
22
- export * from "./run-config.js";
22
+ export * from "./session-config.js";
23
23
  export * from "./bundle-manifest.js";
24
24
  export * from "./runtime-types.js";
25
25
  export * from "./webhook-verify.js";
26
26
  export * from "./http.js";
27
- export * from "./run-artifacts.js";
27
+ export * from "./session-artifacts.js";
28
28
  export * as operations from "./operations.js";
29
29
  export * from "./sse.js";
30
30
  // The single canonical event surface: the `is*` guards live on `AexEvent`
31
31
  // (`event-envelope.js`) and as METHODS on `AexEventView` (`event-view.js`).
32
- // The loose `RunEvent` type and its free-function guard mirror (`event-guards.js`)
32
+ // The loose `TurnEvent` type and its free-function guard mirror (`event-guards.js`)
33
33
  // are RETIRED — there is exactly one event shape.
34
34
  export * from "./error-codes.js";
35
35
  export * from "./error-factory.js";
@@ -1,13 +1,13 @@
1
- import type { RunProvider } from "./submission.js";
1
+ import type { ProviderName } from "./submission.js";
2
2
  /**
3
3
  * Source of truth for the closed model set: each canonical model id maps to the
4
4
  * upstream providers that can serve it and the **provider-native** model string
5
5
  * each one expects.
6
6
  *
7
- * `Models.*` / `RUN_MODELS` are aex's own **canonical, provider-neutral**
7
+ * `Models.*` / `SUPPORTED_MODELS` are aex's own **canonical, provider-neutral**
8
8
  * identifiers — they are NOT the strings sent to a provider. The platform
9
9
  * translates a `(canonical model, provider)` pair to the native id via
10
- * {@link resolveProviderModelId} when it builds the run's session manifest. The
10
+ * {@link resolveProviderModelId} when it builds the session's session manifest. The
11
11
  * same canonical model can therefore be served by more than one provider (e.g.
12
12
  * `gpt-4o-mini` via `openai` *or* `openrouter`), with a different native string
13
13
  * per provider.
@@ -69,11 +69,11 @@ export declare const MODEL_PROVIDER_IDS: {
69
69
  };
70
70
  };
71
71
  /**
72
- * Closed set of canonical model ids accepted by the public run-submission
72
+ * Closed set of canonical model ids accepted by the public session-submission
73
73
  * schema. Derived from {@link MODEL_PROVIDER_IDS} so the two never drift.
74
74
  */
75
- export type RunModel = keyof typeof MODEL_PROVIDER_IDS;
76
- export declare const RUN_MODELS: readonly RunModel[];
75
+ export type ModelName = keyof typeof MODEL_PROVIDER_IDS;
76
+ export declare const SUPPORTED_MODELS: readonly ModelName[];
77
77
  /**
78
78
  * Symbol-style accessors for the closed model set. Prefer these over raw
79
79
  * strings so an invalid token is a compile error, not a runtime 400 — e.g.
@@ -126,27 +126,27 @@ export declare const Models: {
126
126
  /**
127
127
  * Provider → canonical models that provider can serve. Derived from
128
128
  * {@link MODEL_PROVIDER_IDS}; every provider currently serves at least one
129
- * model, so all {@link RunProvider} keys are present.
129
+ * model, so all {@link ProviderName} keys are present.
130
130
  */
131
- export declare const RUN_MODELS_BY_PROVIDER: Readonly<Record<RunProvider, readonly RunModel[]>>;
131
+ export declare const SUPPORTED_MODELS_BY_PROVIDER: Readonly<Record<ProviderName, readonly ModelName[]>>;
132
132
  /**
133
133
  * All upstream providers that can serve a model id, in declaration order.
134
134
  * Returns `[]` for an unknown model.
135
135
  */
136
- export declare function providersForModel(model: string): readonly RunProvider[];
136
+ export declare function providersForModel(model: string): readonly ProviderName[];
137
137
  /**
138
138
  * The default upstream provider for a model id — the first provider declared
139
139
  * for it in {@link MODEL_PROVIDER_IDS}. Returns `undefined` when the input is
140
- * not a known {@link RunModel} (so the SDK can fall back to the default and let
140
+ * not a known {@link ModelName} (so the SDK can fall back to the default and let
141
141
  * the server reject the model).
142
142
  */
143
- export declare function providerForModel(model: string): RunProvider | undefined;
143
+ export declare function providerForModel(model: string): ProviderName | undefined;
144
144
  /**
145
145
  * Translate a canonical model id + provider into the provider-native model
146
146
  * string the upstream API expects (e.g. `("gpt-4o-mini", "openrouter")` →
147
147
  * `"openai/gpt-4o-mini"`). Throws when the provider does not serve the model.
148
148
  */
149
- export declare function resolveProviderModelId(model: string, provider: RunProvider): string;
149
+ export declare function resolveProviderModelId(model: string, provider: ProviderName): string;
150
150
  /**
151
151
  * The single model→provider resolver shared by the SDK and the CLI, wrapping
152
152
  * {@link providersForModel} with the forward-compat unknown-model allowance:
@@ -159,9 +159,9 @@ export declare function resolveProviderModelId(model: string, provider: RunProvi
159
159
  * declared). An UNKNOWN model with no provider throws a `did you mean?`
160
160
  * hint — you must name a provider to run a model this client doesn't know.
161
161
  *
162
- * Returns the resolved {@link RunProvider}.
162
+ * Returns the resolved {@link ProviderName}.
163
163
  */
164
- export declare function resolveModelProvider(model: string, provider?: RunProvider): RunProvider;
165
- export declare function isRunModel(input: unknown): input is RunModel;
166
- export declare function parseRunModel(input: unknown, field?: string): RunModel;
167
- export declare function assertRunModelMatchesProvider(provider: RunProvider, model: RunModel, field?: string): void;
164
+ export declare function resolveModelProvider(model: string, provider?: ProviderName): ProviderName;
165
+ export declare function isModelName(input: unknown): input is ModelName;
166
+ export declare function parseModelName(input: unknown, field?: string): ModelName;
167
+ export declare function assertModelNameMatchesProvider(provider: ProviderName, model: ModelName, field?: string): void;