@axlsdk/axl 0.13.8 → 0.15.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 +19 -0
- package/dist/index.cjs +763 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +407 -13
- package/dist/index.d.ts +407 -13
- package/dist/index.js +763 -137
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -274,14 +274,135 @@ type RaceOptions<T = unknown> = {
|
|
|
274
274
|
};
|
|
275
275
|
/** Execution status */
|
|
276
276
|
type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
277
|
-
/** Trace event */
|
|
278
|
-
type
|
|
277
|
+
/** Trace event type. See `TraceEvent` for per-type data shapes. */
|
|
278
|
+
type TraceEventType = 'agent_call' | 'tool_call' | 'verify' | 'handoff' | 'delegate' | 'tool_denied' | 'tool_approval' | 'log' | 'workflow_start' | 'workflow_end' | 'guardrail' | 'schema_check' | 'validate';
|
|
279
|
+
/** Data shape for `agent_call` trace events. Populated on every LLM call (pass or fail). */
|
|
280
|
+
type AgentCallTraceData = {
|
|
281
|
+
/** Original user prompt passed to `ctx.ask()`. Does not include retry feedback or tool results. */
|
|
282
|
+
prompt: string;
|
|
283
|
+
/** Final LLM response content for this turn. */
|
|
284
|
+
response: string;
|
|
285
|
+
/** Resolved system prompt (after evaluating dynamic system selectors). */
|
|
286
|
+
system?: string;
|
|
287
|
+
/** Reasoning/thinking content returned by the provider, when available. */
|
|
288
|
+
thinking?: string;
|
|
289
|
+
/** Resolved model parameters sent to the provider for this call. */
|
|
290
|
+
params?: {
|
|
291
|
+
temperature?: number;
|
|
292
|
+
maxTokens?: number;
|
|
293
|
+
effort?: Effort;
|
|
294
|
+
thinkingBudget?: number;
|
|
295
|
+
includeThoughts?: boolean;
|
|
296
|
+
toolChoice?: ToolChoice;
|
|
297
|
+
stop?: string[];
|
|
298
|
+
};
|
|
299
|
+
/** 1-indexed iteration of the tool-calling loop for this `ctx.ask()` call. */
|
|
300
|
+
turn?: number;
|
|
301
|
+
/** When set, this call is a retry triggered by a failed gate check on the previous turn. */
|
|
302
|
+
retryReason?: 'schema' | 'validate' | 'guardrail';
|
|
303
|
+
/** Full ChatMessage[] sent to the provider this turn. Only populated when `trace.level === 'full'`. */
|
|
304
|
+
messages?: ChatMessage[];
|
|
305
|
+
};
|
|
306
|
+
/** Data shape for `guardrail` trace events. */
|
|
307
|
+
type GuardrailTraceData = {
|
|
308
|
+
guardrailType: 'input' | 'output';
|
|
309
|
+
blocked: boolean;
|
|
310
|
+
reason?: string;
|
|
311
|
+
/** 1-indexed attempt count (output guardrails only). */
|
|
312
|
+
attempt?: number;
|
|
313
|
+
/** Maximum attempts allowed before the guardrail throws. */
|
|
314
|
+
maxAttempts?: number;
|
|
315
|
+
/** The exact corrective message about to be injected into the conversation — only set when
|
|
316
|
+
* this check failed and a retry is happening. Gives users visibility into what the LLM sees
|
|
317
|
+
* between retry attempts. */
|
|
318
|
+
feedbackMessage?: string;
|
|
319
|
+
};
|
|
320
|
+
/** Data shape for `schema_check` trace events. Emitted on every schema parse (pass or fail). */
|
|
321
|
+
type SchemaCheckTraceData = {
|
|
322
|
+
valid: boolean;
|
|
323
|
+
reason?: string;
|
|
324
|
+
attempt: number;
|
|
325
|
+
maxAttempts: number;
|
|
326
|
+
feedbackMessage?: string;
|
|
327
|
+
};
|
|
328
|
+
/** Data shape for `validate` trace events (post-schema business rule validation). */
|
|
329
|
+
type ValidateTraceData = {
|
|
330
|
+
valid: boolean;
|
|
331
|
+
reason?: string;
|
|
332
|
+
attempt: number;
|
|
333
|
+
maxAttempts: number;
|
|
334
|
+
feedbackMessage?: string;
|
|
335
|
+
};
|
|
336
|
+
/** Data shape for `tool_approval` trace events. Emitted by the approval gate on both outcomes. */
|
|
337
|
+
type ToolApprovalTraceData = {
|
|
338
|
+
approved: boolean;
|
|
339
|
+
args: unknown;
|
|
340
|
+
reason?: string;
|
|
341
|
+
};
|
|
342
|
+
/** Data shape for `tool_call` trace events. */
|
|
343
|
+
type ToolCallTraceData = {
|
|
344
|
+
args: unknown;
|
|
345
|
+
result: unknown;
|
|
346
|
+
callId?: string;
|
|
347
|
+
};
|
|
348
|
+
/** Data shape for `handoff` trace events. */
|
|
349
|
+
type HandoffTraceData = {
|
|
350
|
+
target: string;
|
|
351
|
+
mode: 'oneway' | 'roundtrip';
|
|
352
|
+
/** Wall-clock ms from handoff_to_X tool call to target agent completion.
|
|
353
|
+
* Always emitted — the event only fires at the terminal point of the
|
|
354
|
+
* handoff, so we always have a measurement. */
|
|
355
|
+
duration: number;
|
|
356
|
+
/** Source agent that initiated the handoff (mirrors the event's `agent` field
|
|
357
|
+
* for convenience — lets consumers query the handoff chain without
|
|
358
|
+
* stitching together event.agent and data.target). */
|
|
359
|
+
source?: string;
|
|
360
|
+
/** The `message` arg the source agent passed when invoking `handoff_to_X`
|
|
361
|
+
* (roundtrip mode only). Gives observability into *why* the source chose
|
|
362
|
+
* to delegate. Subject to `config.trace.redact`. */
|
|
363
|
+
message?: string;
|
|
364
|
+
};
|
|
365
|
+
/** Data shape for `delegate` trace events. */
|
|
366
|
+
type DelegateTraceData = {
|
|
367
|
+
candidates: string[];
|
|
368
|
+
/** Set when the decision is known at emission time (single-agent short-circuit). */
|
|
369
|
+
selected?: string;
|
|
370
|
+
/** Router model used for multi-agent routing. */
|
|
371
|
+
routerModel?: string;
|
|
372
|
+
/** Why this delegate was emitted: 'routed' (multi-agent) or 'single_candidate'. */
|
|
373
|
+
reason: 'routed' | 'single_candidate';
|
|
374
|
+
};
|
|
375
|
+
/** Data shape for `verify` trace events. */
|
|
376
|
+
type VerifyTraceData = {
|
|
377
|
+
attempts: number;
|
|
378
|
+
passed: boolean;
|
|
379
|
+
lastError?: string;
|
|
380
|
+
};
|
|
381
|
+
/** Data shape for `workflow_start` trace events. Emitted once per workflow execution. */
|
|
382
|
+
type WorkflowStartTraceData = {
|
|
383
|
+
/** The validated input passed to the workflow handler. */
|
|
384
|
+
input: unknown;
|
|
385
|
+
};
|
|
386
|
+
/** Data shape for `workflow_end` trace events. Emitted once per workflow execution
|
|
387
|
+
* on completion, failure, or cancellation. Distinguish cancellation via `aborted`. */
|
|
388
|
+
type WorkflowEndTraceData = {
|
|
389
|
+
status: 'completed' | 'failed';
|
|
390
|
+
duration: number;
|
|
391
|
+
/** Workflow return value. Present on `status: 'completed'`. */
|
|
392
|
+
result?: unknown;
|
|
393
|
+
/** Error message. Present on `status: 'failed'`. */
|
|
394
|
+
error?: string;
|
|
395
|
+
/** True when the failure was an `AbortError` (user cancellation, budget hard_stop,
|
|
396
|
+
* or consumer disconnect on streaming workflows). */
|
|
397
|
+
aborted?: boolean;
|
|
398
|
+
};
|
|
399
|
+
/** Common fields carried by every `TraceEvent` regardless of `type`. */
|
|
400
|
+
type TraceEventBase = {
|
|
279
401
|
executionId: string;
|
|
280
402
|
step: number;
|
|
281
|
-
|
|
403
|
+
timestamp: number;
|
|
282
404
|
workflow?: string;
|
|
283
405
|
agent?: string;
|
|
284
|
-
tool?: string;
|
|
285
406
|
promptVersion?: string;
|
|
286
407
|
model?: string;
|
|
287
408
|
cost?: number;
|
|
@@ -291,9 +412,62 @@ type TraceEvent = {
|
|
|
291
412
|
reasoning?: number;
|
|
292
413
|
};
|
|
293
414
|
duration?: number;
|
|
294
|
-
|
|
295
|
-
|
|
415
|
+
/** When set, this event was emitted from a child context spawned by a tool
|
|
416
|
+
* handler. The value is the `callId` of the outer `tool_call` that invoked
|
|
417
|
+
* the tool. Lets consumers reconstruct agent-as-tool call graphs by
|
|
418
|
+
* joining nested events to their parent `tool_call`. Undefined on top-level
|
|
419
|
+
* events. */
|
|
420
|
+
parentToolCallId?: string;
|
|
296
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* Trace event. A discriminated union over `type` — consumers that narrow via
|
|
424
|
+
* `type` get statically-typed access to `data` and event-specific fields.
|
|
425
|
+
* When adding a new event type, extend this union AND the emitter in
|
|
426
|
+
* `WorkflowContext.emitTrace()` together so the compiler catches drift.
|
|
427
|
+
*/
|
|
428
|
+
type TraceEvent = (TraceEventBase & {
|
|
429
|
+
type: 'agent_call';
|
|
430
|
+
data?: AgentCallTraceData;
|
|
431
|
+
}) | (TraceEventBase & {
|
|
432
|
+
type: 'tool_call';
|
|
433
|
+
tool: string;
|
|
434
|
+
data?: ToolCallTraceData;
|
|
435
|
+
}) | (TraceEventBase & {
|
|
436
|
+
type: 'tool_approval';
|
|
437
|
+
tool: string;
|
|
438
|
+
data?: ToolApprovalTraceData;
|
|
439
|
+
}) | (TraceEventBase & {
|
|
440
|
+
type: 'tool_denied';
|
|
441
|
+
tool: string;
|
|
442
|
+
data?: unknown;
|
|
443
|
+
}) | (TraceEventBase & {
|
|
444
|
+
type: 'guardrail';
|
|
445
|
+
data?: GuardrailTraceData;
|
|
446
|
+
}) | (TraceEventBase & {
|
|
447
|
+
type: 'schema_check';
|
|
448
|
+
data?: SchemaCheckTraceData;
|
|
449
|
+
}) | (TraceEventBase & {
|
|
450
|
+
type: 'validate';
|
|
451
|
+
data?: ValidateTraceData;
|
|
452
|
+
}) | (TraceEventBase & {
|
|
453
|
+
type: 'delegate';
|
|
454
|
+
data?: DelegateTraceData;
|
|
455
|
+
}) | (TraceEventBase & {
|
|
456
|
+
type: 'handoff';
|
|
457
|
+
data?: HandoffTraceData;
|
|
458
|
+
}) | (TraceEventBase & {
|
|
459
|
+
type: 'verify';
|
|
460
|
+
data?: VerifyTraceData;
|
|
461
|
+
}) | (TraceEventBase & {
|
|
462
|
+
type: 'log';
|
|
463
|
+
data?: unknown;
|
|
464
|
+
}) | (TraceEventBase & {
|
|
465
|
+
type: 'workflow_start';
|
|
466
|
+
data?: WorkflowStartTraceData;
|
|
467
|
+
}) | (TraceEventBase & {
|
|
468
|
+
type: 'workflow_end';
|
|
469
|
+
data?: WorkflowEndTraceData;
|
|
470
|
+
});
|
|
297
471
|
/** Result of a guardrail check. */
|
|
298
472
|
type GuardrailResult = {
|
|
299
473
|
block: boolean;
|
|
@@ -571,6 +745,8 @@ interface StateStore {
|
|
|
571
745
|
saveEvalResult?(entry: EvalHistoryEntry): Promise<void>;
|
|
572
746
|
/** List eval history entries (most recent first). */
|
|
573
747
|
listEvalResults?(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
748
|
+
/** Delete an eval history entry by id. Returns true if an entry was deleted. */
|
|
749
|
+
deleteEvalResult?(id: string): Promise<boolean>;
|
|
574
750
|
/** List all session IDs (used by Studio session browser). */
|
|
575
751
|
listSessions?(): Promise<string[]>;
|
|
576
752
|
close?(): Promise<void>;
|
|
@@ -649,9 +825,49 @@ interface VectorStore {
|
|
|
649
825
|
delete(ids: string[]): Promise<void>;
|
|
650
826
|
close?(): Promise<void>;
|
|
651
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Usage info reported by an embedder for a single `embed()` call.
|
|
830
|
+
*
|
|
831
|
+
* Mirrors the provider `usage` namespace — nested rather than flat so
|
|
832
|
+
* future additions (latency, cache-hit info, rate-limit headers) extend
|
|
833
|
+
* this type without breaking the `Embedder` return shape.
|
|
834
|
+
*
|
|
835
|
+
* All fields are optional so embedders without cost/pricing knowledge
|
|
836
|
+
* (e.g. local models, self-hosted) can still conform to the interface.
|
|
837
|
+
*/
|
|
838
|
+
type EmbedUsage = {
|
|
839
|
+
/** Total input tokens consumed. */
|
|
840
|
+
tokens?: number;
|
|
841
|
+
/** Cost in USD, computed from tokens × per-model pricing. */
|
|
842
|
+
cost?: number;
|
|
843
|
+
/** The underlying model identifier (e.g. "text-embedding-3-small"). */
|
|
844
|
+
model?: string;
|
|
845
|
+
};
|
|
846
|
+
/**
|
|
847
|
+
* Result of an `Embedder.embed()` call.
|
|
848
|
+
*
|
|
849
|
+
* Always contains `vectors`. `usage` is optional so embedders can omit
|
|
850
|
+
* it entirely (non-OpenAI, local, test fakes).
|
|
851
|
+
*/
|
|
852
|
+
type EmbedResult = {
|
|
853
|
+
vectors: number[][];
|
|
854
|
+
usage?: EmbedUsage;
|
|
855
|
+
};
|
|
652
856
|
/** Embedder interface for converting text to vectors. */
|
|
653
857
|
interface Embedder {
|
|
654
|
-
|
|
858
|
+
/**
|
|
859
|
+
* Embed one or more texts into vectors.
|
|
860
|
+
*
|
|
861
|
+
* @param texts Input strings to embed.
|
|
862
|
+
* @param signal Optional `AbortSignal` — when triggered, the underlying
|
|
863
|
+
* network call should abort. Passed through from
|
|
864
|
+
* `ctx.remember` / `ctx.recall` so user cancellation and
|
|
865
|
+
* hard_stop budget aborts propagate to the embedder fetch.
|
|
866
|
+
* Impls are free to ignore it (the call just runs to
|
|
867
|
+
* completion like before), but OpenAIEmbedder honors it
|
|
868
|
+
* via `fetchWithRetry`.
|
|
869
|
+
*/
|
|
870
|
+
embed(texts: string[], signal?: AbortSignal): Promise<EmbedResult>;
|
|
655
871
|
readonly dimensions: number;
|
|
656
872
|
}
|
|
657
873
|
/** Memory configuration. */
|
|
@@ -909,6 +1125,28 @@ declare class McpManager {
|
|
|
909
1125
|
get serverCount(): number;
|
|
910
1126
|
}
|
|
911
1127
|
|
|
1128
|
+
/**
|
|
1129
|
+
* Result of a `MemoryManager.remember()` call.
|
|
1130
|
+
*
|
|
1131
|
+
* Exposes embedder `usage` so callers (WorkflowContext) can attribute
|
|
1132
|
+
* cost to the current execution scope and surface it in trace events.
|
|
1133
|
+
* `usage` is absent when no embedding happened (embed option not set,
|
|
1134
|
+
* or no vector store configured).
|
|
1135
|
+
*/
|
|
1136
|
+
type RememberResult = {
|
|
1137
|
+
usage?: EmbedUsage;
|
|
1138
|
+
};
|
|
1139
|
+
/**
|
|
1140
|
+
* Result of a `MemoryManager.recall()` call.
|
|
1141
|
+
*
|
|
1142
|
+
* Wraps the original return shape (key-value payload or vector search
|
|
1143
|
+
* results) with optional embedder `usage`. Semantic recall populates
|
|
1144
|
+
* `usage` when the embedder reported it; key-value lookups never do.
|
|
1145
|
+
*/
|
|
1146
|
+
type RecallResult = {
|
|
1147
|
+
data: unknown | VectorResult[] | null;
|
|
1148
|
+
usage?: EmbedUsage;
|
|
1149
|
+
};
|
|
912
1150
|
/**
|
|
913
1151
|
* Coordinates key-value memory and vector store for semantic search.
|
|
914
1152
|
* All key-value operations delegate to the StateStore.
|
|
@@ -925,12 +1163,18 @@ declare class MemoryManager {
|
|
|
925
1163
|
* Store a key-value pair in memory.
|
|
926
1164
|
* If a vector store and embedder are configured and embed is true,
|
|
927
1165
|
* also embeds the value for semantic search.
|
|
1166
|
+
*
|
|
1167
|
+
* Returns `{ usage }` when embedding happened, carrying the embedder's
|
|
1168
|
+
* cost/token reporting out to the caller for cost attribution.
|
|
928
1169
|
*/
|
|
929
|
-
remember(key: string, value: unknown, stateStore: StateStore, sessionId: string | undefined, options?: RememberOptions): Promise<
|
|
1170
|
+
remember(key: string, value: unknown, stateStore: StateStore, sessionId: string | undefined, options?: RememberOptions, signal?: AbortSignal): Promise<RememberResult>;
|
|
930
1171
|
/**
|
|
931
1172
|
* Recall a value from memory by key, or perform semantic search if query is provided.
|
|
1173
|
+
*
|
|
1174
|
+
* Always returns `{ data }`; semantic recalls additionally include
|
|
1175
|
+
* `usage` from the embedder (when the embedder reported it).
|
|
932
1176
|
*/
|
|
933
|
-
recall(key: string, stateStore: StateStore, sessionId: string | undefined, options?: RecallOptions): Promise<
|
|
1177
|
+
recall(key: string, stateStore: StateStore, sessionId: string | undefined, options?: RecallOptions, signal?: AbortSignal): Promise<RecallResult>;
|
|
934
1178
|
/** Delete a memory entry. If a vector store is configured, also removes the embedding. */
|
|
935
1179
|
forget(key: string, stateStore: StateStore, sessionId: string | undefined, options?: {
|
|
936
1180
|
scope?: 'session' | 'global';
|
|
@@ -992,6 +1236,10 @@ type WorkflowContextInit = {
|
|
|
992
1236
|
}) => void;
|
|
993
1237
|
/** Callback fired after each ctx.ask() completes (once per ask invocation). */
|
|
994
1238
|
onAgentCallComplete?: (call: AgentCallInfo) => void;
|
|
1239
|
+
/** Set by `createChildContext(parentToolCallId)` — stamped on every trace event
|
|
1240
|
+
* emitted from this child so consumers can join nested agent calls back to
|
|
1241
|
+
* the outer tool call that spawned them. */
|
|
1242
|
+
parentToolCallId?: string;
|
|
995
1243
|
};
|
|
996
1244
|
/**
|
|
997
1245
|
* The central coordination object for all Axl primitives.
|
|
@@ -1029,6 +1277,7 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
1029
1277
|
private awaitHumanHandler?;
|
|
1030
1278
|
private onAgentStart?;
|
|
1031
1279
|
private onAgentCallComplete?;
|
|
1280
|
+
private parentToolCallId?;
|
|
1032
1281
|
constructor(init: WorkflowContextInit);
|
|
1033
1282
|
/**
|
|
1034
1283
|
* Create a child context for nested agent invocations (e.g., agent-as-tool).
|
|
@@ -1036,8 +1285,13 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
1036
1285
|
* state store, span manager, memory manager, MCP manager, config,
|
|
1037
1286
|
* awaitHuman handler, pending decisions, tool overrides.
|
|
1038
1287
|
* Isolates: session history, step counter, streaming callbacks (onToken, onAgentStart, onToolCall).
|
|
1288
|
+
*
|
|
1289
|
+
* @param parentToolCallId - The `callId` of the outer `tool_call` that
|
|
1290
|
+
* spawned this child. When set, every trace event emitted by the child
|
|
1291
|
+
* will carry this id as `parentToolCallId`, so consumers can join nested
|
|
1292
|
+
* agent calls back to the outer tool call that invoked them.
|
|
1039
1293
|
*/
|
|
1040
|
-
createChildContext(): WorkflowContext;
|
|
1294
|
+
createChildContext(parentToolCallId?: string): WorkflowContext;
|
|
1041
1295
|
/**
|
|
1042
1296
|
* Resolve the current abort signal.
|
|
1043
1297
|
* Branch-scoped signals (from race/spawn/map/budget) in AsyncLocalStorage
|
|
@@ -1097,6 +1351,42 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
1097
1351
|
private _mapImpl;
|
|
1098
1352
|
awaitHuman(options: AwaitHumanOptions): Promise<HumanDecision>;
|
|
1099
1353
|
private _awaitHumanImpl;
|
|
1354
|
+
/**
|
|
1355
|
+
* Compose an `AbortSignal` for a memory operation's underlying embedder
|
|
1356
|
+
* fetch. Combines the parent context signal (user cancellation,
|
|
1357
|
+
* `runtime.execute({ signal })`) with the budget hard_stop abort so
|
|
1358
|
+
* that either cause correctly aborts an in-flight embed call.
|
|
1359
|
+
*
|
|
1360
|
+
* Returns `undefined` if there's nothing to cancel on — the embedder
|
|
1361
|
+
* runs without a signal in that case, matching its prior behavior.
|
|
1362
|
+
*
|
|
1363
|
+
* @internal
|
|
1364
|
+
*/
|
|
1365
|
+
private _composeMemorySignal;
|
|
1366
|
+
/**
|
|
1367
|
+
* Accumulate a cost amount into the active `budgetContext` and trip the
|
|
1368
|
+
* `exceeded` flag if we've crossed the limit. On `hard_stop` policy,
|
|
1369
|
+
* also fires the abort controller so in-flight operations cancel.
|
|
1370
|
+
*
|
|
1371
|
+
* Called from every code path that spends money: the `agent_call` loop,
|
|
1372
|
+
* semantic memory operations (`ctx.remember({embed:true})`, `ctx.recall({query})`),
|
|
1373
|
+
* and any future cost-emitting primitive. Centralizing the logic here
|
|
1374
|
+
* means `ctx.budget({ limit, policy })` accurately enforces the limit
|
|
1375
|
+
* across ALL cost sources — not just agent calls.
|
|
1376
|
+
*
|
|
1377
|
+
* @internal
|
|
1378
|
+
*/
|
|
1379
|
+
private _accumulateBudgetCost;
|
|
1380
|
+
/** @internal */
|
|
1381
|
+
_emitWorkflowStart(input: unknown): void;
|
|
1382
|
+
/** @internal */
|
|
1383
|
+
_emitWorkflowEnd(info: {
|
|
1384
|
+
status: 'completed' | 'failed';
|
|
1385
|
+
duration: number;
|
|
1386
|
+
result?: unknown;
|
|
1387
|
+
error?: string;
|
|
1388
|
+
aborted?: boolean;
|
|
1389
|
+
}): void;
|
|
1100
1390
|
log(event: string, data?: unknown): void;
|
|
1101
1391
|
/**
|
|
1102
1392
|
* Store a value in memory, scoped to the current session (default) or globally.
|
|
@@ -1123,6 +1413,12 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
1123
1413
|
* @param options - Optional: schema, routerModel, metadata, retries
|
|
1124
1414
|
*/
|
|
1125
1415
|
delegate<T = string>(agents: Agent[], prompt: string, options?: DelegateOptions<T>): Promise<T>;
|
|
1416
|
+
/**
|
|
1417
|
+
* Internal emitter input — intentionally loose so call sites don't need to
|
|
1418
|
+
* build a perfectly-narrowed discriminated-union member. The resulting
|
|
1419
|
+
* `TraceEvent` (exported type) remains strict, and TypeScript narrows it at
|
|
1420
|
+
* consumer sites via the `type` discriminator.
|
|
1421
|
+
*/
|
|
1126
1422
|
private emitTrace;
|
|
1127
1423
|
}
|
|
1128
1424
|
|
|
@@ -1273,6 +1569,25 @@ declare class Session {
|
|
|
1273
1569
|
|
|
1274
1570
|
type ExecuteOptions = {
|
|
1275
1571
|
metadata?: Record<string, unknown>;
|
|
1572
|
+
/** Handler for tool approval requests. When provided, tools with `requireApproval` resolve
|
|
1573
|
+
* via this handler instead of suspending the execution and registering a pending decision.
|
|
1574
|
+
* Useful for in-process testing and ad-hoc invocations where you don't want to poll
|
|
1575
|
+
* `runtime.getPendingDecisions()` and call `runtime.resolveDecision()`. */
|
|
1576
|
+
awaitHumanHandler?: (options: AwaitHumanOptions) => Promise<HumanDecision>;
|
|
1577
|
+
};
|
|
1578
|
+
/**
|
|
1579
|
+
* Shape of events forwarded to an eval `onProgress` callback. Mirrors
|
|
1580
|
+
* `@axlsdk/eval`'s `EvalProgressEvent` so runtime consumers can type their
|
|
1581
|
+
* callbacks without importing the optional peer dep.
|
|
1582
|
+
*/
|
|
1583
|
+
type EvalProgressEventShape = {
|
|
1584
|
+
type: 'item_done';
|
|
1585
|
+
itemIndex: number;
|
|
1586
|
+
totalItems: number;
|
|
1587
|
+
} | {
|
|
1588
|
+
type: 'run_done';
|
|
1589
|
+
totalItems: number;
|
|
1590
|
+
failures: number;
|
|
1276
1591
|
};
|
|
1277
1592
|
type CreateContextOptions = {
|
|
1278
1593
|
metadata?: Record<string, unknown>;
|
|
@@ -1312,6 +1627,20 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1312
1627
|
private evalHistory;
|
|
1313
1628
|
private evalHistoryLoadPromise;
|
|
1314
1629
|
constructor(config?: AxlConfig);
|
|
1630
|
+
/**
|
|
1631
|
+
* Whether `config.trace.redact` is enabled on this runtime. A narrow
|
|
1632
|
+
* boolean getter is preferred over exposing the full config because:
|
|
1633
|
+
* (a) `Readonly<AxlConfig>` is shallow so the config would be mutable
|
|
1634
|
+
* at runtime through sub-objects, subverting any compliance guarantee;
|
|
1635
|
+
* (b) observability consumers like Studio only need the boolean, not
|
|
1636
|
+
* the whole config tree; (c) if future observability config needs to
|
|
1637
|
+
* expand, each new flag gets its own narrow getter.
|
|
1638
|
+
*
|
|
1639
|
+
* Studio's server-side redaction helpers (executions, memory, sessions,
|
|
1640
|
+
* evals, decisions, tools, playground, workflows) all route through
|
|
1641
|
+
* this accessor to decide whether to scrub response payloads.
|
|
1642
|
+
*/
|
|
1643
|
+
isRedactEnabled(): boolean;
|
|
1315
1644
|
/**
|
|
1316
1645
|
* Initialize MCP servers configured in the config.
|
|
1317
1646
|
* Call this before executing workflows that use MCP tools.
|
|
@@ -1379,6 +1708,18 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1379
1708
|
/** Run a registered eval by name. */
|
|
1380
1709
|
runRegisteredEval(name: string, options?: {
|
|
1381
1710
|
metadata?: Record<string, unknown>;
|
|
1711
|
+
/** Called after each dataset item completes (execution + scoring). */
|
|
1712
|
+
onProgress?: (event: EvalProgressEventShape) => void;
|
|
1713
|
+
/** Abort signal — checked before starting each item. */
|
|
1714
|
+
signal?: AbortSignal;
|
|
1715
|
+
/**
|
|
1716
|
+
* When `true`, populate `EvalItem.traces` on every item (success + failure
|
|
1717
|
+
* paths). Forwards to `runEval({ captureTraces: true })`, which wraps each
|
|
1718
|
+
* item's execution in `runtime.trackExecution({ captureTraces: true })`.
|
|
1719
|
+
* Verbose-mode `agent_call.data.messages` snapshots are stripped from
|
|
1720
|
+
* captured traces to keep memory bounded.
|
|
1721
|
+
*/
|
|
1722
|
+
captureTraces?: boolean;
|
|
1382
1723
|
}): Promise<unknown>;
|
|
1383
1724
|
/** Get all execution info (running + completed + historical). */
|
|
1384
1725
|
getExecutions(): Promise<ExecutionInfo[]>;
|
|
@@ -1409,6 +1750,14 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1409
1750
|
getExecution(executionId: string): Promise<ExecutionInfo | undefined>;
|
|
1410
1751
|
/** Save an eval result to history. */
|
|
1411
1752
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
1753
|
+
/**
|
|
1754
|
+
* Delete an eval history entry by id. Removes from in-memory cache and
|
|
1755
|
+
* the configured StateStore. Returns true if an entry was actually removed.
|
|
1756
|
+
*
|
|
1757
|
+
* Ensures lazy-loaded history is loaded first so the in-memory cache and
|
|
1758
|
+
* the store can't drift apart on the deletion path.
|
|
1759
|
+
*/
|
|
1760
|
+
deleteEvalResult(id: string): Promise<boolean>;
|
|
1412
1761
|
/** Get eval result history (most recent first). */
|
|
1413
1762
|
getEvalHistory(): Promise<EvalHistoryEntry[]>;
|
|
1414
1763
|
/** List pending human decisions. */
|
|
@@ -1447,6 +1796,10 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1447
1796
|
concurrency?: number;
|
|
1448
1797
|
budget?: string;
|
|
1449
1798
|
metadata?: Record<string, unknown>;
|
|
1799
|
+
}, options?: {
|
|
1800
|
+
onProgress?: (event: EvalProgressEventShape) => void;
|
|
1801
|
+
signal?: AbortSignal;
|
|
1802
|
+
captureTraces?: boolean;
|
|
1450
1803
|
}): Promise<unknown>;
|
|
1451
1804
|
/**
|
|
1452
1805
|
* Compare two evaluation results to detect regressions and improvements.
|
|
@@ -1474,20 +1827,58 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1474
1827
|
* Returns cost (same as `trackCost`) plus metadata extracted from trace events:
|
|
1475
1828
|
* models (unique URIs), tokens (input/output/reasoning sums), and agent call count.
|
|
1476
1829
|
*
|
|
1830
|
+
* ## Cost vs tokens semantics
|
|
1831
|
+
*
|
|
1832
|
+
* - `cost` is the full aggregate across EVERY event with a top-level
|
|
1833
|
+
* `event.cost` set: agent calls, tool calls, semantic memory ops, etc.
|
|
1834
|
+
* This is the number to reconcile against your provider bill.
|
|
1835
|
+
*
|
|
1836
|
+
* - `metadata.tokens` is narrowly scoped to **agent** prompt/completion/
|
|
1837
|
+
* reasoning tokens. Embedder tokens from semantic `ctx.remember({embed:true})`
|
|
1838
|
+
* / `ctx.recall({query})` are deliberately NOT summed here — they're a
|
|
1839
|
+
* different category (input-only, different pricing, different model).
|
|
1840
|
+
* Conflating them would make "prompt tokens" misleading in the UI. If you
|
|
1841
|
+
* need embedder token counts, subscribe to `runtime.on('trace', ...)` and
|
|
1842
|
+
* read `data.usage.tokens` on `memory_remember` / `memory_recall` events.
|
|
1843
|
+
*
|
|
1844
|
+
* Pass `{ captureTraces: true }` to also collect the raw `TraceEvent[]` observed
|
|
1845
|
+
* during `fn()`. This is opt-in because it keeps every event in memory for the
|
|
1846
|
+
* duration of the call — useful for eval per-item capture, debugging, and test
|
|
1847
|
+
* assertions, but overhead grows with trace volume. When enabled, verbose-mode
|
|
1848
|
+
* `agent_call.data.messages` snapshots are omitted from captured events (still
|
|
1849
|
+
* broadcast via onTrace) to keep memory bounded — callers who need the full
|
|
1850
|
+
* verbose snapshot should subscribe to `runtime.on('trace', ...)` directly.
|
|
1851
|
+
*
|
|
1477
1852
|
* Works with both `createContext()` and `execute()` calls inside `fn`.
|
|
1478
1853
|
*/
|
|
1479
|
-
trackExecution<T>(fn: () => Promise<T
|
|
1854
|
+
trackExecution<T>(fn: () => Promise<T>, options?: {
|
|
1855
|
+
captureTraces?: boolean;
|
|
1856
|
+
}): Promise<{
|
|
1480
1857
|
result: T;
|
|
1481
1858
|
cost: number;
|
|
1859
|
+
traces?: TraceEvent[];
|
|
1482
1860
|
metadata: {
|
|
1483
1861
|
models: string[];
|
|
1484
1862
|
modelCallCounts?: Record<string, number>;
|
|
1863
|
+
/**
|
|
1864
|
+
* Agent token totals only — does not include embedder tokens from
|
|
1865
|
+
* semantic memory operations. See the method-level JSDoc above.
|
|
1866
|
+
*/
|
|
1485
1867
|
tokens: {
|
|
1486
1868
|
input: number;
|
|
1487
1869
|
output: number;
|
|
1488
1870
|
reasoning: number;
|
|
1489
1871
|
};
|
|
1490
1872
|
agentCalls: number;
|
|
1873
|
+
/**
|
|
1874
|
+
* Unique workflow names observed during execution, ordered by first
|
|
1875
|
+
* appearance (outermost first for nested calls). Captured automatically
|
|
1876
|
+
* from `workflow_start` trace events — callers don't need to declare
|
|
1877
|
+
* anything. Parallel mechanism to `models`.
|
|
1878
|
+
*/
|
|
1879
|
+
workflows: string[];
|
|
1880
|
+
/** Call counts per workflow, if workflows.length > 0. */
|
|
1881
|
+
workflowCallCounts?: Record<string, number>;
|
|
1491
1882
|
};
|
|
1492
1883
|
}>;
|
|
1493
1884
|
/** Register an execution ID with the active cost scope for trackCost() attribution. */
|
|
@@ -1798,6 +2189,7 @@ declare class MemoryStore implements StateStore {
|
|
|
1798
2189
|
listExecutions(limit?: number): Promise<ExecutionInfo[]>;
|
|
1799
2190
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
1800
2191
|
listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
2192
|
+
deleteEvalResult(id: string): Promise<boolean>;
|
|
1801
2193
|
listSessions(): Promise<string[]>;
|
|
1802
2194
|
close(): Promise<void>;
|
|
1803
2195
|
deleteCheckpoints(executionId: string): Promise<void>;
|
|
@@ -1840,6 +2232,7 @@ declare class SQLiteStore implements StateStore {
|
|
|
1840
2232
|
listExecutions(limit?: number): Promise<ExecutionInfo[]>;
|
|
1841
2233
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
1842
2234
|
listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
2235
|
+
deleteEvalResult(id: string): Promise<boolean>;
|
|
1843
2236
|
listSessions(): Promise<string[]>;
|
|
1844
2237
|
saveMemory(scope: string, key: string, value: unknown): Promise<void>;
|
|
1845
2238
|
getMemory(scope: string, key: string): Promise<unknown | null>;
|
|
@@ -1903,6 +2296,7 @@ declare class RedisStore implements StateStore {
|
|
|
1903
2296
|
listExecutions(limit?: number): Promise<ExecutionInfo[]>;
|
|
1904
2297
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
1905
2298
|
listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
2299
|
+
deleteEvalResult(id: string): Promise<boolean>;
|
|
1906
2300
|
listSessions(): Promise<string[]>;
|
|
1907
2301
|
/** Close the Redis connection. */
|
|
1908
2302
|
close(): Promise<void>;
|
|
@@ -1924,7 +2318,7 @@ declare class OpenAIEmbedder implements Embedder {
|
|
|
1924
2318
|
baseUrl?: string;
|
|
1925
2319
|
dimensions?: number;
|
|
1926
2320
|
});
|
|
1927
|
-
embed(texts: string[]): Promise<
|
|
2321
|
+
embed(texts: string[], signal?: AbortSignal): Promise<EmbedResult>;
|
|
1928
2322
|
}
|
|
1929
2323
|
|
|
1930
2324
|
/**
|
|
@@ -1975,4 +2369,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
1975
2369
|
*/
|
|
1976
2370
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
1977
2371
|
|
|
1978
|
-
export { type Agent, type AgentCallInfo, type AgentConfig, AnthropicProvider, type AskOptions, type AwaitHumanOptions, type AxlConfig, AxlError, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, type ChatMessage, type ChatOptions, type CreateContextOptions, type DelegateOptions, type Effort, type Embedder, type EvalHistoryEntry, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, type RaceOptions, type RecallOptions, RedisStore, type RememberOptions, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StreamEvent, type TelemetryConfig, TimeoutError, type Tool, type ToolCallMessage, type ToolChoice, type ToolConfig, ToolDenied, type ToolHooks, type TraceEvent, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, agent, createSpanManager, defineConfig, extractJson, resolveThinkingOptions, tool, workflow, zodToJsonSchema };
|
|
2372
|
+
export { type Agent, type AgentCallInfo, type AgentCallTraceData, type AgentConfig, AnthropicProvider, type AskOptions, type AwaitHumanOptions, type AxlConfig, AxlError, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, type ChatMessage, type ChatOptions, type CreateContextOptions, type DelegateOptions, type DelegateTraceData, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalHistoryEntry, type ExecuteOptions, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, GuardrailError, type GuardrailResult, type GuardrailTraceData, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffTraceData, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, type RaceOptions, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SQLiteStore, type SchemaCheckTraceData, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StreamEvent, type TelemetryConfig, TimeoutError, type Tool, type ToolApprovalTraceData, type ToolCallMessage, type ToolCallTraceData, type ToolChoice, type ToolConfig, ToolDenied, type ToolHooks, type TraceEvent, type TraceEventType, type ValidateResult, type ValidateTraceData, ValidationError, type VectorEntry, type VectorResult, type VectorStore, VerifyError, type VerifyOptions, type VerifyRetry, type VerifyTraceData, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndTraceData, type WorkflowStartTraceData, agent, createSpanManager, defineConfig, extractJson, resolveThinkingOptions, tool, workflow, zodToJsonSchema };
|