@statelyai/agent 2.0.0-alpha.21 → 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 CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_decision = require("./decision-BnTCsuJv.cjs");
2
+ const require_decision = require("./decision-1o45_ZrS.cjs");
3
3
  require("./validate.cjs");
4
4
  let ai = require("ai");
5
5
  //#region src/ai-sdk/mappers.ts
package/dist/ai-sdk.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { d as ChosenEvent } from "./types-DSdj2tGs.cjs";
2
- import { A as AgentDecisionExecutor, N as AgentDecisionRequest, d as AgentTextRequest, l as AgentRequestExecutors, o as AgentRequestExecutor, t as AgentCallUsage } from "./text-logic-Mmbgb2jy.cjs";
2
+ import { A as AgentDecisionExecutor, N as AgentDecisionRequest, d as AgentTextRequest, l as AgentRequestExecutors, o as AgentRequestExecutor, t as AgentCallUsage } from "./text-logic-BaxPrcLk.cjs";
3
3
  import { FinishReason, LanguageModel, LanguageModelUsage, ToolSet, TypedToolCall, TypedToolResult, generateText } from "ai";
4
4
 
5
5
  //#region src/ai-sdk/mappers.d.ts
package/dist/ai-sdk.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { d as ChosenEvent } from "./types-CvWRGFxP.mjs";
2
- import { A as AgentDecisionExecutor, N as AgentDecisionRequest, d as AgentTextRequest, l as AgentRequestExecutors, o as AgentRequestExecutor, t as AgentCallUsage } from "./text-logic-BR5twXCv.mjs";
2
+ import { A as AgentDecisionExecutor, N as AgentDecisionRequest, d as AgentTextRequest, l as AgentRequestExecutors, o as AgentRequestExecutor, t as AgentCallUsage } from "./text-logic-DhfFWzu9.mjs";
3
3
  import { FinishReason, LanguageModel, LanguageModelUsage, ToolSet, TypedToolCall, TypedToolResult, generateText } from "ai";
4
4
 
5
5
  //#region src/ai-sdk/mappers.d.ts
package/dist/ai-sdk.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as isStandardSchema, h as buildEnvelopeSchema, i as renderDecisionAttempts, y as getAgentOutputMode } from "./decision-JWx6n3xR.mjs";
1
+ import { G as isStandardSchema, a as renderDecisionAttempts, b as getAgentOutputMode, g as buildEnvelopeSchema } from "./decision-DxSTqzgZ.mjs";
2
2
  import { NoObjectGeneratedError, Output, generateText, stepCountIs, streamText, tool } from "ai";
3
3
  //#region src/ai-sdk/mappers.ts
4
4
  /**
@@ -363,6 +363,13 @@ function getCallUsage(raw) {
363
363
  }
364
364
  return out;
365
365
  }
366
+ function textRequestSourceIssue(request) {
367
+ const hasPrompt = typeof request.prompt === "string" && request.prompt.length > 0;
368
+ const hasMessages = Array.isArray(request.messages) && request.messages.length > 0;
369
+ const label = request.name ? ` '${request.name}'` : "";
370
+ if (hasPrompt && hasMessages) return `Agent text request${label} has both a non-empty \`prompt\` and \`messages\` — provide exactly one so the model has a single input source.`;
371
+ if (!hasPrompt && !hasMessages) return `Agent text request${label} has neither a non-empty \`prompt\` nor \`messages\` — provide at least one so the model has something to respond to.`;
372
+ }
366
373
  const agentTextInputSchema = { "~standard": {
367
374
  version: 1,
368
375
  vendor: "statelyai-agent",
@@ -370,9 +377,8 @@ const agentTextInputSchema = { "~standard": {
370
377
  if (!value || typeof value !== "object") return { issues: [{ message: "Expected agent text input object" }] };
371
378
  const request = value;
372
379
  if (typeof request.model !== "string") return { issues: [{ message: "Expected agent text input with a string `model`" }] };
373
- const hasPrompt = typeof request.prompt === "string" && request.prompt.length > 0;
374
- const hasMessages = Array.isArray(request.messages) && request.messages.length > 0;
375
- if (!hasPrompt && !hasMessages) return { issues: [{ message: `Agent text request${request.name ? ` '${request.name}'` : ""} has neither a non-empty \`prompt\` nor \`messages\` — provide at least one so the model has something to respond to.` }] };
380
+ const issue = textRequestSourceIssue(request);
381
+ if (issue) return { issues: [{ message: issue }] };
376
382
  return { value: request };
377
383
  }
378
384
  } };
@@ -487,12 +493,21 @@ function createTextLogic(config, execute) {
487
493
  };
488
494
  const request = (input) => {
489
495
  const args = { input: validateSchemaSync(schemas.input, input) };
496
+ const name = resolveTextLogicValue(config.name, args);
497
+ const prompt = resolveTextLogicValue(config.prompt, args);
498
+ const messages = resolveTextLogicValue(config.messages, args);
499
+ const sourceIssue = textRequestSourceIssue({
500
+ name,
501
+ prompt,
502
+ messages
503
+ });
504
+ if (sourceIssue) throw new Error(sourceIssue);
490
505
  return {
491
- name: resolveTextLogicValue(config.name, args),
506
+ name,
492
507
  model: resolveTextLogicValue(config.model, args),
493
508
  system: resolveTextLogicValue(config.system, args),
494
- prompt: resolveTextLogicValue(config.prompt, args),
495
- messages: resolveTextLogicValue(config.messages, args),
509
+ prompt,
510
+ messages,
496
511
  tools: resolveTextLogicValue(config.tools, args),
497
512
  toolChoice: resolveTextLogicValue(config.toolChoice, args),
498
513
  outputSchema: schemas.output,
@@ -663,6 +678,8 @@ async function executeAgentTextRequest(mode, id, input, executors, tools = {}, i
663
678
  ...tools
664
679
  }
665
680
  };
681
+ const sourceIssue = textRequestSourceIssue(request);
682
+ if (sourceIssue) throw new Error(sourceIssue);
666
683
  const executor = mode === "stream" ? executors.streamText : executors.generateText;
667
684
  if (!executor) throw new Error(`No executor provided for ${mode === "stream" ? "stream" : "generate"} request '${id}'.`);
668
685
  const raw = await executor(request, info);
@@ -911,6 +928,82 @@ function resolveAllowedEventTypes(allowedEvents, input) {
911
928
  const resolved = typeof allowedEvents === "function" ? allowedEvents({ input }) : allowedEvents;
912
929
  return typeof resolved === "string" ? [resolved] : resolved;
913
930
  }
931
+ /**
932
+ * Creates reusable, standalone {@link DecisionLogic}: an actor that, when
933
+ * run, resolves to exactly one currently-legal {@link ChosenEvent} by
934
+ * calling the host `decide` executor (passed here as `execute`, or supplied
935
+ * later via {@link DecisionLogic.withExecutor}, `machine.provide(...)`, or
936
+ * `runAgent`'s `decide` option). Register the result under `actors:` and
937
+ * invoke it by name; for a one-off, state-local decision, prefer the
938
+ * `agent.decide` builtin invoke instead — it needs no separate declaration
939
+ * and types `allowedEvents` against the machine's own event schemas.
940
+ *
941
+ * @example
942
+ * ```ts
943
+ * import { createDecisionLogic } from '@statelyai/agent';
944
+ * import { z } from 'zod';
945
+ *
946
+ * export const chooseMove = createDecisionLogic({
947
+ * schemas: { input: z.object({ playerHp: z.number(), enemyHp: z.number() }) },
948
+ * model: 'openai/gpt-5.4-mini',
949
+ * system: 'You are playing a turn-based game. Choose exactly one legal move.',
950
+ * prompt: ({ input }) => `Player HP: ${input.playerHp}\nEnemy HP: ${input.enemyHp}`,
951
+ * allowedEvents: ({ input }) =>
952
+ * input.playerHp <= 6
953
+ * ? ['ATTACK', 'DEFEND', 'HEAL', 'FLEE']
954
+ * : ['ATTACK', 'DEFEND', 'FLEE'],
955
+ * });
956
+ * ```
957
+ */
958
+ function createDecisionLogic(config, execute) {
959
+ const maxRetries = config.maxRetries ?? 2;
960
+ const request = (input) => {
961
+ const parsedInput = config.schemas ? validateSchemaSync(config.schemas.input, input) : input;
962
+ const args = { input: parsedInput };
963
+ const allowedEventTypes = resolveAllowedEventTypes(config.allowedEvents, parsedInput);
964
+ return {
965
+ kind: "decision",
966
+ id: "",
967
+ model: resolveTextLogicValue(config.model, args),
968
+ system: resolveTextLogicValue(config.system, args),
969
+ prompt: resolveTextLogicValue(config.prompt, args),
970
+ messages: resolveTextLogicValue(config.messages, args),
971
+ events: (allowedEventTypes ?? []).map((type) => ({
972
+ type,
973
+ toolName: sanitizeEventToolName(type)
974
+ })),
975
+ attempts: [],
976
+ temperature: resolveTextLogicValue(config.temperature, args),
977
+ maxOutputTokens: resolveTextLogicValue(config.maxOutputTokens, args),
978
+ topP: resolveTextLogicValue(config.topP, args),
979
+ topK: resolveTextLogicValue(config.topK, args),
980
+ seed: resolveTextLogicValue(config.seed, args),
981
+ stopSequences: resolveTextLogicValue(config.stopSequences, args),
982
+ metadata: resolveTextLogicValue(config.metadata, args)
983
+ };
984
+ };
985
+ const logic = (0, xstate.createAsyncLogic)({ run: async ({ input, signal }) => {
986
+ if (!execute) throw new Error("Decision logic has no host execution. Pass an executor as the second argument to createDecisionLogic(...), provide a runtime adapter, or extract it with getAgentEffects(..., { actors }) and resolveDecision(...).");
987
+ const allowedEventTypes = resolveAllowedEventTypes(config.allowedEvents, input);
988
+ if (allowedEventTypes === void 0) throw new Error("Decision logic has omitted `allowedEvents`, which means \"all currently-legal events\" — but that requires a snapshot-aware host (runAgent or the step path) to resolve. Under a bare createActor(...), declare `allowedEvents` explicitly on this logic to use it here.");
989
+ if (allowedEventTypes.some(isEventPattern)) throw new Error("Decision logic uses wildcard `allowedEvents` patterns, which expand against the live snapshot — that requires a snapshot-aware host (runAgent or the step path). Under a bare createActor(...), list event types explicitly.");
990
+ return resolveDecision(request(input), { decide: execute }, {
991
+ maxRetries,
992
+ signal
993
+ });
994
+ } });
995
+ const decisionLogic = Object.assign(logic, {
996
+ kind: "statelyai.decisionLogic",
997
+ maxRetries,
998
+ request,
999
+ allowedEventTypes: (input) => resolveAllowedEventTypes(config.allowedEvents, input),
1000
+ withExecutor(nextExecute) {
1001
+ return createDecisionLogic(config, nextExecute);
1002
+ }
1003
+ });
1004
+ if (execute) executorBoundLogics.add(decisionLogic);
1005
+ return decisionLogic;
1006
+ }
914
1007
  /** Type guard: true for any actor logic built by createDecisionLogic/createDecideActor (checks the `kind` marker). @internal */
915
1008
  function isDecisionLogic(value) {
916
1009
  return !!value && typeof value === "object" && value.kind === "statelyai.decisionLogic" && typeof value.request === "function";
@@ -1108,6 +1201,12 @@ Object.defineProperty(exports, "createDecideActor", {
1108
1201
  return createDecideActor;
1109
1202
  }
1110
1203
  });
1204
+ Object.defineProperty(exports, "createDecisionLogic", {
1205
+ enumerable: true,
1206
+ get: function() {
1207
+ return createDecisionLogic;
1208
+ }
1209
+ });
1111
1210
  Object.defineProperty(exports, "createTextLogic", {
1112
1211
  enumerable: true,
1113
1212
  get: function() {
@@ -362,6 +362,13 @@ function getCallUsage(raw) {
362
362
  }
363
363
  return out;
364
364
  }
365
+ function textRequestSourceIssue(request) {
366
+ const hasPrompt = typeof request.prompt === "string" && request.prompt.length > 0;
367
+ const hasMessages = Array.isArray(request.messages) && request.messages.length > 0;
368
+ const label = request.name ? ` '${request.name}'` : "";
369
+ if (hasPrompt && hasMessages) return `Agent text request${label} has both a non-empty \`prompt\` and \`messages\` — provide exactly one so the model has a single input source.`;
370
+ if (!hasPrompt && !hasMessages) return `Agent text request${label} has neither a non-empty \`prompt\` nor \`messages\` — provide at least one so the model has something to respond to.`;
371
+ }
365
372
  const agentTextInputSchema = { "~standard": {
366
373
  version: 1,
367
374
  vendor: "statelyai-agent",
@@ -369,9 +376,8 @@ const agentTextInputSchema = { "~standard": {
369
376
  if (!value || typeof value !== "object") return { issues: [{ message: "Expected agent text input object" }] };
370
377
  const request = value;
371
378
  if (typeof request.model !== "string") return { issues: [{ message: "Expected agent text input with a string `model`" }] };
372
- const hasPrompt = typeof request.prompt === "string" && request.prompt.length > 0;
373
- const hasMessages = Array.isArray(request.messages) && request.messages.length > 0;
374
- if (!hasPrompt && !hasMessages) return { issues: [{ message: `Agent text request${request.name ? ` '${request.name}'` : ""} has neither a non-empty \`prompt\` nor \`messages\` — provide at least one so the model has something to respond to.` }] };
379
+ const issue = textRequestSourceIssue(request);
380
+ if (issue) return { issues: [{ message: issue }] };
375
381
  return { value: request };
376
382
  }
377
383
  } };
@@ -486,12 +492,21 @@ function createTextLogic(config, execute) {
486
492
  };
487
493
  const request = (input) => {
488
494
  const args = { input: validateSchemaSync(schemas.input, input) };
495
+ const name = resolveTextLogicValue(config.name, args);
496
+ const prompt = resolveTextLogicValue(config.prompt, args);
497
+ const messages = resolveTextLogicValue(config.messages, args);
498
+ const sourceIssue = textRequestSourceIssue({
499
+ name,
500
+ prompt,
501
+ messages
502
+ });
503
+ if (sourceIssue) throw new Error(sourceIssue);
489
504
  return {
490
- name: resolveTextLogicValue(config.name, args),
505
+ name,
491
506
  model: resolveTextLogicValue(config.model, args),
492
507
  system: resolveTextLogicValue(config.system, args),
493
- prompt: resolveTextLogicValue(config.prompt, args),
494
- messages: resolveTextLogicValue(config.messages, args),
508
+ prompt,
509
+ messages,
495
510
  tools: resolveTextLogicValue(config.tools, args),
496
511
  toolChoice: resolveTextLogicValue(config.toolChoice, args),
497
512
  outputSchema: schemas.output,
@@ -662,6 +677,8 @@ async function executeAgentTextRequest(mode, id, input, executors, tools = {}, i
662
677
  ...tools
663
678
  }
664
679
  };
680
+ const sourceIssue = textRequestSourceIssue(request);
681
+ if (sourceIssue) throw new Error(sourceIssue);
665
682
  const executor = mode === "stream" ? executors.streamText : executors.generateText;
666
683
  if (!executor) throw new Error(`No executor provided for ${mode === "stream" ? "stream" : "generate"} request '${id}'.`);
667
684
  const raw = await executor(request, info);
@@ -910,6 +927,82 @@ function resolveAllowedEventTypes(allowedEvents, input) {
910
927
  const resolved = typeof allowedEvents === "function" ? allowedEvents({ input }) : allowedEvents;
911
928
  return typeof resolved === "string" ? [resolved] : resolved;
912
929
  }
930
+ /**
931
+ * Creates reusable, standalone {@link DecisionLogic}: an actor that, when
932
+ * run, resolves to exactly one currently-legal {@link ChosenEvent} by
933
+ * calling the host `decide` executor (passed here as `execute`, or supplied
934
+ * later via {@link DecisionLogic.withExecutor}, `machine.provide(...)`, or
935
+ * `runAgent`'s `decide` option). Register the result under `actors:` and
936
+ * invoke it by name; for a one-off, state-local decision, prefer the
937
+ * `agent.decide` builtin invoke instead — it needs no separate declaration
938
+ * and types `allowedEvents` against the machine's own event schemas.
939
+ *
940
+ * @example
941
+ * ```ts
942
+ * import { createDecisionLogic } from '@statelyai/agent';
943
+ * import { z } from 'zod';
944
+ *
945
+ * export const chooseMove = createDecisionLogic({
946
+ * schemas: { input: z.object({ playerHp: z.number(), enemyHp: z.number() }) },
947
+ * model: 'openai/gpt-5.4-mini',
948
+ * system: 'You are playing a turn-based game. Choose exactly one legal move.',
949
+ * prompt: ({ input }) => `Player HP: ${input.playerHp}\nEnemy HP: ${input.enemyHp}`,
950
+ * allowedEvents: ({ input }) =>
951
+ * input.playerHp <= 6
952
+ * ? ['ATTACK', 'DEFEND', 'HEAL', 'FLEE']
953
+ * : ['ATTACK', 'DEFEND', 'FLEE'],
954
+ * });
955
+ * ```
956
+ */
957
+ function createDecisionLogic(config, execute) {
958
+ const maxRetries = config.maxRetries ?? 2;
959
+ const request = (input) => {
960
+ const parsedInput = config.schemas ? validateSchemaSync(config.schemas.input, input) : input;
961
+ const args = { input: parsedInput };
962
+ const allowedEventTypes = resolveAllowedEventTypes(config.allowedEvents, parsedInput);
963
+ return {
964
+ kind: "decision",
965
+ id: "",
966
+ model: resolveTextLogicValue(config.model, args),
967
+ system: resolveTextLogicValue(config.system, args),
968
+ prompt: resolveTextLogicValue(config.prompt, args),
969
+ messages: resolveTextLogicValue(config.messages, args),
970
+ events: (allowedEventTypes ?? []).map((type) => ({
971
+ type,
972
+ toolName: sanitizeEventToolName(type)
973
+ })),
974
+ attempts: [],
975
+ temperature: resolveTextLogicValue(config.temperature, args),
976
+ maxOutputTokens: resolveTextLogicValue(config.maxOutputTokens, args),
977
+ topP: resolveTextLogicValue(config.topP, args),
978
+ topK: resolveTextLogicValue(config.topK, args),
979
+ seed: resolveTextLogicValue(config.seed, args),
980
+ stopSequences: resolveTextLogicValue(config.stopSequences, args),
981
+ metadata: resolveTextLogicValue(config.metadata, args)
982
+ };
983
+ };
984
+ const logic = createAsyncLogic({ run: async ({ input, signal }) => {
985
+ if (!execute) throw new Error("Decision logic has no host execution. Pass an executor as the second argument to createDecisionLogic(...), provide a runtime adapter, or extract it with getAgentEffects(..., { actors }) and resolveDecision(...).");
986
+ const allowedEventTypes = resolveAllowedEventTypes(config.allowedEvents, input);
987
+ if (allowedEventTypes === void 0) throw new Error("Decision logic has omitted `allowedEvents`, which means \"all currently-legal events\" — but that requires a snapshot-aware host (runAgent or the step path) to resolve. Under a bare createActor(...), declare `allowedEvents` explicitly on this logic to use it here.");
988
+ if (allowedEventTypes.some(isEventPattern)) throw new Error("Decision logic uses wildcard `allowedEvents` patterns, which expand against the live snapshot — that requires a snapshot-aware host (runAgent or the step path). Under a bare createActor(...), list event types explicitly.");
989
+ return resolveDecision(request(input), { decide: execute }, {
990
+ maxRetries,
991
+ signal
992
+ });
993
+ } });
994
+ const decisionLogic = Object.assign(logic, {
995
+ kind: "statelyai.decisionLogic",
996
+ maxRetries,
997
+ request,
998
+ allowedEventTypes: (input) => resolveAllowedEventTypes(config.allowedEvents, input),
999
+ withExecutor(nextExecute) {
1000
+ return createDecisionLogic(config, nextExecute);
1001
+ }
1002
+ });
1003
+ if (execute) executorBoundLogics.add(decisionLogic);
1004
+ return decisionLogic;
1005
+ }
913
1006
  /** Type guard: true for any actor logic built by createDecisionLogic/createDecideActor (checks the `kind` marker). @internal */
914
1007
  function isDecisionLogic(value) {
915
1008
  return !!value && typeof value === "object" && value.kind === "statelyai.decisionLogic" && typeof value.request === "function";
@@ -1029,4 +1122,4 @@ async function resolveDecision(request, executors, options = {}) {
1029
1122
  throw new AgentDecisionExhaustedError(attempts);
1030
1123
  }
1031
1124
  //#endregion
1032
- export { getMachineStaticTransitionTargets as A, getJsonSchema as B, parseModelRef as C, agentExecutionOptions as D, userInputActor as E, missingActor as F, resolveMachineVersion as G, getMachineStructuralHash as H, assistantMessage as I, userMessage as J, systemMessage as K, djb2Hex as L, isUnboundPlaceholder as M, machineIdlePredicates as N, executorBoundLogics as O, machineStaticTransitionTargets as P, findNonSerializableContextPaths as R, normalizeGeneratorResult as S, parseStructuredEnvelope as T, getStateMeta as U, getJsonSchemaSync as V, isStandardSchema as W, validateSchemaSync as Y, createTextLogic as _, resolveDecision as a, getCallUsage as b, AGENT_USAGE_TOKEN_FIELDS as c, INTERPRET_SOURCE as d, STREAM_TEXT_ACTOR as f, builtinTextActors as g, buildEnvelopeSchema as h, renderDecisionAttempts as i, getRegisteredAgentExecutionOptions as j, getMachineIdlePredicate as k, DECIDE_ACTOR as l, bindRequestExecutor as m, createDecideActor as n, getAcceptedEvents as o, USER_INPUT_ACTOR as p, toolMessage as q, isDecisionLogic as r, parseAgentEvent as s, AgentDecisionExhaustedError as t, GENERATE_TEXT_ACTOR as u, executeAgentTextRequest as v, parseOutput as w, isTextLogic as x, getAgentOutputMode as y, getAgentMessages as z };
1125
+ export { getMachineIdlePredicate as A, getAgentMessages as B, normalizeGeneratorResult as C, userInputActor as D, parseStructuredEnvelope as E, machineStaticTransitionTargets as F, isStandardSchema as G, getJsonSchemaSync as H, missingActor as I, toolMessage as J, resolveMachineVersion as K, assistantMessage as L, getRegisteredAgentExecutionOptions as M, isUnboundPlaceholder as N, agentExecutionOptions as O, machineIdlePredicates as P, djb2Hex as R, isTextLogic as S, parseOutput as T, getMachineStructuralHash as U, getJsonSchema as V, getStateMeta as W, validateSchemaSync as X, userMessage as Y, builtinTextActors as _, renderDecisionAttempts as a, getAgentOutputMode as b, parseAgentEvent as c, GENERATE_TEXT_ACTOR as d, INTERPRET_SOURCE as f, buildEnvelopeSchema as g, bindRequestExecutor as h, isDecisionLogic as i, getMachineStaticTransitionTargets as j, executorBoundLogics as k, AGENT_USAGE_TOKEN_FIELDS as l, USER_INPUT_ACTOR as m, createDecideActor as n, resolveDecision as o, STREAM_TEXT_ACTOR as p, systemMessage as q, createDecisionLogic as r, getAcceptedEvents as s, AgentDecisionExhaustedError as t, DECIDE_ACTOR as u, createTextLogic as v, parseModelRef as w, getCallUsage as x, executeAgentTextRequest as y, findNonSerializableContextPaths as z };
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors = require("./errors-DUBBzRLP.cjs");
3
- const require_setup_agent = require("./setup-agent-91FSuZbB.cjs");
4
- const require_decision = require("./decision-BnTCsuJv.cjs");
3
+ const require_setup_agent = require("./setup-agent-DkCTy5Eu.cjs");
4
+ const require_decision = require("./decision-1o45_ZrS.cjs");
5
5
  const require_event_log_store = require("./event-log-store-a_TKy1gk.cjs");
6
6
  require("./validate.cjs");
7
7
  let xstate = require("xstate");
@@ -3208,6 +3208,7 @@ exports.canReach = canReach;
3208
3208
  exports.createAgentActor = createAgentActor;
3209
3209
  exports.createAgentRun = createAgentRun;
3210
3210
  exports.createAgentSchemas = require_setup_agent.createAgentSchemas;
3211
+ exports.createDecisionLogic = require_decision.createDecisionLogic;
3211
3212
  exports.createInMemoryEventLogStore = require_event_log_store.createInMemoryEventLogStore;
3212
3213
  exports.createReplayEntry = require_setup_agent.createReplayEntry;
3213
3214
  exports.createScriptedExecutors = createScriptedExecutors;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
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 AgentEventToolNameResolver, C as buildEnvelopeSchema, D as parseModelRef, E as getCallUsage, F as DecisionLogicConfig, G as parseAgentEvent, H as AgentRequestSource, I as ResolveDecisionOptions, L as renderDecisionAttempts, M as AgentDecisionInput, N as AgentDecisionRequest, O as parseOutput, P as DecisionAttempt, R as resolveDecision, S as bindRequestExecutor, T as getAgentOutputMode, U as AgentSchemas, V as AgentRequestOptions, W as getAcceptedEvents, _ 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, 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 AgentEventDescriptor } from "./text-logic-Mmbgb2jy.cjs";
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-Do094mGu.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-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 with a known `type`. Use it directly as a context
44
- * schema's `messages` field when authoring with `createAgentSchemas`.
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
@@ -1501,4 +1502,4 @@ type DurableAgentResult<TMachine extends AnyStateMachine> = {
1501
1502
  */
1502
1503
  declare function runDurableAgent<TMachine extends AnyStateMachine>(machine: TMachine, options?: RunDurableAgentOptions<TMachine>): Promise<DurableAgentResult<TMachine>>;
1503
1504
  //#endregion
1504
- 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 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, 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
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 AgentEventToolNameResolver, C as buildEnvelopeSchema, D as parseModelRef, E as getCallUsage, F as DecisionLogicConfig, G as parseAgentEvent, H as AgentRequestSource, I as ResolveDecisionOptions, L as renderDecisionAttempts, M as AgentDecisionInput, N as AgentDecisionRequest, O as parseOutput, P as DecisionAttempt, R as resolveDecision, S as bindRequestExecutor, T as getAgentOutputMode, U as AgentSchemas, V as AgentRequestOptions, W as getAcceptedEvents, _ 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, 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 AgentEventDescriptor } from "./text-logic-BR5twXCv.mjs";
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-DBNI8ETM.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-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 with a known `type`. Use it directly as a context
44
- * schema's `messages` field when authoring with `createAgentSchemas`.
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
@@ -1501,4 +1502,4 @@ type DurableAgentResult<TMachine extends AnyStateMachine> = {
1501
1502
  */
1502
1503
  declare function runDurableAgent<TMachine extends AnyStateMachine>(machine: TMachine, options?: RunDurableAgentOptions<TMachine>): Promise<DurableAgentResult<TMachine>>;
1503
1504
  //#endregion
1504
- 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 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, 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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as AgentError } from "./errors-CeSXQx0v.mjs";
2
- import { _ as resolveAgentStep, a as AGENT_USAGE_EVENT_TYPE, b as messagesSchema, c as createReplayEntry, d as initEntry, f as replay, g as initialAgentStep, h as getInvokeEffectMetadata, i as AGENT_INIT_EVENT_TYPE, l as diffEventLogs, m as executeAgentRequest, n as getAgentSchemas, o as AgentReplayDivergenceError, p as validateReplayEntries, r as setupAgent, s as AgentReplayMachineMismatchError, t as createAgentSchemas, u as getAgentEffects, v as transitionAgentStep, y as appendMessages } from "./setup-agent-DqqdcdNh.mjs";
3
- import { A as getMachineStaticTransitionTargets, B as getJsonSchema, C as parseModelRef, G as resolveMachineVersion, H as getMachineStructuralHash, I as assistantMessage, J as userMessage, K as systemMessage, M as isUnboundPlaceholder, O as executorBoundLogics, R as findNonSerializableContextPaths, S as normalizeGeneratorResult, T as parseStructuredEnvelope, U as getStateMeta, V as getJsonSchemaSync, W as isStandardSchema, Y as validateSchemaSync, _ as createTextLogic, a as resolveDecision, b as getCallUsage, c as AGENT_USAGE_TOKEN_FIELDS, d as INTERPRET_SOURCE, h as buildEnvelopeSchema, i as renderDecisionAttempts, j as getRegisteredAgentExecutionOptions, k as getMachineIdlePredicate, m as bindRequestExecutor, o as getAcceptedEvents, q as toolMessage, r as isDecisionLogic, s as parseAgentEvent, t as AgentDecisionExhaustedError, w as parseOutput, x as isTextLogic, y as getAgentOutputMode, z as getAgentMessages } from "./decision-JWx6n3xR.mjs";
2
+ import { _ as resolveAgentStep, a as AGENT_USAGE_EVENT_TYPE, b as messagesSchema, c as createReplayEntry, d as initEntry, f as replay, g as initialAgentStep, h as getInvokeEffectMetadata, i as AGENT_INIT_EVENT_TYPE, l as diffEventLogs, m as executeAgentRequest, n as getAgentSchemas, o as AgentReplayDivergenceError, p as validateReplayEntries, r as setupAgent, s as AgentReplayMachineMismatchError, t as createAgentSchemas, u as getAgentEffects, v as transitionAgentStep, y as appendMessages } from "./setup-agent-nSFYrNTP.mjs";
3
+ import { A as getMachineIdlePredicate, B as getAgentMessages, C as normalizeGeneratorResult, E as parseStructuredEnvelope, G as isStandardSchema, H as getJsonSchemaSync, J as toolMessage, K as resolveMachineVersion, L as assistantMessage, M as getRegisteredAgentExecutionOptions, N as isUnboundPlaceholder, S as isTextLogic, T as parseOutput, U as getMachineStructuralHash, V as getJsonSchema, W as getStateMeta, X as validateSchemaSync, Y as userMessage, a as renderDecisionAttempts, b as getAgentOutputMode, c as parseAgentEvent, f as INTERPRET_SOURCE, g as buildEnvelopeSchema, h as bindRequestExecutor, i as isDecisionLogic, j as getMachineStaticTransitionTargets, k as executorBoundLogics, l as AGENT_USAGE_TOKEN_FIELDS, o as resolveDecision, q as systemMessage, r as createDecisionLogic, s as getAcceptedEvents, t as AgentDecisionExhaustedError, v as createTextLogic, w as parseModelRef, x as getCallUsage, z as findNonSerializableContextPaths } from "./decision-DxSTqzgZ.mjs";
4
4
  import { a as assertJsonSerializable, i as assertAgentLogEntry, n as AgentEventLogConflictError, o as createInMemoryEventLogStore, r as NonSerializableAgentEventError, s as assertEventLogStoreConformance, t as AGENT_EVENT_SCHEMA_VERSION } from "./event-log-store-DmIDosD6.mjs";
5
5
  import { createActor, createAsyncLogic, deliverEvent, getNextTransitions, isMachineSnapshot } from "xstate";
6
6
  import { createDurable } from "xstate/durable";
@@ -3179,4 +3179,4 @@ async function runDurableAgent(machine, options = {}) {
3179
3179
  }
3180
3180
  }
3181
3181
  //#endregion
3182
- export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, AgentDecisionExhaustedError, AgentError, AgentEventLogConflictError, AgentIdleError, AgentIllegalResumeEventError, AgentLintError, AgentMaxModelCallsExceededError, AgentReplayDivergenceError, AgentReplayMachineMismatchError, AgentSnapshotVersionMismatchError, NonSerializableAgentEventError, appendMessages, assertAgentLogEntry, assertAgentMachine, 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 };
3182
+ export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, AgentDecisionExhaustedError, AgentError, AgentEventLogConflictError, AgentIdleError, AgentIllegalResumeEventError, AgentLintError, AgentMaxModelCallsExceededError, AgentReplayDivergenceError, AgentReplayMachineMismatchError, AgentSnapshotVersionMismatchError, NonSerializableAgentEventError, 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/machines.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_setup_agent = require("./setup-agent-91FSuZbB.cjs");
2
+ const require_setup_agent = require("./setup-agent-DkCTy5Eu.cjs");
3
3
  //#region src/machines/internal.ts
4
4
  /** The builtin inline text request every preset lowers a request entry to. */
5
5
  const GENERATE_TEXT_SRC = "agent.generateText";