@statelyai/agent 2.0.0-alpha.28 → 2.0.0-alpha.29

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 (75) hide show
  1. package/dist/ai-sdk.cjs +149 -26
  2. package/dist/ai-sdk.d.cts +57 -34
  3. package/dist/ai-sdk.d.mts +57 -34
  4. package/dist/ai-sdk.mjs +147 -23
  5. package/dist/{decision-RQ0iv0oZ.mjs → decision-Bl_rKQnU.mjs} +73 -7
  6. package/dist/{decision-CmM8-HHz.cjs → decision-oevZnkBe.cjs} +112 -29
  7. package/dist/{text-logic-f5F5sCdc.cjs → event-log-Dtb16p1p.cjs} +813 -6
  8. package/dist/{text-logic-CIqHAmBi.mjs → event-log-GPZO9p7_.mjs} +679 -3
  9. package/dist/{event-log-store-BIPOz-di.d.mts → event-log-store-CN9ygggF.d.cts} +90 -5
  10. package/dist/{event-log-store-2xzFmgr2.d.cts → event-log-store-DS836wch.d.mts} +90 -5
  11. package/dist/event-log-store-bCdskPNS.cjs +95 -0
  12. package/dist/event-log-store-yalq8C77.mjs +84 -0
  13. package/dist/index.cjs +571 -58
  14. package/dist/index.d.cts +104 -510
  15. package/dist/index.d.mts +104 -510
  16. package/dist/index.mjs +542 -32
  17. package/dist/log.cjs +77 -20
  18. package/dist/log.d.cts +5 -5
  19. package/dist/log.d.mts +5 -5
  20. package/dist/log.mjs +58 -3
  21. package/dist/machines.cjs +1 -1
  22. package/dist/machines.d.cts +15 -15
  23. package/dist/machines.d.mts +15 -15
  24. package/dist/machines.mjs +1 -1
  25. package/dist/model-source-C7FFP2Sj.mjs +39 -0
  26. package/dist/model-source-DjJPjGSP.cjs +44 -0
  27. package/dist/openai.cjs +10 -10
  28. package/dist/openai.d.cts +27 -25
  29. package/dist/openai.d.mts +27 -25
  30. package/dist/openai.mjs +2 -2
  31. package/dist/otel.cjs +5 -4
  32. package/dist/otel.d.cts +5 -7
  33. package/dist/otel.d.mts +5 -7
  34. package/dist/otel.mjs +5 -3
  35. package/dist/{run-agent-COXXc0RW.d.mts → run-agent-C9ubX8Tx.d.cts} +87 -30
  36. package/dist/{run-agent-xNTxpt82.mjs → run-agent-CuQT1xSS.mjs} +170 -42
  37. package/dist/{run-agent-ByO-Bxyd.d.cts → run-agent-CxSyZmIE.d.mts} +87 -30
  38. package/dist/{run-agent-Dmf8GV2d.cjs → run-agent-cToZ3K42.cjs} +219 -86
  39. package/dist/{setup-agent-DV4cTou-.cjs → setup-agent-DTF3NQg3.cjs} +31 -20
  40. package/dist/setup-agent-DlbgwsIJ.d.cts +577 -0
  41. package/dist/{setup-agent-BuanDXeh.mjs → setup-agent-DniLvDu7.mjs} +15 -9
  42. package/dist/setup-agent-tsc3vm5I.d.mts +577 -0
  43. package/dist/tanstack-ai.cjs +627 -0
  44. package/dist/tanstack-ai.d.cts +204 -0
  45. package/dist/tanstack-ai.d.mts +204 -0
  46. package/dist/tanstack-ai.mjs +618 -0
  47. package/dist/testing.cjs +98 -985
  48. package/dist/testing.d.cts +51 -347
  49. package/dist/testing.d.mts +51 -347
  50. package/dist/testing.mjs +86 -973
  51. package/dist/{text-logic-IjfYy9DP.d.cts → text-logic-9fv1i9aK.d.cts} +50 -10
  52. package/dist/{text-logic-D-czVPYp.d.mts → text-logic-BDbGjYMh.d.mts} +50 -10
  53. package/dist/{types-BgNbNKnJ.d.mts → types-Dp5_Ru4R.d.cts} +2 -2
  54. package/dist/{types-hR5f5YXa.d.cts → types-Dp5_Ru4R.d.mts} +2 -2
  55. package/dist/usage-D8UphgEA.d.mts +17 -0
  56. package/dist/usage-R1NTmLxY.d.cts +17 -0
  57. package/dist/{utils-_q7F-AZu.d.mts → utils-BnXdWih3.d.mts} +1 -2
  58. package/dist/{utils-o4YRdHJX.d.cts → utils-ebVpCYoF.d.cts} +1 -2
  59. package/dist/validate.cjs +239 -8
  60. package/dist/validate.d.cts +110 -3
  61. package/dist/validate.d.mts +110 -3
  62. package/dist/validate.mjs +238 -7
  63. package/dist/verify-B5qGC5WN.mjs +1181 -0
  64. package/dist/verify-CBuYIpsa.d.mts +414 -0
  65. package/dist/verify-Cqghu4gz.cjs +1222 -0
  66. package/dist/verify-DYH_2VzU.d.cts +414 -0
  67. package/package.json +44 -31
  68. package/readme.md +38 -26
  69. package/skills/generate-machine/SKILL.md +140 -66
  70. package/skills/improve-machine/SKILL.md +190 -0
  71. package/skills/improve-machine/reference.md +96 -0
  72. package/dist/event-log-store-2pAFiWuc.mjs +0 -576
  73. package/dist/event-log-store-C-COhIXP.cjs +0 -702
  74. package/dist/usage-BdEjFuIi.mjs +0 -5
  75. package/dist/usage-efOQPdf_.cjs +0 -10
package/dist/index.cjs CHANGED
@@ -1,31 +1,31 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_text_logic = require("./text-logic-f5F5sCdc.cjs");
3
- const require_decision = require("./decision-CmM8-HHz.cjs");
4
- const require_usage = require("./usage-efOQPdf_.cjs");
5
- const require_setup_agent = require("./setup-agent-DV4cTou-.cjs");
6
- const require_event_log_store = require("./event-log-store-C-COhIXP.cjs");
7
- const require_run_agent = require("./run-agent-Dmf8GV2d.cjs");
2
+ const require_event_log = require("./event-log-Dtb16p1p.cjs");
3
+ const require_decision = require("./decision-oevZnkBe.cjs");
4
+ const require_setup_agent = require("./setup-agent-DTF3NQg3.cjs");
5
+ const require_event_log_store = require("./event-log-store-bCdskPNS.cjs");
6
+ const require_run_agent = require("./run-agent-cToZ3K42.cjs");
7
+ let xstate = require("xstate");
8
8
  //#region src/messages.ts
9
- const KNOWN_PART_TYPES = new Set([
9
+ const KNOWN_PART_TYPES = /* @__PURE__ */ new Set([
10
10
  "text",
11
11
  "image",
12
12
  "file",
13
13
  "tool-call",
14
14
  "tool-result"
15
15
  ]);
16
- const USER_PART_TYPES = new Set([
16
+ const USER_PART_TYPES = /* @__PURE__ */ new Set([
17
17
  "text",
18
18
  "image",
19
19
  "file"
20
20
  ]);
21
- const ASSISTANT_PART_TYPES = new Set([
21
+ const ASSISTANT_PART_TYPES = /* @__PURE__ */ new Set([
22
22
  "text",
23
23
  "file",
24
24
  "tool-call",
25
25
  "tool-result"
26
26
  ]);
27
- const TOOL_PART_TYPES = new Set(["tool-result"]);
28
- const TOOL_RESULT_CONTENT_PART_TYPES = new Set(["text", "image"]);
27
+ const TOOL_PART_TYPES = /* @__PURE__ */ new Set(["tool-result"]);
28
+ const TOOL_RESULT_CONTENT_PART_TYPES = /* @__PURE__ */ new Set(["text", "image"]);
29
29
  function isKnownPart(part) {
30
30
  const type = part && typeof part === "object" ? part.type : void 0;
31
31
  return typeof type === "string" && KNOWN_PART_TYPES.has(type);
@@ -39,7 +39,7 @@ function isMediaData(value) {
39
39
  function requireMediaData(part, type, field) {
40
40
  return isMediaData(part[field]) ? void 0 : `${type} part requires "${field}" to be a string, Uint8Array, ArrayBuffer, or URL`;
41
41
  }
42
- const TOOL_RESULT_OUTPUT_TYPES = new Set([
42
+ const TOOL_RESULT_OUTPUT_TYPES = /* @__PURE__ */ new Set([
43
43
  "text",
44
44
  "json",
45
45
  "error-text",
@@ -153,11 +153,22 @@ function validateEventMeta(value, path) {
153
153
  if (event !== void 0 && (!event || typeof event !== "object" || Array.isArray(event))) issues.push(issue("Expected an object of fixed event fields", [...path, "event"]));
154
154
  return issues;
155
155
  }
156
+ function validateChoice(value, path) {
157
+ if (!value || typeof value !== "object" || Array.isArray(value)) return [issue("Expected a { label, event } choice", path)];
158
+ const choice = value;
159
+ const issues = [];
160
+ if (typeof choice["label"] !== "string") issues.push(issue("Expected a string", [...path, "label"]));
161
+ if (choice["style"] !== void 0 && typeof choice["style"] !== "string") issues.push(issue("Expected a string", [...path, "style"]));
162
+ const event = choice["event"];
163
+ if (!event || typeof event !== "object" || Array.isArray(event) || typeof event.type !== "string") issues.push(issue("Expected an event object with a string `type`", [...path, "event"]));
164
+ return issues;
165
+ }
156
166
  /**
157
167
  * A {@link StandardSchemaV1} for the state metadata {@link getInteraction}
158
168
  * reads: an object whose optional `interaction` declares a `label` (a string
159
169
  * with `{context.path}` interpolation, or a function of the context), an
160
- * `events` map of choices, and a `textEvent` for free-text answers. This is
170
+ * `events` map of choices, payload `choices` (an array, or a context path to
171
+ * one), and a `textEvent` (a type, or `{ type, field }`) for free-text answers. This is
161
172
  * the default `meta` type `setupAgent` gives a machine; pass it to
162
173
  * `createAgentSchemas({ meta: interactionMetaSchema })` only when building a
163
174
  * schema pack by hand.
@@ -175,13 +186,27 @@ const interactionMetaSchema = { "~standard": {
175
186
  const label = descriptor["label"];
176
187
  if (label !== void 0 && typeof label !== "string" && typeof label !== "function") issues.push(issue("Expected a string or a (context) => string", ["interaction", "label"]));
177
188
  const events = descriptor["events"];
178
- if (events !== void 0) if (!events || typeof events !== "object" || Array.isArray(events)) issues.push(issue("Expected an object keyed by event type", ["interaction", "events"]));
179
- else for (const [type, config] of Object.entries(events)) issues.push(...validateEventMeta(config, [
180
- "interaction",
181
- "events",
182
- type
183
- ]));
184
- if (descriptor["textEvent"] !== void 0 && typeof descriptor["textEvent"] !== "string") issues.push(issue("Expected a string", ["interaction", "textEvent"]));
189
+ if (events !== void 0) {
190
+ if (!events || typeof events !== "object" || Array.isArray(events)) issues.push(issue("Expected an object keyed by event type", ["interaction", "events"]));
191
+ else for (const [type, config] of Object.entries(events)) issues.push(...validateEventMeta(config, [
192
+ "interaction",
193
+ "events",
194
+ type
195
+ ]));
196
+ }
197
+ const choices = descriptor["choices"];
198
+ if (choices !== void 0 && typeof choices !== "string") {
199
+ if (!Array.isArray(choices)) issues.push(issue("Expected an array of choices or a context path string", ["interaction", "choices"]));
200
+ else choices.forEach((choice, index) => {
201
+ issues.push(...validateChoice(choice, [
202
+ "interaction",
203
+ "choices",
204
+ index
205
+ ]));
206
+ });
207
+ }
208
+ const textEvent = descriptor["textEvent"];
209
+ if (textEvent !== void 0 && typeof textEvent !== "string" && !(textEvent && typeof textEvent === "object" && typeof textEvent.type === "string" && typeof textEvent.field === "string")) issues.push(issue("Expected a string or { type, field }", ["interaction", "textEvent"]));
185
210
  return issues.length > 0 ? { issues } : { value };
186
211
  }
187
212
  } };
@@ -198,13 +223,20 @@ function interpolate(label, context, preserveWhitespace) {
198
223
  });
199
224
  return preserveWhitespace ? interpolated : interpolated.replace(/\s+/g, " ").trim();
200
225
  }
226
+ function eventSchemasOf(snapshot) {
227
+ const machine = snapshot.machine;
228
+ return require_event_log.getAgentExecutionOptions(machine)?.schemas?.events ?? (machine?.schemas)?.events;
229
+ }
230
+ function isChoice(value) {
231
+ return validateChoice(value, []).length === 0;
232
+ }
201
233
  /** Reads the active state's interaction metadata and filters it through the
202
234
  * events XState currently accepts. Returns `undefined` when none is declared. */
203
235
  function getInteraction(snapshot, options = {}) {
204
- const interaction = require_text_logic.getStateMeta(snapshot).interaction;
236
+ const interaction = require_event_log.getStateMeta(snapshot).interaction;
205
237
  if (!interaction) return void 0;
206
238
  const preserveWhitespace = options.preserveWhitespace ?? false;
207
- const schemas = require_text_logic.getAgentExecutionOptions(snapshot.machine)?.schemas;
239
+ const eventSchemas = eventSchemasOf(snapshot);
208
240
  const accepted = new Set(require_decision.getAcceptedEvents(snapshot).map((event) => event.type));
209
241
  const label = typeof interaction.label === "function" ? interaction.label({ context: snapshot.context }) : interaction.label ?? "";
210
242
  const events = Object.entries(interaction.events ?? {}).filter((entry) => entry[1] !== void 0 && accepted.has(entry[0])).map(([type, config]) => {
@@ -214,7 +246,7 @@ function getInteraction(snapshot, options = {}) {
214
246
  const complete = require_decision.parseAgentEvent(snapshot, {
215
247
  ...descriptor.event,
216
248
  type
217
- }, { schemas });
249
+ }, { events: eventSchemas });
218
250
  return snapshot.can(complete);
219
251
  } catch {
220
252
  return true;
@@ -227,23 +259,61 @@ function getInteraction(snapshot, options = {}) {
227
259
  ...descriptor.event ? { event: descriptor.event } : {}
228
260
  };
229
261
  });
262
+ const declaresChoices = interaction.choices !== void 0;
263
+ const declared = typeof interaction.choices === "string" ? readPath(snapshot.context, interaction.choices) : interaction.choices;
264
+ const choices = (Array.isArray(declared) ? declared : []).filter(isChoice).filter((choice) => {
265
+ try {
266
+ const event = require_decision.parseAgentEvent(snapshot, choice.event, { events: eventSchemas });
267
+ return snapshot.can(event);
268
+ } catch {
269
+ return false;
270
+ }
271
+ }).map((choice) => ({
272
+ label: interpolate(choice.label, snapshot.context, preserveWhitespace),
273
+ event: choice.event,
274
+ ...choice.style ? { style: choice.style } : {}
275
+ }));
276
+ const text = typeof interaction.textEvent === "string" ? {
277
+ type: interaction.textEvent,
278
+ field: "text"
279
+ } : interaction.textEvent;
230
280
  return {
231
281
  label: interpolate(label, snapshot.context, preserveWhitespace),
232
282
  events,
233
- ...interaction.textEvent && accepted.has(interaction.textEvent) ? { textEvent: interaction.textEvent } : {}
283
+ ...declaresChoices ? { choices } : {},
284
+ ...text && accepted.has(text.type) ? {
285
+ textEvent: text.type,
286
+ ...text.field !== "text" ? { textField: text.field } : {}
287
+ } : {}
234
288
  };
235
289
  }
236
- /** Converts a rendered interaction choice back into a schema-validated machine
237
- * event. Fixed fields declared in metadata are merged before user fields. */
290
+ /**
291
+ * Converts a rendered interaction answer back into a schema-validated machine
292
+ * event:
293
+ *
294
+ * - `{ type, ...fields }` — an `events` choice; fixed fields declared in
295
+ * metadata win over user fields.
296
+ * - `{ text }` — free text, placed in the `textEvent` field.
297
+ * - `{ choice }` — a payload choice, by its index in `getInteraction(snapshot).choices`
298
+ * or by its label. A label that several choices share throws; pass the index.
299
+ */
238
300
  function eventFromInteraction(snapshot, choice) {
239
301
  const interaction = getInteraction(snapshot);
240
302
  if (!interaction) throw new require_decision.AgentInvalidEventPayloadError("(interaction)", "this state renders no interaction, so there is no choice to convert.");
241
303
  let event;
242
- if ("text" in choice) {
304
+ if (!("type" in choice) && "choice" in choice) {
305
+ const choices = interaction.choices ?? [];
306
+ const key = choice.choice;
307
+ const labeled = typeof key === "number" ? [] : choices.flatMap((candidate, index) => candidate.label === key ? [index] : []);
308
+ if (labeled.length > 1) throw new require_decision.AgentInvalidEventPayloadError("(choice)", `${labeled.length} choices are labeled ${JSON.stringify(key)} (indexes ${labeled.join(", ")}); pass { choice: <index> } to pick one.`);
309
+ const picked = typeof key === "number" ? choices[key] : choices[labeled[0] ?? -1];
310
+ if (!picked) throw new require_decision.AgentInvalidEventPayloadError("(choice)", `this interaction offers no choice ${JSON.stringify(key)}. Choices: ${choices.map(({ label }) => JSON.stringify(label)).join(", ") || "(none)"}.`);
311
+ event = { ...picked.event };
312
+ } else if ("text" in choice) {
243
313
  if (!interaction.textEvent) throw new require_decision.AgentInvalidEventPayloadError("(text)", `this interaction takes no free text. Choices: ${interaction.events.map(({ type }) => type).join(", ") || "(none)"}.`);
244
314
  event = {
245
315
  type: interaction.textEvent,
246
- text: choice.text
316
+ [interaction.textField ?? "text"]: choice.text
247
317
  };
248
318
  } else {
249
319
  const descriptor = interaction.events.find(({ type }) => type === choice.type);
@@ -254,7 +324,447 @@ function eventFromInteraction(snapshot, choice) {
254
324
  type: choice.type
255
325
  };
256
326
  }
257
- return require_decision.parseAgentEvent(snapshot, event);
327
+ return require_decision.parseAgentEvent(snapshot, event, { events: eventSchemasOf(snapshot) });
328
+ }
329
+ //#endregion
330
+ //#region src/describe-machine.ts
331
+ /**
332
+ * A machine, described in plain text for a model to read: the prompt for a
333
+ * model that proposes an improved machine, or extra context for a decider.
334
+ *
335
+ * The text is read from the machine's own definition (`machineToJSON`):
336
+ * for a `setupAgent.fromConfig(...)` machine that is the lowered JSON config,
337
+ * so every target, guard and context patch is data; for a TS-authored machine,
338
+ * transitions written as functions are read from their source.
339
+ *
340
+ * @module
341
+ */
342
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
343
+ const toList = (value) => value === void 0 ? [] : Array.isArray(value) ? value : [value];
344
+ const oneLine = (text) => text.replace(/\s+/g, " ").trim();
345
+ /** The source of a function as serialized (`{ "@code" }`) or as a live function. */
346
+ function codeOf(value) {
347
+ if (typeof value === "function") return String(value);
348
+ if (isObject(value) && typeof value["@code"] === "string") return value["@code"];
349
+ }
350
+ /** The decoded value of a fromConfig `{ "@expr": "<json>" }` slot, or the value itself. */
351
+ function decodeExpr(value) {
352
+ if (isObject(value) && typeof value["@expr"] === "string") try {
353
+ return JSON.parse(value["@expr"]);
354
+ } catch {
355
+ return value["@expr"];
356
+ }
357
+ return value;
358
+ }
359
+ /** A target as written, resolved from the state the transition leaves: `#id`, `.child`, or a sibling (`sibling.child`). */
360
+ function resolveTarget(source, target) {
361
+ if (target.startsWith("#")) try {
362
+ return source.machine.getStateNodeById(target.slice(1));
363
+ } catch {
364
+ return;
365
+ }
366
+ const [from, path] = target.startsWith(".") ? [source, target.slice(1)] : [source.parent ?? source, target];
367
+ let node = from;
368
+ for (const key of path.split(".")) node = node?.states[key];
369
+ return node;
370
+ }
371
+ /** A target as said from where the transition starts: a sibling by key, else its path below the machine. */
372
+ const nameOf = (source, target) => target.parent === source.parent ? target.key : target.path.join(".");
373
+ /**
374
+ * The keys of the object literal whose `{` is at `open` in `text`, at its top
375
+ * level: `a`, `b` for `{ a: 1, b, ...c }`, and `…c` for a spread, whose keys
376
+ * cannot be read. Strings, templates and nested brackets are skipped over.
377
+ */
378
+ function objectKeys(text, open) {
379
+ const keys = [];
380
+ let depth = 0;
381
+ let expectKey = false;
382
+ for (let i = open; i < text.length; i++) {
383
+ const c = text[i];
384
+ if (c === "\"" || c === "'" || c === "`") {
385
+ const end = text.indexOf(c, i + 1);
386
+ if (end < 0) break;
387
+ i = end;
388
+ continue;
389
+ }
390
+ if (c === "{" || c === "(" || c === "[") {
391
+ depth++;
392
+ if (depth === 1) expectKey = true;
393
+ continue;
394
+ }
395
+ if (c === "}" || c === ")" || c === "]") {
396
+ if (--depth === 0) break;
397
+ continue;
398
+ }
399
+ if (depth !== 1) continue;
400
+ if (c === ",") {
401
+ expectKey = true;
402
+ continue;
403
+ }
404
+ if (expectKey && !/\s/.test(c)) {
405
+ expectKey = false;
406
+ if (text.startsWith("...", i)) {
407
+ const spread = /^\.\.\.\s*([\w$.]+)(\()?/.exec(text.slice(i));
408
+ keys.push(`…${spread?.[1] ?? ""}${spread?.[2] ? "()" : ""}`);
409
+ continue;
410
+ }
411
+ const key = /^[A-Za-z_$][\w$]*/.exec(text.slice(i))?.[0];
412
+ if (key) {
413
+ keys.push(key);
414
+ i += key.length - 1;
415
+ }
416
+ }
417
+ }
418
+ return keys;
419
+ }
420
+ /** Every key of each object literal that follows a match of `at` in `code`; `…name` when what follows is not a literal. */
421
+ function keysInSource(code, at, keys) {
422
+ for (const match of code.matchAll(at)) {
423
+ const open = match.index + match[0].length - 1;
424
+ if (code[open] === "{") for (const key of objectKeys(code, open)) keys.add(key);
425
+ else {
426
+ const from = /^[\w$.]+(\()?/.exec(code.slice(open));
427
+ keys.add(from ? `…${from[0]}${from[1] ? ")" : ""}` : "…");
428
+ }
429
+ }
430
+ }
431
+ /** What a transition sets in context: a declarative patch's keys, or each `context: { … }` in a function's source. */
432
+ function contextKeys(transition, code) {
433
+ const keys = /* @__PURE__ */ new Set();
434
+ if (code) keysInSource(code, /\bcontext\s*:\s*[^\s]/g, keys);
435
+ if (transition) {
436
+ const context = decodeExpr(transition.context);
437
+ const contextCode = codeOf(context);
438
+ if (contextCode) keysInSource(contextCode, /=>\s*\(\s*\{|\breturn\s*\{/g, keys);
439
+ else if (isObject(context)) for (const key of Object.keys(context)) keys.add(key);
440
+ for (const action of toList(transition.actions)) if (isObject(action) && action.type === "@xstate.assign") {
441
+ const assigned = decodeExpr(action.context);
442
+ if (isObject(assigned)) for (const key of Object.keys(assigned)) keys.add(key);
443
+ }
444
+ }
445
+ return [...keys];
446
+ }
447
+ /** A guard as said in the text: a template's dotted path, a named guard, or `guarded` when it is code. */
448
+ function guardText(guard) {
449
+ if (guard === void 0 || guard === null) return void 0;
450
+ const decoded = decodeExpr(guard);
451
+ if (typeof decoded === "string") return oneLine(/^\{\{\s*([\s\S]*?)\s*\}\}$/.exec(decoded)?.[1] ?? decoded);
452
+ if (isObject(decoded) && typeof decoded.type === "string") return decoded.type.startsWith("__fromConfigGuard") ? "guarded" : decoded.type;
453
+ return "guarded";
454
+ }
455
+ /** True when a transition function's source has a path that returns no transition, so it may not be taken. */
456
+ const mayDecline = (code) => /\bundefined\b|\bnull\b|\breturn\s*;|\bif\s*\(|\s\?\s|&&/.test(code);
457
+ /**
458
+ * Where a transition written as a function goes: every string literal after a
459
+ * `target:` that names a real state node, `(conditional)` when it may decline
460
+ * or pick among several, `(stays)` when its source has no `target`, `?` when
461
+ * it names none that resolves.
462
+ */
463
+ function targetsInSource(source, code, choice) {
464
+ const found = /* @__PURE__ */ new Set();
465
+ for (const [, expression] of code.matchAll(/\btarget\s*:\s*(\[[^\]]*\]|[^,}\n]+)/g)) for (const [, , literal] of expression.matchAll(/(['"`])([^'"`$]+)\1/g)) {
466
+ const node = resolveTarget(source, literal);
467
+ if (node) found.add(node);
468
+ }
469
+ const names = [...found].map((node) => nameOf(source, node));
470
+ if (names.length) {
471
+ const conditional = names.length > 1 || !choice && mayDecline(code);
472
+ return `${names.join(", ")}${conditional ? " (conditional)" : ""}`;
473
+ }
474
+ return /\btarget\s*:/.test(code) ? "?" : "(stays)";
475
+ }
476
+ /** One transition, as a line: `on GO if context.ready → review; sets draft — description`. */
477
+ function transitionLine(source, head, transition, options = {}) {
478
+ const code = codeOf(transition);
479
+ let to;
480
+ let guard;
481
+ let description;
482
+ let sets;
483
+ if (typeof transition === "string") {
484
+ const node = resolveTarget(source, transition);
485
+ to = node ? nameOf(source, node) : `${transition} ?`;
486
+ sets = [];
487
+ } else if (code !== void 0) {
488
+ to = targetsInSource(source, code, options.choice ?? false);
489
+ sets = contextKeys(void 0, code);
490
+ } else if (isObject(transition) && !("@expr" in transition)) {
491
+ const targets = toList(transition.target).filter((t) => typeof t === "string");
492
+ to = targets.length ? targets.map((target) => {
493
+ const node = resolveTarget(source, target);
494
+ return node ? nameOf(source, node) : `${target} ?`;
495
+ }).join(", ") : "(stays)";
496
+ guard = guardText(transition[options.guardKey ?? "guard"]);
497
+ description = typeof transition.description === "string" ? transition.description : void 0;
498
+ sets = contextKeys(transition, void 0);
499
+ } else {
500
+ to = "?";
501
+ sets = [];
502
+ }
503
+ return `${head}${guard ? ` if ${guard}` : ""} → ${to}${sets.length ? `; sets ${sets.join(", ")}` : ""}${description ? ` — ${oneLine(description)}` : ""}`;
504
+ }
505
+ function formatMs(ms) {
506
+ if (ms < 1e3) return `${ms}ms`;
507
+ return `${ms / 1e3}s`;
508
+ }
509
+ /** An `after` key as said: `1s`, or a named delay with its duration when it is a number (`slow (5s)`). */
510
+ function delayText(key, delays) {
511
+ if (/^\d+(\.\d+)?$/.test(key)) return formatMs(Number(key));
512
+ const delay = delays[key];
513
+ return typeof delay === "number" ? `${key} (${formatMs(delay)})` : key;
514
+ }
515
+ /** Every transition leaving one state node, as lines at `pad`. */
516
+ function transitionLines(node, json, delays, pad) {
517
+ const lines = [];
518
+ const push = (head, value) => {
519
+ for (const transition of toList(value)) lines.push(`${pad}${transitionLine(node, head, transition)}`);
520
+ };
521
+ for (const [event, value] of Object.entries(isObject(json.on) ? json.on : {})) push(event === "xstate.done.state" ? "onDone" : `on ${event}`, value);
522
+ push("onDone", json.onDone);
523
+ push("always", json.always);
524
+ for (const [key, value] of Object.entries(isObject(json.after) ? json.after : {})) push(`after ${delayText(key, delays)}`, value);
525
+ for (const invoke of toList(json.invoke)) {
526
+ if (!isObject(invoke)) continue;
527
+ const src = typeof invoke.src === "string" ? invoke.src : "(inline)";
528
+ const id = typeof invoke.id === "string" && invoke.id !== src ? ` (${invoke.id})` : "";
529
+ lines.push(`${pad}invoke ${src}${id}`);
530
+ push(" done", invoke.onDone);
531
+ push(" error", invoke.onError);
532
+ }
533
+ if (json.choice !== void 0) toList(json.choice).forEach((branch, index) => {
534
+ const head = isObject(branch) && branch.when !== void 0 || index === 0 ? "choice" : "choice else";
535
+ lines.push(`${pad}${transitionLine(node, head, branch, {
536
+ guardKey: "when",
537
+ choice: true
538
+ })}`);
539
+ });
540
+ return lines;
541
+ }
542
+ /** The state node's line: key, type, tags, interaction label, description. */
543
+ function stateLine(node, json) {
544
+ let marker = "";
545
+ if (node.type === "final" || node.type === "choice" || node.type === "parallel") marker = ` (${node.type})`;
546
+ else if (node.type === "history") marker = json.history === "deep" ? " (history, deep)" : " (history)";
547
+ else if (node.type === "compound" && typeof json.initial === "string") marker = ` (initial: ${json.initial})`;
548
+ const tags = node.tags.length ? ` [tags: ${node.tags.join(", ")}]` : "";
549
+ const interaction = node.meta?.interaction;
550
+ const label = typeof interaction?.label === "string" ? ` [interaction: "${oneLine(interaction.label)}"]` : "";
551
+ const description = node.description ? ` — ${oneLine(node.description)}` : "";
552
+ return `${node.key}${marker}${tags}${label}${description}`;
553
+ }
554
+ /** The machine's events with their schema descriptions and fields, sorted by type. */
555
+ function eventLines(machine) {
556
+ const schemas = require_event_log.getAgentExecutionOptions(machine)?.schemas?.events ?? machine.schemas?.events ?? {};
557
+ const lines = [];
558
+ for (const type of Object.keys(schemas).sort()) {
559
+ if (type.startsWith("@agent.") || type.startsWith("xstate.")) continue;
560
+ let schema;
561
+ try {
562
+ schema = require_event_log.getJsonSchemaSync(schemas[type]);
563
+ } catch {
564
+ schema = void 0;
565
+ }
566
+ const direct = schemas[type].description;
567
+ const description = typeof schema?.description === "string" ? schema.description : typeof direct === "string" ? direct : void 0;
568
+ lines.push(` ${type}${description ? ` — ${oneLine(description)}` : ""}`);
569
+ const properties = isObject(schema?.properties) ? schema.properties : {};
570
+ const required = new Set(Array.isArray(schema?.required) ? schema.required : []);
571
+ for (const [field, property] of Object.entries(properties)) {
572
+ if (!isObject(property)) continue;
573
+ const fieldType = Array.isArray(property.enum) ? property.enum.map((value) => JSON.stringify(value)).join(" | ") : Array.isArray(property.type) ? property.type.join(" | ") : typeof property.type === "string" ? property.type : void 0;
574
+ const fieldDescription = typeof property.description === "string" ? ` — ${oneLine(property.description)}` : "";
575
+ lines.push(` ${field}${required.has(field) ? "" : "?"}${fieldType ? `: ${fieldType}` : ""}${fieldDescription}`);
576
+ }
577
+ }
578
+ return lines;
579
+ }
580
+ /**
581
+ * Describes a machine in plain text for a model to read. The machine's
582
+ * `description` is its goal, so it leads: `Machine <id>`, then `Goal: …`.
583
+ * Then every state node, indented by depth, with its type, tags, interaction
584
+ * label and description (`*` marks the active ones when `snapshot` is given),
585
+ * and under it every transition leaving it, one per line: `on EVENT`,
586
+ * `always`, `after <delay>`, invoke `done`/`error`, and `choice` branches,
587
+ * each with its guard (`if …`), where it goes (`→ review`), and what it sets
588
+ * in context (`sets draft, attempts`). An `Events` section lists the
589
+ * machine's event schemas with their descriptions and fields.
590
+ *
591
+ * A transition written as a function shows the targets its source names
592
+ * (`→ review (conditional)` when it may decline or pick among several),
593
+ * `(stays)` when its source has no `target`, or `→ ?` when no target can be
594
+ * read. A `setupAgent.fromConfig(...)` machine is read from its config, so
595
+ * its targets, guards and context patches are always known.
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * const prompt = `Propose a better machine for this goal.\n\n${describeMachine(machine)}`;
600
+ * ```
601
+ */
602
+ function describeMachine(machine, options = {}) {
603
+ const json = (0, xstate.machineToJSON)(machine);
604
+ const delays = isObject(json.delays) ? json.delays : {};
605
+ const active = new Set(options.snapshot?.nodes.map((node) => node.id) ?? []);
606
+ const root = machine.root;
607
+ const lines = [`Machine ${machine.id}`];
608
+ if (root.description) lines.push(`Goal: ${root.description.trim()}`);
609
+ const rootTransitions = transitionLines(root, json, delays, " ");
610
+ if (rootTransitions.length) lines.push("Any state:", ...rootTransitions);
611
+ const initial = typeof json.initial === "string" ? ` (initial: ${json.initial})` : "";
612
+ lines.push(`States${initial}${options.snapshot ? " (* = current)" : ""}:`);
613
+ const walk = (node, nodeJson, depth) => {
614
+ const pad = " ".repeat(depth);
615
+ const mark = active.has(node.id) ? `${pad.slice(2)}* ` : pad;
616
+ lines.push(`${mark}${stateLine(node, nodeJson)}`);
617
+ lines.push(...transitionLines(node, nodeJson, delays, `${pad} `));
618
+ const childJson = isObject(nodeJson.states) ? nodeJson.states : {};
619
+ for (const [key, child] of Object.entries(node.states)) walk(child, isObject(childJson[key]) ? childJson[key] : {}, depth + 1);
620
+ };
621
+ const rootStates = isObject(json.states) ? json.states : {};
622
+ for (const [key, child] of Object.entries(root.states)) walk(child, isObject(rootStates[key]) ? rootStates[key] : {}, 1);
623
+ const events = eventLines(machine);
624
+ if (events.length) lines.push("Events:", ...events);
625
+ return lines.join("\n");
626
+ }
627
+ //#endregion
628
+ //#region src/decide-next.ts
629
+ /**
630
+ * Asks a model to choose the next event for ANY XState snapshot, including a
631
+ * machine built with plain `createMachine`/`setup` that knows nothing about AI.
632
+ * The candidates are the `allowedEvents` an active state handles, one option per
633
+ * payload, kept only where `snapshot.can(event)` is true; the rest come back as
634
+ * `withheld`. Each option is
635
+ * described from the transition's `description`, else the event schema's,
636
+ * plus (with `lookahead`) what it changes. The chosen event must equal one
637
+ * offered option; anything else is retried.
638
+ *
639
+ * It never sends. The host sends the event, re-checking `can` first, because
640
+ * the actor may have moved while the model was thinking. With no options it
641
+ * returns `{ event: null }` without calling the executor. Exhausting retries
642
+ * throws `AgentDecisionExhaustedError`.
643
+ *
644
+ * @example
645
+ * ```ts no-check
646
+ * let busy = false;
647
+ * actor.subscribe(async (snapshot) => {
648
+ * if (busy || !snapshot.matches('reviewing')) return;
649
+ * busy = true;
650
+ * try {
651
+ * const { event } = await decideNext(snapshot, {
652
+ * decide,
653
+ * model: 'quick',
654
+ * allowedEvents: 'desk.*',
655
+ * payloads: (s) => ({ 'desk.refund': [{ amount: s.context.requested }] }),
656
+ * lookahead: true,
657
+ * });
658
+ * if (event && actor.getSnapshot().can(event)) actor.send(event);
659
+ * } finally {
660
+ * busy = false;
661
+ * }
662
+ * });
663
+ * ```
664
+ */
665
+ async function decideNext(snapshot, options) {
666
+ const patterns = typeof options.allowedEvents === "string" ? [options.allowedEvents] : options.allowedEvents;
667
+ const schemas = snapshot.machine.schemas?.events;
668
+ const events = require_decision.getAcceptedEvents(snapshot, {
669
+ events: schemas,
670
+ eventTypes: patterns
671
+ }).filter((event) => !require_decision.isEventPattern(event.type));
672
+ const payloads = options.payloads?.(snapshot) ?? {};
673
+ const accepted = [];
674
+ const withheld = [];
675
+ for (const { type } of events) for (const payload of payloads[type] ?? [{}]) {
676
+ const event = {
677
+ ...payload,
678
+ type
679
+ };
680
+ (safeCan(snapshot, event) ? accepted : withheld).push(event);
681
+ }
682
+ const offered = accepted.map((event) => ({
683
+ event,
684
+ description: describeOption(snapshot, event, schemas?.[event.type], options.lookahead)
685
+ }));
686
+ const request = require_decision.createDecisionRequest({
687
+ name: options.name ?? "decideNext",
688
+ model: options.model,
689
+ system: options.system,
690
+ prompt: options.prompt,
691
+ input: {
692
+ value: snapshot.value,
693
+ context: snapshot.context
694
+ },
695
+ events,
696
+ options: offered,
697
+ withheld
698
+ });
699
+ if (offered.length === 0) return {
700
+ event: null,
701
+ attempts: [],
702
+ request,
703
+ withheld
704
+ };
705
+ let attempts = [];
706
+ return {
707
+ event: await require_decision.resolveDecision(request, { decide: (attemptRequest, info) => {
708
+ attempts = attemptRequest.attempts;
709
+ return options.decide(attemptRequest, info);
710
+ } }, {
711
+ maxRetries: options.maxRetries,
712
+ signal: options.signal,
713
+ canTake: (chosen) => safeCan(snapshot, chosen)
714
+ }),
715
+ attempts,
716
+ request,
717
+ withheld
718
+ };
719
+ }
720
+ function safeCan(snapshot, event) {
721
+ try {
722
+ return snapshot.can(event);
723
+ } catch {
724
+ return false;
725
+ }
726
+ }
727
+ function describeOption(snapshot, event, schema, lookahead) {
728
+ const what = (0, xstate.getNextTransitions)(snapshot).find((candidate) => candidate.eventType === event.type && candidate.description)?.description ?? schemaDescription(schema) ?? event.type;
729
+ const fields = Object.entries(event).filter(([key]) => key !== "type").map(([key, value]) => `${key}: ${short(value)}`);
730
+ const base = fields.length ? `${what} (${fields.join("; ")})` : what;
731
+ const effect = lookahead ? describeEffect(snapshot, event, lookahead === true ? void 0 : lookahead) : void 0;
732
+ return effect ? `${base}. Then: ${effect}` : base;
733
+ }
734
+ function schemaDescription(schema) {
735
+ if (!schema) return void 0;
736
+ const direct = schema.description;
737
+ if (typeof direct === "string") return direct;
738
+ try {
739
+ const json = schema["~standard"].jsonSchema?.input?.({ target: "draft-2020-12" });
740
+ return require_decision.isRecord(json) && typeof json.description === "string" ? json.description : void 0;
741
+ } catch {
742
+ return;
743
+ }
744
+ }
745
+ function describeEffect(snapshot, event, keys) {
746
+ const maxLength = 120;
747
+ let next;
748
+ try {
749
+ [next] = (0, xstate.transition)(snapshot.machine, snapshot, event);
750
+ } catch {
751
+ return;
752
+ }
753
+ const changes = [];
754
+ if (require_event_log.canonicalEventJson(snapshot.value) !== require_event_log.canonicalEventJson(next.value)) changes.push(`state: ${short(snapshot.value, maxLength)} → ${short(next.value, maxLength)}`);
755
+ const before = require_decision.isRecord(snapshot.context) ? snapshot.context : {};
756
+ const after = require_decision.isRecord(next.context) ? next.context : {};
757
+ for (const key of keys ?? /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) if (require_event_log.canonicalEventJson(before[key]) !== require_event_log.canonicalEventJson(after[key])) changes.push(`${key}: ${short(before[key], maxLength)} → ${short(after[key], maxLength)}`);
758
+ return changes.length ? changes.join("; ") : "nothing changes";
759
+ }
760
+ function short(value, max = 60) {
761
+ let text;
762
+ try {
763
+ text = value === void 0 ? "(none)" : JSON.stringify(value) ?? String(value);
764
+ } catch {
765
+ text = String(value);
766
+ }
767
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
258
768
  }
259
769
  //#endregion
260
770
  //#region src/provide-executors.ts
@@ -310,8 +820,8 @@ function provideExecutors(machine, executors, options = {}) {
310
820
  const invokedSrcs = require_run_agent.getConfiguredInvokeSrcs(provided);
311
821
  for (const [key, logic] of Object.entries(effectiveSources)) {
312
822
  if (require_run_agent.isStateMachineLogic(logic)) {
313
- if (invokedSrcs.has(key)) assertChildBindable(logic, executors, key, new Set([provided]));
314
- const rebound = require_run_agent.bindChildMachineForProvide(logic, executors, bindOptions, new Set([provided]));
823
+ if (invokedSrcs.has(key)) assertChildBindable(logic, executors, key, /* @__PURE__ */ new Set([provided]));
824
+ const rebound = require_run_agent.bindChildMachineForProvide(logic, executors, bindOptions, /* @__PURE__ */ new Set([provided]));
315
825
  if (rebound !== logic) wrappedSources[key] = rebound;
316
826
  continue;
317
827
  }
@@ -321,7 +831,7 @@ function provideExecutors(machine, executors, options = {}) {
321
831
  ...requirement,
322
832
  bind: () => require_decision.isDecisionLogic(logic) ? require_run_agent.bindDecisionForProvide(provided, logic, executors, bindOptions) : require_run_agent.bindTextForProvide(provided, logic, executors, bindOptions)
323
833
  };
324
- if (require_text_logic.executorBoundLogics.has(logic)) continue;
834
+ if (require_event_log.executorBoundLogics.has(logic)) continue;
325
835
  if (!executors[binding.executorKey]) {
326
836
  if (invokedSrcs.has(key)) throw missingExecutorError(key, binding.kind, binding.executorKey);
327
837
  continue;
@@ -336,7 +846,7 @@ function executorRequirementOf(logic) {
336
846
  executorKey: "decide",
337
847
  kind: "decision"
338
848
  };
339
- if (require_text_logic.isTextLogic(logic)) return logic.mode === "stream" ? {
849
+ if (require_event_log.isTextLogic(logic)) return logic.mode === "stream" ? {
340
850
  executorKey: "streamText",
341
851
  kind: "streaming text"
342
852
  } : {
@@ -352,7 +862,7 @@ function executorRequirementOf(logic) {
352
862
  */
353
863
  function assertChildBindable(childMachine, executors, path, visited) {
354
864
  if (visited.has(childMachine)) return;
355
- const nextVisited = new Set([...visited, childMachine]);
865
+ const nextVisited = /* @__PURE__ */ new Set([...visited, childMachine]);
356
866
  const sources = childMachine.sources.actors;
357
867
  for (const src of require_run_agent.getConfiguredInvokeSrcs(childMachine)) {
358
868
  const logic = sources[src];
@@ -362,7 +872,7 @@ function assertChildBindable(childMachine, executors, path, visited) {
362
872
  continue;
363
873
  }
364
874
  const requirement = executorRequirementOf(logic);
365
- if (!requirement || require_text_logic.executorBoundLogics.has(logic)) continue;
875
+ if (!requirement || require_event_log.executorBoundLogics.has(logic)) continue;
366
876
  if (!executors[requirement.executorKey]) throw missingExecutorError(`${path} > ${src}`, requirement.kind, requirement.executorKey);
367
877
  }
368
878
  }
@@ -371,48 +881,51 @@ function missingExecutorError(src, kind, executor) {
371
881
  }
372
882
  //#endregion
373
883
  exports.AGENT_TRACE_SCHEMA_VERSION = require_run_agent.AGENT_TRACE_SCHEMA_VERSION;
374
- exports.AGENT_USAGE_EVENT_TYPE = require_usage.AGENT_USAGE_EVENT_TYPE;
884
+ exports.AGENT_USAGE_EVENT_TYPE = require_event_log.AGENT_USAGE_EVENT_TYPE;
375
885
  exports.AgentDecisionExhaustedError = require_decision.AgentDecisionExhaustedError;
376
- exports.AgentError = require_text_logic.AgentError;
886
+ exports.AgentError = require_event_log.AgentError;
377
887
  exports.AgentEventLogConflictError = require_event_log_store.AgentEventLogConflictError;
378
888
  exports.AgentInvalidEventPayloadError = require_decision.AgentInvalidEventPayloadError;
379
- exports.AgentMachineVersionMismatchError = require_event_log_store.AgentMachineVersionMismatchError;
889
+ exports.AgentMachineVersionMismatchError = require_event_log.AgentMachineVersionMismatchError;
380
890
  exports.AgentMaxModelCallsExceededError = require_run_agent.AgentMaxModelCallsExceededError;
381
891
  exports.AgentSnapshotDivergedError = require_run_agent.AgentSnapshotDivergedError;
382
- exports.AgentTruncatedError = require_text_logic.AgentTruncatedError;
383
- exports.assistantMessage = require_text_logic.assistantMessage;
384
- exports.bindRequestExecutor = require_text_logic.bindRequestExecutor;
892
+ exports.AgentTruncatedError = require_event_log.AgentTruncatedError;
893
+ exports.assistantMessage = require_event_log.assistantMessage;
894
+ exports.bindRequestExecutor = require_event_log.bindRequestExecutor;
385
895
  exports.createAgentRuntime = require_run_agent.createAgentRuntime;
386
896
  exports.createAgentSchemas = require_setup_agent.createAgentSchemas;
387
897
  exports.createDecisionLogic = require_decision.createDecisionLogic;
388
898
  exports.createDecisionRequest = require_decision.createDecisionRequest;
389
- exports.createTextLogic = require_text_logic.createTextLogic;
899
+ exports.createTextLogic = require_event_log.createTextLogic;
900
+ exports.decideNext = decideNext;
901
+ exports.describeMachine = describeMachine;
390
902
  exports.eventFromInteraction = eventFromInteraction;
391
903
  exports.getAcceptedEvents = require_decision.getAcceptedEvents;
392
- exports.getAgentOutputMode = require_text_logic.getAgentOutputMode;
904
+ exports.getAgentOutputMode = require_event_log.getAgentOutputMode;
393
905
  exports.getAgentSchemas = require_setup_agent.getAgentSchemas;
394
- exports.getCallFinishReason = require_text_logic.getCallFinishReason;
395
- exports.getCallUsage = require_text_logic.getCallUsage;
906
+ exports.getCallFinishReason = require_event_log.getCallFinishReason;
907
+ exports.getCallUsage = require_event_log.getCallUsage;
396
908
  exports.getInteraction = getInteraction;
397
- exports.getJsonSchema = require_text_logic.getJsonSchema;
398
- exports.getJsonSchemaSync = require_text_logic.getJsonSchemaSync;
399
- exports.getMachineStructuralHash = require_text_logic.getMachineStructuralHash;
400
- exports.getMessageText = require_text_logic.getMessageText;
401
- exports.getStateMeta = require_text_logic.getStateMeta;
402
- exports.getStatePath = require_text_logic.getStatePath;
909
+ exports.getJsonSchema = require_event_log.getJsonSchema;
910
+ exports.getJsonSchemaSync = require_event_log.getJsonSchemaSync;
911
+ exports.getMachineStructuralHash = require_event_log.getMachineStructuralHash;
912
+ exports.getMessageText = require_event_log.getMessageText;
913
+ exports.getStateMeta = require_event_log.getStateMeta;
914
+ exports.getStatePath = require_event_log.getStatePath;
403
915
  exports.inspectTransitions = require_run_agent.inspectTransitions;
404
916
  exports.interactionMetaSchema = interactionMetaSchema;
405
917
  exports.isAgentIdle = require_run_agent.isAgentIdle;
406
918
  exports.isAgentMessages = isAgentMessages;
407
- exports.isStandardSchema = require_text_logic.isStandardSchema;
919
+ exports.isStandardSchema = require_event_log.isStandardSchema;
408
920
  exports.messagesSchema = messagesSchema;
409
921
  exports.parseAgentEvent = require_decision.parseAgentEvent;
410
- exports.parseOutput = require_text_logic.parseOutput;
411
- exports.parseProviderOutput = require_text_logic.parseProviderOutput;
922
+ exports.parseOutput = require_event_log.parseOutput;
923
+ exports.parseProviderOutput = require_event_log.parseProviderOutput;
412
924
  exports.provideExecutors = provideExecutors;
413
- exports.providerOutputSchema = require_text_logic.providerOutputSchema;
925
+ exports.providerOutputSchema = require_event_log.providerOutputSchema;
414
926
  exports.renderDecisionAttempts = require_decision.renderDecisionAttempts;
415
927
  exports.resolveDecision = require_decision.resolveDecision;
928
+ exports.runAgent = require_run_agent.runAgent;
416
929
  exports.runToQuiescence = require_run_agent.runToQuiescence;
417
930
  exports.serializeTraceEvent = require_run_agent.serializeTraceEvent;
418
931
  Object.defineProperty(exports, "setupAgent", {
@@ -421,7 +934,7 @@ Object.defineProperty(exports, "setupAgent", {
421
934
  return require_setup_agent.setupAgent;
422
935
  }
423
936
  });
424
- exports.systemMessage = require_text_logic.systemMessage;
425
- exports.toolMessage = require_text_logic.toolMessage;
937
+ exports.systemMessage = require_event_log.systemMessage;
938
+ exports.toolMessage = require_event_log.toolMessage;
426
939
  exports.traceTransitions = require_run_agent.traceTransitions;
427
- exports.userMessage = require_text_logic.userMessage;
940
+ exports.userMessage = require_event_log.userMessage;