@statelyai/agent 2.0.0-alpha.18 → 2.0.0-alpha.19

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 (38) hide show
  1. package/dist/ai-sdk.cjs +4 -2
  2. package/dist/ai-sdk.d.cts +1 -1
  3. package/dist/ai-sdk.d.mts +1 -1
  4. package/dist/ai-sdk.mjs +3 -2
  5. package/dist/{decision-C11xuud2.mjs → decision-DsIkEuHz.mjs} +48 -28
  6. package/dist/{decision-DnQCQPew.cjs → decision-t26zsnSR.cjs} +64 -43
  7. package/dist/{event-log-store-CQJq8_v4.d.cts → event-log-store-Bz7HDBkE.d.cts} +11 -12
  8. package/dist/{event-log-store-B-1fcfkT.mjs → event-log-store-DmIDosD6.mjs} +22 -14
  9. package/dist/{event-log-store-yquOV1TX.cjs → event-log-store-a_TKy1gk.cjs} +22 -14
  10. package/dist/{event-log-store-BrC9Q1xW.d.mts → event-log-store-hrA1vqtN.d.mts} +11 -12
  11. package/dist/index.cjs +265 -109
  12. package/dist/index.d.cts +136 -80
  13. package/dist/index.d.mts +136 -80
  14. package/dist/index.mjs +262 -107
  15. package/dist/machines.cjs +13 -17
  16. package/dist/machines.d.cts +14 -17
  17. package/dist/machines.d.mts +14 -17
  18. package/dist/machines.mjs +13 -17
  19. package/dist/otel.cjs +1 -0
  20. package/dist/otel.d.cts +1 -1
  21. package/dist/otel.d.mts +1 -1
  22. package/dist/{run-agent-r9OD4z8F.d.cts → run-agent--4bbms-D.d.cts} +121 -48
  23. package/dist/{run-agent-DQIDikfd.d.mts → run-agent-CwmzAZwj.d.mts} +121 -48
  24. package/dist/{setup-agent-C3ETi_HZ.cjs → setup-agent-BFA4VKpN.cjs} +31 -33
  25. package/dist/{setup-agent-BrE2zFDy.mjs → setup-agent-CPFPN06s.mjs} +31 -28
  26. package/dist/sqlite.cjs +3 -9
  27. package/dist/sqlite.d.cts +1 -1
  28. package/dist/sqlite.d.mts +1 -1
  29. package/dist/sqlite.mjs +3 -9
  30. package/dist/{text-logic-VcWqO-Cl.d.cts → text-logic-Cavva1W6.d.cts} +24 -8
  31. package/dist/{text-logic-RvnlD-An.d.mts → text-logic-Er5KkTX6.d.mts} +24 -8
  32. package/dist/validate.cjs +436 -0
  33. package/dist/validate.d.cts +31 -0
  34. package/dist/validate.d.mts +31 -0
  35. package/dist/validate.mjs +411 -0
  36. package/package.json +15 -1
  37. package/schemas/agent-workflow.json +2 -2
  38. package/skills/generate-machine/SKILL.md +12 -14
@@ -111,7 +111,7 @@ async function assertEventLogStoreConformance(create) {
111
111
  caught = error;
112
112
  }
113
113
  if (!(caught instanceof AgentEventLogConflictError)) fail("a stale expectedIndex must throw AgentEventLogConflictError");
114
- if (caught.threadId !== "t" || caught.expectedIndex !== 0 || caught.actualLength !== 1) fail("conflict error must carry threadId, expectedIndex, and the actual length");
114
+ if (caught.threadId !== "t" || caught.expectedIndex !== 0 || caught.actualIndex !== 1) fail("conflict error must carry threadId, expectedIndex, and the actual index");
115
115
  }
116
116
  {
117
117
  const store = await create();
@@ -240,10 +240,10 @@ async function assertEventLogStoreConformance(create) {
240
240
  assertJsonEqual((await store.read("fork-1")).map((e) => e.index), [0], "fork with upToIndex 1 must copy only entry 0");
241
241
  await store.fork({
242
242
  threadId: "src",
243
- newThreadId: "fork-id",
244
- atEventId: "evt_1"
243
+ newThreadId: "fork-2",
244
+ upToIndex: 2
245
245
  });
246
- assertJsonEqual((await store.read("fork-id")).map((e) => e.id), ["evt_0", "evt_1"], "fork with atEventId must include the named entry");
246
+ assertJsonEqual((await store.read("fork-2")).map((e) => e.id), ["evt_0", "evt_1"], "fork with upToIndex 2 must copy entries 0 and 1 only");
247
247
  await store.append({
248
248
  threadId: "fork-1",
249
249
  expectedIndex: 1,
@@ -271,6 +271,17 @@ async function assertEventLogStoreConformance(create) {
271
271
  caughtUnknown = error;
272
272
  }
273
273
  if (!(caughtUnknown instanceof Error) || caughtUnknown instanceof AgentEventLogConflictError) fail("forking an unknown source thread must reject with a plain Error");
274
+ let caughtRange;
275
+ try {
276
+ await store.fork({
277
+ threadId: "src",
278
+ newThreadId: "fork-range",
279
+ upToIndex: 99
280
+ });
281
+ } catch (error) {
282
+ caughtRange = error;
283
+ }
284
+ if (!(caughtRange instanceof Error) || caughtRange instanceof AgentEventLogConflictError) fail("forking past the source length must reject with a plain Error");
274
285
  }
275
286
  }
276
287
  //#endregion
@@ -352,18 +363,18 @@ function assertAgentLogEntry(entry) {
352
363
  /**
353
364
  * Rejection from {@link AgentEventLogStore.append} when the thread's stored
354
365
  * length is not the `expectedIndex` the writer held — a concurrent writer
355
- * appended first. `actualLength` is the length core found.
366
+ * appended first. `actualIndex` is the next index the store would accept.
356
367
  */
357
368
  var AgentEventLogConflictError = class extends require_errors.AgentError {
358
369
  threadId;
359
370
  expectedIndex;
360
- actualLength;
361
- constructor(threadId, expectedIndex, actualLength) {
362
- super("event-log-conflict", `AgentEventLogStore.append: length conflict on thread "${threadId}": expected length ${expectedIndex} but found ${actualLength} — a concurrent writer won.`);
371
+ actualIndex;
372
+ constructor(threadId, expectedIndex, actualIndex) {
373
+ super("event-log-conflict", `AgentEventLogStore.append: index conflict on thread "${threadId}": expected index ${expectedIndex} but found ${actualIndex} — a concurrent writer won.`);
363
374
  this.name = "AgentEventLogConflictError";
364
375
  this.threadId = threadId;
365
376
  this.expectedIndex = expectedIndex;
366
- this.actualLength = actualLength;
377
+ this.actualIndex = actualIndex;
367
378
  }
368
379
  };
369
380
  /**
@@ -402,14 +413,11 @@ function createInMemoryEventLogStore() {
402
413
  async length(threadId) {
403
414
  return threads.get(threadId)?.length ?? 0;
404
415
  },
405
- async fork({ threadId, newThreadId, upToIndex, atEventId }) {
416
+ async fork({ threadId, newThreadId, upToIndex }) {
406
417
  if ((threads.get(newThreadId)?.length ?? 0) > 0) throw new Error(`AgentEventLogStore.fork: newThreadId "${newThreadId}" already has entries.`);
407
418
  const source = threads.get(threadId);
408
419
  if (!source) throw new Error(`AgentEventLogStore.fork: unknown source thread "${threadId}".`);
409
- if (upToIndex !== void 0 && atEventId !== void 0) throw new Error("AgentEventLogStore.fork: pass either upToIndex or atEventId, not both.");
410
- const eventIndex = atEventId === void 0 ? void 0 : source.findIndex((entry) => entry.id === atEventId);
411
- if (atEventId !== void 0 && eventIndex === -1) throw new Error(`AgentEventLogStore.fork: thread "${threadId}" has no event id "${atEventId}".`);
412
- const upTo = eventIndex === void 0 ? upToIndex ?? source.length : eventIndex + 1;
420
+ const upTo = upToIndex ?? source.length;
413
421
  if (upTo < 0 || upTo > source.length) throw new Error(`AgentEventLogStore.fork: thread "${threadId}" (length ${source.length}) has no index ${upTo} to fork up to.`);
414
422
  threads.set(newThreadId, source.slice(0, upTo).map((entry) => clone(entry)));
415
423
  }
@@ -107,30 +107,29 @@ interface AgentEventLogStore {
107
107
  /** The thread's current log length (0 for an unknown thread) — the next `expectedIndex`. */
108
108
  length(threadId: string): Promise<number>;
109
109
  /**
110
- * Copy a prefix onto a fresh, empty `newThreadId` — either `[0, upToIndex)`
111
- * or through the inclusive `atEventId`. With neither cutoff the full source
112
- * is copied. The fork then appends independently. Rejects (plain `Error`) if
113
- * `newThreadId` already has entries, the source/id is unknown, or both cutoff
114
- * forms are supplied. Implementations may copy-on-write or physically copy;
115
- * observable behavior must match a full copy.
110
+ * Copy the prefix `[0, upToIndex)` onto a fresh, empty `newThreadId`.
111
+ * Without `upToIndex` the full source is copied. The fork then appends
112
+ * independently. Rejects (plain `Error`) if `newThreadId` already has
113
+ * entries, the source is unknown, or `upToIndex` is out of range.
114
+ * Implementations may copy-on-write or physically copy; observable behavior
115
+ * must match a full copy.
116
116
  */
117
117
  fork(input: {
118
118
  threadId: string;
119
- newThreadId: string;
120
- upToIndex?: number; /** Inclusive event-id cutoff. Mutually exclusive with `upToIndex`. */
121
- atEventId?: string;
119
+ newThreadId: string; /** Exclusive index cutoff. */
120
+ upToIndex?: number;
122
121
  }): Promise<void>;
123
122
  }
124
123
  /**
125
124
  * Rejection from {@link AgentEventLogStore.append} when the thread's stored
126
125
  * length is not the `expectedIndex` the writer held — a concurrent writer
127
- * appended first. `actualLength` is the length core found.
126
+ * appended first. `actualIndex` is the next index the store would accept.
128
127
  */
129
128
  declare class AgentEventLogConflictError extends AgentError {
130
129
  readonly threadId: string;
131
130
  readonly expectedIndex: number;
132
- readonly actualLength: number;
133
- constructor(threadId: string, expectedIndex: number, actualLength: number);
131
+ readonly actualIndex: number;
132
+ constructor(threadId: string, expectedIndex: number, actualIndex: number);
134
133
  }
135
134
  /**
136
135
  * In-memory reference store, and the baseline the conformance suite runs