@aexhq/sdk 0.40.16 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/dist/_contracts/api-key.d.ts +6 -4
- package/dist/_contracts/api-key.js +20 -7
- package/dist/_contracts/connection-ticket.d.ts +5 -5
- package/dist/_contracts/connection-ticket.js +7 -7
- package/dist/_contracts/error-codes.d.ts +1 -1
- package/dist/_contracts/error-codes.js +4 -4
- package/dist/_contracts/error-factory.js +1 -1
- package/dist/_contracts/event-envelope.d.ts +41 -41
- package/dist/_contracts/event-envelope.js +49 -49
- package/dist/_contracts/event-stream-client.d.ts +9 -9
- package/dist/_contracts/event-stream-client.js +5 -5
- package/dist/_contracts/event-view.d.ts +6 -6
- package/dist/_contracts/event-view.js +12 -12
- package/dist/_contracts/http.js +1 -1
- package/dist/_contracts/index.d.ts +10 -10
- package/dist/_contracts/index.js +9 -9
- package/dist/_contracts/models.d.ts +17 -17
- package/dist/_contracts/models.js +14 -14
- package/dist/_contracts/operations.d.ts +79 -82
- package/dist/_contracts/operations.js +233 -243
- package/dist/_contracts/provider-support.d.ts +2 -2
- package/dist/_contracts/runner-event.d.ts +8 -8
- package/dist/_contracts/runner-event.js +9 -9
- package/dist/_contracts/runtime-manifest.d.ts +12 -12
- package/dist/_contracts/runtime-manifest.js +1 -1
- package/dist/_contracts/runtime-sizes.d.ts +12 -12
- package/dist/_contracts/runtime-sizes.js +18 -18
- package/dist/_contracts/runtime-types.d.ts +117 -117
- package/dist/_contracts/runtime-types.js +2 -2
- package/dist/_contracts/sdk-errors.d.ts +3 -3
- package/dist/_contracts/sdk-errors.js +4 -4
- package/dist/_contracts/sdk-secrets.js +10 -10
- package/dist/_contracts/session-artifacts.d.ts +151 -0
- package/dist/_contracts/session-artifacts.js +234 -0
- package/dist/_contracts/{run-config.d.ts → session-config.d.ts} +29 -29
- package/dist/_contracts/{run-config.js → session-config.js} +37 -37
- package/dist/_contracts/session-cost.d.ts +140 -0
- package/dist/_contracts/{run-cost.js → session-cost.js} +94 -94
- package/dist/_contracts/{run-custody.d.ts → session-custody.d.ts} +16 -16
- package/dist/_contracts/{run-custody.js → session-custody.js} +42 -42
- package/dist/_contracts/session-record.d.ts +112 -0
- package/dist/_contracts/{run-record.js → session-record.js} +23 -23
- package/dist/_contracts/session-retention.d.ts +209 -0
- package/dist/_contracts/{run-retention.js → session-retention.js} +116 -116
- package/dist/_contracts/{run-unit.d.ts → session-unit.d.ts} +38 -38
- package/dist/_contracts/{run-unit.js → session-unit.js} +33 -33
- package/dist/_contracts/side-effect-audit.d.ts +14 -14
- package/dist/_contracts/side-effect-audit.js +38 -38
- package/dist/_contracts/sse.d.ts +1 -1
- package/dist/_contracts/sse.js +0 -0
- package/dist/_contracts/stable.d.ts +1 -1
- package/dist/_contracts/stable.js +1 -1
- package/dist/_contracts/status.d.ts +18 -18
- package/dist/_contracts/status.js +19 -19
- package/dist/_contracts/submission.d.ts +101 -99
- package/dist/_contracts/submission.js +96 -96
- package/dist/_contracts/{run-trace.d.ts → turn-trace.d.ts} +1 -1
- package/dist/_contracts/webhook-verify.d.ts +1 -1
- package/dist/_contracts/webhook-verify.js +1 -1
- package/dist/agents-md.d.ts +4 -4
- package/dist/agents-md.js +5 -5
- package/dist/agents-md.js.map +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/dist/cli.mjs +578 -621
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +141 -155
- package/dist/client.js +236 -245
- package/dist/client.js.map +1 -1
- package/dist/fetch-archive.js +3 -3
- package/dist/file.d.ts +7 -7
- package/dist/file.js +8 -8
- package/dist/file.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.d.ts +1 -1
- package/dist/retry.d.ts +1 -1
- package/dist/secret.d.ts +6 -6
- package/dist/secret.js +6 -6
- package/dist/secret.js.map +1 -1
- package/dist/skill.d.ts +2 -2
- package/dist/skill.js +3 -3
- package/dist/skill.js.map +1 -1
- package/dist/tool.js +2 -2
- package/dist/tool.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/authentication.md +11 -11
- package/docs/billing.md +3 -3
- package/docs/cleanup.md +5 -5
- package/docs/concepts/agent-tools.md +5 -5
- package/docs/concepts/composition.md +3 -3
- package/docs/concepts/providers-and-runtimes.md +3 -3
- package/docs/concepts/{runs.md → sessions.md} +8 -8
- package/docs/concepts/subagents.md +16 -16
- package/docs/credentials.md +7 -7
- package/docs/defaults.md +14 -14
- package/docs/errors.md +10 -10
- package/docs/events.md +26 -26
- package/docs/files.md +267 -0
- package/docs/limits-and-quotas.md +35 -35
- package/docs/limits.md +6 -6
- package/docs/mcp.md +3 -3
- package/docs/networking.md +24 -24
- package/docs/provider-runtime-capabilities.md +1 -1
- package/docs/public-surface.json +6 -6
- package/docs/quickstart.md +13 -13
- package/docs/release.md +5 -5
- package/docs/retries.md +3 -3
- package/docs/secrets.md +16 -16
- package/docs/session-config.md +58 -0
- package/docs/{run-record.md → session-record.md} +16 -16
- package/docs/skills.md +9 -9
- package/docs/vision-skills.md +7 -7
- package/docs/webhooks.md +11 -11
- package/examples/feature-tour.ts +17 -17
- package/examples/spike-settle-latency.ts +11 -11
- package/package.json +1 -1
- package/dist/_contracts/run-artifacts.d.ts +0 -49
- package/dist/_contracts/run-artifacts.js +0 -102
- package/dist/_contracts/run-cost.d.ts +0 -140
- package/dist/_contracts/run-record.d.ts +0 -116
- package/dist/_contracts/run-retention.d.ts +0 -209
- package/docs/outputs.md +0 -267
- package/docs/run-config.md +0 -58
- /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` (
|
|
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
|
|
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-
|
|
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-
|
|
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
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
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
|
|
92
|
-
// so terminal detection (
|
|
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.
|
|
106
|
+
id: `${ctx.sessionId}:${evt.seq}`,
|
|
107
107
|
source: projection.source,
|
|
108
108
|
type: projection.type,
|
|
109
|
-
subject: ctx.
|
|
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: "
|
|
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
|
|
157
|
+
// authoritative session *status* is still owned by the orchestrator and
|
|
158
158
|
// is never re-derived from this event.
|
|
159
|
-
type: reason === "error" ? "
|
|
159
|
+
type: reason === "error" ? "TURN_ERROR" : "TURN_FINISHED",
|
|
160
160
|
source: "runtime",
|
|
161
|
-
message: reason ? `
|
|
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
|
|
203
|
-
return e.type === "
|
|
202
|
+
export function isTurnStarted(e) {
|
|
203
|
+
return e.type === "TURN_STARTED";
|
|
204
204
|
}
|
|
205
|
-
export function
|
|
206
|
-
return e.type === "
|
|
205
|
+
export function isTurnFinished(e) {
|
|
206
|
+
return e.type === "TURN_FINISHED";
|
|
207
207
|
}
|
|
208
|
-
export function
|
|
209
|
-
return e.type === "
|
|
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
|
|
213
|
-
return e.type === "
|
|
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
|
|
217
|
-
* terminal. A managed one-shot
|
|
218
|
-
* rather than writing a `session_finished` →
|
|
219
|
-
* the AG-UI
|
|
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
|
-
*
|
|
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
|
|
241
|
-
* `awaiting_approval` is deliberately excluded — the
|
|
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
|
|
266
|
-
* Postgres mirror lands — so observing it ⇒ a subsequent `
|
|
267
|
-
* and `
|
|
268
|
-
* typed
|
|
269
|
-
* `streamEnvelopes(
|
|
270
|
-
* Unlike
|
|
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
|
|
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.
|
|
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
|
|
282
|
-
return customName(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
|
|
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
|
|
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 "
|
|
348
|
-
return { type: "
|
|
349
|
-
case "
|
|
350
|
-
return { type: "
|
|
351
|
-
case "
|
|
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: "
|
|
354
|
+
type: "TURN_ERROR",
|
|
355
355
|
timestamp,
|
|
356
|
-
message: str(d.failureMessage) || e.message || "
|
|
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
|
|
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
|
|
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/
|
|
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 (
|
|
55
|
-
* Pass {@link
|
|
56
|
-
* PAST
|
|
57
|
-
* once a subsequent `
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
31
|
-
// WITHOUT the session-park arm a `streamEnvelopes()` over a finished managed
|
|
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 === "
|
|
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
|
|
72
|
-
|
|
71
|
+
/** True for the turn-start lifecycle event. */
|
|
72
|
+
isTurnStarted(): boolean;
|
|
73
73
|
/** True for the terminal success event. */
|
|
74
|
-
|
|
74
|
+
isTurnFinished(): boolean;
|
|
75
75
|
/** True for the terminal error event. */
|
|
76
|
-
|
|
76
|
+
isTurnError(): boolean;
|
|
77
77
|
/** True for a terminal event of either flavour (finished or error). */
|
|
78
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
32
|
-
|
|
33
|
-
return this.type === "
|
|
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
|
-
|
|
37
|
-
return this.type === "
|
|
36
|
+
isTurnFinished() {
|
|
37
|
+
return this.type === "TURN_FINISHED";
|
|
38
38
|
}
|
|
39
39
|
/** True for the terminal error event. */
|
|
40
|
-
|
|
41
|
-
return this.type === "
|
|
40
|
+
isTurnError() {
|
|
41
|
+
return this.type === "TURN_ERROR";
|
|
42
42
|
}
|
|
43
43
|
/** True for a terminal event of either flavour (finished or error). */
|
|
44
|
-
|
|
45
|
-
return this.type === "
|
|
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
|
-
|
|
99
|
-
return
|
|
98
|
+
isSessionSettled() {
|
|
99
|
+
return isSessionSettled(this);
|
|
100
100
|
}
|
|
101
101
|
/** True when the record originates from the given coarse source. */
|
|
102
102
|
isFromSource(source) {
|
package/dist/_contracts/http.js
CHANGED
|
@@ -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
|
|
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,
|
|
5
|
-
export type { ApprovalGate, BuiltinToolName, JsonPrimitive, JsonValue, OutputMode,
|
|
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 "./
|
|
13
|
-
export type { AssistantTextEntry,
|
|
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 "./
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
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 "./
|
|
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 "./
|
|
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";
|
package/dist/_contracts/index.js
CHANGED
|
@@ -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,
|
|
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 "./
|
|
11
|
+
export * from "./session-unit.js";
|
|
12
12
|
export * from "./runtime-manifest.js";
|
|
13
13
|
export * from "./runtime-security-profile.js";
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./
|
|
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 "./
|
|
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 "./
|
|
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 `
|
|
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 {
|
|
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.*` / `
|
|
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
|
|
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
|
|
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
|
|
76
|
-
export declare const
|
|
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
|
|
129
|
+
* model, so all {@link ProviderName} keys are present.
|
|
130
130
|
*/
|
|
131
|
-
export declare const
|
|
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
|
|
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
|
|
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):
|
|
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:
|
|
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
|
|
162
|
+
* Returns the resolved {@link ProviderName}.
|
|
163
163
|
*/
|
|
164
|
-
export declare function resolveModelProvider(model: string, provider?:
|
|
165
|
-
export declare function
|
|
166
|
-
export declare function
|
|
167
|
-
export declare function
|
|
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;
|