@axlsdk/axl 0.17.4 → 0.17.5
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/dist/index.cjs +575 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +246 -2
- package/dist/index.d.ts +246 -2
- package/dist/index.js +576 -36
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -279,7 +279,7 @@ type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
|
279
279
|
* derive `AxlEventType` from this tuple and use it to validate stream filters,
|
|
280
280
|
* redaction tables, and exhaustiveness assertions.
|
|
281
281
|
*/
|
|
282
|
-
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_approval", "tool_denied", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "verify", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
282
|
+
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_approval", "tool_denied", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
283
283
|
/** Discriminator union derived from `AXL_EVENT_TYPES`. */
|
|
284
284
|
type AxlEventType = (typeof AXL_EVENT_TYPES)[number];
|
|
285
285
|
/** Resolved model parameters sent to the provider for an LLM call. */
|
|
@@ -396,6 +396,39 @@ type VerifyData = {
|
|
|
396
396
|
passed: boolean;
|
|
397
397
|
lastError?: string;
|
|
398
398
|
};
|
|
399
|
+
/**
|
|
400
|
+
* Data shape for `string_delta` events.
|
|
401
|
+
*
|
|
402
|
+
* Emitted while the streaming walker is inside a string VALUE (not a key)
|
|
403
|
+
* during a schema-mode response. Each event carries the unescaped chars
|
|
404
|
+
* appended within a single text-delta chunk for one path; consumers
|
|
405
|
+
* concatenate `delta` per (`askId`, `path`) to reconstruct the running text.
|
|
406
|
+
*
|
|
407
|
+
* Splitting an escape sequence across chunks is supported — the walker
|
|
408
|
+
* holds escape state across chunks, so a `\\u00` in chunk N and `41` in
|
|
409
|
+
* chunk N+1 produces a single `A` in the chunk-N+1 delta.
|
|
410
|
+
*/
|
|
411
|
+
type StringDeltaData = {
|
|
412
|
+
/**
|
|
413
|
+
* RFC 6901 JSON Pointer to the string value. Examples:
|
|
414
|
+
* - `/summary` (root-level field)
|
|
415
|
+
* - `/sources/0/title` (nested through array)
|
|
416
|
+
* - keys containing `~` or `/` are escaped to `~0`/`~1` per RFC.
|
|
417
|
+
*
|
|
418
|
+
* Path is structural metadata (preserved under `trace.redact`).
|
|
419
|
+
*/
|
|
420
|
+
path: string;
|
|
421
|
+
/**
|
|
422
|
+
* Unescaped characters appended this chunk. JSON escapes are translated:
|
|
423
|
+
* `\\n` → "\n", `\\t` → "\t", `\\"` → '"', `\\\\` → "\\", `\\uXXXX` → the
|
|
424
|
+
* corresponding UTF-16 code unit. Surrogate pairs (e.g. `\\uD83D\\uDE00`)
|
|
425
|
+
* are emitted as two code units in the order they parse — matches what
|
|
426
|
+
* `JSON.parse` produces.
|
|
427
|
+
*
|
|
428
|
+
* Subject to `config.trace.redact` (always scrubbed when redaction is on).
|
|
429
|
+
*/
|
|
430
|
+
delta: string;
|
|
431
|
+
};
|
|
399
432
|
/** Data shape for legacy `guardrail` events. Replaced by `pipeline` in PR 2. */
|
|
400
433
|
type GuardrailData = {
|
|
401
434
|
guardrailType: 'input' | 'output';
|
|
@@ -717,6 +750,11 @@ type AxlEvent = (AxlEventBase & {
|
|
|
717
750
|
data: {
|
|
718
751
|
object: unknown;
|
|
719
752
|
};
|
|
753
|
+
}) | (AxlEventBase & AskScoped & {
|
|
754
|
+
type: 'string_delta';
|
|
755
|
+
/** 1-indexed schema-retry attempt; mirrors `partial_object.attempt`. */
|
|
756
|
+
attempt: number;
|
|
757
|
+
data: StringDeltaData;
|
|
720
758
|
}) | (AxlEventBase & AskScoped & {
|
|
721
759
|
type: 'verify';
|
|
722
760
|
data: VerifyData;
|
|
@@ -1010,6 +1048,59 @@ type CoalescedPartialObject = {
|
|
|
1010
1048
|
object: unknown;
|
|
1011
1049
|
attempt: number;
|
|
1012
1050
|
};
|
|
1051
|
+
/**
|
|
1052
|
+
* The shape yielded by `AxlEventBus.stringStream` (and `AxlStream.stringStream`).
|
|
1053
|
+
*
|
|
1054
|
+
* A live `string_delta` event carries `delta` (the new chars from this chunk)
|
|
1055
|
+
* and `accumulated` (every char emitted so far for this ask + path,
|
|
1056
|
+
* i.e. `delta1 + delta2 + ...`). Consumers rendering full-field state set
|
|
1057
|
+
* their UI text to `accumulated`; consumers rendering incrementally use
|
|
1058
|
+
* `delta` and append themselves.
|
|
1059
|
+
*
|
|
1060
|
+
* For LATE SUBSCRIBERS — those who attach `stringStream(...)` after one or
|
|
1061
|
+
* more `string_delta` events have already fired for an askId/path —
|
|
1062
|
+
* one synthetic event is yielded at subscribe time with `delta` ===
|
|
1063
|
+
* `accumulated` === the full text-so-far. This guarantees the consumer's
|
|
1064
|
+
* first render reflects the current state of the field, with no manual
|
|
1065
|
+
* catch-up logic.
|
|
1066
|
+
*
|
|
1067
|
+
* `attempt` matches the underlying `string_delta.attempt` (1-indexed
|
|
1068
|
+
* schema-retry counter). `pipeline(failed)` drops the accumulator AND
|
|
1069
|
+
* any pending events for that ask before they reach the consumer, so a
|
|
1070
|
+
* UI subscribed during attempt-N never sees stale text after attempt-N+1
|
|
1071
|
+
* begins.
|
|
1072
|
+
*/
|
|
1073
|
+
type StringStreamEvent = {
|
|
1074
|
+
askId: string;
|
|
1075
|
+
agent?: string;
|
|
1076
|
+
/** RFC 6901 JSON Pointer; matches the source `string_delta.data.path`. */
|
|
1077
|
+
path: string;
|
|
1078
|
+
/** Chars added in this delta. For seeded synthetic events on subscribe,
|
|
1079
|
+
* equals `accumulated` (the full text-so-far). */
|
|
1080
|
+
delta: string;
|
|
1081
|
+
/** Concatenation of every delta this ask + path has emitted in the
|
|
1082
|
+
* current attempt. Cleared on `pipeline(failed)` and `ask_end`. */
|
|
1083
|
+
accumulated: string;
|
|
1084
|
+
/** 1-indexed schema-retry attempt; mirrors the source event. */
|
|
1085
|
+
attempt: number;
|
|
1086
|
+
};
|
|
1087
|
+
/**
|
|
1088
|
+
* Optional filter applied at subscribe time. Filtering happens in the bus's
|
|
1089
|
+
* listener so non-matching events neither buffer nor wake the consumer's
|
|
1090
|
+
* waiter — cheaper than filtering in the consumer.
|
|
1091
|
+
*
|
|
1092
|
+
* - `path`: yield only events for this exact JSON Pointer. The walker
|
|
1093
|
+
* produces RFC 6901-encoded paths, so callers binding to a key with
|
|
1094
|
+
* special chars must encode (`a/b` → `/a~1b`).
|
|
1095
|
+
* - `askId`: yield only events from this ask. Useful when watching a
|
|
1096
|
+
* specific ask in a fan-out workflow.
|
|
1097
|
+
*
|
|
1098
|
+
* Both fields are AND-combined when both are set. Omit a field to wildcard.
|
|
1099
|
+
*/
|
|
1100
|
+
type StringStreamFilter = {
|
|
1101
|
+
path?: string;
|
|
1102
|
+
askId?: string;
|
|
1103
|
+
};
|
|
1013
1104
|
/**
|
|
1014
1105
|
* Thrown when an `AxlEventBus` queue exceeds `maxQueued` and `onOverflow`
|
|
1015
1106
|
* is set to `'throw'`. Surfaced as a typed error so the runtime's emit
|
|
@@ -1087,6 +1178,27 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1087
1178
|
* number of distinct askIds that emitted at least one partial.
|
|
1088
1179
|
*/
|
|
1089
1180
|
private latestPartialByAsk;
|
|
1181
|
+
/**
|
|
1182
|
+
* Per-ask, per-path running accumulator for `string_delta` events,
|
|
1183
|
+
* updated on every `_push(string_delta)` regardless of consumer state.
|
|
1184
|
+
* Used to seed late `stringStream` subscribers with the current text-
|
|
1185
|
+
* so-far per (askId, path) pair, so a UI binding to `/summary` mid-
|
|
1186
|
+
* stream renders the field's current state on first event instead of
|
|
1187
|
+
* waiting for the next chunk.
|
|
1188
|
+
*
|
|
1189
|
+
* Cleared per-askId on `pipeline(failed)` (discarded attempt — old
|
|
1190
|
+
* deltas must not leak into the next attempt's view) and on `ask_end`
|
|
1191
|
+
* (frees memory; stream-event accumulators don't outlive the ask).
|
|
1192
|
+
*
|
|
1193
|
+
* Memory bound: O(active asks × distinct paths × total chars per
|
|
1194
|
+
* field). For typical chat workflows (1 ask, 1-3 streaming string
|
|
1195
|
+
* fields) this is a few KB. The clear-on-`ask_end` cap keeps a
|
|
1196
|
+
* long-running runtime from accumulating per-ask entries forever
|
|
1197
|
+
* (the way `latestPartialByAsk` does — partial snapshots are tiny by
|
|
1198
|
+
* comparison so that map's growth is acceptable; string accumulators
|
|
1199
|
+
* can be 4 KB+ each, hence the more aggressive cleanup here).
|
|
1200
|
+
*/
|
|
1201
|
+
private stringStreamByAsk;
|
|
1090
1202
|
/**
|
|
1091
1203
|
* Hook fired when an iterator obtained from `[Symbol.asyncIterator]`
|
|
1092
1204
|
* is `await using`-disposed. Set via the second constructor argument.
|
|
@@ -1191,6 +1303,38 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1191
1303
|
* once the bus is finished (via `_finish()`).
|
|
1192
1304
|
*/
|
|
1193
1305
|
get partialObjects(): AsyncIterable<CoalescedPartialObject>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Listener-based view over `string_delta` events with optional
|
|
1308
|
+
* filtering by `path` and/or `askId`. Yields `StringStreamEvent`s
|
|
1309
|
+
* carrying `delta` (the new chars) and `accumulated` (the full text-
|
|
1310
|
+
* so-far for that ask + path).
|
|
1311
|
+
*
|
|
1312
|
+
* Designed for chat-style typewriter rendering of long string fields:
|
|
1313
|
+
* a React component binding to `path: '/summary'` sets its text to
|
|
1314
|
+
* `event.accumulated` on every yield, getting smooth char-by-char
|
|
1315
|
+
* progression with no parser of its own.
|
|
1316
|
+
*
|
|
1317
|
+
* Late-subscriber seeding: at subscribe time, the bus's per-ask
|
|
1318
|
+
* accumulator is walked and one synthetic `StringStreamEvent` is
|
|
1319
|
+
* yielded per matching (askId, path) entry, with `delta ===
|
|
1320
|
+
* accumulated === <full text-so-far>`. After that, live deltas flow
|
|
1321
|
+
* normally. A consumer who attaches mid-ask sees the field's current
|
|
1322
|
+
* state on first iteration, then incremental updates.
|
|
1323
|
+
*
|
|
1324
|
+
* Like `partialObjects`, this view is listener-based — it does NOT
|
|
1325
|
+
* race the main async iterator (`for await (const e of bus)`).
|
|
1326
|
+
* Running both concurrently each receives every matching event.
|
|
1327
|
+
*
|
|
1328
|
+
* Schema-retry awareness: on `pipeline(status: 'failed')`, the
|
|
1329
|
+
* accumulator and any pending events for the affected ask are
|
|
1330
|
+
* dropped, so a consumer iterating during attempt-N never observes
|
|
1331
|
+
* stale text after attempt-N+1 begins. Mirrors `partialObjects`'
|
|
1332
|
+
* per-attempt reset.
|
|
1333
|
+
*
|
|
1334
|
+
* Termination: yields any pending events first (live + seeded), then
|
|
1335
|
+
* `done: true` once the bus is finished via `_finish()`.
|
|
1336
|
+
*/
|
|
1337
|
+
stringStream(opts?: StringStreamFilter): AsyncIterable<StringStreamEvent>;
|
|
1194
1338
|
/** Iterator over structural lifecycle events only — skips per-token chatter
|
|
1195
1339
|
* and progressive `partial_object` emissions. Useful for waterfall UIs
|
|
1196
1340
|
* and any consumer that wants the "what happened" timeline. */
|
|
@@ -2364,6 +2508,18 @@ declare class AxlStream extends Readable implements AsyncIterable<AxlEvent> {
|
|
|
2364
2508
|
* `CoalescedPartialObject` shape is shared with the bus so the two
|
|
2365
2509
|
* surfaces can never drift on the `attempt` field. */
|
|
2366
2510
|
get partialObjects(): AsyncIterable<CoalescedPartialObject>;
|
|
2511
|
+
/** Listener-based view over `string_delta` events, with optional filter
|
|
2512
|
+
* on `path` and/or `askId`. Yields `StringStreamEvent`s carrying the new
|
|
2513
|
+
* `delta` and full text-so-far `accumulated`. Designed for chat-style
|
|
2514
|
+
* typewriter rendering of long string fields — bind a UI component to
|
|
2515
|
+
* one path and set its text to `event.accumulated` per yield.
|
|
2516
|
+
*
|
|
2517
|
+
* Late subscribers receive a synthetic event seeded from the bus's
|
|
2518
|
+
* per-ask accumulator (so the field's current state renders on the
|
|
2519
|
+
* first iteration, not after the next char arrives). Doesn't race the
|
|
2520
|
+
* main async iterator. See `AxlEventBus.stringStream` for full
|
|
2521
|
+
* semantics. */
|
|
2522
|
+
stringStream(opts?: StringStreamFilter): AsyncIterable<StringStreamEvent>;
|
|
2367
2523
|
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {
|
|
2368
2524
|
end?: boolean;
|
|
2369
2525
|
}): T;
|
|
@@ -3094,6 +3250,94 @@ declare function expandGlob(pattern: string, cwd: string): string[];
|
|
|
3094
3250
|
*/
|
|
3095
3251
|
declare function registerConditions(conditions: string[]): Promise<void>;
|
|
3096
3252
|
|
|
3253
|
+
/**
|
|
3254
|
+
* Browser-safe wire-side reconstructor for the `stringStream` view.
|
|
3255
|
+
*
|
|
3256
|
+
* Lives in its own module — separate from `event-stream.ts` which
|
|
3257
|
+
* imports `node:events`'s `EventEmitter` for `AxlEventBus` — so a
|
|
3258
|
+
* browser SPA importing only `stringStreamFromEvents` from
|
|
3259
|
+
* `@axlsdk/axl` cannot pull `EventEmitter` into the bundle even under
|
|
3260
|
+
* conservative bundler settings (webpack default is "assume side
|
|
3261
|
+
* effects unless `sideEffects: false` is set"). This is
|
|
3262
|
+
* defense-in-depth alongside `sideEffects: false` in `package.json`:
|
|
3263
|
+
* the module split guarantees tree-shaking at the *file* level (no
|
|
3264
|
+
* dead-code elimination required), so bundle size stays predictable
|
|
3265
|
+
* regardless of bundler configuration.
|
|
3266
|
+
*
|
|
3267
|
+
* All imports here are type-only (`import type`) and resolve against
|
|
3268
|
+
* `types.ts` and `event-stream.ts` — both erased at compile time, no
|
|
3269
|
+
* runtime edge.
|
|
3270
|
+
*/
|
|
3271
|
+
|
|
3272
|
+
/**
|
|
3273
|
+
* Reconstruct a `stringStream`-shaped view from a raw `AxlEvent` source.
|
|
3274
|
+
*
|
|
3275
|
+
* Use this when consuming events on the wire (WebSocket / SSE) rather
|
|
3276
|
+
* than from a live `AxlStream` / `AxlEventBus` you own. The browser-side
|
|
3277
|
+
* SPA has no access to the bus's per-ask accumulator, so each
|
|
3278
|
+
* `string_delta` event arrives carrying only the new chars — without
|
|
3279
|
+
* the running text. This helper maintains the accumulator client-side,
|
|
3280
|
+
* yielding `StringStreamEvent`s with the same `{ delta, accumulated }`
|
|
3281
|
+
* shape the server-side `stringStream` view produces.
|
|
3282
|
+
*
|
|
3283
|
+
* Pure ECMAScript — zero Node dependencies. Safe to bundle for the
|
|
3284
|
+
* browser; lives in its own module so even bundlers that don't honor
|
|
3285
|
+
* `sideEffects: false` won't pull `node:events` from the AxlEventBus
|
|
3286
|
+
* file.
|
|
3287
|
+
*
|
|
3288
|
+
* Differences from the live-bus view:
|
|
3289
|
+
*
|
|
3290
|
+
* - **No late-subscriber seeding.** The function starts accumulating
|
|
3291
|
+
* when iteration begins; if the source has already produced
|
|
3292
|
+
* `string_delta` events before then, those are missed. Server-side
|
|
3293
|
+
* operators wanting cross-reconnect recovery should re-emit current
|
|
3294
|
+
* state on subscribe (out of scope here — the wire transport is the
|
|
3295
|
+
* caller's responsibility).
|
|
3296
|
+
* - **No race-with-bus-iterator concern.** This is a stateless
|
|
3297
|
+
* consumer of an iterable; iterating it twice on the same source
|
|
3298
|
+
* consumes events twice (fork the source first if you need that).
|
|
3299
|
+
* - **No retroactive pending-drop on retry.** The bus view splices
|
|
3300
|
+
* pending events on `pipeline(failed)` to hide attempt-N text from
|
|
3301
|
+
* a buffered consumer. The wire helper has no buffer, so attempt-N
|
|
3302
|
+
* deltas that already yielded stay yielded. The accumulator clear
|
|
3303
|
+
* on `pipeline(failed)` still fires, so the next yielded event has
|
|
3304
|
+
* `accumulated === delta` — a UI re-rendering `event.accumulated`
|
|
3305
|
+
* per yield naturally overwrites stale text in place. Customers
|
|
3306
|
+
* appending `event.delta` to a manual buffer instead must reset the
|
|
3307
|
+
* buffer when `attempt` increases.
|
|
3308
|
+
*
|
|
3309
|
+
* Same filter / clear semantics as the bus view:
|
|
3310
|
+
*
|
|
3311
|
+
* - `opts.path` / `opts.askId` filter at yield time.
|
|
3312
|
+
* - `pipeline(failed)` clears the per-ask accumulator (so
|
|
3313
|
+
* attempt-N text never leaks into attempt-N+1).
|
|
3314
|
+
* - `ask_end` clears the per-ask accumulator (memory hygiene).
|
|
3315
|
+
*
|
|
3316
|
+
* Example (browser, consuming Studio's WS firehose):
|
|
3317
|
+
*
|
|
3318
|
+
* ```ts
|
|
3319
|
+
* import { stringStreamFromEvents } from '@axlsdk/axl';
|
|
3320
|
+
*
|
|
3321
|
+
* async function* readWs(ws: WebSocket): AsyncIterable<AxlEvent> {
|
|
3322
|
+
* const queue: AxlEvent[] = [];
|
|
3323
|
+
* let resolver: (() => void) | null = null;
|
|
3324
|
+
* ws.addEventListener('message', (m) => {
|
|
3325
|
+
* queue.push(JSON.parse(m.data).data);
|
|
3326
|
+
* resolver?.();
|
|
3327
|
+
* });
|
|
3328
|
+
* while (true) {
|
|
3329
|
+
* while (queue.length) yield queue.shift()!;
|
|
3330
|
+
* await new Promise<void>((r) => (resolver = r));
|
|
3331
|
+
* }
|
|
3332
|
+
* }
|
|
3333
|
+
*
|
|
3334
|
+
* for await (const e of stringStreamFromEvents(readWs(ws), { path: '/summary' })) {
|
|
3335
|
+
* setText(e.accumulated);
|
|
3336
|
+
* }
|
|
3337
|
+
* ```
|
|
3338
|
+
*/
|
|
3339
|
+
declare function stringStreamFromEvents(source: AsyncIterable<AxlEvent>, opts?: StringStreamFilter): AsyncIterable<StringStreamEvent>;
|
|
3340
|
+
|
|
3097
3341
|
/**
|
|
3098
3342
|
* Shared helpers for working with `AxlEvent` streams.
|
|
3099
3343
|
*
|
|
@@ -3735,4 +3979,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
3735
3979
|
*/
|
|
3736
3980
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
3737
3981
|
|
|
3738
|
-
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, tool, workflow, zodToJsonSchema };
|
|
3982
|
+
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -279,7 +279,7 @@ type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
|
279
279
|
* derive `AxlEventType` from this tuple and use it to validate stream filters,
|
|
280
280
|
* redaction tables, and exhaustiveness assertions.
|
|
281
281
|
*/
|
|
282
|
-
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_approval", "tool_denied", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "verify", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
282
|
+
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_approval", "tool_denied", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
283
283
|
/** Discriminator union derived from `AXL_EVENT_TYPES`. */
|
|
284
284
|
type AxlEventType = (typeof AXL_EVENT_TYPES)[number];
|
|
285
285
|
/** Resolved model parameters sent to the provider for an LLM call. */
|
|
@@ -396,6 +396,39 @@ type VerifyData = {
|
|
|
396
396
|
passed: boolean;
|
|
397
397
|
lastError?: string;
|
|
398
398
|
};
|
|
399
|
+
/**
|
|
400
|
+
* Data shape for `string_delta` events.
|
|
401
|
+
*
|
|
402
|
+
* Emitted while the streaming walker is inside a string VALUE (not a key)
|
|
403
|
+
* during a schema-mode response. Each event carries the unescaped chars
|
|
404
|
+
* appended within a single text-delta chunk for one path; consumers
|
|
405
|
+
* concatenate `delta` per (`askId`, `path`) to reconstruct the running text.
|
|
406
|
+
*
|
|
407
|
+
* Splitting an escape sequence across chunks is supported — the walker
|
|
408
|
+
* holds escape state across chunks, so a `\\u00` in chunk N and `41` in
|
|
409
|
+
* chunk N+1 produces a single `A` in the chunk-N+1 delta.
|
|
410
|
+
*/
|
|
411
|
+
type StringDeltaData = {
|
|
412
|
+
/**
|
|
413
|
+
* RFC 6901 JSON Pointer to the string value. Examples:
|
|
414
|
+
* - `/summary` (root-level field)
|
|
415
|
+
* - `/sources/0/title` (nested through array)
|
|
416
|
+
* - keys containing `~` or `/` are escaped to `~0`/`~1` per RFC.
|
|
417
|
+
*
|
|
418
|
+
* Path is structural metadata (preserved under `trace.redact`).
|
|
419
|
+
*/
|
|
420
|
+
path: string;
|
|
421
|
+
/**
|
|
422
|
+
* Unescaped characters appended this chunk. JSON escapes are translated:
|
|
423
|
+
* `\\n` → "\n", `\\t` → "\t", `\\"` → '"', `\\\\` → "\\", `\\uXXXX` → the
|
|
424
|
+
* corresponding UTF-16 code unit. Surrogate pairs (e.g. `\\uD83D\\uDE00`)
|
|
425
|
+
* are emitted as two code units in the order they parse — matches what
|
|
426
|
+
* `JSON.parse` produces.
|
|
427
|
+
*
|
|
428
|
+
* Subject to `config.trace.redact` (always scrubbed when redaction is on).
|
|
429
|
+
*/
|
|
430
|
+
delta: string;
|
|
431
|
+
};
|
|
399
432
|
/** Data shape for legacy `guardrail` events. Replaced by `pipeline` in PR 2. */
|
|
400
433
|
type GuardrailData = {
|
|
401
434
|
guardrailType: 'input' | 'output';
|
|
@@ -717,6 +750,11 @@ type AxlEvent = (AxlEventBase & {
|
|
|
717
750
|
data: {
|
|
718
751
|
object: unknown;
|
|
719
752
|
};
|
|
753
|
+
}) | (AxlEventBase & AskScoped & {
|
|
754
|
+
type: 'string_delta';
|
|
755
|
+
/** 1-indexed schema-retry attempt; mirrors `partial_object.attempt`. */
|
|
756
|
+
attempt: number;
|
|
757
|
+
data: StringDeltaData;
|
|
720
758
|
}) | (AxlEventBase & AskScoped & {
|
|
721
759
|
type: 'verify';
|
|
722
760
|
data: VerifyData;
|
|
@@ -1010,6 +1048,59 @@ type CoalescedPartialObject = {
|
|
|
1010
1048
|
object: unknown;
|
|
1011
1049
|
attempt: number;
|
|
1012
1050
|
};
|
|
1051
|
+
/**
|
|
1052
|
+
* The shape yielded by `AxlEventBus.stringStream` (and `AxlStream.stringStream`).
|
|
1053
|
+
*
|
|
1054
|
+
* A live `string_delta` event carries `delta` (the new chars from this chunk)
|
|
1055
|
+
* and `accumulated` (every char emitted so far for this ask + path,
|
|
1056
|
+
* i.e. `delta1 + delta2 + ...`). Consumers rendering full-field state set
|
|
1057
|
+
* their UI text to `accumulated`; consumers rendering incrementally use
|
|
1058
|
+
* `delta` and append themselves.
|
|
1059
|
+
*
|
|
1060
|
+
* For LATE SUBSCRIBERS — those who attach `stringStream(...)` after one or
|
|
1061
|
+
* more `string_delta` events have already fired for an askId/path —
|
|
1062
|
+
* one synthetic event is yielded at subscribe time with `delta` ===
|
|
1063
|
+
* `accumulated` === the full text-so-far. This guarantees the consumer's
|
|
1064
|
+
* first render reflects the current state of the field, with no manual
|
|
1065
|
+
* catch-up logic.
|
|
1066
|
+
*
|
|
1067
|
+
* `attempt` matches the underlying `string_delta.attempt` (1-indexed
|
|
1068
|
+
* schema-retry counter). `pipeline(failed)` drops the accumulator AND
|
|
1069
|
+
* any pending events for that ask before they reach the consumer, so a
|
|
1070
|
+
* UI subscribed during attempt-N never sees stale text after attempt-N+1
|
|
1071
|
+
* begins.
|
|
1072
|
+
*/
|
|
1073
|
+
type StringStreamEvent = {
|
|
1074
|
+
askId: string;
|
|
1075
|
+
agent?: string;
|
|
1076
|
+
/** RFC 6901 JSON Pointer; matches the source `string_delta.data.path`. */
|
|
1077
|
+
path: string;
|
|
1078
|
+
/** Chars added in this delta. For seeded synthetic events on subscribe,
|
|
1079
|
+
* equals `accumulated` (the full text-so-far). */
|
|
1080
|
+
delta: string;
|
|
1081
|
+
/** Concatenation of every delta this ask + path has emitted in the
|
|
1082
|
+
* current attempt. Cleared on `pipeline(failed)` and `ask_end`. */
|
|
1083
|
+
accumulated: string;
|
|
1084
|
+
/** 1-indexed schema-retry attempt; mirrors the source event. */
|
|
1085
|
+
attempt: number;
|
|
1086
|
+
};
|
|
1087
|
+
/**
|
|
1088
|
+
* Optional filter applied at subscribe time. Filtering happens in the bus's
|
|
1089
|
+
* listener so non-matching events neither buffer nor wake the consumer's
|
|
1090
|
+
* waiter — cheaper than filtering in the consumer.
|
|
1091
|
+
*
|
|
1092
|
+
* - `path`: yield only events for this exact JSON Pointer. The walker
|
|
1093
|
+
* produces RFC 6901-encoded paths, so callers binding to a key with
|
|
1094
|
+
* special chars must encode (`a/b` → `/a~1b`).
|
|
1095
|
+
* - `askId`: yield only events from this ask. Useful when watching a
|
|
1096
|
+
* specific ask in a fan-out workflow.
|
|
1097
|
+
*
|
|
1098
|
+
* Both fields are AND-combined when both are set. Omit a field to wildcard.
|
|
1099
|
+
*/
|
|
1100
|
+
type StringStreamFilter = {
|
|
1101
|
+
path?: string;
|
|
1102
|
+
askId?: string;
|
|
1103
|
+
};
|
|
1013
1104
|
/**
|
|
1014
1105
|
* Thrown when an `AxlEventBus` queue exceeds `maxQueued` and `onOverflow`
|
|
1015
1106
|
* is set to `'throw'`. Surfaced as a typed error so the runtime's emit
|
|
@@ -1087,6 +1178,27 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1087
1178
|
* number of distinct askIds that emitted at least one partial.
|
|
1088
1179
|
*/
|
|
1089
1180
|
private latestPartialByAsk;
|
|
1181
|
+
/**
|
|
1182
|
+
* Per-ask, per-path running accumulator for `string_delta` events,
|
|
1183
|
+
* updated on every `_push(string_delta)` regardless of consumer state.
|
|
1184
|
+
* Used to seed late `stringStream` subscribers with the current text-
|
|
1185
|
+
* so-far per (askId, path) pair, so a UI binding to `/summary` mid-
|
|
1186
|
+
* stream renders the field's current state on first event instead of
|
|
1187
|
+
* waiting for the next chunk.
|
|
1188
|
+
*
|
|
1189
|
+
* Cleared per-askId on `pipeline(failed)` (discarded attempt — old
|
|
1190
|
+
* deltas must not leak into the next attempt's view) and on `ask_end`
|
|
1191
|
+
* (frees memory; stream-event accumulators don't outlive the ask).
|
|
1192
|
+
*
|
|
1193
|
+
* Memory bound: O(active asks × distinct paths × total chars per
|
|
1194
|
+
* field). For typical chat workflows (1 ask, 1-3 streaming string
|
|
1195
|
+
* fields) this is a few KB. The clear-on-`ask_end` cap keeps a
|
|
1196
|
+
* long-running runtime from accumulating per-ask entries forever
|
|
1197
|
+
* (the way `latestPartialByAsk` does — partial snapshots are tiny by
|
|
1198
|
+
* comparison so that map's growth is acceptable; string accumulators
|
|
1199
|
+
* can be 4 KB+ each, hence the more aggressive cleanup here).
|
|
1200
|
+
*/
|
|
1201
|
+
private stringStreamByAsk;
|
|
1090
1202
|
/**
|
|
1091
1203
|
* Hook fired when an iterator obtained from `[Symbol.asyncIterator]`
|
|
1092
1204
|
* is `await using`-disposed. Set via the second constructor argument.
|
|
@@ -1191,6 +1303,38 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1191
1303
|
* once the bus is finished (via `_finish()`).
|
|
1192
1304
|
*/
|
|
1193
1305
|
get partialObjects(): AsyncIterable<CoalescedPartialObject>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Listener-based view over `string_delta` events with optional
|
|
1308
|
+
* filtering by `path` and/or `askId`. Yields `StringStreamEvent`s
|
|
1309
|
+
* carrying `delta` (the new chars) and `accumulated` (the full text-
|
|
1310
|
+
* so-far for that ask + path).
|
|
1311
|
+
*
|
|
1312
|
+
* Designed for chat-style typewriter rendering of long string fields:
|
|
1313
|
+
* a React component binding to `path: '/summary'` sets its text to
|
|
1314
|
+
* `event.accumulated` on every yield, getting smooth char-by-char
|
|
1315
|
+
* progression with no parser of its own.
|
|
1316
|
+
*
|
|
1317
|
+
* Late-subscriber seeding: at subscribe time, the bus's per-ask
|
|
1318
|
+
* accumulator is walked and one synthetic `StringStreamEvent` is
|
|
1319
|
+
* yielded per matching (askId, path) entry, with `delta ===
|
|
1320
|
+
* accumulated === <full text-so-far>`. After that, live deltas flow
|
|
1321
|
+
* normally. A consumer who attaches mid-ask sees the field's current
|
|
1322
|
+
* state on first iteration, then incremental updates.
|
|
1323
|
+
*
|
|
1324
|
+
* Like `partialObjects`, this view is listener-based — it does NOT
|
|
1325
|
+
* race the main async iterator (`for await (const e of bus)`).
|
|
1326
|
+
* Running both concurrently each receives every matching event.
|
|
1327
|
+
*
|
|
1328
|
+
* Schema-retry awareness: on `pipeline(status: 'failed')`, the
|
|
1329
|
+
* accumulator and any pending events for the affected ask are
|
|
1330
|
+
* dropped, so a consumer iterating during attempt-N never observes
|
|
1331
|
+
* stale text after attempt-N+1 begins. Mirrors `partialObjects`'
|
|
1332
|
+
* per-attempt reset.
|
|
1333
|
+
*
|
|
1334
|
+
* Termination: yields any pending events first (live + seeded), then
|
|
1335
|
+
* `done: true` once the bus is finished via `_finish()`.
|
|
1336
|
+
*/
|
|
1337
|
+
stringStream(opts?: StringStreamFilter): AsyncIterable<StringStreamEvent>;
|
|
1194
1338
|
/** Iterator over structural lifecycle events only — skips per-token chatter
|
|
1195
1339
|
* and progressive `partial_object` emissions. Useful for waterfall UIs
|
|
1196
1340
|
* and any consumer that wants the "what happened" timeline. */
|
|
@@ -2364,6 +2508,18 @@ declare class AxlStream extends Readable implements AsyncIterable<AxlEvent> {
|
|
|
2364
2508
|
* `CoalescedPartialObject` shape is shared with the bus so the two
|
|
2365
2509
|
* surfaces can never drift on the `attempt` field. */
|
|
2366
2510
|
get partialObjects(): AsyncIterable<CoalescedPartialObject>;
|
|
2511
|
+
/** Listener-based view over `string_delta` events, with optional filter
|
|
2512
|
+
* on `path` and/or `askId`. Yields `StringStreamEvent`s carrying the new
|
|
2513
|
+
* `delta` and full text-so-far `accumulated`. Designed for chat-style
|
|
2514
|
+
* typewriter rendering of long string fields — bind a UI component to
|
|
2515
|
+
* one path and set its text to `event.accumulated` per yield.
|
|
2516
|
+
*
|
|
2517
|
+
* Late subscribers receive a synthetic event seeded from the bus's
|
|
2518
|
+
* per-ask accumulator (so the field's current state renders on the
|
|
2519
|
+
* first iteration, not after the next char arrives). Doesn't race the
|
|
2520
|
+
* main async iterator. See `AxlEventBus.stringStream` for full
|
|
2521
|
+
* semantics. */
|
|
2522
|
+
stringStream(opts?: StringStreamFilter): AsyncIterable<StringStreamEvent>;
|
|
2367
2523
|
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {
|
|
2368
2524
|
end?: boolean;
|
|
2369
2525
|
}): T;
|
|
@@ -3094,6 +3250,94 @@ declare function expandGlob(pattern: string, cwd: string): string[];
|
|
|
3094
3250
|
*/
|
|
3095
3251
|
declare function registerConditions(conditions: string[]): Promise<void>;
|
|
3096
3252
|
|
|
3253
|
+
/**
|
|
3254
|
+
* Browser-safe wire-side reconstructor for the `stringStream` view.
|
|
3255
|
+
*
|
|
3256
|
+
* Lives in its own module — separate from `event-stream.ts` which
|
|
3257
|
+
* imports `node:events`'s `EventEmitter` for `AxlEventBus` — so a
|
|
3258
|
+
* browser SPA importing only `stringStreamFromEvents` from
|
|
3259
|
+
* `@axlsdk/axl` cannot pull `EventEmitter` into the bundle even under
|
|
3260
|
+
* conservative bundler settings (webpack default is "assume side
|
|
3261
|
+
* effects unless `sideEffects: false` is set"). This is
|
|
3262
|
+
* defense-in-depth alongside `sideEffects: false` in `package.json`:
|
|
3263
|
+
* the module split guarantees tree-shaking at the *file* level (no
|
|
3264
|
+
* dead-code elimination required), so bundle size stays predictable
|
|
3265
|
+
* regardless of bundler configuration.
|
|
3266
|
+
*
|
|
3267
|
+
* All imports here are type-only (`import type`) and resolve against
|
|
3268
|
+
* `types.ts` and `event-stream.ts` — both erased at compile time, no
|
|
3269
|
+
* runtime edge.
|
|
3270
|
+
*/
|
|
3271
|
+
|
|
3272
|
+
/**
|
|
3273
|
+
* Reconstruct a `stringStream`-shaped view from a raw `AxlEvent` source.
|
|
3274
|
+
*
|
|
3275
|
+
* Use this when consuming events on the wire (WebSocket / SSE) rather
|
|
3276
|
+
* than from a live `AxlStream` / `AxlEventBus` you own. The browser-side
|
|
3277
|
+
* SPA has no access to the bus's per-ask accumulator, so each
|
|
3278
|
+
* `string_delta` event arrives carrying only the new chars — without
|
|
3279
|
+
* the running text. This helper maintains the accumulator client-side,
|
|
3280
|
+
* yielding `StringStreamEvent`s with the same `{ delta, accumulated }`
|
|
3281
|
+
* shape the server-side `stringStream` view produces.
|
|
3282
|
+
*
|
|
3283
|
+
* Pure ECMAScript — zero Node dependencies. Safe to bundle for the
|
|
3284
|
+
* browser; lives in its own module so even bundlers that don't honor
|
|
3285
|
+
* `sideEffects: false` won't pull `node:events` from the AxlEventBus
|
|
3286
|
+
* file.
|
|
3287
|
+
*
|
|
3288
|
+
* Differences from the live-bus view:
|
|
3289
|
+
*
|
|
3290
|
+
* - **No late-subscriber seeding.** The function starts accumulating
|
|
3291
|
+
* when iteration begins; if the source has already produced
|
|
3292
|
+
* `string_delta` events before then, those are missed. Server-side
|
|
3293
|
+
* operators wanting cross-reconnect recovery should re-emit current
|
|
3294
|
+
* state on subscribe (out of scope here — the wire transport is the
|
|
3295
|
+
* caller's responsibility).
|
|
3296
|
+
* - **No race-with-bus-iterator concern.** This is a stateless
|
|
3297
|
+
* consumer of an iterable; iterating it twice on the same source
|
|
3298
|
+
* consumes events twice (fork the source first if you need that).
|
|
3299
|
+
* - **No retroactive pending-drop on retry.** The bus view splices
|
|
3300
|
+
* pending events on `pipeline(failed)` to hide attempt-N text from
|
|
3301
|
+
* a buffered consumer. The wire helper has no buffer, so attempt-N
|
|
3302
|
+
* deltas that already yielded stay yielded. The accumulator clear
|
|
3303
|
+
* on `pipeline(failed)` still fires, so the next yielded event has
|
|
3304
|
+
* `accumulated === delta` — a UI re-rendering `event.accumulated`
|
|
3305
|
+
* per yield naturally overwrites stale text in place. Customers
|
|
3306
|
+
* appending `event.delta` to a manual buffer instead must reset the
|
|
3307
|
+
* buffer when `attempt` increases.
|
|
3308
|
+
*
|
|
3309
|
+
* Same filter / clear semantics as the bus view:
|
|
3310
|
+
*
|
|
3311
|
+
* - `opts.path` / `opts.askId` filter at yield time.
|
|
3312
|
+
* - `pipeline(failed)` clears the per-ask accumulator (so
|
|
3313
|
+
* attempt-N text never leaks into attempt-N+1).
|
|
3314
|
+
* - `ask_end` clears the per-ask accumulator (memory hygiene).
|
|
3315
|
+
*
|
|
3316
|
+
* Example (browser, consuming Studio's WS firehose):
|
|
3317
|
+
*
|
|
3318
|
+
* ```ts
|
|
3319
|
+
* import { stringStreamFromEvents } from '@axlsdk/axl';
|
|
3320
|
+
*
|
|
3321
|
+
* async function* readWs(ws: WebSocket): AsyncIterable<AxlEvent> {
|
|
3322
|
+
* const queue: AxlEvent[] = [];
|
|
3323
|
+
* let resolver: (() => void) | null = null;
|
|
3324
|
+
* ws.addEventListener('message', (m) => {
|
|
3325
|
+
* queue.push(JSON.parse(m.data).data);
|
|
3326
|
+
* resolver?.();
|
|
3327
|
+
* });
|
|
3328
|
+
* while (true) {
|
|
3329
|
+
* while (queue.length) yield queue.shift()!;
|
|
3330
|
+
* await new Promise<void>((r) => (resolver = r));
|
|
3331
|
+
* }
|
|
3332
|
+
* }
|
|
3333
|
+
*
|
|
3334
|
+
* for await (const e of stringStreamFromEvents(readWs(ws), { path: '/summary' })) {
|
|
3335
|
+
* setText(e.accumulated);
|
|
3336
|
+
* }
|
|
3337
|
+
* ```
|
|
3338
|
+
*/
|
|
3339
|
+
declare function stringStreamFromEvents(source: AsyncIterable<AxlEvent>, opts?: StringStreamFilter): AsyncIterable<StringStreamEvent>;
|
|
3340
|
+
|
|
3097
3341
|
/**
|
|
3098
3342
|
* Shared helpers for working with `AxlEvent` streams.
|
|
3099
3343
|
*
|
|
@@ -3735,4 +3979,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
3735
3979
|
*/
|
|
3736
3980
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
3737
3981
|
|
|
3738
|
-
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, tool, workflow, zodToJsonSchema };
|
|
3982
|
+
export { AXL_EVENT_TYPES, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type AskOptions, type AskScoped, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CallbackMeta, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalData, type ToolCallData, type ToolCallMessage, type ToolCallStartData, type ToolChoice, type ToolConfig, ToolDenied, type ToolDeniedData, type ToolHooks, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, agent, createSpanManager, defineConfig, eventCostContribution, expandGlob, extractJson, findConfig, importModule, isCostBearingLeaf, isRootLevel, needsTsxLoader, parsePartialJson, pickDefault, pickExport, redactEvent, registerConditions, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|