@statelyai/agent 2.0.0-alpha.25 → 2.0.0-alpha.27

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 (53) hide show
  1. package/dist/ai-sdk.cjs +4 -4
  2. package/dist/ai-sdk.d.cts +6 -6
  3. package/dist/ai-sdk.d.mts +6 -6
  4. package/dist/ai-sdk.mjs +4 -4
  5. package/dist/{decision-CM9CYZ6t.cjs → decision-CmM8-HHz.cjs} +10 -9
  6. package/dist/{decision-DzSv1NpD.mjs → decision-RQ0iv0oZ.mjs} +10 -9
  7. package/dist/{event-log-store-Ba2fsc4E.mjs → event-log-store-2pAFiWuc.mjs} +1 -1
  8. package/dist/{event-log-store-DvOcs10J.d.cts → event-log-store-2xzFmgr2.d.cts} +1 -1
  9. package/dist/{event-log-store-DxyVgnas.d.mts → event-log-store-BIPOz-di.d.mts} +1 -1
  10. package/dist/{event-log-store-DQmImLYk.cjs → event-log-store-C-COhIXP.cjs} +1 -1
  11. package/dist/index.cjs +13 -195
  12. package/dist/index.d.cts +25 -105
  13. package/dist/index.d.mts +25 -105
  14. package/dist/index.mjs +12 -189
  15. package/dist/log.cjs +1 -1
  16. package/dist/log.d.cts +1 -1
  17. package/dist/log.d.mts +1 -1
  18. package/dist/log.mjs +1 -1
  19. package/dist/machines.cjs +4 -7
  20. package/dist/machines.d.cts +5 -7
  21. package/dist/machines.d.mts +5 -7
  22. package/dist/machines.mjs +4 -7
  23. package/dist/openai.cjs +3 -3
  24. package/dist/openai.d.cts +5 -5
  25. package/dist/openai.d.mts +5 -5
  26. package/dist/openai.mjs +3 -3
  27. package/dist/otel.cjs +2 -2
  28. package/dist/otel.d.cts +3 -3
  29. package/dist/otel.d.mts +3 -3
  30. package/dist/otel.mjs +2 -2
  31. package/dist/{run-agent-CG343kFs.d.mts → run-agent-ByO-Bxyd.d.cts} +184 -179
  32. package/dist/{run-agent-BOfoJg5B.d.cts → run-agent-COXXc0RW.d.mts} +184 -179
  33. package/dist/{run-agent-Cb1-LS5P.cjs → run-agent-Dmf8GV2d.cjs} +539 -737
  34. package/dist/{run-agent-DvDQd4If.mjs → run-agent-xNTxpt82.mjs} +537 -705
  35. package/dist/{setup-agent-CFW-jPI8.mjs → setup-agent-BuanDXeh.mjs} +6 -28
  36. package/dist/{setup-agent-CPf7MxnG.cjs → setup-agent-DV4cTou-.cjs} +6 -28
  37. package/dist/testing.cjs +285 -170
  38. package/dist/testing.d.cts +39 -22
  39. package/dist/testing.d.mts +39 -22
  40. package/dist/testing.mjs +270 -155
  41. package/dist/{text-logic-Bl_ZRxDi.mjs → text-logic-CIqHAmBi.mjs} +10 -26
  42. package/dist/{text-logic-BFEOxyxv.d.cts → text-logic-D-czVPYp.d.mts} +27 -28
  43. package/dist/{text-logic-hZSiRUo1.d.mts → text-logic-IjfYy9DP.d.cts} +27 -28
  44. package/dist/{text-logic-C8xyr6Ag.cjs → text-logic-f5F5sCdc.cjs} +9 -43
  45. package/dist/{types-B1Qs2q3q.d.cts → types-BgNbNKnJ.d.mts} +3 -3
  46. package/dist/{types-tA3SdczG.d.mts → types-hR5f5YXa.d.cts} +3 -3
  47. package/dist/{utils-C1p37X_c.d.mts → utils-_q7F-AZu.d.mts} +3 -103
  48. package/dist/{utils-RalRn9sk.d.cts → utils-o4YRdHJX.d.cts} +3 -103
  49. package/dist/validate.cjs +0 -8
  50. package/dist/validate.mjs +0 -8
  51. package/package.json +5 -4
  52. package/readme.md +8 -4
  53. package/schemas/agent-workflow.json +0 -8
@@ -1,5 +1,5 @@
1
- import { E as setAgentExecutionOptions, T as missingActor, V as validateSchemaSync, b as getAgentExecutionOptions, n as DECIDE_ACTOR, o as builtinTextActors, s as createTextLogic, w as machineIdlePredicates } from "./text-logic-Bl_ZRxDi.mjs";
2
- import { n as createDecideActor } from "./decision-DzSv1NpD.mjs";
1
+ import { C as setAgentExecutionOptions, R as validateSchemaSync, S as missingActor, n as DECIDE_ACTOR, o as builtinTextActors, s as createTextLogic, y as getAgentExecutionOptions } from "./text-logic-CIqHAmBi.mjs";
2
+ import { n as createDecideActor } from "./decision-RQ0iv0oZ.mjs";
3
3
  import { t as AGENT_USAGE_EVENT_TYPE } from "./usage-BdEjFuIi.mjs";
4
4
  import { createMachineFromConfig, setup } from "xstate";
5
5
  //#region src/workflow-config.ts
@@ -273,22 +273,6 @@ function translateWorkflowConfig(config, translation) {
273
273
  if (json.output === void 0 && finalOutputs.length === 1) json.output = finalOutputs[0];
274
274
  return json;
275
275
  }
276
- function collectDeclaredStateTags(states, tags = /* @__PURE__ */ new Set()) {
277
- for (const state of Object.values(states ?? {})) {
278
- for (const tag of state.tags ?? []) tags.add(tag);
279
- collectDeclaredStateTags(state.states, tags);
280
- }
281
- return tags;
282
- }
283
- function resolveIdlePredicate(config, options) {
284
- if (options.isIdle) return options.isIdle;
285
- const idleTags = config.idleTags ?? [];
286
- if (!idleTags.length) return;
287
- const declaredTags = collectDeclaredStateTags(config.states);
288
- const unknown = idleTags.filter((tag) => !declaredTags.has(tag));
289
- if (unknown.length) throw new Error(`setupAgent.fromConfig: 'idleTags' lists ${unknown.map((tag) => `'${tag}'`).join(", ")}, which no state declares in its 'tags'. Tag the waiting state(s) — e.g. "tags": ["${unknown[0]}"] — or remove the entry.`);
290
- return (snapshot) => idleTags.some((tag) => snapshot.hasTag(tag));
291
- }
292
276
  function setupAgentFromConfig(config, options) {
293
277
  if (!options || typeof options.compileSchema !== "function") throw new Error("setupAgent.fromConfig(...) requires a 'compileSchema' option: { compileSchema: (jsonSchema, name) => StandardSchemaV1 }. Bring your own JSON Schema engine (Ajv, @cfworker/json-schema, a compiled-Zod-from-JSON-Schema pipeline, ...). Core intentionally ships no JSON Schema engine.");
294
278
  const { compileSchema } = options;
@@ -310,16 +294,14 @@ function setupAgentFromConfig(config, options) {
310
294
  event: args.event
311
295
  }))])),
312
296
  ...options.actions ? { actions: options.actions } : {},
313
- actors: Object.fromEntries(Object.keys(actors).map((key) => [key, key])),
297
+ actors,
314
298
  evaluators: { [AGENT_EXPRESSION_LANG]: createWorkflowConfigEvaluator(schemas.context) }
315
- }).provide({ actors });
299
+ });
316
300
  setAgentExecutionOptions(machine, {
317
301
  schemas,
318
302
  actors,
319
303
  models: {}
320
304
  });
321
- const isIdle = resolveIdlePredicate(config, options);
322
- if (isIdle && machine.config) machineIdlePredicates.set(machine.config, isIdle);
323
305
  return {
324
306
  machine,
325
307
  schemas
@@ -388,7 +370,7 @@ const agentUsageEventSchema = { "~standard": {
388
370
  * Adds the reserved `'@agent.usage'` schema to an authored event map. A
389
371
  * user-declared entry under that key is rejected: the `@agent.*` namespace
390
372
  * belongs to the library (same rule as the reserved `agent.*` actor keys), and
391
- * a custom payload schema would silently disagree with what `runAgent`
373
+ * a custom payload schema would silently disagree with what the runtime
392
374
  * delivers.
393
375
  */
394
376
  function withAgentUsageEventSchema(events) {
@@ -423,7 +405,7 @@ function createAgentSchemas(schemas) {
423
405
  /**
424
406
  * Schema-first `setup(...)` for agent machines — the standard entry point
425
407
  * for authoring a machine (the blueprint) that this library then runs (via
426
- * {@link runAgent} or the step helpers) against host-supplied model/decision
408
+ * {@link createAgentRuntime}) against host-supplied model/decision
427
409
  * executors. Context, events, machine input, machine output, and
428
410
  * state/transition meta are all standard schemas — no `{} as Type` casts —
429
411
  * and are retained on `result.schemas` for runtime validation. Also
@@ -496,10 +478,6 @@ function setupAgent(config) {
496
478
  assertStateSchemaKeysExist(config.states, machineConfig?.states);
497
479
  const machine = createBaseMachine(withRootOutputFromSingleFinal(machineConfig));
498
480
  setAgentExecutionOptions(machine, machineOptions);
499
- if (config.isIdle) {
500
- const rootConfig = machine.config;
501
- if (rootConfig) machineIdlePredicates.set(rootConfig, config.isIdle);
502
- }
503
481
  return machine;
504
482
  },
505
483
  schemas,
@@ -1,5 +1,5 @@
1
- const require_text_logic = require("./text-logic-C8xyr6Ag.cjs");
2
- const require_decision = require("./decision-CM9CYZ6t.cjs");
1
+ const require_text_logic = require("./text-logic-f5F5sCdc.cjs");
2
+ const require_decision = require("./decision-CmM8-HHz.cjs");
3
3
  const require_usage = require("./usage-efOQPdf_.cjs");
4
4
  require("./validate.cjs");
5
5
  let xstate = require("xstate");
@@ -274,22 +274,6 @@ function translateWorkflowConfig(config, translation) {
274
274
  if (json.output === void 0 && finalOutputs.length === 1) json.output = finalOutputs[0];
275
275
  return json;
276
276
  }
277
- function collectDeclaredStateTags(states, tags = /* @__PURE__ */ new Set()) {
278
- for (const state of Object.values(states ?? {})) {
279
- for (const tag of state.tags ?? []) tags.add(tag);
280
- collectDeclaredStateTags(state.states, tags);
281
- }
282
- return tags;
283
- }
284
- function resolveIdlePredicate(config, options) {
285
- if (options.isIdle) return options.isIdle;
286
- const idleTags = config.idleTags ?? [];
287
- if (!idleTags.length) return;
288
- const declaredTags = collectDeclaredStateTags(config.states);
289
- const unknown = idleTags.filter((tag) => !declaredTags.has(tag));
290
- if (unknown.length) throw new Error(`setupAgent.fromConfig: 'idleTags' lists ${unknown.map((tag) => `'${tag}'`).join(", ")}, which no state declares in its 'tags'. Tag the waiting state(s) — e.g. "tags": ["${unknown[0]}"] — or remove the entry.`);
291
- return (snapshot) => idleTags.some((tag) => snapshot.hasTag(tag));
292
- }
293
277
  function setupAgentFromConfig(config, options) {
294
278
  if (!options || typeof options.compileSchema !== "function") throw new Error("setupAgent.fromConfig(...) requires a 'compileSchema' option: { compileSchema: (jsonSchema, name) => StandardSchemaV1 }. Bring your own JSON Schema engine (Ajv, @cfworker/json-schema, a compiled-Zod-from-JSON-Schema pipeline, ...). Core intentionally ships no JSON Schema engine.");
295
279
  const { compileSchema } = options;
@@ -311,16 +295,14 @@ function setupAgentFromConfig(config, options) {
311
295
  event: args.event
312
296
  }))])),
313
297
  ...options.actions ? { actions: options.actions } : {},
314
- actors: Object.fromEntries(Object.keys(actors).map((key) => [key, key])),
298
+ actors,
315
299
  evaluators: { [AGENT_EXPRESSION_LANG]: createWorkflowConfigEvaluator(schemas.context) }
316
- }).provide({ actors });
300
+ });
317
301
  require_text_logic.setAgentExecutionOptions(machine, {
318
302
  schemas,
319
303
  actors,
320
304
  models: {}
321
305
  });
322
- const isIdle = resolveIdlePredicate(config, options);
323
- if (isIdle && machine.config) require_text_logic.machineIdlePredicates.set(machine.config, isIdle);
324
306
  return {
325
307
  machine,
326
308
  schemas
@@ -389,7 +371,7 @@ const agentUsageEventSchema = { "~standard": {
389
371
  * Adds the reserved `'@agent.usage'` schema to an authored event map. A
390
372
  * user-declared entry under that key is rejected: the `@agent.*` namespace
391
373
  * belongs to the library (same rule as the reserved `agent.*` actor keys), and
392
- * a custom payload schema would silently disagree with what `runAgent`
374
+ * a custom payload schema would silently disagree with what the runtime
393
375
  * delivers.
394
376
  */
395
377
  function withAgentUsageEventSchema(events) {
@@ -424,7 +406,7 @@ function createAgentSchemas(schemas) {
424
406
  /**
425
407
  * Schema-first `setup(...)` for agent machines — the standard entry point
426
408
  * for authoring a machine (the blueprint) that this library then runs (via
427
- * {@link runAgent} or the step helpers) against host-supplied model/decision
409
+ * {@link createAgentRuntime}) against host-supplied model/decision
428
410
  * executors. Context, events, machine input, machine output, and
429
411
  * state/transition meta are all standard schemas — no `{} as Type` casts —
430
412
  * and are retained on `result.schemas` for runtime validation. Also
@@ -497,10 +479,6 @@ function setupAgent(config) {
497
479
  assertStateSchemaKeysExist(config.states, machineConfig?.states);
498
480
  const machine = createBaseMachine(withRootOutputFromSingleFinal(machineConfig));
499
481
  require_text_logic.setAgentExecutionOptions(machine, machineOptions);
500
- if (config.isIdle) {
501
- const rootConfig = machine.config;
502
- if (rootConfig) require_text_logic.machineIdlePredicates.set(rootConfig, config.isIdle);
503
- }
504
482
  return machine;
505
483
  },
506
484
  schemas,