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

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 (80) hide show
  1. package/dist/ai-sdk.cjs +150 -27
  2. package/dist/ai-sdk.d.cts +59 -36
  3. package/dist/ai-sdk.d.mts +59 -36
  4. package/dist/ai-sdk.mjs +148 -24
  5. package/dist/{decision-RQ0iv0oZ.mjs → decision-BHkvuImD.mjs} +74 -8
  6. package/dist/{decision-CmM8-HHz.cjs → decision-CIb7ddIv.cjs} +113 -30
  7. package/dist/{text-logic-f5F5sCdc.cjs → event-log-BZRfBRd7.cjs} +814 -7
  8. package/dist/{text-logic-CIqHAmBi.mjs → event-log-DJCMHek_.mjs} +680 -4
  9. package/dist/{event-log-store-BIPOz-di.d.mts → event-log-store-CIIJohjj.d.mts} +90 -5
  10. package/dist/{event-log-store-2xzFmgr2.d.cts → event-log-store-CLAC9q2Y.d.cts} +90 -5
  11. package/dist/event-log-store-DZR4IIWe.cjs +95 -0
  12. package/dist/event-log-store-DsP6GCRh.mjs +84 -0
  13. package/dist/index.cjs +576 -58
  14. package/dist/index.d.cts +104 -510
  15. package/dist/index.d.mts +104 -510
  16. package/dist/index.mjs +547 -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-BCKg4qJ1.cjs +44 -0
  26. package/dist/model-source-BaHwJ1wK.mjs +39 -0
  27. package/dist/openai.cjs +11 -11
  28. package/dist/openai.d.cts +28 -26
  29. package/dist/openai.d.mts +28 -26
  30. package/dist/openai.mjs +3 -3
  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-xNTxpt82.mjs → run-agent-BpHqkaZw.mjs} +181 -44
  36. package/dist/{run-agent-COXXc0RW.d.mts → run-agent-CAVt5R-r.d.mts} +95 -30
  37. package/dist/{run-agent-ByO-Bxyd.d.cts → run-agent-CTlMc3Jb.d.cts} +95 -30
  38. package/dist/{run-agent-Dmf8GV2d.cjs → run-agent-ctLCvNgL.cjs} +230 -88
  39. package/dist/{setup-agent-BuanDXeh.mjs → setup-agent-7rV_cujV.mjs} +15 -9
  40. package/dist/setup-agent-CGELn1qZ.d.mts +577 -0
  41. package/dist/setup-agent-CLPCkXsu.d.cts +577 -0
  42. package/dist/{setup-agent-DV4cTou-.cjs → setup-agent-DoUk7EdC.cjs} +31 -20
  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 +204 -985
  48. package/dist/testing.d.cts +132 -347
  49. package/dist/testing.d.mts +132 -347
  50. package/dist/testing.mjs +191 -973
  51. package/dist/{text-logic-IjfYy9DP.d.cts → text-logic-BRYOPWvY.d.mts} +52 -12
  52. package/dist/{text-logic-D-czVPYp.d.mts → text-logic-DmciuVUQ.d.cts} +52 -12
  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-BkM3z02Y.d.mts +17 -0
  56. package/dist/usage-Cm_ovz9V.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-COFWyprJ.mjs +1181 -0
  64. package/dist/verify-CVlsTZ-V.cjs +1222 -0
  65. package/dist/verify-Cn86rT8l.d.mts +414 -0
  66. package/dist/verify-Dzwd4Mvk.d.cts +414 -0
  67. package/package.json +44 -31
  68. package/readme.md +40 -28
  69. package/skills/add-evals/SKILL.md +129 -0
  70. package/skills/add-traces/SKILL.md +135 -0
  71. package/skills/generate-machine/SKILL.md +143 -69
  72. package/skills/graph-engineering/SKILL.md +33 -0
  73. package/skills/improve-machine/SKILL.md +241 -0
  74. package/skills/improve-machine/reference.md +101 -0
  75. package/skills/loop-to-machine/SKILL.md +183 -0
  76. package/skills/loop-to-machine/policy.md +158 -0
  77. package/dist/event-log-store-2pAFiWuc.mjs +0 -576
  78. package/dist/event-log-store-C-COhIXP.cjs +0 -702
  79. package/dist/usage-BdEjFuIi.mjs +0 -5
  80. package/dist/usage-efOQPdf_.cjs +0 -10
package/dist/log.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_event_log_store = require("./event-log-store-C-COhIXP.cjs");
2
+ const require_event_log = require("./event-log-BZRfBRd7.cjs");
3
+ const require_event_log_store = require("./event-log-store-DZR4IIWe.cjs");
3
4
  //#region src/event-log-store-conformance.ts
4
5
  /**
5
6
  * The runner-agnostic conformance suite for {@link AgentEventLogStore}
@@ -341,6 +342,59 @@ const cases = [
341
342
  if (!(caughtZero instanceof Error) || caughtZero instanceof require_event_log_store.AgentEventLogConflictError) fail("forking with upToIndex 0 must reject with a plain Error");
342
343
  if (await store.length("fork-zero") !== 0) fail("a rejected fork must not create the target thread");
343
344
  }
345
+ },
346
+ {
347
+ name: "listThreads (optional) pages by prefix, limit, and cursor",
348
+ async run(create) {
349
+ const store = await create();
350
+ if (store.listThreads === void 0) return;
351
+ assertJsonEqual((await store.listThreads()).threadIds, [], "listThreads on an empty store must list nothing");
352
+ for (const threadId of [
353
+ "user:b",
354
+ "user:a",
355
+ "admin:x",
356
+ "user:c"
357
+ ]) await store.append({
358
+ threadId,
359
+ expectedIndex: 0,
360
+ entries: [entry(0, "start")]
361
+ });
362
+ await store.fork({
363
+ threadId: "user:a",
364
+ newThreadId: "user:d"
365
+ });
366
+ const all = await store.listThreads();
367
+ assertJsonEqual([...all.threadIds].sort(), [
368
+ "admin:x",
369
+ "user:a",
370
+ "user:b",
371
+ "user:c",
372
+ "user:d"
373
+ ], "listThreads must list every non-empty thread, forks included");
374
+ if (all.cursor !== void 0) fail("listThreads without a limit must return no cursor");
375
+ const seen = [];
376
+ let cursor;
377
+ let pages = 0;
378
+ do {
379
+ const page = await store.listThreads({
380
+ prefix: "user:",
381
+ limit: 2,
382
+ ...cursor !== void 0 ? { cursor } : {}
383
+ });
384
+ if (page.threadIds.length > 2) fail(`listThreads must honor limit 2, got ${page.threadIds.length} ids`);
385
+ seen.push(...page.threadIds);
386
+ cursor = page.cursor;
387
+ if (++pages > 10) fail("listThreads paging must terminate");
388
+ } while (cursor !== void 0);
389
+ assertJsonEqual([...seen].sort(), [
390
+ "user:a",
391
+ "user:b",
392
+ "user:c",
393
+ "user:d"
394
+ ], "paging listThreads by prefix must return each matching thread exactly once");
395
+ if (seen.length !== new Set(seen).size) fail("paging listThreads must not repeat a thread");
396
+ if (pages !== 2) fail(`4 matching threads at limit 2 must take exactly 2 pages, took ${pages}`);
397
+ }
344
398
  }
345
399
  ];
346
400
  /**
@@ -349,7 +403,8 @@ const cases = [
349
403
  * stale-`expectedIndex` conflict with correct fields; an interleaved concurrent
350
404
  * append race (exactly one winner); entry-id uniqueness; `read({ from })`
351
405
  * incremental correctness; thread isolation; metadata round-trip; deep-copy
352
- * isolation on append and read; and the full fork contract.
406
+ * isolation on append and read; the full fork contract; and, when the store
407
+ * implements the optional `listThreads`, its prefix/limit/cursor paging.
353
408
  *
354
409
  * Without a `harness`, every case runs in sequence and the first violation
355
410
  * throws. With one, each case is registered as its own test:
@@ -369,24 +424,26 @@ async function assertEventLogStoreConformance(create, harness) {
369
424
  for (const testCase of cases) await testCase.run(create);
370
425
  }
371
426
  //#endregion
372
- exports.AGENT_EVENT_SCHEMA_VERSION = require_event_log_store.AGENT_EVENT_SCHEMA_VERSION;
373
- exports.AGENT_INIT_EVENT_TYPE = require_event_log_store.AGENT_INIT_EVENT_TYPE;
427
+ exports.AGENT_EVENT_SCHEMA_VERSION = require_event_log.AGENT_EVENT_SCHEMA_VERSION;
428
+ exports.AGENT_INIT_EVENT_TYPE = require_event_log.AGENT_INIT_EVENT_TYPE;
374
429
  exports.AgentEventLogConflictError = require_event_log_store.AgentEventLogConflictError;
375
- exports.AgentEventLogError = require_event_log_store.AgentEventLogError;
376
- exports.AgentMachineVersionMismatchError = require_event_log_store.AgentMachineVersionMismatchError;
377
- exports.AgentReplayDivergenceError = require_event_log_store.AgentReplayDivergenceError;
378
- exports.NonSerializableAgentEventError = require_event_log_store.NonSerializableAgentEventError;
379
- exports.agentCallOccurrence = require_event_log_store.agentCallOccurrence;
380
- exports.assertAgentLogEntry = require_event_log_store.assertAgentLogEntry;
430
+ exports.AgentEventLogError = require_event_log.AgentEventLogError;
431
+ exports.AgentMachineVersionMismatchError = require_event_log.AgentMachineVersionMismatchError;
432
+ exports.AgentReplayDivergenceError = require_event_log.AgentReplayDivergenceError;
433
+ exports.NonSerializableAgentEventError = require_event_log.NonSerializableAgentEventError;
434
+ exports.agentCallOccurrence = require_event_log.agentCallOccurrence;
435
+ exports.assertAgentLogEntry = require_event_log.assertAgentLogEntry;
381
436
  exports.assertEventLogStoreConformance = assertEventLogStoreConformance;
382
- exports.assertJsonSerializable = require_event_log_store.assertJsonSerializable;
437
+ exports.assertJsonSerializable = require_event_log.assertJsonSerializable;
383
438
  exports.createInMemoryEventLogStore = require_event_log_store.createInMemoryEventLogStore;
384
- exports.createReplayEntry = require_event_log_store.createReplayEntry;
385
- exports.forkEventLog = require_event_log_store.forkEventLog;
386
- exports.getLogExecutionId = require_event_log_store.getLogExecutionId;
387
- exports.getSnapshotStateHash = require_event_log_store.getSnapshotStateHash;
388
- exports.getUsageFromEvents = require_event_log_store.getUsageFromEvents;
389
- exports.initEntry = require_event_log_store.initEntry;
390
- exports.rebindActorSession = require_event_log_store.rebindActorSession;
391
- exports.replay = require_event_log_store.replay;
392
- exports.validateReplayEntries = require_event_log_store.validateReplayEntries;
439
+ exports.createReplayEntry = require_event_log.createReplayEntry;
440
+ exports.forkEventLog = require_event_log.forkEventLog;
441
+ exports.getDecisionAttempts = require_event_log.getDecisionAttempts;
442
+ exports.getLogExecutionId = require_event_log.getLogExecutionId;
443
+ exports.getSnapshotStateHash = require_event_log.getSnapshotStateHash;
444
+ exports.getUsageFromEvents = require_event_log.getUsageFromEvents;
445
+ exports.initEntry = require_event_log.initEntry;
446
+ exports.rebindActorSession = require_event_log.rebindActorSession;
447
+ exports.recordLog = require_event_log.recordLog;
448
+ exports.replay = require_event_log.replay;
449
+ exports.validateReplayEntries = require_event_log.validateReplayEntries;
package/dist/log.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { A as validateReplayEntries, C as forkEventLog, D as initEntry, E as getUsageFromEvents, O as rebindActorSession, S as createReplayEntry, T as getSnapshotStateHash, _ as ReplayOptions, a as AGENT_INIT_EVENT_TYPE, b as assertAgentLogEntry, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as NonSerializableAgentEventError, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, k as replay, 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 ReplayResult, w as getLogExecutionId, x as assertJsonSerializable, y as agentCallOccurrence } from "./event-log-store-2xzFmgr2.cjs";
2
-
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-CLAC9q2Y.cjs";
3
2
  //#region src/event-log-store-conformance.d.ts
4
3
  /** Produces a fresh, empty store for one case. */
5
4
  type CreateStore = () => Promise<AgentEventLogStore> | AgentEventLogStore;
@@ -17,7 +16,8 @@ interface EventLogStoreConformanceHarness {
17
16
  * stale-`expectedIndex` conflict with correct fields; an interleaved concurrent
18
17
  * append race (exactly one winner); entry-id uniqueness; `read({ from })`
19
18
  * incremental correctness; thread isolation; metadata round-trip; deep-copy
20
- * isolation on append and read; and the full fork contract.
19
+ * isolation on append and read; the full fork contract; and, when the store
20
+ * implements the optional `listThreads`, its prefix/limit/cursor paging.
21
21
  *
22
22
  * Without a `harness`, every case runs in sequence and the first violation
23
23
  * throws. With one, each case is registered as its own test:
@@ -27,6 +27,6 @@ interface EventLogStoreConformanceHarness {
27
27
  * assertEventLogStoreConformance(createMyStore, { describe, it });
28
28
  * ```
29
29
  */
30
- declare function assertEventLogStoreConformance(create: CreateStore, harness?: EventLogStoreConformanceHarness): Promise<void>;
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, NonSerializableAgentEventError, type ReplayOptions, type ReplayResult, agentCallOccurrence, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, rebindActorSession, 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, rebindActorSession, recordLog, replay, validateReplayEntries };
package/dist/log.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { A as validateReplayEntries, C as forkEventLog, D as initEntry, E as getUsageFromEvents, O as rebindActorSession, S as createReplayEntry, T as getSnapshotStateHash, _ as ReplayOptions, a as AGENT_INIT_EVENT_TYPE, b as assertAgentLogEntry, c as AgentLogEntry, d as AgentMachineVersionMismatchError, f as AgentPersistedSnapshot, g as NonSerializableAgentEventError, h as JsonValue, i as AGENT_EVENT_SCHEMA_VERSION, k as replay, 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 ReplayResult, w as getLogExecutionId, x as assertJsonSerializable, y as agentCallOccurrence } from "./event-log-store-BIPOz-di.mjs";
2
-
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-CIIJohjj.mjs";
3
2
  //#region src/event-log-store-conformance.d.ts
4
3
  /** Produces a fresh, empty store for one case. */
5
4
  type CreateStore = () => Promise<AgentEventLogStore> | AgentEventLogStore;
@@ -17,7 +16,8 @@ interface EventLogStoreConformanceHarness {
17
16
  * stale-`expectedIndex` conflict with correct fields; an interleaved concurrent
18
17
  * append race (exactly one winner); entry-id uniqueness; `read({ from })`
19
18
  * incremental correctness; thread isolation; metadata round-trip; deep-copy
20
- * isolation on append and read; and the full fork contract.
19
+ * isolation on append and read; the full fork contract; and, when the store
20
+ * implements the optional `listThreads`, its prefix/limit/cursor paging.
21
21
  *
22
22
  * Without a `harness`, every case runs in sequence and the first violation
23
23
  * throws. With one, each case is registered as its own test:
@@ -27,6 +27,6 @@ interface EventLogStoreConformanceHarness {
27
27
  * assertEventLogStoreConformance(createMyStore, { describe, it });
28
28
  * ```
29
29
  */
30
- declare function assertEventLogStoreConformance(create: CreateStore, harness?: EventLogStoreConformanceHarness): Promise<void>;
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, NonSerializableAgentEventError, type ReplayOptions, type ReplayResult, agentCallOccurrence, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, rebindActorSession, 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, rebindActorSession, recordLog, replay, validateReplayEntries };
package/dist/log.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { _ as getUsageFromEvents, a as AgentEventLogError, b as replay, c as NonSerializableAgentEventError, d as assertJsonSerializable, g as getSnapshotStateHash, h as getLogExecutionId, i as AGENT_INIT_EVENT_TYPE, l as agentCallOccurrence, m as forkEventLog, n as createInMemoryEventLogStore, o as AgentMachineVersionMismatchError, p as createReplayEntry, r as AGENT_EVENT_SCHEMA_VERSION, s as AgentReplayDivergenceError, t as AgentEventLogConflictError, u as assertAgentLogEntry, v as initEntry, x as validateReplayEntries, y as rebindActorSession } from "./event-log-store-2pAFiWuc.mjs";
1
+ import { S as validateReplayEntries, _ as getUsageFromEvents, a as AgentReplayDivergenceError, b as recordLog, c as assertAgentLogEntry, d as createReplayEntry, g as getSnapshotStateHash, h as getLogExecutionId, i as AgentMachineVersionMismatchError, l as assertJsonSerializable, m as getDecisionAttempts, n as AGENT_INIT_EVENT_TYPE, o as NonSerializableAgentEventError, p as forkEventLog, r as AgentEventLogError, s as agentCallOccurrence, t as AGENT_EVENT_SCHEMA_VERSION, v as initEntry, x as replay, y as rebindActorSession } from "./event-log-DJCMHek_.mjs";
2
+ import { n as createInMemoryEventLogStore, t as AgentEventLogConflictError } from "./event-log-store-DsP6GCRh.mjs";
2
3
  //#region src/event-log-store-conformance.ts
3
4
  /**
4
5
  * The runner-agnostic conformance suite for {@link AgentEventLogStore}
@@ -340,6 +341,59 @@ const cases = [
340
341
  if (!(caughtZero instanceof Error) || caughtZero instanceof AgentEventLogConflictError) fail("forking with upToIndex 0 must reject with a plain Error");
341
342
  if (await store.length("fork-zero") !== 0) fail("a rejected fork must not create the target thread");
342
343
  }
344
+ },
345
+ {
346
+ name: "listThreads (optional) pages by prefix, limit, and cursor",
347
+ async run(create) {
348
+ const store = await create();
349
+ if (store.listThreads === void 0) return;
350
+ assertJsonEqual((await store.listThreads()).threadIds, [], "listThreads on an empty store must list nothing");
351
+ for (const threadId of [
352
+ "user:b",
353
+ "user:a",
354
+ "admin:x",
355
+ "user:c"
356
+ ]) await store.append({
357
+ threadId,
358
+ expectedIndex: 0,
359
+ entries: [entry(0, "start")]
360
+ });
361
+ await store.fork({
362
+ threadId: "user:a",
363
+ newThreadId: "user:d"
364
+ });
365
+ const all = await store.listThreads();
366
+ assertJsonEqual([...all.threadIds].sort(), [
367
+ "admin:x",
368
+ "user:a",
369
+ "user:b",
370
+ "user:c",
371
+ "user:d"
372
+ ], "listThreads must list every non-empty thread, forks included");
373
+ if (all.cursor !== void 0) fail("listThreads without a limit must return no cursor");
374
+ const seen = [];
375
+ let cursor;
376
+ let pages = 0;
377
+ do {
378
+ const page = await store.listThreads({
379
+ prefix: "user:",
380
+ limit: 2,
381
+ ...cursor !== void 0 ? { cursor } : {}
382
+ });
383
+ if (page.threadIds.length > 2) fail(`listThreads must honor limit 2, got ${page.threadIds.length} ids`);
384
+ seen.push(...page.threadIds);
385
+ cursor = page.cursor;
386
+ if (++pages > 10) fail("listThreads paging must terminate");
387
+ } while (cursor !== void 0);
388
+ assertJsonEqual([...seen].sort(), [
389
+ "user:a",
390
+ "user:b",
391
+ "user:c",
392
+ "user:d"
393
+ ], "paging listThreads by prefix must return each matching thread exactly once");
394
+ if (seen.length !== new Set(seen).size) fail("paging listThreads must not repeat a thread");
395
+ if (pages !== 2) fail(`4 matching threads at limit 2 must take exactly 2 pages, took ${pages}`);
396
+ }
343
397
  }
344
398
  ];
345
399
  /**
@@ -348,7 +402,8 @@ const cases = [
348
402
  * stale-`expectedIndex` conflict with correct fields; an interleaved concurrent
349
403
  * append race (exactly one winner); entry-id uniqueness; `read({ from })`
350
404
  * incremental correctness; thread isolation; metadata round-trip; deep-copy
351
- * isolation on append and read; and the full fork contract.
405
+ * isolation on append and read; the full fork contract; and, when the store
406
+ * implements the optional `listThreads`, its prefix/limit/cursor paging.
352
407
  *
353
408
  * Without a `harness`, every case runs in sequence and the first violation
354
409
  * throws. With one, each case is registered as its own test:
@@ -368,4 +423,4 @@ async function assertEventLogStoreConformance(create, harness) {
368
423
  for (const testCase of cases) await testCase.run(create);
369
424
  }
370
425
  //#endregion
371
- export { AGENT_EVENT_SCHEMA_VERSION, AGENT_INIT_EVENT_TYPE, AgentEventLogConflictError, AgentEventLogError, AgentMachineVersionMismatchError, AgentReplayDivergenceError, NonSerializableAgentEventError, agentCallOccurrence, assertAgentLogEntry, assertEventLogStoreConformance, assertJsonSerializable, createInMemoryEventLogStore, createReplayEntry, forkEventLog, getLogExecutionId, getSnapshotStateHash, getUsageFromEvents, initEntry, rebindActorSession, replay, validateReplayEntries };
426
+ 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 };
package/dist/machines.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_setup_agent = require("./setup-agent-DV4cTou-.cjs");
2
+ const require_setup_agent = require("./setup-agent-DoUk7EdC.cjs");
3
3
  //#region src/machines/internal.ts
4
4
  /** The builtin inline text request every preset lowers a request entry to. */
5
5
  const GENERATE_TEXT_SRC = "agent.generateText";
@@ -1,6 +1,5 @@
1
- import { _ as StandardSchemaV1, s as AgentTools } from "./types-hR5f5YXa.cjs";
1
+ import { _ as StandardSchemaV1, s as AgentTools } from "./types-Dp5_Ru4R.cjs";
2
2
  import { AnyActorRef, AnyStateMachine, EventObject, MachineContext, MetaObject, StateMachine, StateSchema, StateValue } from "xstate";
3
-
4
3
  //#region src/machines/internal.d.ts
5
4
  /**
6
5
  * The machine type a preset factory returns: its context, event union, input
@@ -95,7 +94,7 @@ type ToolLoopMachine = PresetMachine<ToolLoopContext, ToolLoopInput, ToolLoopOut
95
94
  * // Snapshots and log entries carry machine.version ("1") automatically.
96
95
  * ```
97
96
  */
98
- declare function createToolLoopMachine(config: CreateToolLoopMachineConfig): ToolLoopMachine;
97
+ export declare function createToolLoopMachine(config: CreateToolLoopMachineConfig): ToolLoopMachine;
99
98
  //#endregion
100
99
  //#region src/machines/sequential.d.ts
101
100
  /** Arguments a {@link SequentialStep}'s `prompt` receives. */
@@ -166,7 +165,7 @@ type SequentialMachine = PresetMachine<SequentialContext, SequentialInput, Seque
166
165
  * });
167
166
  * ```
168
167
  */
169
- declare function createSequentialMachine(config: CreateSequentialMachineConfig): SequentialMachine;
168
+ export declare function createSequentialMachine(config: CreateSequentialMachineConfig): SequentialMachine;
170
169
  //#endregion
171
170
  //#region src/machines/router.d.ts
172
171
  /** Config for {@link createRouterMachine}. */
@@ -202,7 +201,7 @@ type RouterEvent<TRoute extends string = string> = {
202
201
  /** The machine {@link createRouterMachine} returns. */
203
202
  type RouterMachine<TRoute extends string = string> = PresetMachine<RouterContext<TRoute>, RouterInput, RouterOutput<TRoute>, RouterEvent<TRoute>>;
204
203
  /** The event a route decision chooses: `ROUTE_<name>`. */
205
- declare function routeEventType(route: string): string;
204
+ export declare function routeEventType(route: string): string;
206
205
  /**
207
206
  * One `agent.decide` picks exactly one declared route, then the machine runs
208
207
  * it. Only the declared routes have events and transitions, so a model naming
@@ -222,7 +221,7 @@ declare function routeEventType(route: string): string;
222
221
  * });
223
222
  * ```
224
223
  */
225
- declare function createRouterMachine<const TRoutes extends Record<string, PresetEntry>>(config: CreateRouterMachineConfig<TRoutes>): RouterMachine<keyof TRoutes & string>;
224
+ export declare function createRouterMachine<const TRoutes extends Record<string, PresetEntry>>(config: CreateRouterMachineConfig<TRoutes>): RouterMachine<keyof TRoutes & string>;
226
225
  //#endregion
227
226
  //#region src/machines/parallel.d.ts
228
227
  /** Config for {@link createParallelMachine}. */
@@ -268,7 +267,7 @@ type ParallelMachine = PresetMachine<ParallelContext, ParallelInput, ParallelOut
268
267
  * });
269
268
  * ```
270
269
  */
271
- declare function createParallelMachine(config: CreateParallelMachineConfig): ParallelMachine;
270
+ export declare function createParallelMachine(config: CreateParallelMachineConfig): ParallelMachine;
272
271
  //#endregion
273
272
  //#region src/machines/loop.d.ts
274
273
  /** The accumulated state a {@link CreateLoopMachineConfig.until} predicate reads. */
@@ -288,7 +287,8 @@ interface CreateLoopMachineConfig {
288
287
  model: string;
289
288
  /** The repeated unit of work: an inline request or a child machine. */
290
289
  body: PresetEntry & {
291
- /** Builds each iteration's prompt. Defaults to the machine's `prompt`. */prompt?: (state: LoopState) => string;
290
+ /** Builds each iteration's prompt. Defaults to the machine's `prompt`. */
291
+ prompt?: (state: LoopState) => string;
292
292
  };
293
293
  /** Stop condition, checked after each iteration. */
294
294
  until: (state: LoopState) => boolean;
@@ -330,7 +330,7 @@ type LoopMachine = PresetMachine<LoopContext, LoopInput, LoopOutput>;
330
330
  * });
331
331
  * ```
332
332
  */
333
- declare function createLoopMachine(config: CreateLoopMachineConfig): LoopMachine;
333
+ export declare function createLoopMachine(config: CreateLoopMachineConfig): LoopMachine;
334
334
  //#endregion
335
335
  //#region src/machines/supervisor.d.ts
336
336
  /** Config for {@link createSupervisorMachine}. */
@@ -369,9 +369,9 @@ type SupervisorEvent<TWorker extends string = string> = {
369
369
  /** The machine {@link createSupervisorMachine} returns. */
370
370
  type SupervisorMachine<TWorker extends string = string> = PresetMachine<SupervisorContext<TWorker>, SupervisorInput, SupervisorOutput, SupervisorEvent<TWorker>>;
371
371
  /** The event a supervising decision chooses to delegate to a worker: `DELEGATE_<name>`. */
372
- declare function delegateEventType(worker: string): string;
372
+ export declare function delegateEventType(worker: string): string;
373
373
  /** The event a supervising decision chooses to stop. */
374
- declare const FINISH_EVENT_TYPE = "FINISH";
374
+ export declare const FINISH_EVENT_TYPE = "FINISH";
375
375
  /**
376
376
  * A supervisor delegating to typed workers: each turn, one `agent.decide`
377
377
  * picks a worker or `FINISH`. Worker results accumulate in context and are fed
@@ -398,7 +398,7 @@ declare const FINISH_EVENT_TYPE = "FINISH";
398
398
  * });
399
399
  * ```
400
400
  */
401
- declare function createSupervisorMachine<const TWorkers extends Record<string, PresetEntry>>(config: CreateSupervisorMachineConfig<TWorkers>): SupervisorMachine<keyof TWorkers & string>;
401
+ export declare function createSupervisorMachine<const TWorkers extends Record<string, PresetEntry>>(config: CreateSupervisorMachineConfig<TWorkers>): SupervisorMachine<keyof TWorkers & string>;
402
402
  //#endregion
403
403
  //#region src/machines/handoff.d.ts
404
404
  /** Config for {@link createHandoffMachine}. */
@@ -429,7 +429,7 @@ type HandoffEvent<TAgent extends string = string> = {
429
429
  /** The machine {@link createHandoffMachine} returns. There is no final state, so it has no output. */
430
430
  type HandoffMachine<TAgent extends string = string> = PresetMachine<HandoffContext<TAgent>, HandoffInput<TAgent>, undefined, HandoffEvent<TAgent>>;
431
431
  /** The event that hands the mic to a peer: `transfer_to_<name>`. */
432
- declare function transferEventType(agent: string): string;
432
+ export declare function transferEventType(agent: string): string;
433
433
  /**
434
434
  * Peer handoff (the swarm shape): `context.activeAgent` holds the mic, runs one
435
435
  * turn, then the machine settles idle in `waiting`. A `transfer_to_<name>`
@@ -459,6 +459,6 @@ declare function transferEventType(agent: string): string;
459
459
  * });
460
460
  * ```
461
461
  */
462
- declare function createHandoffMachine<const TAgents extends Record<string, PresetEntry>>(config: CreateHandoffMachineConfig<TAgents>): HandoffMachine<keyof TAgents & string>;
462
+ export declare function createHandoffMachine<const TAgents extends Record<string, PresetEntry>>(config: CreateHandoffMachineConfig<TAgents>): HandoffMachine<keyof TAgents & string>;
463
463
  //#endregion
464
- export { type CreateHandoffMachineConfig, type CreateLoopMachineConfig, type CreateParallelMachineConfig, type CreateRouterMachineConfig, type CreateSequentialMachineConfig, type CreateSupervisorMachineConfig, type CreateToolLoopMachineConfig, FINISH_EVENT_TYPE, type HandoffContext, type HandoffEvent, type HandoffInput, type HandoffMachine, type LoopContext, type LoopInput, type LoopMachine, type LoopOutput, type LoopState, type ParallelContext, type ParallelInput, type ParallelMachine, type ParallelOutput, type PresetEntry, type PresetMachine, type PresetMachineEntry, type PresetRequestEntry, type RouterContext, type RouterEvent, type RouterInput, type RouterMachine, type RouterOutput, type SequentialContext, type SequentialInput, type SequentialMachine, type SequentialOutput, type SequentialPromptArgs, type SequentialStep, type SupervisorContext, type SupervisorEvent, type SupervisorInput, type SupervisorMachine, type SupervisorOutput, type ToolLoopContext, type ToolLoopInput, type ToolLoopMachine, type ToolLoopOutput, createHandoffMachine, createLoopMachine, createParallelMachine, createRouterMachine, createSequentialMachine, createSupervisorMachine, createToolLoopMachine, delegateEventType, routeEventType, transferEventType };
464
+ export type { CreateHandoffMachineConfig, CreateLoopMachineConfig, CreateParallelMachineConfig, CreateRouterMachineConfig, CreateSequentialMachineConfig, CreateSupervisorMachineConfig, CreateToolLoopMachineConfig, HandoffContext, HandoffEvent, HandoffInput, HandoffMachine, LoopContext, LoopInput, LoopMachine, LoopOutput, LoopState, ParallelContext, ParallelInput, ParallelMachine, ParallelOutput, PresetEntry, PresetMachine, PresetMachineEntry, PresetRequestEntry, RouterContext, RouterEvent, RouterInput, RouterMachine, RouterOutput, SequentialContext, SequentialInput, SequentialMachine, SequentialOutput, SequentialPromptArgs, SequentialStep, SupervisorContext, SupervisorEvent, SupervisorInput, SupervisorMachine, SupervisorOutput, ToolLoopContext, ToolLoopInput, ToolLoopMachine, ToolLoopOutput };
@@ -1,6 +1,5 @@
1
- import { _ as StandardSchemaV1, s as AgentTools } from "./types-BgNbNKnJ.mjs";
1
+ import { _ as StandardSchemaV1, s as AgentTools } from "./types-Dp5_Ru4R.mjs";
2
2
  import { AnyActorRef, AnyStateMachine, EventObject, MachineContext, MetaObject, StateMachine, StateSchema, StateValue } from "xstate";
3
-
4
3
  //#region src/machines/internal.d.ts
5
4
  /**
6
5
  * The machine type a preset factory returns: its context, event union, input
@@ -95,7 +94,7 @@ type ToolLoopMachine = PresetMachine<ToolLoopContext, ToolLoopInput, ToolLoopOut
95
94
  * // Snapshots and log entries carry machine.version ("1") automatically.
96
95
  * ```
97
96
  */
98
- declare function createToolLoopMachine(config: CreateToolLoopMachineConfig): ToolLoopMachine;
97
+ export declare function createToolLoopMachine(config: CreateToolLoopMachineConfig): ToolLoopMachine;
99
98
  //#endregion
100
99
  //#region src/machines/sequential.d.ts
101
100
  /** Arguments a {@link SequentialStep}'s `prompt` receives. */
@@ -166,7 +165,7 @@ type SequentialMachine = PresetMachine<SequentialContext, SequentialInput, Seque
166
165
  * });
167
166
  * ```
168
167
  */
169
- declare function createSequentialMachine(config: CreateSequentialMachineConfig): SequentialMachine;
168
+ export declare function createSequentialMachine(config: CreateSequentialMachineConfig): SequentialMachine;
170
169
  //#endregion
171
170
  //#region src/machines/router.d.ts
172
171
  /** Config for {@link createRouterMachine}. */
@@ -202,7 +201,7 @@ type RouterEvent<TRoute extends string = string> = {
202
201
  /** The machine {@link createRouterMachine} returns. */
203
202
  type RouterMachine<TRoute extends string = string> = PresetMachine<RouterContext<TRoute>, RouterInput, RouterOutput<TRoute>, RouterEvent<TRoute>>;
204
203
  /** The event a route decision chooses: `ROUTE_<name>`. */
205
- declare function routeEventType(route: string): string;
204
+ export declare function routeEventType(route: string): string;
206
205
  /**
207
206
  * One `agent.decide` picks exactly one declared route, then the machine runs
208
207
  * it. Only the declared routes have events and transitions, so a model naming
@@ -222,7 +221,7 @@ declare function routeEventType(route: string): string;
222
221
  * });
223
222
  * ```
224
223
  */
225
- declare function createRouterMachine<const TRoutes extends Record<string, PresetEntry>>(config: CreateRouterMachineConfig<TRoutes>): RouterMachine<keyof TRoutes & string>;
224
+ export declare function createRouterMachine<const TRoutes extends Record<string, PresetEntry>>(config: CreateRouterMachineConfig<TRoutes>): RouterMachine<keyof TRoutes & string>;
226
225
  //#endregion
227
226
  //#region src/machines/parallel.d.ts
228
227
  /** Config for {@link createParallelMachine}. */
@@ -268,7 +267,7 @@ type ParallelMachine = PresetMachine<ParallelContext, ParallelInput, ParallelOut
268
267
  * });
269
268
  * ```
270
269
  */
271
- declare function createParallelMachine(config: CreateParallelMachineConfig): ParallelMachine;
270
+ export declare function createParallelMachine(config: CreateParallelMachineConfig): ParallelMachine;
272
271
  //#endregion
273
272
  //#region src/machines/loop.d.ts
274
273
  /** The accumulated state a {@link CreateLoopMachineConfig.until} predicate reads. */
@@ -288,7 +287,8 @@ interface CreateLoopMachineConfig {
288
287
  model: string;
289
288
  /** The repeated unit of work: an inline request or a child machine. */
290
289
  body: PresetEntry & {
291
- /** Builds each iteration's prompt. Defaults to the machine's `prompt`. */prompt?: (state: LoopState) => string;
290
+ /** Builds each iteration's prompt. Defaults to the machine's `prompt`. */
291
+ prompt?: (state: LoopState) => string;
292
292
  };
293
293
  /** Stop condition, checked after each iteration. */
294
294
  until: (state: LoopState) => boolean;
@@ -330,7 +330,7 @@ type LoopMachine = PresetMachine<LoopContext, LoopInput, LoopOutput>;
330
330
  * });
331
331
  * ```
332
332
  */
333
- declare function createLoopMachine(config: CreateLoopMachineConfig): LoopMachine;
333
+ export declare function createLoopMachine(config: CreateLoopMachineConfig): LoopMachine;
334
334
  //#endregion
335
335
  //#region src/machines/supervisor.d.ts
336
336
  /** Config for {@link createSupervisorMachine}. */
@@ -369,9 +369,9 @@ type SupervisorEvent<TWorker extends string = string> = {
369
369
  /** The machine {@link createSupervisorMachine} returns. */
370
370
  type SupervisorMachine<TWorker extends string = string> = PresetMachine<SupervisorContext<TWorker>, SupervisorInput, SupervisorOutput, SupervisorEvent<TWorker>>;
371
371
  /** The event a supervising decision chooses to delegate to a worker: `DELEGATE_<name>`. */
372
- declare function delegateEventType(worker: string): string;
372
+ export declare function delegateEventType(worker: string): string;
373
373
  /** The event a supervising decision chooses to stop. */
374
- declare const FINISH_EVENT_TYPE = "FINISH";
374
+ export declare const FINISH_EVENT_TYPE = "FINISH";
375
375
  /**
376
376
  * A supervisor delegating to typed workers: each turn, one `agent.decide`
377
377
  * picks a worker or `FINISH`. Worker results accumulate in context and are fed
@@ -398,7 +398,7 @@ declare const FINISH_EVENT_TYPE = "FINISH";
398
398
  * });
399
399
  * ```
400
400
  */
401
- declare function createSupervisorMachine<const TWorkers extends Record<string, PresetEntry>>(config: CreateSupervisorMachineConfig<TWorkers>): SupervisorMachine<keyof TWorkers & string>;
401
+ export declare function createSupervisorMachine<const TWorkers extends Record<string, PresetEntry>>(config: CreateSupervisorMachineConfig<TWorkers>): SupervisorMachine<keyof TWorkers & string>;
402
402
  //#endregion
403
403
  //#region src/machines/handoff.d.ts
404
404
  /** Config for {@link createHandoffMachine}. */
@@ -429,7 +429,7 @@ type HandoffEvent<TAgent extends string = string> = {
429
429
  /** The machine {@link createHandoffMachine} returns. There is no final state, so it has no output. */
430
430
  type HandoffMachine<TAgent extends string = string> = PresetMachine<HandoffContext<TAgent>, HandoffInput<TAgent>, undefined, HandoffEvent<TAgent>>;
431
431
  /** The event that hands the mic to a peer: `transfer_to_<name>`. */
432
- declare function transferEventType(agent: string): string;
432
+ export declare function transferEventType(agent: string): string;
433
433
  /**
434
434
  * Peer handoff (the swarm shape): `context.activeAgent` holds the mic, runs one
435
435
  * turn, then the machine settles idle in `waiting`. A `transfer_to_<name>`
@@ -459,6 +459,6 @@ declare function transferEventType(agent: string): string;
459
459
  * });
460
460
  * ```
461
461
  */
462
- declare function createHandoffMachine<const TAgents extends Record<string, PresetEntry>>(config: CreateHandoffMachineConfig<TAgents>): HandoffMachine<keyof TAgents & string>;
462
+ export declare function createHandoffMachine<const TAgents extends Record<string, PresetEntry>>(config: CreateHandoffMachineConfig<TAgents>): HandoffMachine<keyof TAgents & string>;
463
463
  //#endregion
464
- export { type CreateHandoffMachineConfig, type CreateLoopMachineConfig, type CreateParallelMachineConfig, type CreateRouterMachineConfig, type CreateSequentialMachineConfig, type CreateSupervisorMachineConfig, type CreateToolLoopMachineConfig, FINISH_EVENT_TYPE, type HandoffContext, type HandoffEvent, type HandoffInput, type HandoffMachine, type LoopContext, type LoopInput, type LoopMachine, type LoopOutput, type LoopState, type ParallelContext, type ParallelInput, type ParallelMachine, type ParallelOutput, type PresetEntry, type PresetMachine, type PresetMachineEntry, type PresetRequestEntry, type RouterContext, type RouterEvent, type RouterInput, type RouterMachine, type RouterOutput, type SequentialContext, type SequentialInput, type SequentialMachine, type SequentialOutput, type SequentialPromptArgs, type SequentialStep, type SupervisorContext, type SupervisorEvent, type SupervisorInput, type SupervisorMachine, type SupervisorOutput, type ToolLoopContext, type ToolLoopInput, type ToolLoopMachine, type ToolLoopOutput, createHandoffMachine, createLoopMachine, createParallelMachine, createRouterMachine, createSequentialMachine, createSupervisorMachine, createToolLoopMachine, delegateEventType, routeEventType, transferEventType };
464
+ export type { CreateHandoffMachineConfig, CreateLoopMachineConfig, CreateParallelMachineConfig, CreateRouterMachineConfig, CreateSequentialMachineConfig, CreateSupervisorMachineConfig, CreateToolLoopMachineConfig, HandoffContext, HandoffEvent, HandoffInput, HandoffMachine, LoopContext, LoopInput, LoopMachine, LoopOutput, LoopState, ParallelContext, ParallelInput, ParallelMachine, ParallelOutput, PresetEntry, PresetMachine, PresetMachineEntry, PresetRequestEntry, RouterContext, RouterEvent, RouterInput, RouterMachine, RouterOutput, SequentialContext, SequentialInput, SequentialMachine, SequentialOutput, SequentialPromptArgs, SequentialStep, SupervisorContext, SupervisorEvent, SupervisorInput, SupervisorMachine, SupervisorOutput, ToolLoopContext, ToolLoopInput, ToolLoopMachine, ToolLoopOutput };
package/dist/machines.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as setupAgent } from "./setup-agent-BuanDXeh.mjs";
1
+ import { r as setupAgent } from "./setup-agent-7rV_cujV.mjs";
2
2
  //#region src/machines/internal.ts
3
3
  /** The builtin inline text request every preset lowers a request entry to. */
4
4
  const GENERATE_TEXT_SRC = "agent.generateText";
@@ -0,0 +1,44 @@
1
+ const require_event_log = require("./event-log-BZRfBRd7.cjs");
2
+ const require_decision = require("./decision-CIb7ddIv.cjs");
3
+ //#region src/internal/model-source.ts
4
+ function hasEntries(value) {
5
+ return require_decision.isRecord(value) && Object.keys(value).length > 0;
6
+ }
7
+ function isMachineLike(value) {
8
+ return "config" in value && typeof value.transition === "function";
9
+ }
10
+ /** Short description of a value for construction-time error messages. */
11
+ function describeValue(value) {
12
+ if (value === null) return "null";
13
+ if (Array.isArray(value)) return "an array";
14
+ if (typeof value !== "object") return typeof value;
15
+ if (isMachineLike(value)) return require_event_log.getAgentExecutionOptions(value) ? "a machine whose setupAgent(...) declared no models" : "a machine not built by setupAgent(...).createMachine";
16
+ if (typeof value.createMachine === "function") return "a setupAgent(...) result that declared no models";
17
+ const keys = Object.keys(value);
18
+ return keys.length ? `an object with keys ${keys.join(", ")}` : "an empty object";
19
+ }
20
+ /**
21
+ * Normalizes an adapter's first argument to its options object. Accepts the
22
+ * options object itself (`{ models }`, `{ resolveModel }`), a `setupAgent(...)`
23
+ * result (its `models`), or a machine built by `setupAgent(...).createMachine`
24
+ * (the `models` registered for it). Provider-free: the adapter decides what the
25
+ * model values are. Throws, naming what it got, for anything else. @internal
26
+ */
27
+ function resolveModelSource(adapter, source) {
28
+ if (require_decision.isRecord(source)) {
29
+ if (typeof source.createMachine === "function") {
30
+ if (hasEntries(source.models)) return { models: source.models };
31
+ } else if (isMachineLike(source)) {
32
+ const models = require_event_log.getAgentExecutionOptions(source)?.models;
33
+ if (hasEntries(models)) return { models };
34
+ } else if (require_decision.isRecord(source.models) || typeof source.resolveModel === "function") return source;
35
+ }
36
+ throw new TypeError(`${adapter}: expected { models }, { resolveModel }, a setupAgent(...) result with models, or a machine from its createMachine; got ${describeValue(source)}.`);
37
+ }
38
+ //#endregion
39
+ Object.defineProperty(exports, "resolveModelSource", {
40
+ enumerable: true,
41
+ get: function() {
42
+ return resolveModelSource;
43
+ }
44
+ });
@@ -0,0 +1,39 @@
1
+ import { H as getAgentExecutionOptions } from "./event-log-DJCMHek_.mjs";
2
+ import { m as isRecord } from "./decision-BHkvuImD.mjs";
3
+ //#region src/internal/model-source.ts
4
+ function hasEntries(value) {
5
+ return isRecord(value) && Object.keys(value).length > 0;
6
+ }
7
+ function isMachineLike(value) {
8
+ return "config" in value && typeof value.transition === "function";
9
+ }
10
+ /** Short description of a value for construction-time error messages. */
11
+ function describeValue(value) {
12
+ if (value === null) return "null";
13
+ if (Array.isArray(value)) return "an array";
14
+ if (typeof value !== "object") return typeof value;
15
+ if (isMachineLike(value)) return getAgentExecutionOptions(value) ? "a machine whose setupAgent(...) declared no models" : "a machine not built by setupAgent(...).createMachine";
16
+ if (typeof value.createMachine === "function") return "a setupAgent(...) result that declared no models";
17
+ const keys = Object.keys(value);
18
+ return keys.length ? `an object with keys ${keys.join(", ")}` : "an empty object";
19
+ }
20
+ /**
21
+ * Normalizes an adapter's first argument to its options object. Accepts the
22
+ * options object itself (`{ models }`, `{ resolveModel }`), a `setupAgent(...)`
23
+ * result (its `models`), or a machine built by `setupAgent(...).createMachine`
24
+ * (the `models` registered for it). Provider-free: the adapter decides what the
25
+ * model values are. Throws, naming what it got, for anything else. @internal
26
+ */
27
+ function resolveModelSource(adapter, source) {
28
+ if (isRecord(source)) {
29
+ if (typeof source.createMachine === "function") {
30
+ if (hasEntries(source.models)) return { models: source.models };
31
+ } else if (isMachineLike(source)) {
32
+ const models = getAgentExecutionOptions(source)?.models;
33
+ if (hasEntries(models)) return { models };
34
+ } else if (isRecord(source.models) || typeof source.resolveModel === "function") return source;
35
+ }
36
+ throw new TypeError(`${adapter}: expected { models }, { resolveModel }, a setupAgent(...) result with models, or a machine from its createMachine; got ${describeValue(source)}.`);
37
+ }
38
+ //#endregion
39
+ export { resolveModelSource as t };