@statelyai/agent 2.0.0-alpha.12 → 2.0.0-alpha.13

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { d as ChosenEvent } from "./types-QbEfCVny.cjs";
2
- import { O as AgentDecisionExecutor, a as AgentRequestExecutor, c as AgentRequestExecutors } from "./text-logic-CorGzucG.cjs";
2
+ import { k as AgentDecisionExecutor, l as AgentRequestExecutors, o as AgentRequestExecutor } from "./text-logic-BDxwQNsD.cjs";
3
3
  import { FinishReason, LanguageModel, LanguageModelUsage, ToolSet, TypedToolCall, TypedToolResult } from "ai";
4
4
 
5
5
  //#region src/ai-sdk/index.d.ts
package/dist/ai-sdk.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { d as ChosenEvent } from "./types-_FXoFBGO.mjs";
2
- import { O as AgentDecisionExecutor, a as AgentRequestExecutor, c as AgentRequestExecutors } from "./text-logic-DjR5PUVz.mjs";
2
+ import { k as AgentDecisionExecutor, l as AgentRequestExecutors, o as AgentRequestExecutor } from "./text-logic-TkKPw8Aq.mjs";
3
3
  import { FinishReason, LanguageModel, LanguageModelUsage, ToolSet, TypedToolCall, TypedToolResult } from "ai";
4
4
 
5
5
  //#region src/ai-sdk/index.d.ts
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { C as UserMessage, S as ToolResultPart, _ as StandardSchemaV1, a as AgentToolChoice, b as ToolCallPart, c as AgentTools, d as ChosenEvent, f as EventUnion, g as NormalizedEventSchemas, h as InferOutput, 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 SystemMessage, x as ToolMessage, y as TextPart } from "./types-QbEfCVny.cjs";
2
2
  import { t as AgentError } from "./errors-BQRk9eiZ.cjs";
3
- import { A as AgentDecisionInput, B as resolveDecision, C as createTextLogic, D as parseStructuredEnvelope, E as parseOutput, F as DecisionLogicConfig, G as getAcceptedEvents, H as AgentEventToolNameResolver, I as PLAN_DONE_EVENT_TYPE, K as parseAgentEvent, L as PlanLogic, M as AgentPlanInput, N as AgentPlanOutput, O as AgentDecisionExecutor, P as DecisionAttempt, R as ResolveDecisionOptions, S as buildEnvelopeSchema, T as parseModelRef, U as AgentRequestOptions, V as AgentEventDescriptor, W as AgentRequestSource, _ as TextLogic, a as AgentRequestExecutor, b as TextLogicExecutor, c as AgentRequestExecutors, d as AgentUsage, f as AgentUserInput, g as StructuredOutputEnvelope, h as BuiltinAgentActors, i as AgentOutputMode, j as AgentDecisionRequest, k as AgentDecisionExhaustedError, l as AgentRequestMode, m as AiSdkShapedTextResult, n as AgentModelMap, o as AgentRequestExecutorInfo, p as AiSdkShapedStreamResult, r as AgentModelRef, s as AgentRequestExecutorResult, t as AgentCallUsage, u as AgentTextRequest, v as TextLogicConfig, w as getAgentOutputMode, x as bindRequestExecutor, y as TextLogicExecuteArgs, z as renderDecisionAttempts } from "./text-logic-CorGzucG.cjs";
4
- import { A as AgentReplayDivergenceError, B as getCallUsage, C as AgentStateRequest, D as AgentEffectDiff, E as AgentEffect, F as ReplayOptions, G as AgentRequest, H as replay, I as ReplayResult, K as AgentStepRequest, L as createReplayEntry, M as AgentUsageEvent, N as CreateReplayEntryOptions, O as AgentEventLogDiff, P as GetAgentEffectsOptions, R as diffEventLogs, S as traceTransitions, T as AGENT_USAGE_EVENT_TYPE, U as verifyReplay, V as initEntry, W as AgentPlanRequest, _ as createAgentActor, a as AgentMessageInfo, b as runAgent, c as AgentTraceEvent, d as InspectedActorRef, f as JsonSerializableTraceEvent, g as RunAgentResult, h as RunAgentOptions, i as AgentIllegalResumeEventError, j as AgentReplayMachineMismatchError, k as AgentLogPatchOperation, l as AgentUserInputExecutor, m as RunAgentErrorCause, n as AgentActorSession, o as AgentRunMeta, p as PendingUserInput, q as executeAgentRequest, r as AgentIdleError, s as AgentSnapshotVersionMismatchError, t as AGENT_TRACE_SCHEMA_VERSION, u as GenerateResult, v as generateResult, w as AGENT_INIT_EVENT_TYPE, x as serializeTraceEvent, y as inspectTransitions, z as getAgentEffects } from "./run-agent-qkg0evvW.cjs";
3
+ import { A as AgentDecisionExhaustedError, B as renderDecisionAttempts, C as buildEnvelopeSchema, D as parseOutput, E as parseModelRef, F as DecisionAttempt, G as AgentRequestSource, H as AgentEventDescriptor, I as DecisionLogicConfig, K as getAcceptedEvents, L as PLAN_DONE_EVENT_TYPE, M as AgentDecisionRequest, N as AgentPlanInput, O as parseStructuredEnvelope, P as AgentPlanOutput, R as PlanLogic, S as bindRequestExecutor, T as getAgentOutputMode, U as AgentEventToolNameResolver, V as resolveDecision, W as AgentRequestOptions, _ 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 AgentDecisionInput, k as AgentDecisionExecutor, 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 ResolveDecisionOptions } from "./text-logic-BDxwQNsD.cjs";
4
+ import { A as AgentReplayDivergenceError, B as getCallUsage, C as AgentStateRequest, D as AgentEffectDiff, E as AgentEffect, F as ReplayOptions, G as AgentRequest, H as replay, I as ReplayResult, K as AgentStepRequest, L as createReplayEntry, M as AgentUsageEvent, N as CreateReplayEntryOptions, O as AgentEventLogDiff, P as GetAgentEffectsOptions, R as diffEventLogs, S as traceTransitions, T as AGENT_USAGE_EVENT_TYPE, U as verifyReplay, V as initEntry, W as AgentPlanRequest, _ as createAgentActor, a as AgentMessageInfo, b as runAgent, c as AgentTraceEvent, d as InspectedActorRef, f as JsonSerializableTraceEvent, g as RunAgentResult, h as RunAgentOptions, i as AgentIllegalResumeEventError, j as AgentReplayMachineMismatchError, k as AgentLogPatchOperation, l as AgentUserInputExecutor, m as RunAgentErrorCause, n as AgentActorSession, o as AgentRunMeta, p as PendingUserInput, q as executeAgentRequest, r as AgentIdleError, s as AgentSnapshotVersionMismatchError, t as AGENT_TRACE_SCHEMA_VERSION, u as GenerateResult, v as generateResult, w as AGENT_INIT_EVENT_TYPE, x as serializeTraceEvent, y as inspectTransitions, z as getAgentEffects } from "./run-agent-DnvtcnTZ.cjs";
5
5
  import { a as AgentLogVerification, c as assertAgentLogEntry, d as createInMemoryEventLogStore, i as AgentLogEntry, l as assertEventLogStoreConformance, n as AgentEventLogConflictError, o as JsonValue, r as AgentEventLogStore, s as NonSerializableAgentEventError, t as AGENT_EVENT_SCHEMA_VERSION, u as assertJsonSerializable } from "./event-log-store-Ruq18mGp.cjs";
6
6
  import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventFromLogic, EventObject, InputFrom, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema, SnapshotFrom, StateValue } from "xstate";
7
7
 
@@ -1202,4 +1202,4 @@ declare function getJsonSchema(schema?: StandardSchemaV1): Promise<Record<string
1202
1202
  */
1203
1203
  declare function getJsonSchemaSync(schema?: StandardSchemaV1): Record<string, unknown> | undefined;
1204
1204
  //#endregion
1205
- 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, AgentIdleError, AgentIllegalResumeEventError, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, type AgentPlanInput, type AgentPlanOutput, type AgentPlanRequest, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, 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 DecisionLogicConfig, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type ImagePart, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, PLAN_DONE_EVENT_TYPE, type PendingUserInput, type PlanLogic, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutorsScript, type ScriptedTextEntry, 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, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, persistSnapshot, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage, verifyReplay };
1205
+ 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 AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, type AgentPlanInput, type AgentPlanOutput, type AgentPlanRequest, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, 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 DecisionLogicConfig, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type ImagePart, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, PLAN_DONE_EVENT_TYPE, type PendingUserInput, type PlanLogic, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutorsScript, type ScriptedTextEntry, 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, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, persistSnapshot, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage, verifyReplay };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { C as UserMessage, S as ToolResultPart, _ as StandardSchemaV1, a as AgentToolChoice, b as ToolCallPart, c as AgentTools, d as ChosenEvent, f as EventUnion, g as NormalizedEventSchemas, h as InferOutput, 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 SystemMessage, x as ToolMessage, y as TextPart } from "./types-_FXoFBGO.mjs";
2
2
  import { t as AgentError } from "./errors-C9rxnWbX.mjs";
3
- import { A as AgentDecisionInput, B as resolveDecision, C as createTextLogic, D as parseStructuredEnvelope, E as parseOutput, F as DecisionLogicConfig, G as getAcceptedEvents, H as AgentEventToolNameResolver, I as PLAN_DONE_EVENT_TYPE, K as parseAgentEvent, L as PlanLogic, M as AgentPlanInput, N as AgentPlanOutput, O as AgentDecisionExecutor, P as DecisionAttempt, R as ResolveDecisionOptions, S as buildEnvelopeSchema, T as parseModelRef, U as AgentRequestOptions, V as AgentEventDescriptor, W as AgentRequestSource, _ as TextLogic, a as AgentRequestExecutor, b as TextLogicExecutor, c as AgentRequestExecutors, d as AgentUsage, f as AgentUserInput, g as StructuredOutputEnvelope, h as BuiltinAgentActors, i as AgentOutputMode, j as AgentDecisionRequest, k as AgentDecisionExhaustedError, l as AgentRequestMode, m as AiSdkShapedTextResult, n as AgentModelMap, o as AgentRequestExecutorInfo, p as AiSdkShapedStreamResult, r as AgentModelRef, s as AgentRequestExecutorResult, t as AgentCallUsage, u as AgentTextRequest, v as TextLogicConfig, w as getAgentOutputMode, x as bindRequestExecutor, y as TextLogicExecuteArgs, z as renderDecisionAttempts } from "./text-logic-DjR5PUVz.mjs";
4
- import { A as AgentReplayDivergenceError, B as getCallUsage, C as AgentStateRequest, D as AgentEffectDiff, E as AgentEffect, F as ReplayOptions, G as AgentRequest, H as replay, I as ReplayResult, K as AgentStepRequest, L as createReplayEntry, M as AgentUsageEvent, N as CreateReplayEntryOptions, O as AgentEventLogDiff, P as GetAgentEffectsOptions, R as diffEventLogs, S as traceTransitions, T as AGENT_USAGE_EVENT_TYPE, U as verifyReplay, V as initEntry, W as AgentPlanRequest, _ as createAgentActor, a as AgentMessageInfo, b as runAgent, c as AgentTraceEvent, d as InspectedActorRef, f as JsonSerializableTraceEvent, g as RunAgentResult, h as RunAgentOptions, i as AgentIllegalResumeEventError, j as AgentReplayMachineMismatchError, k as AgentLogPatchOperation, l as AgentUserInputExecutor, m as RunAgentErrorCause, n as AgentActorSession, o as AgentRunMeta, p as PendingUserInput, q as executeAgentRequest, r as AgentIdleError, s as AgentSnapshotVersionMismatchError, t as AGENT_TRACE_SCHEMA_VERSION, u as GenerateResult, v as generateResult, w as AGENT_INIT_EVENT_TYPE, x as serializeTraceEvent, y as inspectTransitions, z as getAgentEffects } from "./run-agent-B1nBa7aV.mjs";
3
+ import { A as AgentDecisionExhaustedError, B as renderDecisionAttempts, C as buildEnvelopeSchema, D as parseOutput, E as parseModelRef, F as DecisionAttempt, G as AgentRequestSource, H as AgentEventDescriptor, I as DecisionLogicConfig, K as getAcceptedEvents, L as PLAN_DONE_EVENT_TYPE, M as AgentDecisionRequest, N as AgentPlanInput, O as parseStructuredEnvelope, P as AgentPlanOutput, R as PlanLogic, S as bindRequestExecutor, T as getAgentOutputMode, U as AgentEventToolNameResolver, V as resolveDecision, W as AgentRequestOptions, _ 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 AgentDecisionInput, k as AgentDecisionExecutor, 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 ResolveDecisionOptions } from "./text-logic-TkKPw8Aq.mjs";
4
+ import { A as AgentReplayDivergenceError, B as getCallUsage, C as AgentStateRequest, D as AgentEffectDiff, E as AgentEffect, F as ReplayOptions, G as AgentRequest, H as replay, I as ReplayResult, K as AgentStepRequest, L as createReplayEntry, M as AgentUsageEvent, N as CreateReplayEntryOptions, O as AgentEventLogDiff, P as GetAgentEffectsOptions, R as diffEventLogs, S as traceTransitions, T as AGENT_USAGE_EVENT_TYPE, U as verifyReplay, V as initEntry, W as AgentPlanRequest, _ as createAgentActor, a as AgentMessageInfo, b as runAgent, c as AgentTraceEvent, d as InspectedActorRef, f as JsonSerializableTraceEvent, g as RunAgentResult, h as RunAgentOptions, i as AgentIllegalResumeEventError, j as AgentReplayMachineMismatchError, k as AgentLogPatchOperation, l as AgentUserInputExecutor, m as RunAgentErrorCause, n as AgentActorSession, o as AgentRunMeta, p as PendingUserInput, q as executeAgentRequest, r as AgentIdleError, s as AgentSnapshotVersionMismatchError, t as AGENT_TRACE_SCHEMA_VERSION, u as GenerateResult, v as generateResult, w as AGENT_INIT_EVENT_TYPE, x as serializeTraceEvent, y as inspectTransitions, z as getAgentEffects } from "./run-agent-C3mFDGTf.mjs";
5
5
  import { a as AgentLogVerification, c as assertAgentLogEntry, d as createInMemoryEventLogStore, i as AgentLogEntry, l as assertEventLogStoreConformance, n as AgentEventLogConflictError, o as JsonValue, r as AgentEventLogStore, s as NonSerializableAgentEventError, t as AGENT_EVENT_SCHEMA_VERSION, u as assertJsonSerializable } from "./event-log-store-CriMgX1D.mjs";
6
6
  import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventFromLogic, EventObject, InputFrom, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema, SnapshotFrom, StateValue } from "xstate";
7
7
 
@@ -1202,4 +1202,4 @@ declare function getJsonSchema(schema?: StandardSchemaV1): Promise<Record<string
1202
1202
  */
1203
1203
  declare function getJsonSchemaSync(schema?: StandardSchemaV1): Record<string, unknown> | undefined;
1204
1204
  //#endregion
1205
- 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, AgentIdleError, AgentIllegalResumeEventError, type AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, type AgentPlanInput, type AgentPlanOutput, type AgentPlanRequest, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, 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 DecisionLogicConfig, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type ImagePart, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, PLAN_DONE_EVENT_TYPE, type PendingUserInput, type PlanLogic, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutorsScript, type ScriptedTextEntry, 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, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, persistSnapshot, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage, verifyReplay };
1205
+ 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 AgentLintDiagnostic, AgentLintError, type AgentLintSeverity, type AgentLogEntry, type AgentLogPatchOperation, type AgentLogVerification, type AgentMessage, type AgentMessageInfo, type AgentModelRef, type AgentOutputMode, type AgentPathReport, type AgentPathTerminal, type AgentPlanInput, type AgentPlanOutput, type AgentPlanRequest, AgentReplayDivergenceError, AgentReplayMachineMismatchError, type AgentRequest, type AgentRequestExecutor, type AgentRequestExecutorInfo, type AgentRequestExecutorResult, type AgentRequestExecutors, type AgentRequestOptions, type AgentRequestSource, type AgentRun, type AgentRunMeta, type AgentSchemaPack, 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 DecisionLogicConfig, type ExplorePathsOptions, type FilePart, type FromConfigOptions, type FromConfigResult, type GenerateResult, type GetAgentEffectsOptions, type ImagePart, type InferOutput, type InspectedActorRef, type JsonSerializableTraceEvent, type JsonValue, type LintAgentMachineOptions, type MatchTrajectoryOptions, NonSerializableAgentEventError, PLAN_DONE_EVENT_TYPE, type PendingUserInput, type PlanLogic, type ProvideExecutorsOptions, type ReplayOptions, type ReplayResult, type ResolveDecisionOptions, type RunAgentErrorCause, type RunAgentOptions, type RunAgentResult, type RunSeamOptions, type RunSeamResult, type SchemaCompiler, type ScriptedDecisionEntry, type ScriptedDecisionValue, type ScriptedExecutorsScript, type ScriptedTextEntry, 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, createInMemoryEventLogStore, createReplayEntry, createScriptedExecutors, createTextLogic, diffEventLogs, executeAgentRequest, explorePaths, generateResult, getAcceptedEvents, getAgentEffects, getAgentMessages, getAgentOutputMode, getCallUsage, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getStateMeta, initEntry, inspectTransitions, isStandardSchema, lintAgentMachine, matchesTrajectory, messagesSchema, parseAgentEvent, parseModelRef, parseOutput, parseStructuredEnvelope, persistSnapshot, provideExecutors, renderDecisionAttempts, replay, resolveDecision, runAgent, runSeam, serializeTraceEvent, setupAgent, simulateAgent, systemMessage, toolMessage, traceTransitions, userMessage, verifyReplay };
package/dist/otel.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as AgentTraceEvent } from "./run-agent-qkg0evvW.cjs";
1
+ import { c as AgentTraceEvent } from "./run-agent-DnvtcnTZ.cjs";
2
2
  import { Attributes, Tracer, TracerProvider } from "@opentelemetry/api";
3
3
 
4
4
  //#region src/otel/index.d.ts
package/dist/otel.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as AgentTraceEvent } from "./run-agent-B1nBa7aV.mjs";
1
+ import { c as AgentTraceEvent } from "./run-agent-C3mFDGTf.mjs";
2
2
  import { Attributes, Tracer, TracerProvider } from "@opentelemetry/api";
3
3
 
4
4
  //#region src/otel/index.d.ts
@@ -1,6 +1,6 @@
1
1
  import { c as AgentTools, d as ChosenEvent, n as AgentMessage } from "./types-_FXoFBGO.mjs";
2
2
  import { t as AgentError } from "./errors-C9rxnWbX.mjs";
3
- import { M as AgentPlanInput, U as AgentRequestOptions, V as AgentEventDescriptor, W as AgentRequestSource, c as AgentRequestExecutors, d as AgentUsage, f as AgentUserInput, j as AgentDecisionRequest, l as AgentRequestMode, t as AgentCallUsage, u as AgentTextRequest } from "./text-logic-DjR5PUVz.mjs";
3
+ import { G as AgentRequestSource, H as AgentEventDescriptor, M as AgentDecisionRequest, N as AgentPlanInput, W as AgentRequestOptions, d as AgentTextRequest, f as AgentUsage, l as AgentRequestExecutors, p as AgentUserInput, t as AgentCallUsage, u as AgentRequestMode } from "./text-logic-TkKPw8Aq.mjs";
4
4
  import { i as AgentLogEntry, o as JsonValue } from "./event-log-store-CriMgX1D.mjs";
5
5
  import { AnyActorLogic, AnyActorRef, AnyMachineSnapshot, AnyStateMachine, AsyncActorLogic, EmittedFrom, EventFromLogic, EventObject, ExecutableActionObject, InputFrom, InspectionEvent, OutputFrom, Snapshot, SnapshotFrom, createActor } from "xstate";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { c as AgentTools, d as ChosenEvent, n as AgentMessage } from "./types-QbEfCVny.cjs";
2
2
  import { t as AgentError } from "./errors-BQRk9eiZ.cjs";
3
- import { M as AgentPlanInput, U as AgentRequestOptions, V as AgentEventDescriptor, W as AgentRequestSource, c as AgentRequestExecutors, d as AgentUsage, f as AgentUserInput, j as AgentDecisionRequest, l as AgentRequestMode, t as AgentCallUsage, u as AgentTextRequest } from "./text-logic-CorGzucG.cjs";
3
+ import { G as AgentRequestSource, H as AgentEventDescriptor, M as AgentDecisionRequest, N as AgentPlanInput, W as AgentRequestOptions, d as AgentTextRequest, f as AgentUsage, l as AgentRequestExecutors, p as AgentUserInput, t as AgentCallUsage, u as AgentRequestMode } from "./text-logic-BDxwQNsD.cjs";
4
4
  import { i as AgentLogEntry, o as JsonValue } from "./event-log-store-Ruq18mGp.cjs";
5
5
  import { AnyActorLogic, AnyActorRef, AnyMachineSnapshot, AnyStateMachine, AsyncActorLogic, EmittedFrom, EventFromLogic, EventObject, ExecutableActionObject, InputFrom, InspectionEvent, OutputFrom, Snapshot, SnapshotFrom, createActor } from "xstate";
6
6
 
@@ -660,7 +660,12 @@ interface AgentRequestExecutorInfo {
660
660
  */
661
661
  type AiSdkShapedTextResult = {
662
662
  text: string | PromiseLike<string>;
663
- [key: string]: unknown;
663
+ output?: unknown;
664
+ usage?: unknown;
665
+ reasoning?: unknown;
666
+ finishReason?: unknown;
667
+ toolCalls?: unknown;
668
+ toolResults?: unknown;
664
669
  };
665
670
  /**
666
671
  * A raw Vercel AI SDK `streamText` result shape: exposes a `textStream` async
@@ -674,21 +679,55 @@ type AiSdkShapedTextResult = {
674
679
  type AiSdkShapedStreamResult = {
675
680
  textStream: AsyncIterable<string>;
676
681
  text?: PromiseLike<string>;
677
- [key: string]: unknown;
682
+ output?: unknown;
683
+ usage?: unknown;
684
+ reasoning?: unknown;
685
+ finishReason?: unknown;
686
+ toolCalls?: unknown;
687
+ toolResults?: unknown;
678
688
  };
689
+ /**
690
+ * The lowered request as an {@link AgentRequestExecutor} receives it. At
691
+ * runtime this is exactly the {@link AgentTextRequest} core built (plus the
692
+ * merged `tools` map); the TYPE is deliberately shaped so the Vercel AI SDK's
693
+ * own `generateText`/`streamText` are directly assignable as executors
694
+ * (function parameters are contravariant, so this type must be assignable to
695
+ * `ai`'s options type):
696
+ *
697
+ * - `prompt`/`messages` are mutually exclusive, matching `ai`'s `Prompt`
698
+ * union (core always sets exactly one).
699
+ * - `tools`, `toolChoice`, and `messages` are widened to `any` — their
700
+ * portable shapes ({@link AgentTools}, {@link AgentToolChoice},
701
+ * {@link AgentMessage}) are structural supersets of `ai`'s branded types
702
+ * and would otherwise fail the contravariant check.
703
+ *
704
+ * Hand-written executors that want the precise shapes can annotate their
705
+ * parameter as `AgentTextRequest & { tools: AgentTools }` — that wider
706
+ * parameter type keeps the executor assignable.
707
+ */
708
+ type AgentExecutorTextRequest<TMetadata = Record<string, unknown>> = Omit<AgentTextRequest<TMetadata>, "prompt" | "messages" | "tools" | "toolChoice"> & {
709
+ tools: any;
710
+ toolChoice?: any;
711
+ } & ({
712
+ prompt: string;
713
+ messages?: undefined;
714
+ } | {
715
+ prompt?: undefined;
716
+ messages: any[];
717
+ });
679
718
  /**
680
719
  * Host implementation of one text call (`generateText` or `streamText`) —
681
- * resolves a lowered {@link AgentTextRequest} to an `{ output }` envelope (see
682
- * {@link AgentRequestExecutorResult}), unwrapped by
683
- * {@link normalizeGeneratorResult}. The return type is widened to also admit the
684
- * raw Vercel AI SDK shapes ({@link AiSdkShapedTextResult} /
685
- * {@link AiSdkShapedStreamResult}) so `ai`'s own `generateText`/`streamText`
686
- * pass through without a cast; `normalizeGeneratorResult` checks for `{ output }`
687
- * first, then falls back to those shapes at runtime.
688
- */
689
- type AgentRequestExecutor<TResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> = (request: AgentTextRequest & {
690
- tools: AgentTools;
691
- }, info?: AgentRequestExecutorInfo) => PromiseLike<TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult> | TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult;
720
+ * resolves a lowered {@link AgentExecutorTextRequest} to an `{ output }`
721
+ * envelope (see {@link AgentRequestExecutorResult}), unwrapped by
722
+ * {@link normalizeGeneratorResult}. Both sides are shaped so `ai`'s own
723
+ * `generateText`/`streamText` pass through without a cast: the request
724
+ * parameter is assignable to `ai`'s options (see
725
+ * {@link AgentExecutorTextRequest}), and the return type is widened to also
726
+ * admit the raw Vercel AI SDK shapes ({@link AiSdkShapedTextResult} /
727
+ * {@link AiSdkShapedStreamResult}) — `normalizeGeneratorResult` checks for
728
+ * `{ output }` first, then falls back to those shapes at runtime.
729
+ */
730
+ type AgentRequestExecutor<TResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> = (request: AgentExecutorTextRequest, info?: AgentRequestExecutorInfo) => PromiseLike<TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult> | TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult;
692
731
  /**
693
732
  * The full set of host executors a machine's agent actors are resolved
694
733
  * with — passed to `runAgent`, `executeAgentRequest`, and
@@ -751,4 +790,4 @@ declare function buildEnvelopeSchema(inner: StandardSchemaV1, options?: {
751
790
  */
752
791
  declare function parseStructuredEnvelope(request: Pick<AgentTextRequest, "outputSchema" | "reasoning">, value: unknown): StructuredOutputEnvelope;
753
792
  //#endregion
754
- export { AgentDecisionInput as A, resolveDecision as B, createTextLogic as C, parseStructuredEnvelope as D, parseOutput as E, DecisionLogicConfig as F, getAcceptedEvents as G, AgentEventToolNameResolver as H, PLAN_DONE_EVENT_TYPE as I, parseAgentEvent as K, PlanLogic as L, AgentPlanInput as M, AgentPlanOutput as N, AgentDecisionExecutor as O, DecisionAttempt as P, ResolveDecisionOptions as R, buildEnvelopeSchema as S, parseModelRef as T, AgentRequestOptions as U, AgentEventDescriptor as V, AgentRequestSource as W, TextLogic as _, AgentRequestExecutor as a, TextLogicExecutor as b, AgentRequestExecutors as c, AgentUsage as d, AgentUserInput as f, StructuredOutputEnvelope as g, BuiltinAgentActors as h, AgentOutputMode as i, AgentDecisionRequest as j, AgentDecisionExhaustedError as k, AgentRequestMode as l, AiSdkShapedTextResult as m, AgentModelMap as n, AgentRequestExecutorInfo as o, AiSdkShapedStreamResult as p, AgentModelRef as r, AgentRequestExecutorResult as s, AgentCallUsage as t, AgentTextRequest as u, TextLogicConfig as v, getAgentOutputMode as w, bindRequestExecutor as x, TextLogicExecuteArgs as y, renderDecisionAttempts as z };
793
+ export { AgentDecisionExhaustedError as A, renderDecisionAttempts as B, buildEnvelopeSchema as C, parseOutput as D, parseModelRef as E, DecisionAttempt as F, AgentRequestSource as G, AgentEventDescriptor as H, DecisionLogicConfig as I, getAcceptedEvents as K, PLAN_DONE_EVENT_TYPE as L, AgentDecisionRequest as M, AgentPlanInput as N, parseStructuredEnvelope as O, AgentPlanOutput as P, PlanLogic as R, bindRequestExecutor as S, getAgentOutputMode as T, AgentEventToolNameResolver as U, resolveDecision as V, AgentRequestOptions as W, StructuredOutputEnvelope as _, AgentOutputMode as a, TextLogicExecuteArgs as b, AgentRequestExecutorResult as c, AgentTextRequest as d, AgentUsage as f, BuiltinAgentActors as g, AiSdkShapedTextResult as h, AgentModelRef as i, AgentDecisionInput as j, AgentDecisionExecutor as k, AgentRequestExecutors as l, AiSdkShapedStreamResult as m, AgentExecutorTextRequest as n, AgentRequestExecutor as o, AgentUserInput as p, parseAgentEvent as q, AgentModelMap as r, AgentRequestExecutorInfo as s, AgentCallUsage as t, AgentRequestMode as u, TextLogic as v, createTextLogic as w, TextLogicExecutor as x, TextLogicConfig as y, ResolveDecisionOptions as z };
@@ -660,7 +660,12 @@ interface AgentRequestExecutorInfo {
660
660
  */
661
661
  type AiSdkShapedTextResult = {
662
662
  text: string | PromiseLike<string>;
663
- [key: string]: unknown;
663
+ output?: unknown;
664
+ usage?: unknown;
665
+ reasoning?: unknown;
666
+ finishReason?: unknown;
667
+ toolCalls?: unknown;
668
+ toolResults?: unknown;
664
669
  };
665
670
  /**
666
671
  * A raw Vercel AI SDK `streamText` result shape: exposes a `textStream` async
@@ -674,21 +679,55 @@ type AiSdkShapedTextResult = {
674
679
  type AiSdkShapedStreamResult = {
675
680
  textStream: AsyncIterable<string>;
676
681
  text?: PromiseLike<string>;
677
- [key: string]: unknown;
682
+ output?: unknown;
683
+ usage?: unknown;
684
+ reasoning?: unknown;
685
+ finishReason?: unknown;
686
+ toolCalls?: unknown;
687
+ toolResults?: unknown;
678
688
  };
689
+ /**
690
+ * The lowered request as an {@link AgentRequestExecutor} receives it. At
691
+ * runtime this is exactly the {@link AgentTextRequest} core built (plus the
692
+ * merged `tools` map); the TYPE is deliberately shaped so the Vercel AI SDK's
693
+ * own `generateText`/`streamText` are directly assignable as executors
694
+ * (function parameters are contravariant, so this type must be assignable to
695
+ * `ai`'s options type):
696
+ *
697
+ * - `prompt`/`messages` are mutually exclusive, matching `ai`'s `Prompt`
698
+ * union (core always sets exactly one).
699
+ * - `tools`, `toolChoice`, and `messages` are widened to `any` — their
700
+ * portable shapes ({@link AgentTools}, {@link AgentToolChoice},
701
+ * {@link AgentMessage}) are structural supersets of `ai`'s branded types
702
+ * and would otherwise fail the contravariant check.
703
+ *
704
+ * Hand-written executors that want the precise shapes can annotate their
705
+ * parameter as `AgentTextRequest & { tools: AgentTools }` — that wider
706
+ * parameter type keeps the executor assignable.
707
+ */
708
+ type AgentExecutorTextRequest<TMetadata = Record<string, unknown>> = Omit<AgentTextRequest<TMetadata>, "prompt" | "messages" | "tools" | "toolChoice"> & {
709
+ tools: any;
710
+ toolChoice?: any;
711
+ } & ({
712
+ prompt: string;
713
+ messages?: undefined;
714
+ } | {
715
+ prompt?: undefined;
716
+ messages: any[];
717
+ });
679
718
  /**
680
719
  * Host implementation of one text call (`generateText` or `streamText`) —
681
- * resolves a lowered {@link AgentTextRequest} to an `{ output }` envelope (see
682
- * {@link AgentRequestExecutorResult}), unwrapped by
683
- * {@link normalizeGeneratorResult}. The return type is widened to also admit the
684
- * raw Vercel AI SDK shapes ({@link AiSdkShapedTextResult} /
685
- * {@link AiSdkShapedStreamResult}) so `ai`'s own `generateText`/`streamText`
686
- * pass through without a cast; `normalizeGeneratorResult` checks for `{ output }`
687
- * first, then falls back to those shapes at runtime.
688
- */
689
- type AgentRequestExecutor<TResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> = (request: AgentTextRequest & {
690
- tools: AgentTools;
691
- }, info?: AgentRequestExecutorInfo) => PromiseLike<TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult> | TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult;
720
+ * resolves a lowered {@link AgentExecutorTextRequest} to an `{ output }`
721
+ * envelope (see {@link AgentRequestExecutorResult}), unwrapped by
722
+ * {@link normalizeGeneratorResult}. Both sides are shaped so `ai`'s own
723
+ * `generateText`/`streamText` pass through without a cast: the request
724
+ * parameter is assignable to `ai`'s options (see
725
+ * {@link AgentExecutorTextRequest}), and the return type is widened to also
726
+ * admit the raw Vercel AI SDK shapes ({@link AiSdkShapedTextResult} /
727
+ * {@link AiSdkShapedStreamResult}) — `normalizeGeneratorResult` checks for
728
+ * `{ output }` first, then falls back to those shapes at runtime.
729
+ */
730
+ type AgentRequestExecutor<TResult extends AgentRequestExecutorResult = AgentRequestExecutorResult> = (request: AgentExecutorTextRequest, info?: AgentRequestExecutorInfo) => PromiseLike<TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult> | TResult | AiSdkShapedTextResult | AiSdkShapedStreamResult;
692
731
  /**
693
732
  * The full set of host executors a machine's agent actors are resolved
694
733
  * with — passed to `runAgent`, `executeAgentRequest`, and
@@ -751,4 +790,4 @@ declare function buildEnvelopeSchema(inner: StandardSchemaV1, options?: {
751
790
  */
752
791
  declare function parseStructuredEnvelope(request: Pick<AgentTextRequest, "outputSchema" | "reasoning">, value: unknown): StructuredOutputEnvelope;
753
792
  //#endregion
754
- export { AgentDecisionInput as A, resolveDecision as B, createTextLogic as C, parseStructuredEnvelope as D, parseOutput as E, DecisionLogicConfig as F, getAcceptedEvents as G, AgentEventToolNameResolver as H, PLAN_DONE_EVENT_TYPE as I, parseAgentEvent as K, PlanLogic as L, AgentPlanInput as M, AgentPlanOutput as N, AgentDecisionExecutor as O, DecisionAttempt as P, ResolveDecisionOptions as R, buildEnvelopeSchema as S, parseModelRef as T, AgentRequestOptions as U, AgentEventDescriptor as V, AgentRequestSource as W, TextLogic as _, AgentRequestExecutor as a, TextLogicExecutor as b, AgentRequestExecutors as c, AgentUsage as d, AgentUserInput as f, StructuredOutputEnvelope as g, BuiltinAgentActors as h, AgentOutputMode as i, AgentDecisionRequest as j, AgentDecisionExhaustedError as k, AgentRequestMode as l, AiSdkShapedTextResult as m, AgentModelMap as n, AgentRequestExecutorInfo as o, AiSdkShapedStreamResult as p, AgentModelRef as r, AgentRequestExecutorResult as s, AgentCallUsage as t, AgentTextRequest as u, TextLogicConfig as v, getAgentOutputMode as w, bindRequestExecutor as x, TextLogicExecuteArgs as y, renderDecisionAttempts as z };
793
+ export { AgentDecisionExhaustedError as A, renderDecisionAttempts as B, buildEnvelopeSchema as C, parseOutput as D, parseModelRef as E, DecisionAttempt as F, AgentRequestSource as G, AgentEventDescriptor as H, DecisionLogicConfig as I, getAcceptedEvents as K, PLAN_DONE_EVENT_TYPE as L, AgentDecisionRequest as M, AgentPlanInput as N, parseStructuredEnvelope as O, AgentPlanOutput as P, PlanLogic as R, bindRequestExecutor as S, getAgentOutputMode as T, AgentEventToolNameResolver as U, resolveDecision as V, AgentRequestOptions as W, StructuredOutputEnvelope as _, AgentOutputMode as a, TextLogicExecuteArgs as b, AgentRequestExecutorResult as c, AgentTextRequest as d, AgentUsage as f, BuiltinAgentActors as g, AiSdkShapedTextResult as h, AgentModelRef as i, AgentDecisionInput as j, AgentDecisionExecutor as k, AgentRequestExecutors as l, AiSdkShapedStreamResult as m, AgentExecutorTextRequest as n, AgentRequestExecutor as o, AgentUserInput as p, parseAgentEvent as q, AgentModelMap as r, AgentRequestExecutorInfo as s, AgentCallUsage as t, AgentRequestMode as u, TextLogic as v, createTextLogic as w, TextLogicExecutor as x, TextLogicConfig as y, ResolveDecisionOptions as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/agent",
3
- "version": "2.0.0-alpha.12",
3
+ "version": "2.0.0-alpha.13",
4
4
  "description": "Make invalid agent actions impossible. Agent logic as state machines: deterministic, inspectable, resumable, runs anywhere.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -99,7 +99,7 @@
99
99
  "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
100
100
  "@opentelemetry/sdk-trace-base": "^2.10.0",
101
101
  "@opentelemetry/sdk-trace-node": "^2.10.0",
102
- "@statelyai/sdk": "^0.15.0",
102
+ "@statelyai/sdk": "^0.16.2",
103
103
  "@types/express": "^5.0.6",
104
104
  "@types/node": "^20.16.10",
105
105
  "@types/react": "^19.2.17",
@@ -117,6 +117,7 @@
117
117
  "react": "^19.2.7",
118
118
  "tsdown": "^0.21.7",
119
119
  "tsx": "^4.21.0",
120
+ "twoslash": "^0.3.9",
120
121
  "typescript": "^5.6.2",
121
122
  "valibot": "^1.4.2",
122
123
  "vitest": "^3.2.6",
@@ -141,7 +142,9 @@
141
142
  },
142
143
  "scripts": {
143
144
  "build": "tsdown",
145
+ "demo": "pnpm --filter @statelyai/agent-demo dev",
144
146
  "proto:prefabs": "tsx .scratch/prefabs/demo.ts",
147
+ "docs:check": "tsx scripts/check-docs-snippets.ts",
145
148
  "typecheck": "pnpm run typecheck:src && pnpm run typecheck:examples && pnpm run typecheck:example-packages",
146
149
  "typecheck:src": "tsc --noEmit",
147
150
  "typecheck:examples": "tsc -p examples/tsconfig.json --noEmit",
package/readme.md CHANGED
@@ -4,15 +4,17 @@
4
4
 
5
5
  Agent logic as state machines: deterministic, inspectable, resumable, runs anywhere. The machine owns control flow; the model only ever picks a legal event. Testing, inspection, and visualization fall out for free.
6
6
 
7
- Stately Agent adds model requests and decisions to XState. The state machine defines what the agent can do. Your application chooses the model, runs the requests, and stores the state.
7
+ Stately Agent adds model requests and decisions to XState:
8
8
 
9
- Any agent workflow or loop can be modeled as a state machine. Model calls and tools run as effects inside it. The model proposes an event. The machine decides whether it is allowed and what happens next.
9
+ - The machine defines what the agent can do.
10
+ - Your application chooses the model, runs the requests, and stores the state.
11
+ - The model proposes an event; the machine decides whether it is allowed and what happens next.
10
12
 
11
13
  Stately Agent 2 is in alpha. APIs may change before the stable release.
12
14
 
13
15
  [Documentation](https://stately.ai/docs/agents) · [Examples](examples/README.md) · [XState](https://github.com/statelyai/xstate)
14
16
 
15
- ## Three ways to start
17
+ ## Three starting points
16
18
 
17
19
  - **Author a new agent.** Build a machine from states, decisions, and typed requests; run it locally with `runAgent`, test it with no API key, then use it in any framework or runtime with zero machine changes. See the [Quickstart](docs/quickstart.md) and [Use in any stack](docs/any-stack.md).
18
20
  - **Retrofit an existing agent.** Turn a `while` loop into a machine: your SDK calls, tools, and retry code become the executors; the machine replaces only the control flow. See [Migrating from a loop](docs/from-a-loop.md).
@@ -26,7 +28,11 @@ Stately Agent 2 is in alpha. APIs may change before the stable release.
26
28
  pnpm add @statelyai/agent@alpha xstate@alpha zod ai@^6 @ai-sdk/openai@^3
27
29
  ```
28
30
 
29
- Node 22.18 or newer is required. The package is ESM-first (CommonJS builds are published too, so `require()` works) and requires XState v6 alpha.25 or newer. Provider packages must match your `ai` major: `@ai-sdk/openai@^3` pairs with `ai@^6` (a bare `@ai-sdk/openai` resolves to `@latest`, which can mismatch the `ai` peer).
31
+ Requirements:
32
+
33
+ - Node 22.18 or newer, and XState v6 alpha.25 or newer.
34
+ - The package is ESM-first. CommonJS builds are published too, so `require()` works.
35
+ - Provider packages must match your `ai` major: `@ai-sdk/openai@^3` pairs with `ai@^6`. A bare `@ai-sdk/openai` resolves to `@latest`, which can mismatch the `ai` peer.
30
36
 
31
37
  ## Quick start
32
38
 
@@ -114,7 +120,7 @@ When the machine reaches `refunded`, the result is:
114
120
 
115
121
  The model chooses between the events allowed in `deciding`. The `AUTO_REFUND` transition only works when the amount is at most $100. If the model chooses it for a larger amount, the guard rejects the choice and the decision is tried again.
116
122
 
117
- **Run it with no API key.** `createScriptedExecutors` plays back canned answers through the same executor contract, so the machine above runs end to end before a model is involved:
123
+ `createScriptedExecutors` plays back canned answers through the same executor contract, so the machine above runs end to end before a model is involved. **No API key needed:**
118
124
 
119
125
  ```ts
120
126
  import { createScriptedExecutors } from "@statelyai/agent";
@@ -127,11 +133,21 @@ const result = await runAgent(refundMachine, {
127
133
 
128
134
  Swap in `createAiSdkExecutors({ models })` when you want a real model. The scripted set is what your tests keep using.
129
135
 
130
- ## The state machine
136
+ ## Architecture
137
+
138
+ ```mermaid
139
+ flowchart LR
140
+ M["Agent machine<br/>states · guards · requests"] -->|request| R["runAgent"]
141
+ R -->|executor call| E["Host executors<br/>generateText · streamText · decide"]
142
+ E -->|API call| L["Model"]
143
+ L -->|result| E
144
+ E -->|result| R
145
+ R -->|event or output| M
146
+ ```
131
147
 
132
- <!-- Add the state machine illustration here. -->
148
+ The machine never talks to a model directly, so swapping `createAiSdkExecutors` for `createScriptedExecutors` (or your own functions) changes nothing about the agent.
133
149
 
134
- The example has one model decision and two final outcomes. Real machines can add approval states, retries, parallel work, child agents, and long-running waits without changing how the control flow is represented.
150
+ The example above has one model decision and two final outcomes. Real machines add approval states, retries, parallel work, child agents, and long-running waits without changing how control flow is represented.
135
151
 
136
152
  ## Core concepts
137
153