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

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.
Files changed (31) hide show
  1. package/dist/ai-sdk.cjs +1 -1
  2. package/dist/ai-sdk.d.cts +2 -2
  3. package/dist/ai-sdk.d.mts +2 -2
  4. package/dist/ai-sdk.mjs +1 -1
  5. package/dist/{decision-dWGhBh0P.cjs → decision-C0cUKvNt.cjs} +0 -105
  6. package/dist/{decision-BezSD_YC.mjs → decision-D9Zi7Xi5.mjs} +2 -65
  7. package/dist/index.cjs +52 -155
  8. package/dist/index.d.cts +26 -13
  9. package/dist/index.d.mts +26 -13
  10. package/dist/index.mjs +54 -156
  11. package/dist/machines.cjs +1 -1
  12. package/dist/machines.d.cts +1 -1
  13. package/dist/machines.d.mts +1 -1
  14. package/dist/machines.mjs +1 -1
  15. package/dist/otel.cjs +5 -15
  16. package/dist/otel.d.cts +1 -1
  17. package/dist/otel.d.mts +1 -1
  18. package/dist/otel.mjs +5 -15
  19. package/dist/{run-agent-C3mFDGTf.d.mts → run-agent-BWzo4FLv.d.mts} +83 -109
  20. package/dist/{run-agent-DnvtcnTZ.d.cts → run-agent-B_n4Qxye.d.cts} +83 -109
  21. package/dist/{setup-agent-DP95MFrI.cjs → setup-agent-CpK0ZRWV.cjs} +10 -210
  22. package/dist/{setup-agent-DAZZSjDS.mjs → setup-agent-DeHRW-qX.mjs} +11 -205
  23. package/dist/sqlite.d.cts +2 -2
  24. package/dist/sqlite.d.mts +2 -2
  25. package/dist/{text-logic-TkKPw8Aq.d.mts → text-logic-C7anC7qX.d.mts} +8 -94
  26. package/dist/{text-logic-BDxwQNsD.d.cts → text-logic-DZW7XWy9.d.cts} +8 -94
  27. package/dist/{types-QbEfCVny.d.cts → types-CTBhMnFu.d.mts} +30 -3
  28. package/dist/{types-_FXoFBGO.d.mts → types-DFD28AWe.d.cts} +30 -3
  29. package/package.json +1 -1
  30. /package/dist/{event-log-store-CriMgX1D.d.mts → event-log-store-BkUNtyOF.d.mts} +0 -0
  31. /package/dist/{event-log-store-Ruq18mGp.d.cts → event-log-store-CVd2eyRy.d.cts} +0 -0
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-DP95MFrI.cjs");
4
- const require_decision = require("./decision-dWGhBh0P.cjs");
3
+ const require_setup_agent = require("./setup-agent-CpK0ZRWV.cjs");
4
+ const require_decision = require("./decision-C0cUKvNt.cjs");
5
5
  const require_event_log_store = require("./event-log-store-CNT_7F0V.cjs");
6
6
  let xstate = require("xstate");
7
7
  //#region src/internal/state-request-pass.ts
@@ -365,7 +365,7 @@ function assertMachineBindable(machine, effectiveSources, options, ctx) {
365
365
  assertChildMachineBindable(src, src, stateName, options, ctx);
366
366
  continue;
367
367
  }
368
- if ((require_decision.isTextLogic(src) || require_decision.isDecisionLogic(src) || require_decision.isPlanLogic(src)) && !require_decision.executorBoundLogics.has(src)) throw new Error(`runAgent: ${where} '${stateName}' invokes a direct-object actor logic (kind: '${src.kind}'). Direct-object invoke srcs cannot be rebound by runAgent — either call '.withExecutor(...)' on the logic before invoking it, or register it as a string-keyed actor source instead (machine.provide({ actors: { name: logic } })) and invoke it by name.`);
368
+ if ((require_decision.isTextLogic(src) || require_decision.isDecisionLogic(src)) && !require_decision.executorBoundLogics.has(src)) throw new Error(`runAgent: ${where} '${stateName}' invokes a direct-object actor logic (kind: '${src.kind}'). Direct-object invoke srcs cannot be rebound by runAgent — either call '.withExecutor(...)' on the logic before invoking it, or register it as a string-keyed actor source instead (machine.provide({ actors: { name: logic } })) and invoke it by name.`);
369
369
  continue;
370
370
  }
371
371
  const logic = effectiveSources[src];
@@ -381,11 +381,6 @@ function assertMachineBindable(machine, effectiveSources, options, ctx) {
381
381
  if (!options.hasDecide) throw new Error(`runAgent: ${where} '${stateName}' invokes decision source '${src}' but no 'decide' executor was provided to runAgent(...).`);
382
382
  continue;
383
383
  }
384
- if (require_decision.isPlanLogic(logic)) {
385
- if (!ctx.rebindable) throw unrebindableChildRequestError(ctx.childPath, stateName, src, "plan");
386
- if (!options.hasDecide) throw new Error(`runAgent: ${where} '${stateName}' invokes plan source '${src}' but no 'decide' executor was provided to runAgent(...).`);
387
- continue;
388
- }
389
384
  if (require_decision.isTextLogic(logic)) {
390
385
  if (require_decision.executorBoundLogics.has(logic)) continue;
391
386
  if (!ctx.rebindable) throw unrebindableChildRequestError(ctx.childPath, stateName, src, logic.mode === "stream" ? "streaming text" : "text");
@@ -443,11 +438,11 @@ function selfIdAndSrc(self) {
443
438
  };
444
439
  }
445
440
  /**
446
- * The machine actor that INVOKED a decision/plan request — the actor whose
441
+ * The machine actor that INVOKED a decision request — the actor whose
447
442
  * live snapshot supplies the candidate events and drives `canTake`/`send`.
448
443
  * For a top-level request this is the root actor (identity-equal to
449
444
  * `runCtx.actorHolder.actorRef`); for a request inside an invoked child
450
- * machine it is that child's actor, so a child decision/plan reads and drives
445
+ * machine it is that child's actor, so a child decision reads and drives
451
446
  * the CHILD's snapshot — not the root's. Read off `self._parent`, with the
452
447
  * root actor as a fallback.
453
448
  */
@@ -542,7 +537,7 @@ function wrapTextLogicForRunAgent(logic, runCtx) {
542
537
  }
543
538
  });
544
539
  }
545
- function createCountingDecide(runCtx, self, kind = "decision") {
540
+ function createCountingDecide(runCtx, self) {
546
541
  return async (attemptRequest) => {
547
542
  runCtx.consumeModelCall();
548
543
  runCtx.onTrace?.({
@@ -558,7 +553,7 @@ function createCountingDecide(runCtx, self, kind = "decision") {
558
553
  if (usage) {
559
554
  const { src } = selfIdAndSrc(self);
560
555
  runCtx.recordUsage?.(usage, {
561
- kind,
556
+ kind: "decision",
562
557
  ...attemptRequest.id ? { id: attemptRequest.id } : {},
563
558
  ...src !== "" ? { src } : {},
564
559
  model: attemptRequest.model
@@ -595,8 +590,8 @@ function createCountingDecide(runCtx, self, kind = "decision") {
595
590
  * logic here that calls `resolveDecision` itself, reusing `logic.request(...)`
596
591
  * to build the request the same way the original logic would have.
597
592
  *
598
- * On success it SENDS the chosen event to the invoking actor (auto-delivery,
599
- * mirroring {@link createRunAgentPlanLogic}) and then completes with that event
593
+ * On success it SENDS the chosen event to the invoking actor (auto-delivery)
594
+ * and then completes with that event
600
595
  * as its output — so callers never wire an `onDone` to deliver it. See the
601
596
  * send-then-complete note inside `run` for how exit-cancels-invoke interacts
602
597
  * with `onDone`.
@@ -633,85 +628,6 @@ function createRunAgentDecisionLogic(logic, runCtx) {
633
628
  });
634
629
  }
635
630
  /**
636
- * Builds the plan actor logic runAgent installs in place of the `agent.plan`
637
- * builtin: iterated {@link resolveDecision}. Each step re-reads the live
638
- * snapshot (so the candidate set reflects everything applied so far), asks
639
- * the `decide` executor for one legal event with the same validation/retry
640
- * loop a decision gets, and sends it to the machine. The loop ends on a
641
- * `stopOn` event, at `maxSteps`, when no legal candidate remains, or when an
642
- * applied event exits the invoking state (xstate cancels this invoke — the
643
- * machine simply moves on and the pending output is discarded).
644
- *
645
- * The invoke's `input` is resolved once, so the prompt cannot re-render
646
- * context between steps; instead the applied trail is appended to the prompt
647
- * each step so the model can see plan progress.
648
- */
649
- function createRunAgentPlanLogic(logic, runCtx) {
650
- const planLogic = (0, xstate.createAsyncLogic)({ run: async ({ input, signal, self }) => {
651
- if (!runCtx.decide) throw new Error("runAgent: no 'decide' executor provided.");
652
- const { id } = selfIdAndSrc(self);
653
- const stopOn = new Set(input.stopOn ?? []);
654
- const countingDecide = createCountingDecide(runCtx, self, "plan");
655
- const base = logic.request(input);
656
- let ledger = require_decision.initialPlanLedger(logic, input);
657
- const end = (stopped) => {
658
- ledger = require_decision.advancePlanLedger(logic, ledger, {
659
- type: "plan.ended",
660
- stopped
661
- });
662
- return ledger.output;
663
- };
664
- await Promise.resolve();
665
- const invokingActor = invokingActorOf(self, runCtx);
666
- while (ledger.context.stepsRemaining > 0) {
667
- const actorRef = invokingActor;
668
- if (!actorRef || signal.aborted) break;
669
- const machineEvents = require_decision.getAcceptedEvents(actorRef.getSnapshot(), {
670
- schemas: runCtx.schemas,
671
- eventTypes: logic.allowedEventTypes(input)
672
- });
673
- if (machineEvents.length === 0) return end("no-legal-events");
674
- const doneDescriptor = {
675
- type: require_decision.PLAN_DONE_EVENT_TYPE,
676
- toolName: require_decision.sanitizeEventToolName(require_decision.PLAN_DONE_EVENT_TYPE)
677
- };
678
- const events = machineEvents.some((event) => event.type === "agent.plan.done") ? machineEvents : [...machineEvents, doneDescriptor];
679
- const applied = ledger.context.applied;
680
- const trail = applied.length === 0 ? "" : `\n\nEvents already applied in this plan, in order:\n${applied.map((step) => JSON.stringify(step)).join("\n")}\nContinue from here; do not repeat applied events.`;
681
- const doneHint = `\n\nWhen the request is fully handled (or no action is needed), choose '${require_decision.PLAN_DONE_EVENT_TYPE}'.`;
682
- const chosen = await require_decision.resolveDecision({
683
- ...base,
684
- id: `${id}[${applied.length}]`,
685
- events,
686
- prompt: `${base.prompt ?? ""}${trail}${doneHint}`,
687
- attempts: []
688
- }, countingDecide, {
689
- maxRetries: input.maxRetries ?? logic.maxRetries,
690
- signal,
691
- canTake: (event) => {
692
- if (event.type === "agent.plan.done" || stopOn.has(event.type)) return true;
693
- return invokingActor ? invokingActor.getSnapshot().can(event) : true;
694
- }
695
- });
696
- if (chosen.type === "agent.plan.done") return end("done");
697
- actorRef.send(chosen);
698
- ledger = require_decision.advancePlanLedger(logic, ledger, {
699
- type: "plan.applied",
700
- event: chosen
701
- });
702
- await Promise.resolve();
703
- if (stopOn.has(chosen.type)) return end("stop-event");
704
- }
705
- return end("max-steps");
706
- } });
707
- return Object.assign(planLogic, {
708
- kind: "statelyai.planLogic",
709
- maxRetries: logic.maxRetries,
710
- request: logic.request,
711
- allowedEventTypes: logic.allowedEventTypes
712
- });
713
- }
714
- /**
715
631
  * The set of string-keyed actor `src`s the machine's own config invokes
716
632
  * (top-level, recursing into child STATES but not into invoked child
717
633
  * machines). {@link provideExecutors} uses it to require an executor only for a
@@ -851,17 +767,29 @@ function bindDecisionForProvide(machine, logic, executors, options) {
851
767
  return createRunAgentDecisionLogic(logic, provideBindContext(machine, executors, options));
852
768
  }
853
769
  /**
854
- * Host-binds one `agent.plan` source for {@link provideExecutors}: runAgent's
855
- * plan wrapper (iterated snapshot-driven decisions, auto-delivery) with the same
856
- * request-level tracing runAgent emits, minus run-scoped counting. @internal
770
+ * Validates `input` against the machine's registered input schema, returning
771
+ * the schema's output so defaults are filled and transforms applied before
772
+ * the value reaches `createActor` or the replayable event log.
773
+ *
774
+ * Standard Schema only (no validation library is referenced), so this works for
775
+ * whatever the machine was declared with. Omitted input stays omitted rather
776
+ * than being validated as `{}`: "started with no input" keeps meaning what it
777
+ * has always meant, instead of newly failing schemas with required fields.
857
778
  */
858
- function bindPlanForProvide(machine, logic, executors, options) {
859
- return createRunAgentPlanLogic(logic, provideBindContext(machine, executors, options));
779
+ function resolveMachineInput(machine, input) {
780
+ if (input === void 0) return input;
781
+ const schema = require_decision.getRegisteredAgentExecutionOptions(machine).schemas?.input;
782
+ if (!require_decision.isStandardSchema(schema)) return input;
783
+ try {
784
+ return require_decision.validateSchemaSync(schema, input);
785
+ } catch (error) {
786
+ throw new require_errors.AgentError("invalid-machine-input", `runAgent: machine input failed validation against the declared input schema: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
787
+ }
860
788
  }
861
789
  /**
862
790
  * Recursively rebinds an invoked child machine's own agent sources with the
863
791
  * SAME host-backed wrappers runAgent applies to the top-level machine, so a
864
- * child's text/stream/decision/plan requests inherit runAgent's executors and
792
+ * child's text/stream/decision requests inherit runAgent's executors and
865
793
  * participate in maxModelCalls counting, onTrace/onChunk/onResult exactly like
866
794
  * parent requests. Returns the child machine to invoke: a `.provide`-rebound
867
795
  * copy when any inner source needed wrapping, else the original untouched.
@@ -882,10 +810,6 @@ function rebindChildMachine(childMachine, runCtx, visited) {
882
810
  if (!require_decision.executorBoundLogics.has(logic)) wrapped[key] = createRunAgentDecisionLogic(logic, runCtx);
883
811
  continue;
884
812
  }
885
- if (require_decision.isPlanLogic(logic)) {
886
- wrapped[key] = createRunAgentPlanLogic(logic, runCtx);
887
- continue;
888
- }
889
813
  if (require_decision.isTextLogic(logic)) {
890
814
  if (!require_decision.executorBoundLogics.has(logic)) wrapped[key] = wrapTextLogicForRunAgent(logic, runCtx);
891
815
  continue;
@@ -972,6 +896,7 @@ function createAgentSession(machine, options, lifecycle) {
972
896
  let warnedHeuristicIdle = false;
973
897
  const runId = `run_${nextRunAgentTraceId++}`;
974
898
  let traceSeq = 0;
899
+ const resolvedInput = resolveMachineInput(machine, options.input);
975
900
  const machineId = machine.config.id ?? machine.id ?? "(machine)";
976
901
  const machineVersion = options.machineVersion ?? machine.version ?? require_decision.getMachineStructuralHash(machine);
977
902
  const agentMeta = {
@@ -1085,10 +1010,6 @@ function createAgentSession(machine, options, lifecycle) {
1085
1010
  wrappedSources[key] = createRunAgentDecisionLogic(logic, runCtx);
1086
1011
  continue;
1087
1012
  }
1088
- if (require_decision.isPlanLogic(logic)) {
1089
- wrappedSources[key] = createRunAgentPlanLogic(logic, runCtx);
1090
- continue;
1091
- }
1092
1013
  if (require_decision.isTextLogic(logic)) {
1093
1014
  if (!require_decision.executorBoundLogics.has(logic)) wrappedSources[key] = wrapTextLogicForRunAgent(logic, runCtx);
1094
1015
  continue;
@@ -1170,7 +1091,7 @@ function createAgentSession(machine, options, lifecycle) {
1170
1091
  return entry;
1171
1092
  };
1172
1093
  if (replayEvents.length === 0 && effectiveSnapshot === void 0) {
1173
- const entry = require_setup_agent.initEntry(machine, options.input, { machineVersion });
1094
+ const entry = require_setup_agent.initEntry(machine, resolvedInput, { machineVersion });
1174
1095
  replayEventIds.add(entry.id);
1175
1096
  replayEvents.push(entry);
1176
1097
  options.onEvent?.(entry);
@@ -1225,10 +1146,8 @@ function createAgentSession(machine, options, lifecycle) {
1225
1146
  settle({
1226
1147
  status: "idle",
1227
1148
  snapshot: current,
1228
- ...pendingUserInputs.length > 0 ? {
1229
- pendingUserInputs,
1230
- persistedSnapshot: actor.getPersistedSnapshot()
1231
- } : {}
1149
+ persistedSnapshot: actor.getPersistedSnapshot(),
1150
+ ...pendingUserInputs.length > 0 ? { pendingUserInputs } : {}
1232
1151
  });
1233
1152
  };
1234
1153
  let interpreting = false;
@@ -1310,7 +1229,7 @@ function createAgentSession(machine, options, lifecycle) {
1310
1229
  }, 0);
1311
1230
  };
1312
1231
  actor = (0, xstate.createActor)(boundMachine, {
1313
- input: options.input,
1232
+ input: resolvedInput,
1314
1233
  snapshot: effectiveSnapshot,
1315
1234
  inspect: (event) => {
1316
1235
  if (typeof options.inspect === "function") options.inspect(event);
@@ -1359,7 +1278,13 @@ function createAgentSession(machine, options, lifecycle) {
1359
1278
  return;
1360
1279
  }
1361
1280
  if (!deliveringResumeEvent && isSuspended(snapshot) && isIdleSnapshot(snapshot, { ignoreUserInputChildren: userInputIsPlaceholder })) {
1362
- if (!maybeInterpret(snapshot)) settleIdle(snapshot);
1281
+ queueMicrotask(() => {
1282
+ if (settled) return;
1283
+ const current = actor.getSnapshot();
1284
+ if (isSuspended(current) && isIdleSnapshot(current, { ignoreUserInputChildren: userInputIsPlaceholder })) {
1285
+ if (!maybeInterpret(current)) settleIdle(current);
1286
+ } else scheduleIdleCheck();
1287
+ });
1363
1288
  return;
1364
1289
  }
1365
1290
  scheduleIdleCheck();
@@ -1401,7 +1326,7 @@ function createAgentSession(machine, options, lifecycle) {
1401
1326
  }
1402
1327
  onTrace({
1403
1328
  type: "run.start",
1404
- ...options.input !== void 0 ? { input: options.input } : {},
1329
+ ...resolvedInput !== void 0 ? { input: resolvedInput } : {},
1405
1330
  ...effectiveSnapshot !== void 0 ? { snapshot: effectiveSnapshot } : {},
1406
1331
  ...options.event !== void 0 ? { event: options.event } : {}
1407
1332
  });
@@ -1499,7 +1424,10 @@ function isIdleSnapshot(snapshot, { ignoreUserInputChildren }) {
1499
1424
  if (Object.values(snapshot.children ?? {}).some((child) => {
1500
1425
  const ref = child;
1501
1426
  if (ignoreUserInputChildren && ref?.src === "agent.userInput") return false;
1502
- return ref?.getSnapshot?.()?.status === "active";
1427
+ const childSnapshot = ref?.getSnapshot?.();
1428
+ if (childSnapshot?.status !== "active") return false;
1429
+ if ((0, xstate.isMachineSnapshot)(childSnapshot)) return !isIdleSnapshot(childSnapshot, { ignoreUserInputChildren });
1430
+ return true;
1503
1431
  })) return false;
1504
1432
  return !(0, xstate.getNextTransitions)(snapshot).some((transitionDef) => transitionDef.eventType === "" || transitionDef.eventType.startsWith("xstate.after"));
1505
1433
  }
@@ -1638,7 +1566,6 @@ function createAgentRun(machine, options) {
1638
1566
  * - decision / `agent.decide` source → `executors.decide` (snapshot-driven
1639
1567
  * candidate events, guard `canTake`, and auto-delivery of the chosen event,
1640
1568
  * mirroring `runAgent` but without its model-call counting)
1641
- * - `agent.plan` source → `executors.decide` (iterated, same semantics)
1642
1569
  *
1643
1570
  * Pass `options.onTrace` to observe request-level trace events (identical in
1644
1571
  * shape to `runAgent`'s); pair it with {@link traceTransitions} on the actor's
@@ -1676,14 +1603,6 @@ function provideExecutors(machine, executors, options = {}) {
1676
1603
  wrappedSources[key] = bindDecisionForProvide(provided, logic, executors, bindOptions);
1677
1604
  continue;
1678
1605
  }
1679
- if (require_decision.isPlanLogic(logic)) {
1680
- if (!executors.decide) {
1681
- if (invokedSrcs.has(key)) throw missingExecutorError(key, "plan", "decide");
1682
- continue;
1683
- }
1684
- wrappedSources[key] = bindPlanForProvide(provided, logic, executors, bindOptions);
1685
- continue;
1686
- }
1687
1606
  if (require_decision.isTextLogic(logic)) {
1688
1607
  if (require_decision.executorBoundLogics.has(logic)) continue;
1689
1608
  if (!(logic.mode === "stream" ? executors.streamText : executors.generateText)) {
@@ -1702,7 +1621,6 @@ function missingExecutorError(src, kind, executor) {
1702
1621
  //#endregion
1703
1622
  //#region src/verify.ts
1704
1623
  const DECIDE_SRC = "agent.decide";
1705
- const PLAN_SRC = "agent.plan";
1706
1624
  function normalizeInvokes(invoke) {
1707
1625
  if (invoke === void 0 || invoke === null) return [];
1708
1626
  return Array.isArray(invoke) ? invoke : [invoke];
@@ -1839,17 +1757,12 @@ function hasNonEmptyOn(config) {
1839
1757
  function decisionKindOf(src, actors) {
1840
1758
  if (typeof src === "string") {
1841
1759
  if (src === DECIDE_SRC) return "decision";
1842
- if (src === PLAN_SRC) return "plan";
1843
- const logic = actors[src];
1844
- if (require_decision.isDecisionLogic(logic)) return "decision";
1845
- if (require_decision.isPlanLogic(logic)) return "plan";
1846
- return;
1760
+ return require_decision.isDecisionLogic(actors[src]) ? "decision" : void 0;
1847
1761
  }
1848
- if (require_decision.isDecisionLogic(src)) return "decision";
1849
- if (require_decision.isPlanLogic(src)) return "plan";
1762
+ return require_decision.isDecisionLogic(src) ? "decision" : void 0;
1850
1763
  }
1851
1764
  function isAgentLogicNeedingBinding(src) {
1852
- return (require_decision.isTextLogic(src) || require_decision.isDecisionLogic(src) || require_decision.isPlanLogic(src)) && !require_decision.executorBoundLogics.has(src);
1765
+ return (require_decision.isTextLogic(src) || require_decision.isDecisionLogic(src)) && !require_decision.executorBoundLogics.has(src);
1853
1766
  }
1854
1767
  function schemaExposesJson(schema) {
1855
1768
  if (!schema) return false;
@@ -2130,17 +2043,6 @@ async function simulateAgent(machine, options) {
2130
2043
  });
2131
2044
  continue;
2132
2045
  }
2133
- if (request.kind === "plan") {
2134
- const taken = takeFromQueue(script.decisions, request.src);
2135
- if (!taken.found) throw scriptDryError("decision", request.src, request.id, request);
2136
- const event = taken.value;
2137
- step = await require_setup_agent.resolveAgentRequests(machine, step, { decide: async () => ({ event }) });
2138
- trail.push({
2139
- state: step.snapshot.value,
2140
- appliedEvent: taken.value
2141
- });
2142
- continue;
2143
- }
2144
2046
  const taken = takeFromQueue(script.text, request.src);
2145
2047
  if (!taken.found) throw scriptDryError("text", request.src, request.id);
2146
2048
  step = require_setup_agent.resolveAgentStep(machine, step, request, taken.value);
@@ -2224,7 +2126,7 @@ async function explore(machine, options, stopWhen) {
2224
2126
  recordState(current.snapshot);
2225
2127
  continue;
2226
2128
  }
2227
- if (request && (request.kind === "decision" || request.kind === "plan")) return { step: current };
2129
+ if (request && request.kind === "decision") return { step: current };
2228
2130
  const [invoke] = pendingInvokes(current);
2229
2131
  if (invoke) {
2230
2132
  if (!(invoke.src in textOutputs)) return {
@@ -2271,8 +2173,7 @@ async function explore(machine, options, stopWhen) {
2271
2173
  return;
2272
2174
  }
2273
2175
  const request = settled.requests[0];
2274
- const isPlan = request?.kind === "plan";
2275
- const branchEvents = request?.kind === "decision" || request?.kind === "plan" ? request.events.map((descriptor) => ({ type: descriptor.type })) : require_decision.getAcceptedEvents(settled.snapshot).map((descriptor) => ({ type: descriptor.type }));
2176
+ const branchEvents = request?.kind === "decision" ? request.events.map((descriptor) => ({ type: descriptor.type })) : require_decision.getAcceptedEvents(settled.snapshot).map((descriptor) => ({ type: descriptor.type }));
2276
2177
  if (branchEvents.length === 0) {
2277
2178
  pathsExplored++;
2278
2179
  terminals.push({
@@ -2297,11 +2198,11 @@ async function explore(machine, options, stopWhen) {
2297
2198
  if (pathsExplored >= maxPaths) hitPathCap = true;
2298
2199
  return;
2299
2200
  }
2300
- if (!(isPlan && event.type === "agent.plan.done") && !settled.snapshot.can(event)) {
2201
+ if (!settled.snapshot.can(event)) {
2301
2202
  prunedByGuard++;
2302
2203
  continue;
2303
2204
  }
2304
- const next = isPlan ? await require_setup_agent.resolveAgentRequests(machine, settled, { decide: async () => ({ event }) }) : require_setup_agent.transitionAgentStep(machine, settled, event);
2205
+ const next = require_setup_agent.transitionAgentStep(machine, settled, event);
2305
2206
  recordState(next.snapshot);
2306
2207
  await visit(next, [...path, event], depth + 1);
2307
2208
  }
@@ -2324,10 +2225,7 @@ async function explore(machine, options, stopWhen) {
2324
2225
  * depth, model-free, and reports which states are reached and how each path
2325
2226
  * terminates. At each decision request it forks one branch per candidate event
2326
2227
  * (guard-rejected candidates are counted in `prunedByGuard`, not explored); at
2327
- * an idle wait it forks per externally-accepted event. A `agent.plan` request
2328
- * forks the same way — one branch per candidate, including the reserved
2329
- * `agent.plan.done` move — advancing each branch through the real plan protocol
2330
- * (`resolveAgentRequests`), so a plan can consume several depth units. Text/`userInput` invokes
2228
+ * an idle wait it forks per externally-accepted event. Text/`userInput` invokes
2331
2229
  * are resolved from `textOutputs` (a by-src canned-output map) — a missing src
2332
2230
  * halts that branch with a `needs-output` terminal rather than throwing.
2333
2231
  *
@@ -2811,7 +2709,6 @@ exports.AgentReplayDivergenceError = require_setup_agent.AgentReplayDivergenceEr
2811
2709
  exports.AgentReplayMachineMismatchError = require_setup_agent.AgentReplayMachineMismatchError;
2812
2710
  exports.AgentSnapshotVersionMismatchError = AgentSnapshotVersionMismatchError;
2813
2711
  exports.NonSerializableAgentEventError = require_event_log_store.NonSerializableAgentEventError;
2814
- exports.PLAN_DONE_EVENT_TYPE = require_decision.PLAN_DONE_EVENT_TYPE;
2815
2712
  exports.appendMessages = require_setup_agent.appendMessages;
2816
2713
  exports.assertAgentLogEntry = require_event_log_store.assertAgentLogEntry;
2817
2714
  exports.assertAgentMachine = assertAgentMachine;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
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";
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-DFD28AWe.cjs";
2
2
  import { t as AgentError } from "./errors-BQRk9eiZ.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
- 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";
3
+ import { A as AgentDecisionExhaustedError, B as AgentRequestOptions, C as buildEnvelopeSchema, D as parseOutput, E as parseModelRef, F as ResolveDecisionOptions, H as getAcceptedEvents, I as renderDecisionAttempts, L as resolveDecision, M as AgentDecisionRequest, N as DecisionAttempt, O as parseStructuredEnvelope, P as DecisionLogicConfig, R as AgentEventDescriptor, S as bindRequestExecutor, T as getAgentOutputMode, U as parseAgentEvent, V 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 AgentDecisionInput, k as AgentDecisionExecutor, 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 AgentEventToolNameResolver } from "./text-logic-DZW7XWy9.cjs";
4
+ 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-CVd2eyRy.cjs";
5
+ import { A as AgentEffect, B as ReplayResult, C as traceTransitions, D as executeAgentRequest, E as AgentStepRequest, F as AgentReplayMachineMismatchError, G as initEntry, H as diffEventLogs, I as AgentUsageEvent, K as replay, L as CreateReplayEntryOptions, M as AgentEventLogDiff, N as AgentLogPatchOperation, O as AGENT_INIT_EVENT_TYPE, P as AgentReplayDivergenceError, R as GetAgentEffectsOptions, S as serializeTraceEvent, T as AgentRequest, U as getAgentEffects, V as createReplayEntry, W as getCallUsage, _ as RunAgentResult, a as AgentInputFrom, b as inspectTransitions, c as AgentSnapshotVersionMismatchError, d as GenerateResult, f as InspectedActorRef, g as RunAgentOptions, h as RunAgentErrorCause, i as AgentIllegalResumeEventError, j as AgentEffectDiff, k as AGENT_USAGE_EVENT_TYPE, l as AgentTraceEvent, m as PendingUserInput, n as AgentActorSession, o as AgentMessageInfo, p as JsonSerializableTraceEvent, q as verifyReplay, r as AgentIdleError, s as AgentRunMeta, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentUserInputExecutor, v as createAgentActor, w as AgentStateRequest, x as runAgent, y as generateResult, z as ReplayOptions } from "./run-agent-B_n4Qxye.cjs";
6
6
  import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventFromLogic, EventObject, InputFrom, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema, SnapshotFrom, StateValue } from "xstate";
7
7
 
8
8
  //#region src/messages.d.ts
@@ -309,10 +309,27 @@ type AgentSetupEventsSchema<TEventSchemas extends AgentEventSchemaInputMap> = {
309
309
  type AgentSetupEmittedSchema<TEmittedSchemas extends Record<string, StandardSchemaV1>> = [keyof TEmittedSchemas] extends [never] ? {} : {
310
310
  emitted: TEmittedSchemas;
311
311
  };
312
+ /**
313
+ * The input schema as handed to xstate's `setup(...)`, with the machine's input
314
+ * type branded by the schema it came from.
315
+ *
316
+ * XState resolves `schemas.input` to a single type used both by
317
+ * `createActor`'s `input` option and by the `context: ({ input })` factory —
318
+ * and it never validates, so a schema default reads as a required field at the
319
+ * call site while being absent at runtime. `runAgent` validates the input
320
+ * (filling defaults) and reads this brand back through `AgentInputFrom` to
321
+ * accept the schema's looser *input* side, while the factory keeps seeing the
322
+ * validated *output* side.
323
+ *
324
+ * Only object-shaped input is branded: with no declared input schema the
325
+ * resolved type is xstate's `NonReducibleUnknown` (a union including `null`),
326
+ * and intersecting a brand into that collapses members to `never`.
327
+ */
328
+ type BrandedInputSchema<TInputSchema extends StandardSchemaV1> = InferOutput<TInputSchema> extends Record<string, unknown> ? StandardSchemaV1<InferInput<TInputSchema>, InferOutput<TInputSchema> & WithAgentInputSchema<TInputSchema>> : TInputSchema;
312
329
  type AgentSetupXStateConfig<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap, TActors extends { [K in keyof TActors]: AnyActorLogic }, TRequestSchemas extends AgentRequestSchemaMap, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TModels extends AgentModelMap, TEmittedSchemas extends Record<string, StandardSchemaV1> = {}, TStateSchemas extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>> = {
313
330
  schemas: {
314
331
  context: TContextSchema;
315
- input: TInputSchema;
332
+ input: BrandedInputSchema<TInputSchema>;
316
333
  output: TOutputSchema;
317
334
  meta: TMetaSchema;
318
335
  } & AgentSetupEventsSchema<TEventSchemas> & AgentSetupEmittedSchema<TEmittedSchemas>;
@@ -420,7 +437,7 @@ type SetupAgentResult<TContextSchema extends StandardSchemaV1<Record<string, unk
420
437
  * state/transition meta are all standard schemas — no `{} as Type` casts —
421
438
  * and are retained on `result.schemas` for runtime validation. Also
422
439
  * registers the `agent.generateText`/`agent.streamText`/`agent.userInput`/
423
- * `agent.decide`/`agent.plan` builtin actors and lowers `requests`/`actors` into the
440
+ * `agent.decide` builtin actors and lowers `requests`/`actors` into the
424
441
  * machine's actor sources. The result is the xstate `setup(...)` object with
425
442
  * a wrapped `result.createMachine(...)` plus `result.schemas`/`models`/
426
443
  * `requests`/`appendMessages` attached. Also has a
@@ -593,7 +610,6 @@ interface ProvideExecutorsOptions<TMachine extends AnyStateMachine = AnyStateMac
593
610
  * - decision / `agent.decide` source → `executors.decide` (snapshot-driven
594
611
  * candidate events, guard `canTake`, and auto-delivery of the chosen event,
595
612
  * mirroring `runAgent` but without its model-call counting)
596
- * - `agent.plan` source → `executors.decide` (iterated, same semantics)
597
613
  *
598
614
  * Pass `options.onTrace` to observe request-level trace events (identical in
599
615
  * shape to `runAgent`'s); pair it with {@link traceTransitions} on the actor's
@@ -782,10 +798,7 @@ interface AgentPathReport {
782
798
  * depth, model-free, and reports which states are reached and how each path
783
799
  * terminates. At each decision request it forks one branch per candidate event
784
800
  * (guard-rejected candidates are counted in `prunedByGuard`, not explored); at
785
- * an idle wait it forks per externally-accepted event. A `agent.plan` request
786
- * forks the same way — one branch per candidate, including the reserved
787
- * `agent.plan.done` move — advancing each branch through the real plan protocol
788
- * (`resolveAgentRequests`), so a plan can consume several depth units. Text/`userInput` invokes
801
+ * an idle wait it forks per externally-accepted event. Text/`userInput` invokes
789
802
  * are resolved from `textOutputs` (a by-src canned-output map) — a missing src
790
803
  * halts that branch with a `needs-output` terminal rather than throwing.
791
804
  *
@@ -938,7 +951,7 @@ type ScriptedDecisionEntry = ScriptedDecisionValue | ((request: AgentDecisionReq
938
951
  type ScriptedTextEntry = ((request: AgentTextRequest, info?: AgentRequestExecutorInfo) => unknown) | string | number | boolean | null | object;
939
952
  /** The script {@link createScriptedExecutors} plays back. */
940
953
  interface ScriptedExecutorsScript {
941
- /** Answers for `decide` (and `agent.plan`) requests, consumed in order. */
954
+ /** Answers for `decide` requests, consumed in order. */
942
955
  decisions?: ScriptedDecisionEntry[];
943
956
  /** Answers for text requests, consumed in order. `generateText` and `streamText` share this one queue. */
944
957
  text?: ScriptedTextEntry[];
@@ -1202,4 +1215,4 @@ declare function getJsonSchema(schema?: StandardSchemaV1): Promise<Record<string
1202
1215
  */
1203
1216
  declare function getJsonSchemaSync(schema?: StandardSchemaV1): Record<string, unknown> | undefined;
1204
1217
  //#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, 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 };
1218
+ 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, 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 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 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 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,8 +1,8 @@
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";
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-CTBhMnFu.mjs";
2
2
  import { t as AgentError } from "./errors-C9rxnWbX.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
- 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";
3
+ import { A as AgentDecisionExhaustedError, B as AgentRequestOptions, C as buildEnvelopeSchema, D as parseOutput, E as parseModelRef, F as ResolveDecisionOptions, H as getAcceptedEvents, I as renderDecisionAttempts, L as resolveDecision, M as AgentDecisionRequest, N as DecisionAttempt, O as parseStructuredEnvelope, P as DecisionLogicConfig, R as AgentEventDescriptor, S as bindRequestExecutor, T as getAgentOutputMode, U as parseAgentEvent, V 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 AgentDecisionInput, k as AgentDecisionExecutor, 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 AgentEventToolNameResolver } from "./text-logic-C7anC7qX.mjs";
4
+ 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-BkUNtyOF.mjs";
5
+ import { A as AgentEffect, B as ReplayResult, C as traceTransitions, D as executeAgentRequest, E as AgentStepRequest, F as AgentReplayMachineMismatchError, G as initEntry, H as diffEventLogs, I as AgentUsageEvent, K as replay, L as CreateReplayEntryOptions, M as AgentEventLogDiff, N as AgentLogPatchOperation, O as AGENT_INIT_EVENT_TYPE, P as AgentReplayDivergenceError, R as GetAgentEffectsOptions, S as serializeTraceEvent, T as AgentRequest, U as getAgentEffects, V as createReplayEntry, W as getCallUsage, _ as RunAgentResult, a as AgentInputFrom, b as inspectTransitions, c as AgentSnapshotVersionMismatchError, d as GenerateResult, f as InspectedActorRef, g as RunAgentOptions, h as RunAgentErrorCause, i as AgentIllegalResumeEventError, j as AgentEffectDiff, k as AGENT_USAGE_EVENT_TYPE, l as AgentTraceEvent, m as PendingUserInput, n as AgentActorSession, o as AgentMessageInfo, p as JsonSerializableTraceEvent, q as verifyReplay, r as AgentIdleError, s as AgentRunMeta, t as AGENT_TRACE_SCHEMA_VERSION, u as AgentUserInputExecutor, v as createAgentActor, w as AgentStateRequest, x as runAgent, y as generateResult, z as ReplayOptions } from "./run-agent-BWzo4FLv.mjs";
6
6
  import { AnyActorLogic, AnyMachineSnapshot, AnySetupConfig, AnyStateMachine, AsyncActorLogic, EventFromLogic, EventObject, InputFrom, MachineContext, MetaObject, NonReducibleUnknown, SetupReturnFromConfig, SetupStateSchema, SnapshotFrom, StateValue } from "xstate";
7
7
 
8
8
  //#region src/messages.d.ts
@@ -309,10 +309,27 @@ type AgentSetupEventsSchema<TEventSchemas extends AgentEventSchemaInputMap> = {
309
309
  type AgentSetupEmittedSchema<TEmittedSchemas extends Record<string, StandardSchemaV1>> = [keyof TEmittedSchemas] extends [never] ? {} : {
310
310
  emitted: TEmittedSchemas;
311
311
  };
312
+ /**
313
+ * The input schema as handed to xstate's `setup(...)`, with the machine's input
314
+ * type branded by the schema it came from.
315
+ *
316
+ * XState resolves `schemas.input` to a single type used both by
317
+ * `createActor`'s `input` option and by the `context: ({ input })` factory —
318
+ * and it never validates, so a schema default reads as a required field at the
319
+ * call site while being absent at runtime. `runAgent` validates the input
320
+ * (filling defaults) and reads this brand back through `AgentInputFrom` to
321
+ * accept the schema's looser *input* side, while the factory keeps seeing the
322
+ * validated *output* side.
323
+ *
324
+ * Only object-shaped input is branded: with no declared input schema the
325
+ * resolved type is xstate's `NonReducibleUnknown` (a union including `null`),
326
+ * and intersecting a brand into that collapses members to `never`.
327
+ */
328
+ type BrandedInputSchema<TInputSchema extends StandardSchemaV1> = InferOutput<TInputSchema> extends Record<string, unknown> ? StandardSchemaV1<InferInput<TInputSchema>, InferOutput<TInputSchema> & WithAgentInputSchema<TInputSchema>> : TInputSchema;
312
329
  type AgentSetupXStateConfig<TContextSchema extends StandardSchemaV1<Record<string, unknown>>, TEventSchemas extends AgentEventSchemaInputMap, TActors extends { [K in keyof TActors]: AnyActorLogic }, TRequestSchemas extends AgentRequestSchemaMap, TInputSchema extends StandardSchemaV1, TOutputSchema extends StandardSchemaV1, TMetaSchema extends StandardSchemaV1, TModels extends AgentModelMap, TEmittedSchemas extends Record<string, StandardSchemaV1> = {}, TStateSchemas extends Record<string, SetupStateSchema> = Record<string, SetupStateSchema>> = {
313
330
  schemas: {
314
331
  context: TContextSchema;
315
- input: TInputSchema;
332
+ input: BrandedInputSchema<TInputSchema>;
316
333
  output: TOutputSchema;
317
334
  meta: TMetaSchema;
318
335
  } & AgentSetupEventsSchema<TEventSchemas> & AgentSetupEmittedSchema<TEmittedSchemas>;
@@ -420,7 +437,7 @@ type SetupAgentResult<TContextSchema extends StandardSchemaV1<Record<string, unk
420
437
  * state/transition meta are all standard schemas — no `{} as Type` casts —
421
438
  * and are retained on `result.schemas` for runtime validation. Also
422
439
  * registers the `agent.generateText`/`agent.streamText`/`agent.userInput`/
423
- * `agent.decide`/`agent.plan` builtin actors and lowers `requests`/`actors` into the
440
+ * `agent.decide` builtin actors and lowers `requests`/`actors` into the
424
441
  * machine's actor sources. The result is the xstate `setup(...)` object with
425
442
  * a wrapped `result.createMachine(...)` plus `result.schemas`/`models`/
426
443
  * `requests`/`appendMessages` attached. Also has a
@@ -593,7 +610,6 @@ interface ProvideExecutorsOptions<TMachine extends AnyStateMachine = AnyStateMac
593
610
  * - decision / `agent.decide` source → `executors.decide` (snapshot-driven
594
611
  * candidate events, guard `canTake`, and auto-delivery of the chosen event,
595
612
  * mirroring `runAgent` but without its model-call counting)
596
- * - `agent.plan` source → `executors.decide` (iterated, same semantics)
597
613
  *
598
614
  * Pass `options.onTrace` to observe request-level trace events (identical in
599
615
  * shape to `runAgent`'s); pair it with {@link traceTransitions} on the actor's
@@ -782,10 +798,7 @@ interface AgentPathReport {
782
798
  * depth, model-free, and reports which states are reached and how each path
783
799
  * terminates. At each decision request it forks one branch per candidate event
784
800
  * (guard-rejected candidates are counted in `prunedByGuard`, not explored); at
785
- * an idle wait it forks per externally-accepted event. A `agent.plan` request
786
- * forks the same way — one branch per candidate, including the reserved
787
- * `agent.plan.done` move — advancing each branch through the real plan protocol
788
- * (`resolveAgentRequests`), so a plan can consume several depth units. Text/`userInput` invokes
801
+ * an idle wait it forks per externally-accepted event. Text/`userInput` invokes
789
802
  * are resolved from `textOutputs` (a by-src canned-output map) — a missing src
790
803
  * halts that branch with a `needs-output` terminal rather than throwing.
791
804
  *
@@ -938,7 +951,7 @@ type ScriptedDecisionEntry = ScriptedDecisionValue | ((request: AgentDecisionReq
938
951
  type ScriptedTextEntry = ((request: AgentTextRequest, info?: AgentRequestExecutorInfo) => unknown) | string | number | boolean | null | object;
939
952
  /** The script {@link createScriptedExecutors} plays back. */
940
953
  interface ScriptedExecutorsScript {
941
- /** Answers for `decide` (and `agent.plan`) requests, consumed in order. */
954
+ /** Answers for `decide` requests, consumed in order. */
942
955
  decisions?: ScriptedDecisionEntry[];
943
956
  /** Answers for text requests, consumed in order. `generateText` and `streamText` share this one queue. */
944
957
  text?: ScriptedTextEntry[];
@@ -1202,4 +1215,4 @@ declare function getJsonSchema(schema?: StandardSchemaV1): Promise<Record<string
1202
1215
  */
1203
1216
  declare function getJsonSchemaSync(schema?: StandardSchemaV1): Record<string, unknown> | undefined;
1204
1217
  //#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, 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 };
1218
+ 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, 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 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 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 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 };