@statelyai/agent 2.0.0-alpha.20 → 2.0.0-alpha.22
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/ai-sdk.cjs +89 -25
- package/dist/ai-sdk.d.cts +56 -12
- package/dist/ai-sdk.d.mts +56 -12
- package/dist/ai-sdk.mjs +89 -26
- package/dist/{decision-DhsKLYAI.cjs → decision-1o45_ZrS.cjs} +120 -9
- package/dist/{decision-BfhSgCc6.mjs → decision-DxSTqzgZ.mjs} +103 -10
- package/dist/index.cjs +203 -41
- package/dist/index.d.cts +141 -20
- package/dist/index.d.mts +141 -20
- package/dist/index.mjs +202 -42
- package/dist/machines.cjs +1 -1
- package/dist/machines.d.cts +151 -54
- package/dist/machines.d.mts +151 -54
- package/dist/machines.mjs +1 -1
- package/dist/otel.d.cts +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/{run-agent-CwmzAZwj.d.mts → run-agent-0fpEZ1wJ.d.mts} +3 -3
- package/dist/{run-agent--4bbms-D.d.cts → run-agent-Zbkx7XP8.d.cts} +3 -3
- package/dist/{setup-agent-gISRLxRe.cjs → setup-agent-DkCTy5Eu.cjs} +76 -23
- package/dist/{setup-agent-BOcSpsIq.mjs → setup-agent-nSFYrNTP.mjs} +77 -18
- package/dist/sqlite.d.cts +1 -1
- package/dist/sqlite.d.mts +1 -1
- package/dist/{text-logic-Cavva1W6.d.cts → text-logic-BaxPrcLk.d.cts} +52 -6
- package/dist/{text-logic-Er5KkTX6.d.mts → text-logic-DhfFWzu9.d.mts} +52 -6
- package/dist/{types-DYpK3QF4.d.mts → types-CvWRGFxP.d.mts} +6 -1
- package/dist/{types-pJ5Hn8fv.d.cts → types-DSdj2tGs.d.cts} +6 -1
- package/dist/validate.cjs +2 -2
- package/dist/validate.mjs +1 -1
- package/package.json +28 -28
- package/readme.md +4 -4
- package/schemas/agent-workflow.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ToolResultPart, S as ToolMessage, T as WithAgentInputSchema, _ as NormalizedEventSchemas, a as AgentToolChoice, b as TextPart, c as AgentTools, d as ChosenEvent, f as EventUnion, g as InferOutput, h as InferInput, i as AgentTool, l as AllowedEvents, m as ImagePart, n as AgentMessage, o as AgentToolDescriptor, p as FilePart, r as AgentSnapshotStore, s as AgentToolExecute, t as AgentEventSchemaInputMap, u as AssistantMessage, v as StandardSchemaV1, w as UserMessage, x as ToolCallPart, y as SystemMessage } from "./types-
|
|
1
|
+
import { C as ToolResultPart, S as ToolMessage, T as WithAgentInputSchema, _ as NormalizedEventSchemas, a as AgentToolChoice, b as TextPart, c as AgentTools, d as ChosenEvent, f as EventUnion, g as InferOutput, h as InferInput, i as AgentTool, l as AllowedEvents, m as ImagePart, n as AgentMessage, o as AgentToolDescriptor, p as FilePart, r as AgentSnapshotStore, s as AgentToolExecute, t as AgentEventSchemaInputMap, u as AssistantMessage, v as StandardSchemaV1, w as UserMessage, x as ToolCallPart, y as SystemMessage } from "./types-DSdj2tGs.cjs";
|
|
2
2
|
import { t as AgentError } from "./errors-BQRk9eiZ.cjs";
|
|
3
|
-
import { A as AgentDecisionExecutor, B as
|
|
3
|
+
import { A as AgentDecisionExecutor, B as resolveDecision, C as buildEnvelopeSchema, D as parseModelRef, E as getCallUsage, F as DecisionLogic, G as AgentSchemas, H as AgentEventToolNameResolver, I as DecisionLogicConfig, K as getAcceptedEvents, L as ResolveDecisionOptions, M as AgentDecisionInput, N as AgentDecisionRequest, O as parseOutput, P as DecisionAttempt, R as createDecisionLogic, S as bindRequestExecutor, T as getAgentOutputMode, U as AgentRequestOptions, V as AgentEventDescriptor, W as AgentRequestSource, _ as StructuredOutputEnvelope, a as AgentOutputMode, b as TextLogicExecuteArgs, c as AgentRequestExecutorResult, d as AgentTextRequest, f as AgentUsage, g as BuiltinAgentActors, h as AiSdkShapedTextResult, i as AgentModelRef, j as AgentDecisionExhaustedError, k as parseStructuredEnvelope, l as AgentRequestExecutors, m as AiSdkShapedStreamResult, n as AgentExecutorTextRequest, o as AgentRequestExecutor, p as AgentUserInput, q as parseAgentEvent, r as AgentModelMap, s as AgentRequestExecutorInfo, t as AgentCallUsage, u as AgentRequestMode, v as TextLogic, w as createTextLogic, x as TextLogicExecutor, y as TextLogicConfig, z as renderDecisionAttempts } from "./text-logic-BaxPrcLk.cjs";
|
|
4
4
|
import { a as AgentLogVerification, c as assertAgentLogEntry, d as assertEventLogStoreConformance, i as AgentLogEntry, l as assertJsonSerializable, n as AgentEventLogConflictError, o as JsonValue, r as AgentEventLogStore, s as NonSerializableAgentEventError, t as AGENT_EVENT_SCHEMA_VERSION, u as createInMemoryEventLogStore } from "./event-log-store-Bz7HDBkE.cjs";
|
|
5
|
-
import { A as AgentRequest, B as AgentReplayMachineMismatchError, C as getSnapshotNodes, D as serializeTraceEvent, E as runAgent, F as AgentEffect, G as ReplayResult, H as CreateReplayEntryOptions, I as AgentEffectDiff, J as getAgentEffects, K as createReplayEntry, L as AgentEventLogDiff, M as executeAgentRequest, N as AGENT_INIT_EVENT_TYPE, O as traceTransitions, P as AGENT_USAGE_EVENT_TYPE, R as AgentLogPatchOperation, S as generateResult, T as inspectTransitions, U as GetAgentEffectsOptions, V as AgentUsageEvent, W as ReplayOptions, X as replay, Y as initEntry, _ as PendingUserInput, a as AgentInputFrom, b as RunAgentResult, c as AgentRunMeta, d as AgentTraceEvent, f as AgentUserInputExecutor, g as JsonSerializableTraceEvent, h as InspectedActorRef, i as AgentIllegalResumeEventError, j as AgentStepRequest, k as AgentStateRequest, l as AgentSnapshotNode, m as GetSnapshotRequestsOptions, n as AgentActorSession, o as AgentMaxModelCallsExceededError, p as GenerateResult, q as diffEventLogs, r as AgentIdleError, s as AgentMessageInfo, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentSnapshotVersionMismatchError, v as RunAgentErrorCause, w as getSnapshotRequests, x as createAgentActor, y as RunAgentOptions, z as AgentReplayDivergenceError } from "./run-agent
|
|
5
|
+
import { A as AgentRequest, B as AgentReplayMachineMismatchError, C as getSnapshotNodes, D as serializeTraceEvent, E as runAgent, F as AgentEffect, G as ReplayResult, H as CreateReplayEntryOptions, I as AgentEffectDiff, J as getAgentEffects, K as createReplayEntry, L as AgentEventLogDiff, M as executeAgentRequest, N as AGENT_INIT_EVENT_TYPE, O as traceTransitions, P as AGENT_USAGE_EVENT_TYPE, R as AgentLogPatchOperation, S as generateResult, T as inspectTransitions, U as GetAgentEffectsOptions, V as AgentUsageEvent, W as ReplayOptions, X as replay, Y as initEntry, _ as PendingUserInput, a as AgentInputFrom, b as RunAgentResult, c as AgentRunMeta, d as AgentTraceEvent, f as AgentUserInputExecutor, g as JsonSerializableTraceEvent, h as InspectedActorRef, i as AgentIllegalResumeEventError, j as AgentStepRequest, k as AgentStateRequest, l as AgentSnapshotNode, m as GetSnapshotRequestsOptions, n as AgentActorSession, o as AgentMaxModelCallsExceededError, p as GenerateResult, q as diffEventLogs, r as AgentIdleError, s as AgentMessageInfo, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentSnapshotVersionMismatchError, v as RunAgentErrorCause, w as getSnapshotRequests, x as createAgentActor, y as RunAgentOptions, z as AgentReplayDivergenceError } from "./run-agent-Zbkx7XP8.cjs";
|
|
6
6
|
import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventFromLogic, EventObject, InputFrom, MachineContext, MetaObject, NonReducibleUnknown, OutputFrom, SetupReturnFromConfig, SetupStateSchema, SnapshotFrom, StateValue } from "xstate";
|
|
7
7
|
|
|
8
8
|
//#region src/messages.d.ts
|
|
@@ -40,8 +40,9 @@ declare function appendMessages<TContext extends {
|
|
|
40
40
|
* A {@link StandardSchemaV1} validating an `AgentMessage[]` context field —
|
|
41
41
|
* checks that every message has a known `role` (`system`/`user`/`assistant`/
|
|
42
42
|
* `tool`) and that `content` is either a string (where the role allows it) or
|
|
43
|
-
* an array of parts
|
|
44
|
-
*
|
|
43
|
+
* an array of role-appropriate parts whose required fields and media payloads
|
|
44
|
+
* have the right runtime types (extra fields are allowed). Use it directly as
|
|
45
|
+
* a context schema's `messages` field when authoring with `createAgentSchemas`.
|
|
45
46
|
*/
|
|
46
47
|
declare const messagesSchema: StandardSchemaV1<AgentMessage[]>;
|
|
47
48
|
//#endregion
|
|
@@ -121,8 +122,8 @@ interface AgentWorkflowRequestConfig {
|
|
|
121
122
|
output: JsonSchemaObject;
|
|
122
123
|
tools?: AgentTools;
|
|
123
124
|
toolChoice?: AgentToolChoice | unknown;
|
|
124
|
-
/** Opt into the structured-output envelope's `reasoning` field (see `AgentTextRequest.
|
|
125
|
-
|
|
125
|
+
/** Opt into the structured-output envelope's `reasoning` field (see `AgentTextRequest.includeReasoning`). */
|
|
126
|
+
includeReasoning?: boolean;
|
|
126
127
|
temperature?: unknown;
|
|
127
128
|
maxOutputTokens?: unknown;
|
|
128
129
|
topP?: unknown;
|
|
@@ -255,6 +256,22 @@ interface FromConfigOptions {
|
|
|
255
256
|
type Constrain<T, TConstraint> = T extends TConstraint ? T : TConstraint;
|
|
256
257
|
type ContextOf<TContextSchema extends StandardSchemaV1> = Constrain<InferOutput<TContextSchema>, MachineContext>;
|
|
257
258
|
type EventsOf<TEventSchemas extends AgentEventSchemaInputMap> = Constrain<EventUnion<TEventSchemas>, EventObject>;
|
|
259
|
+
/**
|
|
260
|
+
* The first argument a guard or delay source receives. `context` and `event`
|
|
261
|
+
* come from the agent's own schemas, so an inline source is contextually typed
|
|
262
|
+
* and an annotated one stays assignable. XState's remaining fields (`self`,
|
|
263
|
+
* `parent`, `value`, `children`, `stateNode`) are deliberately not modeled:
|
|
264
|
+
* `setupAgent` only forwards these sources to `setup()`, which types them for
|
|
265
|
+
* real where the machine is built.
|
|
266
|
+
*/
|
|
267
|
+
type AgentSourceArgs<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap> = {
|
|
268
|
+
context: ContextOf<TContextSchema>;
|
|
269
|
+
event: EventsOf<TEventSchemas>;
|
|
270
|
+
};
|
|
271
|
+
/** Guard sources for `setupAgent({ guards })`, typed against the agent's own context and events. */
|
|
272
|
+
type AgentGuardSources<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap> = Record<string, (args: AgentSourceArgs<TContextSchema, TEventSchemas>, ...params: any[]) => boolean>;
|
|
273
|
+
/** Delay sources for `setupAgent({ delays })`, typed the same way as {@link AgentGuardSources}. */
|
|
274
|
+
type AgentDelaySources<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap> = Record<string, number | ((args: AgentSourceArgs<TContextSchema, TEventSchemas>) => number)>;
|
|
258
275
|
type SetupActors<TActors extends { [K in keyof TActors]: AnyActorLogic }> = { [K in keyof TActors]: TActors[K] extends AsyncActorLogic<infer TOutput, infer TInput> ? AsyncActorLogic<TOutput, TInput> : TActors[K] };
|
|
259
276
|
type AgentSetupActors<TActors extends { [K in keyof TActors]: AnyActorLogic }, TEvent extends string = string, TModel extends string = string> = TActors & BuiltinAgentActors<TEvent, TModel>;
|
|
260
277
|
/**
|
|
@@ -407,8 +424,8 @@ type SetupAgentBaseConfig<TContextSchema extends StandardSchemaV1<Record<string,
|
|
|
407
424
|
states?: TStateSchemas;
|
|
408
425
|
requests?: AgentRequestInput<TRequestSchemas, AgentModelRef<TModels>>;
|
|
409
426
|
actions?: NonNullable<AnySetupConfig["actions"]>;
|
|
410
|
-
guards?:
|
|
411
|
-
delays?:
|
|
427
|
+
guards?: AgentGuardSources<TContextSchema, TEventSchemas>;
|
|
428
|
+
delays?: AgentDelaySources<TContextSchema, TEventSchemas>;
|
|
412
429
|
/**
|
|
413
430
|
* Detects a snapshot that is an INTENTIONAL wait for an external event (a
|
|
414
431
|
* human approval, an inbound webhook, …) — the machine's own declaration of
|
|
@@ -724,8 +741,8 @@ interface LintAgentMachineOptions {
|
|
|
724
741
|
*/
|
|
725
742
|
declare function lintAgentMachine(machine: AnyStateMachine, options?: LintAgentMachineOptions): AgentLintDiagnostic[];
|
|
726
743
|
/**
|
|
727
|
-
* Thrown by `lintAgentMachine(machine, { throw: true })`
|
|
728
|
-
* failing diagnostics.
|
|
744
|
+
* Thrown by `lintAgentMachine(machine, { throw: true })` (and its
|
|
745
|
+
* {@link assertAgentMachine} alias) when lint finds failing diagnostics.
|
|
729
746
|
* `diagnostics` holds the findings; the message lists them one per finding,
|
|
730
747
|
* so a test runner's failure output reads like the CLI's lint report.
|
|
731
748
|
*/
|
|
@@ -733,6 +750,26 @@ declare class AgentLintError extends AgentError {
|
|
|
733
750
|
readonly diagnostics: AgentLintDiagnostic[];
|
|
734
751
|
constructor(machineId: string, diagnostics: AgentLintDiagnostic[]);
|
|
735
752
|
}
|
|
753
|
+
/** Options for {@link assertAgentMachine}. */
|
|
754
|
+
interface AssertAgentMachineOptions extends LintAgentMachineOptions {
|
|
755
|
+
/** Also fail on warning-severity findings. Default: errors only. */
|
|
756
|
+
warnings?: boolean;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Asserts a machine passes {@link lintAgentMachine}: returns silently when
|
|
760
|
+
* clean, throws {@link AgentLintError} (with the findings on `.diagnostics`)
|
|
761
|
+
* otherwise — sugar for `lintAgentMachine(machine, { ...options, throw: true })`.
|
|
762
|
+
* Fails on error-severity findings; set `warnings: true` to fail on warnings
|
|
763
|
+
* too. The one-liner for tests and generation loops:
|
|
764
|
+
*
|
|
765
|
+
* @example
|
|
766
|
+
* ```ts
|
|
767
|
+
* test('agent machine is structurally sound', () => {
|
|
768
|
+
* assertAgentMachine(machine);
|
|
769
|
+
* });
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
declare function assertAgentMachine(machine: AnyStateMachine, options?: AssertAgentMachineOptions): void;
|
|
736
773
|
/**
|
|
737
774
|
* Scripted responses for a {@link simulateAgent} playthrough. Each channel is a
|
|
738
775
|
* by-`src` map of FIFO queues, consumed in the order the machine reaches the
|
|
@@ -740,25 +777,49 @@ declare class AgentLintError extends AgentError {
|
|
|
740
777
|
* - `text` — output values for text requests, keyed by request src (the
|
|
741
778
|
* `setupAgent({ requests })` key, or `agent.generateText`/`agent.streamText`).
|
|
742
779
|
* - `decisions` — the {@link ChosenEvent} to apply for a decision request,
|
|
743
|
-
* keyed by decision src (usually `agent.decide`).
|
|
780
|
+
* keyed by decision src (usually `agent.decide`). An invoke whose src is an
|
|
781
|
+
* inline logic object has only an auto-generated src, so its queue may be
|
|
782
|
+
* keyed by the invoke's `id` instead.
|
|
744
783
|
* - `invokes` — output values for scripted invokes (any actor whose output must
|
|
745
784
|
* be canned), keyed by src.
|
|
746
785
|
* - `userInput` — a flat FIFO queue of answers for `agent.userInput`, the
|
|
747
786
|
* shorthand for `invokes: { 'agent.userInput': [...] }`. Entries here are
|
|
748
787
|
* consumed before that src's `invokes` queue.
|
|
788
|
+
* - `events` — a flat FIFO queue of external (human/host-sent) events. When the
|
|
789
|
+
* machine settles idle with no pending request or invoke — a human gate — the
|
|
790
|
+
* next queued event is applied, so a simulation can cross states that a live
|
|
791
|
+
* run crosses via `actor.send(...)`. An event the current state cannot take
|
|
792
|
+
* (no handler, or guard-rejected) throws rather than silently vanishing.
|
|
749
793
|
*/
|
|
750
794
|
interface SimulationScript {
|
|
751
795
|
text?: Record<string, unknown[]>;
|
|
752
796
|
decisions?: Record<string, ChosenEvent[]>;
|
|
753
797
|
invokes?: Record<string, unknown[]>;
|
|
754
798
|
userInput?: unknown[];
|
|
799
|
+
events?: ChosenEvent[];
|
|
755
800
|
}
|
|
756
|
-
/**
|
|
801
|
+
/**
|
|
802
|
+
* One entry in a {@link SimulateAgentResult.trail}: the state after this step,
|
|
803
|
+
* plus what drove the step. The first entry is always the machine's initial
|
|
804
|
+
* state, with no `appliedEvent`/`resolvedRequest` — so `trail.map((e) =>
|
|
805
|
+
* e.state)` is the complete state path, directly comparable with
|
|
806
|
+
* `matchesTrajectory` without prepending the initial state by hand.
|
|
807
|
+
*/
|
|
757
808
|
interface SimulationTrailEntry {
|
|
758
809
|
/** The machine state value after applying this step. */
|
|
759
810
|
state: unknown;
|
|
760
|
-
/** The chosen event applied (for a decision request). */
|
|
811
|
+
/** The chosen event applied (for a decision request), or the external event applied (when `external`). */
|
|
761
812
|
appliedEvent?: ChosenEvent;
|
|
813
|
+
/** True when `appliedEvent` came from the script's `events` queue (an external/user event), not a decision. */
|
|
814
|
+
external?: boolean;
|
|
815
|
+
/**
|
|
816
|
+
* Scripted decisions that failed validation (unknown event, invalid payload,
|
|
817
|
+
* or guard-rejected — live-run retry parity, see {@link simulateAgent})
|
|
818
|
+
* before this step settled. Present with an `appliedEvent` when a later
|
|
819
|
+
* scripted attempt succeeded, or alone when every attempt failed and the
|
|
820
|
+
* exhaustion error was routed through the decision invoke's `onError`.
|
|
821
|
+
*/
|
|
822
|
+
rejectedEvents?: ChosenEvent[];
|
|
762
823
|
/** The resolved request (for a text/userInput invoke): its kind and src. */
|
|
763
824
|
resolvedRequest?: {
|
|
764
825
|
kind: "text" | "userInput";
|
|
@@ -787,6 +848,21 @@ interface SimulateAgentResult {
|
|
|
787
848
|
* the real transition logic. Returns the terminal `status`, final `snapshot`,
|
|
788
849
|
* and a `trail` of every step taken.
|
|
789
850
|
*
|
|
851
|
+
* Decisions run through the live run's own validation/retry core,
|
|
852
|
+
* {@link resolveDecision}, with the script standing in for the model: each
|
|
853
|
+
* attempt consumes the next queued {@link ChosenEvent} for that src, so an
|
|
854
|
+
* unknown, payload-invalid, or guard-rejected event is NOT silently swallowed
|
|
855
|
+
* — the next queued decision is tried, exactly as a live run re-asks the
|
|
856
|
+
* model. The decision logic's `maxRetries` caps attempts as it would live;
|
|
857
|
+
* when retries continue past the end of the queue, the last queued decision
|
|
858
|
+
* repeats (a scripted model that insists). The repeat applies only within one
|
|
859
|
+
* decision request's retries — each new decision request must have its own
|
|
860
|
+
* queued entry, or the dry-script error throws as usual. Exhausting all
|
|
861
|
+
* attempts delivers
|
|
862
|
+
* the resulting {@link AgentDecisionExhaustedError} to the machine as the
|
|
863
|
+
* decision invoke's error (so an `onError` transition observes it, as it
|
|
864
|
+
* would live); with no `onError` to catch it, it is thrown.
|
|
865
|
+
*
|
|
790
866
|
* Throws a descriptive error when the script runs dry mid-request, naming the
|
|
791
867
|
* pending request's kind, src, and id so the missing scripted response is
|
|
792
868
|
* obvious.
|
|
@@ -795,7 +871,10 @@ interface SimulateAgentResult {
|
|
|
795
871
|
* ```ts
|
|
796
872
|
* const { status, snapshot } = simulateAgent(machine, {
|
|
797
873
|
* input: { topic: 'state machines' },
|
|
798
|
-
* script: {
|
|
874
|
+
* script: {
|
|
875
|
+
* decisions: { 'agent.decide': [{ type: 'ESCALATE' }] },
|
|
876
|
+
* events: [{ type: 'APPROVE' }], // crosses the human gate
|
|
877
|
+
* },
|
|
799
878
|
* });
|
|
800
879
|
* ```
|
|
801
880
|
*/
|
|
@@ -872,8 +951,11 @@ interface CanReachResult {
|
|
|
872
951
|
witness?: ChosenEvent[];
|
|
873
952
|
}
|
|
874
953
|
/**
|
|
875
|
-
* Answers "can the machine reach
|
|
876
|
-
*
|
|
954
|
+
* Answers "can the machine reach this?" by exploring its branches (a thin
|
|
955
|
+
* wrapper over {@link explorePaths}). The target is either a state path string
|
|
956
|
+
* (`snapshot.matches(...)` semantics) or a snapshot predicate — the predicate
|
|
957
|
+
* form checks any property (a context invariant, a tag, a state+context
|
|
958
|
+
* combination) without reifying a sentinel state for it. Returns
|
|
877
959
|
* `{ reachable: true, witness }` with the event sequence that reaches it, or
|
|
878
960
|
* `{ reachable: false }`.
|
|
879
961
|
*
|
|
@@ -882,8 +964,18 @@ interface CanReachResult {
|
|
|
882
964
|
* const { reachable, witness } = await canReach(refundMachine, 'denied', { input: { request: 'x', amount: 5000 } });
|
|
883
965
|
* // reachable → true; witness → [{ type: 'NEEDS_REVIEW' }, { type: 'DENY' }]
|
|
884
966
|
* ```
|
|
967
|
+
*
|
|
968
|
+
* @example Predicate target — a violation property, no sentinel state needed
|
|
969
|
+
* ```ts
|
|
970
|
+
* const violation = await canReach(
|
|
971
|
+
* refundMachine,
|
|
972
|
+
* (snapshot) => snapshot.matches('issued') && !snapshot.context.approved,
|
|
973
|
+
* { input: { amount: 5000 } },
|
|
974
|
+
* );
|
|
975
|
+
* // violation.reachable → false is the safety proof
|
|
976
|
+
* ```
|
|
885
977
|
*/
|
|
886
|
-
declare function canReach(machine: AnyStateMachine,
|
|
978
|
+
declare function canReach(machine: AnyStateMachine, target: string | ((snapshot: AnyMachineSnapshot) => boolean), options?: ExplorePathsOptions): Promise<CanReachResult>;
|
|
887
979
|
//#endregion
|
|
888
980
|
//#region src/trajectory.d.ts
|
|
889
981
|
/** An event-shaped trajectory item: anything with a string `type`. */
|
|
@@ -1204,6 +1296,26 @@ interface SeamTurn<TMachine extends AnyStateMachine> {
|
|
|
1204
1296
|
/** The `idle` result that produced the pause. */
|
|
1205
1297
|
result: RunAgentResult<TMachine>;
|
|
1206
1298
|
}
|
|
1299
|
+
/**
|
|
1300
|
+
* One text call in a {@link runSeam} run's ledger, in call order — the receipt
|
|
1301
|
+
* that says which answers came from the script and which one came from the
|
|
1302
|
+
* candidate, so "everything else stayed scripted" is a plain assertion on
|
|
1303
|
+
* {@link RunSeamResult.calls} rather than a recording function wrapped around
|
|
1304
|
+
* every script entry. Text calls only: `decide` and other base executors are
|
|
1305
|
+
* not routed by the seam and do not appear.
|
|
1306
|
+
*/
|
|
1307
|
+
interface SeamCall {
|
|
1308
|
+
/** The request's `name`, when it has one. */
|
|
1309
|
+
name?: string;
|
|
1310
|
+
/** The request's model key. */
|
|
1311
|
+
model: string;
|
|
1312
|
+
/** The `scripts` queue key that routed this call. */
|
|
1313
|
+
key: string;
|
|
1314
|
+
/** Where the answer came from: the script, or the seam's `candidate`. */
|
|
1315
|
+
source: "script" | "candidate";
|
|
1316
|
+
/** True for the seam call itself — scripted or candidate. */
|
|
1317
|
+
seam: boolean;
|
|
1318
|
+
}
|
|
1207
1319
|
/** One side of the seam: a trajectory pair ready for `matchesTrajectory`. */
|
|
1208
1320
|
interface SeamSlice {
|
|
1209
1321
|
/** State values entered on this side of the seam, in order. */
|
|
@@ -1240,7 +1352,7 @@ interface RunSeamOptions<TMachine extends AnyStateMachine> {
|
|
|
1240
1352
|
* request-shaped. Omit to run the seam scripted too: the whole seam run is
|
|
1241
1353
|
* then keyless and deterministic.
|
|
1242
1354
|
*/
|
|
1243
|
-
candidate?:
|
|
1355
|
+
candidate?: AgentRequestExecutor;
|
|
1244
1356
|
/**
|
|
1245
1357
|
* The simulated user. Called at every idle pause; return the event to send,
|
|
1246
1358
|
* or `null`/`undefined` to stop the run there. Omitted, the run stops at the
|
|
@@ -1269,8 +1381,17 @@ interface RunSeamResult<TMachine extends AnyStateMachine> {
|
|
|
1269
1381
|
result: RunAgentResult<TMachine>;
|
|
1270
1382
|
/** What the seam call returned, or `undefined` when the run never reached it. */
|
|
1271
1383
|
seamOutput: unknown;
|
|
1384
|
+
/**
|
|
1385
|
+
* The seam call's own reported token usage — the cost of the one live call
|
|
1386
|
+
* when a `candidate` is a real model. `undefined` when the run never reached
|
|
1387
|
+
* the seam or its answer reported no usage (scripted entries report usage
|
|
1388
|
+
* only via the `{ output, usage }` envelope).
|
|
1389
|
+
*/
|
|
1390
|
+
seamUsage?: AgentCallUsage;
|
|
1272
1391
|
/** Model calls made before the seam, or `-1` when the run never reached it. */
|
|
1273
1392
|
callsBeforeSeam: number;
|
|
1393
|
+
/** The run's text calls in order: what was served, and by whom. */
|
|
1394
|
+
calls: SeamCall[];
|
|
1274
1395
|
/** Everything up to the seam's own effect completion. */
|
|
1275
1396
|
before: SeamSlice;
|
|
1276
1397
|
/**
|
|
@@ -1381,4 +1502,4 @@ type DurableAgentResult<TMachine extends AnyStateMachine> = {
|
|
|
1381
1502
|
*/
|
|
1382
1503
|
declare function runDurableAgent<TMachine extends AnyStateMachine>(machine: TMachine, options?: RunDurableAgentOptions<TMachine>): Promise<DurableAgentResult<TMachine>>;
|
|
1383
1504
|
//#endregion
|
|
1384
|
-
export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, type AgentActorSession, type AgentCallUsage, type AgentDecisionExecutor, AgentDecisionExhaustedError, type AgentDecisionInput, type AgentDecisionRequest, type AgentEffect, type AgentEffectDiff, AgentError, type AgentEventDescriptor, AgentEventLogConflictError, type AgentEventLogDiff, type AgentEventLogStore, type AgentEventToolNameResolver, type AgentExecutorTextRequest, AgentIdleError, AgentIllegalResumeEventError, type AgentInputFrom, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, AgentMaxModelCallsExceededError, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, type AgentSchemas, type AgentSnapshotNode, type AgentSnapshotStore, AgentSnapshotVersionMismatchError, type AgentStateRequest, type AgentStepRequest, type AgentTextRequest, type AgentTool, type AgentToolChoice, type AgentToolDescriptor, type AgentToolExecute, type AgentTools, type AgentTraceEvent, type AgentUsage, type AgentUsageEvent, type AgentUsageEventPayload, type AgentUserInput, type AgentUserInputExecutor, type AgentWorkflowActionConfig, type AgentWorkflowActorConfig, type AgentWorkflowConfig, type AgentWorkflowInvokeConfig, type AgentWorkflowRequestConfig, type AgentWorkflowStateConfig, type AgentWorkflowTransitionConfig, type AiSdkShapedStreamResult, type AiSdkShapedTextResult, type AllowedEvents, type AssistantMessage, type CanReachResult, type ChosenEvent, type CreateReplayEntryOptions, type DecisionAttempt, type DecisionLogicConfig, type DurableAgentResult, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type GetSnapshotRequestsOptions, type ImagePart, type InferInput, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, type PendingUserInput, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunDurableAgentOptions, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutors, type ScriptedExecutorsScript, type ScriptedTextEntry, type ScriptedUserInputEntry, type SeamRef, type SeamSlice, type SeamTurn, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, type StandardSchemaV1, type StructuredOutputEnvelope, type SystemMessage, type TextLogic, type TextLogicConfig, type TextLogicExecuteArgs, type TextLogicExecutor, type TextPart, type ToolCallPart, type ToolMessage, type ToolResultPart, type TrajectoryEvent, type TrajectoryItem, type TrajectoryMatch, type TrajectoryMiss, type UserMessage, type WithAgentUsageEvent, appendMessages, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, assistantMessage, bindRequestExecutor, buildEnvelopeSchema, canReach, createAgentActor, createAgentRun, createAgentSchemas, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getAgentSchemas, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getSnapshotNodes, getSnapshotRequests, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runDurableAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage };
|
|
1505
|
+
export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, type AgentActorSession, type AgentCallUsage, type AgentDecisionExecutor, AgentDecisionExhaustedError, type AgentDecisionInput, type AgentDecisionRequest, type AgentEffect, type AgentEffectDiff, AgentError, type AgentEventDescriptor, AgentEventLogConflictError, type AgentEventLogDiff, type AgentEventLogStore, type AgentEventToolNameResolver, type AgentExecutorTextRequest, AgentIdleError, AgentIllegalResumeEventError, type AgentInputFrom, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, AgentMaxModelCallsExceededError, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, type AgentSchemas, type AgentSnapshotNode, type AgentSnapshotStore, AgentSnapshotVersionMismatchError, type AgentStateRequest, type AgentStepRequest, type AgentTextRequest, type AgentTool, type AgentToolChoice, type AgentToolDescriptor, type AgentToolExecute, type AgentTools, type AgentTraceEvent, type AgentUsage, type AgentUsageEvent, type AgentUsageEventPayload, type AgentUserInput, type AgentUserInputExecutor, type AgentWorkflowActionConfig, type AgentWorkflowActorConfig, type AgentWorkflowConfig, type AgentWorkflowInvokeConfig, type AgentWorkflowRequestConfig, type AgentWorkflowStateConfig, type AgentWorkflowTransitionConfig, type AiSdkShapedStreamResult, type AiSdkShapedTextResult, type AllowedEvents, type AssertAgentMachineOptions, type AssistantMessage, type CanReachResult, type ChosenEvent, type CreateReplayEntryOptions, type DecisionAttempt, type DecisionLogic, type DecisionLogicConfig, type DurableAgentResult, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type GetSnapshotRequestsOptions, type ImagePart, type InferInput, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, type PendingUserInput, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunDurableAgentOptions, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutors, type ScriptedExecutorsScript, type ScriptedTextEntry, type ScriptedUserInputEntry, type SeamCall, type SeamRef, type SeamSlice, type SeamTurn, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, type StandardSchemaV1, type StructuredOutputEnvelope, type SystemMessage, type TextLogic, type TextLogicConfig, type TextLogicExecuteArgs, type TextLogicExecutor, type TextPart, type ToolCallPart, type ToolMessage, type ToolResultPart, type TrajectoryEvent, type TrajectoryItem, type TrajectoryMatch, type TrajectoryMiss, type UserMessage, type WithAgentUsageEvent, appendMessages, assertAgentLogEntry, assertAgentMachine, assertEventLogStoreConformance, assertJsonSerializable, assistantMessage, bindRequestExecutor, buildEnvelopeSchema, canReach, createAgentActor, createAgentRun, createAgentSchemas, createDecisionLogic, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getAgentSchemas, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getSnapshotNodes, getSnapshotRequests, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runDurableAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ToolResultPart, S as ToolMessage, T as WithAgentInputSchema, _ as NormalizedEventSchemas, a as AgentToolChoice, b as TextPart, c as AgentTools, d as ChosenEvent, f as EventUnion, g as InferOutput, h as InferInput, i as AgentTool, l as AllowedEvents, m as ImagePart, n as AgentMessage, o as AgentToolDescriptor, p as FilePart, r as AgentSnapshotStore, s as AgentToolExecute, t as AgentEventSchemaInputMap, u as AssistantMessage, v as StandardSchemaV1, w as UserMessage, x as ToolCallPart, y as SystemMessage } from "./types-
|
|
1
|
+
import { C as ToolResultPart, S as ToolMessage, T as WithAgentInputSchema, _ as NormalizedEventSchemas, a as AgentToolChoice, b as TextPart, c as AgentTools, d as ChosenEvent, f as EventUnion, g as InferOutput, h as InferInput, i as AgentTool, l as AllowedEvents, m as ImagePart, n as AgentMessage, o as AgentToolDescriptor, p as FilePart, r as AgentSnapshotStore, s as AgentToolExecute, t as AgentEventSchemaInputMap, u as AssistantMessage, v as StandardSchemaV1, w as UserMessage, x as ToolCallPart, y as SystemMessage } from "./types-CvWRGFxP.mjs";
|
|
2
2
|
import { t as AgentError } from "./errors-C9rxnWbX.mjs";
|
|
3
|
-
import { A as AgentDecisionExecutor, B as
|
|
3
|
+
import { A as AgentDecisionExecutor, B as resolveDecision, C as buildEnvelopeSchema, D as parseModelRef, E as getCallUsage, F as DecisionLogic, G as AgentSchemas, H as AgentEventToolNameResolver, I as DecisionLogicConfig, K as getAcceptedEvents, L as ResolveDecisionOptions, M as AgentDecisionInput, N as AgentDecisionRequest, O as parseOutput, P as DecisionAttempt, R as createDecisionLogic, S as bindRequestExecutor, T as getAgentOutputMode, U as AgentRequestOptions, V as AgentEventDescriptor, W as AgentRequestSource, _ as StructuredOutputEnvelope, a as AgentOutputMode, b as TextLogicExecuteArgs, c as AgentRequestExecutorResult, d as AgentTextRequest, f as AgentUsage, g as BuiltinAgentActors, h as AiSdkShapedTextResult, i as AgentModelRef, j as AgentDecisionExhaustedError, k as parseStructuredEnvelope, l as AgentRequestExecutors, m as AiSdkShapedStreamResult, n as AgentExecutorTextRequest, o as AgentRequestExecutor, p as AgentUserInput, q as parseAgentEvent, r as AgentModelMap, s as AgentRequestExecutorInfo, t as AgentCallUsage, u as AgentRequestMode, v as TextLogic, w as createTextLogic, x as TextLogicExecutor, y as TextLogicConfig, z as renderDecisionAttempts } from "./text-logic-DhfFWzu9.mjs";
|
|
4
4
|
import { a as AgentLogVerification, c as assertAgentLogEntry, d as assertEventLogStoreConformance, i as AgentLogEntry, l as assertJsonSerializable, n as AgentEventLogConflictError, o as JsonValue, r as AgentEventLogStore, s as NonSerializableAgentEventError, t as AGENT_EVENT_SCHEMA_VERSION, u as createInMemoryEventLogStore } from "./event-log-store-hrA1vqtN.mjs";
|
|
5
|
-
import { A as AgentRequest, B as AgentReplayMachineMismatchError, C as getSnapshotNodes, D as serializeTraceEvent, E as runAgent, F as AgentEffect, G as ReplayResult, H as CreateReplayEntryOptions, I as AgentEffectDiff, J as getAgentEffects, K as createReplayEntry, L as AgentEventLogDiff, M as executeAgentRequest, N as AGENT_INIT_EVENT_TYPE, O as traceTransitions, P as AGENT_USAGE_EVENT_TYPE, R as AgentLogPatchOperation, S as generateResult, T as inspectTransitions, U as GetAgentEffectsOptions, V as AgentUsageEvent, W as ReplayOptions, X as replay, Y as initEntry, _ as PendingUserInput, a as AgentInputFrom, b as RunAgentResult, c as AgentRunMeta, d as AgentTraceEvent, f as AgentUserInputExecutor, g as JsonSerializableTraceEvent, h as InspectedActorRef, i as AgentIllegalResumeEventError, j as AgentStepRequest, k as AgentStateRequest, l as AgentSnapshotNode, m as GetSnapshotRequestsOptions, n as AgentActorSession, o as AgentMaxModelCallsExceededError, p as GenerateResult, q as diffEventLogs, r as AgentIdleError, s as AgentMessageInfo, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentSnapshotVersionMismatchError, v as RunAgentErrorCause, w as getSnapshotRequests, x as createAgentActor, y as RunAgentOptions, z as AgentReplayDivergenceError } from "./run-agent-
|
|
5
|
+
import { A as AgentRequest, B as AgentReplayMachineMismatchError, C as getSnapshotNodes, D as serializeTraceEvent, E as runAgent, F as AgentEffect, G as ReplayResult, H as CreateReplayEntryOptions, I as AgentEffectDiff, J as getAgentEffects, K as createReplayEntry, L as AgentEventLogDiff, M as executeAgentRequest, N as AGENT_INIT_EVENT_TYPE, O as traceTransitions, P as AGENT_USAGE_EVENT_TYPE, R as AgentLogPatchOperation, S as generateResult, T as inspectTransitions, U as GetAgentEffectsOptions, V as AgentUsageEvent, W as ReplayOptions, X as replay, Y as initEntry, _ as PendingUserInput, a as AgentInputFrom, b as RunAgentResult, c as AgentRunMeta, d as AgentTraceEvent, f as AgentUserInputExecutor, g as JsonSerializableTraceEvent, h as InspectedActorRef, i as AgentIllegalResumeEventError, j as AgentStepRequest, k as AgentStateRequest, l as AgentSnapshotNode, m as GetSnapshotRequestsOptions, n as AgentActorSession, o as AgentMaxModelCallsExceededError, p as GenerateResult, q as diffEventLogs, r as AgentIdleError, s as AgentMessageInfo, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentSnapshotVersionMismatchError, v as RunAgentErrorCause, w as getSnapshotRequests, x as createAgentActor, y as RunAgentOptions, z as AgentReplayDivergenceError } from "./run-agent-0fpEZ1wJ.mjs";
|
|
6
6
|
import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventFromLogic, EventObject, InputFrom, MachineContext, MetaObject, NonReducibleUnknown, OutputFrom, SetupReturnFromConfig, SetupStateSchema, SnapshotFrom, StateValue } from "xstate";
|
|
7
7
|
|
|
8
8
|
//#region src/messages.d.ts
|
|
@@ -40,8 +40,9 @@ declare function appendMessages<TContext extends {
|
|
|
40
40
|
* A {@link StandardSchemaV1} validating an `AgentMessage[]` context field —
|
|
41
41
|
* checks that every message has a known `role` (`system`/`user`/`assistant`/
|
|
42
42
|
* `tool`) and that `content` is either a string (where the role allows it) or
|
|
43
|
-
* an array of parts
|
|
44
|
-
*
|
|
43
|
+
* an array of role-appropriate parts whose required fields and media payloads
|
|
44
|
+
* have the right runtime types (extra fields are allowed). Use it directly as
|
|
45
|
+
* a context schema's `messages` field when authoring with `createAgentSchemas`.
|
|
45
46
|
*/
|
|
46
47
|
declare const messagesSchema: StandardSchemaV1<AgentMessage[]>;
|
|
47
48
|
//#endregion
|
|
@@ -121,8 +122,8 @@ interface AgentWorkflowRequestConfig {
|
|
|
121
122
|
output: JsonSchemaObject;
|
|
122
123
|
tools?: AgentTools;
|
|
123
124
|
toolChoice?: AgentToolChoice | unknown;
|
|
124
|
-
/** Opt into the structured-output envelope's `reasoning` field (see `AgentTextRequest.
|
|
125
|
-
|
|
125
|
+
/** Opt into the structured-output envelope's `reasoning` field (see `AgentTextRequest.includeReasoning`). */
|
|
126
|
+
includeReasoning?: boolean;
|
|
126
127
|
temperature?: unknown;
|
|
127
128
|
maxOutputTokens?: unknown;
|
|
128
129
|
topP?: unknown;
|
|
@@ -255,6 +256,22 @@ interface FromConfigOptions {
|
|
|
255
256
|
type Constrain<T, TConstraint> = T extends TConstraint ? T : TConstraint;
|
|
256
257
|
type ContextOf<TContextSchema extends StandardSchemaV1> = Constrain<InferOutput<TContextSchema>, MachineContext>;
|
|
257
258
|
type EventsOf<TEventSchemas extends AgentEventSchemaInputMap> = Constrain<EventUnion<TEventSchemas>, EventObject>;
|
|
259
|
+
/**
|
|
260
|
+
* The first argument a guard or delay source receives. `context` and `event`
|
|
261
|
+
* come from the agent's own schemas, so an inline source is contextually typed
|
|
262
|
+
* and an annotated one stays assignable. XState's remaining fields (`self`,
|
|
263
|
+
* `parent`, `value`, `children`, `stateNode`) are deliberately not modeled:
|
|
264
|
+
* `setupAgent` only forwards these sources to `setup()`, which types them for
|
|
265
|
+
* real where the machine is built.
|
|
266
|
+
*/
|
|
267
|
+
type AgentSourceArgs<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap> = {
|
|
268
|
+
context: ContextOf<TContextSchema>;
|
|
269
|
+
event: EventsOf<TEventSchemas>;
|
|
270
|
+
};
|
|
271
|
+
/** Guard sources for `setupAgent({ guards })`, typed against the agent's own context and events. */
|
|
272
|
+
type AgentGuardSources<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap> = Record<string, (args: AgentSourceArgs<TContextSchema, TEventSchemas>, ...params: any[]) => boolean>;
|
|
273
|
+
/** Delay sources for `setupAgent({ delays })`, typed the same way as {@link AgentGuardSources}. */
|
|
274
|
+
type AgentDelaySources<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap> = Record<string, number | ((args: AgentSourceArgs<TContextSchema, TEventSchemas>) => number)>;
|
|
258
275
|
type SetupActors<TActors extends { [K in keyof TActors]: AnyActorLogic }> = { [K in keyof TActors]: TActors[K] extends AsyncActorLogic<infer TOutput, infer TInput> ? AsyncActorLogic<TOutput, TInput> : TActors[K] };
|
|
259
276
|
type AgentSetupActors<TActors extends { [K in keyof TActors]: AnyActorLogic }, TEvent extends string = string, TModel extends string = string> = TActors & BuiltinAgentActors<TEvent, TModel>;
|
|
260
277
|
/**
|
|
@@ -407,8 +424,8 @@ type SetupAgentBaseConfig<TContextSchema extends StandardSchemaV1<Record<string,
|
|
|
407
424
|
states?: TStateSchemas;
|
|
408
425
|
requests?: AgentRequestInput<TRequestSchemas, AgentModelRef<TModels>>;
|
|
409
426
|
actions?: NonNullable<AnySetupConfig["actions"]>;
|
|
410
|
-
guards?:
|
|
411
|
-
delays?:
|
|
427
|
+
guards?: AgentGuardSources<TContextSchema, TEventSchemas>;
|
|
428
|
+
delays?: AgentDelaySources<TContextSchema, TEventSchemas>;
|
|
412
429
|
/**
|
|
413
430
|
* Detects a snapshot that is an INTENTIONAL wait for an external event (a
|
|
414
431
|
* human approval, an inbound webhook, …) — the machine's own declaration of
|
|
@@ -724,8 +741,8 @@ interface LintAgentMachineOptions {
|
|
|
724
741
|
*/
|
|
725
742
|
declare function lintAgentMachine(machine: AnyStateMachine, options?: LintAgentMachineOptions): AgentLintDiagnostic[];
|
|
726
743
|
/**
|
|
727
|
-
* Thrown by `lintAgentMachine(machine, { throw: true })`
|
|
728
|
-
* failing diagnostics.
|
|
744
|
+
* Thrown by `lintAgentMachine(machine, { throw: true })` (and its
|
|
745
|
+
* {@link assertAgentMachine} alias) when lint finds failing diagnostics.
|
|
729
746
|
* `diagnostics` holds the findings; the message lists them one per finding,
|
|
730
747
|
* so a test runner's failure output reads like the CLI's lint report.
|
|
731
748
|
*/
|
|
@@ -733,6 +750,26 @@ declare class AgentLintError extends AgentError {
|
|
|
733
750
|
readonly diagnostics: AgentLintDiagnostic[];
|
|
734
751
|
constructor(machineId: string, diagnostics: AgentLintDiagnostic[]);
|
|
735
752
|
}
|
|
753
|
+
/** Options for {@link assertAgentMachine}. */
|
|
754
|
+
interface AssertAgentMachineOptions extends LintAgentMachineOptions {
|
|
755
|
+
/** Also fail on warning-severity findings. Default: errors only. */
|
|
756
|
+
warnings?: boolean;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Asserts a machine passes {@link lintAgentMachine}: returns silently when
|
|
760
|
+
* clean, throws {@link AgentLintError} (with the findings on `.diagnostics`)
|
|
761
|
+
* otherwise — sugar for `lintAgentMachine(machine, { ...options, throw: true })`.
|
|
762
|
+
* Fails on error-severity findings; set `warnings: true` to fail on warnings
|
|
763
|
+
* too. The one-liner for tests and generation loops:
|
|
764
|
+
*
|
|
765
|
+
* @example
|
|
766
|
+
* ```ts
|
|
767
|
+
* test('agent machine is structurally sound', () => {
|
|
768
|
+
* assertAgentMachine(machine);
|
|
769
|
+
* });
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
declare function assertAgentMachine(machine: AnyStateMachine, options?: AssertAgentMachineOptions): void;
|
|
736
773
|
/**
|
|
737
774
|
* Scripted responses for a {@link simulateAgent} playthrough. Each channel is a
|
|
738
775
|
* by-`src` map of FIFO queues, consumed in the order the machine reaches the
|
|
@@ -740,25 +777,49 @@ declare class AgentLintError extends AgentError {
|
|
|
740
777
|
* - `text` — output values for text requests, keyed by request src (the
|
|
741
778
|
* `setupAgent({ requests })` key, or `agent.generateText`/`agent.streamText`).
|
|
742
779
|
* - `decisions` — the {@link ChosenEvent} to apply for a decision request,
|
|
743
|
-
* keyed by decision src (usually `agent.decide`).
|
|
780
|
+
* keyed by decision src (usually `agent.decide`). An invoke whose src is an
|
|
781
|
+
* inline logic object has only an auto-generated src, so its queue may be
|
|
782
|
+
* keyed by the invoke's `id` instead.
|
|
744
783
|
* - `invokes` — output values for scripted invokes (any actor whose output must
|
|
745
784
|
* be canned), keyed by src.
|
|
746
785
|
* - `userInput` — a flat FIFO queue of answers for `agent.userInput`, the
|
|
747
786
|
* shorthand for `invokes: { 'agent.userInput': [...] }`. Entries here are
|
|
748
787
|
* consumed before that src's `invokes` queue.
|
|
788
|
+
* - `events` — a flat FIFO queue of external (human/host-sent) events. When the
|
|
789
|
+
* machine settles idle with no pending request or invoke — a human gate — the
|
|
790
|
+
* next queued event is applied, so a simulation can cross states that a live
|
|
791
|
+
* run crosses via `actor.send(...)`. An event the current state cannot take
|
|
792
|
+
* (no handler, or guard-rejected) throws rather than silently vanishing.
|
|
749
793
|
*/
|
|
750
794
|
interface SimulationScript {
|
|
751
795
|
text?: Record<string, unknown[]>;
|
|
752
796
|
decisions?: Record<string, ChosenEvent[]>;
|
|
753
797
|
invokes?: Record<string, unknown[]>;
|
|
754
798
|
userInput?: unknown[];
|
|
799
|
+
events?: ChosenEvent[];
|
|
755
800
|
}
|
|
756
|
-
/**
|
|
801
|
+
/**
|
|
802
|
+
* One entry in a {@link SimulateAgentResult.trail}: the state after this step,
|
|
803
|
+
* plus what drove the step. The first entry is always the machine's initial
|
|
804
|
+
* state, with no `appliedEvent`/`resolvedRequest` — so `trail.map((e) =>
|
|
805
|
+
* e.state)` is the complete state path, directly comparable with
|
|
806
|
+
* `matchesTrajectory` without prepending the initial state by hand.
|
|
807
|
+
*/
|
|
757
808
|
interface SimulationTrailEntry {
|
|
758
809
|
/** The machine state value after applying this step. */
|
|
759
810
|
state: unknown;
|
|
760
|
-
/** The chosen event applied (for a decision request). */
|
|
811
|
+
/** The chosen event applied (for a decision request), or the external event applied (when `external`). */
|
|
761
812
|
appliedEvent?: ChosenEvent;
|
|
813
|
+
/** True when `appliedEvent` came from the script's `events` queue (an external/user event), not a decision. */
|
|
814
|
+
external?: boolean;
|
|
815
|
+
/**
|
|
816
|
+
* Scripted decisions that failed validation (unknown event, invalid payload,
|
|
817
|
+
* or guard-rejected — live-run retry parity, see {@link simulateAgent})
|
|
818
|
+
* before this step settled. Present with an `appliedEvent` when a later
|
|
819
|
+
* scripted attempt succeeded, or alone when every attempt failed and the
|
|
820
|
+
* exhaustion error was routed through the decision invoke's `onError`.
|
|
821
|
+
*/
|
|
822
|
+
rejectedEvents?: ChosenEvent[];
|
|
762
823
|
/** The resolved request (for a text/userInput invoke): its kind and src. */
|
|
763
824
|
resolvedRequest?: {
|
|
764
825
|
kind: "text" | "userInput";
|
|
@@ -787,6 +848,21 @@ interface SimulateAgentResult {
|
|
|
787
848
|
* the real transition logic. Returns the terminal `status`, final `snapshot`,
|
|
788
849
|
* and a `trail` of every step taken.
|
|
789
850
|
*
|
|
851
|
+
* Decisions run through the live run's own validation/retry core,
|
|
852
|
+
* {@link resolveDecision}, with the script standing in for the model: each
|
|
853
|
+
* attempt consumes the next queued {@link ChosenEvent} for that src, so an
|
|
854
|
+
* unknown, payload-invalid, or guard-rejected event is NOT silently swallowed
|
|
855
|
+
* — the next queued decision is tried, exactly as a live run re-asks the
|
|
856
|
+
* model. The decision logic's `maxRetries` caps attempts as it would live;
|
|
857
|
+
* when retries continue past the end of the queue, the last queued decision
|
|
858
|
+
* repeats (a scripted model that insists). The repeat applies only within one
|
|
859
|
+
* decision request's retries — each new decision request must have its own
|
|
860
|
+
* queued entry, or the dry-script error throws as usual. Exhausting all
|
|
861
|
+
* attempts delivers
|
|
862
|
+
* the resulting {@link AgentDecisionExhaustedError} to the machine as the
|
|
863
|
+
* decision invoke's error (so an `onError` transition observes it, as it
|
|
864
|
+
* would live); with no `onError` to catch it, it is thrown.
|
|
865
|
+
*
|
|
790
866
|
* Throws a descriptive error when the script runs dry mid-request, naming the
|
|
791
867
|
* pending request's kind, src, and id so the missing scripted response is
|
|
792
868
|
* obvious.
|
|
@@ -795,7 +871,10 @@ interface SimulateAgentResult {
|
|
|
795
871
|
* ```ts
|
|
796
872
|
* const { status, snapshot } = simulateAgent(machine, {
|
|
797
873
|
* input: { topic: 'state machines' },
|
|
798
|
-
* script: {
|
|
874
|
+
* script: {
|
|
875
|
+
* decisions: { 'agent.decide': [{ type: 'ESCALATE' }] },
|
|
876
|
+
* events: [{ type: 'APPROVE' }], // crosses the human gate
|
|
877
|
+
* },
|
|
799
878
|
* });
|
|
800
879
|
* ```
|
|
801
880
|
*/
|
|
@@ -872,8 +951,11 @@ interface CanReachResult {
|
|
|
872
951
|
witness?: ChosenEvent[];
|
|
873
952
|
}
|
|
874
953
|
/**
|
|
875
|
-
* Answers "can the machine reach
|
|
876
|
-
*
|
|
954
|
+
* Answers "can the machine reach this?" by exploring its branches (a thin
|
|
955
|
+
* wrapper over {@link explorePaths}). The target is either a state path string
|
|
956
|
+
* (`snapshot.matches(...)` semantics) or a snapshot predicate — the predicate
|
|
957
|
+
* form checks any property (a context invariant, a tag, a state+context
|
|
958
|
+
* combination) without reifying a sentinel state for it. Returns
|
|
877
959
|
* `{ reachable: true, witness }` with the event sequence that reaches it, or
|
|
878
960
|
* `{ reachable: false }`.
|
|
879
961
|
*
|
|
@@ -882,8 +964,18 @@ interface CanReachResult {
|
|
|
882
964
|
* const { reachable, witness } = await canReach(refundMachine, 'denied', { input: { request: 'x', amount: 5000 } });
|
|
883
965
|
* // reachable → true; witness → [{ type: 'NEEDS_REVIEW' }, { type: 'DENY' }]
|
|
884
966
|
* ```
|
|
967
|
+
*
|
|
968
|
+
* @example Predicate target — a violation property, no sentinel state needed
|
|
969
|
+
* ```ts
|
|
970
|
+
* const violation = await canReach(
|
|
971
|
+
* refundMachine,
|
|
972
|
+
* (snapshot) => snapshot.matches('issued') && !snapshot.context.approved,
|
|
973
|
+
* { input: { amount: 5000 } },
|
|
974
|
+
* );
|
|
975
|
+
* // violation.reachable → false is the safety proof
|
|
976
|
+
* ```
|
|
885
977
|
*/
|
|
886
|
-
declare function canReach(machine: AnyStateMachine,
|
|
978
|
+
declare function canReach(machine: AnyStateMachine, target: string | ((snapshot: AnyMachineSnapshot) => boolean), options?: ExplorePathsOptions): Promise<CanReachResult>;
|
|
887
979
|
//#endregion
|
|
888
980
|
//#region src/trajectory.d.ts
|
|
889
981
|
/** An event-shaped trajectory item: anything with a string `type`. */
|
|
@@ -1204,6 +1296,26 @@ interface SeamTurn<TMachine extends AnyStateMachine> {
|
|
|
1204
1296
|
/** The `idle` result that produced the pause. */
|
|
1205
1297
|
result: RunAgentResult<TMachine>;
|
|
1206
1298
|
}
|
|
1299
|
+
/**
|
|
1300
|
+
* One text call in a {@link runSeam} run's ledger, in call order — the receipt
|
|
1301
|
+
* that says which answers came from the script and which one came from the
|
|
1302
|
+
* candidate, so "everything else stayed scripted" is a plain assertion on
|
|
1303
|
+
* {@link RunSeamResult.calls} rather than a recording function wrapped around
|
|
1304
|
+
* every script entry. Text calls only: `decide` and other base executors are
|
|
1305
|
+
* not routed by the seam and do not appear.
|
|
1306
|
+
*/
|
|
1307
|
+
interface SeamCall {
|
|
1308
|
+
/** The request's `name`, when it has one. */
|
|
1309
|
+
name?: string;
|
|
1310
|
+
/** The request's model key. */
|
|
1311
|
+
model: string;
|
|
1312
|
+
/** The `scripts` queue key that routed this call. */
|
|
1313
|
+
key: string;
|
|
1314
|
+
/** Where the answer came from: the script, or the seam's `candidate`. */
|
|
1315
|
+
source: "script" | "candidate";
|
|
1316
|
+
/** True for the seam call itself — scripted or candidate. */
|
|
1317
|
+
seam: boolean;
|
|
1318
|
+
}
|
|
1207
1319
|
/** One side of the seam: a trajectory pair ready for `matchesTrajectory`. */
|
|
1208
1320
|
interface SeamSlice {
|
|
1209
1321
|
/** State values entered on this side of the seam, in order. */
|
|
@@ -1240,7 +1352,7 @@ interface RunSeamOptions<TMachine extends AnyStateMachine> {
|
|
|
1240
1352
|
* request-shaped. Omit to run the seam scripted too: the whole seam run is
|
|
1241
1353
|
* then keyless and deterministic.
|
|
1242
1354
|
*/
|
|
1243
|
-
candidate?:
|
|
1355
|
+
candidate?: AgentRequestExecutor;
|
|
1244
1356
|
/**
|
|
1245
1357
|
* The simulated user. Called at every idle pause; return the event to send,
|
|
1246
1358
|
* or `null`/`undefined` to stop the run there. Omitted, the run stops at the
|
|
@@ -1269,8 +1381,17 @@ interface RunSeamResult<TMachine extends AnyStateMachine> {
|
|
|
1269
1381
|
result: RunAgentResult<TMachine>;
|
|
1270
1382
|
/** What the seam call returned, or `undefined` when the run never reached it. */
|
|
1271
1383
|
seamOutput: unknown;
|
|
1384
|
+
/**
|
|
1385
|
+
* The seam call's own reported token usage — the cost of the one live call
|
|
1386
|
+
* when a `candidate` is a real model. `undefined` when the run never reached
|
|
1387
|
+
* the seam or its answer reported no usage (scripted entries report usage
|
|
1388
|
+
* only via the `{ output, usage }` envelope).
|
|
1389
|
+
*/
|
|
1390
|
+
seamUsage?: AgentCallUsage;
|
|
1272
1391
|
/** Model calls made before the seam, or `-1` when the run never reached it. */
|
|
1273
1392
|
callsBeforeSeam: number;
|
|
1393
|
+
/** The run's text calls in order: what was served, and by whom. */
|
|
1394
|
+
calls: SeamCall[];
|
|
1274
1395
|
/** Everything up to the seam's own effect completion. */
|
|
1275
1396
|
before: SeamSlice;
|
|
1276
1397
|
/**
|
|
@@ -1381,4 +1502,4 @@ type DurableAgentResult<TMachine extends AnyStateMachine> = {
|
|
|
1381
1502
|
*/
|
|
1382
1503
|
declare function runDurableAgent<TMachine extends AnyStateMachine>(machine: TMachine, options?: RunDurableAgentOptions<TMachine>): Promise<DurableAgentResult<TMachine>>;
|
|
1383
1504
|
//#endregion
|
|
1384
|
-
export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, type AgentActorSession, type AgentCallUsage, type AgentDecisionExecutor, AgentDecisionExhaustedError, type AgentDecisionInput, type AgentDecisionRequest, type AgentEffect, type AgentEffectDiff, AgentError, type AgentEventDescriptor, AgentEventLogConflictError, type AgentEventLogDiff, type AgentEventLogStore, type AgentEventToolNameResolver, type AgentExecutorTextRequest, AgentIdleError, AgentIllegalResumeEventError, type AgentInputFrom, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, AgentMaxModelCallsExceededError, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, type AgentSchemas, type AgentSnapshotNode, type AgentSnapshotStore, AgentSnapshotVersionMismatchError, type AgentStateRequest, type AgentStepRequest, type AgentTextRequest, type AgentTool, type AgentToolChoice, type AgentToolDescriptor, type AgentToolExecute, type AgentTools, type AgentTraceEvent, type AgentUsage, type AgentUsageEvent, type AgentUsageEventPayload, type AgentUserInput, type AgentUserInputExecutor, type AgentWorkflowActionConfig, type AgentWorkflowActorConfig, type AgentWorkflowConfig, type AgentWorkflowInvokeConfig, type AgentWorkflowRequestConfig, type AgentWorkflowStateConfig, type AgentWorkflowTransitionConfig, type AiSdkShapedStreamResult, type AiSdkShapedTextResult, type AllowedEvents, type AssistantMessage, type CanReachResult, type ChosenEvent, type CreateReplayEntryOptions, type DecisionAttempt, type DecisionLogicConfig, type DurableAgentResult, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type GetSnapshotRequestsOptions, type ImagePart, type InferInput, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, type PendingUserInput, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunDurableAgentOptions, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutors, type ScriptedExecutorsScript, type ScriptedTextEntry, type ScriptedUserInputEntry, type SeamRef, type SeamSlice, type SeamTurn, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, type StandardSchemaV1, type StructuredOutputEnvelope, type SystemMessage, type TextLogic, type TextLogicConfig, type TextLogicExecuteArgs, type TextLogicExecutor, type TextPart, type ToolCallPart, type ToolMessage, type ToolResultPart, type TrajectoryEvent, type TrajectoryItem, type TrajectoryMatch, type TrajectoryMiss, type UserMessage, type WithAgentUsageEvent, appendMessages, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, assistantMessage, bindRequestExecutor, buildEnvelopeSchema, canReach, createAgentActor, createAgentRun, createAgentSchemas, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getAgentSchemas, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getSnapshotNodes, getSnapshotRequests, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runDurableAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage };
|
|
1505
|
+
export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, type AgentActorSession, type AgentCallUsage, type AgentDecisionExecutor, AgentDecisionExhaustedError, type AgentDecisionInput, type AgentDecisionRequest, type AgentEffect, type AgentEffectDiff, AgentError, type AgentEventDescriptor, AgentEventLogConflictError, type AgentEventLogDiff, type AgentEventLogStore, type AgentEventToolNameResolver, type AgentExecutorTextRequest, AgentIdleError, AgentIllegalResumeEventError, type AgentInputFrom, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, AgentMaxModelCallsExceededError, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, type AgentSchemas, type AgentSnapshotNode, type AgentSnapshotStore, AgentSnapshotVersionMismatchError, type AgentStateRequest, type AgentStepRequest, type AgentTextRequest, type AgentTool, type AgentToolChoice, type AgentToolDescriptor, type AgentToolExecute, type AgentTools, type AgentTraceEvent, type AgentUsage, type AgentUsageEvent, type AgentUsageEventPayload, type AgentUserInput, type AgentUserInputExecutor, type AgentWorkflowActionConfig, type AgentWorkflowActorConfig, type AgentWorkflowConfig, type AgentWorkflowInvokeConfig, type AgentWorkflowRequestConfig, type AgentWorkflowStateConfig, type AgentWorkflowTransitionConfig, type AiSdkShapedStreamResult, type AiSdkShapedTextResult, type AllowedEvents, type AssertAgentMachineOptions, type AssistantMessage, type CanReachResult, type ChosenEvent, type CreateReplayEntryOptions, type DecisionAttempt, type DecisionLogic, type DecisionLogicConfig, type DurableAgentResult, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type GetSnapshotRequestsOptions, type ImagePart, type InferInput, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, type PendingUserInput, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunDurableAgentOptions, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutors, type ScriptedExecutorsScript, type ScriptedTextEntry, type ScriptedUserInputEntry, type SeamCall, type SeamRef, type SeamSlice, type SeamTurn, type SimulateAgentOptions, type SimulateAgentResult, type SimulationScript, type SimulationTrailEntry, type StandardSchemaV1, type StructuredOutputEnvelope, type SystemMessage, type TextLogic, type TextLogicConfig, type TextLogicExecuteArgs, type TextLogicExecutor, type TextPart, type ToolCallPart, type ToolMessage, type ToolResultPart, type TrajectoryEvent, type TrajectoryItem, type TrajectoryMatch, type TrajectoryMiss, type UserMessage, type WithAgentUsageEvent, appendMessages, assertAgentLogEntry, assertAgentMachine, assertEventLogStoreConformance, assertJsonSerializable, assistantMessage, bindRequestExecutor, buildEnvelopeSchema, canReach, createAgentActor, createAgentRun, createAgentSchemas, createDecisionLogic, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getAgentSchemas, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getSnapshotNodes, getSnapshotRequests, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runDurableAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage };
|