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.
- package/CHANGELOG.md +6 -0
- package/dist/agent-runtime/archive-spill.d.ts +61 -0
- package/dist/agent-runtime/archive-spill.d.ts.map +1 -0
- package/dist/agent-runtime/branch-contract.d.ts +102 -0
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -0
- package/dist/agent-runtime/branch-events.d.ts +18 -0
- package/dist/agent-runtime/branch-events.d.ts.map +1 -0
- package/dist/agent-runtime/branch-identities.d.ts +20 -0
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -0
- package/dist/agent-runtime/branch-messages.d.ts +32 -0
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -0
- package/dist/agent-runtime/branch-observations.d.ts +104 -0
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -0
- package/dist/agent-runtime/branch-provider.d.ts +130 -0
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -0
- package/dist/agent-runtime/branch-replay.d.ts +426 -0
- package/dist/agent-runtime/branch-replay.d.ts.map +1 -0
- package/dist/agent-runtime/branch-source.d.ts +16 -0
- package/dist/agent-runtime/branch-source.d.ts.map +1 -0
- package/dist/agent-runtime/branch-transitions.d.ts +6 -0
- package/dist/agent-runtime/branch-transitions.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-history.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts +1 -0
- package/dist/agent-runtime/store-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts +5 -0
- package/dist/agent-runtime/store-branch.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts +4 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +6 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +90 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-archive.d.ts +8 -0
- package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -0
- package/dist/agent-runtime/store-memory-events.d.ts +7 -0
- package/dist/agent-runtime/store-memory-events.d.ts.map +1 -0
- package/dist/agent-runtime/store-memory.d.ts +1 -1
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store-purge.d.ts +2 -0
- package/dist/agent-runtime/store-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-run.d.ts +2 -2
- package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +1 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
- package/dist/agent-runtime/store-reducer.d.ts +2 -2
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +3 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/durability/events.d.ts +4 -0
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +1 -2
- package/dist/entrypoints/agent-runtime/harness.js +4 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -5
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -3
- package/dist/entrypoints/agent-runtime/testing.js +89 -5
- package/dist/entrypoints/agent-runtime.d.ts +1 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +25 -15
- package/dist/entrypoints/tools.js +5 -3
- package/dist/{index-c17xcx4k.js → index-56yx8dxp.js} +19 -96
- package/dist/{index-0gs4ymfj.js → index-6qeqdz0z.js} +7 -1
- package/dist/{index-924500c3.js → index-79zxnh52.js} +2 -2
- package/dist/{index-8rstkvcf.js → index-7c046kxr.js} +1 -1
- package/dist/{index-tjdsyrys.js → index-bm180f2d.js} +203 -83
- package/dist/{index-5p55xreg.js → index-e9rbhw1s.js} +67 -29
- package/dist/index-s2bgwsyr.js +2280 -0
- package/dist/index-snef22zr.js +94 -0
- package/dist/{index-c0hffcmj.js → index-zbssway3.js} +19 -2
- package/llms/agent-runtime.3.txt +3 -0
- package/llms/agent-runtime.txt +60 -0
- package/llms-full.txt +63 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/index-8ks9b85e.js +0 -129
- package/dist/index-d2h99n7d.js +0 -1071
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
AgentStoreEventEnvelopeSchema2,
|
|
3
3
|
AgentStoreEventPageSchema2,
|
|
4
4
|
AgentRecoverablePageSchema2
|
|
5
|
-
} from "./index-
|
|
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-
|
|
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
|
|
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
|
}
|