@statelyai/agent 2.0.0-alpha.38 → 2.0.0-alpha.39

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 (135) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/{act-CrX0JwWY.cjs → act-B0CVbmo4.cjs} +1 -1
  3. package/dist/{act-B9hLQls6.mjs → act-Bsz-hUfD.mjs} +1 -1
  4. package/dist/ai-sdk.cjs +4 -4
  5. package/dist/ai-sdk.d.cts +2 -3
  6. package/dist/ai-sdk.d.mts +2 -3
  7. package/dist/ai-sdk.mjs +4 -4
  8. package/dist/{decision-m5hGmHpF.mjs → decision-B41YBx5U.mjs} +1 -1
  9. package/dist/{decision-CMeuNZ1g.cjs → decision-D8bcIGXQ.cjs} +1 -1
  10. package/dist/{decision-object-DBcLWVvv.d.cts → decision-object-BB8XV5Ec.d.cts} +1 -1
  11. package/dist/{decision-object-B5zGSPFp.d.mts → decision-object-CH_sE694.d.mts} +1 -1
  12. package/dist/effects-B9IvUPVh.mjs +23 -0
  13. package/dist/effects-DrWcUGgc.cjs +34 -0
  14. package/dist/evals.cjs +810 -0
  15. package/dist/evals.d.cts +595 -0
  16. package/dist/evals.d.mts +595 -0
  17. package/dist/evals.mjs +801 -0
  18. package/dist/{event-log-DkVlk3Rh.mjs → event-log-CEq_bVXQ.mjs} +8 -4
  19. package/dist/{event-log-Dkc-yIYu.cjs → event-log-dSOnXHuG.cjs} +7 -15
  20. package/dist/{event-log-store-Brx9tOHt.mjs → event-log-store-DLAfNM34.mjs} +1 -1
  21. package/dist/{event-log-store-BBS8so8a.d.mts → event-log-store-DYun526m.d.mts} +15 -14
  22. package/dist/{event-log-store-Cl-YWDnq.cjs → event-log-store-Dey9ufA4.cjs} +1 -1
  23. package/dist/{event-log-store-bc4ICGcS.d.cts → event-log-store-aFXK6yZX.d.cts} +15 -14
  24. package/dist/index.cjs +131 -93
  25. package/dist/index.d.cts +73 -134
  26. package/dist/index.d.mts +73 -134
  27. package/dist/index.mjs +112 -70
  28. package/dist/internal-BzlpzSux.d.cts +14 -0
  29. package/dist/internal-BzlpzSux.d.mts +14 -0
  30. package/dist/log.cjs +2 -3
  31. package/dist/log.d.cts +2 -2
  32. package/dist/log.d.mts +2 -2
  33. package/dist/log.mjs +3 -3
  34. package/dist/machines.cjs +1 -719
  35. package/dist/machines.d.cts +2 -424
  36. package/dist/machines.d.mts +2 -424
  37. package/dist/machines.mjs +2 -709
  38. package/dist/{model-source-kjGwqAV8.mjs → model-source-BrsLDvHL.mjs} +1 -1
  39. package/dist/{model-source-B4WQ8Idp.cjs → model-source-YpxjmWuX.cjs} +1 -1
  40. package/dist/openai.cjs +3 -3
  41. package/dist/openai.d.cts +2 -3
  42. package/dist/openai.d.mts +2 -3
  43. package/dist/openai.mjs +3 -3
  44. package/dist/otel.d.cts +1 -1
  45. package/dist/otel.d.mts +1 -1
  46. package/dist/policy.cjs +77 -0
  47. package/dist/policy.d.cts +143 -0
  48. package/dist/policy.d.mts +143 -0
  49. package/dist/policy.mjs +75 -0
  50. package/dist/{effects-BT_cSY0j.mjs → run-agent-BE7DOWD6.mjs} +150 -184
  51. package/dist/{run-agent-DlPzBWj-.d.mts → run-agent-DHlq87G7.d.mts} +18 -34
  52. package/dist/{effects-DDseYtJk.cjs → run-agent-De3xVFGw.cjs} +149 -201
  53. package/dist/{run-agent-30mH2moE.d.cts → run-agent-Dq0oSFRm.d.cts} +18 -34
  54. package/dist/{setup-agent-BDmNr6PC.mjs → setup-agent-CLm6QVGy.mjs} +3 -3
  55. package/dist/{setup-agent-BaNyz6Q3.d.cts → setup-agent-Cv8Hk3mX.d.cts} +12 -11
  56. package/dist/{setup-agent-C1CG_nfX.d.mts → setup-agent-DgFAhaPJ.d.mts} +12 -11
  57. package/dist/{setup-agent-CmEToB8y.cjs → setup-agent-Dv5VpuHe.cjs} +3 -3
  58. package/dist/tanstack-ai.cjs +4 -4
  59. package/dist/tanstack-ai.d.cts +2 -3
  60. package/dist/tanstack-ai.d.mts +2 -3
  61. package/dist/tanstack-ai.mjs +4 -4
  62. package/dist/testing.cjs +122 -996
  63. package/dist/testing.d.cts +36 -695
  64. package/dist/testing.d.mts +36 -695
  65. package/dist/testing.mjs +112 -977
  66. package/dist/{text-logic-BqxalgMr.d.mts → text-logic-x17uLBwA.d.cts} +238 -2
  67. package/dist/{text-logic-CSf9bqpP.d.cts → text-logic-x17uLBwA.d.mts} +238 -2
  68. package/dist/trajectory-BFjXaooB.d.cts +96 -0
  69. package/dist/trajectory-BFjXaooB.d.mts +96 -0
  70. package/dist/trajectory-BUXj_1Ue.mjs +152 -0
  71. package/dist/trajectory-CoZSv4wF.cjs +157 -0
  72. package/dist/{usage-Bm5nvpow.d.cts → usage-B4B-TQSV.d.mts} +1 -1
  73. package/dist/{usage-BnikdOca.d.mts → usage-DvGcoK6x.d.cts} +1 -1
  74. package/dist/{utils-7lSa4H-i.d.cts → utils-B8k-YPYI.d.mts} +23 -17
  75. package/dist/{utils-CBbKw2fM.d.mts → utils-DAclF-kw.d.cts} +23 -17
  76. package/dist/validate.cjs +4 -4
  77. package/dist/validate.d.cts +2 -2
  78. package/dist/validate.d.mts +2 -2
  79. package/dist/validate.mjs +4 -4
  80. package/dist/{verify-DJHfEfm6.d.cts → verify-BM0sGmsf.d.cts} +42 -6
  81. package/dist/{verify-ChyX6jq0.mjs → verify-CWlg3j7B.mjs} +153 -45
  82. package/dist/{verify-CwlombbC.cjs → verify-Dek6gHCS.cjs} +153 -45
  83. package/dist/{verify-i9Hiwc5g.d.mts → verify-H3Pr2gNw.d.mts} +42 -6
  84. package/dist/{with-model-calls-B_WLmOSl.cjs → with-model-calls-D50Ca6qW.cjs} +2 -2
  85. package/dist/{with-model-calls-BkOwdroS.mjs → with-model-calls-uY-KKliA.mjs} +2 -2
  86. package/docs/advanced.md +5 -5
  87. package/docs/choosing-a-run-mode.md +7 -7
  88. package/docs/debugging.md +6 -8
  89. package/docs/decisions.md +5 -4
  90. package/docs/environment-and-policy.md +1 -1
  91. package/docs/evals.md +57 -43
  92. package/docs/event-log.md +13 -15
  93. package/docs/from-a-loop.md +3 -3
  94. package/docs/generate-machines.md +4 -4
  95. package/docs/hosts.md +20 -27
  96. package/docs/human-in-the-loop.md +5 -8
  97. package/docs/index.md +4 -4
  98. package/docs/judgments.md +5 -7
  99. package/docs/langgraph-comparison.md +6 -6
  100. package/docs/machines-as-data.md +7 -12
  101. package/docs/machines-presets.md +17 -120
  102. package/docs/machines.md +13 -13
  103. package/docs/models-and-providers.md +19 -25
  104. package/docs/multi-agent.md +1 -1
  105. package/docs/observability.md +6 -8
  106. package/docs/persistence.md +10 -20
  107. package/docs/quickstart.md +3 -3
  108. package/docs/statechart-policy-examples.md +1 -1
  109. package/docs/steps.md +5 -6
  110. package/docs/strangler-fig.md +72 -7
  111. package/docs/text-requests.md +10 -12
  112. package/docs/thinking-in-state-machines.md +8 -8
  113. package/docs/tools.md +10 -12
  114. package/docs/upgrading.md +1 -1
  115. package/docs/usage-and-budgets.md +51 -56
  116. package/docs/validate-and-repair.md +9 -14
  117. package/docs/verify.md +53 -7
  118. package/docs/xstate-4-and-5-apps.md +19 -28
  119. package/llms.txt +1 -1
  120. package/package.json +31 -6
  121. package/readme.md +32 -24
  122. package/dist/internal-C3Lqu538.d.cts +0 -43
  123. package/dist/internal-DUcdhk-i.d.mts +0 -43
  124. package/dist/types-DQUOOaZO.d.cts +0 -238
  125. package/dist/types-DQUOOaZO.d.mts +0 -238
  126. package/skills/add-evals/SKILL.md +0 -152
  127. package/skills/add-traces/SKILL.md +0 -152
  128. package/skills/build-machine/SKILL.md +0 -84
  129. package/skills/generate-machine/SKILL.md +0 -335
  130. package/skills/graph-engineering/SKILL.md +0 -43
  131. package/skills/improve-machine/SKILL.md +0 -261
  132. package/skills/improve-machine/reference.md +0 -101
  133. package/skills/loop-to-machine/SKILL.md +0 -205
  134. package/skills/loop-to-machine/policy.md +0 -154
  135. package/skills/loop-to-machine/reference.md +0 -260
package/dist/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { $ as getJsonSchema, B as parseOutput, F as getCallFinishReason, G as executorBoundLogics, H as providerOutputSchema, K as getAgentExecutionOptions, L as getCallUsage, N as createTextLogic, P as getAgentOutputMode, R as isTextLogic, V as parseProviderOutput, Z as assistantMessage, at as isStandardSchema, ct as toolMessage, d as canonicalEventJson, et as getJsonSchemaSync, gt as AgentTruncatedError, ht as AgentError, i as AgentMachineVersionMismatchError, it as getStatePath, j as bindRequestExecutor, lt as userMessage, mt as isRecord, nt as getMessageText, rt as getStateMeta, st as systemMessage, tt as getMachineStructuralHash, u as assertJsonSerializable, w as AGENT_USAGE_EVENT_TYPE } from "./event-log-DkVlk3Rh.mjs";
2
- import { a as createDecisionRequest, c as renderDecisionAttempts, d as GROUPED_EVENT_THRESHOLD, f as MAX_FINITE_PAYLOADS, h as getAcceptedEvents, i as createDecisionLogic, m as AgentInvalidEventPayloadError, s as isDecisionLogic, t as AgentDecisionExhaustedError, u as resolveDecision, v as parseAgentEvent } from "./decision-m5hGmHpF.mjs";
3
- import { i as isActLogic, n as DEFAULT_ACT_MAX_STEPS, t as ACT_STATE_EXITED } from "./act-B9hLQls6.mjs";
4
- import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-BDmNr6PC.mjs";
5
- import { _ as runToQuiescence, a as AgentSnapshotDivergedError, b as traceTransitions, c as bindDecisionForProvide, d as createAgentRuntime, f as getConfiguredInvokeSrcs, g as runAgent, h as isStateMachineLogic, i as AgentMaxModelCallsExceededError, l as bindTextForProvide, m as isAgentIdle, n as mapEffects, o as bindActForProvide, p as inspectTransitions, r as AGENT_TRACE_SCHEMA_VERSION, s as bindChildMachineForProvide, t as isAsyncIterable, u as createAgentInbox, v as serializeTraceEvent, x as decideNext, y as toJsonValue } from "./effects-BT_cSY0j.mjs";
6
- import { t as AgentEventLogConflictError } from "./event-log-store-Brx9tOHt.mjs";
1
+ import { $ as getJsonSchemaSync, A as bindRequestExecutor, B as parseProviderOutput, C as AGENT_USAGE_EVENT_TYPE, G as getAgentExecutionOptions, I as getCallUsage, L as isTextLogic, M as createTextLogic, N as getAgentOutputMode, P as getCallFinishReason, Q as getJsonSchema, V as providerOutputSchema, W as executorBoundLogics, X as assistantMessage, at as systemMessage, et as getMessageText, i as AgentMachineVersionMismatchError, mt as AgentTruncatedError, nt as getStatePath, ot as toolMessage, pt as AgentError, rt as isStandardSchema, st as userMessage, tt as getStateMeta, z as parseOutput } from "./event-log-CEq_bVXQ.mjs";
2
+ import { a as createDecisionRequest, c as renderDecisionAttempts, d as GROUPED_EVENT_THRESHOLD, f as MAX_FINITE_PAYLOADS, h as getAcceptedEvents, i as createDecisionLogic, m as AgentInvalidEventPayloadError, s as isDecisionLogic, t as AgentDecisionExhaustedError, u as resolveDecision, v as parseAgentEvent } from "./decision-B41YBx5U.mjs";
3
+ import { i as isActLogic, n as DEFAULT_ACT_MAX_STEPS, t as ACT_STATE_EXITED } from "./act-Bsz-hUfD.mjs";
4
+ import { n as getAgentSchemas, r as setupAgent, t as createAgentSchemas } from "./setup-agent-CLm6QVGy.mjs";
5
+ import { t as AgentEventLogConflictError } from "./event-log-store-DLAfNM34.mjs";
6
+ import { _ as traceTransitions, a as bindChildMachineForProvide, c as createAgentInbox, d as isAgentIdle, f as isStateMachineLogic, g as toJsonValue, h as serializeTraceEvent, i as bindActForProvide, l as createAgentRuntime, n as AgentMaxModelCallsExceededError, o as bindDecisionForProvide, p as runAgent, r as AgentSnapshotDivergedError, s as bindTextForProvide, t as AGENT_TRACE_SCHEMA_VERSION, u as getConfiguredInvokeSrcs } from "./run-agent-BE7DOWD6.mjs";
7
+ import { n as mapEffects, t as isAsyncIterable } from "./effects-B9IvUPVh.mjs";
7
8
  import { createAsyncLogic, machineToJSON } from "xstate";
8
9
  import { parse } from "acorn";
9
10
  //#region src/messages.ts
@@ -866,76 +867,117 @@ function describeMachine(machine, options = {}) {
866
867
  return lines.join("\n");
867
868
  }
868
869
  //#endregion
869
- //#region src/policy-decider.ts
870
+ //#region src/generator-bridge.ts
871
+ /** A `runAgent` result that settled with an error. */
872
+ function isFailedRun(value) {
873
+ return typeof value === "object" && value !== null && value.status === "error" && "error" in value;
874
+ }
870
875
  /**
871
- * Runs a policy machine as a decide executor: each decision request starts one
872
- * run of `policy`, and its output is the chosen event. The policy can answer
873
- * with a rule (a `choice` over the facts, no model call) and invoke
874
- * `agent.decide` for the rest, answered by `options.executors`.
876
+ * A backpressured hand-off between an actor and an async generator's
877
+ * consumer, for a loop whose public surface is an `AsyncGenerator`: the
878
+ * machine owns the loop head, each pass is an actor, and the events it
879
+ * yields still reach the consumer one pull at a time.
875
880
  *
876
- * The environment still judges the event: one it does not accept is retried
877
- * like any other decider's choice. The policy's input must be JSON (it opens
878
- * the policy run's event log): the default drops keys whose value is
879
- * `undefined`, and any other value that is not JSON throws before the run. The policy's token usage is reported on the
880
- * result, and left out when the policy made no model call. A run that does not
881
- * end `done` with an event throws `AgentError` with code `policy-not-done`.
881
+ * One bridge serves one run.
882
882
  *
883
883
  * @example
884
- * ```ts no-check
885
- * const decide = createPolicyDecider(policyMachine, { executors: modelExecutors });
886
- * await runAgent(deskMachine, { input, executors: { ...modelExecutors, decide } });
884
+ * ```ts
885
+ * async function* carvedLoop(input: Input): AsyncGenerator<Event, Result> {
886
+ * const bridge = createGeneratorBridge<Event>();
887
+ * const pass = createAsyncLogic({
888
+ * run: async () => {
889
+ * const step = await bridge.forward(legacyPass(input));
890
+ * return step.closed ? { kind: "closed" } : step.value;
891
+ * },
892
+ * });
893
+ * const result = yield* bridge.stream(runAgent(loopMachine, { input, actors: { pass } }));
894
+ * if (result.status === "error") throw result.error;
895
+ * return toResult(result);
896
+ * }
887
897
  * ```
888
898
  */
889
- function createPolicyDecider(policy, options = {}) {
890
- const { input = defaultInput, threadId, ...runOptions } = options;
891
- const id = policy.config.id ?? policy.id;
892
- return async (request, info) => {
893
- const policyInput = input(request);
894
- assertJsonSerializable(policyInput, "policy input");
895
- const thread = runOptions.store === void 0 ? void 0 : await policyThread(request, policyInput, info);
896
- const result = await runAgent(policy, {
897
- ...runOptions,
898
- input: policyInput,
899
- ...thread === void 0 ? {} : { threadId: thread },
900
- ...info?.signal ? { signal: info.signal } : {}
899
+ function createGeneratorBridge() {
900
+ const queue = [];
901
+ let wake;
902
+ let ended = false;
903
+ const notify = () => {
904
+ const resume = wake;
905
+ wake = void 0;
906
+ resume?.();
907
+ };
908
+ const put = (value) => {
909
+ if (ended) return Promise.resolve(false);
910
+ return new Promise((pulled, threw) => {
911
+ queue.push({
912
+ value,
913
+ pulled,
914
+ threw
915
+ });
916
+ notify();
901
917
  });
902
- if (result.status !== "done") {
903
- const why = result.status === "error" ? `: ${String(result.error)}` : "";
904
- throw new AgentError("policy-not-done", `policy '${id}' settled '${result.status}'${why}`, { cause: result.status === "error" ? result.error : void 0 });
918
+ };
919
+ return {
920
+ put,
921
+ async forward(generator) {
922
+ let closed = false;
923
+ let step = await generator.next();
924
+ while (!step.done) {
925
+ let pulled;
926
+ try {
927
+ pulled = await put(step.value);
928
+ } catch (error) {
929
+ step = await generator.throw(error);
930
+ continue;
931
+ }
932
+ if (pulled || closed) step = await generator.next();
933
+ else {
934
+ closed = true;
935
+ step = await generator.return(void 0);
936
+ }
937
+ }
938
+ return {
939
+ closed,
940
+ value: step.value
941
+ };
942
+ },
943
+ stream(settled) {
944
+ const end = () => {
945
+ ended = true;
946
+ for (const item of queue.splice(0)) item.pulled(false);
947
+ notify();
948
+ };
949
+ Promise.resolve(settled).then(end, end);
950
+ const next = async () => {
951
+ while (!queue.length && !ended) await new Promise((resolve) => wake = resolve);
952
+ return queue.shift();
953
+ };
954
+ const loop = async function* (stopped) {
955
+ while (true) {
956
+ const item = await next();
957
+ if (!item) {
958
+ const result = await settled;
959
+ if (stopped && isFailedRun(result)) throw result.error;
960
+ return result;
961
+ }
962
+ let resumed = false;
963
+ try {
964
+ yield item.value;
965
+ resumed = true;
966
+ item.pulled(true);
967
+ } catch (error) {
968
+ resumed = true;
969
+ item.threw(error);
970
+ } finally {
971
+ if (!resumed) {
972
+ item.pulled(false);
973
+ return yield* loop(true);
974
+ }
975
+ }
976
+ }
977
+ };
978
+ return loop(false);
905
979
  }
906
- const event = result.output;
907
- if (!isRecord(event) || typeof event.type !== "string") throw new AgentError("policy-not-done", `policy '${id}' output is not an event: ${JSON.stringify(event)}`);
908
- const { modelCalls, ...usage } = result.usage;
909
- return {
910
- event,
911
- ...modelCalls > 0 ? { usage } : {}
912
- };
913
980
  };
914
- async function policyThread(request, policyInput, info) {
915
- if (threadId) return threadId(request, info);
916
- if (info?.callKey) return `policy:${info.callKey}:${await sha256(canonicalEventJson(policyInput))}`;
917
- throw new AgentError("missing-thread-id", `policy '${id}' has a store but no threadId, and the decision came with no callKey to derive one from`);
918
- }
919
- }
920
- function defaultInput(request) {
921
- const facts = request.metadata?.facts;
922
- return withoutUndefinedKeys({
923
- facts,
924
- options: (request.options ?? []).map((option) => option.event),
925
- system: request.system,
926
- prompt: request.prompt
927
- });
928
- }
929
- /** A copy of `value` with every object key whose value is `undefined` removed, at any depth. */
930
- function withoutUndefinedKeys(value) {
931
- if (Array.isArray(value)) return value.map(withoutUndefinedKeys);
932
- if (!isRecord(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) return value;
933
- return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0).map(([key, child]) => [key, withoutUndefinedKeys(child)]));
934
- }
935
- /** Hex SHA-256 of `text`, with Web Crypto (Node, browsers, workers). */
936
- async function sha256(text) {
937
- const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
938
- return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
939
981
  }
940
982
  //#endregion
941
983
  //#region src/wrap-workflow.ts
@@ -1217,12 +1259,12 @@ function wrapWorkflow(config) {
1217
1259
  return {
1218
1260
  machine,
1219
1261
  async run(input, options = {}) {
1220
- const { effects: overrides, recorder, ...runOptions } = options;
1262
+ const { effects: overrides, recorder, recordOptions, ...runOptions } = options;
1221
1263
  let effects = {
1222
1264
  ...mapEffects(config.effects, (_name, effect) => effect),
1223
1265
  ...overrides ? mapEffects(overrides, (_name, effect) => effect) : {}
1224
1266
  };
1225
- if (recorder) effects = mapEffects(effects, (name, effect) => recorder.fn(name, effect));
1267
+ if (recorder) effects = mapEffects(effects, (name, effect) => recorder.fn(name, effect, recordOptions?.[name]));
1226
1268
  const { signal: _signal, ...agentOptions } = runOptions;
1227
1269
  const result = await runAgent(machine, {
1228
1270
  ...agentOptions,
@@ -1359,4 +1401,4 @@ function missingExecutorError(src, kind, executor) {
1359
1401
  return /* @__PURE__ */ new Error(`provideExecutors: actor source '${src}' is a ${kind} source but no '${executor}' executor was provided. Add it to the executors object, or bind the source with its own executor (logic.withExecutor(...)) before calling provideExecutors.`);
1360
1402
  }
1361
1403
  //#endregion
1362
- export { ACT_STATE_EXITED, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, AgentDecisionExhaustedError, AgentError, AgentEventLogConflictError, AgentInvalidEventPayloadError, AgentMachineVersionMismatchError, AgentMaxModelCallsExceededError, AgentSnapshotDivergedError, AgentTruncatedError, DEFAULT_ACT_MAX_STEPS, GROUPED_EVENT_THRESHOLD, MAX_FINITE_PAYLOADS, assistantMessage, bindRequestExecutor, createAgentInbox, createAgentRuntime, createAgentSchemas, createDecisionLogic, createDecisionRequest, createPolicyDecider, createTextLogic, decideNext, describeMachine, eventFromInteraction, getAcceptedEvents, getAgentOutputMode, getAgentSchemas, getCallFinishReason, getCallUsage, getInteraction, getJsonSchema, getJsonSchemaSync, getMachineStructuralHash, getMessageText, getStateMeta, getStatePath, inspectTransitions, interactionMetaSchema, isAgentIdle, isAgentMessages, isStandardSchema, messagesSchema, parseAgentEvent, parseOutput, parseProviderOutput, provideExecutors, providerOutputSchema, renderDecisionAttempts, resolveDecision, runAgent, runToQuiescence, serializeTraceEvent, setupAgent, systemMessage, toolMessage, traceTransitions, userMessage, wrapWorkflow };
1404
+ export { ACT_STATE_EXITED, AGENT_TRACE_SCHEMA_VERSION, AGENT_USAGE_EVENT_TYPE, AgentDecisionExhaustedError, AgentError, AgentEventLogConflictError, AgentInvalidEventPayloadError, AgentMachineVersionMismatchError, AgentMaxModelCallsExceededError, AgentSnapshotDivergedError, AgentTruncatedError, DEFAULT_ACT_MAX_STEPS, GROUPED_EVENT_THRESHOLD, MAX_FINITE_PAYLOADS, assistantMessage, bindRequestExecutor, createAgentInbox, createAgentRuntime, createAgentSchemas, createDecisionLogic, createDecisionRequest, createGeneratorBridge, createTextLogic, describeMachine, eventFromInteraction, getAcceptedEvents, getAgentOutputMode, getAgentSchemas, getCallFinishReason, getCallUsage, getInteraction, getJsonSchema, getJsonSchemaSync, getMessageText, getStateMeta, getStatePath, interactionMetaSchema, isAgentIdle, isAgentMessages, isStandardSchema, messagesSchema, parseAgentEvent, parseOutput, parseProviderOutput, provideExecutors, providerOutputSchema, renderDecisionAttempts, resolveDecision, runAgent, serializeTraceEvent, setupAgent, systemMessage, toolMessage, traceTransitions, userMessage, wrapWorkflow };
@@ -0,0 +1,14 @@
1
+ import { AnyActorRef, EventObject, MachineContext, MetaObject, StateMachine, StateSchema, StateValue } from "xstate";
2
+ //#region src/machines/internal.d.ts
3
+ /**
4
+ * The machine type a preset factory returns: its context, event union, input
5
+ * and output are all concrete, so callers get typed run input and
6
+ * output instead of `AnyStateMachine`. The remaining slots (children, state
7
+ * value/tags/config, source maps) are left permissive — a preset builds its
8
+ * states dynamically, so there is no literal state schema to infer.
9
+ *
10
+ * @internal
11
+ */
12
+ type PresetMachine<TContext extends MachineContext, TInput, TOutput, TEvent extends EventObject = EventObject> = StateMachine<TContext, TEvent, Record<string, AnyActorRef | undefined>, StateValue, string, TInput, TOutput, EventObject, MetaObject, StateSchema, any, any, any, any>;
13
+ //#endregion
14
+ export { PresetMachine as t };
@@ -0,0 +1,14 @@
1
+ import { AnyActorRef, EventObject, MachineContext, MetaObject, StateMachine, StateSchema, StateValue } from "xstate";
2
+ //#region src/machines/internal.d.ts
3
+ /**
4
+ * The machine type a preset factory returns: its context, event union, input
5
+ * and output are all concrete, so callers get typed run input and
6
+ * output instead of `AnyStateMachine`. The remaining slots (children, state
7
+ * value/tags/config, source maps) are left permissive — a preset builds its
8
+ * states dynamically, so there is no literal state schema to infer.
9
+ *
10
+ * @internal
11
+ */
12
+ type PresetMachine<TContext extends MachineContext, TInput, TOutput, TEvent extends EventObject = EventObject> = StateMachine<TContext, TEvent, Record<string, AnyActorRef | undefined>, StateValue, string, TInput, TOutput, EventObject, MetaObject, StateSchema, any, any, any, any>;
13
+ //#endregion
14
+ export { PresetMachine as t };
package/dist/log.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_event_log = require("./event-log-Dkc-yIYu.cjs");
3
- const require_event_log_store = require("./event-log-store-Cl-YWDnq.cjs");
2
+ const require_event_log = require("./event-log-dSOnXHuG.cjs");
3
+ const require_event_log_store = require("./event-log-store-Dey9ufA4.cjs");
4
4
  //#region src/event-log-store-conformance.ts
5
5
  /**
6
6
  * The runner-agnostic conformance suite for {@link AgentEventLogStore}
@@ -478,7 +478,6 @@ exports.getLogExecutionId = require_event_log.getLogExecutionId;
478
478
  exports.getSnapshotStateHash = require_event_log.getSnapshotStateHash;
479
479
  exports.getUsageFromEvents = require_event_log.getUsageFromEvents;
480
480
  exports.initEntry = require_event_log.initEntry;
481
- exports.rebindActorSession = require_event_log.rebindActorSession;
482
481
  exports.recordLog = require_event_log.recordLog;
483
482
  exports.replay = require_event_log.replay;
484
483
  exports.validateReplayEntries = require_event_log.validateReplayEntries;
package/dist/log.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as rebindActorSession, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as replay, N as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as recordLog, k as initEntry, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-bc4ICGcS.cjs";
1
+ import { A as recordLog, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as replay, k as initEntry, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-aFXK6yZX.cjs";
2
2
  //#region src/event-log-store-conformance.d.ts
3
3
  /** Produces a fresh, empty store for one case. */
4
4
  type CreateStore = () => Promise<AgentEventLogStore> | AgentEventLogStore;
@@ -29,4 +29,4 @@ interface EventLogStoreConformanceHarness {
29
29
  */
30
30
  export declare function assertEventLogStoreConformance(create: CreateStore, harness?: EventLogStoreConformanceHarness): Promise<void>;
31
31
  //#endregion
32
- export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, type AgentEventLogStore, type AgentInitEvent, type AgentLogEntry, type AgentLogInit, type AgentLogVerification, AgentMachineVersionMismatchError, type AgentPersistedSnapshot, AgentReplayDivergenceError, type CreateReplayEntryOptions, type EventLogStoreConformanceHarness, type JsonValue, type LogRecorder, NonSerializableAgentEventError, type ReplayOptions, type ReplayResult, agentCallOccurrence, assertAgentLogEntry, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getDecisionAttempts, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, rebindActorSession, recordLog, replay, validateReplayEntries };
32
+ export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, type AgentEventLogStore, type AgentInitEvent, type AgentLogEntry, type AgentLogInit, type AgentLogVerification, AgentMachineVersionMismatchError, type AgentPersistedSnapshot, AgentReplayDivergenceError, type CreateReplayEntryOptions, type EventLogStoreConformanceHarness, type JsonValue, type LogRecorder, NonSerializableAgentEventError, type ReplayOptions, type ReplayResult, agentCallOccurrence, assertAgentLogEntry, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getDecisionAttempts, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, recordLog, replay, validateReplayEntries };
package/dist/log.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as rebindActorSession, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as replay, N as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as recordLog, k as initEntry, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-BBS8so8a.mjs";
1
+ import { A as recordLog, C as createReplayEntry, D as getSnapshotStateHash, E as getLogExecutionId, M as validateReplayEntries, O as getUsageFromEvents, S as assertJsonSerializable, T as getDecisionAttempts, _ as NonSerializableAgentEventError, a as AGENT_INIT_EVENT_TYPE, b as agentCallOccurrence, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as LogRecorder, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, j as replay, k as initEntry, l as AgentLogInit, m as CreateReplayEntryOptions, n as AgentEventLogStore, o as AgentEventLogError, p as AgentReplayDivergenceError, r as createInMemoryEventLogStore, s as AgentInitEvent, t as AgentEventLogConflictError, u as AgentLogVerification, v as ReplayOptions, w as forkEventLog, x as assertAgentLogEntry, y as ReplayResult } from "./event-log-store-DYun526m.mjs";
2
2
  //#region src/event-log-store-conformance.d.ts
3
3
  /** Produces a fresh, empty store for one case. */
4
4
  type CreateStore = () => Promise<AgentEventLogStore> | AgentEventLogStore;
@@ -29,4 +29,4 @@ interface EventLogStoreConformanceHarness {
29
29
  */
30
30
  export declare function assertEventLogStoreConformance(create: CreateStore, harness?: EventLogStoreConformanceHarness): Promise<void>;
31
31
  //#endregion
32
- export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, type AgentEventLogStore, type AgentInitEvent, type AgentLogEntry, type AgentLogInit, type AgentLogVerification, AgentMachineVersionMismatchError, type AgentPersistedSnapshot, AgentReplayDivergenceError, type CreateReplayEntryOptions, type EventLogStoreConformanceHarness, type JsonValue, type LogRecorder, NonSerializableAgentEventError, type ReplayOptions, type ReplayResult, agentCallOccurrence, assertAgentLogEntry, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getDecisionAttempts, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, rebindActorSession, recordLog, replay, validateReplayEntries };
32
+ export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, type AgentEventLogStore, type AgentInitEvent, type AgentLogEntry, type AgentLogInit, type AgentLogVerification, AgentMachineVersionMismatchError, type AgentPersistedSnapshot, AgentReplayDivergenceError, type CreateReplayEntryOptions, type EventLogStoreConformanceHarness, type JsonValue, type LogRecorder, NonSerializableAgentEventError, type ReplayOptions, type ReplayResult, agentCallOccurrence, assertAgentLogEntry, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getDecisionAttempts, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, recordLog, replay, validateReplayEntries };
package/dist/log.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { C as validateReplayEntries, S as replay, _ as getSnapshotStateHash, a as AgentReplayDivergenceError, b as rebindActorSession, f as createReplayEntry, g as getLogExecutionId, h as getDecisionAttempts, i as AgentMachineVersionMismatchError, l as assertAgentLogEntry, m as forkEventLog, n as AGENT_INIT_EVENT_TYPE, o as NonSerializableAgentEventError, r as AgentEventLogError, s as agentCallOccurrence, t as AGENT_EVENT_SCHEMA_VERSION, u as assertJsonSerializable, v as getUsageFromEvents, x as recordLog, y as initEntry } from "./event-log-DkVlk3Rh.mjs";
2
- import { n as createInMemoryEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-Brx9tOHt.mjs";
1
+ import { S as validateReplayEntries, _ as getSnapshotStateHash, a as AgentReplayDivergenceError, b as recordLog, f as createReplayEntry, g as getLogExecutionId, h as getDecisionAttempts, i as AgentMachineVersionMismatchError, l as assertAgentLogEntry, m as forkEventLog, n as AGENT_INIT_EVENT_TYPE, o as NonSerializableAgentEventError, r as AgentEventLogError, s as agentCallOccurrence, t as AGENT_EVENT_SCHEMA_VERSION, u as assertJsonSerializable, v as getUsageFromEvents, x as replay, y as initEntry } from "./event-log-CEq_bVXQ.mjs";
2
+ import { n as createInMemoryEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-DLAfNM34.mjs";
3
3
  //#region src/event-log-store-conformance.ts
4
4
  /**
5
5
  * The runner-agnostic conformance suite for {@link AgentEventLogStore}
@@ -458,4 +458,4 @@ async function assertEventLogStoreConformance(create, harness) {
458
458
  for (const testCase of cases) await testCase.run(create);
459
459
  }
460
460
  //#endregion
461
- export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, AgentMachineVersionMismatchError, AgentReplayDivergenceError, NonSerializableAgentEventError, agentCallOccurrence, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getDecisionAttempts, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, rebindActorSession, recordLog, replay, validateReplayEntries };
461
+ export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, AgentMachineVersionMismatchError, AgentReplayDivergenceError, NonSerializableAgentEventError, agentCallOccurrence, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getDecisionAttempts, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, recordLog, replay, validateReplayEntries };