stitchkit 0.110.1 → 0.110.2

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 (81) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/agent-runtime/archive-spill.d.ts +61 -0
  3. package/dist/agent-runtime/archive-spill.d.ts.map +1 -0
  4. package/dist/agent-runtime/branch-contract.d.ts +102 -0
  5. package/dist/agent-runtime/branch-contract.d.ts.map +1 -0
  6. package/dist/agent-runtime/branch-events.d.ts +18 -0
  7. package/dist/agent-runtime/branch-events.d.ts.map +1 -0
  8. package/dist/agent-runtime/branch-identities.d.ts +20 -0
  9. package/dist/agent-runtime/branch-identities.d.ts.map +1 -0
  10. package/dist/agent-runtime/branch-messages.d.ts +32 -0
  11. package/dist/agent-runtime/branch-messages.d.ts.map +1 -0
  12. package/dist/agent-runtime/branch-observations.d.ts +104 -0
  13. package/dist/agent-runtime/branch-observations.d.ts.map +1 -0
  14. package/dist/agent-runtime/branch-provider.d.ts +130 -0
  15. package/dist/agent-runtime/branch-provider.d.ts.map +1 -0
  16. package/dist/agent-runtime/branch-replay.d.ts +426 -0
  17. package/dist/agent-runtime/branch-replay.d.ts.map +1 -0
  18. package/dist/agent-runtime/branch-source.d.ts +16 -0
  19. package/dist/agent-runtime/branch-source.d.ts.map +1 -0
  20. package/dist/agent-runtime/branch-transitions.d.ts +6 -0
  21. package/dist/agent-runtime/branch-transitions.d.ts.map +1 -0
  22. package/dist/agent-runtime/sqlite-history.d.ts.map +1 -1
  23. package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
  24. package/dist/agent-runtime/store-archive.d.ts +1 -0
  25. package/dist/agent-runtime/store-archive.d.ts.map +1 -1
  26. package/dist/agent-runtime/store-branch.d.ts +5 -0
  27. package/dist/agent-runtime/store-branch.d.ts.map +1 -0
  28. package/dist/agent-runtime/store-conformance-branch.d.ts +4 -0
  29. package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -0
  30. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  31. package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
  32. package/dist/agent-runtime/store-create.d.ts +1 -1
  33. package/dist/agent-runtime/store-create.d.ts.map +1 -1
  34. package/dist/agent-runtime/store-driver-contract.d.ts +6 -0
  35. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  36. package/dist/agent-runtime/store-events.d.ts +90 -0
  37. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  38. package/dist/agent-runtime/store-memory-archive.d.ts +8 -0
  39. package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -0
  40. package/dist/agent-runtime/store-memory-events.d.ts +7 -0
  41. package/dist/agent-runtime/store-memory-events.d.ts.map +1 -0
  42. package/dist/agent-runtime/store-memory.d.ts +1 -1
  43. package/dist/agent-runtime/store-memory.d.ts.map +1 -1
  44. package/dist/agent-runtime/store-purge.d.ts +2 -0
  45. package/dist/agent-runtime/store-purge.d.ts.map +1 -1
  46. package/dist/agent-runtime/store-reduce-run.d.ts +2 -2
  47. package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -1
  48. package/dist/agent-runtime/store-reduce-shared.d.ts +1 -0
  49. package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
  50. package/dist/agent-runtime/store-reducer.d.ts +2 -2
  51. package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
  52. package/dist/agent-runtime/store.d.ts +3 -0
  53. package/dist/agent-runtime/store.d.ts.map +1 -1
  54. package/dist/durability/events.d.ts +4 -0
  55. package/dist/durability/events.d.ts.map +1 -1
  56. package/dist/entrypoints/agent-runtime/coding-tools.js +1 -2
  57. package/dist/entrypoints/agent-runtime/harness.js +4 -3
  58. package/dist/entrypoints/agent-runtime/sandbox.js +3 -5
  59. package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -3
  60. package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -3
  61. package/dist/entrypoints/agent-runtime/testing.js +89 -5
  62. package/dist/entrypoints/agent-runtime.d.ts +1 -0
  63. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  64. package/dist/entrypoints/agent-runtime.js +25 -15
  65. package/dist/entrypoints/tools.js +5 -3
  66. package/dist/{index-c17xcx4k.js → index-56yx8dxp.js} +19 -96
  67. package/dist/{index-0gs4ymfj.js → index-6qeqdz0z.js} +7 -1
  68. package/dist/{index-924500c3.js → index-79zxnh52.js} +2 -2
  69. package/dist/{index-8rstkvcf.js → index-7c046kxr.js} +1 -1
  70. package/dist/{index-tjdsyrys.js → index-bm180f2d.js} +203 -83
  71. package/dist/{index-5p55xreg.js → index-e9rbhw1s.js} +67 -29
  72. package/dist/index-s2bgwsyr.js +2280 -0
  73. package/dist/index-snef22zr.js +94 -0
  74. package/dist/{index-c0hffcmj.js → index-zbssway3.js} +19 -2
  75. package/llms/agent-runtime.3.txt +3 -0
  76. package/llms/agent-runtime.txt +60 -0
  77. package/llms-full.txt +63 -0
  78. package/llms.txt +1 -1
  79. package/package.json +1 -1
  80. package/dist/index-8ks9b85e.js +0 -129
  81. package/dist/index-d2h99n7d.js +0 -1071
@@ -2,7 +2,7 @@ import {
2
2
  AgentStoreEventEnvelopeSchema2,
3
3
  AgentStoreEventPageSchema2,
4
4
  AgentRecoverablePageSchema2
5
- } from "./index-0gs4ymfj.js";
5
+ } from "./index-6qeqdz0z.js";
6
6
  import {
7
7
  AgentRecordIdSchema2,
8
8
  AgentMessageSchema2
@@ -15,12 +15,64 @@ import {
15
15
  AgentHistoryMutationSchema2,
16
16
  isActiveRunState,
17
17
  replaceMessage,
18
+ ArchiveSpillSchema,
18
19
  createAgentRuntimeStore2
19
- } from "./index-d2h99n7d.js";
20
+ } from "./index-s2bgwsyr.js";
20
21
 
21
22
  // src/agent-runtime/store-memory.ts
23
+ import { z as z2 } from "zod";
24
+
25
+ // src/agent-runtime/store-memory-archive.ts
22
26
  import { z } from "zod";
23
- var RecoverableCursorSchema = z.tuple([AgentRecordIdSchema2, AgentRecordIdSchema2]);
27
+ var memoryArchive = {
28
+ async export(transaction, conversationId) {
29
+ return {
30
+ projections: [],
31
+ spills: z.array(z.json()).parse(structuredClone(transaction.spills.get(conversationId) ?? []))
32
+ };
33
+ },
34
+ async import(transaction, archive) {
35
+ const spills = archive.spills.map((value) => ArchiveSpillSchema.parse(value));
36
+ const occupied = new Set([...transaction.spills.values()].flatMap((entries) => entries.map((spill) => spill.reference)));
37
+ for (const spill of spills) {
38
+ if (occupied.has(spill.reference))
39
+ throw new TypeError("Conversation archive spill identity is already present");
40
+ occupied.add(spill.reference);
41
+ }
42
+ transaction.spills.set(archive.conversationId, structuredClone(spills));
43
+ }
44
+ };
45
+
46
+ // src/agent-runtime/store-memory-events.ts
47
+ var memoryEvents = {
48
+ async append(transaction, draft) {
49
+ const current = transaction.events.get(draft.conversationId) ?? [];
50
+ const event = AgentStoreEventEnvelopeSchema2.parse({
51
+ ...draft,
52
+ seq: (current.at(-1)?.seq ?? 0) + 1
53
+ });
54
+ if (current.some((candidate) => candidate.eventId === event.eventId)) {
55
+ throw new TypeError("Agent store event identity is already present");
56
+ }
57
+ transaction.events.set(draft.conversationId, [...current, event]);
58
+ return event;
59
+ },
60
+ async list(transaction, input) {
61
+ const selected = (transaction.events.get(input.conversationId) ?? []).filter((event) => (input.fromSeq === undefined || event.seq >= input.fromSeq) && (input.toSeq === undefined || event.seq <= input.toSeq));
62
+ const items = selected.slice(0, input.limit);
63
+ const last = items.at(-1);
64
+ return AgentStoreEventPageSchema2.parse({
65
+ items,
66
+ ...selected.length > items.length && last ? { nextSeq: last.seq + 1 } : {}
67
+ });
68
+ },
69
+ async find(transaction, input) {
70
+ return (transaction.events.get(input.conversationId) ?? []).find((event) => event.eventId === input.eventId);
71
+ }
72
+ };
73
+
74
+ // src/agent-runtime/store-memory.ts
75
+ var RecoverableCursorSchema = z2.tuple([AgentRecordIdSchema2, AgentRecordIdSchema2]);
24
76
  function recoverableCursor(input) {
25
77
  return JSON.stringify([input.conversationId, input.run.id]);
26
78
  }
@@ -46,6 +98,9 @@ function cloneHistoryMap(source) {
46
98
  ]));
47
99
  }
48
100
  var memoryConversations = {
101
+ async isEmpty(transaction, id) {
102
+ return !transaction.heads.has(id) && !transaction.runs.has(id) && !transaction.admissions.has(id) && !transaction.seeds.has(id) && !transaction.histories.has(id) && !transaction.events.has(id) && !transaction.spills.has(id);
103
+ },
49
104
  async isPurged(transaction, conversationId) {
50
105
  return transaction.purged.has(conversationId);
51
106
  },
@@ -57,6 +112,7 @@ var memoryConversations = {
57
112
  transaction.seeds.delete(conversationId);
58
113
  transaction.histories.delete(conversationId);
59
114
  transaction.events.delete(conversationId);
115
+ transaction.spills.delete(conversationId);
60
116
  }
61
117
  };
62
118
  var memoryHead = {
@@ -140,6 +196,10 @@ var memorySeeds = {
140
196
  }
141
197
  };
142
198
  var memoryHistory = {
199
+ async restore(transaction, input) {
200
+ const compacted = new Set(input.compactedMessageIds);
201
+ transaction.histories.set(input.conversationId, input.messages.filter((message) => !compacted.has(message.id)).map((message) => AgentMessageSchema2.parse(structuredClone(message))));
202
+ },
143
203
  async load(transaction, conversationId) {
144
204
  return (transaction.histories.get(conversationId) ?? []).map((message) => AgentMessageSchema2.parse(structuredClone(message)));
145
205
  },
@@ -181,32 +241,6 @@ var memoryHistory = {
181
241
  ]);
182
242
  }
183
243
  };
184
- var memoryEvents = {
185
- async append(transaction, draft) {
186
- const current = transaction.events.get(draft.conversationId) ?? [];
187
- const event = AgentStoreEventEnvelopeSchema2.parse({
188
- ...draft,
189
- seq: (current.at(-1)?.seq ?? 0) + 1
190
- });
191
- if (current.some((candidate) => candidate.eventId === event.eventId)) {
192
- throw new TypeError("Agent store event identity is already present");
193
- }
194
- transaction.events.set(draft.conversationId, [...current, event]);
195
- return event;
196
- },
197
- async list(transaction, input) {
198
- const selected = (transaction.events.get(input.conversationId) ?? []).filter((event) => (input.fromSeq === undefined || event.seq >= input.fromSeq) && (input.toSeq === undefined || event.seq <= input.toSeq));
199
- const items = selected.slice(0, input.limit);
200
- const last = items.at(-1);
201
- return AgentStoreEventPageSchema2.parse({
202
- items,
203
- ...selected.length > items.length && last ? { nextSeq: last.seq + 1 } : {}
204
- });
205
- },
206
- async find(transaction, input) {
207
- return (transaction.events.get(input.conversationId) ?? []).find((event) => event.eventId === input.eventId);
208
- }
209
- };
210
244
  function scanMemoryRecoverable(runs, input) {
211
245
  const descriptors = [...runs].flatMap(([conversationId, conversationRuns]) => [...conversationRuns.values()].filter((record) => isActiveRunState(record.run.state)).map((record) => ({ conversationId, run: record.run }))).sort((left, right) => left.conversationId.localeCompare(right.conversationId) || left.run.id.localeCompare(right.run.id));
212
246
  const cursorTuple = input.cursor ? parseRecoverableCursor(input.cursor) : undefined;
@@ -230,6 +264,7 @@ function createMemoryAgentRuntimeStore2() {
230
264
  let seeds = new Map;
231
265
  let histories = new Map;
232
266
  let events = new Map;
267
+ let spills = new Map;
233
268
  let transactionTail = Promise.resolve();
234
269
  const driver = {
235
270
  async transaction(work) {
@@ -243,6 +278,7 @@ function createMemoryAgentRuntimeStore2() {
243
278
  });
244
279
  const transaction = {
245
280
  purged: new Set(purged),
281
+ spills: structuredClone(spills),
246
282
  heads: cloneHeadMap(heads),
247
283
  runs: cloneNestedMap(runs, (record) => AgentStoredRunSchema2.parse(structuredClone(record))),
248
284
  admissions: cloneNestedMap(admissions, (receipt) => AgentAdmissionReceiptSchema2.parse(structuredClone(receipt))),
@@ -256,6 +292,7 @@ function createMemoryAgentRuntimeStore2() {
256
292
  try {
257
293
  const result = await work(transaction);
258
294
  purged = transaction.purged;
295
+ spills = transaction.spills;
259
296
  heads = transaction.heads;
260
297
  runs = transaction.runs;
261
298
  admissions = transaction.admissions;
@@ -274,6 +311,7 @@ function createMemoryAgentRuntimeStore2() {
274
311
  seeds: memorySeeds,
275
312
  history: memoryHistory,
276
313
  events: memoryEvents,
314
+ archive: memoryArchive,
277
315
  async scanRecoverable(input) {
278
316
  return scanMemoryRecoverable(runs, input);
279
317
  }